n20-common-lib 3.0.55 → 3.0.57
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
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div :class="prefixCls">
|
|
3
|
-
<el-form
|
|
4
|
-
v-show="visible"
|
|
5
|
-
ref="advancedFilter"
|
|
6
|
-
:class="prefixCls + '-body'"
|
|
7
|
-
@submit.native.prevent="() => {}"
|
|
8
|
-
>
|
|
3
|
+
<el-form v-show="visible" ref="advancedFilter" :class="prefixCls + '-body'" @submit.native.prevent="() => {}">
|
|
9
4
|
<slot name="prefix"></slot>
|
|
10
5
|
<el-form-item
|
|
11
6
|
v-for="item in GroupData"
|
|
@@ -45,7 +40,7 @@
|
|
|
45
40
|
<el-input v-model="keyword" clearable class="input-w m-b-s" :placeholder="$lc('搜索筛选条件')" />
|
|
46
41
|
<div class="flex-box flex-lr">
|
|
47
42
|
<el-button type="text" @click="allCheck">{{
|
|
48
|
-
|
|
43
|
+
isAllNonFixedChecked ? $lc('取消全选') : $lc('全选')
|
|
49
44
|
}}</el-button>
|
|
50
45
|
<el-button v-if="filterId" type="text" @click="defaultCheck">{{ $lc('恢复默认') }}</el-button>
|
|
51
46
|
</div>
|
|
@@ -215,6 +210,14 @@ export default {
|
|
|
215
210
|
set(v) {
|
|
216
211
|
return v
|
|
217
212
|
}
|
|
213
|
+
},
|
|
214
|
+
// 判断所有非固定(非static、非isNotClose)项目是否都已选中
|
|
215
|
+
isAllNonFixedChecked() {
|
|
216
|
+
const nonFixedItems = this.filterListS.filter((res) => !res.static && !res.isNotClose)
|
|
217
|
+
if (nonFixedItems.length === 0) return false
|
|
218
|
+
|
|
219
|
+
const nonFixedItemIds = nonFixedItems.map((item) => item[this.onlyKey])
|
|
220
|
+
return nonFixedItemIds.every((id) => this.checkList.includes(id))
|
|
218
221
|
}
|
|
219
222
|
},
|
|
220
223
|
watch: {
|
|
@@ -398,15 +401,23 @@ export default {
|
|
|
398
401
|
}
|
|
399
402
|
},
|
|
400
403
|
allCheck() {
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
404
|
+
// 获取非固定(非static、非isNotClose)的项目
|
|
405
|
+
const nonFixedItems = this.filterListS.filter((res) => !res.static && !res.isNotClose)
|
|
406
|
+
const nonFixedItemIds = nonFixedItems.map((item) => item[this.onlyKey])
|
|
407
|
+
|
|
408
|
+
// 检查所有非固定项目是否都已选中
|
|
409
|
+
const allNonFixedChecked = nonFixedItemIds.length > 0 && nonFixedItemIds.every((id) => this.checkList.includes(id))
|
|
410
|
+
|
|
411
|
+
// 获取固定项目的ID
|
|
412
|
+
const fixedItemIds = this.filterListS
|
|
413
|
+
.filter((res) => res.static || res.isNotClose)
|
|
414
|
+
.map((item) => item[this.onlyKey])
|
|
415
|
+
|
|
416
|
+
if (allNonFixedChecked) {
|
|
417
|
+
// 取消全选:只保留固定项目
|
|
418
|
+
this.checkList = [...fixedItemIds]
|
|
409
419
|
} else {
|
|
420
|
+
// 全选:选中所有项目
|
|
410
421
|
if (this.maxLength) {
|
|
411
422
|
this.checkList = this.filterListS.slice(0, this.maxLength)?.map((res) => res[this.onlyKey])
|
|
412
423
|
} else {
|
|
@@ -521,18 +532,35 @@ export default {
|
|
|
521
532
|
mackData(data) {
|
|
522
533
|
let _data = data
|
|
523
534
|
if (_data && _data.length > 0) {
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
535
|
+
// 先过滤出在 filterList 中存在的项目,避免使用已删除的筛选条件
|
|
536
|
+
_data = _data.filter((item) => {
|
|
537
|
+
return this.filterList.some((filterItem) => filterItem[this.onlyKey] === item[this.onlyKey])
|
|
538
|
+
})
|
|
539
|
+
|
|
540
|
+
// 如果过滤后没有有效数据,使用默认逻辑
|
|
541
|
+
if (_data.length === 0) {
|
|
542
|
+
if (this.removeLoad) {
|
|
543
|
+
this.GroupData = this.filterList.filter((item) => {
|
|
544
|
+
if (item.isDefault) {
|
|
545
|
+
return item
|
|
546
|
+
}
|
|
547
|
+
})
|
|
548
|
+
} else {
|
|
549
|
+
this.GroupData = []
|
|
550
|
+
}
|
|
551
|
+
} else {
|
|
552
|
+
// 更新有效数据的 label 和 options
|
|
553
|
+
this.GroupData = _data.map((item) => {
|
|
554
|
+
const originItem = this.filterList.find((filter) => filter[this.onlyKey] === item[this.onlyKey])
|
|
555
|
+
if (originItem) {
|
|
528
556
|
item.label = originItem.label
|
|
529
|
-
if (
|
|
557
|
+
if (originItem.options) {
|
|
530
558
|
item.options = originItem.options
|
|
531
559
|
}
|
|
532
560
|
}
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
}
|
|
561
|
+
return item
|
|
562
|
+
})
|
|
563
|
+
}
|
|
536
564
|
} else {
|
|
537
565
|
if (this.removeLoad) {
|
|
538
566
|
this.GroupData = this.filterList.filter((item) => {
|
|
@@ -544,6 +572,27 @@ export default {
|
|
|
544
572
|
this.GroupData = []
|
|
545
573
|
}
|
|
546
574
|
}
|
|
575
|
+
|
|
576
|
+
// ✨ 确保 static: true 的项目自动添加并勾选
|
|
577
|
+
const staticItemsInFilterList = this.filterList.filter((item) => item.static)
|
|
578
|
+
const existingIds = this.GroupData.map((item) => item[this.onlyKey])
|
|
579
|
+
|
|
580
|
+
// 找出不在 GroupData 中的 static 项目
|
|
581
|
+
const missingStaticItems = staticItemsInFilterList.filter((item) => !existingIds.includes(item[this.onlyKey]))
|
|
582
|
+
|
|
583
|
+
// 将缺失的 static 项目添加到 GroupData 开头
|
|
584
|
+
if (missingStaticItems.length > 0) {
|
|
585
|
+
const staticItemsToAdd = missingStaticItems.map((item) => ({ ...item }))
|
|
586
|
+
this.GroupData = [...staticItemsToAdd, ...this.GroupData]
|
|
587
|
+
}
|
|
588
|
+
|
|
589
|
+
// ✨ 强制将所有 static: true 的项目移到最前面
|
|
590
|
+
if (this.GroupData && this.GroupData.length > 0) {
|
|
591
|
+
const staticItems = this.GroupData.filter((item) => item.static)
|
|
592
|
+
const otherItems = this.GroupData.filter((item) => !item.static)
|
|
593
|
+
this.GroupData = [...staticItems, ...otherItems]
|
|
594
|
+
}
|
|
595
|
+
|
|
547
596
|
this.checkList = this.GroupData.map((res) => res.id)
|
|
548
597
|
console.log(this.checkList)
|
|
549
598
|
this.cancelCheck = XEUtils.clone(this.checkList, true)
|