n20-common-lib 2.22.22 → 2.22.23
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
|
@@ -115,6 +115,10 @@ export default {
|
|
|
115
115
|
filterId: {
|
|
116
116
|
type: String,
|
|
117
117
|
default: ''
|
|
118
|
+
},
|
|
119
|
+
beforeFilterList: {
|
|
120
|
+
type: Function,
|
|
121
|
+
default: (data) => data
|
|
118
122
|
}
|
|
119
123
|
},
|
|
120
124
|
data() {
|
|
@@ -363,9 +367,9 @@ export default {
|
|
|
363
367
|
/**
|
|
364
368
|
* 获取筛选条件
|
|
365
369
|
*/
|
|
366
|
-
getFilterList() {
|
|
367
|
-
|
|
368
|
-
.post(
|
|
370
|
+
async getFilterList() {
|
|
371
|
+
try {
|
|
372
|
+
const { data } = await axios.post(
|
|
369
373
|
`/bems/prod_1.0/user/pageHabit/list?t=${Date.now()}`,
|
|
370
374
|
{
|
|
371
375
|
userNo: this.userNo,
|
|
@@ -373,53 +377,55 @@ export default {
|
|
|
373
377
|
},
|
|
374
378
|
{ loading: false, noMsg: true }
|
|
375
379
|
)
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
380
|
+
|
|
381
|
+
const _data = JSON.parse(data)
|
|
382
|
+
|
|
383
|
+
await Promise.resolve(this.beforeFilterList(_data))
|
|
384
|
+
|
|
385
|
+
if (_data && _data.length > 0) {
|
|
386
|
+
this.GroupData = _data.map((item) => {
|
|
387
|
+
for (let i = 0; i < this.filterList.length; i++) {
|
|
388
|
+
const originItem = this.filterList[i]
|
|
389
|
+
if (originItem[this.onlyKey] === item[this.onlyKey]) {
|
|
390
|
+
item.label = originItem.label
|
|
391
|
+
if (item.options && originItem.options) {
|
|
392
|
+
item.options = originItem.options
|
|
387
393
|
}
|
|
388
394
|
}
|
|
389
|
-
|
|
395
|
+
}
|
|
396
|
+
return item
|
|
397
|
+
})
|
|
398
|
+
} else {
|
|
399
|
+
if (this.removeLoad) {
|
|
400
|
+
this.GroupData = this.filterList.filter((item) => {
|
|
401
|
+
if (item.isDefault) {
|
|
402
|
+
return item
|
|
403
|
+
}
|
|
390
404
|
})
|
|
391
405
|
} else {
|
|
392
|
-
|
|
393
|
-
this.GroupData = this.filterList.filter((item) => {
|
|
394
|
-
if (item.isDefault) {
|
|
395
|
-
return item
|
|
396
|
-
}
|
|
397
|
-
})
|
|
398
|
-
} else {
|
|
399
|
-
this.GroupData = []
|
|
400
|
-
}
|
|
406
|
+
this.GroupData = []
|
|
401
407
|
}
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
return 0
|
|
413
|
-
})
|
|
414
|
-
})
|
|
415
|
-
.finally(() => {
|
|
416
|
-
for (const key in getOptionsMap()) {
|
|
417
|
-
if (Object.hasOwnProperty.call(getOptionsMap(), key)) {
|
|
418
|
-
const data = getOptionsMap()[key]
|
|
419
|
-
this.setChoices(key, data)
|
|
420
|
-
}
|
|
408
|
+
}
|
|
409
|
+
this.checkList = this.GroupData.map((res) => res.id)
|
|
410
|
+
this.cancelCheck = XEUtils.clone(this.checkList, true)
|
|
411
|
+
// 查找排序,在this.filterList中查找this.checkList中的每一项,并将其排在前面
|
|
412
|
+
this.filterList = this.filterList.sort((a, b) => {
|
|
413
|
+
if (this.checkList.includes(a[this.onlyKey]) && !this.checkList.includes(b[this.onlyKey])) {
|
|
414
|
+
return -1
|
|
415
|
+
}
|
|
416
|
+
if (!this.checkList.includes(a[this.onlyKey]) && this.checkList.includes(b[this.onlyKey])) {
|
|
417
|
+
return 1
|
|
421
418
|
}
|
|
419
|
+
return 0
|
|
422
420
|
})
|
|
421
|
+
} finally {
|
|
422
|
+
for (const key in getOptionsMap()) {
|
|
423
|
+
if (Object.hasOwnProperty.call(getOptionsMap(), key)) {
|
|
424
|
+
const data = getOptionsMap()[key]
|
|
425
|
+
this.setChoices(key, data)
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
423
429
|
}
|
|
424
430
|
}
|
|
425
431
|
}
|