n20-common-lib 2.6.45 → 2.6.46
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/package.json +1 -1
- package/src/assets/css/filter.scss +4 -0
- package/src/components/AdvancedFilter/formItemRender.vue +56 -28
- package/src/components/AdvancedFilter/index.vue +30 -4
- package/src/directives/VRuleKey/index.js +1 -1
- package/style/index.css +1 -1
- package/theme/blue.css +1 -1
- package/theme/cctcRed.css +1 -1
- package/theme/green.css +1 -1
- package/theme/lightBlue.css +1 -1
- package/theme/orange.css +1 -1
- package/theme/purple.css +1 -1
- package/theme/red.css +1 -1
- package/theme/yellow.css +1 -1
package/package.json
CHANGED
|
@@ -120,25 +120,40 @@ export default {
|
|
|
120
120
|
|
|
121
121
|
const calcWidth = (value, type) => {
|
|
122
122
|
let W = null
|
|
123
|
-
if (!value) {
|
|
124
|
-
if (
|
|
125
|
-
|
|
123
|
+
if (!Array.isArray(value)) {
|
|
124
|
+
if (!value) {
|
|
125
|
+
if (type) {
|
|
126
|
+
return Number(w) + 110 + 'px'
|
|
127
|
+
}
|
|
128
|
+
return w + 'px'
|
|
126
129
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
if (getWidth(value, type) > w) {
|
|
131
|
+
if (getWidth(value, type) > MAX_WIDTH) {
|
|
132
|
+
W = MAX_WIDTH
|
|
133
|
+
} else {
|
|
134
|
+
W = getWidth(value, type)
|
|
135
|
+
}
|
|
132
136
|
} else {
|
|
133
|
-
|
|
137
|
+
if (type) {
|
|
138
|
+
W = w ? w : asciiWidth(item.placeholder || typeEnum[item.type]) + 150
|
|
139
|
+
} else {
|
|
140
|
+
W = w ? w : asciiWidth(item.placeholder || typeEnum[item.type]) + 40
|
|
141
|
+
}
|
|
134
142
|
}
|
|
135
143
|
} else {
|
|
136
|
-
if (
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
144
|
+
if (!value[0] && !value[1]) {
|
|
145
|
+
return Number(w) + 110 + 'px'
|
|
146
|
+
}
|
|
147
|
+
let widthMax = getWidth(value[0]) + getWidth(value[1]) + 35
|
|
148
|
+
if (widthMax > w) {
|
|
149
|
+
if (widthMax > MAX_WIDTH) {
|
|
150
|
+
W = MAX_WIDTH
|
|
151
|
+
} else {
|
|
152
|
+
W = widthMax
|
|
153
|
+
}
|
|
140
154
|
}
|
|
141
155
|
}
|
|
156
|
+
|
|
142
157
|
return W + 'px'
|
|
143
158
|
}
|
|
144
159
|
|
|
@@ -341,7 +356,7 @@ export default {
|
|
|
341
356
|
ruleErrorHide: item.ruleErrorHide
|
|
342
357
|
},
|
|
343
358
|
style: {
|
|
344
|
-
width: calcWidth(form[item.startValue], true)
|
|
359
|
+
width: calcWidth([form[item.startValue], form[item.endValue]], true)
|
|
345
360
|
},
|
|
346
361
|
props: inputRangeProps,
|
|
347
362
|
on: {
|
|
@@ -368,13 +383,22 @@ export default {
|
|
|
368
383
|
const datePickerProps = {
|
|
369
384
|
value: form[item.value],
|
|
370
385
|
type: item.type,
|
|
386
|
+
'prefix-icon': (item.props && item.props.prefixIcon) ?? '',
|
|
371
387
|
clearable: (item.props && item.props.clearable) ?? true,
|
|
372
388
|
// 将 props 对象中的属性应用到 datePicker 上
|
|
373
389
|
...item.props
|
|
374
390
|
}
|
|
375
|
-
elementDom = h('
|
|
391
|
+
elementDom = h('el-date-picker', {
|
|
376
392
|
directives: [{ name: 'rule-key' }],
|
|
377
|
-
attrs: {
|
|
393
|
+
attrs: {
|
|
394
|
+
'rule-form': 'ruleValidate',
|
|
395
|
+
ruleField: true,
|
|
396
|
+
class: `n20-date-editor`,
|
|
397
|
+
'value-format': (item.props && item.props.valueFormat) ?? 'yyyy-MM-dd',
|
|
398
|
+
placeholder: (item.props && item.props.placeholder) ?? $lc('请选择'),
|
|
399
|
+
rules: item.rules,
|
|
400
|
+
ruleErrorHide: item.ruleErrorHide
|
|
401
|
+
},
|
|
378
402
|
style: {
|
|
379
403
|
width: calcWidth(form[item.value])
|
|
380
404
|
},
|
|
@@ -399,29 +423,33 @@ export default {
|
|
|
399
423
|
case 'monthrange':
|
|
400
424
|
const pickerProps = {
|
|
401
425
|
type: item.type,
|
|
402
|
-
startDate: form[item.startDate],
|
|
403
|
-
endDate: form[item.endDate],
|
|
426
|
+
startDate: form[item.startDate] || null,
|
|
427
|
+
endDate: form[item.endDate] || null,
|
|
428
|
+
rules: item.rules,
|
|
404
429
|
clearable: (item.props && item.props.clearable) ?? true,
|
|
405
430
|
...item.props
|
|
406
431
|
}
|
|
407
|
-
|
|
408
432
|
elementDom = h('datePickerPor', {
|
|
409
433
|
directives: [{ name: 'rule-key', value: 'startDate' }],
|
|
410
|
-
attrs: {
|
|
434
|
+
attrs: {
|
|
435
|
+
ruleField: true,
|
|
436
|
+
'rule-form': 'ruleValidate',
|
|
437
|
+
ruleErrorHide: item.ruleErrorHide,
|
|
438
|
+
rules: item.rules
|
|
439
|
+
},
|
|
411
440
|
props: pickerProps,
|
|
412
441
|
style: {
|
|
413
442
|
width: calcWidth(form[item.startDate], true)
|
|
414
443
|
},
|
|
415
444
|
on: {
|
|
445
|
+
'update:start-date': (val) => {
|
|
446
|
+
this.$set(form, item.startDate, val)
|
|
447
|
+
},
|
|
448
|
+
'update:end-date': (val) => {
|
|
449
|
+
this.$set(form, item.endDate, val)
|
|
450
|
+
},
|
|
416
451
|
clear: this.handleClear,
|
|
417
|
-
change: (
|
|
418
|
-
if (value) {
|
|
419
|
-
this.$set(form, item.startDate, value[0])
|
|
420
|
-
this.$set(form, item.endDate, value[1])
|
|
421
|
-
} else {
|
|
422
|
-
this.$set(form, item.startDate, null)
|
|
423
|
-
this.$set(form, item.endDate, null)
|
|
424
|
-
}
|
|
452
|
+
change: () => {
|
|
425
453
|
this.handleFilter()
|
|
426
454
|
}
|
|
427
455
|
},
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :class="prefixCls">
|
|
3
|
-
<el-form ref="advancedFilter" v-
|
|
3
|
+
<el-form ref="advancedFilter" v-show="visible" :class="prefixCls + '-body'">
|
|
4
4
|
<slot name="prefix"></slot>
|
|
5
5
|
<el-form-item
|
|
6
6
|
v-for="item in GroupData"
|
|
@@ -165,7 +165,13 @@ export default {
|
|
|
165
165
|
let flag = ''
|
|
166
166
|
switch (item.type) {
|
|
167
167
|
case 'numberrange':
|
|
168
|
-
flag =
|
|
168
|
+
flag =
|
|
169
|
+
this.model[item.startValue] !== null &&
|
|
170
|
+
this.model[item.endValue] !== null &&
|
|
171
|
+
this.model[item.startValue] !== undefined &&
|
|
172
|
+
this.model[item.endValue] !== undefined
|
|
173
|
+
? this.prefixCls + '-active'
|
|
174
|
+
: ''
|
|
169
175
|
break
|
|
170
176
|
case 'daterange':
|
|
171
177
|
case 'datetimerange':
|
|
@@ -227,7 +233,27 @@ export default {
|
|
|
227
233
|
cleared() {
|
|
228
234
|
this.$emit('clear')
|
|
229
235
|
},
|
|
230
|
-
|
|
236
|
+
setModelData(list) {
|
|
237
|
+
let arr = []
|
|
238
|
+
list.forEach((res) => {
|
|
239
|
+
if (res.value) {
|
|
240
|
+
arr.push(res.value)
|
|
241
|
+
} else if (res.startDate && res.endDate) {
|
|
242
|
+
arr.push(res.startDate)
|
|
243
|
+
arr.push(res.endDate)
|
|
244
|
+
} else if (res.startValue && res.endValue) {
|
|
245
|
+
arr.push(res.startValue)
|
|
246
|
+
arr.push(res.endValue)
|
|
247
|
+
}
|
|
248
|
+
})
|
|
249
|
+
for (const key in this.model) {
|
|
250
|
+
if (Object.hasOwnProperty.call(this.model, key)) {
|
|
251
|
+
if (!arr.includes(key)) {
|
|
252
|
+
delete this.model[key]
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
},
|
|
231
257
|
check: _debounce(function (keys) {
|
|
232
258
|
// 保存当前选择的过滤条件
|
|
233
259
|
this.checkList = keys
|
|
@@ -240,6 +266,7 @@ export default {
|
|
|
240
266
|
}
|
|
241
267
|
})
|
|
242
268
|
}
|
|
269
|
+
this.setModelData(saveCheckArr)
|
|
243
270
|
this.saveFilter(saveCheckArr).then(({ code }) => {
|
|
244
271
|
// 如果保存成功
|
|
245
272
|
if (code === 200) {
|
|
@@ -248,7 +275,6 @@ export default {
|
|
|
248
275
|
}
|
|
249
276
|
})
|
|
250
277
|
this.$emit('check')
|
|
251
|
-
// // 保存过滤条件
|
|
252
278
|
}, 1000),
|
|
253
279
|
/**
|
|
254
280
|
* 保存筛选条件
|