@94ai/nf-search-form 8.3.0 → 8.3.4

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.
@@ -6852,6 +6852,12 @@ const __sfc_main = vueDemi.defineComponent({
6852
6852
  name: "nf-search-form"
6853
6853
  });
6854
6854
  __sfc_main.props = {
6855
+ viewIdentity: {
6856
+ key: "viewIdentity",
6857
+ required: false,
6858
+ type: String,
6859
+ default: ""
6860
+ },
6855
6861
  isMvc: {
6856
6862
  key: "isMvc",
6857
6863
  required: false,
@@ -7515,7 +7521,74 @@ __sfc_main.setup = (__props, __ctx) => {
7515
7521
  const useLabelWidth = vueDemi.ref(commonUtils.validate.isNumber(props.labelWidth) ? `${props.labelWidth}px` : props.labelWidth);
7516
7522
  const changeUpdateKeys = vueDemi.ref([]);
7517
7523
  const cBtnItems = vueDemi.ref([]);
7518
- const cStorageKey = vueDemi.ref(props.storageKey || `nf-search-form-columns-cached-key-${routeName.value}`);
7524
+ const cStorageKey = vueDemi.computed(() => {
7525
+ const key = props.storageKey || `nf-search-form-columns-cached-key-${routeName.value}`;
7526
+ if (props.viewIdentity) {
7527
+ const userId = window.userId;
7528
+ if (userId) {
7529
+ return userId + "-" + key;
7530
+ }
7531
+ }
7532
+ return key;
7533
+ });
7534
+ const cStorageKeyViewIdentity = vueDemi.computed(() => {
7535
+ return "nf-search-form-view-identity";
7536
+ });
7537
+ const processedColumns = vueDemi.computed(() => {
7538
+ var _a2;
7539
+ const viewField = window.viewField;
7540
+ if (props.viewIdentity && (viewField == null ? void 0 : viewField.length)) {
7541
+ const showList = (_a2 = viewField.find((item) => item.viewIdentity === props.viewIdentity)) == null ? void 0 : _a2.fieldList;
7542
+ if (showList == null ? void 0 : showList.length) {
7543
+ return props.formOptions.filter((item) => showList.includes(item.prop));
7544
+ }
7545
+ }
7546
+ return props.formOptions;
7547
+ });
7548
+ const checkViewIdentityChange = async () => {
7549
+ const userId = window.userId;
7550
+ const viewField = window.viewField;
7551
+ if (props.viewIdentity && userId && viewField) {
7552
+ let viewIdentity = commonUtils.CachedManager.syncCachedGet(cStorageKeyViewIdentity.value);
7553
+ if (!viewIdentity) {
7554
+ viewIdentity = await commonUtils.CachedManager.asyncCachedGet(cStorageKeyViewIdentity.value);
7555
+ }
7556
+ if (!viewIdentity) {
7557
+ await commonUtils.CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewField);
7558
+ } else {
7559
+ const newViewIdentity = viewField.find((item) => item.viewIdentity === props.viewIdentity);
7560
+ const oldViewIdentity = viewIdentity.find((item) => item.viewIdentity === props.viewIdentity);
7561
+ if (newViewIdentity && !oldViewIdentity || !newViewIdentity && oldViewIdentity) {
7562
+ await clearColumnEditCached();
7563
+ await clearDragCached();
7564
+ } else if (newViewIdentity && oldViewIdentity) {
7565
+ let change = false;
7566
+ newViewIdentity.fieldList.every((item) => {
7567
+ if (!oldViewIdentity.fieldList.includes(item)) {
7568
+ change = true;
7569
+ return;
7570
+ }
7571
+ return true;
7572
+ });
7573
+ if (!change) {
7574
+ oldViewIdentity.fieldList.every((item) => {
7575
+ if (!newViewIdentity.fieldList.includes(item)) {
7576
+ change = true;
7577
+ return;
7578
+ }
7579
+ return true;
7580
+ });
7581
+ }
7582
+ if (change) {
7583
+ await clearColumnEditCached();
7584
+ await clearDragCached();
7585
+ oldViewIdentity.fieldList = newViewIdentity.fieldList;
7586
+ await commonUtils.CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewIdentity);
7587
+ }
7588
+ }
7589
+ }
7590
+ }
7591
+ };
7519
7592
  const nfSearchFormModel = vueDemi.ref(commonUtils.deepClone(props.defaultFormData));
7520
7593
  const setValue = (item, val) => {
7521
7594
  commonUtils.mapDispose.setValue(nfSearchFormModel.value, item.prop, val);
@@ -7542,7 +7615,7 @@ __sfc_main.setup = (__props, __ctx) => {
7542
7615
  };
7543
7616
  const getChangePropKeys = () => {
7544
7617
  let list = [];
7545
- props.formOptions.forEach((item) => {
7618
+ processedColumns.value.forEach((item) => {
7546
7619
  list = list.concat(item.changeProps || []);
7547
7620
  });
7548
7621
  changeUpdateKeys.value = list;
@@ -7583,7 +7656,7 @@ __sfc_main.setup = (__props, __ctx) => {
7583
7656
  };
7584
7657
  const handleChangeProps = (changeProps) => {
7585
7658
  if (changeProps == null ? void 0 : changeProps.length) {
7586
- props.formOptions.forEach((item) => {
7659
+ processedColumns.value.forEach((item) => {
7587
7660
  if (!changeProps.includes(item.prop))
7588
7661
  return;
7589
7662
  setDefaultVal(item, false);
@@ -7601,7 +7674,7 @@ __sfc_main.setup = (__props, __ctx) => {
7601
7674
  if (!init) {
7602
7675
  props.formOptions._skip = true;
7603
7676
  }
7604
- const result = props.formOptions.filter((item) => {
7677
+ const result = processedColumns.value.filter((item) => {
7605
7678
  var _a2;
7606
7679
  if ((_a2 = props.showItems) == null ? void 0 : _a2.includes(item.prop)) {
7607
7680
  item.initHidden = false;
@@ -7616,7 +7689,7 @@ __sfc_main.setup = (__props, __ctx) => {
7616
7689
  if (result.length) {
7617
7690
  return result;
7618
7691
  }
7619
- return props.formOptions.map((item) => item.prop);
7692
+ return processedColumns.value.map((item) => item.prop);
7620
7693
  };
7621
7694
  const localShowItems = vueDemi.ref(initLocalShow(true));
7622
7695
  vueDemi.watch(() => localShowItems.value, async (newVal, oldVal) => {
@@ -7635,7 +7708,7 @@ __sfc_main.setup = (__props, __ctx) => {
7635
7708
  const syncLocalShowColumnToCookies = () => {
7636
7709
  if (props.columnEdit) {
7637
7710
  const columnState = {};
7638
- props.formOptions.map((i, index2) => {
7711
+ processedColumns.value.map((i, index2) => {
7639
7712
  const prop = i.prop;
7640
7713
  columnState[prop] = {
7641
7714
  initHidden: i.initHidden || false,
@@ -7648,7 +7721,7 @@ __sfc_main.setup = (__props, __ctx) => {
7648
7721
  };
7649
7722
  const syncShowItemToInitHidden = () => {
7650
7723
  props.formOptions._skip = true;
7651
- props.formOptions.forEach((item) => {
7724
+ processedColumns.value.forEach((item) => {
7652
7725
  var _a2;
7653
7726
  if ((_a2 = localShowItems.value) == null ? void 0 : _a2.includes(item.prop)) {
7654
7727
  item.initHidden = false;
@@ -7671,6 +7744,7 @@ __sfc_main.setup = (__props, __ctx) => {
7671
7744
  const syncCookiesToLocalShowColumn = async (refreshModel = false) => {
7672
7745
  if (props.columnEdit) {
7673
7746
  try {
7747
+ await checkViewIdentityChange();
7674
7748
  let columnState = commonUtils.CachedManager.syncCachedGet(cStorageKey.value);
7675
7749
  if (!columnState) {
7676
7750
  columnState = await commonUtils.CachedManager.asyncCachedGet(cStorageKey.value);
@@ -7698,6 +7772,7 @@ __sfc_main.setup = (__props, __ctx) => {
7698
7772
  const initCachedData = async () => {
7699
7773
  var _a2, _b;
7700
7774
  if (props.columnEdit) {
7775
+ await checkViewIdentityChange();
7701
7776
  let cached = commonUtils.CachedManager.syncCachedGet(cStorageKey.value);
7702
7777
  if (!cached) {
7703
7778
  cached = await commonUtils.CachedManager.asyncCachedGet(cStorageKey.value);
@@ -7719,6 +7794,7 @@ __sfc_main.setup = (__props, __ctx) => {
7719
7794
  const handleColumnsInitHideAndSort = async (columns) => {
7720
7795
  if (props.columnEdit) {
7721
7796
  try {
7797
+ await checkViewIdentityChange();
7722
7798
  let columnState = commonUtils.CachedManager.syncCachedGet(cStorageKey.value);
7723
7799
  if (!columnState) {
7724
7800
  columnState = await commonUtils.CachedManager.asyncCachedGet(cStorageKey.value);
@@ -7749,7 +7825,7 @@ __sfc_main.setup = (__props, __ctx) => {
7749
7825
  let initSearchForm = true;
7750
7826
  const syncCookiesToSearchFormItemOptions = async (readCached = true) => {
7751
7827
  props.formOptions._skip = true;
7752
- const columns = props.formOptions.map((item, index2) => {
7828
+ const columns = processedColumns.value.map((item, index2) => {
7753
7829
  item.key = item.key || commonUtils.createUniqueString();
7754
7830
  item._index = index2;
7755
7831
  item.__index = index2;
@@ -7807,7 +7883,7 @@ __sfc_main.setup = (__props, __ctx) => {
7807
7883
  formsInit();
7808
7884
  });
7809
7885
  const refreshNfSearchFormModel = () => {
7810
- props.formOptions.filter((item) => !commonUtils.resolveValue(item.destory, nfSearchFormModel.value)).forEach((v) => {
7886
+ processedColumns.value.filter((item) => !commonUtils.resolveValue(item.destory, nfSearchFormModel.value)).forEach((v) => {
7811
7887
  if (!localShowItems.value.includes(v.prop)) {
7812
7888
  commonUtils.mapDispose.setValue(nfSearchFormModel.value, v.key, void 0);
7813
7889
  } else if (nfSearchFormModel.value[v.prop] === void 0) {
@@ -7817,7 +7893,7 @@ __sfc_main.setup = (__props, __ctx) => {
7817
7893
  };
7818
7894
  const formsInit = () => {
7819
7895
  getChangePropKeys();
7820
- props.formOptions.forEach((item) => {
7896
+ processedColumns.value.forEach((item) => {
7821
7897
  if (commonUtils.resolveValue(item.destory, nfSearchFormModel.value) || !localShowItems.value.includes(item.prop))
7822
7898
  return;
7823
7899
  setDefaultVal(item, true);
@@ -7924,7 +8000,7 @@ __sfc_main.setup = (__props, __ctx) => {
7924
8000
  };
7925
8001
  const hiddenNfSearchFormItemOptionField = async (prop) => {
7926
8002
  prop.formOptions._skip = true;
7927
- prop.formOptions.every((item) => {
8003
+ processedColumns.value.every((item) => {
7928
8004
  if (item.prop === prop) {
7929
8005
  item.initHidden = true;
7930
8006
  return false;
@@ -7934,7 +8010,7 @@ __sfc_main.setup = (__props, __ctx) => {
7934
8010
  vueDemi.nextTick(() => {
7935
8011
  props.formOptions._skip = false;
7936
8012
  });
7937
- localShowItems.value = prop.formOptions.filter((item) => !item.initHidden).map((item) => item.prop);
8013
+ localShowItems.value = processedColumns.value.filter((item) => !item.initHidden).map((item) => item.prop);
7938
8014
  refreshNfSearchFormModel();
7939
8015
  await syncLocalShowColumnToCookies();
7940
8016
  await syncCookiesToSearchFormItemOptions();
@@ -7982,7 +8058,7 @@ __sfc_main.setup = (__props, __ctx) => {
7982
8058
  refreshLabel();
7983
8059
  };
7984
8060
  const handleExchangeKey = (data) => {
7985
- props.formOptions.forEach((item) => {
8061
+ processedColumns.value.forEach((item) => {
7986
8062
  var _a2, _b, _c, _d;
7987
8063
  if (!item.exchangeKey)
7988
8064
  return;
@@ -8020,6 +8096,7 @@ __sfc_main.setup = (__props, __ctx) => {
8020
8096
  useLabelWidth,
8021
8097
  cBtnItems,
8022
8098
  cStorageKey,
8099
+ processedColumns,
8023
8100
  nfSearchFormModel,
8024
8101
  handleChangeProps,
8025
8102
  configNfSearchItemVisibleDialog,
@@ -8457,7 +8534,7 @@ var _sfc_render = function render6() {
8457
8534
  "show": _vm.configNfSearchItemVisibleDialog,
8458
8535
  "modal-append-to-body": _vm.modalAppendToBody,
8459
8536
  "storage-key": _vm.cStorageKey,
8460
- "table-columns": _vm.formOptions,
8537
+ "table-columns": _vm.processedColumns,
8461
8538
  "width": _vm.moreDialogWidth,
8462
8539
  "modal": _vm.modal,
8463
8540
  "fullscreen": _vm.fullscreen,
@@ -8530,7 +8607,7 @@ var _sfc_render = function render6() {
8530
8607
  "get-checked-length-desc": _vm.columnCheckGetCheckedLengthDesc,
8531
8608
  "get-all-check-desc": _vm.columnCheckGetAllCheckDesc,
8532
8609
  "storage-key": _vm.cStorageKey,
8533
- "table-columns": _vm.formOptions,
8610
+ "table-columns": _vm.processedColumns,
8534
8611
  "column-edit": _vm.columnEdit
8535
8612
  }
8536
8613
  })], 2) : _vm._e()], 1);
@@ -6850,6 +6850,12 @@ const __sfc_main = defineComponent({
6850
6850
  name: "nf-search-form"
6851
6851
  });
6852
6852
  __sfc_main.props = {
6853
+ viewIdentity: {
6854
+ key: "viewIdentity",
6855
+ required: false,
6856
+ type: String,
6857
+ default: ""
6858
+ },
6853
6859
  isMvc: {
6854
6860
  key: "isMvc",
6855
6861
  required: false,
@@ -7513,7 +7519,74 @@ __sfc_main.setup = (__props, __ctx) => {
7513
7519
  const useLabelWidth = ref(validate.isNumber(props.labelWidth) ? `${props.labelWidth}px` : props.labelWidth);
7514
7520
  const changeUpdateKeys = ref([]);
7515
7521
  const cBtnItems = ref([]);
7516
- const cStorageKey = ref(props.storageKey || `nf-search-form-columns-cached-key-${routeName.value}`);
7522
+ const cStorageKey = computed(() => {
7523
+ const key = props.storageKey || `nf-search-form-columns-cached-key-${routeName.value}`;
7524
+ if (props.viewIdentity) {
7525
+ const userId = window.userId;
7526
+ if (userId) {
7527
+ return userId + "-" + key;
7528
+ }
7529
+ }
7530
+ return key;
7531
+ });
7532
+ const cStorageKeyViewIdentity = computed(() => {
7533
+ return "nf-search-form-view-identity";
7534
+ });
7535
+ const processedColumns = computed(() => {
7536
+ var _a2;
7537
+ const viewField = window.viewField;
7538
+ if (props.viewIdentity && (viewField == null ? void 0 : viewField.length)) {
7539
+ const showList = (_a2 = viewField.find((item) => item.viewIdentity === props.viewIdentity)) == null ? void 0 : _a2.fieldList;
7540
+ if (showList == null ? void 0 : showList.length) {
7541
+ return props.formOptions.filter((item) => showList.includes(item.prop));
7542
+ }
7543
+ }
7544
+ return props.formOptions;
7545
+ });
7546
+ const checkViewIdentityChange = async () => {
7547
+ const userId = window.userId;
7548
+ const viewField = window.viewField;
7549
+ if (props.viewIdentity && userId && viewField) {
7550
+ let viewIdentity = CachedManager.syncCachedGet(cStorageKeyViewIdentity.value);
7551
+ if (!viewIdentity) {
7552
+ viewIdentity = await CachedManager.asyncCachedGet(cStorageKeyViewIdentity.value);
7553
+ }
7554
+ if (!viewIdentity) {
7555
+ await CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewField);
7556
+ } else {
7557
+ const newViewIdentity = viewField.find((item) => item.viewIdentity === props.viewIdentity);
7558
+ const oldViewIdentity = viewIdentity.find((item) => item.viewIdentity === props.viewIdentity);
7559
+ if (newViewIdentity && !oldViewIdentity || !newViewIdentity && oldViewIdentity) {
7560
+ await clearColumnEditCached();
7561
+ await clearDragCached();
7562
+ } else if (newViewIdentity && oldViewIdentity) {
7563
+ let change = false;
7564
+ newViewIdentity.fieldList.every((item) => {
7565
+ if (!oldViewIdentity.fieldList.includes(item)) {
7566
+ change = true;
7567
+ return;
7568
+ }
7569
+ return true;
7570
+ });
7571
+ if (!change) {
7572
+ oldViewIdentity.fieldList.every((item) => {
7573
+ if (!newViewIdentity.fieldList.includes(item)) {
7574
+ change = true;
7575
+ return;
7576
+ }
7577
+ return true;
7578
+ });
7579
+ }
7580
+ if (change) {
7581
+ await clearColumnEditCached();
7582
+ await clearDragCached();
7583
+ oldViewIdentity.fieldList = newViewIdentity.fieldList;
7584
+ await CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewIdentity);
7585
+ }
7586
+ }
7587
+ }
7588
+ }
7589
+ };
7517
7590
  const nfSearchFormModel = ref(deepClone(props.defaultFormData));
7518
7591
  const setValue = (item, val) => {
7519
7592
  mapDispose.setValue(nfSearchFormModel.value, item.prop, val);
@@ -7540,7 +7613,7 @@ __sfc_main.setup = (__props, __ctx) => {
7540
7613
  };
7541
7614
  const getChangePropKeys = () => {
7542
7615
  let list = [];
7543
- props.formOptions.forEach((item) => {
7616
+ processedColumns.value.forEach((item) => {
7544
7617
  list = list.concat(item.changeProps || []);
7545
7618
  });
7546
7619
  changeUpdateKeys.value = list;
@@ -7581,7 +7654,7 @@ __sfc_main.setup = (__props, __ctx) => {
7581
7654
  };
7582
7655
  const handleChangeProps = (changeProps) => {
7583
7656
  if (changeProps == null ? void 0 : changeProps.length) {
7584
- props.formOptions.forEach((item) => {
7657
+ processedColumns.value.forEach((item) => {
7585
7658
  if (!changeProps.includes(item.prop))
7586
7659
  return;
7587
7660
  setDefaultVal(item, false);
@@ -7599,7 +7672,7 @@ __sfc_main.setup = (__props, __ctx) => {
7599
7672
  if (!init) {
7600
7673
  props.formOptions._skip = true;
7601
7674
  }
7602
- const result = props.formOptions.filter((item) => {
7675
+ const result = processedColumns.value.filter((item) => {
7603
7676
  var _a2;
7604
7677
  if ((_a2 = props.showItems) == null ? void 0 : _a2.includes(item.prop)) {
7605
7678
  item.initHidden = false;
@@ -7614,7 +7687,7 @@ __sfc_main.setup = (__props, __ctx) => {
7614
7687
  if (result.length) {
7615
7688
  return result;
7616
7689
  }
7617
- return props.formOptions.map((item) => item.prop);
7690
+ return processedColumns.value.map((item) => item.prop);
7618
7691
  };
7619
7692
  const localShowItems = ref(initLocalShow(true));
7620
7693
  watch(() => localShowItems.value, async (newVal, oldVal) => {
@@ -7633,7 +7706,7 @@ __sfc_main.setup = (__props, __ctx) => {
7633
7706
  const syncLocalShowColumnToCookies = () => {
7634
7707
  if (props.columnEdit) {
7635
7708
  const columnState = {};
7636
- props.formOptions.map((i, index2) => {
7709
+ processedColumns.value.map((i, index2) => {
7637
7710
  const prop = i.prop;
7638
7711
  columnState[prop] = {
7639
7712
  initHidden: i.initHidden || false,
@@ -7646,7 +7719,7 @@ __sfc_main.setup = (__props, __ctx) => {
7646
7719
  };
7647
7720
  const syncShowItemToInitHidden = () => {
7648
7721
  props.formOptions._skip = true;
7649
- props.formOptions.forEach((item) => {
7722
+ processedColumns.value.forEach((item) => {
7650
7723
  var _a2;
7651
7724
  if ((_a2 = localShowItems.value) == null ? void 0 : _a2.includes(item.prop)) {
7652
7725
  item.initHidden = false;
@@ -7669,6 +7742,7 @@ __sfc_main.setup = (__props, __ctx) => {
7669
7742
  const syncCookiesToLocalShowColumn = async (refreshModel = false) => {
7670
7743
  if (props.columnEdit) {
7671
7744
  try {
7745
+ await checkViewIdentityChange();
7672
7746
  let columnState = CachedManager.syncCachedGet(cStorageKey.value);
7673
7747
  if (!columnState) {
7674
7748
  columnState = await CachedManager.asyncCachedGet(cStorageKey.value);
@@ -7696,6 +7770,7 @@ __sfc_main.setup = (__props, __ctx) => {
7696
7770
  const initCachedData = async () => {
7697
7771
  var _a2, _b;
7698
7772
  if (props.columnEdit) {
7773
+ await checkViewIdentityChange();
7699
7774
  let cached = CachedManager.syncCachedGet(cStorageKey.value);
7700
7775
  if (!cached) {
7701
7776
  cached = await CachedManager.asyncCachedGet(cStorageKey.value);
@@ -7717,6 +7792,7 @@ __sfc_main.setup = (__props, __ctx) => {
7717
7792
  const handleColumnsInitHideAndSort = async (columns) => {
7718
7793
  if (props.columnEdit) {
7719
7794
  try {
7795
+ await checkViewIdentityChange();
7720
7796
  let columnState = CachedManager.syncCachedGet(cStorageKey.value);
7721
7797
  if (!columnState) {
7722
7798
  columnState = await CachedManager.asyncCachedGet(cStorageKey.value);
@@ -7747,7 +7823,7 @@ __sfc_main.setup = (__props, __ctx) => {
7747
7823
  let initSearchForm = true;
7748
7824
  const syncCookiesToSearchFormItemOptions = async (readCached = true) => {
7749
7825
  props.formOptions._skip = true;
7750
- const columns = props.formOptions.map((item, index2) => {
7826
+ const columns = processedColumns.value.map((item, index2) => {
7751
7827
  item.key = item.key || createUniqueString();
7752
7828
  item._index = index2;
7753
7829
  item.__index = index2;
@@ -7805,7 +7881,7 @@ __sfc_main.setup = (__props, __ctx) => {
7805
7881
  formsInit();
7806
7882
  });
7807
7883
  const refreshNfSearchFormModel = () => {
7808
- props.formOptions.filter((item) => !resolveValue(item.destory, nfSearchFormModel.value)).forEach((v) => {
7884
+ processedColumns.value.filter((item) => !resolveValue(item.destory, nfSearchFormModel.value)).forEach((v) => {
7809
7885
  if (!localShowItems.value.includes(v.prop)) {
7810
7886
  mapDispose.setValue(nfSearchFormModel.value, v.key, void 0);
7811
7887
  } else if (nfSearchFormModel.value[v.prop] === void 0) {
@@ -7815,7 +7891,7 @@ __sfc_main.setup = (__props, __ctx) => {
7815
7891
  };
7816
7892
  const formsInit = () => {
7817
7893
  getChangePropKeys();
7818
- props.formOptions.forEach((item) => {
7894
+ processedColumns.value.forEach((item) => {
7819
7895
  if (resolveValue(item.destory, nfSearchFormModel.value) || !localShowItems.value.includes(item.prop))
7820
7896
  return;
7821
7897
  setDefaultVal(item, true);
@@ -7922,7 +7998,7 @@ __sfc_main.setup = (__props, __ctx) => {
7922
7998
  };
7923
7999
  const hiddenNfSearchFormItemOptionField = async (prop) => {
7924
8000
  prop.formOptions._skip = true;
7925
- prop.formOptions.every((item) => {
8001
+ processedColumns.value.every((item) => {
7926
8002
  if (item.prop === prop) {
7927
8003
  item.initHidden = true;
7928
8004
  return false;
@@ -7932,7 +8008,7 @@ __sfc_main.setup = (__props, __ctx) => {
7932
8008
  nextTick(() => {
7933
8009
  props.formOptions._skip = false;
7934
8010
  });
7935
- localShowItems.value = prop.formOptions.filter((item) => !item.initHidden).map((item) => item.prop);
8011
+ localShowItems.value = processedColumns.value.filter((item) => !item.initHidden).map((item) => item.prop);
7936
8012
  refreshNfSearchFormModel();
7937
8013
  await syncLocalShowColumnToCookies();
7938
8014
  await syncCookiesToSearchFormItemOptions();
@@ -7980,7 +8056,7 @@ __sfc_main.setup = (__props, __ctx) => {
7980
8056
  refreshLabel();
7981
8057
  };
7982
8058
  const handleExchangeKey = (data) => {
7983
- props.formOptions.forEach((item) => {
8059
+ processedColumns.value.forEach((item) => {
7984
8060
  var _a2, _b, _c, _d;
7985
8061
  if (!item.exchangeKey)
7986
8062
  return;
@@ -8018,6 +8094,7 @@ __sfc_main.setup = (__props, __ctx) => {
8018
8094
  useLabelWidth,
8019
8095
  cBtnItems,
8020
8096
  cStorageKey,
8097
+ processedColumns,
8021
8098
  nfSearchFormModel,
8022
8099
  handleChangeProps,
8023
8100
  configNfSearchItemVisibleDialog,
@@ -8455,7 +8532,7 @@ var _sfc_render = function render6() {
8455
8532
  "show": _vm.configNfSearchItemVisibleDialog,
8456
8533
  "modal-append-to-body": _vm.modalAppendToBody,
8457
8534
  "storage-key": _vm.cStorageKey,
8458
- "table-columns": _vm.formOptions,
8535
+ "table-columns": _vm.processedColumns,
8459
8536
  "width": _vm.moreDialogWidth,
8460
8537
  "modal": _vm.modal,
8461
8538
  "fullscreen": _vm.fullscreen,
@@ -8528,7 +8605,7 @@ var _sfc_render = function render6() {
8528
8605
  "get-checked-length-desc": _vm.columnCheckGetCheckedLengthDesc,
8529
8606
  "get-all-check-desc": _vm.columnCheckGetAllCheckDesc,
8530
8607
  "storage-key": _vm.cStorageKey,
8531
- "table-columns": _vm.formOptions,
8608
+ "table-columns": _vm.processedColumns,
8532
8609
  "column-edit": _vm.columnEdit
8533
8610
  }
8534
8611
  })], 2) : _vm._e()], 1);
@@ -269,7 +269,7 @@
269
269
  :show.sync="configNfSearchItemVisibleDialog"
270
270
  :modal-append-to-body="modalAppendToBody"
271
271
  :storage-key="cStorageKey"
272
- :table-columns="formOptions"
272
+ :table-columns="processedColumns"
273
273
  :width="moreDialogWidth"
274
274
  :modal="modal"
275
275
  :fullscreen="fullscreen"
@@ -322,7 +322,7 @@
322
322
 
323
323
  ref="columnCheckDrawer"
324
324
  :storage-key="cStorageKey"
325
- :table-columns="formOptions"
325
+ :table-columns="processedColumns"
326
326
  :column-edit="columnEdit"
327
327
  />
328
328
  </nf-drawer>
@@ -392,6 +392,7 @@ interface IBtnItems {
392
392
  }
393
393
 
394
394
  const props = withDefaults(defineProps<{
395
+ viewIdentity?: string,
395
396
  /**
396
397
  * isMvc版本改造参数
397
398
  */
@@ -557,6 +558,7 @@ const props = withDefaults(defineProps<{
557
558
  resetBtnText?: string,
558
559
  resetBtnClass?: string,
559
560
  }>(), {
561
+ viewIdentity: '',
560
562
  isMvc: false, // 单向数据流传版本
561
563
  defaultFormData: () => {
562
564
  return {}
@@ -715,7 +717,78 @@ const columnCheckDialog = ref()
715
717
  const useLabelWidth = ref<string | number>(useValidate.isNumber(props.labelWidth) ? `${props.labelWidth}px` : props.labelWidth)
716
718
  const changeUpdateKeys = ref<string[]>([])
717
719
  const cBtnItems = ref<object[]>([]) // 处理后的bthItems
718
- const cStorageKey = ref(props.storageKey || `nf-search-form-columns-cached-key-${routeName.value}`)
720
+
721
+ const cStorageKey = computed(() => {
722
+ const key = props.storageKey || `nf-search-form-columns-cached-key-${routeName.value}`
723
+ if (props.viewIdentity) {
724
+ const userId = (window as any).userId
725
+ if (userId) {
726
+ return userId + '-' + key
727
+ }
728
+ }
729
+ return key
730
+ })
731
+
732
+ const cStorageKeyViewIdentity = computed(() => {
733
+ return 'nf-search-form-view-identity'
734
+ })
735
+
736
+
737
+ const processedColumns = computed(() => {
738
+ const viewField = (window as any).viewField
739
+ if (props.viewIdentity && viewField?.length) {
740
+ const showList = viewField.find(item => item.viewIdentity === props.viewIdentity)?.fieldList
741
+ if (showList?.length) {
742
+ return props.formOptions.filter(item => showList.includes(item.prop))
743
+ }
744
+ }
745
+ return props.formOptions
746
+ })
747
+
748
+ const checkViewIdentityChange = async () => {
749
+ const userId = (window as any).userId
750
+ const viewField = (window as any).viewField
751
+ if (props.viewIdentity && userId && viewField) {
752
+ let viewIdentity = CachedManager.syncCachedGet(cStorageKeyViewIdentity.value)
753
+ if (!viewIdentity) {
754
+ viewIdentity = await CachedManager.asyncCachedGet(cStorageKeyViewIdentity.value)
755
+ }
756
+ if (!viewIdentity) {
757
+ await CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewField)
758
+ } else {
759
+ const newViewIdentity = viewField.find(item => item.viewIdentity === props.viewIdentity)
760
+ const oldViewIdentity = viewIdentity.find(item => item.viewIdentity === props.viewIdentity)
761
+ if ((newViewIdentity && !oldViewIdentity) || (!newViewIdentity && oldViewIdentity)) {
762
+ await clearColumnEditCached()
763
+ await clearDragCached()
764
+ } else if (newViewIdentity && oldViewIdentity) {
765
+ let change = false
766
+ newViewIdentity.fieldList.every(item => {
767
+ if (!oldViewIdentity.fieldList.includes(item)) {
768
+ change = true
769
+ return
770
+ }
771
+ return true
772
+ })
773
+ if (!change) {
774
+ oldViewIdentity.fieldList.every(item => {
775
+ if (!newViewIdentity.fieldList.includes(item)) {
776
+ change = true
777
+ return
778
+ }
779
+ return true
780
+ })
781
+ }
782
+ if (change) {
783
+ await clearColumnEditCached()
784
+ await clearDragCached()
785
+ oldViewIdentity.fieldList = newViewIdentity.fieldList
786
+ await CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewIdentity)
787
+ }
788
+ }
789
+ }
790
+ }
791
+ }
719
792
 
720
793
  /**
721
794
  * 表单填充的数据
@@ -762,7 +835,7 @@ const setDefaultVal = (item, init = true) => {
762
835
  // 获取changeProps所有涉及的key
763
836
  const getChangePropKeys = () => {
764
837
  let list = []
765
- props.formOptions.forEach(item => {
838
+ processedColumns.value.forEach(item => {
766
839
  list = list.concat(item.changeProps || [])
767
840
  })
768
841
  changeUpdateKeys.value = list
@@ -813,7 +886,7 @@ const btnItemsInit = () => {
813
886
  */
814
887
  const handleChangeProps = (changeProps: string[]) => {
815
888
  if (changeProps?.length) {
816
- props.formOptions.forEach(item => {
889
+ processedColumns.value.forEach(item => {
817
890
  if (!changeProps.includes(item.prop)) return
818
891
  setDefaultVal(item, false)
819
892
  triggerGetOptions(item)
@@ -835,7 +908,7 @@ const initLocalShow = (init = false) => {
835
908
  if (!init) {
836
909
  props.formOptions._skip = true
837
910
  }
838
- const result = props.formOptions.filter(item => {
911
+ const result = processedColumns.value.filter(item => {
839
912
  if (props.showItems?.includes(item.prop!)) {
840
913
  item.initHidden = false
841
914
  }
@@ -849,7 +922,7 @@ const initLocalShow = (init = false) => {
849
922
  if (result.length) {
850
923
  return result
851
924
  }
852
- return props.formOptions.map(item => item.prop!)
925
+ return processedColumns.value.map(item => item.prop!)
853
926
  }
854
927
  /**
855
928
  * 表单显示的item集合
@@ -870,7 +943,7 @@ watch(() => localShowItems.value, async (newVal, oldVal) => {
870
943
  const syncLocalShowColumnToCookies = () => {
871
944
  if (props.columnEdit) {
872
945
  const columnState = {}
873
- props.formOptions.map((i, index) => {
946
+ processedColumns.value.map((i, index) => {
874
947
  const prop = i.prop
875
948
  columnState[prop!] = {
876
949
  initHidden: i.initHidden || false,
@@ -883,7 +956,7 @@ const syncLocalShowColumnToCookies = () => {
883
956
  }
884
957
  const syncShowItemToInitHidden = () => {
885
958
  props.formOptions._skip = true
886
- props.formOptions.forEach(item => {
959
+ processedColumns.value.forEach(item => {
887
960
  if (localShowItems.value?.includes(item.prop!)) {
888
961
  item.initHidden = false
889
962
  } else {
@@ -908,6 +981,7 @@ const setLocalShowItems = (list, syncToInitHidden = false) => {
908
981
  const syncCookiesToLocalShowColumn = async (refreshModel = false) => {
909
982
  if (props.columnEdit) {
910
983
  try {
984
+ await checkViewIdentityChange()
911
985
  let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(cStorageKey.value)
912
986
  if (!columnState) {
913
987
  columnState = await CachedManager.asyncCachedGet(cStorageKey.value)
@@ -936,6 +1010,7 @@ const syncCookiesToLocalShowColumn = async (refreshModel = false) => {
936
1010
 
937
1011
  const initCachedData = async () => {
938
1012
  if (props.columnEdit) {
1013
+ await checkViewIdentityChange()
939
1014
  // 同步缓存参数
940
1015
  let cached: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(cStorageKey.value)
941
1016
  if (!cached) {
@@ -975,6 +1050,7 @@ const handleColumnsInitHideAndSort = async(columns: any[]) => {
975
1050
  if (props.columnEdit) {
976
1051
  // 读取缓存 Column 配置
977
1052
  try {
1053
+ await checkViewIdentityChange()
978
1054
  // 同步缓存参数
979
1055
  let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(cStorageKey.value)
980
1056
  if (!columnState) {
@@ -1010,7 +1086,7 @@ const renderSearchFormItemOptions = ref<NfSearchFormItemOption[]>([])
1010
1086
  let initSearchForm = true
1011
1087
  const syncCookiesToSearchFormItemOptions = async (readCached = true) => {
1012
1088
  props.formOptions._skip = true
1013
- const columns = props.formOptions!.map((item, index) => {
1089
+ const columns = processedColumns.value!.map((item, index) => {
1014
1090
  item.key = item.key || createUniqueString()
1015
1091
  item._index = index // 混合缓存后的数据
1016
1092
  item.__index = index // 原始顺序
@@ -1106,7 +1182,7 @@ onBeforeMount(() => {
1106
1182
  * @description 未勾选的筛选项,给予undefined;已勾选的若初次展示,设置默认值
1107
1183
  */
1108
1184
  const refreshNfSearchFormModel = () => {
1109
- props.formOptions.filter(item => !resolveValue(item.destory, nfSearchFormModel.value)).forEach(v => {
1185
+ processedColumns.value.filter(item => !resolveValue(item.destory, nfSearchFormModel.value)).forEach(v => {
1110
1186
  if (!localShowItems.value.includes(v.prop)) {
1111
1187
  mapDispose.setValue(nfSearchFormModel.value, v.key, undefined)
1112
1188
  } else if (nfSearchFormModel.value[v.prop] === undefined) {
@@ -1119,7 +1195,7 @@ const refreshNfSearchFormModel = () => {
1119
1195
  const formsInit = () => {
1120
1196
  // refreshNfSearchFormModel()
1121
1197
  getChangePropKeys()
1122
- props.formOptions.forEach(item => {
1198
+ processedColumns.value.forEach(item => {
1123
1199
  if (resolveValue(item.destory, nfSearchFormModel.value) || !localShowItems.value.includes(item.prop)) return
1124
1200
  // 设置默认值
1125
1201
  setDefaultVal(item, true)
@@ -1252,7 +1328,7 @@ const onNfSearchFormClick = (item) => {
1252
1328
  */
1253
1329
  const hiddenNfSearchFormItemOptionField = async (prop) => {
1254
1330
  prop.formOptions._skip = true
1255
- prop.formOptions.every(item => {
1331
+ processedColumns.value.every(item => {
1256
1332
  if (item.prop === prop) {
1257
1333
  item.initHidden = true
1258
1334
  return false
@@ -1262,7 +1338,7 @@ const hiddenNfSearchFormItemOptionField = async (prop) => {
1262
1338
  nextTick(() => {
1263
1339
  props.formOptions._skip = false
1264
1340
  })
1265
- localShowItems.value = prop.formOptions.filter(item => !item.initHidden).map(item => item.prop)
1341
+ localShowItems.value = processedColumns.value.filter(item => !item.initHidden).map(item => item.prop)
1266
1342
  refreshNfSearchFormModel()
1267
1343
  await syncLocalShowColumnToCookies()
1268
1344
  await syncCookiesToSearchFormItemOptions()
@@ -1322,7 +1398,7 @@ const nfSearchFormItemOptionFieldsSave = async (value) => {
1322
1398
  * 数组值分割多个字段
1323
1399
  */
1324
1400
  const handleExchangeKey = (data) => {
1325
- props.formOptions.forEach(item => {
1401
+ processedColumns.value.forEach(item => {
1326
1402
  if (!item.exchangeKey) return
1327
1403
  const { type, value } = item.exchangeKey
1328
1404
  const key = item.prop
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-search-form",
3
- "version": "8.3.0",
3
+ "version": "8.3.4",
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.3.0",
18
- "@94ai/common-utils": "^8.3.0",
19
- "@94ai/nf-button": "^8.3.0",
20
- "@94ai/nf-double-half-year": "^8.3.0",
21
- "@94ai/nf-double-quarter": "^8.3.0",
22
- "@94ai/nf-double-week": "^8.3.0",
23
- "@94ai/nf-double-year": "^8.3.0",
24
- "@94ai/nf-drawer": "^8.3.0",
25
- "@94ai/nf-form": "^8.3.0",
26
- "@94ai/nf-form-item": "^8.3.0",
27
- "@94ai/nf-half-year-picker": "^8.3.0",
28
- "@94ai/nf-lazy-select": "^8.3.0",
29
- "@94ai/nf-message": "^8.3.0",
30
- "@94ai/nf-quarter-picker": "^8.3.0",
31
- "@94ai/nf-theme-chalk": "^8.3.0",
32
- "@94ai/nf-transfer-select": "^8.3.0",
33
- "@94ai/nf-virtual-select": "^8.3.0",
17
+ "@94ai/common-constants": "^8.3.4",
18
+ "@94ai/common-utils": "^8.3.4",
19
+ "@94ai/nf-button": "^8.3.4",
20
+ "@94ai/nf-double-half-year": "^8.3.4",
21
+ "@94ai/nf-double-quarter": "^8.3.4",
22
+ "@94ai/nf-double-week": "^8.3.4",
23
+ "@94ai/nf-double-year": "^8.3.4",
24
+ "@94ai/nf-drawer": "^8.3.4",
25
+ "@94ai/nf-form": "^8.3.4",
26
+ "@94ai/nf-form-item": "^8.3.4",
27
+ "@94ai/nf-half-year-picker": "^8.3.4",
28
+ "@94ai/nf-lazy-select": "^8.3.4",
29
+ "@94ai/nf-message": "^8.3.4",
30
+ "@94ai/nf-quarter-picker": "^8.3.4",
31
+ "@94ai/nf-theme-chalk": "^8.3.4",
32
+ "@94ai/nf-transfer-select": "^8.3.4",
33
+ "@94ai/nf-virtual-select": "^8.3.4",
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": "d5b29fecd87582ed9747c58e279d4490294c5891"
53
+ "gitHead": "d79d17da5054791bd9aac0240fd5ef916e2b0ab3"
54
54
  }