wui-components-v2 1.2.38 → 1.2.40
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/form-control/form-control.vue +22 -2
- package/components/report-table/report-table.vue +6 -3
- package/components/search/search.vue +42 -13
- package/components/wui-list/wui-list.vue +10 -2
- package/components/wui-select-list/wui-select-list.vue +8 -1
- package/components/wui-select-popup/wui-select-popup.vue +8 -1
- package/package.json +1 -1
|
@@ -122,9 +122,19 @@ function initFormData() {
|
|
|
122
122
|
ControlTypeSupportor.getControlType(item, props.entity && props.entity[item.sourceId]) === 'eetime' ||
|
|
123
123
|
ControlTypeSupportor.getControlType(item, props.entity && props.entity[item.sourceId]) === 'date'
|
|
124
124
|
) {
|
|
125
|
+
const entityVal = props.entity && props.entity[item.sourceId]
|
|
126
|
+
// 解析默认值:支持 $$currentD(今天)、纯数字时间戳、日期字符串
|
|
127
|
+
const defaultVal = item.transDefaultValue || item.defaultValue || ''
|
|
128
|
+
const resolvedDefault = defaultVal
|
|
129
|
+
? defaultVal === '$$currentD'
|
|
130
|
+
? dayjs().format('YYYY-MM-DD')
|
|
131
|
+
: /^\d+$/.test(String(defaultVal))
|
|
132
|
+
? dayjs(Number(defaultVal)).format('YYYY-MM-DD')
|
|
133
|
+
: defaultVal
|
|
134
|
+
: ''
|
|
125
135
|
return (models[item.sourceId] =
|
|
126
|
-
(
|
|
127
|
-
(
|
|
136
|
+
(entityVal && dayjs(entityVal).valueOf()) ||
|
|
137
|
+
(resolvedDefault && dayjs(resolvedDefault).valueOf()) ||
|
|
128
138
|
null)
|
|
129
139
|
}
|
|
130
140
|
|
|
@@ -588,6 +598,16 @@ function submit() {
|
|
|
588
598
|
} else {
|
|
589
599
|
data[key] = model.value[key]
|
|
590
600
|
}
|
|
601
|
+
} else if (ControlTypeSupportor.getControlType(item) === 'date') {
|
|
602
|
+
data[key] = model.value[key] ? dayjs(model.value[key]).format('YYYY-MM-DD') : ''
|
|
603
|
+
} else if (ControlTypeSupportor.getControlType(item) === 'datetime') {
|
|
604
|
+
data[key] = model.value[key] ? dayjs(model.value[key]).format('YYYY-MM-DD HH:mm:ss') : ''
|
|
605
|
+
} else if (ControlTypeSupportor.getControlType(item) === 'time') {
|
|
606
|
+
data[key] = model.value[key] ? dayjs(model.value[key]).format('HH:mm:ss') : ''
|
|
607
|
+
} else if (ControlTypeSupportor.getControlType(item) === 'date-YY') {
|
|
608
|
+
data[key] = model.value[key] ? dayjs(model.value[key]).format('YYYY') : ''
|
|
609
|
+
} else if (ControlTypeSupportor.getControlType(item) === 'date-M1') {
|
|
610
|
+
data[key] = model.value[key] ? dayjs(model.value[key]).format('YYYY-MM') : ''
|
|
591
611
|
} else {
|
|
592
612
|
data[key] = model.value[key]
|
|
593
613
|
}
|
|
@@ -213,7 +213,12 @@ async function fetchData() {
|
|
|
213
213
|
timeCriteria.value.forEach(item => {
|
|
214
214
|
const defaultVal = item.transDefaultValue || item.defaultValue
|
|
215
215
|
if (defaultVal && defaultVal !== '') {
|
|
216
|
-
const formatted =
|
|
216
|
+
const formatted =
|
|
217
|
+
defaultVal === '$$currentD'
|
|
218
|
+
? dayjs().format('YYYY-MM-DD')
|
|
219
|
+
: /^\d+$/.test(String(defaultVal))
|
|
220
|
+
? dayjs(Number(defaultVal)).format('YYYY-MM-DD')
|
|
221
|
+
: defaultVal
|
|
217
222
|
defaultTimeData = defaultTimeData
|
|
218
223
|
? `${defaultTimeData}&c_${item.sourceId}=${formatted}`
|
|
219
224
|
: `c_${item.sourceId}=${formatted}`
|
|
@@ -274,7 +279,6 @@ function submitSearch(data: any) {
|
|
|
274
279
|
const val = fdata[item.sourceId]
|
|
275
280
|
if (val === undefined || val === null || val === '') return
|
|
276
281
|
if (Array.isArray(val) && val.length === 0) return
|
|
277
|
-
if (item.transDefaultValue && String(val) === String(item.transDefaultValue)) return
|
|
278
282
|
// 时间戳转日期字符串
|
|
279
283
|
const formatted = typeof val === 'number' ? dayjs(val).format('YYYY-MM-DD') : val
|
|
280
284
|
timeData = timeData ? `${timeData}&c_${item.sourceId}=${formatted}` : `c_${item.sourceId}=${formatted}`
|
|
@@ -302,7 +306,6 @@ function submitTimeFilter() {
|
|
|
302
306
|
const val = fdata[item.sourceId]
|
|
303
307
|
if (val === undefined || val === null || val === '') return
|
|
304
308
|
if (Array.isArray(val) && val.length === 0) return
|
|
305
|
-
if (item.transDefaultValue && String(val) === String(item.transDefaultValue)) return
|
|
306
309
|
// 时间戳转日期字符串
|
|
307
310
|
const formatted = typeof val === 'number' ? dayjs(val).format('YYYY-MM-DD') : val
|
|
308
311
|
data = data ? `${data}&c_${item.sourceId}=${formatted}` : `c_${item.sourceId}=${formatted}`
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import { computed, defineEmits, defineOptions, defineProps, ref } from 'vue'
|
|
3
3
|
import type { Enums, Fields, Split2TabCriterias } from '../../type'
|
|
4
4
|
import formControl from '../form-control/form-control.vue'
|
|
5
|
+
import ControlTypeSupportor from '../../utils/control-type-supportor'
|
|
5
6
|
import { useManualThemeStore } from '../../store/manualThemeStore'
|
|
6
7
|
|
|
7
8
|
defineOptions({ name: 'Search' })
|
|
@@ -21,19 +22,32 @@ const show = ref(false)
|
|
|
21
22
|
const search = ref('')
|
|
22
23
|
const formControlRef = ref()
|
|
23
24
|
const entity = ref({})
|
|
25
|
+
// 判断字段实际渲染的控件类型是否为纯文本输入(优先 extControlType,回退 controlType)
|
|
26
|
+
const isTextCriterion = (item: Fields) => ControlTypeSupportor.getControlType(item) === 'text'
|
|
27
|
+
// 用于 wd-search 的搜索字段:primaryCriterion 存在时直接使用,否则取 criteria 中第一个文本类型的筛选项
|
|
28
|
+
const searchCriterion = computed(() => {
|
|
29
|
+
if (props.primaryCriterion) {
|
|
30
|
+
return props.primaryCriterion
|
|
31
|
+
}
|
|
32
|
+
return props.criteria.find(item => isTextCriterion(item)) || null
|
|
33
|
+
})
|
|
34
|
+
// 仅当 searchCriterion 存在时显示搜索框
|
|
35
|
+
const showSearch = computed(() => searchCriterion.value !== null)
|
|
24
36
|
const filterCriteria = computed(() => {
|
|
25
37
|
const criteriaSourceIds = props.split2TabCriterias?.map(item => item.sourceId) || []
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
// 仅当搜索框真正显示时,才把 searchCriterion 从筛选弹窗中排除;
|
|
39
|
+
// 否则(extControlType 存在)该字段应回落到筛选弹窗中参与筛选
|
|
40
|
+
const searchSourceId = showSearch.value ? searchCriterion.value?.sourceId : undefined
|
|
41
|
+
if (!searchSourceId) return props.criteria.filter(item => !criteriaSourceIds.includes(item.sourceId))
|
|
42
|
+
return props.criteria.filter(item => ![searchSourceId, ...criteriaSourceIds].includes(item.sourceId))
|
|
29
43
|
})
|
|
30
44
|
function handleClose() {
|
|
31
45
|
show.value = false
|
|
32
46
|
}
|
|
33
47
|
function handleSubmit() {
|
|
34
48
|
if (!formControlRef.value) {
|
|
35
|
-
if (!
|
|
36
|
-
const data = `c_${
|
|
49
|
+
if (!showSearch.value || !searchCriterion.value?.sourceId) return
|
|
50
|
+
const data = `c_${searchCriterion.value.sourceId}=${search.value}`
|
|
37
51
|
emits('submit', data)
|
|
38
52
|
handleClose()
|
|
39
53
|
return
|
|
@@ -41,19 +55,28 @@ function handleSubmit() {
|
|
|
41
55
|
formControlRef.value.submit().then((fdata: any) => {
|
|
42
56
|
entity.value = {
|
|
43
57
|
...fdata,
|
|
44
|
-
...(
|
|
58
|
+
...(showSearch.value && searchCriterion.value?.sourceId
|
|
59
|
+
? { [searchCriterion.value.sourceId]: search.value }
|
|
60
|
+
: {}),
|
|
45
61
|
}
|
|
46
62
|
let data = ''
|
|
47
63
|
|
|
48
|
-
if (
|
|
49
|
-
data = `c_${
|
|
64
|
+
if (showSearch.value && searchCriterion.value?.sourceId) {
|
|
65
|
+
data = `c_${searchCriterion.value.sourceId}=${search.value}`
|
|
50
66
|
}
|
|
51
67
|
|
|
52
68
|
filterCriteria.value.forEach(item => {
|
|
53
69
|
const element = fdata[item.sourceId]
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
if (
|
|
70
|
+
// 空值(空字符串、undefined、null、空数组)仍拼接 `c_${sourceId}=` 空参数,
|
|
71
|
+
// 让父组件识别「该字段已被用户清空」,从而跳过 defaultCriteriaValue 的默认值兜底
|
|
72
|
+
if (element === undefined || element === null || element === '') {
|
|
73
|
+
data = `${data}&c_${item.sourceId}=`
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
if (Array.isArray(element) && element.length === 0) {
|
|
77
|
+
data = `${data}&c_${item.sourceId}=`
|
|
78
|
+
return
|
|
79
|
+
}
|
|
57
80
|
// 跳过用户未修改的默认值(时间字段常被自动填充当前时间,不应作为查询条件)
|
|
58
81
|
if (item.transDefaultValue && String(element) === String(item.transDefaultValue)) return
|
|
59
82
|
if (item.extControlType === 'relselectvalue') {
|
|
@@ -83,11 +106,11 @@ function handleSubmit() {
|
|
|
83
106
|
|
|
84
107
|
<template>
|
|
85
108
|
<wd-config-provider :theme="theme">
|
|
86
|
-
<view v-if="
|
|
109
|
+
<view v-if="showSearch" class="w-full">
|
|
87
110
|
<wd-search
|
|
88
111
|
v-model="search"
|
|
89
112
|
cancel-txt="搜索"
|
|
90
|
-
:placeholder="`请输入${
|
|
113
|
+
:placeholder="`请输入${searchCriterion?.title || ''}搜索`"
|
|
91
114
|
@clear="handleSubmit"
|
|
92
115
|
@cancel="handleSubmit"
|
|
93
116
|
>
|
|
@@ -103,6 +126,12 @@ function handleSubmit() {
|
|
|
103
126
|
</template>
|
|
104
127
|
</wd-search>
|
|
105
128
|
</view>
|
|
129
|
+
<view v-else-if="filterCriteria.length" class="px-[8px] mt-2">
|
|
130
|
+
<wd-button block custom-class="search-filter-btn" @click="show = true">
|
|
131
|
+
<wd-icon name="filter" size="17px" class="mr-1" />
|
|
132
|
+
筛选
|
|
133
|
+
</wd-button>
|
|
134
|
+
</view>
|
|
106
135
|
<wd-popup v-model="show" position="bottom" custom-class="h-80vh" closable @close="handleClose">
|
|
107
136
|
<view class="relative box-border h-full p-1 bg-white dark:bg-[var(--wot-dark-background)]">
|
|
108
137
|
<view class="h-34px flex items-center justify-center text-black dark:text-[var(--wot-dark-color)]">筛选</view>
|
|
@@ -8,6 +8,7 @@ import Search from '../search/search.vue'
|
|
|
8
8
|
import ListTopButtons from '../list-top-buttons/list-top-buttons.vue'
|
|
9
9
|
import CardBotomButtons from '../card-botom-buttons/card-botom-buttons.vue'
|
|
10
10
|
import { generateHighResolutionID } from '../../utils/index'
|
|
11
|
+
import dayjs from 'dayjs/esm/index'
|
|
11
12
|
import productCard from '../product-card/product-card.vue'
|
|
12
13
|
import tabSearch from '../tab-search/tab-search.vue'
|
|
13
14
|
import { useEnums } from '../../composables/useEnumes'
|
|
@@ -67,7 +68,7 @@ const props = withDefaults(
|
|
|
67
68
|
sourceId: '',
|
|
68
69
|
// 查询条件默认为空
|
|
69
70
|
query: '',
|
|
70
|
-
}
|
|
71
|
+
}
|
|
71
72
|
)
|
|
72
73
|
|
|
73
74
|
const Zpaging = ref<any>(null)
|
|
@@ -181,7 +182,13 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
181
182
|
if (config.value.defaultCriteriaValue) {
|
|
182
183
|
for (const key in config.value.defaultCriteriaValue) {
|
|
183
184
|
if (Object.prototype.hasOwnProperty.call(config.value.defaultCriteriaValue, key)) {
|
|
184
|
-
|
|
185
|
+
let element = config.value.defaultCriteriaValue[key]
|
|
186
|
+
// $$currentD 占位符转换为当日时间(年-月-日),没有值则传空字符串
|
|
187
|
+
if (element === '$$currentD') {
|
|
188
|
+
element = dayjs().format('YYYY-MM-DD')
|
|
189
|
+
} else if (element === undefined || element === null) {
|
|
190
|
+
element = ''
|
|
191
|
+
}
|
|
185
192
|
if (!qre.includes(key)) {
|
|
186
193
|
qre = `${qre}&${key}=${element}`
|
|
187
194
|
}
|
|
@@ -190,6 +197,7 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
190
197
|
}
|
|
191
198
|
|
|
192
199
|
try {
|
|
200
|
+
console.log('qre', qre)
|
|
193
201
|
const res = await pageKey(internalSourceId.value, mainCode.value, qre) // 获取key
|
|
194
202
|
const data = await listData(res.key, pageNo, pageSize) // 获取数据
|
|
195
203
|
// 缓存最新一次的 queryKey,给顶部「导出」接口使用
|
|
@@ -8,6 +8,7 @@ import type { Config, Entities, Enums, FoldCardModel } from '../../type'
|
|
|
8
8
|
import { useGlobalToast } from '../../composables/useGlobalToast'
|
|
9
9
|
import Search from '../search/search.vue'
|
|
10
10
|
import foldCard from '../fold-card/fold-card.vue'
|
|
11
|
+
import dayjs from 'dayjs/esm/index'
|
|
11
12
|
|
|
12
13
|
defineOptions({
|
|
13
14
|
name: 'WuiSelectList',
|
|
@@ -155,7 +156,13 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
155
156
|
if (config.value.defaultCriteriaValue) {
|
|
156
157
|
for (const key in config.value.defaultCriteriaValue) {
|
|
157
158
|
if (Object.prototype.hasOwnProperty.call(config.value.defaultCriteriaValue, key)) {
|
|
158
|
-
|
|
159
|
+
let element = config.value.defaultCriteriaValue[key]
|
|
160
|
+
// $$currentD 占位符转换为当日时间(年-月-日),没有值则传空字符串
|
|
161
|
+
if (element === '$$currentD') {
|
|
162
|
+
element = dayjs().format('YYYY-MM-DD')
|
|
163
|
+
} else if (element === undefined || element === null) {
|
|
164
|
+
element = ''
|
|
165
|
+
}
|
|
159
166
|
if (!qre.includes(key)) {
|
|
160
167
|
qre = `${qre}&${key}=${element}`
|
|
161
168
|
}
|
|
@@ -6,6 +6,7 @@ import Search from '../search/search.vue'
|
|
|
6
6
|
import type { Config, Entities, Enums, FoldCardModel } from '../../type'
|
|
7
7
|
import { useGlobalToast } from '../../composables/useGlobalToast'
|
|
8
8
|
import listTopButtons from '../list-top-buttons/list-top-buttons.vue'
|
|
9
|
+
import dayjs from 'dayjs/esm/index'
|
|
9
10
|
|
|
10
11
|
defineOptions({
|
|
11
12
|
name: 'WuiSelectPopup',
|
|
@@ -301,7 +302,13 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
301
302
|
if (config.value.defaultCriteriaValue) {
|
|
302
303
|
for (const key in config.value.defaultCriteriaValue) {
|
|
303
304
|
if (Object.prototype.hasOwnProperty.call(config.value.defaultCriteriaValue, key)) {
|
|
304
|
-
|
|
305
|
+
let element = config.value.defaultCriteriaValue[key]
|
|
306
|
+
// $$currentD 占位符转换为当日时间(年-月-日),没有值则传空字符串
|
|
307
|
+
if (element === '$$currentD') {
|
|
308
|
+
element = dayjs().format('YYYY-MM-DD')
|
|
309
|
+
} else if (element === undefined || element === null) {
|
|
310
|
+
element = ''
|
|
311
|
+
}
|
|
305
312
|
if (!qre.includes(key)) {
|
|
306
313
|
qre = `${qre}&${key}=${element}`
|
|
307
314
|
}
|