@94ai/nf-table 100.1.44 → 100.1.45

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
@@ -970,7 +970,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
970
970
  calcTableHeight: () => void;
971
971
  syncLocalShowColumnToCookies: () => void;
972
972
  syncCookiesToLocalShowColumn: () => Promise<void>;
973
- syncCookiesToTableColumn: (readCached?: boolean) => Promise<void>;
973
+ syncCookiesToTableColumn: (readCached?: boolean, init?: boolean) => Promise<void>;
974
974
  elTableRefKey: import("vue-demi").Ref<number>;
975
975
  }> & import("vue/types/v3-component-options").ExtractComputedReturns<{}> & import("vue-demi").ComponentCustomProperties & Readonly<import("vue-demi").ExtractPropTypes<{
976
976
  background: {
@@ -1597,7 +1597,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
1597
1597
  calcTableHeight: () => void;
1598
1598
  syncLocalShowColumnToCookies: () => void;
1599
1599
  syncCookiesToLocalShowColumn: () => Promise<void>;
1600
- syncCookiesToTableColumn: (readCached?: boolean) => Promise<void>;
1600
+ syncCookiesToTableColumn: (readCached?: boolean, init?: boolean) => Promise<void>;
1601
1601
  elTableRefKey: import("vue-demi").Ref<number>;
1602
1602
  }, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {
1603
1603
  fieldsChange: (event: string[]) => void;
@@ -6361,6 +6361,9 @@ __sfc_main.setup = (__props, __ctx) => {
6361
6361
  console.log(e);
6362
6362
  }
6363
6363
  }
6364
+ if (props.dragCached) {
6365
+ await commonUtils.CachedManager.asyncCachedGet(`${props.storageKey}$drag-column-width`);
6366
+ }
6364
6367
  };
6365
6368
  const getMinWidth = (column) => {
6366
6369
  const fs = 14;
@@ -6374,13 +6377,21 @@ __sfc_main.setup = (__props, __ctx) => {
6374
6377
  };
6375
6378
  const tableColumns = vueDemi.ref([]);
6376
6379
  const elTableRefKey = vueDemi.ref(Date.now());
6377
- const syncCookiesToTableColumn = async (readCached = true) => {
6380
+ const syncCookiesToTableColumn = async (readCached = true, init = false) => {
6378
6381
  props.columns._skip = true;
6379
6382
  const columns = props.columns.map((item, index2) => {
6383
+ var _a2;
6380
6384
  const attr = item.attr || {};
6381
6385
  if (!attr["min-width"] && item.label) {
6382
6386
  attr["min-width"] = String(getMinWidth(item)) + "px";
6383
6387
  }
6388
+ if (init && props.dragCached) {
6389
+ const prop = item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
6390
+ let columnWidth = commonUtils.CachedManager.syncCachedGet(`${props.storageKey}$drag-column-width`) || {};
6391
+ if (columnWidth[prop]) {
6392
+ attr.width = columnWidth[prop];
6393
+ }
6394
+ }
6384
6395
  item.attr = {
6385
6396
  ...item.attr,
6386
6397
  ...attr
@@ -6431,7 +6442,7 @@ __sfc_main.setup = (__props, __ctx) => {
6431
6442
  };
6432
6443
  const initColumn = async () => {
6433
6444
  await initCachedData();
6434
- syncCookiesToTableColumn();
6445
+ syncCookiesToTableColumn(true, true);
6435
6446
  };
6436
6447
  initColumn();
6437
6448
  vueDemi.onBeforeMount(() => {
@@ -6562,6 +6573,11 @@ __sfc_main.setup = (__props, __ctx) => {
6562
6573
  if (newWidth < minWidth) {
6563
6574
  column.width = minWidth;
6564
6575
  }
6576
+ if (props.dragCached) {
6577
+ const columnCachedData = await commonUtils.CachedManager.asyncCachedGet(`${props.storageKey}$drag-column-width`) || {};
6578
+ columnCachedData[column.property] = column.width;
6579
+ await commonUtils.CachedManager.asyncCachedSet(`${props.storageKey}$drag-column-width`, columnCachedData);
6580
+ }
6565
6581
  await ((_b = (_a2 = props.tableEvents)["header-dragend"]) == null ? void 0 : _b.call(_a2, newWidth, oldWidth, column, event));
6566
6582
  };
6567
6583
  const columnCheckConfirmFeedback = (value) => {
@@ -6359,6 +6359,9 @@ __sfc_main.setup = (__props, __ctx) => {
6359
6359
  console.log(e);
6360
6360
  }
6361
6361
  }
6362
+ if (props.dragCached) {
6363
+ await CachedManager.asyncCachedGet(`${props.storageKey}$drag-column-width`);
6364
+ }
6362
6365
  };
6363
6366
  const getMinWidth = (column) => {
6364
6367
  const fs = 14;
@@ -6372,13 +6375,21 @@ __sfc_main.setup = (__props, __ctx) => {
6372
6375
  };
6373
6376
  const tableColumns = ref([]);
6374
6377
  const elTableRefKey = ref(Date.now());
6375
- const syncCookiesToTableColumn = async (readCached = true) => {
6378
+ const syncCookiesToTableColumn = async (readCached = true, init = false) => {
6376
6379
  props.columns._skip = true;
6377
6380
  const columns = props.columns.map((item, index2) => {
6381
+ var _a2;
6378
6382
  const attr = item.attr || {};
6379
6383
  if (!attr["min-width"] && item.label) {
6380
6384
  attr["min-width"] = String(getMinWidth(item)) + "px";
6381
6385
  }
6386
+ if (init && props.dragCached) {
6387
+ const prop = item.prop || ((_a2 = item.attr) == null ? void 0 : _a2.prop);
6388
+ let columnWidth = CachedManager.syncCachedGet(`${props.storageKey}$drag-column-width`) || {};
6389
+ if (columnWidth[prop]) {
6390
+ attr.width = columnWidth[prop];
6391
+ }
6392
+ }
6382
6393
  item.attr = {
6383
6394
  ...item.attr,
6384
6395
  ...attr
@@ -6429,7 +6440,7 @@ __sfc_main.setup = (__props, __ctx) => {
6429
6440
  };
6430
6441
  const initColumn = async () => {
6431
6442
  await initCachedData();
6432
- syncCookiesToTableColumn();
6443
+ syncCookiesToTableColumn(true, true);
6433
6444
  };
6434
6445
  initColumn();
6435
6446
  onBeforeMount(() => {
@@ -6560,6 +6571,11 @@ __sfc_main.setup = (__props, __ctx) => {
6560
6571
  if (newWidth < minWidth) {
6561
6572
  column.width = minWidth;
6562
6573
  }
6574
+ if (props.dragCached) {
6575
+ const columnCachedData = await CachedManager.asyncCachedGet(`${props.storageKey}$drag-column-width`) || {};
6576
+ columnCachedData[column.property] = column.width;
6577
+ await CachedManager.asyncCachedSet(`${props.storageKey}$drag-column-width`, columnCachedData);
6578
+ }
6563
6579
  await ((_b = (_a2 = props.tableEvents)["header-dragend"]) == null ? void 0 : _b.call(_a2, newWidth, oldWidth, column, event));
6564
6580
  };
6565
6581
  const columnCheckConfirmFeedback = (value) => {
@@ -350,7 +350,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
350
350
  calcTableHeight: () => void;
351
351
  syncLocalShowColumnToCookies: () => void;
352
352
  syncCookiesToLocalShowColumn: () => Promise<void>;
353
- syncCookiesToTableColumn: (readCached?: boolean) => Promise<void>;
353
+ syncCookiesToTableColumn: (readCached?: boolean, init?: boolean) => Promise<void>;
354
354
  elTableRefKey: import("vue-demi").Ref<number>;
355
355
  }, {}, {}, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {
356
356
  fieldsChange: (event: string[]) => void;
@@ -909,6 +909,9 @@ const initCachedData = async () => {
909
909
  console.log(e)
910
910
  }
911
911
  }
912
+ if (props.dragCached) {
913
+ await CachedManager.asyncCachedGet(`${props.storageKey}$drag-column-width`)
914
+ }
912
915
  }
913
916
 
914
917
  const getMinWidth = (column) => {
@@ -924,7 +927,7 @@ const getMinWidth = (column) => {
924
927
 
925
928
  const tableColumns = ref<NfTableColumnAttributes[]>([])
926
929
  const elTableRefKey = ref(Date.now())
927
- const syncCookiesToTableColumn = async (readCached = true) => {
930
+ const syncCookiesToTableColumn = async (readCached = true, init = false) => {
928
931
  props.columns._skip = true
929
932
  const columns = props.columns!.map((item, index) => {
930
933
  const attr = (item.attr || {}) as ElTableColumnAttributes
@@ -932,6 +935,13 @@ const syncCookiesToTableColumn = async (readCached = true) => {
932
935
  if (!attr['min-width'] && item.label) {
933
936
  attr['min-width'] = String(getMinWidth(item)) + 'px'
934
937
  }
938
+ if (init && props.dragCached) {
939
+ const prop = item.prop || item.attr?.prop
940
+ let columnWidth = CachedManager.syncCachedGet(`${props.storageKey}$drag-column-width`) || {}
941
+ if (columnWidth[prop]) { // 读取缓存
942
+ attr.width = columnWidth[prop]
943
+ }
944
+ }
935
945
  item.attr = {
936
946
  ...item.attr,
937
947
  ...attr
@@ -981,7 +991,7 @@ const syncCookiesToTableColumn = async (readCached = true) => {
981
991
  }
982
992
  const initColumn = async () => {
983
993
  await initCachedData()
984
- syncCookiesToTableColumn()
994
+ syncCookiesToTableColumn(true, true)
985
995
  }
986
996
 
987
997
  initColumn()
@@ -1109,8 +1119,11 @@ const headerDragend = async (newWidth, oldWidth, column, event) => {
1109
1119
  if (newWidth < minWidth) {
1110
1120
  column.width = minWidth
1111
1121
  }
1112
- // if (props.dragCached) {
1113
- // }
1122
+ if (props.dragCached) { // 记录缓存
1123
+ const columnCachedData = await CachedManager.asyncCachedGet(`${props.storageKey}$drag-column-width`) || {}
1124
+ columnCachedData[column.property] = column.width
1125
+ await CachedManager.asyncCachedSet(`${props.storageKey}$drag-column-width`, columnCachedData)
1126
+ }
1114
1127
  await props.tableEvents['header-dragend']?.(newWidth, oldWidth, column, event)
1115
1128
  }
1116
1129
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-table",
3
- "version": "100.1.44",
3
+ "version": "100.1.45",
4
4
  "description": "> TODO: description",
5
5
  "keywords": [],
6
6
  "author": "zoujiahe <zoujiahe@94ai.com>",
@@ -14,12 +14,12 @@
14
14
  "url": "http://94ai.gitlab.com/zoujiahe/common-ui.git"
15
15
  },
16
16
  "dependencies": {
17
- "@94ai/common-utils": "^100.1.44",
18
- "@94ai/nf-button": "^100.1.44",
19
- "@94ai/nf-drawer": "^100.1.44",
20
- "@94ai/nf-message": "^100.1.44",
21
- "@94ai/nf-search-form": "^100.1.44",
22
- "@94ai/nf-theme-chalk": "^100.1.44",
17
+ "@94ai/common-utils": "^100.1.45",
18
+ "@94ai/nf-button": "^100.1.45",
19
+ "@94ai/nf-drawer": "^100.1.45",
20
+ "@94ai/nf-message": "^100.1.45",
21
+ "@94ai/nf-search-form": "^100.1.45",
22
+ "@94ai/nf-theme-chalk": "^100.1.45",
23
23
  "idb-keyval": "^6.2.1",
24
24
  "vue-demi": "^0.14.5",
25
25
  "vuedraggable": "^2.24.3"