vxe-table 3.12.1 → 3.12.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.
@@ -212,6 +212,54 @@ function cacheColumnMap($xeTable) {
212
212
  reactData.expandColumn = expandColumn;
213
213
  reactData.isAllOverflow = isAllOverflow;
214
214
  }
215
+ const updateScrollYStatus = ($xeTable, fullData) => {
216
+ const props = $xeTable;
217
+ const reactData = $xeTable;
218
+ const internalData = $xeTable;
219
+ const { treeConfig } = props;
220
+ const sYOpts = $xeTable.computeSYOpts;
221
+ const treeOpts = $xeTable.computeTreeOpts;
222
+ const { transform } = treeOpts;
223
+ const allList = fullData || internalData.tableFullData;
224
+ // 如果gt为0,则总是启用
225
+ const scrollYLoad = (transform || !treeConfig) && !!sYOpts.enabled && sYOpts.gt > -1 && (sYOpts.gt === 0 || sYOpts.gt < allList.length);
226
+ reactData.scrollYLoad = scrollYLoad;
227
+ return scrollYLoad;
228
+ };
229
+ /**
230
+ * 如果为虚拟树,将树结构拍平
231
+ * @returns
232
+ */
233
+ function handleVirtualTreeToList($xeTable) {
234
+ const props = $xeTable;
235
+ const reactData = $xeTable;
236
+ const internalData = $xeTable;
237
+ const { treeConfig } = props;
238
+ const { treeExpandedMaps } = reactData;
239
+ const { fullAllDataRowIdData } = internalData;
240
+ const treeOpts = $xeTable.computeTreeOpts;
241
+ const childrenField = treeOpts.children || treeOpts.childrenField;
242
+ if (treeConfig && treeOpts.transform) {
243
+ const fullData = [];
244
+ const expandMaps = {};
245
+ XEUtils.eachTree(internalData.afterTreeFullData, (row, index, items, path, parentRow) => {
246
+ const rowid = getRowid($xeTable, row);
247
+ const parentRowid = getRowid($xeTable, parentRow);
248
+ if (!parentRow || (expandMaps[parentRowid] && treeExpandedMaps[parentRowid])) {
249
+ const rowRest = fullAllDataRowIdData[rowid];
250
+ if (rowRest) {
251
+ rowRest._index = fullData.length;
252
+ }
253
+ expandMaps[rowid] = 1;
254
+ fullData.push(row);
255
+ }
256
+ }, { children: childrenField });
257
+ internalData.afterFullData = fullData;
258
+ updateScrollYStatus($xeTable, fullData);
259
+ return fullData;
260
+ }
261
+ return internalData.afterFullData;
262
+ }
215
263
  function computeRowHeight($xeTable) {
216
264
  const tableHeader = $xeTable.$refs.tableHeader;
217
265
  const tableBody = $xeTable.$refs.tableBody;
@@ -1102,6 +1150,7 @@ const Methods = {
1102
1150
  });
1103
1151
  },
1104
1152
  handleTableData(force) {
1153
+ const $xeTable = this;
1105
1154
  const { scrollYLoad, scrollYStore, fullDataRowIdData, afterFullData } = this;
1106
1155
  let fullList = afterFullData;
1107
1156
  // 是否进行数据处理
@@ -1109,7 +1158,7 @@ const Methods = {
1109
1158
  // 更新数据,处理筛选和排序
1110
1159
  this.updateAfterFullData();
1111
1160
  // 如果为虚拟树,将树结构拍平
1112
- fullList = this.handleVirtualTreeToList();
1161
+ fullList = handleVirtualTreeToList($xeTable);
1113
1162
  }
1114
1163
  const tableData = scrollYLoad ? fullList.slice(scrollYStore.startIndex, scrollYStore.endIndex) : fullList.slice(0);
1115
1164
  tableData.forEach((row, $index) => {
@@ -1122,15 +1171,6 @@ const Methods = {
1122
1171
  this.tableData = tableData;
1123
1172
  return this.$nextTick();
1124
1173
  },
1125
- updateScrollYStatus(fullData) {
1126
- const { treeConfig, treeOpts, sYOpts } = this;
1127
- const { transform } = treeOpts;
1128
- const allList = fullData || this.tableFullData;
1129
- // 如果gt为0,则总是启用
1130
- const scrollYLoad = (transform || !treeConfig) && !!sYOpts.enabled && sYOpts.gt > -1 && (sYOpts.gt === 0 || sYOpts.gt <= allList.length);
1131
- this.scrollYLoad = scrollYLoad;
1132
- return scrollYLoad;
1133
- },
1134
1174
  /**
1135
1175
  * 加载表格数据
1136
1176
  * @param {Array} datas 数据
@@ -1186,7 +1226,7 @@ const Methods = {
1186
1226
  editStore.insertMaps = {};
1187
1227
  editStore.removeList = [];
1188
1228
  editStore.removeMaps = {};
1189
- const sYLoad = this.updateScrollYStatus(fullData);
1229
+ const sYLoad = updateScrollYStatus($xeTable, fullData);
1190
1230
  this.isDragRowMove = false;
1191
1231
  // 全量数据
1192
1232
  this.tableFullData = fullData;
@@ -2069,37 +2109,6 @@ const Methods = {
2069
2109
  }
2070
2110
  return rowList;
2071
2111
  },
2072
- /**
2073
- * 如果为虚拟树,将树结构拍平
2074
- * @returns
2075
- */
2076
- handleVirtualTreeToList() {
2077
- const $xeTable = this;
2078
- const internalData = $xeTable;
2079
- const { fullAllDataRowIdData } = internalData;
2080
- const { treeOpts, treeConfig, treeExpandedMaps, afterTreeFullData, afterFullData } = this;
2081
- const childrenField = treeOpts.children || treeOpts.childrenField;
2082
- if (treeConfig && treeOpts.transform) {
2083
- const fullData = [];
2084
- const expandMaps = {};
2085
- XEUtils.eachTree(afterTreeFullData, (row, index, items, path, parentRow) => {
2086
- const rowid = getRowid(this, row);
2087
- const parentRowid = getRowid(this, parentRow);
2088
- if (!parentRow || (expandMaps[parentRowid] && treeExpandedMaps[parentRowid])) {
2089
- const rowRest = fullAllDataRowIdData[rowid];
2090
- if (rowRest) {
2091
- rowRest._index = fullData.length;
2092
- }
2093
- expandMaps[rowid] = 1;
2094
- fullData.push(row);
2095
- }
2096
- }, { children: childrenField });
2097
- this.afterFullData = fullData;
2098
- this.updateScrollYStatus(fullData);
2099
- return fullData;
2100
- }
2101
- return afterFullData;
2102
- },
2103
2112
  /**
2104
2113
  * 获取处理后全量的表格数据
2105
2114
  * 如果存在筛选条件,继续处理
@@ -5547,7 +5556,7 @@ const Methods = {
5547
5556
  reactData.isDragRowMove = true;
5548
5557
  $xeTable.handleTableData(treeConfig && transform);
5549
5558
  $xeTable.cacheRowMap();
5550
- $xeTable.updateScrollYStatus();
5559
+ updateScrollYStatus($xeTable);
5551
5560
  if (!(treeConfig && transform)) {
5552
5561
  $xeTable.updateAfterDataIndex();
5553
5562
  }
@@ -6214,19 +6223,20 @@ const Methods = {
6214
6223
  },
6215
6224
  clearRowExpandLoaded(row) {
6216
6225
  const $xeTable = this;
6217
- const { expandOpts, rowExpandLazyLoadedMaps, fullAllDataRowIdData } = this;
6226
+ const reactData = $xeTable;
6227
+ const internalData = $xeTable;
6228
+ const rExpandLazyLoadedMaps = Object.assign({}, reactData.rowExpandLazyLoadedMaps);
6229
+ const { fullAllDataRowIdData } = internalData;
6230
+ const expandOpts = $xeTable.computeExpandOpts;
6218
6231
  const { lazy } = expandOpts;
6219
6232
  const rowid = getRowid($xeTable, row);
6220
6233
  const rowRest = fullAllDataRowIdData[rowid];
6221
6234
  if (lazy && rowRest) {
6222
6235
  rowRest.expandLoaded = false;
6223
- const rowTempExpandLazyLoadedMaps = Object.assign({}, rowExpandLazyLoadedMaps);
6224
- if (rowTempExpandLazyLoadedMaps[rowid]) {
6225
- delete rowTempExpandLazyLoadedMaps[rowid];
6226
- }
6227
- this.rowExpandLazyLoadedMaps = rowTempExpandLazyLoadedMaps;
6236
+ delete rExpandLazyLoadedMaps[rowid];
6228
6237
  }
6229
- return this.$nextTick();
6238
+ reactData.rowExpandLazyLoadedMaps = rExpandLazyLoadedMaps;
6239
+ return $xeTable.$nextTick();
6230
6240
  },
6231
6241
  /**
6232
6242
  * 重新懒加载展开行,并展开内容
@@ -6314,30 +6324,36 @@ const Methods = {
6314
6324
  },
6315
6325
  handleAsyncRowExpand(row) {
6316
6326
  const $xeTable = this;
6327
+ const reactData = $xeTable;
6328
+ const internalData = $xeTable;
6317
6329
  return new Promise(resolve => {
6318
6330
  const { expandOpts } = this;
6319
6331
  const { loadMethod } = expandOpts;
6320
6332
  if (loadMethod) {
6321
- const { rowExpandLazyLoadedMaps, fullAllDataRowIdData } = this;
6333
+ const { fullAllDataRowIdData } = internalData;
6334
+ const rExpandLazyLoadedMaps = Object.assign({}, reactData.rowExpandLazyLoadedMaps);
6322
6335
  const rowid = getRowid($xeTable, row);
6323
6336
  const rowRest = fullAllDataRowIdData[rowid];
6324
- rowExpandLazyLoadedMaps[rowid] = row;
6325
- loadMethod({ $table: $xeTable, row, rowIndex: this.getRowIndex(row), $rowIndex: this.getVMRowIndex(row) }).then(() => {
6326
- const { rowExpandedMaps } = this;
6337
+ rExpandLazyLoadedMaps[rowid] = row;
6338
+ reactData.rowExpandLazyLoadedMaps = rExpandLazyLoadedMaps;
6339
+ loadMethod({ $table: $xeTable, row, rowIndex: $xeTable.getRowIndex(row), $rowIndex: $xeTable.getVMRowIndex(row) }).then(() => {
6340
+ const rExpandedMaps = Object.assign({}, reactData.rowExpandedMaps);
6327
6341
  if (rowRest) {
6328
6342
  rowRest.expandLoaded = true;
6329
6343
  }
6330
- rowExpandedMaps[rowid] = row;
6344
+ rExpandedMaps[rowid] = row;
6345
+ reactData.rowExpandedMaps = rExpandedMaps;
6331
6346
  }).catch(() => {
6332
6347
  if (rowRest) {
6333
6348
  rowRest.expandLoaded = false;
6334
6349
  }
6335
6350
  }).finally(() => {
6336
- const { rowExpandLazyLoadedMaps } = this;
6337
- if (rowExpandLazyLoadedMaps[rowid]) {
6338
- delete rowExpandLazyLoadedMaps[rowid];
6351
+ const rExpandLazyLoadedMaps = Object.assign({}, reactData.rowExpandLazyLoadedMaps);
6352
+ if (rExpandLazyLoadedMaps[rowid]) {
6353
+ delete rExpandLazyLoadedMaps[rowid];
6339
6354
  }
6340
- this.$nextTick().then(() => this.recalculate()).then(() => resolve());
6355
+ reactData.rowExpandLazyLoadedMaps = rExpandLazyLoadedMaps;
6356
+ $xeTable.$nextTick().then(() => $xeTable.recalculate()).then(() => resolve());
6341
6357
  });
6342
6358
  }
6343
6359
  else {
@@ -6490,7 +6506,11 @@ const Methods = {
6490
6506
  },
6491
6507
  clearTreeExpandLoaded(rows) {
6492
6508
  const $xeTable = this;
6493
- const { treeOpts, treeExpandedMaps, fullAllDataRowIdData } = this;
6509
+ const reactData = $xeTable;
6510
+ const internalData = $xeTable;
6511
+ const tExpandedMaps = Object.assign({}, reactData.treeExpandedMaps);
6512
+ const { fullAllDataRowIdData } = internalData;
6513
+ const treeOpts = $xeTable.computeTreeOpts;
6494
6514
  const { transform } = treeOpts;
6495
6515
  if (rows) {
6496
6516
  if (!XEUtils.isArray(rows)) {
@@ -6501,23 +6521,25 @@ const Methods = {
6501
6521
  const rowRest = fullAllDataRowIdData[rowid];
6502
6522
  if (rowRest) {
6503
6523
  rowRest.treeLoaded = false;
6504
- if (treeExpandedMaps[rowid]) {
6505
- delete treeExpandedMaps[rowid];
6524
+ if (tExpandedMaps[rowid]) {
6525
+ delete tExpandedMaps[rowid];
6506
6526
  }
6507
6527
  }
6508
6528
  });
6509
6529
  }
6530
+ reactData.treeExpandedMaps = tExpandedMaps;
6510
6531
  if (transform) {
6511
- this.handleVirtualTreeToList();
6512
- return this.handleTableData();
6532
+ handleVirtualTreeToList($xeTable);
6533
+ return $xeTable.handleTableData();
6513
6534
  }
6514
- return this.$nextTick();
6535
+ return $xeTable.$nextTick();
6515
6536
  },
6516
6537
  /**
6517
6538
  * 重新懒加载树节点,并展开该节点
6518
6539
  * @param {Row} row 行对象
6519
6540
  */
6520
6541
  reloadTreeExpand(row) {
6542
+ const $xeTable = this;
6521
6543
  const { treeOpts, treeExpandLazyLoadedMaps } = this;
6522
6544
  const { transform, lazy } = treeOpts;
6523
6545
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField;
@@ -6527,7 +6549,7 @@ const Methods = {
6527
6549
  return this.handleAsyncTreeExpandChilds(row);
6528
6550
  }).then(() => {
6529
6551
  if (transform) {
6530
- this.handleVirtualTreeToList();
6552
+ handleVirtualTreeToList($xeTable);
6531
6553
  return this.handleTableData();
6532
6554
  }
6533
6555
  }).then(() => {
@@ -6739,8 +6761,9 @@ const Methods = {
6739
6761
  * @returns
6740
6762
  */
6741
6763
  handleVirtualTreeExpand(rows, expanded) {
6764
+ const $xeTable = this;
6742
6765
  return this.handleBaseTreeExpand(rows, expanded).then(() => {
6743
- this.handleVirtualTreeToList();
6766
+ handleVirtualTreeToList($xeTable);
6744
6767
  this.handleTableData();
6745
6768
  this.updateTreeDataIndex();
6746
6769
  }).then(() => {
@@ -6789,6 +6812,7 @@ const Methods = {
6789
6812
  * 手动清空树形节点的展开状态,数据会恢复成未展开的状态
6790
6813
  */
6791
6814
  clearTreeExpand() {
6815
+ const $xeTable = this;
6792
6816
  const { treeOpts, tableFullData } = this;
6793
6817
  const { transform, reserve } = treeOpts;
6794
6818
  const childrenField = treeOpts.children || treeOpts.childrenField;
@@ -6799,7 +6823,7 @@ const Methods = {
6799
6823
  }
6800
6824
  return this.handleTableData().then(() => {
6801
6825
  if (transform) {
6802
- this.handleVirtualTreeToList();
6826
+ handleVirtualTreeToList($xeTable);
6803
6827
  return this.handleTableData();
6804
6828
  }
6805
6829
  }).then(() => {
@@ -4,7 +4,7 @@ import { VxeUI } from '../../ui';
4
4
  import { getSlotVNs } from '../../ui/src/vn';
5
5
  import { warnLog, errLog } from '../../ui/src/log';
6
6
  const { getConfig, getIcon, getI18n, renderer, commands, createEvent, globalMixins, renderEmptyElement } = VxeUI;
7
- export default {
7
+ export default defineVxeComponent({
8
8
  name: 'VxeToolbar',
9
9
  mixins: [
10
10
  globalMixins.sizeMixin
@@ -704,4 +704,4 @@ export default {
704
704
  render(h) {
705
705
  return this.renderVN(h);
706
706
  }
707
- };
707
+ });
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.12.1";
3
+ export const version = "3.12.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.12.1"}`;
3
+ const version = `table v${"3.12.3"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);