@94ai/nf-table 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.
package/lib/index.d.ts CHANGED
@@ -48,6 +48,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
48
48
  type: import("vue-demi").PropType<string[]>;
49
49
  default: undefined;
50
50
  };
51
+ viewIdentity: {
52
+ type: import("vue-demi").PropType<string>;
53
+ default: string;
54
+ };
51
55
  searchFormAttrs: {
52
56
  type: import("vue-demi").PropType<import("./types").NfSearchFormAttributes>;
53
57
  default: () => {};
@@ -355,6 +359,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
355
359
  type: import("vue-demi").PropType<string[]>;
356
360
  default: undefined;
357
361
  };
362
+ viewIdentity: {
363
+ type: import("vue-demi").PropType<string>;
364
+ default: string;
365
+ };
358
366
  searchFormAttrs: {
359
367
  type: import("vue-demi").PropType<import("./types").NfSearchFormAttributes>;
360
368
  default: () => {};
@@ -633,6 +641,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
633
641
  text: string;
634
642
  selectEmptyWarningTips: string;
635
643
  showColumn: string[];
644
+ viewIdentity: string;
636
645
  searchFormAttrs: import("./types").NfSearchFormAttributes;
637
646
  searchFormEvents: Partial<Record<import("./types").NfSearchFormEventKey, Function>>;
638
647
  tableAttrs: import("./types").ElTableAttributes;
@@ -745,6 +754,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
745
754
  type: import("vue-demi").PropType<string[]>;
746
755
  default: undefined;
747
756
  };
757
+ viewIdentity: {
758
+ type: import("vue-demi").PropType<string>;
759
+ default: string;
760
+ };
748
761
  searchFormAttrs: {
749
762
  type: import("vue-demi").PropType<import("./types").NfSearchFormAttributes>;
750
763
  default: () => {};
@@ -1151,6 +1164,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
1151
1164
  type: import("vue-demi").PropType<string[]>;
1152
1165
  default: undefined;
1153
1166
  };
1167
+ viewIdentity: {
1168
+ type: import("vue-demi").PropType<string>;
1169
+ default: string;
1170
+ };
1154
1171
  searchFormAttrs: {
1155
1172
  type: import("vue-demi").PropType<import("./types").NfSearchFormAttributes>;
1156
1173
  default: () => {};
@@ -1458,6 +1475,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
1458
1475
  type: import("vue-demi").PropType<string[]>;
1459
1476
  default: undefined;
1460
1477
  };
1478
+ viewIdentity: {
1479
+ type: import("vue-demi").PropType<string>;
1480
+ default: string;
1481
+ };
1461
1482
  searchFormAttrs: {
1462
1483
  type: import("vue-demi").PropType<import("./types").NfSearchFormAttributes>;
1463
1484
  default: () => {};
@@ -1835,6 +1856,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
1835
1856
  text: string;
1836
1857
  selectEmptyWarningTips: string;
1837
1858
  showColumn: string[];
1859
+ viewIdentity: string;
1838
1860
  searchFormAttrs: import("./types").NfSearchFormAttributes;
1839
1861
  searchFormEvents: Partial<Record<import("./types").NfSearchFormEventKey, Function>>;
1840
1862
  tableAttrs: import("./types").ElTableAttributes;
@@ -1948,6 +1970,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
1948
1970
  type: import("vue-demi").PropType<string[]>;
1949
1971
  default: undefined;
1950
1972
  };
1973
+ viewIdentity: {
1974
+ type: import("vue-demi").PropType<string>;
1975
+ default: string;
1976
+ };
1951
1977
  searchFormAttrs: {
1952
1978
  type: import("vue-demi").PropType<import("./types").NfSearchFormAttributes>;
1953
1979
  default: () => {};
@@ -8940,6 +8940,12 @@ const __sfc_main = vueDemi.defineComponent({
8940
8940
  name: "nf-table"
8941
8941
  });
8942
8942
  __sfc_main.props = {
8943
+ viewIdentity: {
8944
+ key: "viewIdentity",
8945
+ required: false,
8946
+ type: String,
8947
+ default: ""
8948
+ },
8943
8949
  data: {
8944
8950
  key: "data",
8945
8951
  required: false,
@@ -9405,6 +9411,17 @@ __sfc_main.setup = (__props, __ctx) => {
9405
9411
  var _a;
9406
9412
  const props = __props;
9407
9413
  const emit = __ctx.emit;
9414
+ const processedColumns = vueDemi.computed(() => {
9415
+ var _a2;
9416
+ const viewField = window.viewField;
9417
+ if (props.viewIdentity && viewField) {
9418
+ const showList = (_a2 = viewField.find((item) => item.viewIdentity === props.viewIdentity)) == null ? void 0 : _a2.fieldList;
9419
+ if (showList == null ? void 0 : showList.length) {
9420
+ return props.columns.filter((item) => showList.includes(item.prop) || item.prop === props.operationPropKey || item.type === "selection" || item.type === "index" || item.type === "expand");
9421
+ }
9422
+ }
9423
+ return props.columns;
9424
+ });
9408
9425
  const getOperationListLocal = (column, scope) => {
9409
9426
  if (typeof column.operationList === "function") {
9410
9427
  return column.operationList(scope);
@@ -9438,7 +9455,61 @@ __sfc_main.setup = (__props, __ctx) => {
9438
9455
  const preSearchFormData = vueDemi.ref({});
9439
9456
  const cPageChangeSearchApi = vueDemi.ref(props.pageChangeSearchApi ?? props.setEasyConf);
9440
9457
  const cInitSearchApi = vueDemi.ref(props.initSearchApi ?? props.setEasyConf);
9441
- const cStorageKey = vueDemi.ref(props.storageKey || `nf-table-columns-cached-key-${routeName.value}`);
9458
+ const cStorageKey = vueDemi.computed(() => {
9459
+ const key = props.storageKey || `nf-table-columns-cached-key-${routeName.value}`;
9460
+ const userId = window.userId;
9461
+ if (props.viewIdentity && userId) {
9462
+ return userId + "-" + key;
9463
+ }
9464
+ return key;
9465
+ });
9466
+ const cStorageKeyViewIdentity = vueDemi.computed(() => {
9467
+ return "nf-table-view-identity";
9468
+ });
9469
+ const checkViewIdentityChange = async () => {
9470
+ const userId = window.userId;
9471
+ const viewField = window.viewField;
9472
+ if (props.viewIdentity && userId && viewField) {
9473
+ let viewIdentity = commonUtils.CachedManager.syncCachedGet(cStorageKeyViewIdentity.value);
9474
+ if (!viewIdentity) {
9475
+ viewIdentity = await commonUtils.CachedManager.asyncCachedGet(cStorageKeyViewIdentity.value);
9476
+ }
9477
+ if (!viewIdentity) {
9478
+ await commonUtils.CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewField);
9479
+ } else {
9480
+ const newViewIdentity = viewField.find((item) => item.viewIdentity === props.viewIdentity);
9481
+ const oldViewIdentity = viewIdentity.find((item) => item.viewIdentity === props.viewIdentity);
9482
+ if (newViewIdentity && !oldViewIdentity || !newViewIdentity && oldViewIdentity) {
9483
+ await clearColumnEditCached();
9484
+ await clearDragCached();
9485
+ } else if (newViewIdentity && oldViewIdentity) {
9486
+ let change = false;
9487
+ newViewIdentity.fieldList.every((item) => {
9488
+ if (!oldViewIdentity.fieldList.includes(item)) {
9489
+ change = true;
9490
+ return;
9491
+ }
9492
+ return true;
9493
+ });
9494
+ if (!change) {
9495
+ oldViewIdentity.fieldList.every((item) => {
9496
+ if (!newViewIdentity.fieldList.includes(item)) {
9497
+ change = true;
9498
+ return;
9499
+ }
9500
+ return true;
9501
+ });
9502
+ }
9503
+ if (change) {
9504
+ await clearColumnEditCached();
9505
+ await clearDragCached();
9506
+ oldViewIdentity.fieldList = newViewIdentity.fieldList;
9507
+ await commonUtils.CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewIdentity);
9508
+ }
9509
+ }
9510
+ }
9511
+ }
9512
+ };
9442
9513
  const cPageAttrs = vueDemi.reactive({
9443
9514
  // 页码,没有props时 & 允许分页时;默认 = 1
9444
9515
  "current-page": props.pageAttrs["current-page"] || (props.alwaysShowPage ? 1 : void 0),
@@ -9512,7 +9583,7 @@ __sfc_main.setup = (__props, __ctx) => {
9512
9583
  if (!init) {
9513
9584
  props.columns._skip = true;
9514
9585
  }
9515
- const result = props.columns.filter((item) => {
9586
+ const result = processedColumns.value.filter((item) => {
9516
9587
  var _a2, _b;
9517
9588
  const prop = item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
9518
9589
  if ((_b = props.showColumn) == null ? void 0 : _b.includes(prop)) {
@@ -9531,7 +9602,7 @@ __sfc_main.setup = (__props, __ctx) => {
9531
9602
  if (result.length) {
9532
9603
  return result;
9533
9604
  }
9534
- return props.columns.map((item) => {
9605
+ return processedColumns.value.map((item) => {
9535
9606
  var _a2;
9536
9607
  return item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
9537
9608
  });
@@ -9548,7 +9619,7 @@ __sfc_main.setup = (__props, __ctx) => {
9548
9619
  const syncLocalShowColumnToCookies = () => {
9549
9620
  if (props.columnEdit) {
9550
9621
  const columnState = {};
9551
- props.columns.map((i, index2) => {
9622
+ processedColumns.value.map((i, index2) => {
9552
9623
  var _a2, _b;
9553
9624
  const prop = i.prop || ((_a2 = i.attr) == null ? void 0 : _a2.prop);
9554
9625
  columnState[prop] = {
@@ -9563,7 +9634,7 @@ __sfc_main.setup = (__props, __ctx) => {
9563
9634
  };
9564
9635
  const syncShowItemToInitHidden = () => {
9565
9636
  props.columns._skip = true;
9566
- props.columns.forEach((item) => {
9637
+ processedColumns.value.forEach((item) => {
9567
9638
  var _a2, _b;
9568
9639
  const prop = item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
9569
9640
  if ((_b = localShowColumn.value) == null ? void 0 : _b.includes(prop)) {
@@ -9579,6 +9650,7 @@ __sfc_main.setup = (__props, __ctx) => {
9579
9650
  const syncCookiesToLocalShowColumn = async () => {
9580
9651
  if (props.columnEdit) {
9581
9652
  try {
9653
+ await checkViewIdentityChange();
9582
9654
  let columnState = commonUtils.CachedManager.syncCachedGet(cStorageKey.value);
9583
9655
  if (!columnState) {
9584
9656
  columnState = await commonUtils.CachedManager.asyncCachedGet(cStorageKey.value);
@@ -9605,6 +9677,7 @@ __sfc_main.setup = (__props, __ctx) => {
9605
9677
  var _a2, _b;
9606
9678
  if (props.columnEdit) {
9607
9679
  try {
9680
+ await checkViewIdentityChange();
9608
9681
  let cached = commonUtils.CachedManager.syncCachedGet(cStorageKey.value);
9609
9682
  if (!cached) {
9610
9683
  cached = await commonUtils.CachedManager.asyncCachedGet(cStorageKey.value);
@@ -9643,7 +9716,7 @@ __sfc_main.setup = (__props, __ctx) => {
9643
9716
  const elTableRefKey = vueDemi.ref(Date.now());
9644
9717
  const syncCookiesToTableColumn = async (readCached = true) => {
9645
9718
  props.columns._skip = true;
9646
- const columns = props.columns.map((item, index2) => {
9719
+ const columns = processedColumns.value.map((item, index2) => {
9647
9720
  var _a2;
9648
9721
  const attr = item.attr || {};
9649
9722
  if (!attr["min-width"] && item.label) {
@@ -9686,6 +9759,7 @@ __sfc_main.setup = (__props, __ctx) => {
9686
9759
  });
9687
9760
  if (readCached && props.columnEdit) {
9688
9761
  try {
9762
+ await checkViewIdentityChange();
9689
9763
  let columnState = commonUtils.CachedManager.syncCachedGet(cStorageKey.value);
9690
9764
  if (!columnState) {
9691
9765
  columnState = await commonUtils.CachedManager.asyncCachedGet(cStorageKey.value);
@@ -9756,6 +9830,7 @@ __sfc_main.setup = (__props, __ctx) => {
9756
9830
  columnEdit: true
9757
9831
  } : {},
9758
9832
  storageKey: props.searchFormStorageKey,
9833
+ viewIdentity: props.viewIdentity,
9759
9834
  ...props.searchFormAttrs
9760
9835
  };
9761
9836
  return obj;
@@ -9974,8 +10049,8 @@ __sfc_main.setup = (__props, __ctx) => {
9974
10049
  };
9975
10050
  const resizeTable = () => {
9976
10051
  if (props.detectResize) {
9977
- const hasLeftFixed = props.columns.find((item) => item.attr.fixed === "left" || item.attr.fixed === true);
9978
- const hasRightFixed = props.columns.find((item) => item.attr.fixed === "right");
10052
+ const hasLeftFixed = processedColumns.value.find((item) => item.attr.fixed === "left" || item.attr.fixed === true);
10053
+ const hasRightFixed = processedColumns.value.find((item) => item.attr.fixed === "right");
9979
10054
  if (!hasLeftFixed && !hasRightFixed) {
9980
10055
  return;
9981
10056
  }
@@ -10040,6 +10115,7 @@ __sfc_main.setup = (__props, __ctx) => {
10040
10115
  });
10041
10116
  return Object.assign({
10042
10117
  resolveValue: commonUtils.resolveValue,
10118
+ processedColumns,
10043
10119
  getOperationListLocal,
10044
10120
  eventsOperationListBtns,
10045
10121
  elTableRef,
@@ -10999,7 +11075,7 @@ var _sfc_render = function render4() {
10999
11075
  "cancel-text": _vm.columnCheckCancelButtonText,
11000
11076
  "basic-field-desc": _vm.columnCheckBasicFieldDesc,
11001
11077
  "show": _vm.nfColumCheckDialogVisible,
11002
- "table-columns": _vm.columns,
11078
+ "table-columns": _vm.processedColumns,
11003
11079
  "column-edit": _vm.columnEdit,
11004
11080
  "storage-key": _vm.cStorageKey,
11005
11081
  "width": _vm.columnCheckWidth,
@@ -11066,7 +11142,7 @@ var _sfc_render = function render4() {
11066
11142
  "column-edit": _vm.columnEdit,
11067
11143
  "operation-prop-key": _vm.operationPropKey,
11068
11144
  "storage-key": _vm.cStorageKey,
11069
- "table-columns": _vm.columns
11145
+ "table-columns": _vm.processedColumns
11070
11146
  }
11071
11147
  })], 2) : _vm._e()], 2);
11072
11148
  };
@@ -8938,6 +8938,12 @@ const __sfc_main = defineComponent({
8938
8938
  name: "nf-table"
8939
8939
  });
8940
8940
  __sfc_main.props = {
8941
+ viewIdentity: {
8942
+ key: "viewIdentity",
8943
+ required: false,
8944
+ type: String,
8945
+ default: ""
8946
+ },
8941
8947
  data: {
8942
8948
  key: "data",
8943
8949
  required: false,
@@ -9403,6 +9409,17 @@ __sfc_main.setup = (__props, __ctx) => {
9403
9409
  var _a;
9404
9410
  const props = __props;
9405
9411
  const emit = __ctx.emit;
9412
+ const processedColumns = computed(() => {
9413
+ var _a2;
9414
+ const viewField = window.viewField;
9415
+ if (props.viewIdentity && viewField) {
9416
+ const showList = (_a2 = viewField.find((item) => item.viewIdentity === props.viewIdentity)) == null ? void 0 : _a2.fieldList;
9417
+ if (showList == null ? void 0 : showList.length) {
9418
+ return props.columns.filter((item) => showList.includes(item.prop) || item.prop === props.operationPropKey || item.type === "selection" || item.type === "index" || item.type === "expand");
9419
+ }
9420
+ }
9421
+ return props.columns;
9422
+ });
9406
9423
  const getOperationListLocal = (column, scope) => {
9407
9424
  if (typeof column.operationList === "function") {
9408
9425
  return column.operationList(scope);
@@ -9436,7 +9453,61 @@ __sfc_main.setup = (__props, __ctx) => {
9436
9453
  const preSearchFormData = ref({});
9437
9454
  const cPageChangeSearchApi = ref(props.pageChangeSearchApi ?? props.setEasyConf);
9438
9455
  const cInitSearchApi = ref(props.initSearchApi ?? props.setEasyConf);
9439
- const cStorageKey = ref(props.storageKey || `nf-table-columns-cached-key-${routeName.value}`);
9456
+ const cStorageKey = computed(() => {
9457
+ const key = props.storageKey || `nf-table-columns-cached-key-${routeName.value}`;
9458
+ const userId = window.userId;
9459
+ if (props.viewIdentity && userId) {
9460
+ return userId + "-" + key;
9461
+ }
9462
+ return key;
9463
+ });
9464
+ const cStorageKeyViewIdentity = computed(() => {
9465
+ return "nf-table-view-identity";
9466
+ });
9467
+ const checkViewIdentityChange = async () => {
9468
+ const userId = window.userId;
9469
+ const viewField = window.viewField;
9470
+ if (props.viewIdentity && userId && viewField) {
9471
+ let viewIdentity = CachedManager.syncCachedGet(cStorageKeyViewIdentity.value);
9472
+ if (!viewIdentity) {
9473
+ viewIdentity = await CachedManager.asyncCachedGet(cStorageKeyViewIdentity.value);
9474
+ }
9475
+ if (!viewIdentity) {
9476
+ await CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewField);
9477
+ } else {
9478
+ const newViewIdentity = viewField.find((item) => item.viewIdentity === props.viewIdentity);
9479
+ const oldViewIdentity = viewIdentity.find((item) => item.viewIdentity === props.viewIdentity);
9480
+ if (newViewIdentity && !oldViewIdentity || !newViewIdentity && oldViewIdentity) {
9481
+ await clearColumnEditCached();
9482
+ await clearDragCached();
9483
+ } else if (newViewIdentity && oldViewIdentity) {
9484
+ let change = false;
9485
+ newViewIdentity.fieldList.every((item) => {
9486
+ if (!oldViewIdentity.fieldList.includes(item)) {
9487
+ change = true;
9488
+ return;
9489
+ }
9490
+ return true;
9491
+ });
9492
+ if (!change) {
9493
+ oldViewIdentity.fieldList.every((item) => {
9494
+ if (!newViewIdentity.fieldList.includes(item)) {
9495
+ change = true;
9496
+ return;
9497
+ }
9498
+ return true;
9499
+ });
9500
+ }
9501
+ if (change) {
9502
+ await clearColumnEditCached();
9503
+ await clearDragCached();
9504
+ oldViewIdentity.fieldList = newViewIdentity.fieldList;
9505
+ await CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewIdentity);
9506
+ }
9507
+ }
9508
+ }
9509
+ }
9510
+ };
9440
9511
  const cPageAttrs = reactive({
9441
9512
  // 页码,没有props时 & 允许分页时;默认 = 1
9442
9513
  "current-page": props.pageAttrs["current-page"] || (props.alwaysShowPage ? 1 : void 0),
@@ -9510,7 +9581,7 @@ __sfc_main.setup = (__props, __ctx) => {
9510
9581
  if (!init) {
9511
9582
  props.columns._skip = true;
9512
9583
  }
9513
- const result = props.columns.filter((item) => {
9584
+ const result = processedColumns.value.filter((item) => {
9514
9585
  var _a2, _b;
9515
9586
  const prop = item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
9516
9587
  if ((_b = props.showColumn) == null ? void 0 : _b.includes(prop)) {
@@ -9529,7 +9600,7 @@ __sfc_main.setup = (__props, __ctx) => {
9529
9600
  if (result.length) {
9530
9601
  return result;
9531
9602
  }
9532
- return props.columns.map((item) => {
9603
+ return processedColumns.value.map((item) => {
9533
9604
  var _a2;
9534
9605
  return item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
9535
9606
  });
@@ -9546,7 +9617,7 @@ __sfc_main.setup = (__props, __ctx) => {
9546
9617
  const syncLocalShowColumnToCookies = () => {
9547
9618
  if (props.columnEdit) {
9548
9619
  const columnState = {};
9549
- props.columns.map((i, index2) => {
9620
+ processedColumns.value.map((i, index2) => {
9550
9621
  var _a2, _b;
9551
9622
  const prop = i.prop || ((_a2 = i.attr) == null ? void 0 : _a2.prop);
9552
9623
  columnState[prop] = {
@@ -9561,7 +9632,7 @@ __sfc_main.setup = (__props, __ctx) => {
9561
9632
  };
9562
9633
  const syncShowItemToInitHidden = () => {
9563
9634
  props.columns._skip = true;
9564
- props.columns.forEach((item) => {
9635
+ processedColumns.value.forEach((item) => {
9565
9636
  var _a2, _b;
9566
9637
  const prop = item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
9567
9638
  if ((_b = localShowColumn.value) == null ? void 0 : _b.includes(prop)) {
@@ -9577,6 +9648,7 @@ __sfc_main.setup = (__props, __ctx) => {
9577
9648
  const syncCookiesToLocalShowColumn = async () => {
9578
9649
  if (props.columnEdit) {
9579
9650
  try {
9651
+ await checkViewIdentityChange();
9580
9652
  let columnState = CachedManager.syncCachedGet(cStorageKey.value);
9581
9653
  if (!columnState) {
9582
9654
  columnState = await CachedManager.asyncCachedGet(cStorageKey.value);
@@ -9603,6 +9675,7 @@ __sfc_main.setup = (__props, __ctx) => {
9603
9675
  var _a2, _b;
9604
9676
  if (props.columnEdit) {
9605
9677
  try {
9678
+ await checkViewIdentityChange();
9606
9679
  let cached = CachedManager.syncCachedGet(cStorageKey.value);
9607
9680
  if (!cached) {
9608
9681
  cached = await CachedManager.asyncCachedGet(cStorageKey.value);
@@ -9641,7 +9714,7 @@ __sfc_main.setup = (__props, __ctx) => {
9641
9714
  const elTableRefKey = ref(Date.now());
9642
9715
  const syncCookiesToTableColumn = async (readCached = true) => {
9643
9716
  props.columns._skip = true;
9644
- const columns = props.columns.map((item, index2) => {
9717
+ const columns = processedColumns.value.map((item, index2) => {
9645
9718
  var _a2;
9646
9719
  const attr = item.attr || {};
9647
9720
  if (!attr["min-width"] && item.label) {
@@ -9684,6 +9757,7 @@ __sfc_main.setup = (__props, __ctx) => {
9684
9757
  });
9685
9758
  if (readCached && props.columnEdit) {
9686
9759
  try {
9760
+ await checkViewIdentityChange();
9687
9761
  let columnState = CachedManager.syncCachedGet(cStorageKey.value);
9688
9762
  if (!columnState) {
9689
9763
  columnState = await CachedManager.asyncCachedGet(cStorageKey.value);
@@ -9754,6 +9828,7 @@ __sfc_main.setup = (__props, __ctx) => {
9754
9828
  columnEdit: true
9755
9829
  } : {},
9756
9830
  storageKey: props.searchFormStorageKey,
9831
+ viewIdentity: props.viewIdentity,
9757
9832
  ...props.searchFormAttrs
9758
9833
  };
9759
9834
  return obj;
@@ -9972,8 +10047,8 @@ __sfc_main.setup = (__props, __ctx) => {
9972
10047
  };
9973
10048
  const resizeTable = () => {
9974
10049
  if (props.detectResize) {
9975
- const hasLeftFixed = props.columns.find((item) => item.attr.fixed === "left" || item.attr.fixed === true);
9976
- const hasRightFixed = props.columns.find((item) => item.attr.fixed === "right");
10050
+ const hasLeftFixed = processedColumns.value.find((item) => item.attr.fixed === "left" || item.attr.fixed === true);
10051
+ const hasRightFixed = processedColumns.value.find((item) => item.attr.fixed === "right");
9977
10052
  if (!hasLeftFixed && !hasRightFixed) {
9978
10053
  return;
9979
10054
  }
@@ -10038,6 +10113,7 @@ __sfc_main.setup = (__props, __ctx) => {
10038
10113
  });
10039
10114
  return Object.assign({
10040
10115
  resolveValue,
10116
+ processedColumns,
10041
10117
  getOperationListLocal,
10042
10118
  eventsOperationListBtns,
10043
10119
  elTableRef,
@@ -10997,7 +11073,7 @@ var _sfc_render = function render4() {
10997
11073
  "cancel-text": _vm.columnCheckCancelButtonText,
10998
11074
  "basic-field-desc": _vm.columnCheckBasicFieldDesc,
10999
11075
  "show": _vm.nfColumCheckDialogVisible,
11000
- "table-columns": _vm.columns,
11076
+ "table-columns": _vm.processedColumns,
11001
11077
  "column-edit": _vm.columnEdit,
11002
11078
  "storage-key": _vm.cStorageKey,
11003
11079
  "width": _vm.columnCheckWidth,
@@ -11064,7 +11140,7 @@ var _sfc_render = function render4() {
11064
11140
  "column-edit": _vm.columnEdit,
11065
11141
  "operation-prop-key": _vm.operationPropKey,
11066
11142
  "storage-key": _vm.cStorageKey,
11067
- "table-columns": _vm.columns
11143
+ "table-columns": _vm.processedColumns
11068
11144
  }
11069
11145
  })], 2) : _vm._e()], 2);
11070
11146
  };
@@ -1,6 +1,7 @@
1
1
  import { NfTableColumnAttributes, ElTableAttributes, ElTableEventKey, ElPaginationEventKey, ElPaginationAttributes, NfSearchFormAttributes, NfSearchFormEventKey, NfTableActionBtnAttributes } from './types';
2
2
  import { ITabItem } from '@94ai/nf-drawer/lib/types';
3
3
  declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
4
+ viewIdentity?: string | undefined;
4
5
  data?: Record<string, any>[] | undefined;
5
6
  columns?: NfTableColumnAttributes[] | any;
6
7
  searchFormAttrs?: NfSearchFormAttributes | undefined;
@@ -79,6 +80,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
79
80
  virtualTableData?: Record<string, any>[] | undefined;
80
81
  virtualProps?: Record<string, any> | undefined;
81
82
  }>, {
83
+ viewIdentity: string;
82
84
  dragCached: boolean;
83
85
  emptyImageSize: number;
84
86
  emptyText: string;
@@ -261,6 +263,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
261
263
  callback: Function;
262
264
  }) => void;
263
265
  }, string, Readonly<import("vue-demi").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
266
+ viewIdentity?: string | undefined;
264
267
  data?: Record<string, any>[] | undefined;
265
268
  columns?: NfTableColumnAttributes[] | any;
266
269
  searchFormAttrs?: NfSearchFormAttributes | undefined;
@@ -339,6 +342,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
339
342
  virtualTableData?: Record<string, any>[] | undefined;
340
343
  virtualProps?: Record<string, any> | undefined;
341
344
  }>, {
345
+ viewIdentity: string;
342
346
  dragCached: boolean;
343
347
  emptyImageSize: number;
344
348
  emptyText: string;
@@ -427,6 +431,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
427
431
  text: string;
428
432
  selectEmptyWarningTips: string;
429
433
  showColumn: string[];
434
+ viewIdentity: string;
430
435
  searchFormAttrs: NfSearchFormAttributes;
431
436
  searchFormEvents: Partial<Record<NfSearchFormEventKey, Function>>;
432
437
  tableAttrs: ElTableAttributes;
@@ -691,7 +691,7 @@
691
691
  :basic-field-desc="columnCheckBasicFieldDesc"
692
692
 
693
693
  :show.sync="nfColumCheckDialogVisible"
694
- :table-columns="columns"
694
+ :table-columns="processedColumns"
695
695
  :column-edit="columnEdit"
696
696
  :storage-key="cStorageKey"
697
697
  :width="columnCheckWidth"
@@ -750,7 +750,7 @@
750
750
  :column-edit="columnEdit"
751
751
  :operation-prop-key="operationPropKey"
752
752
  :storage-key="cStorageKey"
753
- :table-columns="columns"
753
+ :table-columns="processedColumns"
754
754
  />
755
755
  </nf-drawer>
756
756
  </div>
@@ -797,6 +797,7 @@ import { useRoute } from 'vue-router/composables'
797
797
  import VirtualScroll, { VirtualColumn } from 'el-table-virtual-scroll'
798
798
 
799
799
  const props = withDefaults(defineProps<{
800
+ viewIdentity?: string,
800
801
  data?: Record<string, any>[],
801
802
  columns?: NfTableColumnAttributes[] | any,
802
803
  searchFormAttrs?: NfSearchFormAttributes,
@@ -916,6 +917,7 @@ const props = withDefaults(defineProps<{
916
917
  virtualTableData?: Record<string, any>[],
917
918
  virtualProps?: Record<string, any>,
918
919
  }>(), {
920
+ viewIdentity: '',
919
921
  dragCached: true,
920
922
  emptyImageSize: 145,
921
923
  emptyText: '',
@@ -999,6 +1001,18 @@ const emit = defineEmits<{
999
1001
  (e: 'searchApi', event: { data: Record<string, any>, callback: Function}): void
1000
1002
  }>()
1001
1003
 
1004
+ const processedColumns = computed(() => {
1005
+ const viewField = (window as any).viewField
1006
+ if (props.viewIdentity && viewField) {
1007
+ const showList = viewField.find(item => item.viewIdentity === props.viewIdentity)?.fieldList
1008
+ if (showList?.length) {
1009
+ return props.columns.filter(item => showList.includes(item.prop) || item.prop === props.operationPropKey || item.type === 'selection' || item.type === 'index' || item.type === 'expand')
1010
+ }
1011
+ }
1012
+ return props.columns
1013
+ })
1014
+
1015
+
1002
1016
  const getOperationListLocal = (column, scope) => {
1003
1017
  if (typeof column.operationList === 'function') {
1004
1018
  return column.operationList(scope)
@@ -1033,7 +1047,65 @@ const nfColumCheckDialogVisible = ref(false)
1033
1047
  const preSearchFormData = ref({})
1034
1048
  const cPageChangeSearchApi = ref(props.pageChangeSearchApi ?? props.setEasyConf)
1035
1049
  const cInitSearchApi = ref(props.initSearchApi ?? props.setEasyConf)
1036
- const cStorageKey = ref(props.storageKey || `nf-table-columns-cached-key-${routeName.value}`)
1050
+
1051
+ const cStorageKey = computed(() => {
1052
+ const key = props.storageKey || `nf-table-columns-cached-key-${routeName.value}`
1053
+ const userId = (window as any).userId
1054
+ if (props.viewIdentity && userId) {
1055
+ return userId + '-' + key
1056
+ }
1057
+ return key
1058
+ })
1059
+
1060
+ const cStorageKeyViewIdentity = computed(() => {
1061
+ return 'nf-table-view-identity'
1062
+ })
1063
+
1064
+ const checkViewIdentityChange = async () => {
1065
+ const userId = (window as any).userId
1066
+ const viewField = (window as any).viewField
1067
+ if (props.viewIdentity && userId && viewField) {
1068
+ let viewIdentity = CachedManager.syncCachedGet(cStorageKeyViewIdentity.value)
1069
+ if (!viewIdentity) {
1070
+ viewIdentity = await CachedManager.asyncCachedGet(cStorageKeyViewIdentity.value)
1071
+ }
1072
+ if (!viewIdentity) {
1073
+ await CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewField)
1074
+ } else {
1075
+ const newViewIdentity = viewField.find(item => item.viewIdentity === props.viewIdentity)
1076
+ const oldViewIdentity = viewIdentity.find(item => item.viewIdentity === props.viewIdentity)
1077
+ if ((newViewIdentity && !oldViewIdentity) || (!newViewIdentity && oldViewIdentity)) {
1078
+ await clearColumnEditCached()
1079
+ await clearDragCached()
1080
+ } else if (newViewIdentity && oldViewIdentity) {
1081
+ let change = false
1082
+ newViewIdentity.fieldList.every(item => {
1083
+ if (!oldViewIdentity.fieldList.includes(item)) {
1084
+ change = true
1085
+ return
1086
+ }
1087
+ return true
1088
+ })
1089
+ if (!change) {
1090
+ oldViewIdentity.fieldList.every(item => {
1091
+ if (!newViewIdentity.fieldList.includes(item)) {
1092
+ change = true
1093
+ return
1094
+ }
1095
+ return true
1096
+ })
1097
+ }
1098
+ if (change) {
1099
+ await clearColumnEditCached()
1100
+ await clearDragCached()
1101
+ oldViewIdentity.fieldList = newViewIdentity.fieldList
1102
+ await CachedManager.asyncCachedSet(cStorageKeyViewIdentity.value, viewIdentity)
1103
+ }
1104
+ }
1105
+ }
1106
+ }
1107
+ }
1108
+
1037
1109
  const cPageAttrs = reactive({
1038
1110
  // 页码,没有props时 & 允许分页时;默认 = 1
1039
1111
  'current-page': props.pageAttrs['current-page'] || (props.alwaysShowPage ? 1 : undefined),
@@ -1119,7 +1191,7 @@ const initLocalShow = (init = false) => {
1119
1191
  if (!init) {
1120
1192
  props.columns._skip = true
1121
1193
  }
1122
- const result = props.columns.filter(item => {
1194
+ const result = processedColumns.value.filter(item => {
1123
1195
  const prop = item.prop || item.attr?.prop
1124
1196
  if (props.showColumn?.includes(prop!)) {
1125
1197
  item.initHidden = false
@@ -1134,7 +1206,7 @@ const initLocalShow = (init = false) => {
1134
1206
  if (result.length) {
1135
1207
  return result
1136
1208
  }
1137
- return props.columns.map(item => item.prop! || item.attr?.prop!)
1209
+ return processedColumns.value.map(item => item.prop! || item.attr?.prop!)
1138
1210
  }
1139
1211
  const localShowColumn = ref<string[]>(initLocalShow(true))
1140
1212
  watch(() => localShowColumn.value?.length, () => {
@@ -1146,7 +1218,7 @@ watch(() => localShowColumn.value?.length, () => {
1146
1218
  const syncLocalShowColumnToCookies = () => {
1147
1219
  if (props.columnEdit) {
1148
1220
  const columnState = {}
1149
- props.columns.map((i, index) => {
1221
+ processedColumns.value.map((i, index) => {
1150
1222
  const prop = i.prop || i.attr?.prop
1151
1223
  columnState[prop!] = {
1152
1224
  initHidden: i.initHidden || false,
@@ -1161,7 +1233,7 @@ const syncLocalShowColumnToCookies = () => {
1161
1233
 
1162
1234
  const syncShowItemToInitHidden = () => {
1163
1235
  props.columns._skip = true
1164
- props.columns.forEach(item => {
1236
+ processedColumns.value.forEach(item => {
1165
1237
  const prop = item.prop || item.attr?.prop
1166
1238
  if (localShowColumn.value?.includes(prop!)) {
1167
1239
  item.initHidden = false
@@ -1176,6 +1248,7 @@ const syncShowItemToInitHidden = () => {
1176
1248
  const syncCookiesToLocalShowColumn = async () => {
1177
1249
  if (props.columnEdit) {
1178
1250
  try {
1251
+ await checkViewIdentityChange()
1179
1252
  let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(cStorageKey.value)
1180
1253
  if (!columnState) {
1181
1254
  columnState = await CachedManager.asyncCachedGet(cStorageKey.value)
@@ -1203,6 +1276,7 @@ const initCachedData = async () => {
1203
1276
  if (props.columnEdit) {
1204
1277
  // 同步缓存参数
1205
1278
  try {
1279
+ await checkViewIdentityChange()
1206
1280
  let cached: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(cStorageKey.value)
1207
1281
  if (!cached) {
1208
1282
  cached = await CachedManager.asyncCachedGet(cStorageKey.value)
@@ -1243,7 +1317,7 @@ const tableColumns = ref<NfTableColumnAttributes[]>([])
1243
1317
  const elTableRefKey = ref(Date.now())
1244
1318
  const syncCookiesToTableColumn = async (readCached = true) => {
1245
1319
  props.columns._skip = true
1246
- const columns = props.columns!.map((item, index) => {
1320
+ const columns = processedColumns.value!.map((item, index) => {
1247
1321
  const attr = (item.attr || {}) as ElTableColumnAttributes
1248
1322
  // 区分中文、数字、其他字符
1249
1323
  if (!attr['min-width'] && item.label) {
@@ -1288,6 +1362,7 @@ const syncCookiesToTableColumn = async (readCached = true) => {
1288
1362
  if (readCached && props.columnEdit) {
1289
1363
  // 读取缓存 Column 配置
1290
1364
  try {
1365
+ await checkViewIdentityChange()
1291
1366
  let columnState: string | NfTableColumnAttributes | undefined = CachedManager.syncCachedGet(cStorageKey.value)
1292
1367
  if (!columnState) {
1293
1368
  columnState = await CachedManager.asyncCachedGet(cStorageKey.value)
@@ -1359,6 +1434,7 @@ const searchFormAttrer = computed(() => {
1359
1434
  columnEdit: true
1360
1435
  } : {}),
1361
1436
  storageKey: props.searchFormStorageKey,
1437
+ viewIdentity: props.viewIdentity,
1362
1438
  ...props.searchFormAttrs
1363
1439
  }
1364
1440
  return obj
@@ -1598,8 +1674,8 @@ const searchApi = async (formData = {}, refresh = false) => {
1598
1674
  // 调整table固定列高度
1599
1675
  const resizeTable = () => {
1600
1676
  if (props.detectResize) {
1601
- const hasLeftFixed = props.columns.find(item => item.attr.fixed === 'left' || item.attr.fixed === true)
1602
- const hasRightFixed = props.columns.find(item => item.attr.fixed === 'right')
1677
+ const hasLeftFixed = processedColumns.value.find(item => item.attr.fixed === 'left' || item.attr.fixed === true)
1678
+ const hasRightFixed = processedColumns.value.find(item => item.attr.fixed === 'right')
1603
1679
  if (!hasLeftFixed && !hasRightFixed) {
1604
1680
  return
1605
1681
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-table",
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,13 +14,13 @@
14
14
  "url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/common-utils": "^8.3.0",
18
- "@94ai/nf-button": "^8.3.0",
19
- "@94ai/nf-drawer": "^8.3.0",
20
- "@94ai/nf-message": "^8.3.0",
21
- "@94ai/nf-search-form": "^8.3.0",
22
- "@94ai/nf-tag": "^8.3.0",
23
- "@94ai/nf-theme-chalk": "^8.3.0",
17
+ "@94ai/common-utils": "^8.3.4",
18
+ "@94ai/nf-button": "^8.3.4",
19
+ "@94ai/nf-drawer": "^8.3.4",
20
+ "@94ai/nf-message": "^8.3.4",
21
+ "@94ai/nf-search-form": "^8.3.4",
22
+ "@94ai/nf-tag": "^8.3.4",
23
+ "@94ai/nf-theme-chalk": "^8.3.4",
24
24
  "idb-keyval": "^6.2.1",
25
25
  "vue-demi": "^0.14.5",
26
26
  "vue-router": "3.6.4",
@@ -39,5 +39,5 @@
39
39
  "types": "lib/index.d.ts",
40
40
  "main": "lib/nf-table.cjs.js",
41
41
  "module": "lib/nf-table.esm-bundler.js",
42
- "gitHead": "d5b29fecd87582ed9747c58e279d4490294c5891"
42
+ "gitHead": "d79d17da5054791bd9aac0240fd5ef916e2b0ab3"
43
43
  }