@94ai/nf-search-form 8.0.1 → 8.0.8

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.
@@ -6375,13 +6375,36 @@ __sfc_main$1.setup = (__props, __ctx) => {
6375
6375
  const updateColumn = () => {
6376
6376
  fixedColumn.value = [];
6377
6377
  unFixedColumn.value = [];
6378
- currentTable.value.map((item) => {
6378
+ currentTable.value.filter((item) => !item.initHidden).map((item) => {
6379
6379
  if (item.attr.fixed) {
6380
6380
  fixedColumn.value.push(item);
6381
6381
  } else {
6382
6382
  unFixedColumn.value.push(item);
6383
6383
  }
6384
6384
  });
6385
+ updateCheckStatus();
6386
+ };
6387
+ const pullAwayColumn = (column) => {
6388
+ const unFixedIndex = unFixedColumn.value.findIndex((item) => item.prop === column.prop);
6389
+ const fixedIndex = fixedColumn.value.findIndex((item) => item.prop === column.prop);
6390
+ if (unFixedIndex > -1) {
6391
+ unFixedColumn.value.splice(unFixedIndex, 1);
6392
+ } else if (fixedIndex > -1) {
6393
+ fixedColumn.value.splice(fixedIndex, 1);
6394
+ }
6395
+ };
6396
+ const insertColumn = (column, append = false) => {
6397
+ const unFixedIndex = unFixedColumn.value.findIndex((item) => item.prop === column.prop);
6398
+ const fixedIndex = fixedColumn.value.findIndex((item) => item.prop === column.prop);
6399
+ if (unFixedIndex === -1 && fixedIndex === -1) {
6400
+ if (append) {
6401
+ unFixedColumn.value.push(column);
6402
+ } else {
6403
+ unFixedColumn.value.unshift(column);
6404
+ }
6405
+ }
6406
+ };
6407
+ const updateCheckStatus = () => {
6385
6408
  showColumn.value = currentTable.value.filter((i) => !i.initHidden).map((item) => item.prop);
6386
6409
  if (columnName.value && fields.value.length) {
6387
6410
  checkedCount.value = searchValue.filter((i) => !i.initHidden).length;
@@ -6403,28 +6426,72 @@ __sfc_main$1.setup = (__props, __ctx) => {
6403
6426
  }
6404
6427
  });
6405
6428
  setFields(searchValue);
6406
- updateColumn();
6429
+ updateCheckStatus();
6407
6430
  };
6408
6431
  const checkAll = vueDemi.ref(false);
6409
6432
  const isIndeterminate = vueDemi.ref(false);
6410
6433
  const handleCheckAllChange = (v) => {
6434
+ if (v) {
6435
+ let flag = false;
6436
+ if (columnName.value && fields.value.length) {
6437
+ if (searchValue.length && currentTable.value.length && searchValue.length === currentTable.value.length) {
6438
+ if (!unFixedColumn.value.length && !fixedColumn.value.length) {
6439
+ flag = true;
6440
+ }
6441
+ }
6442
+ } else if (!unFixedColumn.value.length && !fixedColumn.value.length) {
6443
+ flag = true;
6444
+ }
6445
+ if (flag) {
6446
+ fixedColumn.value = [];
6447
+ unFixedColumn.value = [];
6448
+ const newColumns = [];
6449
+ props.tableColumns.forEach((column) => {
6450
+ const item = currentTable.value.find((item2) => item2.prop === column.prop);
6451
+ if (item) {
6452
+ item.initHidden = false;
6453
+ newColumns.push(item);
6454
+ }
6455
+ });
6456
+ currentTable.value = newColumns;
6457
+ currentTable.value.map((item) => {
6458
+ if (item.attr.fixed) {
6459
+ fixedColumn.value.push(item);
6460
+ } else {
6461
+ unFixedColumn.value.push(item);
6462
+ }
6463
+ });
6464
+ updateCheckStatus();
6465
+ isIndeterminate.value = false;
6466
+ return;
6467
+ }
6468
+ }
6411
6469
  if (columnName.value && fields.value.length) {
6412
6470
  searchValue.map((item) => {
6471
+ if (v) {
6472
+ insertColumn(item, true);
6473
+ } else {
6474
+ pullAwayColumn(item);
6475
+ }
6413
6476
  if (!unChangedColumn.value.includes(item.prop)) {
6414
6477
  item.initHidden = !v;
6415
6478
  v ? "" : item.attr.fixed = false;
6416
6479
  }
6417
6480
  });
6418
- updateColumn();
6419
6481
  } else {
6420
6482
  currentTable.value.map((item) => {
6483
+ if (v) {
6484
+ insertColumn(item, true);
6485
+ } else {
6486
+ pullAwayColumn(item);
6487
+ }
6421
6488
  if (!unChangedColumn.value.includes(item.prop)) {
6422
6489
  item.initHidden = !v;
6423
6490
  v ? "" : item.attr.fixed = false;
6424
6491
  }
6425
6492
  });
6426
- updateColumn();
6427
6493
  }
6494
+ updateCheckStatus();
6428
6495
  isIndeterminate.value = false;
6429
6496
  };
6430
6497
  const handleCheckedChange = (v, prop) => {
@@ -6432,9 +6499,10 @@ __sfc_main$1.setup = (__props, __ctx) => {
6432
6499
  if (item.prop === prop) {
6433
6500
  item.initHidden = !v;
6434
6501
  v ? "" : item.attr.fixed = false;
6502
+ v ? insertColumn(item, true) : pullAwayColumn(item);
6435
6503
  }
6436
6504
  });
6437
- updateColumn();
6505
+ updateCheckStatus();
6438
6506
  };
6439
6507
  const syncTableColumnsToCookies = () => {
6440
6508
  var _a2;
@@ -6829,6 +6897,12 @@ __sfc_main.props = {
6829
6897
  type: String,
6830
6898
  default: "收起"
6831
6899
  },
6900
+ requiredValidate: {
6901
+ key: "requiredValidate",
6902
+ required: false,
6903
+ type: Boolean,
6904
+ default: false
6905
+ },
6832
6906
  rules: {
6833
6907
  key: "rules",
6834
6908
  required: false,
@@ -7623,7 +7697,7 @@ __sfc_main.setup = (__props, __ctx) => {
7623
7697
  item._index = index2;
7624
7698
  item.__index = index2;
7625
7699
  vue.set(item, "initHidden", !!item.initHidden);
7626
- vue.set(item, "destory", !!item.destory);
7700
+ vue.set(item, "destory", item.destory);
7627
7701
  if (!item.options)
7628
7702
  vue.set(item, "options", []);
7629
7703
  return item;
@@ -7642,11 +7716,10 @@ __sfc_main.setup = (__props, __ctx) => {
7642
7716
  };
7643
7717
  syncCookiesToSearchFormItemOptions();
7644
7718
  const itemIsShow = (item) => {
7645
- var _a2;
7646
- return !item.initHidden && !item.destory && (commonUtils.validate.isFunction(item.show) ? (_a2 = item == null ? void 0 : item.show) == null ? void 0 : _a2.call(item, nfSearchFormModel.value) : true);
7719
+ return !item.initHidden && !commonUtils.resolveValue(item.destory, nfSearchFormModel.value) && commonUtils.resolveValue((item == null ? void 0 : item.show) === void 0 ? true : item == null ? void 0 : item.show, nfSearchFormModel.value);
7647
7720
  };
7648
7721
  const btnIsShow = (item) => {
7649
- return item.show ? item.show(nfSearchFormModel.value) : true;
7722
+ return commonUtils.resolveValue((item == null ? void 0 : item.show) === void 0 ? true : item == null ? void 0 : item.show, nfSearchFormModel.value);
7650
7723
  };
7651
7724
  vueDemi.watch(() => nfSearchFormModel.value, () => {
7652
7725
  emit("onChange", nfSearchFormModel.value);
@@ -7677,7 +7750,7 @@ __sfc_main.setup = (__props, __ctx) => {
7677
7750
  formsInit();
7678
7751
  });
7679
7752
  const refreshNfSearchFormModel = () => {
7680
- props.formOptions.filter((item) => !item.destory).forEach((v) => {
7753
+ props.formOptions.filter((item) => !commonUtils.resolveValue(item.destory, nfSearchFormModel.value)).forEach((v) => {
7681
7754
  if (!localShowItems.value.includes(v.prop)) {
7682
7755
  commonUtils.mapDispose.setValue(nfSearchFormModel.value, v.key, void 0);
7683
7756
  } else if (nfSearchFormModel.value[v.prop] === void 0) {
@@ -7688,7 +7761,7 @@ __sfc_main.setup = (__props, __ctx) => {
7688
7761
  const formsInit = () => {
7689
7762
  getChangePropKeys();
7690
7763
  props.formOptions.forEach((item) => {
7691
- if (item.destory || !localShowItems.value.includes(item.prop))
7764
+ if (commonUtils.resolveValue(item.destory, nfSearchFormModel.value) || !localShowItems.value.includes(item.prop))
7692
7765
  return;
7693
7766
  setDefaultVal(item, true);
7694
7767
  triggerGetOptions(item);
@@ -7765,6 +7838,9 @@ __sfc_main.setup = (__props, __ctx) => {
7765
7838
  };
7766
7839
  const onNfSearchFormValidate = (callback) => {
7767
7840
  nfSearchFormRef.value.validate((valid) => {
7841
+ if (props.requiredValidate && !valid) {
7842
+ return;
7843
+ }
7768
7844
  callback == null ? void 0 : callback(valid);
7769
7845
  });
7770
7846
  };
@@ -7875,6 +7951,7 @@ __sfc_main.setup = (__props, __ctx) => {
7875
7951
  return data;
7876
7952
  };
7877
7953
  return Object.assign({
7954
+ resolveValue: commonUtils.resolveValue,
7878
7955
  defaultButtonSlot,
7879
7956
  nfSearchFormRef,
7880
7957
  columnCheckNfDrawer,
@@ -8005,6 +8082,7 @@ var _sfc_render = function render6() {
8005
8082
  "size": _vm.size,
8006
8083
  "disabled": _vm.disabled,
8007
8084
  "rules": _vm.rules,
8085
+ "requiredValidate": _vm.requiredValidate,
8008
8086
  "label-suffix": _vm.labelSuffix,
8009
8087
  "hide-required-asterisk": _vm.hideRequiredAsterisk,
8010
8088
  "show-message": _vm.showMessage,
@@ -8046,7 +8124,7 @@ var _sfc_render = function render6() {
8046
8124
  "label-width": item.labelWidth
8047
8125
  }
8048
8126
  }, [_vm._t(item.labelSlot, function() {
8049
- return [_vm._v(" " + _vm._s(item.label ? item.isShowColon ? item.label + ":" : item.label : "") + " ")];
8127
+ return [_vm._v(" " + _vm._s(_vm.resolveValue(item.label, _vm.nfSearchFormModel) ? item.isShowColon ? _vm.resolveValue(item.label, _vm.nfSearchFormModel) + ":" : _vm.resolveValue(item.label, _vm.nfSearchFormModel) : "") + " ")];
8050
8128
  }, {
8051
8129
  "slot": "label"
8052
8130
  }), _c("search-form-item", {
@@ -1,6 +1,6 @@
1
1
  import { defineComponent, ref, getCurrentInstance, computed, watch, onBeforeMount, onMounted, nextTick, onBeforeUnmount } from "vue-demi";
2
2
  import { normalizeComponent } from "@94ai/vue2-runtime-helpers";
3
- import { createUniqueString, CachedManager, deepClone, validate, mapDispose } from "@94ai/common-utils";
3
+ import { createUniqueString, CachedManager, deepClone, validate, resolveValue, mapDispose } from "@94ai/common-utils";
4
4
  import ResizeObserver from "resize-observer-polyfill";
5
5
  import { getCurrentInstance as getCurrentInstance$1, effectScope, shallowReactive, set } from "vue";
6
6
  import { throttle as throttle$1 } from "lodash-es";
@@ -6373,13 +6373,36 @@ __sfc_main$1.setup = (__props, __ctx) => {
6373
6373
  const updateColumn = () => {
6374
6374
  fixedColumn.value = [];
6375
6375
  unFixedColumn.value = [];
6376
- currentTable.value.map((item) => {
6376
+ currentTable.value.filter((item) => !item.initHidden).map((item) => {
6377
6377
  if (item.attr.fixed) {
6378
6378
  fixedColumn.value.push(item);
6379
6379
  } else {
6380
6380
  unFixedColumn.value.push(item);
6381
6381
  }
6382
6382
  });
6383
+ updateCheckStatus();
6384
+ };
6385
+ const pullAwayColumn = (column) => {
6386
+ const unFixedIndex = unFixedColumn.value.findIndex((item) => item.prop === column.prop);
6387
+ const fixedIndex = fixedColumn.value.findIndex((item) => item.prop === column.prop);
6388
+ if (unFixedIndex > -1) {
6389
+ unFixedColumn.value.splice(unFixedIndex, 1);
6390
+ } else if (fixedIndex > -1) {
6391
+ fixedColumn.value.splice(fixedIndex, 1);
6392
+ }
6393
+ };
6394
+ const insertColumn = (column, append = false) => {
6395
+ const unFixedIndex = unFixedColumn.value.findIndex((item) => item.prop === column.prop);
6396
+ const fixedIndex = fixedColumn.value.findIndex((item) => item.prop === column.prop);
6397
+ if (unFixedIndex === -1 && fixedIndex === -1) {
6398
+ if (append) {
6399
+ unFixedColumn.value.push(column);
6400
+ } else {
6401
+ unFixedColumn.value.unshift(column);
6402
+ }
6403
+ }
6404
+ };
6405
+ const updateCheckStatus = () => {
6383
6406
  showColumn.value = currentTable.value.filter((i) => !i.initHidden).map((item) => item.prop);
6384
6407
  if (columnName.value && fields.value.length) {
6385
6408
  checkedCount.value = searchValue.filter((i) => !i.initHidden).length;
@@ -6401,28 +6424,72 @@ __sfc_main$1.setup = (__props, __ctx) => {
6401
6424
  }
6402
6425
  });
6403
6426
  setFields(searchValue);
6404
- updateColumn();
6427
+ updateCheckStatus();
6405
6428
  };
6406
6429
  const checkAll = ref(false);
6407
6430
  const isIndeterminate = ref(false);
6408
6431
  const handleCheckAllChange = (v) => {
6432
+ if (v) {
6433
+ let flag = false;
6434
+ if (columnName.value && fields.value.length) {
6435
+ if (searchValue.length && currentTable.value.length && searchValue.length === currentTable.value.length) {
6436
+ if (!unFixedColumn.value.length && !fixedColumn.value.length) {
6437
+ flag = true;
6438
+ }
6439
+ }
6440
+ } else if (!unFixedColumn.value.length && !fixedColumn.value.length) {
6441
+ flag = true;
6442
+ }
6443
+ if (flag) {
6444
+ fixedColumn.value = [];
6445
+ unFixedColumn.value = [];
6446
+ const newColumns = [];
6447
+ props.tableColumns.forEach((column) => {
6448
+ const item = currentTable.value.find((item2) => item2.prop === column.prop);
6449
+ if (item) {
6450
+ item.initHidden = false;
6451
+ newColumns.push(item);
6452
+ }
6453
+ });
6454
+ currentTable.value = newColumns;
6455
+ currentTable.value.map((item) => {
6456
+ if (item.attr.fixed) {
6457
+ fixedColumn.value.push(item);
6458
+ } else {
6459
+ unFixedColumn.value.push(item);
6460
+ }
6461
+ });
6462
+ updateCheckStatus();
6463
+ isIndeterminate.value = false;
6464
+ return;
6465
+ }
6466
+ }
6409
6467
  if (columnName.value && fields.value.length) {
6410
6468
  searchValue.map((item) => {
6469
+ if (v) {
6470
+ insertColumn(item, true);
6471
+ } else {
6472
+ pullAwayColumn(item);
6473
+ }
6411
6474
  if (!unChangedColumn.value.includes(item.prop)) {
6412
6475
  item.initHidden = !v;
6413
6476
  v ? "" : item.attr.fixed = false;
6414
6477
  }
6415
6478
  });
6416
- updateColumn();
6417
6479
  } else {
6418
6480
  currentTable.value.map((item) => {
6481
+ if (v) {
6482
+ insertColumn(item, true);
6483
+ } else {
6484
+ pullAwayColumn(item);
6485
+ }
6419
6486
  if (!unChangedColumn.value.includes(item.prop)) {
6420
6487
  item.initHidden = !v;
6421
6488
  v ? "" : item.attr.fixed = false;
6422
6489
  }
6423
6490
  });
6424
- updateColumn();
6425
6491
  }
6492
+ updateCheckStatus();
6426
6493
  isIndeterminate.value = false;
6427
6494
  };
6428
6495
  const handleCheckedChange = (v, prop) => {
@@ -6430,9 +6497,10 @@ __sfc_main$1.setup = (__props, __ctx) => {
6430
6497
  if (item.prop === prop) {
6431
6498
  item.initHidden = !v;
6432
6499
  v ? "" : item.attr.fixed = false;
6500
+ v ? insertColumn(item, true) : pullAwayColumn(item);
6433
6501
  }
6434
6502
  });
6435
- updateColumn();
6503
+ updateCheckStatus();
6436
6504
  };
6437
6505
  const syncTableColumnsToCookies = () => {
6438
6506
  var _a2;
@@ -6827,6 +6895,12 @@ __sfc_main.props = {
6827
6895
  type: String,
6828
6896
  default: "收起"
6829
6897
  },
6898
+ requiredValidate: {
6899
+ key: "requiredValidate",
6900
+ required: false,
6901
+ type: Boolean,
6902
+ default: false
6903
+ },
6830
6904
  rules: {
6831
6905
  key: "rules",
6832
6906
  required: false,
@@ -7621,7 +7695,7 @@ __sfc_main.setup = (__props, __ctx) => {
7621
7695
  item._index = index2;
7622
7696
  item.__index = index2;
7623
7697
  set(item, "initHidden", !!item.initHidden);
7624
- set(item, "destory", !!item.destory);
7698
+ set(item, "destory", item.destory);
7625
7699
  if (!item.options)
7626
7700
  set(item, "options", []);
7627
7701
  return item;
@@ -7640,11 +7714,10 @@ __sfc_main.setup = (__props, __ctx) => {
7640
7714
  };
7641
7715
  syncCookiesToSearchFormItemOptions();
7642
7716
  const itemIsShow = (item) => {
7643
- var _a2;
7644
- return !item.initHidden && !item.destory && (validate.isFunction(item.show) ? (_a2 = item == null ? void 0 : item.show) == null ? void 0 : _a2.call(item, nfSearchFormModel.value) : true);
7717
+ return !item.initHidden && !resolveValue(item.destory, nfSearchFormModel.value) && resolveValue((item == null ? void 0 : item.show) === void 0 ? true : item == null ? void 0 : item.show, nfSearchFormModel.value);
7645
7718
  };
7646
7719
  const btnIsShow = (item) => {
7647
- return item.show ? item.show(nfSearchFormModel.value) : true;
7720
+ return resolveValue((item == null ? void 0 : item.show) === void 0 ? true : item == null ? void 0 : item.show, nfSearchFormModel.value);
7648
7721
  };
7649
7722
  watch(() => nfSearchFormModel.value, () => {
7650
7723
  emit("onChange", nfSearchFormModel.value);
@@ -7675,7 +7748,7 @@ __sfc_main.setup = (__props, __ctx) => {
7675
7748
  formsInit();
7676
7749
  });
7677
7750
  const refreshNfSearchFormModel = () => {
7678
- props.formOptions.filter((item) => !item.destory).forEach((v) => {
7751
+ props.formOptions.filter((item) => !resolveValue(item.destory, nfSearchFormModel.value)).forEach((v) => {
7679
7752
  if (!localShowItems.value.includes(v.prop)) {
7680
7753
  mapDispose.setValue(nfSearchFormModel.value, v.key, void 0);
7681
7754
  } else if (nfSearchFormModel.value[v.prop] === void 0) {
@@ -7686,7 +7759,7 @@ __sfc_main.setup = (__props, __ctx) => {
7686
7759
  const formsInit = () => {
7687
7760
  getChangePropKeys();
7688
7761
  props.formOptions.forEach((item) => {
7689
- if (item.destory || !localShowItems.value.includes(item.prop))
7762
+ if (resolveValue(item.destory, nfSearchFormModel.value) || !localShowItems.value.includes(item.prop))
7690
7763
  return;
7691
7764
  setDefaultVal(item, true);
7692
7765
  triggerGetOptions(item);
@@ -7763,6 +7836,9 @@ __sfc_main.setup = (__props, __ctx) => {
7763
7836
  };
7764
7837
  const onNfSearchFormValidate = (callback) => {
7765
7838
  nfSearchFormRef.value.validate((valid) => {
7839
+ if (props.requiredValidate && !valid) {
7840
+ return;
7841
+ }
7766
7842
  callback == null ? void 0 : callback(valid);
7767
7843
  });
7768
7844
  };
@@ -7873,6 +7949,7 @@ __sfc_main.setup = (__props, __ctx) => {
7873
7949
  return data;
7874
7950
  };
7875
7951
  return Object.assign({
7952
+ resolveValue,
7876
7953
  defaultButtonSlot,
7877
7954
  nfSearchFormRef,
7878
7955
  columnCheckNfDrawer,
@@ -8003,6 +8080,7 @@ var _sfc_render = function render6() {
8003
8080
  "size": _vm.size,
8004
8081
  "disabled": _vm.disabled,
8005
8082
  "rules": _vm.rules,
8083
+ "requiredValidate": _vm.requiredValidate,
8006
8084
  "label-suffix": _vm.labelSuffix,
8007
8085
  "hide-required-asterisk": _vm.hideRequiredAsterisk,
8008
8086
  "show-message": _vm.showMessage,
@@ -8044,7 +8122,7 @@ var _sfc_render = function render6() {
8044
8122
  "label-width": item.labelWidth
8045
8123
  }
8046
8124
  }, [_vm._t(item.labelSlot, function() {
8047
- return [_vm._v(" " + _vm._s(item.label ? item.isShowColon ? item.label + ":" : item.label : "") + " ")];
8125
+ return [_vm._v(" " + _vm._s(_vm.resolveValue(item.label, _vm.nfSearchFormModel) ? item.isShowColon ? _vm.resolveValue(item.label, _vm.nfSearchFormModel) + ":" : _vm.resolveValue(item.label, _vm.nfSearchFormModel) : "") + " ")];
8048
8126
  }, {
8049
8127
  "slot": "label"
8050
8128
  }), _c("search-form-item", {
package/lib/types.d.ts CHANGED
@@ -7,8 +7,8 @@ export declare type NfSearchFormItemOption = {
7
7
  _index?: number;
8
8
  __index?: number;
9
9
  initHidden?: boolean;
10
- destory?: boolean;
11
- label?: string;
10
+ destory?: boolean | ((any: any) => boolean);
11
+ label?: string | ((any: any) => string);
12
12
  addLabel?: string;
13
13
  prop?: string;
14
14
  width?: string;
@@ -248,13 +248,40 @@ const checkedCount = ref(0) // 勾选的数量
248
248
  const updateColumn = () => {
249
249
  fixedColumn.value = []
250
250
  unFixedColumn.value = []
251
- currentTable.value.map(item => {
251
+ currentTable.value.filter(item => !item.initHidden).map(item => {
252
252
  if (item.attr.fixed) {
253
253
  fixedColumn.value.push(item)
254
254
  } else {
255
255
  unFixedColumn.value.push(item)
256
256
  }
257
257
  })
258
+ updateCheckStatus()
259
+ }
260
+
261
+
262
+ const pullAwayColumn = (column) => {
263
+ const unFixedIndex = unFixedColumn.value.findIndex(item => item.prop === column.prop)
264
+ const fixedIndex = fixedColumn.value.findIndex(item => item.prop === column.prop)
265
+ if (unFixedIndex > -1) {
266
+ unFixedColumn.value.splice(unFixedIndex, 1)
267
+ } else if (fixedIndex > -1) {
268
+ fixedColumn.value.splice(fixedIndex, 1)
269
+ }
270
+ }
271
+
272
+ const insertColumn = (column, append = false) => {
273
+ const unFixedIndex = unFixedColumn.value.findIndex(item => item.prop === column.prop)
274
+ const fixedIndex = fixedColumn.value.findIndex(item => item.prop === column.prop)
275
+ if (unFixedIndex === -1 && fixedIndex === -1) {
276
+ if (append) {
277
+ unFixedColumn.value.push(column)
278
+ } else {
279
+ unFixedColumn.value.unshift(column)
280
+ }
281
+ }
282
+ }
283
+
284
+ const updateCheckStatus = () => {
258
285
  // 勾选状态
259
286
  showColumn.value = currentTable.value.filter(i => !i.initHidden).map(item => item.prop)
260
287
  // [全选 checkbox] 展示状态
@@ -283,7 +310,7 @@ const handleSearch = (str) => {
283
310
  }
284
311
  })
285
312
  setFields(searchValue)
286
- updateColumn()
313
+ updateCheckStatus()
287
314
  }
288
315
 
289
316
  /**
@@ -293,26 +320,70 @@ const handleSearch = (str) => {
293
320
  const checkAll = ref(false)
294
321
  const isIndeterminate = ref(false) // 来自官方解释:indeterminate 属性用以表示 checkbox 的不确定状态,一般用于实现全选的效果
295
322
  const handleCheckAllChange = (v) => {
323
+ if (v) { // 全选前为空,全选还原成最原始默认的顺序
324
+ let flag = false
325
+ if (columnName.value && fields.value.length) { // 搜索时,全选
326
+ if (searchValue.length && currentTable.value.length && searchValue.length === currentTable.value.length) {
327
+ if (!unFixedColumn.value.length && !fixedColumn.value.length) {
328
+ flag = true
329
+ }
330
+ }
331
+ } else if (!unFixedColumn.value.length && !fixedColumn.value.length) {
332
+ flag = true
333
+ }
334
+ if (flag) {
335
+ fixedColumn.value = []
336
+ unFixedColumn.value = []
337
+ const newColumns: Record<string, any>[] = []
338
+ props.tableColumns.forEach(column => {
339
+ const item = currentTable.value.find(item => item.prop === column.prop)
340
+ if (item) {
341
+ item.initHidden = false
342
+ newColumns.push(item)
343
+ }
344
+ })
345
+ currentTable.value = newColumns
346
+ currentTable.value.map(item => {
347
+ if (item.attr.fixed) {
348
+ fixedColumn.value.push(item)
349
+ } else {
350
+ unFixedColumn.value.push(item)
351
+ }
352
+ })
353
+ updateCheckStatus()
354
+ isIndeterminate.value = false
355
+ return
356
+ }
357
+ }
296
358
  // 搜索时,全选
297
359
  if (columnName.value && fields.value.length) {
298
360
  searchValue.map(item => {
361
+ if (v) { // 追加
362
+ insertColumn(item, true)
363
+ } else {
364
+ pullAwayColumn(item)
365
+ }
299
366
  if (!unChangedColumn.value.includes(item.prop)) {
300
367
  item.initHidden = !v
301
368
  // 清除列目时,清除固定属性
302
369
  v ? '' : item.attr.fixed = false
303
370
  }
304
371
  })
305
- updateColumn()
306
372
  } else {
307
373
  currentTable.value.map(item => {
374
+ if (v) { // 追加
375
+ insertColumn(item, true)
376
+ } else {
377
+ pullAwayColumn(item)
378
+ }
308
379
  if (!unChangedColumn.value.includes(item.prop)) {
309
380
  item.initHidden = !v
310
381
  // 清除列目时,清除固定属性
311
382
  v ? '' : item.attr.fixed = false
312
383
  }
313
384
  })
314
- updateColumn()
315
385
  }
386
+ updateCheckStatus()
316
387
  isIndeterminate.value = false
317
388
  }
318
389
 
@@ -327,9 +398,10 @@ const handleCheckedChange = (v, prop) => {
327
398
  item.initHidden = !v
328
399
  // 清除列目时,清除固定属性
329
400
  v ? '' : item.attr.fixed = false
401
+ v ? insertColumn(item, true) : pullAwayColumn(item)
330
402
  }
331
403
  })
332
- updateColumn()
404
+ updateCheckStatus()
333
405
  }
334
406
 
335
407
  /**
@@ -341,8 +413,20 @@ const handleFixed = (v, prop) => {
341
413
  const columnInfo = currentTable.value.find(item => item.prop === prop)
342
414
  if (columnInfo) {
343
415
  columnInfo.attr.fixed = v ? 'left' : false
416
+ if (v) { // 固定
417
+ const unFixedColumnIndex = unFixedColumn.value.findIndex(unFixedColumnItem => unFixedColumnItem.prop === columnInfo.prop)
418
+ if (unFixedColumnIndex > -1) {
419
+ unFixedColumn.value.splice(unFixedColumnIndex, 1)
420
+ fixedColumn.value.push(columnInfo)
421
+ }
422
+ } else { // 取消固定
423
+ const fixedColumnIndex = fixedColumn.value.findIndex(fixedColumnItem => fixedColumnItem.prop === columnInfo.prop)
424
+ if (fixedColumnIndex > -1) {
425
+ fixedColumn.value.splice(fixedColumnIndex, 1)
426
+ unFixedColumn.value.push(columnInfo)
427
+ }
428
+ }
344
429
  }
345
- updateColumn()
346
430
  }
347
431
 
348
432
  /**
@@ -2,36 +2,36 @@
2
2
  <div class="nf-search-form" ref="topDom">
3
3
  <!-- 空行以下保留原有,未重新梳理 -->
4
4
  <nf-form ref="nfSearchFormRef"
5
- :model="nfSearchFormModel"
6
- :inline="inline"
7
- :label-position="labelPosition"
8
- :label-width="useLabelWidth"
9
- :size="size"
10
- :disabled="disabled"
11
-
12
- :rules="rules"
13
- :label-suffix="labelSuffix"
14
- :hide-required-asterisk="hideRequiredAsterisk"
15
- :show-message="showMessage"
16
- :inline-message="inlineMessage"
17
- :status-icon="statusIcon"
18
- :validate-on-rule-change="validateOnRuleChange"
19
- :expand-btn-type="expandBtnType"
20
- :expand-btn-icon="expandBtnIcon"
21
- :expand-btn-plain="expandBtnPlain"
22
- :expand-btn-size="expandBtnSize"
23
- :expand-btn-round="expandBtnRound"
24
- :expand-btn-circle="expandBtnCircle"
25
- :expand-btn-loading="expandBtnLoading"
26
- :expand-btn-disabled="expandBtnDisabled"
27
- :columns="inline ? newColumns : columns"
28
- :up-icon="upIcon"
29
- :down-icon="downIcon"
30
- :show-btn="showBtn"
31
- :is-collapse="isCollapse"
32
- :expand-btn-tooltip-desc="expandBtnTooltipDesc"
33
- :shrink-btn-tooltip-desc="shrinkBtnTooltipDesc"
34
- @isCollapseChange="isCollapseChange"
5
+ :model="nfSearchFormModel"
6
+ :inline="inline"
7
+ :label-position="labelPosition"
8
+ :label-width="useLabelWidth"
9
+ :size="size"
10
+ :disabled="disabled"
11
+ :rules="rules"
12
+ :requiredValidate="requiredValidate"
13
+ :label-suffix="labelSuffix"
14
+ :hide-required-asterisk="hideRequiredAsterisk"
15
+ :show-message="showMessage"
16
+ :inline-message="inlineMessage"
17
+ :status-icon="statusIcon"
18
+ :validate-on-rule-change="validateOnRuleChange"
19
+ :expand-btn-type="expandBtnType"
20
+ :expand-btn-icon="expandBtnIcon"
21
+ :expand-btn-plain="expandBtnPlain"
22
+ :expand-btn-size="expandBtnSize"
23
+ :expand-btn-round="expandBtnRound"
24
+ :expand-btn-circle="expandBtnCircle"
25
+ :expand-btn-loading="expandBtnLoading"
26
+ :expand-btn-disabled="expandBtnDisabled"
27
+ :columns="inline ? newColumns : columns"
28
+ :up-icon="upIcon"
29
+ :down-icon="downIcon"
30
+ :show-btn="showBtn"
31
+ :is-collapse="isCollapse"
32
+ :expand-btn-tooltip-desc="expandBtnTooltipDesc"
33
+ :shrink-btn-tooltip-desc="shrinkBtnTooltipDesc"
34
+ @isCollapseChange="isCollapseChange"
35
35
  >
36
36
  <template
37
37
  v-for="item in renderSearchFormItemOptions"
@@ -50,7 +50,7 @@
50
50
  :label-width="item.labelWidth"
51
51
  >
52
52
  <slot :name="item.labelSlot" slot="label">
53
- {{ item.label ? (item.isShowColon?item.label + ':':item.label) : '' }}
53
+ {{ resolveValue(item.label, nfSearchFormModel) ? (item.isShowColon?resolveValue(item.label, nfSearchFormModel) + ':':resolveValue(item.label, nfSearchFormModel)) : '' }}
54
54
  </slot>
55
55
  <search-form-item
56
56
  :key="item.key"
@@ -363,7 +363,8 @@ import {
363
363
  deepClone,
364
364
  createUniqueString,
365
365
  validate as useValidate,
366
- mapDispose
366
+ mapDispose,
367
+ resolveValue
367
368
  } from '@94ai/common-utils'
368
369
  import {
369
370
  throttle
@@ -386,7 +387,7 @@ interface IBtnItems {
386
387
  class?: string,
387
388
  validate?: boolean,
388
389
  onClick?: (formData: Record<string, any>) => void,
389
- show?: (formData: Record<string, any>) => boolean,
390
+ show?: boolean | ((formData: Record<string, any>) => boolean),
390
391
  [key: string]: any,
391
392
  }
392
393
 
@@ -418,6 +419,7 @@ const props = withDefaults(defineProps<{
418
419
  /**
419
420
  * 以下同el-form配置项
420
421
  */
422
+ requiredValidate?: boolean
421
423
  rules?: Record<string, any>
422
424
  labelSuffix?: string
423
425
  hideRequiredAsterisk?: boolean
@@ -576,6 +578,7 @@ const props = withDefaults(defineProps<{
576
578
  columns: undefined,
577
579
  labelPosition: 'top',
578
580
  inline: true,
581
+ requiredValidate: false, // 当前表单搜索时是否需要校验必填项
579
582
  rules: undefined,
580
583
  labelSuffix: undefined,
581
584
  hideRequiredAsterisk: false,
@@ -1012,7 +1015,7 @@ const syncCookiesToSearchFormItemOptions = async (readCached = true) => {
1012
1015
  item._index = index // 混合缓存后的数据
1013
1016
  item.__index = index // 原始顺序
1014
1017
  set(item, 'initHidden', !!item.initHidden)
1015
- set(item, 'destory', !!item.destory)
1018
+ set(item, 'destory', item.destory)
1016
1019
  if (!item.options) set(item, 'options', [])
1017
1020
  return item
1018
1021
  })
@@ -1038,9 +1041,7 @@ syncCookiesToSearchFormItemOptions()
1038
1041
  * @param prop
1039
1042
  */
1040
1043
  const itemIsShow = (item: NfSearchFormItemOption) => {
1041
- return !item.initHidden && !item.destory && (
1042
- useValidate.isFunction(item.show) ? item?.show?.(nfSearchFormModel.value) : true
1043
- )
1044
+ return !item.initHidden && !resolveValue(item.destory, nfSearchFormModel.value) && resolveValue((item?.show === undefined ? true : item?.show), nfSearchFormModel.value)
1044
1045
  }
1045
1046
 
1046
1047
  /**
@@ -1048,7 +1049,7 @@ const itemIsShow = (item: NfSearchFormItemOption) => {
1048
1049
  * @param prop
1049
1050
  */
1050
1051
  const btnIsShow = (item: IBtnItems) => {
1051
- return item.show ? item.show(nfSearchFormModel.value) : true
1052
+ return resolveValue((item?.show === undefined ? true : item?.show), nfSearchFormModel.value)
1052
1053
  }
1053
1054
 
1054
1055
  /**
@@ -1105,7 +1106,7 @@ onBeforeMount(() => {
1105
1106
  * @description 未勾选的筛选项,给予undefined;已勾选的若初次展示,设置默认值
1106
1107
  */
1107
1108
  const refreshNfSearchFormModel = () => {
1108
- props.formOptions.filter(item => !item.destory).forEach(v => {
1109
+ props.formOptions.filter(item => !resolveValue(item.destory, nfSearchFormModel.value)).forEach(v => {
1109
1110
  if (!localShowItems.value.includes(v.prop)) {
1110
1111
  mapDispose.setValue(nfSearchFormModel.value, v.key, undefined)
1111
1112
  } else if (nfSearchFormModel.value[v.prop] === undefined) {
@@ -1119,7 +1120,7 @@ const formsInit = () => {
1119
1120
  // refreshNfSearchFormModel()
1120
1121
  getChangePropKeys()
1121
1122
  props.formOptions.forEach(item => {
1122
- if (item.destory || !localShowItems.value.includes(item.prop)) return
1123
+ if (resolveValue(item.destory, nfSearchFormModel.value) || !localShowItems.value.includes(item.prop)) return
1123
1124
  // 设置默认值
1124
1125
  setDefaultVal(item, true)
1125
1126
  // // 处理动态表单列表
@@ -1210,6 +1211,7 @@ const resetNfSearchFormModel = () => {
1210
1211
  */
1211
1212
  const onNfSearchFormValidate = (callback) => {
1212
1213
  nfSearchFormRef.value.validate(valid => {
1214
+ if (props.requiredValidate && !valid) { return } // 校验不通过
1213
1215
  callback?.(valid)
1214
1216
  })
1215
1217
  }
package/package/types.ts CHANGED
@@ -11,11 +11,11 @@ export type NfSearchFormItemOption = {
11
11
  _index?: number
12
12
  __index?: number
13
13
  initHidden?: boolean
14
- destory?: boolean
14
+ destory?: boolean | ((any: any) => boolean)
15
15
  /**
16
16
  * nf-form-item配置
17
17
  */
18
- label?: string,
18
+ label?: string | ((any: any) => string),
19
19
  addLabel?: string,
20
20
  prop?: string,
21
21
  width?: string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-search-form",
3
- "version": "8.0.1",
3
+ "version": "8.0.8",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zoujiahe <zoujiahe@94ai.com>",
@@ -14,23 +14,23 @@
14
14
  "url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/common-constants": "^8.0.1",
18
- "@94ai/common-utils": "^8.0.1",
19
- "@94ai/nf-button": "^8.0.1",
20
- "@94ai/nf-double-half-year": "^8.0.1",
21
- "@94ai/nf-double-quarter": "^8.0.1",
22
- "@94ai/nf-double-week": "^8.0.1",
23
- "@94ai/nf-double-year": "^8.0.1",
24
- "@94ai/nf-drawer": "^8.0.1",
25
- "@94ai/nf-form": "^8.0.1",
26
- "@94ai/nf-form-item": "^8.0.1",
27
- "@94ai/nf-half-year-picker": "^8.0.1",
28
- "@94ai/nf-lazy-select": "^8.0.1",
29
- "@94ai/nf-message": "^8.0.1",
30
- "@94ai/nf-quarter-picker": "^8.0.1",
31
- "@94ai/nf-theme-chalk": "^8.0.1",
32
- "@94ai/nf-transfer-select": "^8.0.1",
33
- "@94ai/nf-virtual-select": "^8.0.1",
17
+ "@94ai/common-constants": "^8.0.8",
18
+ "@94ai/common-utils": "^8.0.8",
19
+ "@94ai/nf-button": "^8.0.8",
20
+ "@94ai/nf-double-half-year": "^8.0.8",
21
+ "@94ai/nf-double-quarter": "^8.0.8",
22
+ "@94ai/nf-double-week": "^8.0.8",
23
+ "@94ai/nf-double-year": "^8.0.8",
24
+ "@94ai/nf-drawer": "^8.0.8",
25
+ "@94ai/nf-form": "^8.0.8",
26
+ "@94ai/nf-form-item": "^8.0.8",
27
+ "@94ai/nf-half-year-picker": "^8.0.8",
28
+ "@94ai/nf-lazy-select": "^8.0.8",
29
+ "@94ai/nf-message": "^8.0.8",
30
+ "@94ai/nf-quarter-picker": "^8.0.8",
31
+ "@94ai/nf-theme-chalk": "^8.0.8",
32
+ "@94ai/nf-transfer-select": "^8.0.8",
33
+ "@94ai/nf-virtual-select": "^8.0.8",
34
34
  "idb-keyval": "^6.2.1",
35
35
  "resize-observer-polyfill": "^1.5.1",
36
36
  "vue-demi": "^0.14.5",
@@ -50,5 +50,5 @@
50
50
  "types": "lib/index.d.ts",
51
51
  "main": "lib/nf-search-form.cjs.js",
52
52
  "module": "lib/nf-search-form.esm-bundler.js",
53
- "gitHead": "316144e9cd2a06b10e14476d5fdc7f1d42fa88c6"
53
+ "gitHead": "348837ce37e1b93e62681cbd0021bc66cc94e660"
54
54
  }