vxe-table 3.17.0-beta.9 → 3.17.1

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.
Files changed (55) hide show
  1. package/es/grid/src/grid.js +88 -23
  2. package/es/style.css +1 -1
  3. package/es/table/module/custom/mixin.js +32 -14
  4. package/es/table/module/custom/panel.js +1 -1
  5. package/es/table/module/edit/mixin.js +5 -5
  6. package/es/table/src/body.js +7 -6
  7. package/es/table/src/columnInfo.js +5 -0
  8. package/es/table/src/methods.js +223 -85
  9. package/es/table/src/table.js +17 -8
  10. package/es/table/src/util.js +9 -0
  11. package/es/ui/index.js +3 -1
  12. package/es/ui/src/log.js +1 -1
  13. package/lib/grid/src/grid.js +104 -29
  14. package/lib/grid/src/grid.min.js +1 -1
  15. package/lib/index.umd.js +465 -139
  16. package/lib/index.umd.min.js +1 -1
  17. package/lib/style.css +1 -1
  18. package/lib/table/module/custom/mixin.js +37 -13
  19. package/lib/table/module/custom/mixin.min.js +1 -1
  20. package/lib/table/module/custom/panel.js +1 -1
  21. package/lib/table/module/custom/panel.min.js +1 -1
  22. package/lib/table/module/edit/mixin.js +5 -0
  23. package/lib/table/module/edit/mixin.min.js +1 -1
  24. package/lib/table/src/body.js +7 -6
  25. package/lib/table/src/body.min.js +1 -1
  26. package/lib/table/src/columnInfo.js +5 -0
  27. package/lib/table/src/columnInfo.min.js +1 -1
  28. package/lib/table/src/methods.js +273 -82
  29. package/lib/table/src/methods.min.js +1 -1
  30. package/lib/table/src/table.js +21 -8
  31. package/lib/table/src/table.min.js +1 -1
  32. package/lib/table/src/util.js +10 -0
  33. package/lib/table/src/util.min.js +1 -1
  34. package/lib/ui/index.js +3 -1
  35. package/lib/ui/index.min.js +1 -1
  36. package/lib/ui/src/log.js +1 -1
  37. package/lib/ui/src/log.min.js +1 -1
  38. package/package.json +2 -2
  39. package/packages/grid/src/grid.ts +101 -25
  40. package/packages/table/module/custom/mixin.ts +32 -13
  41. package/packages/table/module/custom/panel.ts +1 -1
  42. package/packages/table/module/edit/mixin.ts +5 -5
  43. package/packages/table/src/body.ts +7 -6
  44. package/packages/table/src/columnInfo.ts +7 -0
  45. package/packages/table/src/methods.ts +237 -85
  46. package/packages/table/src/props.ts +1 -1
  47. package/packages/table/src/table.ts +18 -9
  48. package/packages/table/src/util.ts +10 -0
  49. package/packages/ui/index.ts +2 -0
  50. /package/es/{iconfont.1753497303145.ttf → iconfont.1754358049869.ttf} +0 -0
  51. /package/es/{iconfont.1753497303145.woff → iconfont.1754358049869.woff} +0 -0
  52. /package/es/{iconfont.1753497303145.woff2 → iconfont.1754358049869.woff2} +0 -0
  53. /package/lib/{iconfont.1753497303145.ttf → iconfont.1754358049869.ttf} +0 -0
  54. /package/lib/{iconfont.1753497303145.woff → iconfont.1754358049869.woff} +0 -0
  55. /package/lib/{iconfont.1753497303145.woff2 → iconfont.1754358049869.woff2} +0 -0
@@ -3,7 +3,7 @@ import { getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTarge
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, clearTableAllStatus, toFilters, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getRefElem, getCellRestHeight } from './util';
6
+ import { getRowUniqueId, clearTableAllStatus, getColumnList, toFilters, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getRefElem, getCellRestHeight } from './util';
7
7
  import { getSlotVNs } from '../../ui/src/vn';
8
8
  import { moveRowAnimateToTb, clearRowAnimate, moveColAnimateToLr, clearColAnimate } from './anime';
9
9
  import { warnLog, errLog } from '../../ui/src/log';
@@ -115,37 +115,91 @@ function handleVirtualXVisible($xeTable) {
115
115
  return { toVisibleIndex: 0, visibleSize: 6 };
116
116
  }
117
117
  function handleCustomRestore($xeTable, storeData) {
118
+ const props = $xeTable;
118
119
  const reactData = $xeTable;
119
120
  const internalData = $xeTable;
120
- let { collectColumn } = internalData;
121
- const { resizableData, sortData, visibleData, fixedData } = storeData;
122
- let hasCustomSort = false;
121
+ const { aggregateConfig, rowGroupConfig } = props;
122
+ const { collectColumn } = internalData;
123
+ const customOpts = $xeTable.computeCustomOpts;
124
+ const { storage, storeOptions } = customOpts;
125
+ const isAllCustom = storage === true;
126
+ const storageOpts = isAllCustom ? {} : Object.assign({}, storage || {}, storeOptions);
127
+ const isCustomResizable = hangleStorageDefaultValue(storageOpts.resizable, isAllCustom);
128
+ const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom);
129
+ const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom);
130
+ const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom);
131
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom);
132
+ const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom);
133
+ let { resizableData, sortData, visibleData, fixedData, aggGroupData, aggFuncData } = storeData;
123
134
  // 处理还原
124
- if (resizableData || sortData || visibleData || fixedData) {
135
+ if ((isCustomResizable && resizableData) || (isCustomSort && sortData) || (isCustomVisible && visibleData) || (isCustomFixed && fixedData) || (isCustomAggGroup && aggGroupData) || (isCustomAggFunc && aggFuncData)) {
136
+ const sortColMaps = {};
137
+ if (isCustomSort && sortData) {
138
+ // 转换兼容老版本数据,即将废弃兼容
139
+ if (!XEUtils.isArray(sortData)) {
140
+ const sortRests = [];
141
+ XEUtils.each(sortData, (index, colKey) => {
142
+ sortRests.push({ key: colKey, index });
143
+ });
144
+ sortData = XEUtils.orderBy(sortRests, { field: 'index', order: 'asc' }).map(item => ({ k: item.key }));
145
+ }
146
+ let colNum = 1;
147
+ XEUtils.eachTree(sortData, (sObj, index, sOjs, path, pSObj) => {
148
+ sortColMaps[sObj.k] = {
149
+ key: sObj.k,
150
+ sNum: colNum++,
151
+ pKey: pSObj ? pSObj.k : null
152
+ };
153
+ }, { children: 'c' });
154
+ }
155
+ const colKeyMaps = {};
156
+ const allCols = [];
157
+ const aggGroupConfs = [];
125
158
  XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
126
159
  const colKey = column.getKey();
127
160
  // 支持一级
128
161
  if (!parentColumn) {
129
- if (fixedData && fixedData[colKey] !== undefined) {
162
+ if (isCustomFixed && fixedData && fixedData[colKey] !== undefined) {
130
163
  column.fixed = fixedData[colKey];
131
164
  }
132
- if (sortData && XEUtils.isNumber(sortData[colKey])) {
133
- hasCustomSort = true;
134
- column.renderSortNumber = sortData[colKey];
135
- }
136
165
  }
137
- if (resizableData && XEUtils.isNumber(resizableData[colKey])) {
166
+ if (isCustomResizable && resizableData && XEUtils.isNumber(resizableData[colKey])) {
138
167
  column.resizeWidth = resizableData[colKey];
139
168
  }
140
- if (visibleData && XEUtils.isBoolean(visibleData[colKey])) {
169
+ if (isCustomVisible && visibleData && XEUtils.isBoolean(visibleData[colKey])) {
141
170
  column.visible = visibleData[colKey];
142
171
  }
172
+ if (isCustomAggFunc && aggFuncData && (aggregateConfig || rowGroupConfig) && aggFuncData[colKey]) {
173
+ column.aggFunc = aggFuncData[colKey];
174
+ }
175
+ if (isCustomAggGroup && aggGroupData && aggGroupData[colKey]) {
176
+ aggGroupConfs.push({ field: column.field });
177
+ }
178
+ colKeyMaps[colKey] = column;
179
+ allCols.push(column);
143
180
  });
181
+ if ((aggregateConfig || rowGroupConfig) && aggGroupConfs.length) {
182
+ const groupRest = handleGroupData($xeTable, internalData.tableFullData, aggGroupConfs);
183
+ internalData.tableFullTreeData = [];
184
+ internalData.tableFullGroupData = groupRest.treeData;
185
+ reactData.isRowGroupStatus = true;
186
+ reactData.rowGroupList = aggGroupConfs;
187
+ $xeTable.cacheRowMap(false);
188
+ }
144
189
  // 如果自定义了顺序
145
- if (hasCustomSort) {
146
- collectColumn = XEUtils.orderBy(collectColumn, 'renderSortNumber');
147
- internalData.collectColumn = collectColumn;
148
- internalData.tableFullColumn = getColumnList(collectColumn);
190
+ if (isCustomSort && sortData) {
191
+ allCols.forEach(column => {
192
+ const colKey = column.getKey();
193
+ const scItem = sortColMaps[colKey];
194
+ if (scItem) {
195
+ const parentColumn = scItem.pKey ? colKeyMaps[scItem.pKey] : null;
196
+ column.parentId = parentColumn ? parentColumn.id : null;
197
+ column.renderSortNumber = scItem.sNum;
198
+ }
199
+ });
200
+ const newCollectCols = XEUtils.toArrayTree(XEUtils.orderBy(allCols, 'renderSortNumber'), { key: 'id', parentKey: 'parentId', children: 'children' });
201
+ internalData.collectColumn = newCollectCols;
202
+ internalData.tableFullColumn = getColumnList(newCollectCols);
149
203
  }
150
204
  reactData.isCustomStatus = true;
151
205
  }
@@ -197,8 +251,8 @@ function cacheColumnMap($xeTable) {
197
251
  const reactData = $xeTable;
198
252
  const internalData = $xeTable;
199
253
  const { tableFullColumn, collectColumn } = internalData;
200
- const fullColumnIdData = internalData.fullColumnIdData = {};
201
- const fullColumnFieldData = internalData.fullColumnFieldData = {};
254
+ const fullColIdData = internalData.fullColumnIdData = {};
255
+ const fullColFieldData = internalData.fullColumnFieldData = {};
202
256
  const mouseOpts = $xeTable.computeMouseOpts;
203
257
  const expandOpts = $xeTable.computeExpandOpts;
204
258
  const columnOpts = $xeTable.computeColumnOpts;
@@ -220,10 +274,10 @@ function cacheColumnMap($xeTable) {
220
274
  const { id: colid, field, fixed, type, treeNode, rowGroupNode } = column;
221
275
  const rest = { $index: -1, _index: -1, column, colid, index, items, parent: parentColumn || null, width: 0, oLeft: 0 };
222
276
  if (field) {
223
- if (fullColumnFieldData[field]) {
277
+ if (fullColFieldData[field]) {
224
278
  errLog('vxe.error.colRepet', ['field', field]);
225
279
  }
226
- fullColumnFieldData[field] = rest;
280
+ fullColFieldData[field] = rest;
227
281
  }
228
282
  else {
229
283
  if ((storage && !type) || (columnOpts.drag && (isCrossDrag || isSelfToChildDrag))) {
@@ -279,10 +333,10 @@ function cacheColumnMap($xeTable) {
279
333
  if (isAllOverflow && column.showOverflow === false) {
280
334
  isAllOverflow = false;
281
335
  }
282
- if (fullColumnIdData[colid]) {
336
+ if (fullColIdData[colid]) {
283
337
  errLog('vxe.error.colRepet', ['colId', colid]);
284
338
  }
285
- fullColumnIdData[colid] = rest;
339
+ fullColIdData[colid] = rest;
286
340
  };
287
341
  if (isGroup) {
288
342
  XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn, nodes) => {
@@ -298,10 +352,10 @@ function cacheColumnMap($xeTable) {
298
352
  }
299
353
  if (htmlColumn) {
300
354
  if (!columnOpts.useKey) {
301
- errLog('vxe.error.reqProp', ['column-config.useKey & column.type=html']);
355
+ errLog('vxe.error.notSupportProp', ['column.type=html', 'column-config.useKey=false', 'column-config.useKey=true']);
302
356
  }
303
357
  if (!rowOpts.useKey) {
304
- errLog('vxe.error.reqProp', ['row-config.useKey & column.type=html']);
358
+ errLog('vxe.error.notSupportProp', ['column.type=html', 'row-config.useKey=false', 'row-config.useKey=true']);
305
359
  }
306
360
  }
307
361
  reactData.isGroup = isGroup;
@@ -535,7 +589,7 @@ function updateAfterListIndex($xeTable) {
535
589
  rowRest._index = index;
536
590
  }
537
591
  else {
538
- const rest = { row, rowid, seq, index: -1, $index: -1, _index: index, treeIndex: -1, items: [], parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 };
592
+ const rest = { row, rowid, seq, index: -1, $index: -1, _index: index, treeIndex: -1, _tIndex: -1, items: [], parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 };
539
593
  fullAllDataRowIdData[rowid] = rest;
540
594
  fullDataRowIdData[rowid] = rest;
541
595
  }
@@ -557,6 +611,7 @@ function updateAfterDataIndex($xeTable) {
557
611
  const childrenField = treeOpts.children || treeOpts.childrenField;
558
612
  const fullMaps = {};
559
613
  if (treeConfig) {
614
+ let _treeIndex = 0;
560
615
  const { handleGetRowId } = createHandleGetRowId($xeTable);
561
616
  XEUtils.eachTree(afterTreeFullData, (row, index, items, path) => {
562
617
  const rowid = handleGetRowId(row);
@@ -565,12 +620,14 @@ function updateAfterDataIndex($xeTable) {
565
620
  if (rowRest) {
566
621
  rowRest.seq = seq;
567
622
  rowRest.treeIndex = index;
623
+ rowRest._tIndex = _treeIndex;
568
624
  }
569
625
  else {
570
- const rest = { row, rowid, seq, index: -1, $index: -1, _index: -1, treeIndex: -1, items: [], parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 };
626
+ const rest = { row, rowid, seq, index: -1, $index: -1, _index: -1, treeIndex: -1, _tIndex: _treeIndex, items: [], parent: null, level: 0, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 };
571
627
  fullAllDataRowIdData[rowid] = rest;
572
628
  fullDataRowIdData[rowid] = rest;
573
629
  }
630
+ _treeIndex++;
574
631
  fullMaps[rowid] = row;
575
632
  }, { children: transform ? treeOpts.mapChildrenField : childrenField });
576
633
  if (transform) {
@@ -1981,16 +2038,24 @@ function removeFooterMerges($xeTable, merges) {
1981
2038
  return rest;
1982
2039
  }
1983
2040
  function handleSortEvent($xeTable, evnt, sortConfs, isUpdate) {
2041
+ const internalData = $xeTable;
2042
+ const { tableFullColumn } = internalData;
1984
2043
  const sortOpts = $xeTable.computeSortOpts;
1985
2044
  const { multiple, remote, orders } = sortOpts;
1986
2045
  if (!XEUtils.isArray(sortConfs)) {
1987
2046
  sortConfs = [sortConfs];
1988
2047
  }
1989
2048
  if (sortConfs && sortConfs.length) {
2049
+ const orderActiveMaps = {};
1990
2050
  if (!multiple) {
1991
2051
  sortConfs = [sortConfs[0]];
1992
- clearAllSort($xeTable);
2052
+ tableFullColumn.forEach((column) => {
2053
+ if (column.order) {
2054
+ orderActiveMaps[column.id] = column;
2055
+ }
2056
+ });
1993
2057
  }
2058
+ const sortColMpps = {};
1994
2059
  let firstColumn = null;
1995
2060
  sortConfs.forEach((confs, index) => {
1996
2061
  let { field, order } = confs;
@@ -2009,8 +2074,16 @@ function handleSortEvent($xeTable, evnt, sortConfs, isUpdate) {
2009
2074
  column.order = order;
2010
2075
  }
2011
2076
  column.sortTime = Date.now() + index;
2077
+ sortColMpps[column.id] = column;
2012
2078
  }
2013
2079
  });
2080
+ if (!multiple) {
2081
+ XEUtils.each(orderActiveMaps, (oaCol, oaId) => {
2082
+ if (!sortColMpps[oaId]) {
2083
+ oaCol.order = null;
2084
+ }
2085
+ });
2086
+ }
2014
2087
  if (isUpdate) {
2015
2088
  if (!remote) {
2016
2089
  $xeTable.handleTableData(true);
@@ -2192,7 +2265,7 @@ const calcCellHeight = ($xeTable) => {
2192
2265
  const { fullAllDataRowIdData } = internalData;
2193
2266
  const defaultRowHeight = $xeTable.computeDefaultRowHeight;
2194
2267
  const el = $xeTable.$refs.refElem;
2195
- if (!isAllOverflow && scrollYLoad && el) {
2268
+ if (!isAllOverflow && (scrollYLoad || scrollXLoad) && el) {
2196
2269
  const { handleGetRowId } = createHandleGetRowId($xeTable);
2197
2270
  tableData.forEach(row => {
2198
2271
  const rowid = handleGetRowId(row);
@@ -2680,18 +2753,18 @@ function handleUpdateAggValues($xeTable) {
2680
2753
  }
2681
2754
  function handleUpdateRowGroup($xeTable, groupFields) {
2682
2755
  const reactData = $xeTable;
2683
- const aggFields = [];
2684
- const aggConfs = [];
2756
+ const aggGroupFields = [];
2757
+ const aggGroupConfs = [];
2685
2758
  if (groupFields) {
2686
2759
  (XEUtils.isArray(groupFields) ? groupFields : [groupFields]).forEach(field => {
2687
- aggFields.push(field);
2688
- aggConfs.push({
2760
+ aggGroupFields.push(field);
2761
+ aggGroupConfs.push({
2689
2762
  field
2690
2763
  });
2691
2764
  });
2692
2765
  }
2693
- reactData.rowGroupList = aggConfs;
2694
- reactData.aggHandleFields = aggFields;
2766
+ reactData.rowGroupList = aggGroupConfs;
2767
+ reactData.aggHandleFields = aggGroupFields;
2695
2768
  handleUpdateAggValues($xeTable);
2696
2769
  }
2697
2770
  function handleeGroupSummary($xeTable, aggList) {
@@ -3065,14 +3138,6 @@ function loadScrollXData($xeTable) {
3065
3138
  }
3066
3139
  $xeTable.closeTooltip();
3067
3140
  }
3068
- // 获取所有的列,排除分组
3069
- function getColumnList(columns) {
3070
- const result = [];
3071
- columns.forEach((column) => {
3072
- result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]));
3073
- });
3074
- return result;
3075
- }
3076
3141
  function parseColumns($xeTable, isReset) {
3077
3142
  const props = $xeTable;
3078
3143
  const reactData = $xeTable;
@@ -3095,7 +3160,7 @@ function parseColumns($xeTable, isReset) {
3095
3160
  if (parentColumn && parentColumn.fixed) {
3096
3161
  column.fixed = parentColumn.fixed;
3097
3162
  }
3098
- if (parentColumn && column.fixed !== parentColumn.fixed) {
3163
+ if (parentColumn && (column.fixed || '') !== (parentColumn.fixed || '')) {
3099
3164
  errLog('vxe.error.groupFixed');
3100
3165
  }
3101
3166
  if (isColGroup) {
@@ -3205,16 +3270,33 @@ function parseColumns($xeTable, isReset) {
3205
3270
  }
3206
3271
  return $xeTable.updateFooter();
3207
3272
  }
3208
- function initColumnSort($xeTable) {
3273
+ function initColumnHierarchy($xeTable) {
3209
3274
  const internalData = $xeTable;
3210
3275
  const { collectColumn } = internalData;
3211
- collectColumn.forEach((column, index) => {
3212
- const sortIndex = index + 1;
3276
+ const fullColIdData = {};
3277
+ const fullColFieldData = {};
3278
+ let sortIndex = 1;
3279
+ XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
3280
+ const { id: colid, field } = column;
3281
+ const parentId = parentColumn ? parentColumn.id : null;
3282
+ const rest = { $index: -1, _index: -1, column, colid, index, items, parent: parentColumn || null, width: 0, oLeft: 0 };
3283
+ column.parentId = parentId;
3284
+ column.defaultParentId = parentId;
3213
3285
  column.sortNumber = sortIndex;
3214
3286
  column.renderSortNumber = sortIndex;
3287
+ sortIndex++;
3288
+ if (field) {
3289
+ if (fullColFieldData[field]) {
3290
+ errLog('vxe.error.colRepet', ['field', field]);
3291
+ }
3292
+ fullColFieldData[field] = rest;
3293
+ }
3294
+ fullColIdData[colid] = rest;
3215
3295
  });
3296
+ internalData.fullColumnIdData = fullColIdData;
3297
+ internalData.fullColumnFieldData = fullColFieldData;
3216
3298
  }
3217
- function handleColumn($xeTable, collectColumn) {
3299
+ function handleInitColumn($xeTable, collectColumn) {
3218
3300
  const $xeToolbar = $xeTable.$refs.$xeToolbar;
3219
3301
  const reactData = $xeTable;
3220
3302
  const internalData = $xeTable;
@@ -3223,7 +3305,7 @@ function handleColumn($xeTable, collectColumn) {
3223
3305
  const tableFullColumn = getColumnList(collectColumn);
3224
3306
  internalData.tableFullColumn = tableFullColumn;
3225
3307
  reactData.isColLoading = true;
3226
- initColumnSort($xeTable);
3308
+ initColumnHierarchy($xeTable);
3227
3309
  return Promise.resolve(restoreCustomStorage($xeTable)).then(() => {
3228
3310
  const { scrollXLoad, scrollYLoad, expandColumn } = reactData;
3229
3311
  cacheColumnMap($xeTable);
@@ -3863,7 +3945,7 @@ const Methods = {
3863
3945
  const internalData = $xeTable;
3864
3946
  const { lastScrollLeft, lastScrollTop } = internalData;
3865
3947
  const collectColumn = XEUtils.mapTree(columns, column => Cell.createColumn($xeTable, column), { children: 'children' });
3866
- return handleColumn($xeTable, collectColumn).then(() => {
3948
+ return handleInitColumn($xeTable, collectColumn).then(() => {
3867
3949
  let targetScrollLeft = lastScrollLeft;
3868
3950
  let targetScrollTop = lastScrollTop;
3869
3951
  const virtualXOpts = $xeTable.computeVirtualXOpts;
@@ -3888,9 +3970,9 @@ const Methods = {
3888
3970
  return this.loadColumn(columns);
3889
3971
  });
3890
3972
  },
3891
- handleColumn(collectColumn) {
3973
+ handleInitColumn(collectColumn) {
3892
3974
  const $xeTable = this;
3893
- return handleColumn($xeTable, collectColumn);
3975
+ return handleInitColumn($xeTable, collectColumn);
3894
3976
  },
3895
3977
  /**
3896
3978
  * 更新数据行的 Map
@@ -3909,7 +3991,7 @@ const Methods = {
3909
3991
  const handleRowCache = (row, index, items, currIndex, parentRow, rowid, level, seq) => {
3910
3992
  let rowRest = fullAllDataRowIdMaps[rowid];
3911
3993
  if (!rowRest) {
3912
- rowRest = { row, rowid, seq, index: -1, _index: -1, $index: -1, treeIndex: index, items, parent: parentRow, level, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 };
3994
+ rowRest = { row, rowid, seq, index: -1, _index: -1, $index: -1, treeIndex: index, _tIndex: -1, items, parent: parentRow, level, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 };
3913
3995
  }
3914
3996
  rowRest.treeLoaded = false;
3915
3997
  rowRest.expandLoaded = false;
@@ -4014,7 +4096,7 @@ const Methods = {
4014
4096
  XEUtils.eachTree(rows, (childRow, index, items, path, parentItem, nodes) => {
4015
4097
  const rowid = getRowid($xeTable, childRow);
4016
4098
  const parentRow = parentItem || parentRest.row;
4017
- const rest = { row: childRow, rowid, seq: -1, index, _index: -1, $index: -1, treeIndex: -1, items, parent: parentRow, level: parentLevel + nodes.length, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 };
4099
+ const rest = { row: childRow, rowid, seq: -1, index, _index: -1, $index: -1, treeIndex: -1, _tIndex: -1, items, parent: parentRow, level: parentLevel + nodes.length, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 };
4018
4100
  fullDataRowIdData[rowid] = rest;
4019
4101
  fullAllDataRowIdData[rowid] = rest;
4020
4102
  }, { children: childrenField });
@@ -5006,8 +5088,9 @@ const Methods = {
5006
5088
  const isCustomResizable = hangleStorageDefaultValue(storageOpts.resizable, isAllCustom);
5007
5089
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom);
5008
5090
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom);
5091
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom);
5009
5092
  const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom);
5010
- if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort)) {
5093
+ if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomAggGroup || isCustomSort)) {
5011
5094
  if (!tableId) {
5012
5095
  errLog('vxe.error.reqProp', ['id']);
5013
5096
  return;
@@ -5029,10 +5112,12 @@ const Methods = {
5029
5112
  getCustomStoreData() {
5030
5113
  const $xeTable = this;
5031
5114
  const props = $xeTable;
5115
+ const reactData = $xeTable;
5032
5116
  const internalData = $xeTable;
5033
5117
  const { id } = props;
5034
5118
  const customOpts = $xeTable.computeCustomOpts;
5035
- const { collectColumn } = internalData;
5119
+ const { isRowGroupStatus, rowGroupList } = reactData;
5120
+ const { fullColumnFieldData, collectColumn } = internalData;
5036
5121
  const { storage, checkMethod, storeOptions } = customOpts;
5037
5122
  const isAllCustom = storage === true;
5038
5123
  const storageOpts = isAllCustom ? {} : Object.assign({}, storage || {}, storeOptions);
@@ -5040,17 +5125,20 @@ const Methods = {
5040
5125
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom);
5041
5126
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom);
5042
5127
  const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom);
5128
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom);
5043
5129
  const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom);
5044
5130
  const resizableData = {};
5045
- const sortData = {};
5131
+ const sortData = [];
5046
5132
  const visibleData = {};
5047
5133
  const fixedData = {};
5134
+ const aggGroupData = {};
5048
5135
  const aggFuncData = {};
5049
5136
  const storeData = {
5050
5137
  resizableData: undefined,
5051
5138
  sortData: undefined,
5052
5139
  visibleData: undefined,
5053
5140
  fixedData: undefined,
5141
+ aggGroupData: undefined,
5054
5142
  aggFuncData: undefined
5055
5143
  };
5056
5144
  if (!id) {
@@ -5064,19 +5152,37 @@ const Methods = {
5064
5152
  let hasFixed = 0;
5065
5153
  let hasVisible = 0;
5066
5154
  let hasAggFunc = 0;
5155
+ const sortMaps = {};
5067
5156
  XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
5068
5157
  const colKey = column.getKey();
5069
5158
  if (!colKey) {
5070
5159
  errLog('vxe.error.reqProp', [`${column.getTitle() || column.type || ''} -> column.field=?`]);
5071
5160
  return;
5072
5161
  }
5073
- // 只支持一级
5074
- if (!parentColumn) {
5162
+ if (parentColumn) {
5163
+ if (isCustomSort) {
5164
+ const pColKey = parentColumn.getKey();
5165
+ const psObj = sortMaps[pColKey];
5166
+ hasSort = 1;
5167
+ if (psObj) {
5168
+ const sObj = { k: colKey };
5169
+ sortMaps[colKey] = sObj;
5170
+ if (!psObj.c) {
5171
+ psObj.c = [];
5172
+ }
5173
+ psObj.c.push(sObj);
5174
+ }
5175
+ }
5176
+ }
5177
+ else {
5075
5178
  if (isCustomSort) {
5076
5179
  hasSort = 1;
5077
- sortData[colKey] = column.renderSortNumber;
5180
+ const sObj = { k: colKey };
5181
+ sortMaps[colKey] = sObj;
5182
+ sortData.push(sObj);
5078
5183
  }
5079
- if (isCustomFixed && column.fixed !== column.defaultFixed) {
5184
+ // 只支持一级
5185
+ if (isCustomFixed && (column.fixed || '') !== (column.defaultFixed || '')) {
5080
5186
  hasFixed = 1;
5081
5187
  fixedData[colKey] = column.fixed;
5082
5188
  }
@@ -5095,7 +5201,7 @@ const Methods = {
5095
5201
  visibleData[colKey] = true;
5096
5202
  }
5097
5203
  }
5098
- if (isCustomAggFunc && column.aggFunc !== column.defaultAggFunc) {
5204
+ if (isCustomAggFunc && (column.aggFunc || '') !== (column.defaultAggFunc || '')) {
5099
5205
  hasAggFunc = 1;
5100
5206
  aggFuncData[colKey] = column.aggFunc;
5101
5207
  }
@@ -5112,6 +5218,15 @@ const Methods = {
5112
5218
  if (hasVisible) {
5113
5219
  storeData.visibleData = visibleData;
5114
5220
  }
5221
+ if (isCustomAggGroup && isRowGroupStatus) {
5222
+ rowGroupList.forEach(aggConf => {
5223
+ const colRest = fullColumnFieldData[aggConf.field];
5224
+ if (colRest) {
5225
+ aggGroupData[colRest.column.getKey()] = true;
5226
+ }
5227
+ });
5228
+ storeData.aggGroupData = aggGroupData;
5229
+ }
5115
5230
  if (hasAggFunc) {
5116
5231
  storeData.aggFuncData = aggFuncData;
5117
5232
  }
@@ -5131,11 +5246,12 @@ const Methods = {
5131
5246
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom);
5132
5247
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom);
5133
5248
  const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom);
5249
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom);
5134
5250
  const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom);
5135
5251
  if (type !== 'reset') {
5136
5252
  reactData.isCustomStatus = true;
5137
5253
  }
5138
- if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort || isCustomAggFunc)) {
5254
+ if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort || isCustomAggGroup || isCustomAggFunc)) {
5139
5255
  if (!tableId) {
5140
5256
  errLog('vxe.error.reqProp', ['id']);
5141
5257
  return this.$nextTick();
@@ -5145,7 +5261,9 @@ const Methods = {
5145
5261
  resizableData: {},
5146
5262
  sortData: {},
5147
5263
  visibleData: {},
5148
- fixedData: {}
5264
+ fixedData: {},
5265
+ aggGroupData: {},
5266
+ aggFuncData: {}
5149
5267
  }
5150
5268
  : this.getCustomStoreData();
5151
5269
  if (updateStore) {
@@ -8722,9 +8840,9 @@ const Methods = {
8722
8840
  const $xeTable = this;
8723
8841
  return handleSortEvent($xeTable, null, sortConfs, isUpdate);
8724
8842
  },
8725
- setSortByEvent(evnt, sortConfs, isUpdate) {
8843
+ setSortByEvent(evnt, sortConfs) {
8726
8844
  const $xeTable = this;
8727
- return handleSortEvent($xeTable, evnt, sortConfs, isUpdate);
8845
+ return handleSortEvent($xeTable, evnt, sortConfs, true);
8728
8846
  },
8729
8847
  /**
8730
8848
  * 清空指定列的排序条件
@@ -8756,6 +8874,7 @@ const Methods = {
8756
8874
  const internalData = $xeTable;
8757
8875
  const { tableFullColumn } = internalData;
8758
8876
  const sortOpts = $xeTable.computeSortOpts;
8877
+ const { multiple } = sortOpts;
8759
8878
  const sortCols = [];
8760
8879
  let column = null;
8761
8880
  if (evnt) {
@@ -8776,13 +8895,16 @@ const Methods = {
8776
8895
  if (!sortOpts.remote) {
8777
8896
  $xeTable.handleTableData(true);
8778
8897
  }
8779
- if (sortCols.length) {
8780
- const params = { $table: $xeTable, $event: evnt, cols: sortCols, sortList: [] };
8781
- $xeTable.dispatchEvent('clear-all-sort', params, evnt);
8898
+ if (!multiple) {
8899
+ column = sortCols[0];
8782
8900
  }
8783
- else if (column) {
8901
+ if (column) {
8784
8902
  $xeTable.handleColumnSortEvent(evnt, column);
8785
8903
  }
8904
+ if (multiple && sortCols.length) {
8905
+ const params = { $table: $xeTable, $event: evnt, cols: sortCols, sortList: [] };
8906
+ $xeTable.dispatchEvent('clear-all-sort', params, evnt);
8907
+ }
8786
8908
  }
8787
8909
  return $xeTable.$nextTick().then(() => {
8788
8910
  updateRowOffsetTop($xeTable);
@@ -8815,21 +8937,12 @@ const Methods = {
8815
8937
  }
8816
8938
  return sortList;
8817
8939
  },
8818
- setFilterByEvent(evnt, fieldOrColumn, options, isUpdate) {
8940
+ setFilterByEvent(evnt, fieldOrColumn, options) {
8819
8941
  const $xeTable = this;
8820
- const reactData = $xeTable;
8821
- const { filterStore } = reactData;
8822
8942
  const column = handleFieldOrColumn($xeTable, fieldOrColumn);
8823
8943
  if (column && column.filters) {
8824
8944
  column.filters = toFilters(options || []);
8825
- if (isUpdate) {
8826
- return $xeTable.handleColumnConfirmFilter(column, evnt);
8827
- }
8828
- else {
8829
- if (filterStore.visible) {
8830
- $xeTable.handleFilterOptions(column);
8831
- }
8832
- }
8945
+ return $xeTable.handleColumnConfirmFilter(column, evnt);
8833
8946
  }
8834
8947
  return $xeTable.$nextTick();
8835
8948
  },
@@ -8879,6 +8992,7 @@ const Methods = {
8879
8992
  const { filterStore } = reactData;
8880
8993
  const { tableFullColumn } = internalData;
8881
8994
  const filterOpts = $xeTable.computeFilterOpts;
8995
+ const { multiple } = filterOpts;
8882
8996
  const filterCols = [];
8883
8997
  let column = null;
8884
8998
  if (fieldOrColumn) {
@@ -8909,13 +9023,37 @@ const Methods = {
8909
9023
  if (!filterOpts.remote) {
8910
9024
  $xeTable.updateData();
8911
9025
  }
8912
- if (filterCols.length) {
9026
+ if (!multiple) {
9027
+ column = filterCols[0];
9028
+ }
9029
+ if (column) {
9030
+ const filterList = () => $xeTable.getCheckedFilters();
9031
+ const values = [];
9032
+ const datas = [];
9033
+ column.filters.forEach((item) => {
9034
+ if (item.checked) {
9035
+ values.push(item.value);
9036
+ datas.push(item.data);
9037
+ }
9038
+ });
9039
+ const params = {
9040
+ $table: $xeTable,
9041
+ $event: evnt,
9042
+ column,
9043
+ field: column.field,
9044
+ property: column.field,
9045
+ values,
9046
+ datas,
9047
+ filters: filterList,
9048
+ filterList
9049
+ };
9050
+ $xeTable.dispatchEvent('filter-change', params, evnt);
9051
+ $xeTable.dispatchEvent('clear-filter', params, evnt);
9052
+ }
9053
+ if (multiple && filterCols.length) {
8913
9054
  const params = { $table: $xeTable, $event: evnt, cols: filterCols, filterList: [] };
8914
9055
  $xeTable.dispatchEvent('clear-all-filter', params, evnt);
8915
9056
  }
8916
- else if (column) {
8917
- $xeTable.dispatchEvent('clear-filter', { filterList: () => $xeTable.getCheckedFilters() }, evnt);
8918
- }
8919
9057
  return $xeTable.$nextTick();
8920
9058
  },
8921
9059
  /**
@@ -10672,7 +10810,7 @@ const Methods = {
10672
10810
  }
10673
10811
  };
10674
10812
  // Module methods
10675
- const funcs = 'setFilter,openFilter,clearFilter,saveFilterPanel,saveFilterPanelByEvent,resetFilterPanel,resetFilterPanelByEvent,getCheckedFilters,updateFilterOptionStatus,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,getCopyCellAreas,clearCopyCellArea,setCellAreas,openFNR,openFind,openReplace,closeFNR,getSelectedCell,clearSelected,insert,insertAt,insertNextAt,insertChild,insertChildAt,insertChildNextAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearEdit,clearActived,getEditRecord,getEditCell,getActiveRecord,isEditByRow,isActiveByRow,setEditRow,setActiveRow,setEditCell,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,fullValidateField,validateField,openExport,closeExport,openPrint,closePrint,getPrintHtml,exportData,openImport,closeImport,importData,saveFile,readFile,importByFile,print,openCustom,closeCustom,toggleCustom,saveCustom,cancelCustom,resetCustom,toggleCustomAllCheckbox,setCustomAllCheckbox'.split(',');
10813
+ const funcs = 'setFilter,openFilter,clearFilter,saveFilterPanel,saveFilterPanelByEvent,resetFilterPanel,resetFilterPanelByEvent,getCheckedFilters,updateFilterOptionStatus,closeMenu,setActiveCellArea,getActiveCellArea,getCellAreas,clearCellAreas,copyCellArea,cutCellArea,pasteCellArea,getCopyCellArea,getCopyCellAreas,clearCopyCellArea,setCellAreas,openFNR,openFind,openReplace,closeFNR,getSelectedCell,clearSelected,insert,insertAt,insertNextAt,insertChild,insertChildAt,insertChildNextAt,remove,removeCheckboxRow,removeRadioRow,removeCurrentRow,getRecordset,getInsertRecords,getRemoveRecords,getUpdateRecords,clearEdit,clearActived,getEditRecord,getEditCell,getActiveRecord,isEditByRow,isActiveByRow,setEditRow,setActiveRow,setEditCell,setActiveCell,setSelectCell,clearValidate,fullValidate,validate,fullValidateField,validateField,openExport,closeExport,openPrint,closePrint,getPrintHtml,exportData,openImport,closeImport,importData,saveFile,readFile,importByFile,print,getCustomVisible,openCustom,closeCustom,toggleCustom,saveCustom,cancelCustom,resetCustom,toggleCustomAllCheckbox,setCustomAllCheckbox'.split(',');
10676
10814
  funcs.forEach(name => {
10677
10815
  Methods[name] = function (...args) {
10678
10816
  if (!this[`_${name}`]) {