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.
@@ -607,6 +607,27 @@ function handleRowGroupVirtualExpand($xeTable, rows, expanded) {
607
607
  }, 30);
608
608
  });
609
609
  }
610
+ /**
611
+ * 处理默认展开分组行
612
+ */
613
+ function handleDefaultRowGroupExpand($xeTable) {
614
+ const reactData = $xeTable;
615
+ const {
616
+ isRowGroupStatus
617
+ } = reactData;
618
+ if (isRowGroupStatus) {
619
+ const aggregateOpts = $xeTable.computeAggregateOpts;
620
+ const {
621
+ expandAll,
622
+ expandGroupFields
623
+ } = aggregateOpts;
624
+ if (expandAll) {
625
+ $xeTable.setAllRowGroupExpand(true);
626
+ } else if (expandGroupFields && expandGroupFields.length) {
627
+ $xeTable.setRowGroupExpandByField(expandGroupFields, true);
628
+ }
629
+ }
630
+ }
610
631
  function updateAfterListIndex($xeTable) {
611
632
  const props = $xeTable;
612
633
  const internalData = $xeTable;
@@ -3514,6 +3535,13 @@ function loadTableData($xeTable, datas, isReset) {
3514
3535
  }
3515
3536
  reactData.isRowLoading = false;
3516
3537
  handleRecalculateStyle($xeTable, false, false, false);
3538
+ // 如果是自动行高,特殊情况需调用 recalculate 手动刷新
3539
+ if (!props.showOverflow) {
3540
+ setTimeout(() => {
3541
+ handleLazyRecalculate($xeTable, false, true, true);
3542
+ setTimeout(() => handleLazyRecalculate($xeTable, false, true, true), 3000);
3543
+ }, 2000);
3544
+ }
3517
3545
  // 是否变更虚拟滚动
3518
3546
  if (oldScrollYLoad === sYLoad) {
3519
3547
  (0, _util.restoreScrollLocation)($xeTable, targetScrollLeft, targetScrollTop).then(() => {
@@ -3543,6 +3571,7 @@ function handleLoadDefaults($xeTable) {
3543
3571
  handleDefaultRadioChecked($xeTable);
3544
3572
  handleDefaultRowExpand($xeTable);
3545
3573
  handleDefaultTreeExpand($xeTable);
3574
+ handleDefaultRowGroupExpand($xeTable);
3546
3575
  handleDefaultMergeCells($xeTable);
3547
3576
  handleDefaultMergeFooterItems($xeTable);
3548
3577
  $xeTable.$nextTick(() => setTimeout(() => $xeTable.recalculate()));
@@ -6116,7 +6145,6 @@ const Methods = {
6116
6145
  scrollbarHeight
6117
6146
  } = reactData;
6118
6147
  const {
6119
- elemStore,
6120
6148
  visibleColumn
6121
6149
  } = internalData;
6122
6150
  const {
@@ -6141,26 +6169,31 @@ const Methods = {
6141
6169
  } = evnt;
6142
6170
  const dragBtnElem = evnt.target;
6143
6171
  let resizeColumn = column;
6144
- if (column.children && column.children.length) {
6172
+ const isDragGroupCol = column.children && column.children.length;
6173
+ if (isDragGroupCol) {
6145
6174
  _xeUtils.default.eachTree(column.children, childColumn => {
6146
6175
  resizeColumn = childColumn;
6147
6176
  });
6148
6177
  }
6149
- const cell = dragBtnElem.parentNode;
6150
- const cellParams = Object.assign(params, {
6178
+ let cell = dragBtnElem.parentElement;
6179
+ if (isDragGroupCol) {
6180
+ const trEl = cell ? cell.parentElement : null;
6181
+ const theadEl = trEl ? trEl.parentElement : null;
6182
+ cell = theadEl ? theadEl.querySelector(`.vxe-header--column[colid="${resizeColumn.id}"]`) : null;
6183
+ }
6184
+ if (!cell) {
6185
+ return;
6186
+ }
6187
+ const cellParams = _xeUtils.default.assign(params, {
6151
6188
  cell
6152
6189
  });
6153
6190
  let dragLeft = 0;
6154
- const bodyScrollElem = (0, _util.getRefElem)(elemStore['main-body-scroll']);
6155
- if (!bodyScrollElem) {
6156
- return;
6157
- }
6158
6191
  const tableRect = tableEl.getBoundingClientRect();
6159
6192
  const rightContainerRect = rightContainerElem ? rightContainerElem.getBoundingClientRect() : null;
6160
6193
  const cellRect = cell.getBoundingClientRect();
6161
6194
  const dragBtnRect = dragBtnElem.getBoundingClientRect();
6162
6195
  const dragBtnWidth = dragBtnElem.clientWidth;
6163
- const dragBtnOffsetWidth = Math.floor(dragBtnWidth / 2);
6196
+ const dragBtnOffsetWidth = _xeUtils.default.floor(dragBtnWidth / 2);
6164
6197
  const dragPosLeft = dragBtnRect.x - tableRect.x + dragBtnOffsetWidth;
6165
6198
  const minInterval = (0, _util.getColReMinWidth)(cellParams) - dragBtnOffsetWidth; // 列之间的最小间距
6166
6199
  const dragMinLeft = isRightFixed ? 0 : cellRect.x - tableRect.x + dragBtnWidth + minInterval;
@@ -10115,8 +10148,7 @@ const Methods = {
10115
10148
  },
10116
10149
  setSort(sortConfs, isUpdate) {
10117
10150
  const $xeTable = this;
10118
- // 已废弃,即将去掉事件触发 new Event('click') -> null
10119
- return handleSortEvent($xeTable, new Event('click'), sortConfs, isUpdate);
10151
+ return handleSortEvent($xeTable, null, sortConfs, isUpdate);
10120
10152
  },
10121
10153
  setSortByEvent(evnt, sortConfs, isUpdate) {
10122
10154
  const $xeTable = this;
@@ -10733,6 +10765,41 @@ const Methods = {
10733
10765
  }
10734
10766
  return $xeTable.$nextTick();
10735
10767
  },
10768
+ setRowGroupExpandByField(groupFields, expanded) {
10769
+ const $xeTable = this;
10770
+ const reactData = $xeTable;
10771
+ const internalData = $xeTable;
10772
+ const {
10773
+ isRowGroupStatus
10774
+ } = reactData;
10775
+ const aggregateOpts = $xeTable.computeAggregateOpts;
10776
+ const {
10777
+ childrenField
10778
+ } = aggregateOpts;
10779
+ if (groupFields) {
10780
+ if (!_xeUtils.default.isArray(groupFields)) {
10781
+ groupFields = [groupFields];
10782
+ }
10783
+ if (isRowGroupStatus) {
10784
+ const rows = [];
10785
+ const gfKeys = {};
10786
+ groupFields.forEach(groupField => {
10787
+ gfKeys[groupField] = true;
10788
+ });
10789
+ _xeUtils.default.eachTree(internalData.afterGroupFullData, row => {
10790
+ if (row.isAggregate && gfKeys[row.groupField]) {
10791
+ rows.push(row);
10792
+ }
10793
+ }, {
10794
+ children: childrenField
10795
+ });
10796
+ if (rows.length) {
10797
+ return handleRowGroupVirtualExpand($xeTable, rows, expanded);
10798
+ }
10799
+ }
10800
+ }
10801
+ return $xeTable.$nextTick();
10802
+ },
10736
10803
  setAllRowGroupExpand(expanded) {
10737
10804
  const $xeTable = this;
10738
10805
  const reactData = $xeTable;
@@ -11909,8 +11976,6 @@ const Methods = {
11909
11976
  },
11910
11977
  /**
11911
11978
  * 如果有滚动条,则滚动到对应的位置
11912
- * @param {Number} scrollLeft 左距离
11913
- * @param {Number} scrollTop 上距离
11914
11979
  */
11915
11980
  scrollTo(scrollLeft, scrollTop) {
11916
11981
  const $xeTable = this;
@@ -11927,6 +11992,12 @@ const Methods = {
11927
11992
  const xHandleEl = $xeTable.$refs.refScrollXHandleElem;
11928
11993
  const yHandleEl = $xeTable.$refs.refScrollYHandleElem;
11929
11994
  internalData.intoRunScroll = true;
11995
+ if (scrollLeft) {
11996
+ if (!_xeUtils.default.isNumber(scrollLeft)) {
11997
+ scrollTop = scrollLeft.top;
11998
+ scrollLeft = scrollLeft.left;
11999
+ }
12000
+ }
11930
12001
  if (_xeUtils.default.isNumber(scrollLeft)) {
11931
12002
  (0, _dom.setScrollLeft)(xHandleEl, scrollLeft);
11932
12003
  (0, _dom.setScrollLeft)(bodyScrollElem, scrollLeft);