vxe-table 3.17.0-beta.9 → 3.17.0

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 (51) 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 +22 -14
  4. package/es/table/module/edit/mixin.js +5 -5
  5. package/es/table/src/body.js +7 -6
  6. package/es/table/src/columnInfo.js +5 -0
  7. package/es/table/src/methods.js +201 -76
  8. package/es/table/src/table.js +7 -6
  9. package/es/table/src/util.js +9 -0
  10. package/es/ui/index.js +2 -1
  11. package/es/ui/src/log.js +1 -1
  12. package/lib/grid/src/grid.js +104 -29
  13. package/lib/grid/src/grid.min.js +1 -1
  14. package/lib/index.umd.js +402 -127
  15. package/lib/index.umd.min.js +1 -1
  16. package/lib/style.css +1 -1
  17. package/lib/table/module/custom/mixin.js +25 -13
  18. package/lib/table/module/custom/mixin.min.js +1 -1
  19. package/lib/table/module/edit/mixin.js +5 -0
  20. package/lib/table/module/edit/mixin.min.js +1 -1
  21. package/lib/table/src/body.js +7 -6
  22. package/lib/table/src/body.min.js +1 -1
  23. package/lib/table/src/columnInfo.js +5 -0
  24. package/lib/table/src/columnInfo.min.js +1 -1
  25. package/lib/table/src/methods.js +238 -73
  26. package/lib/table/src/methods.min.js +1 -1
  27. package/lib/table/src/table.js +7 -6
  28. package/lib/table/src/table.min.js +1 -1
  29. package/lib/table/src/util.js +10 -0
  30. package/lib/table/src/util.min.js +1 -1
  31. package/lib/ui/index.js +2 -1
  32. package/lib/ui/index.min.js +1 -1
  33. package/lib/ui/src/log.js +1 -1
  34. package/lib/ui/src/log.min.js +1 -1
  35. package/package.json +2 -2
  36. package/packages/grid/src/grid.ts +101 -25
  37. package/packages/table/module/custom/mixin.ts +21 -13
  38. package/packages/table/module/edit/mixin.ts +5 -5
  39. package/packages/table/src/body.ts +7 -6
  40. package/packages/table/src/columnInfo.ts +7 -0
  41. package/packages/table/src/methods.ts +215 -76
  42. package/packages/table/src/props.ts +1 -1
  43. package/packages/table/src/table.ts +7 -6
  44. package/packages/table/src/util.ts +10 -0
  45. package/packages/ui/index.ts +1 -0
  46. /package/es/{iconfont.1753497303145.ttf → iconfont.1753928711953.ttf} +0 -0
  47. /package/es/{iconfont.1753497303145.woff → iconfont.1753928711953.woff} +0 -0
  48. /package/es/{iconfont.1753497303145.woff2 → iconfont.1753928711953.woff2} +0 -0
  49. /package/lib/{iconfont.1753497303145.ttf → iconfont.1753928711953.ttf} +0 -0
  50. /package/lib/{iconfont.1753497303145.woff → iconfont.1753928711953.woff} +0 -0
  51. /package/lib/{iconfont.1753497303145.woff2 → iconfont.1753928711953.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
  }
@@ -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,20 @@ 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
+ let sortIndex = 1;
3277
+ XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
3278
+ const parentId = parentColumn ? parentColumn.id : null;
3279
+ column.parentId = parentId;
3280
+ column.defaultParentId = parentId;
3213
3281
  column.sortNumber = sortIndex;
3214
3282
  column.renderSortNumber = sortIndex;
3283
+ sortIndex++;
3215
3284
  });
3216
3285
  }
3217
- function handleColumn($xeTable, collectColumn) {
3286
+ function handleInitColumn($xeTable, collectColumn) {
3218
3287
  const $xeToolbar = $xeTable.$refs.$xeToolbar;
3219
3288
  const reactData = $xeTable;
3220
3289
  const internalData = $xeTable;
@@ -3223,7 +3292,7 @@ function handleColumn($xeTable, collectColumn) {
3223
3292
  const tableFullColumn = getColumnList(collectColumn);
3224
3293
  internalData.tableFullColumn = tableFullColumn;
3225
3294
  reactData.isColLoading = true;
3226
- initColumnSort($xeTable);
3295
+ initColumnHierarchy($xeTable);
3227
3296
  return Promise.resolve(restoreCustomStorage($xeTable)).then(() => {
3228
3297
  const { scrollXLoad, scrollYLoad, expandColumn } = reactData;
3229
3298
  cacheColumnMap($xeTable);
@@ -3863,7 +3932,7 @@ const Methods = {
3863
3932
  const internalData = $xeTable;
3864
3933
  const { lastScrollLeft, lastScrollTop } = internalData;
3865
3934
  const collectColumn = XEUtils.mapTree(columns, column => Cell.createColumn($xeTable, column), { children: 'children' });
3866
- return handleColumn($xeTable, collectColumn).then(() => {
3935
+ return handleInitColumn($xeTable, collectColumn).then(() => {
3867
3936
  let targetScrollLeft = lastScrollLeft;
3868
3937
  let targetScrollTop = lastScrollTop;
3869
3938
  const virtualXOpts = $xeTable.computeVirtualXOpts;
@@ -3888,9 +3957,9 @@ const Methods = {
3888
3957
  return this.loadColumn(columns);
3889
3958
  });
3890
3959
  },
3891
- handleColumn(collectColumn) {
3960
+ handleInitColumn(collectColumn) {
3892
3961
  const $xeTable = this;
3893
- return handleColumn($xeTable, collectColumn);
3962
+ return handleInitColumn($xeTable, collectColumn);
3894
3963
  },
3895
3964
  /**
3896
3965
  * 更新数据行的 Map
@@ -3909,7 +3978,7 @@ const Methods = {
3909
3978
  const handleRowCache = (row, index, items, currIndex, parentRow, rowid, level, seq) => {
3910
3979
  let rowRest = fullAllDataRowIdMaps[rowid];
3911
3980
  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 };
3981
+ 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
3982
  }
3914
3983
  rowRest.treeLoaded = false;
3915
3984
  rowRest.expandLoaded = false;
@@ -4014,7 +4083,7 @@ const Methods = {
4014
4083
  XEUtils.eachTree(rows, (childRow, index, items, path, parentItem, nodes) => {
4015
4084
  const rowid = getRowid($xeTable, childRow);
4016
4085
  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 };
4086
+ 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
4087
  fullDataRowIdData[rowid] = rest;
4019
4088
  fullAllDataRowIdData[rowid] = rest;
4020
4089
  }, { children: childrenField });
@@ -5006,8 +5075,9 @@ const Methods = {
5006
5075
  const isCustomResizable = hangleStorageDefaultValue(storageOpts.resizable, isAllCustom);
5007
5076
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom);
5008
5077
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom);
5078
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom);
5009
5079
  const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom);
5010
- if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort)) {
5080
+ if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomAggGroup || isCustomSort)) {
5011
5081
  if (!tableId) {
5012
5082
  errLog('vxe.error.reqProp', ['id']);
5013
5083
  return;
@@ -5029,10 +5099,12 @@ const Methods = {
5029
5099
  getCustomStoreData() {
5030
5100
  const $xeTable = this;
5031
5101
  const props = $xeTable;
5102
+ const reactData = $xeTable;
5032
5103
  const internalData = $xeTable;
5033
5104
  const { id } = props;
5034
5105
  const customOpts = $xeTable.computeCustomOpts;
5035
- const { collectColumn } = internalData;
5106
+ const { isRowGroupStatus, rowGroupList } = reactData;
5107
+ const { fullColumnFieldData, collectColumn } = internalData;
5036
5108
  const { storage, checkMethod, storeOptions } = customOpts;
5037
5109
  const isAllCustom = storage === true;
5038
5110
  const storageOpts = isAllCustom ? {} : Object.assign({}, storage || {}, storeOptions);
@@ -5040,17 +5112,20 @@ const Methods = {
5040
5112
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom);
5041
5113
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom);
5042
5114
  const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom);
5115
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom);
5043
5116
  const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom);
5044
5117
  const resizableData = {};
5045
- const sortData = {};
5118
+ const sortData = [];
5046
5119
  const visibleData = {};
5047
5120
  const fixedData = {};
5121
+ const aggGroupData = {};
5048
5122
  const aggFuncData = {};
5049
5123
  const storeData = {
5050
5124
  resizableData: undefined,
5051
5125
  sortData: undefined,
5052
5126
  visibleData: undefined,
5053
5127
  fixedData: undefined,
5128
+ aggGroupData: undefined,
5054
5129
  aggFuncData: undefined
5055
5130
  };
5056
5131
  if (!id) {
@@ -5064,19 +5139,37 @@ const Methods = {
5064
5139
  let hasFixed = 0;
5065
5140
  let hasVisible = 0;
5066
5141
  let hasAggFunc = 0;
5142
+ const sortMaps = {};
5067
5143
  XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
5068
5144
  const colKey = column.getKey();
5069
5145
  if (!colKey) {
5070
5146
  errLog('vxe.error.reqProp', [`${column.getTitle() || column.type || ''} -> column.field=?`]);
5071
5147
  return;
5072
5148
  }
5073
- // 只支持一级
5074
- if (!parentColumn) {
5149
+ if (parentColumn) {
5075
5150
  if (isCustomSort) {
5151
+ const pColKey = parentColumn.getKey();
5152
+ const psObj = sortMaps[pColKey];
5076
5153
  hasSort = 1;
5077
- sortData[colKey] = column.renderSortNumber;
5154
+ if (psObj) {
5155
+ const sObj = { k: colKey };
5156
+ sortMaps[colKey] = sObj;
5157
+ if (!psObj.c) {
5158
+ psObj.c = [];
5159
+ }
5160
+ psObj.c.push(sObj);
5161
+ }
5078
5162
  }
5079
- if (isCustomFixed && column.fixed !== column.defaultFixed) {
5163
+ }
5164
+ else {
5165
+ if (isCustomSort) {
5166
+ hasSort = 1;
5167
+ const sObj = { k: colKey };
5168
+ sortMaps[colKey] = sObj;
5169
+ sortData.push(sObj);
5170
+ }
5171
+ // 只支持一级
5172
+ if (isCustomFixed && (column.fixed || '') !== (column.defaultFixed || '')) {
5080
5173
  hasFixed = 1;
5081
5174
  fixedData[colKey] = column.fixed;
5082
5175
  }
@@ -5095,7 +5188,7 @@ const Methods = {
5095
5188
  visibleData[colKey] = true;
5096
5189
  }
5097
5190
  }
5098
- if (isCustomAggFunc && column.aggFunc !== column.defaultAggFunc) {
5191
+ if (isCustomAggFunc && (column.aggFunc || '') !== (column.defaultAggFunc || '')) {
5099
5192
  hasAggFunc = 1;
5100
5193
  aggFuncData[colKey] = column.aggFunc;
5101
5194
  }
@@ -5112,6 +5205,15 @@ const Methods = {
5112
5205
  if (hasVisible) {
5113
5206
  storeData.visibleData = visibleData;
5114
5207
  }
5208
+ if (isCustomAggGroup && isRowGroupStatus) {
5209
+ rowGroupList.forEach(aggConf => {
5210
+ const colRest = fullColumnFieldData[aggConf.field];
5211
+ if (colRest) {
5212
+ aggGroupData[colRest.column.getKey()] = true;
5213
+ }
5214
+ });
5215
+ storeData.aggGroupData = aggGroupData;
5216
+ }
5115
5217
  if (hasAggFunc) {
5116
5218
  storeData.aggFuncData = aggFuncData;
5117
5219
  }
@@ -5131,11 +5233,12 @@ const Methods = {
5131
5233
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom);
5132
5234
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom);
5133
5235
  const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom);
5236
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom);
5134
5237
  const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom);
5135
5238
  if (type !== 'reset') {
5136
5239
  reactData.isCustomStatus = true;
5137
5240
  }
5138
- if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort || isCustomAggFunc)) {
5241
+ if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort || isCustomAggGroup || isCustomAggFunc)) {
5139
5242
  if (!tableId) {
5140
5243
  errLog('vxe.error.reqProp', ['id']);
5141
5244
  return this.$nextTick();
@@ -5145,7 +5248,9 @@ const Methods = {
5145
5248
  resizableData: {},
5146
5249
  sortData: {},
5147
5250
  visibleData: {},
5148
- fixedData: {}
5251
+ fixedData: {},
5252
+ aggGroupData: {},
5253
+ aggFuncData: {}
5149
5254
  }
5150
5255
  : this.getCustomStoreData();
5151
5256
  if (updateStore) {
@@ -8722,9 +8827,9 @@ const Methods = {
8722
8827
  const $xeTable = this;
8723
8828
  return handleSortEvent($xeTable, null, sortConfs, isUpdate);
8724
8829
  },
8725
- setSortByEvent(evnt, sortConfs, isUpdate) {
8830
+ setSortByEvent(evnt, sortConfs) {
8726
8831
  const $xeTable = this;
8727
- return handleSortEvent($xeTable, evnt, sortConfs, isUpdate);
8832
+ return handleSortEvent($xeTable, evnt, sortConfs, true);
8728
8833
  },
8729
8834
  /**
8730
8835
  * 清空指定列的排序条件
@@ -8756,6 +8861,7 @@ const Methods = {
8756
8861
  const internalData = $xeTable;
8757
8862
  const { tableFullColumn } = internalData;
8758
8863
  const sortOpts = $xeTable.computeSortOpts;
8864
+ const { multiple } = sortOpts;
8759
8865
  const sortCols = [];
8760
8866
  let column = null;
8761
8867
  if (evnt) {
@@ -8776,13 +8882,16 @@ const Methods = {
8776
8882
  if (!sortOpts.remote) {
8777
8883
  $xeTable.handleTableData(true);
8778
8884
  }
8779
- if (sortCols.length) {
8780
- const params = { $table: $xeTable, $event: evnt, cols: sortCols, sortList: [] };
8781
- $xeTable.dispatchEvent('clear-all-sort', params, evnt);
8885
+ if (!multiple) {
8886
+ column = sortCols[0];
8782
8887
  }
8783
- else if (column) {
8888
+ if (column) {
8784
8889
  $xeTable.handleColumnSortEvent(evnt, column);
8785
8890
  }
8891
+ if (multiple && sortCols.length) {
8892
+ const params = { $table: $xeTable, $event: evnt, cols: sortCols, sortList: [] };
8893
+ $xeTable.dispatchEvent('clear-all-sort', params, evnt);
8894
+ }
8786
8895
  }
8787
8896
  return $xeTable.$nextTick().then(() => {
8788
8897
  updateRowOffsetTop($xeTable);
@@ -8815,21 +8924,12 @@ const Methods = {
8815
8924
  }
8816
8925
  return sortList;
8817
8926
  },
8818
- setFilterByEvent(evnt, fieldOrColumn, options, isUpdate) {
8927
+ setFilterByEvent(evnt, fieldOrColumn, options) {
8819
8928
  const $xeTable = this;
8820
- const reactData = $xeTable;
8821
- const { filterStore } = reactData;
8822
8929
  const column = handleFieldOrColumn($xeTable, fieldOrColumn);
8823
8930
  if (column && column.filters) {
8824
8931
  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
- }
8932
+ return $xeTable.handleColumnConfirmFilter(column, evnt);
8833
8933
  }
8834
8934
  return $xeTable.$nextTick();
8835
8935
  },
@@ -8879,6 +8979,7 @@ const Methods = {
8879
8979
  const { filterStore } = reactData;
8880
8980
  const { tableFullColumn } = internalData;
8881
8981
  const filterOpts = $xeTable.computeFilterOpts;
8982
+ const { multiple } = filterOpts;
8882
8983
  const filterCols = [];
8883
8984
  let column = null;
8884
8985
  if (fieldOrColumn) {
@@ -8909,13 +9010,37 @@ const Methods = {
8909
9010
  if (!filterOpts.remote) {
8910
9011
  $xeTable.updateData();
8911
9012
  }
8912
- if (filterCols.length) {
9013
+ if (!multiple) {
9014
+ column = filterCols[0];
9015
+ }
9016
+ if (column) {
9017
+ const filterList = () => $xeTable.getCheckedFilters();
9018
+ const values = [];
9019
+ const datas = [];
9020
+ column.filters.forEach((item) => {
9021
+ if (item.checked) {
9022
+ values.push(item.value);
9023
+ datas.push(item.data);
9024
+ }
9025
+ });
9026
+ const params = {
9027
+ $table: $xeTable,
9028
+ $event: evnt,
9029
+ column,
9030
+ field: column.field,
9031
+ property: column.field,
9032
+ values,
9033
+ datas,
9034
+ filters: filterList,
9035
+ filterList
9036
+ };
9037
+ $xeTable.dispatchEvent('filter-change', params, evnt);
9038
+ $xeTable.dispatchEvent('clear-filter', params, evnt);
9039
+ }
9040
+ if (multiple && filterCols.length) {
8913
9041
  const params = { $table: $xeTable, $event: evnt, cols: filterCols, filterList: [] };
8914
9042
  $xeTable.dispatchEvent('clear-all-filter', params, evnt);
8915
9043
  }
8916
- else if (column) {
8917
- $xeTable.dispatchEvent('clear-filter', { filterList: () => $xeTable.getCheckedFilters() }, evnt);
8918
- }
8919
9044
  return $xeTable.$nextTick();
8920
9045
  },
8921
9046
  /**
@@ -232,16 +232,17 @@ function renderRowExpandedVNs(h, $xeTable) {
232
232
  let rowIndex = -1;
233
233
  let $rowIndex = -1;
234
234
  if (rowRest) {
235
+ rowIndex = rowRest.index;
236
+ $rowIndex = rowRest.$index;
237
+ _rowIndex = rowRest._index;
235
238
  rowLevel = rowRest.level;
239
+ seq = rowRest.seq;
236
240
  if (isRowGroupStatus || (treeConfig && transform && seqMode === 'increasing')) {
237
241
  seq = rowRest._index + 1;
238
242
  }
239
- else {
240
- seq = rowRest.seq;
243
+ else if ((treeConfig && seqMode === 'fixed')) {
244
+ seq = rowRest._tIndex + 1;
241
245
  }
242
- rowIndex = rowRest.index;
243
- $rowIndex = rowRest.$index;
244
- _rowIndex = rowRest._index;
245
246
  }
246
247
  if (expandHeight) {
247
248
  cellStyle.height = `${expandHeight}px`;
@@ -1272,7 +1273,7 @@ export default {
1272
1273
  });
1273
1274
  },
1274
1275
  staticColumns(value) {
1275
- this.handleColumn(XEUtils.clone(value));
1276
+ this.$nextTick(() => this.handleInitColumn(XEUtils.clone(value)));
1276
1277
  },
1277
1278
  tableColumn() {
1278
1279
  this.analyColumnWidth();
@@ -206,6 +206,7 @@ export function assembleColumn(_vm) {
206
206
  if (!groupConfig.children) {
207
207
  groupConfig.children = [];
208
208
  }
209
+ columnConfig.defaultParentId = groupConfig.id;
209
210
  groupConfig.children.splice(XEUtils.arrayIndexOf($xeColumn.$el.children, $el), 0, columnConfig);
210
211
  }
211
212
  else {
@@ -403,6 +404,14 @@ export function clearTableAllStatus(_vm) {
403
404
  export function isColumnInfo(column) {
404
405
  return column instanceof ColumnInfo;
405
406
  }
407
+ // 获取所有的列,排除分组
408
+ export function getColumnList(columns) {
409
+ const result = [];
410
+ columns.forEach((column) => {
411
+ result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]));
412
+ });
413
+ return result;
414
+ }
406
415
  export function createColumn($xeTable, options, renderOptions) {
407
416
  return isColumnInfo(options) ? options : new ColumnInfo($xeTable, options, renderOptions);
408
417
  }
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.9";
3
+ export const version = "3.17.0";
4
4
  VxeUI.version = version;
5
5
  VxeUI.tableVersion = version;
6
6
  VxeUI.setConfig({
@@ -134,6 +134,7 @@ VxeUI.setConfig({
134
134
  // filterMethod: null,
135
135
  // destroyOnClose: false,
136
136
  // isEvery: false,
137
+ multiple: true,
137
138
  showIcon: true
138
139
  },
139
140
  aggregateConfig: {
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.9"}`;
3
+ const version = `table v${"3.17.0"}`;
4
4
  export const warnLog = log.create('warn', version);
5
5
  export const errLog = log.create('error', version);