vxe-table 3.21.7 → 3.21.8

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.
@@ -3,7 +3,7 @@ import { getTpImg, isPx, isScale, hasClass, addClass, removeClass, wheelScrollLe
3
3
  import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils';
4
4
  import { VxeUI } from '../../ui';
5
5
  import Cell from './cell';
6
- import { getRowUniqueId, createRowId, clearTableAllStatus, getColumnList, toFilters, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, getColReMaxWidth, createHandleUpdateRowId, createHandleGetRowId, getRefElem, getCellRestHeight, getLastChildColumn } from './util';
6
+ import { getRowUniqueId, createRowId, clearTableAllStatus, getColumnList, toFilters, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, getColReMaxWidth, createHandleUpdateRowId, createHandleGetRowId, getRefElem, getCellRestHeight, getLastChildColumn, getRowMaxHeight } from './util';
7
7
  import { getSlotVNs } from '../../ui/src/vn';
8
8
  import { moveRowAnimateToTb, clearRowAnimate, moveColAnimateToLr, clearColAnimate } from '../../ui/src/anime';
9
9
  import { warnLog, errLog } from '../../ui/src/log';
@@ -2470,35 +2470,39 @@ function autoCellWidth($xeTable) {
2470
2470
  /**
2471
2471
  * 计算自适应行高
2472
2472
  */
2473
- const calcCellAutoHeight = ($xeTable, rowRest, wrapperEl) => {
2474
- const reactData = $xeTable;
2475
- const { scrollXLoad } = reactData;
2473
+ const calcCellAutoHeight = ($xeTable, rowid, rowRest, wrapperEl) => {
2474
+ const internalData = $xeTable;
2475
+ const { fullCellHeightMaps } = internalData;
2476
+ let chRest = fullCellHeightMaps[rowid];
2477
+ if (!chRest) {
2478
+ chRest = {};
2479
+ fullCellHeightMaps[rowid] = chRest;
2480
+ }
2476
2481
  const wrapperElemList = wrapperEl.querySelectorAll(`.vxe-cell--wrapper[rowid="${rowRest.rowid}"]`);
2477
- let colHeight = 0;
2478
2482
  let firstCellStyle = null;
2479
2483
  let topBottomPadding = 0;
2484
+ let changeCH = false;
2480
2485
  for (let i = 0; i < wrapperElemList.length; i++) {
2481
2486
  const wrapperElem = wrapperElemList[i];
2482
2487
  const cellElem = wrapperElem.parentElement;
2483
2488
  const cellStyle = cellElem.style;
2484
2489
  const orHeight = cellStyle.height;
2485
- if (!scrollXLoad) {
2486
- cellStyle.height = '';
2487
- }
2490
+ const colid = wrapperElem.getAttribute('colid') || '';
2491
+ cellStyle.height = '';
2488
2492
  if (!firstCellStyle) {
2489
2493
  firstCellStyle = getComputedStyle(cellElem);
2490
2494
  topBottomPadding = firstCellStyle ? Math.ceil(XEUtils.toNumber(firstCellStyle.paddingTop) + XEUtils.toNumber(firstCellStyle.paddingBottom)) : 0;
2491
2495
  }
2492
- if (!scrollXLoad) {
2493
- cellStyle.height = orHeight;
2494
- }
2495
2496
  const cellHeight = wrapperElem ? wrapperElem.clientHeight : 0;
2496
- colHeight = Math.max(colHeight, Math.ceil(cellHeight + topBottomPadding));
2497
- }
2498
- if (scrollXLoad) {
2499
- colHeight = Math.max(colHeight, rowRest.height);
2497
+ const colHeight = Math.ceil(cellHeight + topBottomPadding);
2498
+ if (chRest[colid] !== colHeight) {
2499
+ changeCH = true;
2500
+ chRest[colid] = colHeight;
2501
+ }
2502
+ cellStyle.height = orHeight;
2500
2503
  }
2501
- return colHeight;
2504
+ const cellMaxHeight = getRowMaxHeight(chRest, changeCH);
2505
+ return cellMaxHeight;
2502
2506
  };
2503
2507
  /**
2504
2508
  * 自适应行高
@@ -2523,7 +2527,7 @@ const calcCellHeight = ($xeTable) => {
2523
2527
  const rowid = handleGetRowId(row);
2524
2528
  const rowRest = fullAllDataRowIdData[rowid];
2525
2529
  if (rowRest) {
2526
- const height = calcCellAutoHeight($xeTable, rowRest, el);
2530
+ const height = calcCellAutoHeight($xeTable, rowid, rowRest, el);
2527
2531
  rowRest.height = Math.max(defaultRowHeight, height);
2528
2532
  }
2529
2533
  el.removeAttribute('data-calc-row');
@@ -3014,7 +3018,6 @@ function calcScrollbar($xeTable) {
3014
3018
  function handleRecalculateStyle($xeTable, reFull, reWidth, reHeight) {
3015
3019
  const internalData = $xeTable;
3016
3020
  const el = $xeTable.$refs.refElem;
3017
- internalData.rceRunTime = Date.now();
3018
3021
  if (!el || !el.clientWidth) {
3019
3022
  return $xeTable.$nextTick();
3020
3023
  }
@@ -3038,6 +3041,7 @@ function handleRecalculateStyle($xeTable, reFull, reWidth, reHeight) {
3038
3041
  if (reFull) {
3039
3042
  updateTreeLineStyle($xeTable);
3040
3043
  }
3044
+ internalData.rceRunTime = Date.now();
3041
3045
  return computeScrollLoad($xeTable).then(() => {
3042
3046
  // 初始化时需要在列计算之后再执行优化运算,达到最优显示效果
3043
3047
  if (reWidth) {
@@ -3058,11 +3062,13 @@ function handleRecalculateStyle($xeTable, reFull, reWidth, reHeight) {
3058
3062
  if (reFull) {
3059
3063
  updateTreeLineStyle($xeTable);
3060
3064
  }
3065
+ internalData.rceRunTime = Date.now();
3061
3066
  if (reFull) {
3062
3067
  return computeScrollLoad($xeTable);
3063
3068
  }
3064
3069
  });
3065
3070
  }
3071
+ const minRunDelay = 50;
3066
3072
  function handleLazyRecalculate($xeTable, reFull, reWidth, reHeight) {
3067
3073
  const reactData = $xeTable;
3068
3074
  const internalData = $xeTable;
@@ -3071,7 +3077,17 @@ function handleLazyRecalculate($xeTable, reFull, reWidth, reHeight) {
3071
3077
  const { rceTimeout, rceRunTime } = internalData;
3072
3078
  const $xeGanttView = internalData.xeGanttView;
3073
3079
  const resizeOpts = $xeTable.computeResizeOpts;
3074
- const refreshDelay = resizeOpts.refreshDelay || 20;
3080
+ let rceDelay = internalData.rceDelay;
3081
+ // 如果在500毫秒内频繁执行,则执行次数减缓
3082
+ if (rceRunTime && rceRunTime > Date.now() - 500) {
3083
+ rceDelay += 50;
3084
+ }
3085
+ else {
3086
+ rceDelay = 0;
3087
+ }
3088
+ internalData.rceDelay = rceDelay;
3089
+ const refreshDelay = resizeOpts.refreshDelay || 30;
3090
+ const reDelay = rceDelay + refreshDelay;
3075
3091
  const el = $xeTable.$refs.refElem;
3076
3092
  if (el && el.clientWidth) {
3077
3093
  autoCellWidth($xeTable);
@@ -3082,7 +3098,7 @@ function handleLazyRecalculate($xeTable, reFull, reWidth, reHeight) {
3082
3098
  }
3083
3099
  if (rceTimeout) {
3084
3100
  clearTimeout(rceTimeout);
3085
- if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
3101
+ if (rceRunTime && rceRunTime + minRunDelay < Date.now()) {
3086
3102
  resolve(handleRecalculateStyle($xeTable, reFull, reWidth, reHeight));
3087
3103
  }
3088
3104
  else {
@@ -3100,7 +3116,7 @@ function handleLazyRecalculate($xeTable, reFull, reWidth, reHeight) {
3100
3116
  internalData.rceTimeout = setTimeout(() => {
3101
3117
  internalData.rceTimeout = undefined;
3102
3118
  handleRecalculateStyle($xeTable, reFull, reWidth, reHeight);
3103
- }, refreshDelay);
3119
+ }, reDelay);
3104
3120
  });
3105
3121
  }
3106
3122
  function handleResizeEvent($xeTable) {
@@ -3437,6 +3453,7 @@ function loadTableData($xeTable, datas, isReload, isReset) {
3437
3453
  reactData.insertRowFlag++;
3438
3454
  internalData.removeRowMaps = {};
3439
3455
  reactData.removeRowFlag++;
3456
+ internalData.fullCellHeightMaps = {};
3440
3457
  const sYLoad = updateScrollYStatus($xeTable, fullData);
3441
3458
  // 全量数据
3442
3459
  internalData.tableFullData = fullData;
@@ -3811,12 +3828,48 @@ function initColumnHierarchy($xeTable) {
3811
3828
  internalData.fullColumnIdData = fullColIdData;
3812
3829
  internalData.fullColumnFieldData = fullColFieldData;
3813
3830
  }
3814
- function handleInitColumn($xeTable, collectColumn) {
3831
+ function buildColumnInfo($xeTable) {
3815
3832
  const props = $xeTable;
3816
3833
  const $xeToolbar = $xeTable.$refs.$xeToolbar;
3817
3834
  const reactData = $xeTable;
3818
3835
  const internalData = $xeTable;
3836
+ const { scrollXLoad, scrollYLoad, expandColumn } = reactData;
3819
3837
  const expandOpts = $xeTable.computeExpandOpts;
3838
+ cacheColumnMap($xeTable);
3839
+ parseColumns($xeTable, true).then(() => {
3840
+ if (reactData.scrollXLoad) {
3841
+ loadScrollXData($xeTable);
3842
+ }
3843
+ });
3844
+ $xeTable.clearHeaderFormatterCache();
3845
+ $xeTable.clearMergeCells();
3846
+ $xeTable.clearMergeFooterItems();
3847
+ $xeTable.handleTableData(true);
3848
+ $xeTable.handleAggregateSummaryData();
3849
+ if ((scrollXLoad || scrollYLoad) && (expandColumn && expandOpts.mode !== 'fixed')) {
3850
+ warnLog('vxe.error.scrollErrProp', ['column.type=expand']);
3851
+ }
3852
+ return $xeTable.$nextTick().then(() => {
3853
+ if ($xeToolbar) {
3854
+ $xeToolbar.syncUpdate({
3855
+ collectColumn: internalData.collectColumn,
3856
+ $table: $xeTable
3857
+ });
3858
+ }
3859
+ if ($xeTable.handleUpdateCustomColumn) {
3860
+ $xeTable.handleUpdateCustomColumn();
3861
+ }
3862
+ const columnOpts = $xeTable.computeColumnOpts;
3863
+ if (props.showCustomHeader && reactData.isGroup && (columnOpts.resizable || props.resizable)) {
3864
+ warnLog('vxe.error.notConflictProp', ['show-custom-header & colgroup', 'column-config.resizable=false']);
3865
+ }
3866
+ reactData.isColLoading = false;
3867
+ return handleLazyRecalculate($xeTable, false, true, true);
3868
+ });
3869
+ }
3870
+ function handleInitColumn($xeTable, collectColumn) {
3871
+ const reactData = $xeTable;
3872
+ const internalData = $xeTable;
3820
3873
  internalData.collectColumn = collectColumn;
3821
3874
  const tFullColumn = getColumnList(collectColumn);
3822
3875
  internalData.tableFullColumn = tFullColumn;
@@ -3824,38 +3877,7 @@ function handleInitColumn($xeTable, collectColumn) {
3824
3877
  reactData.isColLoading = true;
3825
3878
  initColumnHierarchy($xeTable);
3826
3879
  return Promise.resolve(restoreCustomStorage($xeTable)).then(() => {
3827
- const { scrollXLoad, scrollYLoad, expandColumn } = reactData;
3828
- cacheColumnMap($xeTable);
3829
- parseColumns($xeTable, true).then(() => {
3830
- if (reactData.scrollXLoad) {
3831
- loadScrollXData($xeTable);
3832
- }
3833
- });
3834
- $xeTable.clearHeaderFormatterCache();
3835
- $xeTable.clearMergeCells();
3836
- $xeTable.clearMergeFooterItems();
3837
- $xeTable.handleTableData(true);
3838
- $xeTable.handleAggregateSummaryData();
3839
- if ((scrollXLoad || scrollYLoad) && (expandColumn && expandOpts.mode !== 'fixed')) {
3840
- warnLog('vxe.error.scrollErrProp', ['column.type=expand']);
3841
- }
3842
- return $xeTable.$nextTick().then(() => {
3843
- if ($xeToolbar) {
3844
- $xeToolbar.syncUpdate({
3845
- collectColumn: internalData.collectColumn,
3846
- $table: $xeTable
3847
- });
3848
- }
3849
- if ($xeTable.handleUpdateCustomColumn) {
3850
- $xeTable.handleUpdateCustomColumn();
3851
- }
3852
- const columnOpts = $xeTable.computeColumnOpts;
3853
- if (props.showCustomHeader && reactData.isGroup && (columnOpts.resizable || props.resizable)) {
3854
- warnLog('vxe.error.notConflictProp', ['show-custom-header & colgroup', 'column-config.resizable=false']);
3855
- }
3856
- reactData.isColLoading = false;
3857
- return handleLazyRecalculate($xeTable, false, true, true);
3858
- });
3880
+ return buildColumnInfo($xeTable);
3859
3881
  });
3860
3882
  }
3861
3883
  /**
@@ -6197,6 +6219,9 @@ const tableMethods = {
6197
6219
  warnLog('vxe.error.delFunc', ['resetColumn', 'resetCustom']);
6198
6220
  return this.resetCustom(options);
6199
6221
  },
6222
+ /**
6223
+ * @private
6224
+ */
6200
6225
  handleCustom() {
6201
6226
  const $xeTable = this;
6202
6227
  const props = $xeTable;
@@ -6249,6 +6274,68 @@ const tableMethods = {
6249
6274
  }
6250
6275
  }
6251
6276
  },
6277
+ /**
6278
+ * 用于 custom-config,用于手动恢复自定义列设置信息,恢复表格重置为初始状态
6279
+ * @param storeData
6280
+ * @returns
6281
+ */
6282
+ setCustomStoreData(storeData) {
6283
+ const $xeTable = this;
6284
+ const reactData = $xeTable;
6285
+ const internalData = $xeTable;
6286
+ if (!storeData) {
6287
+ return $xeTable.$nextTick();
6288
+ }
6289
+ const customOpts = $xeTable.computeCustomOpts;
6290
+ const { checkMethod } = customOpts;
6291
+ // 重置状态
6292
+ clearTableAllStatus($xeTable);
6293
+ // 恢复列
6294
+ const allCols = [];
6295
+ XEUtils.eachTree(internalData.collectColumn, (column) => {
6296
+ column.resizeWidth = 0;
6297
+ column.fixed = column.defaultFixed;
6298
+ column.renderSortNumber = column.sortNumber;
6299
+ column.parentId = column.defaultParentId;
6300
+ if (!checkMethod || checkMethod({ $table: $xeTable, column })) {
6301
+ column.visible = column.defaultVisible;
6302
+ }
6303
+ column.aggFunc = column.defaultAggFunc;
6304
+ column.renderAggFn = column.defaultAggFunc;
6305
+ column.renderResizeWidth = column.renderWidth;
6306
+ allCols.push(column);
6307
+ });
6308
+ const newCollectCols = XEUtils.toArrayTree(XEUtils.orderBy(allCols, 'renderSortNumber'), { key: 'id', parentKey: 'parentId', children: 'children' });
6309
+ internalData.collectColumn = newCollectCols;
6310
+ internalData.tableFullColumn = getColumnList(newCollectCols);
6311
+ reactData.updateColFlag++;
6312
+ reactData.isColLoading = true;
6313
+ initColumnHierarchy($xeTable);
6314
+ return Promise.resolve(handleCustomRestore($xeTable, storeData)).then(() => {
6315
+ return buildColumnInfo($xeTable);
6316
+ }).then(() => {
6317
+ // 恢复数据聚合分组
6318
+ const { isRowGroupStatus, rowGroupList } = reactData;
6319
+ if (isRowGroupStatus && !!$xeTable.handlePivotTableAggData) {
6320
+ const rowGroupFields = $xeTable.computeRowGroupFields;
6321
+ if (rowGroupFields ? rowGroupFields.length : rowGroupList.length) {
6322
+ if (rowGroupFields && rowGroupFields.length) {
6323
+ $xeTable.setRowGroups(rowGroupFields);
6324
+ }
6325
+ else {
6326
+ $xeTable.clearRowGroups();
6327
+ }
6328
+ }
6329
+ else {
6330
+ $xeTable.handleUpdateAggData();
6331
+ }
6332
+ }
6333
+ });
6334
+ },
6335
+ /**
6336
+ * 用于 custom-config,用于获取自定义列设置信息,用于自定义保持
6337
+ * @returns
6338
+ */
6252
6339
  getCustomStoreData() {
6253
6340
  const $xeTable = this;
6254
6341
  const props = $xeTable;
@@ -6372,6 +6459,9 @@ const tableMethods = {
6372
6459
  }
6373
6460
  return storeData;
6374
6461
  },
6462
+ /**
6463
+ * @private
6464
+ */
6375
6465
  saveCustomStore(type) {
6376
6466
  const $xeTable = this;
6377
6467
  const props = $xeTable;
@@ -6716,6 +6806,9 @@ const tableMethods = {
6716
6806
  }
6717
6807
  }
6718
6808
  },
6809
+ /**
6810
+ * @private
6811
+ */
6719
6812
  handleRowResizeMousedownEvent(evnt, params) {
6720
6813
  const $xeTable = this;
6721
6814
  const props = $xeTable;
@@ -6836,6 +6929,9 @@ const tableMethods = {
6836
6929
  };
6837
6930
  updateEvent(evnt);
6838
6931
  },
6932
+ /**
6933
+ * @private
6934
+ */
6839
6935
  handleRowResizeDblclickEvent(evnt, params) {
6840
6936
  const $xeTable = this;
6841
6937
  const reactData = $xeTable;
@@ -6857,7 +6953,7 @@ const tableMethods = {
6857
6953
  }
6858
6954
  const handleRsHeight = () => {
6859
6955
  el.setAttribute('data-calc-row', 'Y');
6860
- const resizeHeight = calcCellAutoHeight($xeTable, rowRest, el);
6956
+ const resizeHeight = calcCellAutoHeight($xeTable, rowid, rowRest, el);
6861
6957
  el.removeAttribute('data-calc-row');
6862
6958
  const resizeParams = Object.assign(Object.assign({}, params), { resizeHeight, resizeRow: row });
6863
6959
  reactData.isDragResize = false;
@@ -6943,7 +7039,7 @@ const tableMethods = {
6943
7039
  const rowid = XEUtils.isString(row) || XEUtils.isNumber(row) ? row : handleGetRowId(row);
6944
7040
  const rowRest = fullAllDataRowIdData[rowid];
6945
7041
  if (rowRest) {
6946
- rowRest.resizeHeight = calcCellAutoHeight($xeTable, rowRest, el);
7042
+ rowRest.resizeHeight = calcCellAutoHeight($xeTable, rowid, rowRest, el);
6947
7043
  }
6948
7044
  el.removeAttribute('data-calc-row');
6949
7045
  });
@@ -83,6 +83,7 @@ export function createInternalData() {
83
83
  sourceDataRowIdData: {},
84
84
  fullColumnIdData: {},
85
85
  fullColumnFieldData: {},
86
+ fullCellHeightMaps: {},
86
87
  // 当前行
87
88
  currentRow: null,
88
89
  // 合并表头单元格的数据
@@ -142,7 +143,8 @@ export function createInternalData() {
142
143
  inited: false,
143
144
  tooltipTimeout: null,
144
145
  initStatus: false,
145
- isActivated: false
146
+ isActivated: false,
147
+ rceDelay: 0
146
148
  // _sToTime: null
147
149
  };
148
150
  }
@@ -390,6 +392,21 @@ export function createReactData() {
390
392
  isColLoading: false
391
393
  };
392
394
  }
395
+ const maxKey = '__max';
396
+ export function getRowMaxHeight(chRest, isForce) {
397
+ if (isForce || !chRest[maxKey]) {
398
+ let max = 0;
399
+ for (const key in chRest) {
400
+ const val = chRest[key];
401
+ if (key !== maxKey && XEUtils.isNumber(val) && val > max) {
402
+ max = val;
403
+ }
404
+ }
405
+ chRest[maxKey] = max;
406
+ return max;
407
+ }
408
+ return chRest[maxKey];
409
+ }
393
410
  const getAllConvertColumns = (columns, parentColumn) => {
394
411
  const result = [];
395
412
  columns.forEach((column) => {
package/es/ui/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  import { getFuncText } from './src/utils';
3
- export const version = "3.21.7";
3
+ export const version = "3.21.8";
4
4
  VxeUI.version = version;
5
5
  VxeUI.tableVersion = version;
6
6
  VxeUI.setConfig({
package/es/ui/src/log.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { VxeUI } from '@vxe-ui/core';
2
2
  const { log } = VxeUI;
3
- const version = `table v${"3.21.7"}`;
3
+ const version = `table v${"3.21.8"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);