n20-common-lib 2.6.44 → 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 +35 -5
- 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"
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
/>
|
|
24
24
|
</div>
|
|
25
25
|
<i
|
|
26
|
-
v-if="!item.
|
|
26
|
+
v-if="!item.isNotClose"
|
|
27
27
|
:key="getOnlyKey(item)"
|
|
28
28
|
:class="[prefixCls + '-item-close', 'n20-icon-yichu']"
|
|
29
29
|
@click="handleClose(item)"
|
|
@@ -67,6 +67,10 @@ export default {
|
|
|
67
67
|
filterItem
|
|
68
68
|
},
|
|
69
69
|
props: {
|
|
70
|
+
isNotClose: {
|
|
71
|
+
type: Boolean,
|
|
72
|
+
default: false
|
|
73
|
+
},
|
|
70
74
|
visible: {
|
|
71
75
|
type: Boolean,
|
|
72
76
|
default: false
|
|
@@ -161,7 +165,13 @@ export default {
|
|
|
161
165
|
let flag = ''
|
|
162
166
|
switch (item.type) {
|
|
163
167
|
case 'numberrange':
|
|
164
|
-
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
|
+
: ''
|
|
165
175
|
break
|
|
166
176
|
case 'daterange':
|
|
167
177
|
case 'datetimerange':
|
|
@@ -223,7 +233,27 @@ export default {
|
|
|
223
233
|
cleared() {
|
|
224
234
|
this.$emit('clear')
|
|
225
235
|
},
|
|
226
|
-
|
|
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
|
+
},
|
|
227
257
|
check: _debounce(function (keys) {
|
|
228
258
|
// 保存当前选择的过滤条件
|
|
229
259
|
this.checkList = keys
|
|
@@ -236,6 +266,7 @@ export default {
|
|
|
236
266
|
}
|
|
237
267
|
})
|
|
238
268
|
}
|
|
269
|
+
this.setModelData(saveCheckArr)
|
|
239
270
|
this.saveFilter(saveCheckArr).then(({ code }) => {
|
|
240
271
|
// 如果保存成功
|
|
241
272
|
if (code === 200) {
|
|
@@ -244,7 +275,6 @@ export default {
|
|
|
244
275
|
}
|
|
245
276
|
})
|
|
246
277
|
this.$emit('check')
|
|
247
|
-
// // 保存过滤条件
|
|
248
278
|
}, 1000),
|
|
249
279
|
/**
|
|
250
280
|
* 保存筛选条件
|