@94ai/nf-table 100.1.37 → 100.1.44

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
+ dragCached: {
52
+ type: import("vue-demi").PropType<boolean>;
53
+ default: boolean;
54
+ };
51
55
  emptyImageSize: {
52
56
  type: import("vue-demi").PropType<number>;
53
57
  default: number;
@@ -319,6 +323,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
319
323
  type: import("vue-demi").PropType<string[]>;
320
324
  default: undefined;
321
325
  };
326
+ dragCached: {
327
+ type: import("vue-demi").PropType<boolean>;
328
+ default: boolean;
329
+ };
322
330
  emptyImageSize: {
323
331
  type: import("vue-demi").PropType<number>;
324
332
  default: number;
@@ -557,6 +565,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
557
565
  text: string;
558
566
  selectEmptyWarningTips: string;
559
567
  showColumn: string[];
568
+ dragCached: boolean;
560
569
  emptyImageSize: number;
561
570
  searchFormAttrs: import("./types").NfSearchFormAttributes;
562
571
  searchFormEvents: Partial<Record<import("./types").NfSearchFormEventKey, Function>>;
@@ -660,6 +669,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
660
669
  type: import("vue-demi").PropType<string[]>;
661
670
  default: undefined;
662
671
  };
672
+ dragCached: {
673
+ type: import("vue-demi").PropType<boolean>;
674
+ default: boolean;
675
+ };
663
676
  emptyImageSize: {
664
677
  type: import("vue-demi").PropType<number>;
665
678
  default: number;
@@ -1008,6 +1021,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
1008
1021
  type: import("vue-demi").PropType<string[]>;
1009
1022
  default: undefined;
1010
1023
  };
1024
+ dragCached: {
1025
+ type: import("vue-demi").PropType<boolean>;
1026
+ default: boolean;
1027
+ };
1011
1028
  emptyImageSize: {
1012
1029
  type: import("vue-demi").PropType<number>;
1013
1030
  default: number;
@@ -1279,6 +1296,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
1279
1296
  type: import("vue-demi").PropType<string[]>;
1280
1297
  default: undefined;
1281
1298
  };
1299
+ dragCached: {
1300
+ type: import("vue-demi").PropType<boolean>;
1301
+ default: boolean;
1302
+ };
1282
1303
  emptyImageSize: {
1283
1304
  type: import("vue-demi").PropType<number>;
1284
1305
  default: number;
@@ -1594,6 +1615,7 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
1594
1615
  text: string;
1595
1616
  selectEmptyWarningTips: string;
1596
1617
  showColumn: string[];
1618
+ dragCached: boolean;
1597
1619
  emptyImageSize: number;
1598
1620
  searchFormAttrs: import("./types").NfSearchFormAttributes;
1599
1621
  searchFormEvents: Partial<Record<import("./types").NfSearchFormEventKey, Function>>;
@@ -1698,6 +1720,10 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
1698
1720
  type: import("vue-demi").PropType<string[]>;
1699
1721
  default: undefined;
1700
1722
  };
1723
+ dragCached: {
1724
+ type: import("vue-demi").PropType<boolean>;
1725
+ default: boolean;
1726
+ };
1701
1727
  emptyImageSize: {
1702
1728
  type: import("vue-demi").PropType<number>;
1703
1729
  default: number;
@@ -1926,9 +1952,6 @@ declare const _default: import("vue/types/v3-component-public-instance").Compone
1926
1952
  slot: any;
1927
1953
  }) => any>> & Partial<Record<any, (_: {
1928
1954
  slot: any;
1929
- }) => any>> & Partial<Record<any, (_: {
1930
- row: any;
1931
- index: any;
1932
1955
  }) => any>> & Partial<Record<any, (_: {}) => any>> & Partial<Record<any, (_: {
1933
1956
  $index: any;
1934
1957
  column: any;
@@ -5771,6 +5771,12 @@ const __sfc_main = vueDemi.defineComponent({
5771
5771
  name: "nf-table"
5772
5772
  });
5773
5773
  __sfc_main.props = {
5774
+ dragCached: {
5775
+ key: "dragCached",
5776
+ required: false,
5777
+ type: Boolean,
5778
+ default: true
5779
+ },
5774
5780
  emptyImageSize: {
5775
5781
  key: "emptyImageSize",
5776
5782
  required: false,
@@ -6294,7 +6300,7 @@ __sfc_main.setup = (__props, __ctx) => {
6294
6300
  index: index2
6295
6301
  };
6296
6302
  });
6297
- commonUtils.CachedManager.syncCachedSet(props.storageKey, columnState);
6303
+ return commonUtils.CachedManager.syncCachedSet(props.storageKey, columnState);
6298
6304
  }
6299
6305
  };
6300
6306
  const syncShowItemToInitHidden = () => {
@@ -6347,33 +6353,33 @@ __sfc_main.setup = (__props, __ctx) => {
6347
6353
  }
6348
6354
  const cachedPriority = props.priority === "cached";
6349
6355
  if (cachedPriority ? cached : (_a2 = localShowColumn.value) == null ? void 0 : _a2.length) {
6350
- cachedPriority ? await syncCookiesToLocalShowColumn() : syncLocalShowColumnToCookies();
6356
+ cachedPriority ? await syncCookiesToLocalShowColumn() : await syncLocalShowColumnToCookies();
6351
6357
  } else if (cachedPriority ? (_b = localShowColumn.value) == null ? void 0 : _b.length : cached) {
6352
- cachedPriority ? syncLocalShowColumnToCookies() : await syncCookiesToLocalShowColumn();
6358
+ cachedPriority ? await syncLocalShowColumnToCookies() : await syncCookiesToLocalShowColumn();
6353
6359
  }
6354
6360
  } catch (e) {
6355
6361
  console.log(e);
6356
6362
  }
6357
6363
  }
6358
6364
  };
6359
- initCachedData();
6365
+ const getMinWidth = (column) => {
6366
+ const fs = 14;
6367
+ const label = column.customLabel || column.label;
6368
+ const char = label.match(/[\u2E80-\u9FFF]/g);
6369
+ const charLen = char ? char.length : 0;
6370
+ const num = label.match(/\d|\./g);
6371
+ const numLen = num ? num.length : 0;
6372
+ const otherLen = label.length - charLen - numLen;
6373
+ return fs * (charLen * 1 + numLen * 0.7 + otherLen * 0.58) + 20 + (column.sortable ? 24 : 0);
6374
+ };
6360
6375
  const tableColumns = vueDemi.ref([]);
6361
6376
  const elTableRefKey = vueDemi.ref(Date.now());
6362
6377
  const syncCookiesToTableColumn = async (readCached = true) => {
6363
6378
  props.columns._skip = true;
6364
6379
  const columns = props.columns.map((item, index2) => {
6365
- var _a2;
6366
- ((_a2 = item.label) == null ? void 0 : _a2.length) || 0;
6367
6380
  const attr = item.attr || {};
6368
6381
  if (!attr["min-width"] && item.label) {
6369
- const fs = 14;
6370
- const char = item.label.match(/[\u2E80-\u9FFF]/g);
6371
- const charLen = char ? char.length : 0;
6372
- const num = item.label.match(/\d|\./g);
6373
- const numLen = num ? num.length : 0;
6374
- const otherLen = item.label.length - charLen - numLen;
6375
- const minWidth = fs * (charLen * 1.1 + numLen * 0.65 + otherLen * 0.5) + 32 + (attr.sortable ? 24 : 0);
6376
- attr["min-width"] = String(minWidth) + "px";
6382
+ attr["min-width"] = String(getMinWidth(item)) + "px";
6377
6383
  }
6378
6384
  item.attr = {
6379
6385
  ...item.attr,
@@ -6423,7 +6429,11 @@ __sfc_main.setup = (__props, __ctx) => {
6423
6429
  });
6424
6430
  elTableRefKey.value = Date.now();
6425
6431
  };
6426
- syncCookiesToTableColumn();
6432
+ const initColumn = async () => {
6433
+ await initCachedData();
6434
+ syncCookiesToTableColumn();
6435
+ };
6436
+ initColumn();
6427
6437
  vueDemi.onBeforeMount(() => {
6428
6438
  vueDemi.watch(() => {
6429
6439
  return props.columns;
@@ -6548,8 +6558,9 @@ __sfc_main.setup = (__props, __ctx) => {
6548
6558
  const headerDragend = async (newWidth, oldWidth, column, event) => {
6549
6559
  var _a2, _b;
6550
6560
  await vueDemi.nextTick();
6551
- if (newWidth < column.minWidth) {
6552
- column.width = column.minWidth;
6561
+ const minWidth = getMinWidth(column);
6562
+ if (newWidth < minWidth) {
6563
+ column.width = minWidth;
6553
6564
  }
6554
6565
  await ((_b = (_a2 = props.tableEvents)["header-dragend"]) == null ? void 0 : _b.call(_a2, newWidth, oldWidth, column, event));
6555
6566
  };
@@ -6833,33 +6844,13 @@ var _sfc_render = function render3() {
6833
6844
  "height": _vm.elTableHeight
6834
6845
  }
6835
6846
  }, "el-table", _vm.tableAttrer, false), _vm.tableEventer), [_vm._l(_vm.tableColumns, function(column) {
6836
- return [_vm.isShow(column) ? [column.type ? [column.render || column.prop || column.slot ? _c("el-table-column", _vm._b({
6837
- key: column.key || column.prop,
6838
- attrs: {
6839
- "type": column.type,
6840
- "label": column.label
6841
- },
6842
- scopedSlots: _vm._u([{
6843
- key: "default",
6844
- fn: function(scope) {
6845
- return [column.render ? _c("render-component", {
6846
- attrs: {
6847
- "render": column.render,
6848
- "row": scope.row
6849
- }
6850
- }) : [column.slot ? _vm._t(column.slot, null, {
6851
- "row": scope.row,
6852
- "index": scope.$index
6853
- }) : _c("span", [_vm._v(_vm._s(scope.row[column.prop]))])]];
6854
- }
6855
- }], null, true)
6856
- }, "el-table-column", column.attr, false)) : _c("el-table-column", _vm._b({
6857
- key: column.key || column.prop,
6847
+ return [_vm.isShow(column) ? [column.type ? _c("el-table-column", _vm._b({
6848
+ key: column.key || column.prop || column.type,
6858
6849
  attrs: {
6859
6850
  "type": column.type,
6860
6851
  "label": column.label
6861
6852
  }
6862
- }, "el-table-column", column.attr, false))] : [column.attr && column.attr.formatter ? _c("el-table-column", _vm._b({
6853
+ }, "el-table-column", column.attr, false)) : [column.attr && column.attr.formatter ? _c("el-table-column", _vm._b({
6863
6854
  key: column.key || column.prop,
6864
6855
  attrs: {
6865
6856
  "prop": column.prop,
@@ -5769,6 +5769,12 @@ const __sfc_main = defineComponent({
5769
5769
  name: "nf-table"
5770
5770
  });
5771
5771
  __sfc_main.props = {
5772
+ dragCached: {
5773
+ key: "dragCached",
5774
+ required: false,
5775
+ type: Boolean,
5776
+ default: true
5777
+ },
5772
5778
  emptyImageSize: {
5773
5779
  key: "emptyImageSize",
5774
5780
  required: false,
@@ -6292,7 +6298,7 @@ __sfc_main.setup = (__props, __ctx) => {
6292
6298
  index: index2
6293
6299
  };
6294
6300
  });
6295
- CachedManager.syncCachedSet(props.storageKey, columnState);
6301
+ return CachedManager.syncCachedSet(props.storageKey, columnState);
6296
6302
  }
6297
6303
  };
6298
6304
  const syncShowItemToInitHidden = () => {
@@ -6345,33 +6351,33 @@ __sfc_main.setup = (__props, __ctx) => {
6345
6351
  }
6346
6352
  const cachedPriority = props.priority === "cached";
6347
6353
  if (cachedPriority ? cached : (_a2 = localShowColumn.value) == null ? void 0 : _a2.length) {
6348
- cachedPriority ? await syncCookiesToLocalShowColumn() : syncLocalShowColumnToCookies();
6354
+ cachedPriority ? await syncCookiesToLocalShowColumn() : await syncLocalShowColumnToCookies();
6349
6355
  } else if (cachedPriority ? (_b = localShowColumn.value) == null ? void 0 : _b.length : cached) {
6350
- cachedPriority ? syncLocalShowColumnToCookies() : await syncCookiesToLocalShowColumn();
6356
+ cachedPriority ? await syncLocalShowColumnToCookies() : await syncCookiesToLocalShowColumn();
6351
6357
  }
6352
6358
  } catch (e) {
6353
6359
  console.log(e);
6354
6360
  }
6355
6361
  }
6356
6362
  };
6357
- initCachedData();
6363
+ const getMinWidth = (column) => {
6364
+ const fs = 14;
6365
+ const label = column.customLabel || column.label;
6366
+ const char = label.match(/[\u2E80-\u9FFF]/g);
6367
+ const charLen = char ? char.length : 0;
6368
+ const num = label.match(/\d|\./g);
6369
+ const numLen = num ? num.length : 0;
6370
+ const otherLen = label.length - charLen - numLen;
6371
+ return fs * (charLen * 1 + numLen * 0.7 + otherLen * 0.58) + 20 + (column.sortable ? 24 : 0);
6372
+ };
6358
6373
  const tableColumns = ref([]);
6359
6374
  const elTableRefKey = ref(Date.now());
6360
6375
  const syncCookiesToTableColumn = async (readCached = true) => {
6361
6376
  props.columns._skip = true;
6362
6377
  const columns = props.columns.map((item, index2) => {
6363
- var _a2;
6364
- ((_a2 = item.label) == null ? void 0 : _a2.length) || 0;
6365
6378
  const attr = item.attr || {};
6366
6379
  if (!attr["min-width"] && item.label) {
6367
- const fs = 14;
6368
- const char = item.label.match(/[\u2E80-\u9FFF]/g);
6369
- const charLen = char ? char.length : 0;
6370
- const num = item.label.match(/\d|\./g);
6371
- const numLen = num ? num.length : 0;
6372
- const otherLen = item.label.length - charLen - numLen;
6373
- const minWidth = fs * (charLen * 1.1 + numLen * 0.65 + otherLen * 0.5) + 32 + (attr.sortable ? 24 : 0);
6374
- attr["min-width"] = String(minWidth) + "px";
6380
+ attr["min-width"] = String(getMinWidth(item)) + "px";
6375
6381
  }
6376
6382
  item.attr = {
6377
6383
  ...item.attr,
@@ -6421,7 +6427,11 @@ __sfc_main.setup = (__props, __ctx) => {
6421
6427
  });
6422
6428
  elTableRefKey.value = Date.now();
6423
6429
  };
6424
- syncCookiesToTableColumn();
6430
+ const initColumn = async () => {
6431
+ await initCachedData();
6432
+ syncCookiesToTableColumn();
6433
+ };
6434
+ initColumn();
6425
6435
  onBeforeMount(() => {
6426
6436
  watch(() => {
6427
6437
  return props.columns;
@@ -6546,8 +6556,9 @@ __sfc_main.setup = (__props, __ctx) => {
6546
6556
  const headerDragend = async (newWidth, oldWidth, column, event) => {
6547
6557
  var _a2, _b;
6548
6558
  await nextTick();
6549
- if (newWidth < column.minWidth) {
6550
- column.width = column.minWidth;
6559
+ const minWidth = getMinWidth(column);
6560
+ if (newWidth < minWidth) {
6561
+ column.width = minWidth;
6551
6562
  }
6552
6563
  await ((_b = (_a2 = props.tableEvents)["header-dragend"]) == null ? void 0 : _b.call(_a2, newWidth, oldWidth, column, event));
6553
6564
  };
@@ -6831,33 +6842,13 @@ var _sfc_render = function render3() {
6831
6842
  "height": _vm.elTableHeight
6832
6843
  }
6833
6844
  }, "el-table", _vm.tableAttrer, false), _vm.tableEventer), [_vm._l(_vm.tableColumns, function(column) {
6834
- return [_vm.isShow(column) ? [column.type ? [column.render || column.prop || column.slot ? _c("el-table-column", _vm._b({
6835
- key: column.key || column.prop,
6836
- attrs: {
6837
- "type": column.type,
6838
- "label": column.label
6839
- },
6840
- scopedSlots: _vm._u([{
6841
- key: "default",
6842
- fn: function(scope) {
6843
- return [column.render ? _c("render-component", {
6844
- attrs: {
6845
- "render": column.render,
6846
- "row": scope.row
6847
- }
6848
- }) : [column.slot ? _vm._t(column.slot, null, {
6849
- "row": scope.row,
6850
- "index": scope.$index
6851
- }) : _c("span", [_vm._v(_vm._s(scope.row[column.prop]))])]];
6852
- }
6853
- }], null, true)
6854
- }, "el-table-column", column.attr, false)) : _c("el-table-column", _vm._b({
6855
- key: column.key || column.prop,
6845
+ return [_vm.isShow(column) ? [column.type ? _c("el-table-column", _vm._b({
6846
+ key: column.key || column.prop || column.type,
6856
6847
  attrs: {
6857
6848
  "type": column.type,
6858
6849
  "label": column.label
6859
6850
  }
6860
- }, "el-table-column", column.attr, false))] : [column.attr && column.attr.formatter ? _c("el-table-column", _vm._b({
6851
+ }, "el-table-column", column.attr, false)) : [column.attr && column.attr.formatter ? _c("el-table-column", _vm._b({
6861
6852
  key: column.key || column.prop,
6862
6853
  attrs: {
6863
6854
  "prop": column.prop,
@@ -49,6 +49,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
49
49
  type: import("vue-demi").PropType<string[]>;
50
50
  default: undefined;
51
51
  };
52
+ dragCached: {
53
+ type: import("vue-demi").PropType<boolean>;
54
+ default: boolean;
55
+ };
52
56
  emptyImageSize: {
53
57
  type: import("vue-demi").PropType<number>;
54
58
  default: number;
@@ -400,6 +404,10 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
400
404
  type: import("vue-demi").PropType<string[]>;
401
405
  default: undefined;
402
406
  };
407
+ dragCached: {
408
+ type: import("vue-demi").PropType<boolean>;
409
+ default: boolean;
410
+ };
403
411
  emptyImageSize: {
404
412
  type: import("vue-demi").PropType<number>;
405
413
  default: number;
@@ -635,6 +643,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
635
643
  text: string;
636
644
  selectEmptyWarningTips: string;
637
645
  showColumn: string[];
646
+ dragCached: boolean;
638
647
  emptyImageSize: number;
639
648
  searchFormAttrs: NfSearchFormAttributes;
640
649
  searchFormEvents: Partial<Record<NfSearchFormEventKey, Function>>;
@@ -693,9 +702,6 @@ declare const _default: __VLS_WithTemplateSlots<import("vue-demi").DefineCompone
693
702
  slot: any;
694
703
  }) => any>> & Partial<Record<any, (_: {
695
704
  slot: any;
696
- }) => any>> & Partial<Record<any, (_: {
697
- row: any;
698
- index: any;
699
705
  }) => any>> & Partial<Record<any, (_: {}) => any>> & Partial<Record<any, (_: {
700
706
  $index: any;
701
707
  column: any;
@@ -53,20 +53,13 @@
53
53
  >
54
54
  <template v-for="column in tableColumns">
55
55
  <template v-if="isShow(column)">
56
- <template v-if="column.type">
57
- <el-table-column :key="column.key || column.prop" :type="column.type" :label="column.label" v-bind="column.attr"
58
- v-if="column.render || column.prop || column.slot">
59
- <template slot-scope="scope">
60
- <render-component v-if="column.render" :render="column.render" :row="scope.row" />
61
- <template v-else>
62
- <slot v-if="column.slot" :name="column.slot" :row="scope.row" :index="scope.$index" />
63
- <span v-else>{{ scope.row[column.prop] }}</span>
64
- </template>
65
- </template>
66
- </el-table-column>
67
- <el-table-column :key="column.key || column.prop" :type="column.type" :label="column.label" v-bind="column.attr"
68
- v-else />
69
- </template>
56
+ <el-table-column
57
+ v-if="column.type"
58
+ :key="column.key || column.prop || column.type"
59
+ :type="column.type"
60
+ :label="column.label"
61
+ v-bind="column.attr"
62
+ />
70
63
  <template v-else>
71
64
  <el-table-column
72
65
  v-if="column.attr&&column.attr.formatter"
@@ -568,6 +561,7 @@ import { ITabItem } from '@94ai/nf-drawer/lib/types'
568
561
  import { CachedManager } from '@94ai/common-utils'
569
562
 
570
563
  const props = withDefaults(defineProps<{
564
+ dragCached?: boolean,
571
565
  emptyImageSize?: number,
572
566
  data?: Record<string, any>[],
573
567
  columns?: NfTableColumnAttributes[] | any,
@@ -669,6 +663,7 @@ const props = withDefaults(defineProps<{
669
663
  */
670
664
  operationPropKey?: string
671
665
  }>(), {
666
+ dragCached: true,
672
667
  emptyImageSize: 145,
673
668
  selectEmptyWarningTips: '请选择至少一个选项',
674
669
  priority: 'cached',
@@ -852,7 +847,7 @@ const syncLocalShowColumnToCookies = () => {
852
847
  index
853
848
  }
854
849
  })
855
- CachedManager.syncCachedSet(props.storageKey, columnState)
850
+ return CachedManager.syncCachedSet(props.storageKey, columnState)
856
851
  }
857
852
  }
858
853
 
@@ -906,9 +901,9 @@ const initCachedData = async () => {
906
901
  }
907
902
  const cachedPriority = props.priority === 'cached'
908
903
  if (cachedPriority ? cached : localShowColumn.value?.length) {
909
- cachedPriority ? await syncCookiesToLocalShowColumn() : syncLocalShowColumnToCookies()
904
+ cachedPriority ? await syncCookiesToLocalShowColumn() : await syncLocalShowColumnToCookies()
910
905
  } else if (cachedPriority ? localShowColumn.value?.length : cached) {
911
- cachedPriority ? syncLocalShowColumnToCookies() : await syncCookiesToLocalShowColumn()
906
+ cachedPriority ? await syncLocalShowColumnToCookies() : await syncCookiesToLocalShowColumn()
912
907
  }
913
908
  } catch (e) {
914
909
  console.log(e)
@@ -916,30 +911,26 @@ const initCachedData = async () => {
916
911
  }
917
912
  }
918
913
 
919
- initCachedData()
914
+ const getMinWidth = (column) => {
915
+ const fs = 14
916
+ const label = column.customLabel || column.label
917
+ const char = label.match(/[\u2E80-\u9FFF]/g)
918
+ const charLen = char ? char.length : 0
919
+ const num = label.match(/\d|\./g)
920
+ const numLen = num ? num.length : 0
921
+ const otherLen = label.length - charLen - numLen
922
+ return fs * (charLen * 1 + numLen * 0.7 + otherLen * 0.58) + 20 + (column.sortable ? 24 : 0)
923
+ }
920
924
 
921
925
  const tableColumns = ref<NfTableColumnAttributes[]>([])
922
926
  const elTableRefKey = ref(Date.now())
923
927
  const syncCookiesToTableColumn = async (readCached = true) => {
924
928
  props.columns._skip = true
925
929
  const columns = props.columns!.map((item, index) => {
926
- const len = item.label?.length || 0
927
- const fz = 15 // 每个字大小,其实是每个字的比例值,大概会比字体大小差不多大一点,
928
930
  const attr = (item.attr || {}) as ElTableColumnAttributes
929
- // const minWidth = fz * len + 32 + (attr.sortable ? 24 : 0)
930
- // if (!attr['min-width'] || minWidth > parseFloat(attr['min-width'])) {
931
- // attr['min-width'] = String(minWidth) + 'px' // 字大小乘个数即长度 ,注意不要加px像素,这里minWidth只是一个比例值,不是真正的长度,+32表示th左右两边的内边距
932
- // }
933
931
  // 区分中文、数字、其他字符
934
932
  if (!attr['min-width'] && item.label) {
935
- const fs = 14
936
- const char = item.label.match(/[\u2E80-\u9FFF]/g)
937
- const charLen = char ? char.length : 0
938
- const num = item.label.match(/\d|\./g)
939
- const numLen = num ? num.length : 0
940
- const otherLen = item.label.length - charLen - numLen
941
- const minWidth = fs * (charLen * 1.1 + numLen * 0.65 + otherLen * 0.5) + 32 + (attr.sortable ? 24 : 0)
942
- attr['min-width'] = String(minWidth) + 'px'
933
+ attr['min-width'] = String(getMinWidth(item)) + 'px'
943
934
  }
944
935
  item.attr = {
945
936
  ...item.attr,
@@ -988,8 +979,12 @@ const syncCookiesToTableColumn = async (readCached = true) => {
988
979
  })
989
980
  elTableRefKey.value = Date.now()
990
981
  }
982
+ const initColumn = async () => {
983
+ await initCachedData()
984
+ syncCookiesToTableColumn()
985
+ }
991
986
 
992
- syncCookiesToTableColumn()
987
+ initColumn()
993
988
 
994
989
  onBeforeMount(() => {
995
990
  watch(() => {
@@ -1110,9 +1105,12 @@ const sort = (prop, order) => {
1110
1105
 
1111
1106
  const headerDragend = async (newWidth, oldWidth, column, event) => {
1112
1107
  await nextTick()
1113
- if (newWidth < column.minWidth) {
1114
- column.width = column.minWidth
1108
+ const minWidth = getMinWidth(column)
1109
+ if (newWidth < minWidth) {
1110
+ column.width = minWidth
1115
1111
  }
1112
+ // if (props.dragCached) {
1113
+ // }
1116
1114
  await props.tableEvents['header-dragend']?.(newWidth, oldWidth, column, event)
1117
1115
  }
1118
1116
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@94ai/nf-table",
3
- "version": "100.1.37",
3
+ "version": "100.1.44",
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.37",
18
- "@94ai/nf-button": "^100.1.37",
19
- "@94ai/nf-drawer": "^100.1.37",
20
- "@94ai/nf-message": "^100.1.37",
21
- "@94ai/nf-search-form": "^100.1.37",
22
- "@94ai/nf-theme-chalk": "^100.1.37",
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",
23
23
  "idb-keyval": "^6.2.1",
24
24
  "vue-demi": "^0.14.5",
25
25
  "vuedraggable": "^2.24.3"
@@ -37,5 +37,5 @@
37
37
  "types": "lib/index.d.ts",
38
38
  "main": "lib/nf-table.cjs.js",
39
39
  "module": "lib/nf-table.esm-bundler.js",
40
- "gitHead": "ad05ed1496a2495824391a570eaf277bd50d8b86"
40
+ "gitHead": "4c5a85d5403ee4fb6bb5a1810f2b77235a5a842e"
41
41
  }