wui-components-v2 1.2.79 → 1.2.80
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.
|
@@ -104,41 +104,36 @@ function handleClose() {
|
|
|
104
104
|
}
|
|
105
105
|
// 把合并后的数据对象(fdata)拼接为查询条件字符串
|
|
106
106
|
function buildQueryData(fdata: { [key: string]: any }) {
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
107
|
+
const parts: string[] = []
|
|
108
|
+
// 搜索框没输入关键字时不拼参数:空值参数(`c_xxx=`)会被后端当成"等于空串"的
|
|
109
|
+
// 过滤条件,也会把父组件 defaultCriteriaValue 的默认值顶掉,导致数据全被过滤掉
|
|
110
|
+
if (showSearch.value && searchCriterion.value?.sourceId && search.value !== '') {
|
|
111
|
+
parts.push(`c_${searchCriterion.value.sourceId}=${search.value}`)
|
|
110
112
|
}
|
|
111
113
|
filterCriteria.value.forEach(item => {
|
|
112
114
|
const element = fdata[item.sourceId]
|
|
113
|
-
// 空值(空字符串、undefined、null
|
|
114
|
-
|
|
115
|
-
if (element
|
|
116
|
-
data = `${data}&c_${item.sourceId}=`
|
|
117
|
-
return
|
|
118
|
-
}
|
|
119
|
-
if (Array.isArray(element) && element.length === 0) {
|
|
120
|
-
data = `${data}&c_${item.sourceId}=`
|
|
121
|
-
return
|
|
122
|
-
}
|
|
115
|
+
// 空值(空字符串、undefined、null、空数组)不拼参数,直接跳过
|
|
116
|
+
if (element === undefined || element === null || element === '') return
|
|
117
|
+
if (Array.isArray(element) && element.length === 0) return
|
|
123
118
|
// 跳过用户未修改的默认值(时间字段常被自动填充当前时间,不应作为查询条件)
|
|
124
119
|
if (item.transDefaultValue && String(element) === String(item.transDefaultValue)) return
|
|
125
120
|
if (item.extControlType === 'relselectvalue') {
|
|
126
121
|
const elements = Array.isArray(element) ? element : [element]
|
|
127
|
-
|
|
122
|
+
parts.push(`c_${item.sourceId}=${elements
|
|
128
123
|
.map((item: string) => {
|
|
129
124
|
return item.split('@R@')[1]
|
|
130
125
|
})
|
|
131
|
-
.join('@,@')}`
|
|
126
|
+
.join('@,@')}`)
|
|
132
127
|
} else if (item.extControlType === 'multiselect') {
|
|
133
128
|
const elements = Array.isArray(element) ? element : [element]
|
|
134
129
|
elements.forEach((subitem: string) => {
|
|
135
|
-
|
|
130
|
+
parts.push(`c_${item.sourceId}=${subitem}`)
|
|
136
131
|
})
|
|
137
132
|
} else {
|
|
138
|
-
|
|
133
|
+
parts.push(`c_${item.sourceId}=${element}`)
|
|
139
134
|
}
|
|
140
135
|
})
|
|
141
|
-
return
|
|
136
|
+
return parts.join('&')
|
|
142
137
|
}
|
|
143
138
|
// 对外触发提交(点击搜索/确定时使用)
|
|
144
139
|
function emitSubmit(fdata: { [key: string]: any }) {
|
|
@@ -497,22 +497,36 @@ async function queryList(pageNo: number, pageSize: number) {
|
|
|
497
497
|
if (!qre && urlKeys.length) {
|
|
498
498
|
qre = urlKeys.map(key => `c_${key}=${urlDefaultCriteria.value[key]}`).join('&')
|
|
499
499
|
}
|
|
500
|
+
// 解析 qre 为键值对:search 组件会把用户未填写的筛选项拼成 `c_xxx=` 空参数,
|
|
501
|
+
// 空值条件传给后端会过滤掉全部数据;且原来的 qre.includes(key) 是子串匹配,
|
|
502
|
+
// 空参数也会命中,把 $$currentD 等默认值顶掉,导致「点击搜索后数据消失」。
|
|
503
|
+
// 这里统一丢弃空值条件,再按精确 key 合并默认值(用户已填非空值的字段不覆盖)。
|
|
504
|
+
const parts: [string, string][] = []
|
|
505
|
+
qre.split('&').forEach((part) => {
|
|
506
|
+
if (!part) return
|
|
507
|
+
const eq = part.indexOf('=')
|
|
508
|
+
const k = eq === -1 ? part : part.slice(0, eq)
|
|
509
|
+
const v = eq === -1 ? '' : part.slice(eq + 1)
|
|
510
|
+
if (v === '') return
|
|
511
|
+
parts.push([k, v])
|
|
512
|
+
})
|
|
500
513
|
if (config.value.defaultCriteriaValue) {
|
|
501
514
|
for (const key in config.value.defaultCriteriaValue) {
|
|
502
515
|
if (Object.prototype.hasOwnProperty.call(config.value.defaultCriteriaValue, key)) {
|
|
503
516
|
let element = config.value.defaultCriteriaValue[key]
|
|
504
|
-
// $$currentD
|
|
517
|
+
// $$currentD 占位符转换为当日时间(年-月-日),没有值则不追加
|
|
505
518
|
if (element === '$$currentD') {
|
|
506
519
|
element = dayjs().format('YYYY-MM-DD')
|
|
507
520
|
} else if (element === undefined || element === null) {
|
|
508
521
|
element = ''
|
|
509
522
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
523
|
+
// 用户已显式填写该条件,或默认值本身为空,则跳过
|
|
524
|
+
if (element === '' || parts.some(([k]) => k === key)) continue
|
|
525
|
+
parts.push([key, String(element)])
|
|
513
526
|
}
|
|
514
527
|
}
|
|
515
528
|
}
|
|
529
|
+
qre = parts.map(([k, v]) => `${k}=${v}`).join('&')
|
|
516
530
|
|
|
517
531
|
try {
|
|
518
532
|
console.log('qre', qre)
|