n20-common-lib 3.0.65 → 3.0.66

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,6 +1,6 @@
1
1
  {
2
2
  "name": "n20-common-lib",
3
- "version": "3.0.65",
3
+ "version": "3.0.66",
4
4
  "private": false,
5
5
  "scripts": {
6
6
  "serve": "vue-cli-service serve",
@@ -459,6 +459,32 @@ export default {
459
459
  // 然后再发起异步请求获取更精确的字段配置
460
460
  this.getAdvancedQueryFields()
461
461
  },
462
+ watch: {
463
+ canSetFilter: {
464
+ handler(newVal) {
465
+ // 当 value 为空且 canSetFilter 有数据时,将 isDefault: true 的字段默认添加到条件列表中
466
+ if (this.value.length === 0 && newVal.length > 0) {
467
+ const defaultFields = newVal.filter((item) => item.isDefault === true)
468
+ if (defaultFields.length > 0) {
469
+ const conditions = defaultFields.map((field) => ({
470
+ field: field.value,
471
+ operator: '',
472
+ value: '',
473
+ advancedQueryType: field.advancedQueryType,
474
+ valueType: ''
475
+ }))
476
+ this.$emit('update:value', [
477
+ {
478
+ conditionLogic: 'and',
479
+ conditions
480
+ }
481
+ ])
482
+ }
483
+ }
484
+ },
485
+ immediate: true
486
+ }
487
+ },
462
488
  methods: {
463
489
  // 查询支持可配置高级查询的字段
464
490
  async getAdvancedQueryFields() {
@@ -476,7 +502,7 @@ export default {
476
502
  console.log(this.filterList, '10086')
477
503
 
478
504
  // 用 filterList 去匹配可搜索的字段,并设置 advancedQueryType
479
- this.canSetFilter = this.filterList
505
+ let matchedFields = this.filterList
480
506
  .filter((item) => {
481
507
  return searchableFields.some((field) => field.fieldCode === item.fieldCode || field.fieldCode === item.value)
482
508
  })
@@ -492,6 +518,15 @@ export default {
492
518
  }
493
519
  return item
494
520
  })
521
+ // 根据 isDefault 排序:isDefault: true 的排在前面
522
+ matchedFields.sort((a, b) => {
523
+ const aHasDefault = a.isDefault === true
524
+ const bHasDefault = b.isDefault === true
525
+ if (aHasDefault && !bHasDefault) return -1
526
+ if (!aHasDefault && bHasDefault) return 1
527
+ return 0
528
+ })
529
+ this.canSetFilter = matchedFields
495
530
  // 再次过滤,确保数据正确
496
531
  this.filterInvalidConditions()
497
532
  },