vxe-table 3.17.0-beta.1 → 3.17.0-beta.3

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.
@@ -500,6 +500,23 @@ function handleRowGroupVirtualExpand($xeTable, rows, expanded) {
500
500
  }, 30);
501
501
  });
502
502
  }
503
+ /**
504
+ * 处理默认展开分组行
505
+ */
506
+ function handleDefaultRowGroupExpand($xeTable) {
507
+ const reactData = $xeTable;
508
+ const { isRowGroupStatus } = reactData;
509
+ if (isRowGroupStatus) {
510
+ const aggregateOpts = $xeTable.computeAggregateOpts;
511
+ const { expandAll, expandGroupFields } = aggregateOpts;
512
+ if (expandAll) {
513
+ $xeTable.setAllRowGroupExpand(true);
514
+ }
515
+ else if (expandGroupFields && expandGroupFields.length) {
516
+ $xeTable.setRowGroupExpandByField(expandGroupFields, true);
517
+ }
518
+ }
519
+ }
503
520
  function updateAfterListIndex($xeTable) {
504
521
  const props = $xeTable;
505
522
  const internalData = $xeTable;
@@ -2952,6 +2969,13 @@ function loadTableData($xeTable, datas, isReset) {
2952
2969
  }
2953
2970
  reactData.isRowLoading = false;
2954
2971
  handleRecalculateStyle($xeTable, false, false, false);
2972
+ // 如果是自动行高,特殊情况需调用 recalculate 手动刷新
2973
+ if (!props.showOverflow) {
2974
+ setTimeout(() => {
2975
+ handleLazyRecalculate($xeTable, false, true, true);
2976
+ setTimeout(() => handleLazyRecalculate($xeTable, false, true, true), 3000);
2977
+ }, 2000);
2978
+ }
2955
2979
  // 是否变更虚拟滚动
2956
2980
  if (oldScrollYLoad === sYLoad) {
2957
2981
  restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
@@ -2984,6 +3008,7 @@ function handleLoadDefaults($xeTable) {
2984
3008
  handleDefaultRadioChecked($xeTable);
2985
3009
  handleDefaultRowExpand($xeTable);
2986
3010
  handleDefaultTreeExpand($xeTable);
3011
+ handleDefaultRowGroupExpand($xeTable);
2987
3012
  handleDefaultMergeCells($xeTable);
2988
3013
  handleDefaultMergeFooterItems($xeTable);
2989
3014
  $xeTable.$nextTick(() => setTimeout(() => $xeTable.recalculate()));
@@ -5217,7 +5242,7 @@ const Methods = {
5217
5242
  evnt.preventDefault();
5218
5243
  const { column } = params;
5219
5244
  const { columnStore, overflowX, scrollbarHeight } = reactData;
5220
- const { elemStore, visibleColumn } = internalData;
5245
+ const { visibleColumn } = internalData;
5221
5246
  const { leftList, rightList } = columnStore;
5222
5247
  const resizableOpts = $xeTable.computeResizableOpts;
5223
5248
  const osbHeight = overflowX ? scrollbarHeight : 0;
@@ -5235,24 +5260,29 @@ const Methods = {
5235
5260
  const { clientX: dragClientX } = evnt;
5236
5261
  const dragBtnElem = evnt.target;
5237
5262
  let resizeColumn = column;
5238
- if (column.children && column.children.length) {
5263
+ const isDragGroupCol = column.children && column.children.length;
5264
+ if (isDragGroupCol) {
5239
5265
  XEUtils.eachTree(column.children, childColumn => {
5240
5266
  resizeColumn = childColumn;
5241
5267
  });
5242
5268
  }
5243
- const cell = dragBtnElem.parentNode;
5244
- const cellParams = Object.assign(params, { cell });
5245
- let dragLeft = 0;
5246
- const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
5247
- if (!bodyScrollElem) {
5269
+ let cell = dragBtnElem.parentElement;
5270
+ if (isDragGroupCol) {
5271
+ const trEl = cell ? cell.parentElement : null;
5272
+ const theadEl = trEl ? trEl.parentElement : null;
5273
+ cell = theadEl ? theadEl.querySelector(`.vxe-header--column[colid="${resizeColumn.id}"]`) : null;
5274
+ }
5275
+ if (!cell) {
5248
5276
  return;
5249
5277
  }
5278
+ const cellParams = XEUtils.assign(params, { cell });
5279
+ let dragLeft = 0;
5250
5280
  const tableRect = tableEl.getBoundingClientRect();
5251
5281
  const rightContainerRect = rightContainerElem ? rightContainerElem.getBoundingClientRect() : null;
5252
5282
  const cellRect = cell.getBoundingClientRect();
5253
5283
  const dragBtnRect = dragBtnElem.getBoundingClientRect();
5254
5284
  const dragBtnWidth = dragBtnElem.clientWidth;
5255
- const dragBtnOffsetWidth = Math.floor(dragBtnWidth / 2);
5285
+ const dragBtnOffsetWidth = XEUtils.floor(dragBtnWidth / 2);
5256
5286
  const dragPosLeft = dragBtnRect.x - tableRect.x + dragBtnOffsetWidth;
5257
5287
  const minInterval = getColReMinWidth(cellParams) - dragBtnOffsetWidth; // 列之间的最小间距
5258
5288
  const dragMinLeft = isRightFixed ? 0 : (cellRect.x - tableRect.x + dragBtnWidth + minInterval);
@@ -8670,8 +8700,7 @@ const Methods = {
8670
8700
  },
8671
8701
  setSort(sortConfs, isUpdate) {
8672
8702
  const $xeTable = this;
8673
- // 已废弃,即将去掉事件触发 new Event('click') -> null
8674
- return handleSortEvent($xeTable, new Event('click'), sortConfs, isUpdate);
8703
+ return handleSortEvent($xeTable, null, sortConfs, isUpdate);
8675
8704
  },
8676
8705
  setSortByEvent(evnt, sortConfs, isUpdate) {
8677
8706
  const $xeTable = this;
@@ -9186,6 +9215,35 @@ const Methods = {
9186
9215
  }
9187
9216
  return $xeTable.$nextTick();
9188
9217
  },
9218
+ setRowGroupExpandByField(groupFields, expanded) {
9219
+ const $xeTable = this;
9220
+ const reactData = $xeTable;
9221
+ const internalData = $xeTable;
9222
+ const { isRowGroupStatus } = reactData;
9223
+ const aggregateOpts = $xeTable.computeAggregateOpts;
9224
+ const { childrenField } = aggregateOpts;
9225
+ if (groupFields) {
9226
+ if (!XEUtils.isArray(groupFields)) {
9227
+ groupFields = [groupFields];
9228
+ }
9229
+ if (isRowGroupStatus) {
9230
+ const rows = [];
9231
+ const gfKeys = {};
9232
+ groupFields.forEach(groupField => {
9233
+ gfKeys[groupField] = true;
9234
+ });
9235
+ XEUtils.eachTree(internalData.afterGroupFullData, (row) => {
9236
+ if (row.isAggregate && gfKeys[row.groupField]) {
9237
+ rows.push(row);
9238
+ }
9239
+ }, { children: childrenField });
9240
+ if (rows.length) {
9241
+ return handleRowGroupVirtualExpand($xeTable, rows, expanded);
9242
+ }
9243
+ }
9244
+ }
9245
+ return $xeTable.$nextTick();
9246
+ },
9189
9247
  setAllRowGroupExpand(expanded) {
9190
9248
  const $xeTable = this;
9191
9249
  const reactData = $xeTable;
@@ -10201,8 +10259,6 @@ const Methods = {
10201
10259
  },
10202
10260
  /**
10203
10261
  * 如果有滚动条,则滚动到对应的位置
10204
- * @param {Number} scrollLeft 左距离
10205
- * @param {Number} scrollTop 上距离
10206
10262
  */
10207
10263
  scrollTo(scrollLeft, scrollTop) {
10208
10264
  const $xeTable = this;
@@ -10217,6 +10273,12 @@ const Methods = {
10217
10273
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
10218
10274
  const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
10219
10275
  internalData.intoRunScroll = true;
10276
+ if (scrollLeft) {
10277
+ if (!XEUtils.isNumber(scrollLeft)) {
10278
+ scrollTop = scrollLeft.top;
10279
+ scrollLeft = scrollLeft.left;
10280
+ }
10281
+ }
10220
10282
  if (XEUtils.isNumber(scrollLeft)) {
10221
10283
  setScrollLeft(xHandleEl, scrollLeft);
10222
10284
  setScrollLeft(bodyScrollElem, scrollLeft);
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.17.0-beta.1";
3
+ export const version = "3.17.0-beta.3";
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.17.0-beta.1"}`;
3
+ const version = `table v${"3.17.0-beta.3"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);
package/lib/index.umd.js CHANGED
@@ -2002,7 +2002,7 @@ function getClass(property, params) {
2002
2002
  ;// CONCATENATED MODULE: ./packages/ui/index.ts
2003
2003
 
2004
2004
 
2005
- const version = "3.17.0-beta.1";
2005
+ const version = "3.17.0-beta.3";
2006
2006
  core_.VxeUI.version = version;
2007
2007
  core_.VxeUI.tableVersion = version;
2008
2008
  core_.VxeUI.setConfig({
@@ -2667,7 +2667,7 @@ function isNodeElement(elem) {
2667
2667
  const {
2668
2668
  log: log_log
2669
2669
  } = core_.VxeUI;
2670
- const log_version = `table v${"3.17.0-beta.1"}`;
2670
+ const log_version = `table v${"3.17.0-beta.3"}`;
2671
2671
  const warnLog = log_log.create('warn', log_version);
2672
2672
  const errLog = log_log.create('error', log_version);
2673
2673
  ;// CONCATENATED MODULE: ./packages/table/src/columnInfo.ts
@@ -5832,6 +5832,27 @@ function handleRowGroupVirtualExpand($xeTable, rows, expanded) {
5832
5832
  }, 30);
5833
5833
  });
5834
5834
  }
5835
+ /**
5836
+ * 处理默认展开分组行
5837
+ */
5838
+ function handleDefaultRowGroupExpand($xeTable) {
5839
+ const reactData = $xeTable;
5840
+ const {
5841
+ isRowGroupStatus
5842
+ } = reactData;
5843
+ if (isRowGroupStatus) {
5844
+ const aggregateOpts = $xeTable.computeAggregateOpts;
5845
+ const {
5846
+ expandAll,
5847
+ expandGroupFields
5848
+ } = aggregateOpts;
5849
+ if (expandAll) {
5850
+ $xeTable.setAllRowGroupExpand(true);
5851
+ } else if (expandGroupFields && expandGroupFields.length) {
5852
+ $xeTable.setRowGroupExpandByField(expandGroupFields, true);
5853
+ }
5854
+ }
5855
+ }
5835
5856
  function updateAfterListIndex($xeTable) {
5836
5857
  const props = $xeTable;
5837
5858
  const internalData = $xeTable;
@@ -8739,6 +8760,13 @@ function loadTableData($xeTable, datas, isReset) {
8739
8760
  }
8740
8761
  reactData.isRowLoading = false;
8741
8762
  handleRecalculateStyle($xeTable, false, false, false);
8763
+ // 如果是自动行高,特殊情况需调用 recalculate 手动刷新
8764
+ if (!props.showOverflow) {
8765
+ setTimeout(() => {
8766
+ handleLazyRecalculate($xeTable, false, true, true);
8767
+ setTimeout(() => handleLazyRecalculate($xeTable, false, true, true), 3000);
8768
+ }, 2000);
8769
+ }
8742
8770
  // 是否变更虚拟滚动
8743
8771
  if (oldScrollYLoad === sYLoad) {
8744
8772
  restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop).then(() => {
@@ -8768,6 +8796,7 @@ function handleLoadDefaults($xeTable) {
8768
8796
  handleDefaultRadioChecked($xeTable);
8769
8797
  handleDefaultRowExpand($xeTable);
8770
8798
  handleDefaultTreeExpand($xeTable);
8799
+ handleDefaultRowGroupExpand($xeTable);
8771
8800
  handleDefaultMergeCells($xeTable);
8772
8801
  handleDefaultMergeFooterItems($xeTable);
8773
8802
  $xeTable.$nextTick(() => setTimeout(() => $xeTable.recalculate()));
@@ -11343,7 +11372,6 @@ const Methods = {
11343
11372
  scrollbarHeight
11344
11373
  } = reactData;
11345
11374
  const {
11346
- elemStore,
11347
11375
  visibleColumn
11348
11376
  } = internalData;
11349
11377
  const {
@@ -11368,26 +11396,31 @@ const Methods = {
11368
11396
  } = evnt;
11369
11397
  const dragBtnElem = evnt.target;
11370
11398
  let resizeColumn = column;
11371
- if (column.children && column.children.length) {
11399
+ const isDragGroupCol = column.children && column.children.length;
11400
+ if (isDragGroupCol) {
11372
11401
  external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().eachTree(column.children, childColumn => {
11373
11402
  resizeColumn = childColumn;
11374
11403
  });
11375
11404
  }
11376
- const cell = dragBtnElem.parentNode;
11377
- const cellParams = Object.assign(params, {
11405
+ let cell = dragBtnElem.parentElement;
11406
+ if (isDragGroupCol) {
11407
+ const trEl = cell ? cell.parentElement : null;
11408
+ const theadEl = trEl ? trEl.parentElement : null;
11409
+ cell = theadEl ? theadEl.querySelector(`.vxe-header--column[colid="${resizeColumn.id}"]`) : null;
11410
+ }
11411
+ if (!cell) {
11412
+ return;
11413
+ }
11414
+ const cellParams = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().assign(params, {
11378
11415
  cell
11379
11416
  });
11380
11417
  let dragLeft = 0;
11381
- const bodyScrollElem = getRefElem(elemStore['main-body-scroll']);
11382
- if (!bodyScrollElem) {
11383
- return;
11384
- }
11385
11418
  const tableRect = tableEl.getBoundingClientRect();
11386
11419
  const rightContainerRect = rightContainerElem ? rightContainerElem.getBoundingClientRect() : null;
11387
11420
  const cellRect = cell.getBoundingClientRect();
11388
11421
  const dragBtnRect = dragBtnElem.getBoundingClientRect();
11389
11422
  const dragBtnWidth = dragBtnElem.clientWidth;
11390
- const dragBtnOffsetWidth = Math.floor(dragBtnWidth / 2);
11423
+ const dragBtnOffsetWidth = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().floor(dragBtnWidth / 2);
11391
11424
  const dragPosLeft = dragBtnRect.x - tableRect.x + dragBtnOffsetWidth;
11392
11425
  const minInterval = getColReMinWidth(cellParams) - dragBtnOffsetWidth; // 列之间的最小间距
11393
11426
  const dragMinLeft = isRightFixed ? 0 : cellRect.x - tableRect.x + dragBtnWidth + minInterval;
@@ -15349,8 +15382,7 @@ const Methods = {
15349
15382
  },
15350
15383
  setSort(sortConfs, isUpdate) {
15351
15384
  const $xeTable = this;
15352
- // 已废弃,即将去掉事件触发 new Event('click') -> null
15353
- return handleSortEvent($xeTable, new Event('click'), sortConfs, isUpdate);
15385
+ return handleSortEvent($xeTable, null, sortConfs, isUpdate);
15354
15386
  },
15355
15387
  setSortByEvent(evnt, sortConfs, isUpdate) {
15356
15388
  const $xeTable = this;
@@ -15967,6 +15999,41 @@ const Methods = {
15967
15999
  }
15968
16000
  return $xeTable.$nextTick();
15969
16001
  },
16002
+ setRowGroupExpandByField(groupFields, expanded) {
16003
+ const $xeTable = this;
16004
+ const reactData = $xeTable;
16005
+ const internalData = $xeTable;
16006
+ const {
16007
+ isRowGroupStatus
16008
+ } = reactData;
16009
+ const aggregateOpts = $xeTable.computeAggregateOpts;
16010
+ const {
16011
+ childrenField
16012
+ } = aggregateOpts;
16013
+ if (groupFields) {
16014
+ if (!external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isArray(groupFields)) {
16015
+ groupFields = [groupFields];
16016
+ }
16017
+ if (isRowGroupStatus) {
16018
+ const rows = [];
16019
+ const gfKeys = {};
16020
+ groupFields.forEach(groupField => {
16021
+ gfKeys[groupField] = true;
16022
+ });
16023
+ external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().eachTree(internalData.afterGroupFullData, row => {
16024
+ if (row.isAggregate && gfKeys[row.groupField]) {
16025
+ rows.push(row);
16026
+ }
16027
+ }, {
16028
+ children: childrenField
16029
+ });
16030
+ if (rows.length) {
16031
+ return handleRowGroupVirtualExpand($xeTable, rows, expanded);
16032
+ }
16033
+ }
16034
+ }
16035
+ return $xeTable.$nextTick();
16036
+ },
15970
16037
  setAllRowGroupExpand(expanded) {
15971
16038
  const $xeTable = this;
15972
16039
  const reactData = $xeTable;
@@ -17144,8 +17211,6 @@ const Methods = {
17144
17211
  },
17145
17212
  /**
17146
17213
  * 如果有滚动条,则滚动到对应的位置
17147
- * @param {Number} scrollLeft 左距离
17148
- * @param {Number} scrollTop 上距离
17149
17214
  */
17150
17215
  scrollTo(scrollLeft, scrollTop) {
17151
17216
  const $xeTable = this;
@@ -17162,6 +17227,12 @@ const Methods = {
17162
17227
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
17163
17228
  const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
17164
17229
  internalData.intoRunScroll = true;
17230
+ if (scrollLeft) {
17231
+ if (!external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isNumber(scrollLeft)) {
17232
+ scrollTop = scrollLeft.top;
17233
+ scrollLeft = scrollLeft.left;
17234
+ }
17235
+ }
17165
17236
  if (external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isNumber(scrollLeft)) {
17166
17237
  setScrollLeft(xHandleEl, scrollLeft);
17167
17238
  setScrollLeft(bodyScrollElem, scrollLeft);