@94ai/nf-table 3.2.26 → 3.2.32

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
@@ -37,7 +37,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
37
37
  default: string;
38
38
  };
39
39
  columns: {
40
- type: import("vue-demi").PropType<import("./types").NfTableColumnAttributes[]>;
40
+ type: import("vue-demi").PropType<any>;
41
41
  default: () => never[];
42
42
  };
43
43
  searchFormAttrs: {
@@ -300,7 +300,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
300
300
  default: string;
301
301
  };
302
302
  columns: {
303
- type: import("vue-demi").PropType<import("./types").NfTableColumnAttributes[]>;
303
+ type: import("vue-demi").PropType<any>;
304
304
  default: () => never[];
305
305
  };
306
306
  searchFormAttrs: {
@@ -538,7 +538,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
538
538
  text: string;
539
539
  selectEmptyWarningTips: string;
540
540
  operationPropKey: string;
541
- columns: import("./types").NfTableColumnAttributes[];
541
+ columns: any;
542
542
  searchFormAttrs: import("./types").NfSearchFormAttributes;
543
543
  searchFormEvents: Partial<Record<import("./types").NfSearchFormEventKey, Function>>;
544
544
  tableAttrs: import("./types").ElTableAttributes;
@@ -631,7 +631,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
631
631
  default: string;
632
632
  };
633
633
  columns: {
634
- type: import("vue-demi").PropType<import("./types").NfTableColumnAttributes[]>;
634
+ type: import("vue-demi").PropType<any>;
635
635
  default: () => never[];
636
636
  };
637
637
  searchFormAttrs: {
@@ -888,6 +888,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
888
888
  _index?: number | undefined;
889
889
  __index?: number | undefined;
890
890
  initHidden?: boolean | undefined;
891
+ destory?: boolean | undefined;
891
892
  type?: "index" | "selection" | "expand" | undefined;
892
893
  label?: string | undefined;
893
894
  prop?: string | undefined;
@@ -929,7 +930,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
929
930
  }[]>;
930
931
  syncLocalShowColumnToCookies: () => void;
931
932
  syncCookiesToLocalShowColumn: () => void;
932
- syncCookiesToTableColumn: () => void;
933
+ syncCookiesToTableColumn: (readCached?: boolean) => void;
933
934
  }> & import("vue/types/v3-component-options").ExtractComputedReturns<{}> & import("vue-demi").ComponentCustomProperties & Readonly<import("vue-demi").ExtractPropTypes<{
934
935
  data: {
935
936
  type: import("vue-demi").PropType<Record<string, any>[]>;
@@ -968,7 +969,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
968
969
  default: string;
969
970
  };
970
971
  columns: {
971
- type: import("vue-demi").PropType<import("./types").NfTableColumnAttributes[]>;
972
+ type: import("vue-demi").PropType<any>;
972
973
  default: () => never[];
973
974
  };
974
975
  searchFormAttrs: {
@@ -1231,7 +1232,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
1231
1232
  default: string;
1232
1233
  };
1233
1234
  columns: {
1234
- type: import("vue-demi").PropType<import("./types").NfTableColumnAttributes[]>;
1235
+ type: import("vue-demi").PropType<any>;
1235
1236
  default: () => never[];
1236
1237
  };
1237
1238
  searchFormAttrs: {
@@ -1488,6 +1489,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
1488
1489
  _index?: number | undefined;
1489
1490
  __index?: number | undefined;
1490
1491
  initHidden?: boolean | undefined;
1492
+ destory?: boolean | undefined;
1491
1493
  type?: "index" | "selection" | "expand" | undefined;
1492
1494
  label?: string | undefined;
1493
1495
  prop?: string | undefined;
@@ -1529,7 +1531,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
1529
1531
  }[]>;
1530
1532
  syncLocalShowColumnToCookies: () => void;
1531
1533
  syncCookiesToLocalShowColumn: () => void;
1532
- syncCookiesToTableColumn: () => void;
1534
+ syncCookiesToTableColumn: (readCached?: boolean) => void;
1533
1535
  }, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {
1534
1536
  fieldsChange: (event: string[]) => void;
1535
1537
  "update:showColumn": (event: string[] | undefined) => void;
@@ -1543,7 +1545,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
1543
1545
  text: string;
1544
1546
  selectEmptyWarningTips: string;
1545
1547
  operationPropKey: string;
1546
- columns: import("./types").NfTableColumnAttributes[];
1548
+ columns: any;
1547
1549
  searchFormAttrs: import("./types").NfSearchFormAttributes;
1548
1550
  searchFormEvents: Partial<Record<import("./types").NfSearchFormEventKey, Function>>;
1549
1551
  tableAttrs: import("./types").ElTableAttributes;
@@ -1637,7 +1639,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
1637
1639
  default: string;
1638
1640
  };
1639
1641
  columns: {
1640
- type: import("vue-demi").PropType<import("./types").NfTableColumnAttributes[]>;
1642
+ type: import("vue-demi").PropType<any>;
1641
1643
  default: () => never[];
1642
1644
  };
1643
1645
  searchFormAttrs: {
@@ -1915,6 +1917,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
1915
1917
  _index?: number | undefined;
1916
1918
  __index?: number | undefined;
1917
1919
  initHidden?: boolean | undefined;
1920
+ destory?: boolean | undefined;
1918
1921
  type?: "index" | "selection" | "expand" | undefined;
1919
1922
  label?: string | undefined;
1920
1923
  prop?: string | undefined;
@@ -5317,13 +5317,14 @@ __sfc_main$1.setup = (__props, __ctx) => {
5317
5317
  const fixedColumn = vueDemi.ref([]);
5318
5318
  const unFixedColumn = vueDemi.ref([]);
5319
5319
  vueDemi.onBeforeMount(() => {
5320
- currentTable.value = deepClone(props.tableColumns).sort((a, b) => a._index - b._index < 0 ? -1 : a._index - b._index > 0 ? 1 : 0);
5320
+ currentTable.value = deepClone(props.tableColumns.filter((item) => !item.destory)).sort((a, b) => a._index - b._index < 0 ? -1 : a._index - b._index > 0 ? 1 : 0);
5321
5321
  currentTable.value.map((i) => {
5322
5322
  if (!i.attr) {
5323
5323
  i.attr = {};
5324
5324
  }
5325
5325
  });
5326
- setFields(props.tableColumns);
5326
+ const list = props.tableColumns.filter((item) => !item.destory);
5327
+ setFields(list);
5327
5328
  updateColumn();
5328
5329
  if (currentTable.value.findIndex((item) => !!item.type) > -1) {
5329
5330
  unChangedColumn.value.push("selection");
@@ -5336,7 +5337,7 @@ __sfc_main$1.setup = (__props, __ctx) => {
5336
5337
  }
5337
5338
  if (currentTable.value.every((i) => !i.initHidden)) {
5338
5339
  showColumn.value = currentTable.value.map((i) => i.prop);
5339
- checkedCount.value = props.tableColumns.length;
5340
+ checkedCount.value = list.length;
5340
5341
  checkAll.value = true;
5341
5342
  isIndeterminate.value = false;
5342
5343
  }
@@ -5761,7 +5762,7 @@ __sfc_main.props = {
5761
5762
  columns: {
5762
5763
  key: "columns",
5763
5764
  required: false,
5764
- type: Array,
5765
+ type: [Array, null],
5765
5766
  default: () => []
5766
5767
  },
5767
5768
  searchFormAttrs: {
@@ -6214,17 +6215,26 @@ __sfc_main.setup = (__props, __ctx) => {
6214
6215
  immediate: true
6215
6216
  });
6216
6217
  const initLocalShow = () => {
6217
- return props.columns.filter((item) => {
6218
+ props.columns._skip = true;
6219
+ const result = props.columns.filter((item) => {
6218
6220
  var _a2, _b2;
6219
6221
  const prop = item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
6220
6222
  if ((_b2 = props.showColumn) == null ? void 0 : _b2.includes(prop)) {
6221
6223
  item.initHidden = false;
6222
6224
  }
6223
- return item.initHidden;
6225
+ return !item.initHidden;
6224
6226
  }).map((item) => {
6225
6227
  var _a2;
6226
6228
  return item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
6227
6229
  });
6230
+ props.columns._skip = false;
6231
+ if (result.length) {
6232
+ return result;
6233
+ }
6234
+ return props.columns.map((item) => {
6235
+ var _a2;
6236
+ return item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
6237
+ });
6228
6238
  };
6229
6239
  const localShowColumn = vueDemi.ref(initLocalShow());
6230
6240
  vueDemi.watch(() => {
@@ -6252,6 +6262,19 @@ __sfc_main.setup = (__props, __ctx) => {
6252
6262
  (_a2 = instance == null ? void 0 : instance.$cookies) == null ? void 0 : _a2.set(props.storageKey, JSON.stringify(columnState), -1);
6253
6263
  }
6254
6264
  };
6265
+ const syncShowItemToInitHidden = () => {
6266
+ props.columns._skip = true;
6267
+ props.columns.forEach((item) => {
6268
+ var _a2, _b2;
6269
+ const prop = item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
6270
+ if ((_b2 = localShowColumn.value) == null ? void 0 : _b2.includes(prop)) {
6271
+ item.initHidden = false;
6272
+ } else {
6273
+ item.initHidden = true;
6274
+ }
6275
+ });
6276
+ props.columns._skip = false;
6277
+ };
6255
6278
  const syncCookiesToLocalShowColumn = () => {
6256
6279
  var _a2;
6257
6280
  if (props.columnEdit) {
@@ -6267,15 +6290,7 @@ __sfc_main.setup = (__props, __ctx) => {
6267
6290
  }
6268
6291
  }
6269
6292
  localShowColumn.value = showColumnItems;
6270
- props.columns.forEach((item) => {
6271
- var _a3, _b2;
6272
- const prop = item.prop || ((_a3 = item.attr) == null ? void 0 : _a3.prop);
6273
- if ((_b2 = localShowColumn.value) == null ? void 0 : _b2.includes(prop)) {
6274
- item.initHidden = false;
6275
- } else {
6276
- item.initHidden = true;
6277
- }
6278
- });
6293
+ syncShowItemToInitHidden();
6279
6294
  }
6280
6295
  }
6281
6296
  };
@@ -6290,8 +6305,9 @@ __sfc_main.setup = (__props, __ctx) => {
6290
6305
  }
6291
6306
  const tableColumns = vueDemi.ref([]);
6292
6307
  const elTableRefKey = vueDemi.ref(Date.now());
6293
- const syncCookiesToTableColumn = () => {
6308
+ const syncCookiesToTableColumn = (readCached = true) => {
6294
6309
  var _a2;
6310
+ props.columns._skip = true;
6295
6311
  const columns = props.columns.map((item, index2) => {
6296
6312
  var _a3;
6297
6313
  ((_a3 = item.label) == null ? void 0 : _a3.length) || 0;
@@ -6316,7 +6332,7 @@ __sfc_main.setup = (__props, __ctx) => {
6316
6332
  item.__index = index2;
6317
6333
  return item;
6318
6334
  });
6319
- if (props.columnEdit) {
6335
+ if (readCached && props.columnEdit) {
6320
6336
  let columnState = (_a2 = instance == null ? void 0 : instance.$cookies) == null ? void 0 : _a2.get(props.storageKey);
6321
6337
  if (columnState) {
6322
6338
  if (typeof columnState === "string") {
@@ -6338,21 +6354,34 @@ __sfc_main.setup = (__props, __ctx) => {
6338
6354
  }
6339
6355
  }
6340
6356
  }
6357
+ props.columns._skip = true;
6341
6358
  tableColumns.value = columns.sort((a, b) => a._index - b._index < 0 ? -1 : a._index - b._index > 0 ? 1 : 0);
6342
6359
  elTableRefKey.value = Date.now();
6343
6360
  };
6344
6361
  syncCookiesToTableColumn();
6362
+ vueDemi.onBeforeMount(() => {
6363
+ vueDemi.watch(() => {
6364
+ return props.columns;
6365
+ }, () => {
6366
+ if (props.columns._skip) {
6367
+ return;
6368
+ }
6369
+ syncCookiesToTableColumn(false);
6370
+ }, {
6371
+ deep: true
6372
+ });
6373
+ });
6345
6374
  const tableAttrer = vueDemi.computed(() => {
6346
6375
  const obj = {
6347
6376
  "header-cell-style": {
6348
- "text-align": "left",
6377
+ "text-align": "center",
6349
6378
  "background": "#F5F7FA",
6350
6379
  "height": "48px",
6351
6380
  "color": "#303133",
6352
6381
  "font-size": "14px"
6353
6382
  },
6354
6383
  "cell-style": {
6355
- "text-align": "left"
6384
+ "text-align": "center"
6356
6385
  },
6357
6386
  resizable: true,
6358
6387
  border: true,
@@ -6394,10 +6423,13 @@ __sfc_main.setup = (__props, __ctx) => {
6394
6423
  });
6395
6424
  const isShow = (row) => {
6396
6425
  var _a2;
6397
- if (!((_a2 = localShowColumn.value) == null ? void 0 : _a2.length) || row.type) {
6426
+ if (row.type) {
6398
6427
  return true;
6399
6428
  }
6400
- return localShowColumn.value.includes(row.prop) && !row.initHidden;
6429
+ if (!((_a2 = localShowColumn.value) == null ? void 0 : _a2.length)) {
6430
+ return !row.initHidden && !row.destory;
6431
+ }
6432
+ return localShowColumn.value.includes(row.prop) && !row.initHidden && !row.destory;
6401
6433
  };
6402
6434
  const resetNfSearchFormModel = () => {
6403
6435
  var _a2;
@@ -6459,16 +6491,6 @@ __sfc_main.setup = (__props, __ctx) => {
6459
6491
  }
6460
6492
  await ((_b2 = (_a2 = props.tableEvents)["header-dragend"]) == null ? void 0 : _b2.call(_a2, newWidth, oldWidth, column, event));
6461
6493
  };
6462
- const syncShowItemToInitHidden = () => {
6463
- props.columns.forEach((item) => {
6464
- var _a2;
6465
- if ((_a2 = localShowColumn.value) == null ? void 0 : _a2.includes(item.prop)) {
6466
- item.initHidden = false;
6467
- } else {
6468
- item.initHidden = true;
6469
- }
6470
- });
6471
- };
6472
6494
  const columnCheckConfirmFeedback = (value) => {
6473
6495
  if (!props.columnEdit) {
6474
6496
  const itemsList = [];
@@ -6514,7 +6536,6 @@ __sfc_main.setup = (__props, __ctx) => {
6514
6536
  }
6515
6537
  });
6516
6538
  return Object.assign({
6517
- props,
6518
6539
  elTableRef,
6519
6540
  nfTableActionContainerRef,
6520
6541
  nfTablePaginationRef,
@@ -7277,7 +7298,7 @@ var _sfc_render = function render3() {
7277
7298
  ref: "columnCheckDialog",
7278
7299
  attrs: {
7279
7300
  "show": _vm.nfColumCheckDialogVisible,
7280
- "table-columns": _vm.props.columns,
7301
+ "table-columns": _vm.columns,
7281
7302
  "show-column": _vm.localShowColumn,
7282
7303
  "storage-key": _vm.storageKey,
7283
7304
  "title": _vm.columnCheckTitle,
@@ -7343,7 +7364,7 @@ var _sfc_render = function render3() {
7343
7364
  "get-all-check-desc": _vm.columnCheckGetAllCheckDesc,
7344
7365
  "operation-prop-key": _vm.operationPropKey,
7345
7366
  "storage-key": _vm.storageKey,
7346
- "table-columns": _vm.props.columns,
7367
+ "table-columns": _vm.columns,
7347
7368
  "select-empty-warning-tips": _vm.selectEmptyWarningTips
7348
7369
  }
7349
7370
  })], 2) : _vm._e()], 2);
@@ -5315,13 +5315,14 @@ __sfc_main$1.setup = (__props, __ctx) => {
5315
5315
  const fixedColumn = ref([]);
5316
5316
  const unFixedColumn = ref([]);
5317
5317
  onBeforeMount(() => {
5318
- currentTable.value = deepClone(props.tableColumns).sort((a, b) => a._index - b._index < 0 ? -1 : a._index - b._index > 0 ? 1 : 0);
5318
+ currentTable.value = deepClone(props.tableColumns.filter((item) => !item.destory)).sort((a, b) => a._index - b._index < 0 ? -1 : a._index - b._index > 0 ? 1 : 0);
5319
5319
  currentTable.value.map((i) => {
5320
5320
  if (!i.attr) {
5321
5321
  i.attr = {};
5322
5322
  }
5323
5323
  });
5324
- setFields(props.tableColumns);
5324
+ const list = props.tableColumns.filter((item) => !item.destory);
5325
+ setFields(list);
5325
5326
  updateColumn();
5326
5327
  if (currentTable.value.findIndex((item) => !!item.type) > -1) {
5327
5328
  unChangedColumn.value.push("selection");
@@ -5334,7 +5335,7 @@ __sfc_main$1.setup = (__props, __ctx) => {
5334
5335
  }
5335
5336
  if (currentTable.value.every((i) => !i.initHidden)) {
5336
5337
  showColumn.value = currentTable.value.map((i) => i.prop);
5337
- checkedCount.value = props.tableColumns.length;
5338
+ checkedCount.value = list.length;
5338
5339
  checkAll.value = true;
5339
5340
  isIndeterminate.value = false;
5340
5341
  }
@@ -5759,7 +5760,7 @@ __sfc_main.props = {
5759
5760
  columns: {
5760
5761
  key: "columns",
5761
5762
  required: false,
5762
- type: Array,
5763
+ type: [Array, null],
5763
5764
  default: () => []
5764
5765
  },
5765
5766
  searchFormAttrs: {
@@ -6212,17 +6213,26 @@ __sfc_main.setup = (__props, __ctx) => {
6212
6213
  immediate: true
6213
6214
  });
6214
6215
  const initLocalShow = () => {
6215
- return props.columns.filter((item) => {
6216
+ props.columns._skip = true;
6217
+ const result = props.columns.filter((item) => {
6216
6218
  var _a2, _b2;
6217
6219
  const prop = item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
6218
6220
  if ((_b2 = props.showColumn) == null ? void 0 : _b2.includes(prop)) {
6219
6221
  item.initHidden = false;
6220
6222
  }
6221
- return item.initHidden;
6223
+ return !item.initHidden;
6222
6224
  }).map((item) => {
6223
6225
  var _a2;
6224
6226
  return item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
6225
6227
  });
6228
+ props.columns._skip = false;
6229
+ if (result.length) {
6230
+ return result;
6231
+ }
6232
+ return props.columns.map((item) => {
6233
+ var _a2;
6234
+ return item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
6235
+ });
6226
6236
  };
6227
6237
  const localShowColumn = ref(initLocalShow());
6228
6238
  watch(() => {
@@ -6250,6 +6260,19 @@ __sfc_main.setup = (__props, __ctx) => {
6250
6260
  (_a2 = instance == null ? void 0 : instance.$cookies) == null ? void 0 : _a2.set(props.storageKey, JSON.stringify(columnState), -1);
6251
6261
  }
6252
6262
  };
6263
+ const syncShowItemToInitHidden = () => {
6264
+ props.columns._skip = true;
6265
+ props.columns.forEach((item) => {
6266
+ var _a2, _b2;
6267
+ const prop = item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
6268
+ if ((_b2 = localShowColumn.value) == null ? void 0 : _b2.includes(prop)) {
6269
+ item.initHidden = false;
6270
+ } else {
6271
+ item.initHidden = true;
6272
+ }
6273
+ });
6274
+ props.columns._skip = false;
6275
+ };
6253
6276
  const syncCookiesToLocalShowColumn = () => {
6254
6277
  var _a2;
6255
6278
  if (props.columnEdit) {
@@ -6265,15 +6288,7 @@ __sfc_main.setup = (__props, __ctx) => {
6265
6288
  }
6266
6289
  }
6267
6290
  localShowColumn.value = showColumnItems;
6268
- props.columns.forEach((item) => {
6269
- var _a3, _b2;
6270
- const prop = item.prop || ((_a3 = item.attr) == null ? void 0 : _a3.prop);
6271
- if ((_b2 = localShowColumn.value) == null ? void 0 : _b2.includes(prop)) {
6272
- item.initHidden = false;
6273
- } else {
6274
- item.initHidden = true;
6275
- }
6276
- });
6291
+ syncShowItemToInitHidden();
6277
6292
  }
6278
6293
  }
6279
6294
  };
@@ -6288,8 +6303,9 @@ __sfc_main.setup = (__props, __ctx) => {
6288
6303
  }
6289
6304
  const tableColumns = ref([]);
6290
6305
  const elTableRefKey = ref(Date.now());
6291
- const syncCookiesToTableColumn = () => {
6306
+ const syncCookiesToTableColumn = (readCached = true) => {
6292
6307
  var _a2;
6308
+ props.columns._skip = true;
6293
6309
  const columns = props.columns.map((item, index2) => {
6294
6310
  var _a3;
6295
6311
  ((_a3 = item.label) == null ? void 0 : _a3.length) || 0;
@@ -6314,7 +6330,7 @@ __sfc_main.setup = (__props, __ctx) => {
6314
6330
  item.__index = index2;
6315
6331
  return item;
6316
6332
  });
6317
- if (props.columnEdit) {
6333
+ if (readCached && props.columnEdit) {
6318
6334
  let columnState = (_a2 = instance == null ? void 0 : instance.$cookies) == null ? void 0 : _a2.get(props.storageKey);
6319
6335
  if (columnState) {
6320
6336
  if (typeof columnState === "string") {
@@ -6336,21 +6352,34 @@ __sfc_main.setup = (__props, __ctx) => {
6336
6352
  }
6337
6353
  }
6338
6354
  }
6355
+ props.columns._skip = true;
6339
6356
  tableColumns.value = columns.sort((a, b) => a._index - b._index < 0 ? -1 : a._index - b._index > 0 ? 1 : 0);
6340
6357
  elTableRefKey.value = Date.now();
6341
6358
  };
6342
6359
  syncCookiesToTableColumn();
6360
+ onBeforeMount(() => {
6361
+ watch(() => {
6362
+ return props.columns;
6363
+ }, () => {
6364
+ if (props.columns._skip) {
6365
+ return;
6366
+ }
6367
+ syncCookiesToTableColumn(false);
6368
+ }, {
6369
+ deep: true
6370
+ });
6371
+ });
6343
6372
  const tableAttrer = computed(() => {
6344
6373
  const obj = {
6345
6374
  "header-cell-style": {
6346
- "text-align": "left",
6375
+ "text-align": "center",
6347
6376
  "background": "#F5F7FA",
6348
6377
  "height": "48px",
6349
6378
  "color": "#303133",
6350
6379
  "font-size": "14px"
6351
6380
  },
6352
6381
  "cell-style": {
6353
- "text-align": "left"
6382
+ "text-align": "center"
6354
6383
  },
6355
6384
  resizable: true,
6356
6385
  border: true,
@@ -6392,10 +6421,13 @@ __sfc_main.setup = (__props, __ctx) => {
6392
6421
  });
6393
6422
  const isShow = (row) => {
6394
6423
  var _a2;
6395
- if (!((_a2 = localShowColumn.value) == null ? void 0 : _a2.length) || row.type) {
6424
+ if (row.type) {
6396
6425
  return true;
6397
6426
  }
6398
- return localShowColumn.value.includes(row.prop) && !row.initHidden;
6427
+ if (!((_a2 = localShowColumn.value) == null ? void 0 : _a2.length)) {
6428
+ return !row.initHidden && !row.destory;
6429
+ }
6430
+ return localShowColumn.value.includes(row.prop) && !row.initHidden && !row.destory;
6399
6431
  };
6400
6432
  const resetNfSearchFormModel = () => {
6401
6433
  var _a2;
@@ -6457,16 +6489,6 @@ __sfc_main.setup = (__props, __ctx) => {
6457
6489
  }
6458
6490
  await ((_b2 = (_a2 = props.tableEvents)["header-dragend"]) == null ? void 0 : _b2.call(_a2, newWidth, oldWidth, column, event));
6459
6491
  };
6460
- const syncShowItemToInitHidden = () => {
6461
- props.columns.forEach((item) => {
6462
- var _a2;
6463
- if ((_a2 = localShowColumn.value) == null ? void 0 : _a2.includes(item.prop)) {
6464
- item.initHidden = false;
6465
- } else {
6466
- item.initHidden = true;
6467
- }
6468
- });
6469
- };
6470
6492
  const columnCheckConfirmFeedback = (value) => {
6471
6493
  if (!props.columnEdit) {
6472
6494
  const itemsList = [];
@@ -6512,7 +6534,6 @@ __sfc_main.setup = (__props, __ctx) => {
6512
6534
  }
6513
6535
  });
6514
6536
  return Object.assign({
6515
- props,
6516
6537
  elTableRef,
6517
6538
  nfTableActionContainerRef,
6518
6539
  nfTablePaginationRef,
@@ -7275,7 +7296,7 @@ var _sfc_render = function render3() {
7275
7296
  ref: "columnCheckDialog",
7276
7297
  attrs: {
7277
7298
  "show": _vm.nfColumCheckDialogVisible,
7278
- "table-columns": _vm.props.columns,
7299
+ "table-columns": _vm.columns,
7279
7300
  "show-column": _vm.localShowColumn,
7280
7301
  "storage-key": _vm.storageKey,
7281
7302
  "title": _vm.columnCheckTitle,
@@ -7341,7 +7362,7 @@ var _sfc_render = function render3() {
7341
7362
  "get-all-check-desc": _vm.columnCheckGetAllCheckDesc,
7342
7363
  "operation-prop-key": _vm.operationPropKey,
7343
7364
  "storage-key": _vm.storageKey,
7344
- "table-columns": _vm.props.columns,
7365
+ "table-columns": _vm.columns,
7345
7366
  "select-empty-warning-tips": _vm.selectEmptyWarningTips
7346
7367
  }
7347
7368
  })], 2) : _vm._e()], 2);
@@ -38,7 +38,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
38
38
  default: string;
39
39
  };
40
40
  columns: {
41
- type: import("vue-demi").PropType<NfTableColumnAttributes[]>;
41
+ type: import("vue-demi").PropType<any>;
42
42
  default: () => never[];
43
43
  };
44
44
  searchFormAttrs: {
@@ -295,6 +295,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
295
295
  _index?: number | undefined;
296
296
  __index?: number | undefined;
297
297
  initHidden?: boolean | undefined;
298
+ destory?: boolean | undefined;
298
299
  type?: "index" | "selection" | "expand" | undefined;
299
300
  label?: string | undefined;
300
301
  prop?: string | undefined;
@@ -336,7 +337,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
336
337
  }[]>;
337
338
  syncLocalShowColumnToCookies: () => void;
338
339
  syncCookiesToLocalShowColumn: () => void;
339
- syncCookiesToTableColumn: () => void;
340
+ syncCookiesToTableColumn: (readCached?: boolean) => void;
340
341
  }, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {
341
342
  fieldsChange: (event: string[]) => void;
342
343
  "update:showColumn": (event: string[] | undefined) => void;
@@ -378,7 +379,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
378
379
  default: string;
379
380
  };
380
381
  columns: {
381
- type: import("vue-demi").PropType<NfTableColumnAttributes[]>;
382
+ type: import("vue-demi").PropType<any>;
382
383
  default: () => never[];
383
384
  };
384
385
  searchFormAttrs: {
@@ -613,7 +614,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
613
614
  text: string;
614
615
  selectEmptyWarningTips: string;
615
616
  operationPropKey: string;
616
- columns: NfTableColumnAttributes[];
617
+ columns: NfTableColumnAttributes[] | any;
617
618
  searchFormAttrs: NfSearchFormAttributes;
618
619
  searchFormEvents: Partial<Record<NfSearchFormEventKey, Function>>;
619
620
  tableAttrs: ElTableAttributes;
@@ -719,6 +720,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
719
720
  _index?: number | undefined;
720
721
  __index?: number | undefined;
721
722
  initHidden?: boolean | undefined;
723
+ destory?: boolean | undefined;
722
724
  type?: "index" | "selection" | "expand" | undefined;
723
725
  label?: string | undefined;
724
726
  prop?: string | undefined;
package/lib/types.d.ts CHANGED
@@ -178,6 +178,7 @@ export interface NfTableColumnAttributes {
178
178
  _index?: number;
179
179
  __index?: number;
180
180
  initHidden?: boolean;
181
+ destory?: boolean;
181
182
  type?: 'selection' | 'index' | 'expand';
182
183
  label?: string;
183
184
  prop?: string;
@@ -183,7 +183,7 @@ const unFixedColumn = ref<Record<string, any>[]>([])
183
183
 
184
184
 
185
185
  onBeforeMount(() => {
186
- currentTable.value = deepClone(props.tableColumns).sort((a,b) => a._index! - b._index! < 0 ? -1 : a._index! - b._index! > 0 ? 1 : 0) as Record<string, any>[]
186
+ currentTable.value = deepClone(props.tableColumns.filter(item => !item.destory)).sort((a,b) => a._index! - b._index! < 0 ? -1 : a._index! - b._index! > 0 ? 1 : 0) as Record<string, any>[]
187
187
  // 兼容处理
188
188
  currentTable.value.map(i => {
189
189
  if (!i.attr) {
@@ -191,8 +191,10 @@ onBeforeMount(() => {
191
191
  }
192
192
  })
193
193
 
194
+ const list = props.tableColumns.filter(item => !item.destory)
195
+
194
196
  // 可选列表 → 字段区分
195
- setFields(props.tableColumns)
197
+ setFields(list)
196
198
  // 已选列表
197
199
  updateColumn()
198
200
  if (currentTable.value.findIndex((item) => !!item.type) > -1) {
@@ -203,7 +205,7 @@ onBeforeMount(() => {
203
205
  }
204
206
  if (currentTable.value.every(i => !i.initHidden)) {
205
207
  showColumn.value = currentTable.value.map(i => i.prop)
206
- checkedCount.value = props.tableColumns.length
208
+ checkedCount.value = list.length
207
209
  checkAll.value = true
208
210
  isIndeterminate.value = false
209
211
  }
@@ -467,7 +467,7 @@
467
467
  <column-check-dialog
468
468
  v-if="nfColumCheckDialogVisible && checkMode === 'dialog'"
469
469
  :show.sync="nfColumCheckDialogVisible"
470
- :table-columns="props.columns"
470
+ :table-columns="columns"
471
471
  :show-column="localShowColumn"
472
472
  :storage-key="storageKey"
473
473
  @save="fieldsConfirm"
@@ -520,7 +520,7 @@
520
520
  :operation-prop-key="operationPropKey"
521
521
  ref="columnCheckDrawer"
522
522
  :storage-key="storageKey"
523
- :table-columns="props.columns"
523
+ :table-columns="columns"
524
524
  :select-empty-warning-tips="selectEmptyWarningTips"
525
525
  />
526
526
  </nf-drawer>
@@ -545,6 +545,7 @@ import {
545
545
  getCurrentInstance,
546
546
  nextTick,
547
547
  onMounted,
548
+ onBeforeMount,
548
549
  ref,
549
550
  watch
550
551
  } from 'vue-demi'
@@ -563,7 +564,7 @@ import { ITabItem } from '@94ai/nf-drawer/lib/types'
563
564
 
564
565
  const props = withDefaults(defineProps<{
565
566
  data?: Record<string, any>[],
566
- columns?: NfTableColumnAttributes[],
567
+ columns?: NfTableColumnAttributes[] | any,
567
568
  searchFormAttrs?: NfSearchFormAttributes,
568
569
  searchFormEvents?: Partial<Record<NfSearchFormEventKey, Function>>,
569
570
  tableAttrs?: ElTableAttributes,
@@ -803,13 +804,19 @@ watch(() => {
803
804
  })
804
805
  // 同步用户参数
805
806
  const initLocalShow = () => {
806
- return props.columns.filter(item => {
807
+ props.columns._skip = true
808
+ const result = props.columns.filter(item => {
807
809
  const prop = item.prop || item.attr?.prop
808
- if (props.showColumn?.includes(prop!)) {
809
- item.initHidden = false
810
- }
811
- return item.initHidden
810
+ if (props.showColumn?.includes(prop!)) {
811
+ item.initHidden = false
812
+ }
813
+ return !item.initHidden
812
814
  }).map(item => item.prop! || item.attr?.prop!)
815
+ props.columns._skip = false
816
+ if (result.length) {
817
+ return result
818
+ }
819
+ return props.columns.map(item => item.prop! || item.attr?.prop!)
813
820
  }
814
821
  const localShowColumn = ref<string[]>(initLocalShow())
815
822
  watch(() => localShowColumn.value?.length, () => {
@@ -834,6 +841,19 @@ const syncLocalShowColumnToCookies = () => {
834
841
  instance?.$cookies?.set(props.storageKey, JSON.stringify(columnState), -1)
835
842
  }
836
843
  }
844
+
845
+ const syncShowItemToInitHidden = () => {
846
+ props.columns._skip = true
847
+ props.columns.forEach(item => {
848
+ const prop = item.prop || item.attr?.prop
849
+ if (localShowColumn.value?.includes(prop!)) {
850
+ item.initHidden = false
851
+ } else {
852
+ item.initHidden = true
853
+ }
854
+ })
855
+ props.columns._skip = false
856
+ }
837
857
  const syncCookiesToLocalShowColumn = () => {
838
858
  if (props.columnEdit) {
839
859
  let columnState: string | NfTableColumnAttributes | null = instance?.$cookies?.get(props.storageKey)
@@ -848,15 +868,7 @@ const syncCookiesToLocalShowColumn = () => {
848
868
  }
849
869
  }
850
870
  localShowColumn.value = showColumnItems
851
-
852
- props.columns.forEach(item => {
853
- const prop = item.prop || item.attr?.prop
854
- if (localShowColumn.value?.includes(prop!)) {
855
- item.initHidden = false
856
- } else {
857
- item.initHidden = true
858
- }
859
- })
871
+ syncShowItemToInitHidden()
860
872
  }
861
873
  }
862
874
  }
@@ -873,7 +885,8 @@ if (props.columnEdit) {
873
885
 
874
886
  const tableColumns = ref<NfTableColumnAttributes[]>([])
875
887
  const elTableRefKey = ref(Date.now())
876
- const syncCookiesToTableColumn = () => {
888
+ const syncCookiesToTableColumn = (readCached = true) => {
889
+ props.columns._skip = true
877
890
  const columns = props.columns!.map((item, index) => {
878
891
  const len = item.label?.length || 0
879
892
  const fz = 15 // 每个字大小,其实是每个字的比例值,大概会比字体大小差不多大一点,
@@ -903,7 +916,7 @@ const syncCookiesToTableColumn = () => {
903
916
  item.__index = index
904
917
  return item
905
918
  })
906
- if (props.columnEdit) {
919
+ if (readCached && props.columnEdit) {
907
920
  // 读取缓存 Column 配置
908
921
  let columnState: string | NfTableColumnAttributes | null = instance?.$cookies?.get(props.storageKey)
909
922
  if (columnState) {
@@ -924,22 +937,36 @@ const syncCookiesToTableColumn = () => {
924
937
  }
925
938
  }
926
939
  }
940
+ props.columns._skip = true
927
941
  tableColumns.value = columns.sort((a, b) => a._index! - b._index! < 0 ? -1 : a._index! - b._index! > 0 ? 1 : 0)
928
942
  elTableRefKey.value = Date.now()
929
943
  }
930
944
 
931
945
  syncCookiesToTableColumn()
932
946
 
947
+ onBeforeMount(() => {
948
+ watch(() => {
949
+ return props.columns
950
+ }, () => {
951
+ if (props.columns._skip) {
952
+ return
953
+ }
954
+ syncCookiesToTableColumn(false)
955
+ }, {
956
+ deep: true
957
+ })
958
+ })
959
+
933
960
  const tableAttrer = computed(() => {
934
961
  const obj: Record<string, any> = {
935
962
  'header-cell-style': {
936
- 'text-align': 'left',
963
+ 'text-align': 'center',
937
964
  'background': '#F5F7FA',
938
965
  'height': '48px',
939
966
  'color': '#303133',
940
967
  'font-size': '14px'
941
968
  },
942
- 'cell-style': { 'text-align': 'left' },
969
+ 'cell-style': { 'text-align': 'center' },
943
970
  resizable: true,
944
971
  border: true,
945
972
  ...props.tableAttrs
@@ -985,10 +1012,13 @@ const pageAttrer = computed(() => {
985
1012
  })
986
1013
 
987
1014
  const isShow = (row: Record<string, any>) => {
988
- if (!localShowColumn.value?.length || row.type) {
1015
+ if (row.type) {
989
1016
  return true
990
1017
  }
991
- return localShowColumn.value.includes(row.prop) && !row.initHidden
1018
+ if (!localShowColumn.value?.length) {
1019
+ return !row.initHidden && !row.destory
1020
+ }
1021
+ return localShowColumn.value.includes(row.prop) && !row.initHidden && !row.destory
992
1022
  }
993
1023
 
994
1024
  const resetNfSearchFormModel = () => {
@@ -1040,15 +1070,6 @@ const headerDragend = async (newWidth, oldWidth, column, event) => {
1040
1070
  await props.tableEvents['header-dragend']?.(newWidth, oldWidth, column, event)
1041
1071
  }
1042
1072
 
1043
- const syncShowItemToInitHidden = () => {
1044
- props.columns.forEach(item => {
1045
- if (localShowColumn.value?.includes(item.prop!)) {
1046
- item.initHidden = false
1047
- } else {
1048
- item.initHidden = true
1049
- }
1050
- })
1051
- }
1052
1073
 
1053
1074
  const columnCheckConfirmFeedback = (value: Record<string, any>) => {
1054
1075
  if (!props.columnEdit) {
@@ -1072,7 +1093,6 @@ const fieldsConfirm = (value) => {
1072
1093
  syncCookiesToLocalShowColumn()
1073
1094
  syncCookiesToTableColumn()
1074
1095
  emit('fieldsChange', localShowColumn.value)
1075
-
1076
1096
  }
1077
1097
  /**
1078
1098
  * 抽屉确定
package/package/types.ts CHANGED
@@ -244,6 +244,7 @@ export interface NfTableColumnAttributes {
244
244
  _index?: number
245
245
  __index?: number
246
246
  initHidden?: boolean
247
+ destory?: boolean
247
248
  type?: 'selection' | 'index' | 'expand'
248
249
  label?: string
249
250
  prop?: string
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-table",
3
- "version": "3.2.26",
3
+ "version": "3.2.32",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zoujiahe <zoujiahe@94ai.com>",
@@ -14,10 +14,10 @@
14
14
  "url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/nf-drawer": "^3.2.26",
18
- "@94ai/nf-message": "^3.2.26",
19
- "@94ai/nf-search-form": "^3.2.26",
20
- "@94ai/nf-theme-chalk": "^3.2.26",
17
+ "@94ai/nf-drawer": "^3.2.32",
18
+ "@94ai/nf-message": "^3.2.32",
19
+ "@94ai/nf-search-form": "^3.2.32",
20
+ "@94ai/nf-theme-chalk": "^3.2.32",
21
21
  "vue-cookies": "^1.8.3",
22
22
  "vue-demi": "^0.14.5",
23
23
  "vuedraggable": "^2.24.3"
@@ -35,5 +35,5 @@
35
35
  "types": "lib/index.d.ts",
36
36
  "main": "lib/nf-table.cjs.js",
37
37
  "module": "lib/nf-table.esm-bundler.js",
38
- "gitHead": "3fc82ba76ea5963f800c942e7dddf4ec58d851c4"
38
+ "gitHead": "10cdc1cc67171a0545ae2b2afd2794caff180e53"
39
39
  }