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'
@@ -131,38 +131,96 @@ function handleVirtualXVisible ($xeTable: VxeTableConstructor & VxeTablePrivateM
131
131
  }
132
132
 
133
133
  function handleCustomRestore ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, storeData: VxeTableDefines.CustomStoreData) {
134
+ const props = $xeTable
134
135
  const reactData = $xeTable as unknown as TableReactData
135
136
  const internalData = $xeTable as unknown as TableInternalData
136
137
 
137
- let { collectColumn } = internalData
138
- const { resizableData, sortData, visibleData, fixedData } = storeData
139
- let hasCustomSort = false
138
+ const { aggregateConfig, rowGroupConfig } = props
139
+ const { collectColumn } = internalData
140
+ const customOpts = $xeTable.computeCustomOpts
141
+ const { storage, storeOptions } = customOpts
142
+ const isAllCustom = storage === true
143
+ const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {}, storeOptions)
144
+ const isCustomResizable = hangleStorageDefaultValue(storageOpts.resizable, isAllCustom)
145
+ const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
146
+ const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
147
+ const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom)
148
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom)
149
+ const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom)
150
+ let { resizableData, sortData, visibleData, fixedData, aggGroupData, aggFuncData } = storeData
140
151
  // 处理还原
141
- if (resizableData || sortData || visibleData || fixedData) {
152
+ if ((isCustomResizable && resizableData) || (isCustomSort && sortData) || (isCustomVisible && visibleData) || (isCustomFixed && fixedData) || (isCustomAggGroup && aggGroupData) || (isCustomAggFunc && aggFuncData)) {
153
+ const sortColMaps: Record<string, {
154
+ key: string
155
+ sNum: number
156
+ pKey: string | null
157
+ }> = {}
158
+ if (isCustomSort && sortData) {
159
+ // 转换兼容老版本数据,即将废弃兼容
160
+ if (!XEUtils.isArray(sortData)) {
161
+ const sortRests: {key: string, index: number}[] = []
162
+ XEUtils.each(sortData, (index: number, colKey: string) => {
163
+ sortRests.push({ key: colKey, index })
164
+ })
165
+ sortData = XEUtils.orderBy(sortRests, { field: 'index', order: 'asc' }).map(item => ({ k: item.key }))
166
+ }
167
+ let colNum = 1
168
+ XEUtils.eachTree(sortData, (sObj, index, sOjs, path, pSObj) => {
169
+ sortColMaps[sObj.k] = {
170
+ key: sObj.k,
171
+ sNum: colNum++,
172
+ pKey: pSObj ? pSObj.k : null
173
+ }
174
+ }, { children: 'c' })
175
+ }
176
+ const colKeyMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
177
+ const allCols: VxeTableDefines.ColumnInfo[] = []
178
+ const aggGroupConfs: VxeTableDefines.RowGroupItem[] = []
142
179
  XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
143
180
  const colKey = column.getKey()
144
181
  // 支持一级
145
182
  if (!parentColumn) {
146
- if (fixedData && fixedData[colKey] !== undefined) {
183
+ if (isCustomFixed && fixedData && fixedData[colKey] !== undefined) {
147
184
  column.fixed = fixedData[colKey]
148
185
  }
149
- if (sortData && XEUtils.isNumber(sortData[colKey])) {
150
- hasCustomSort = true
151
- column.renderSortNumber = sortData[colKey]
152
- }
153
186
  }
154
- if (resizableData && XEUtils.isNumber(resizableData[colKey])) {
187
+ if (isCustomResizable && resizableData && XEUtils.isNumber(resizableData[colKey])) {
155
188
  column.resizeWidth = resizableData[colKey]
156
189
  }
157
- if (visibleData && XEUtils.isBoolean(visibleData[colKey])) {
190
+ if (isCustomVisible && visibleData && XEUtils.isBoolean(visibleData[colKey])) {
158
191
  column.visible = visibleData[colKey]
159
192
  }
193
+ if (isCustomAggFunc && aggFuncData && (aggregateConfig || rowGroupConfig) && aggFuncData[colKey]) {
194
+ column.aggFunc = aggFuncData[colKey]
195
+ }
196
+ if (isCustomAggGroup && aggGroupData && aggGroupData[colKey]) {
197
+ aggGroupConfs.push({ field: column.field })
198
+ }
199
+ colKeyMaps[colKey] = column
200
+ allCols.push(column)
160
201
  })
202
+ if ((aggregateConfig || rowGroupConfig) && aggGroupConfs.length) {
203
+ const groupRest = handleGroupData($xeTable, internalData.tableFullData, aggGroupConfs)
204
+ internalData.tableFullTreeData = []
205
+ internalData.tableFullGroupData = groupRest.treeData
206
+ reactData.isRowGroupStatus = true
207
+ reactData.rowGroupList = aggGroupConfs
208
+ $xeTable.cacheRowMap(false)
209
+ }
161
210
  // 如果自定义了顺序
162
- if (hasCustomSort) {
163
- collectColumn = XEUtils.orderBy(collectColumn, 'renderSortNumber')
164
- internalData.collectColumn = collectColumn
165
- internalData.tableFullColumn = getColumnList(collectColumn)
211
+ if (isCustomSort && sortData) {
212
+ allCols.forEach(column => {
213
+ const colKey = column.getKey()
214
+ const scItem = sortColMaps[colKey]
215
+ if (scItem) {
216
+ const parentColumn = scItem.pKey ? colKeyMaps[scItem.pKey] : null
217
+ column.parentId = parentColumn ? parentColumn.id : null
218
+ column.renderSortNumber = scItem.sNum
219
+ }
220
+ })
221
+ const newCollectCols = XEUtils.toArrayTree(XEUtils.orderBy(allCols, 'renderSortNumber'), { key: 'id', parentKey: 'parentId', children: 'children' })
222
+ internalData.collectColumn = newCollectCols
223
+ internalData.tableFullColumn = getColumnList(newCollectCols)
166
224
  }
167
225
  reactData.isCustomStatus = true
168
226
  } else {
@@ -218,8 +276,8 @@ function cacheColumnMap ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
218
276
  const internalData = $xeTable as unknown as TableInternalData
219
277
 
220
278
  const { tableFullColumn, collectColumn } = internalData
221
- const fullColumnIdData: Record<string, VxeTableDefines.ColumnCacheItem> = internalData.fullColumnIdData = {}
222
- const fullColumnFieldData: Record<string, VxeTableDefines.ColumnCacheItem> = internalData.fullColumnFieldData = {}
279
+ const fullColIdData: Record<string, VxeTableDefines.ColumnCacheItem> = internalData.fullColumnIdData = {}
280
+ const fullColFieldData: Record<string, VxeTableDefines.ColumnCacheItem> = internalData.fullColumnFieldData = {}
223
281
  const mouseOpts = $xeTable.computeMouseOpts
224
282
  const expandOpts = $xeTable.computeExpandOpts
225
283
  const columnOpts = $xeTable.computeColumnOpts
@@ -241,10 +299,10 @@ function cacheColumnMap ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
241
299
  const { id: colid, field, fixed, type, treeNode, rowGroupNode } = column
242
300
  const rest = { $index: -1, _index: -1, column, colid, index, items, parent: parentColumn || null, width: 0, oLeft: 0 }
243
301
  if (field) {
244
- if (fullColumnFieldData[field]) {
302
+ if (fullColFieldData[field]) {
245
303
  errLog('vxe.error.colRepet', ['field', field])
246
304
  }
247
- fullColumnFieldData[field] = rest
305
+ fullColFieldData[field] = rest
248
306
  } else {
249
307
  if ((storage && !type) || (columnOpts.drag && (isCrossDrag || isSelfToChildDrag))) {
250
308
  errLog('vxe.error.reqProp', [`${column.getTitle() || type || ''} -> column.field=?`])
@@ -298,10 +356,10 @@ function cacheColumnMap ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
298
356
  if (isAllOverflow && column.showOverflow === false) {
299
357
  isAllOverflow = false
300
358
  }
301
- if (fullColumnIdData[colid]) {
359
+ if (fullColIdData[colid]) {
302
360
  errLog('vxe.error.colRepet', ['colId', colid])
303
361
  }
304
- fullColumnIdData[colid] = rest
362
+ fullColIdData[colid] = rest
305
363
  }
306
364
 
307
365
  if (isGroup) {
@@ -319,10 +377,10 @@ function cacheColumnMap ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
319
377
 
320
378
  if (htmlColumn) {
321
379
  if (!columnOpts.useKey) {
322
- errLog('vxe.error.reqProp', ['column-config.useKey & column.type=html'])
380
+ errLog('vxe.error.notSupportProp', ['column.type=html', 'column-config.useKey=false', 'column-config.useKey=true'])
323
381
  }
324
382
  if (!rowOpts.useKey) {
325
- errLog('vxe.error.reqProp', ['row-config.useKey & column.type=html'])
383
+ errLog('vxe.error.notSupportProp', ['column.type=html', 'row-config.useKey=false', 'row-config.useKey=true'])
326
384
  }
327
385
  }
328
386
 
@@ -568,7 +626,7 @@ function updateAfterListIndex ($xeTable: VxeTableConstructor & VxeTablePrivateMe
568
626
  }
569
627
  rowRest._index = index
570
628
  } else {
571
- 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 }
629
+ 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 }
572
630
  fullAllDataRowIdData[rowid] = rest
573
631
  fullDataRowIdData[rowid] = rest
574
632
  }
@@ -592,6 +650,7 @@ function updateAfterDataIndex ($xeTable: VxeTableConstructor & VxeTablePrivateMe
592
650
  const childrenField = treeOpts.children || treeOpts.childrenField
593
651
  const fullMaps: Record<string, any> = {}
594
652
  if (treeConfig) {
653
+ let _treeIndex = 0
595
654
  const { handleGetRowId } = createHandleGetRowId($xeTable)
596
655
  XEUtils.eachTree(afterTreeFullData, (row, index, items, path) => {
597
656
  const rowid = handleGetRowId(row)
@@ -600,11 +659,13 @@ function updateAfterDataIndex ($xeTable: VxeTableConstructor & VxeTablePrivateMe
600
659
  if (rowRest) {
601
660
  rowRest.seq = seq
602
661
  rowRest.treeIndex = index
662
+ rowRest._tIndex = _treeIndex
603
663
  } else {
604
- 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 }
664
+ 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 }
605
665
  fullAllDataRowIdData[rowid] = rest
606
666
  fullDataRowIdData[rowid] = rest
607
667
  }
668
+ _treeIndex++
608
669
  fullMaps[rowid] = row
609
670
  }, { children: transform ? treeOpts.mapChildrenField : childrenField })
610
671
  if (transform) {
@@ -2055,16 +2116,25 @@ function removeFooterMerges ($xeTable: VxeTableConstructor & VxeTablePrivateMeth
2055
2116
  }
2056
2117
 
2057
2118
  function handleSortEvent ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: Event | null, sortConfs: VxeTableDefines.SortConfs | VxeTableDefines.SortConfs[], isUpdate?: boolean) {
2119
+ const internalData = $xeTable as unknown as TableInternalData
2120
+
2121
+ const { tableFullColumn } = internalData
2058
2122
  const sortOpts = $xeTable.computeSortOpts
2059
2123
  const { multiple, remote, orders } = sortOpts
2060
2124
  if (!XEUtils.isArray(sortConfs)) {
2061
2125
  sortConfs = [sortConfs]
2062
2126
  }
2063
2127
  if (sortConfs && sortConfs.length) {
2128
+ const orderActiveMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
2064
2129
  if (!multiple) {
2065
2130
  sortConfs = [sortConfs[0]]
2066
- clearAllSort($xeTable)
2131
+ tableFullColumn.forEach((column) => {
2132
+ if (column.order) {
2133
+ orderActiveMaps[column.id] = column
2134
+ }
2135
+ })
2067
2136
  }
2137
+ const sortColMpps: Record<string, VxeTableDefines.ColumnInfo> = {}
2068
2138
  let firstColumn: any = null
2069
2139
  sortConfs.forEach((confs: any, index: number) => {
2070
2140
  let { field, order } = confs
@@ -2083,8 +2153,16 @@ function handleSortEvent ($xeTable: VxeTableConstructor & VxeTablePrivateMethods
2083
2153
  column.order = order
2084
2154
  }
2085
2155
  column.sortTime = Date.now() + index
2156
+ sortColMpps[column.id] = column
2086
2157
  }
2087
2158
  })
2159
+ if (!multiple) {
2160
+ XEUtils.each(orderActiveMaps, (oaCol: VxeTableDefines.ColumnInfo, oaId) => {
2161
+ if (!sortColMpps[oaId]) {
2162
+ oaCol.order = null
2163
+ }
2164
+ })
2165
+ }
2088
2166
  if (isUpdate) {
2089
2167
  if (!remote) {
2090
2168
  $xeTable.handleTableData(true)
@@ -2272,7 +2350,7 @@ const calcCellHeight = ($xeTable: VxeTableConstructor) => {
2272
2350
  const { fullAllDataRowIdData } = internalData
2273
2351
  const defaultRowHeight = $xeTable.computeDefaultRowHeight
2274
2352
  const el = $xeTable.$refs.refElem as HTMLDivElement
2275
- if (!isAllOverflow && scrollYLoad && el) {
2353
+ if (!isAllOverflow && (scrollYLoad || scrollXLoad) && el) {
2276
2354
  const { handleGetRowId } = createHandleGetRowId($xeTable)
2277
2355
  tableData.forEach(row => {
2278
2356
  const rowid = handleGetRowId(row)
@@ -2792,18 +2870,18 @@ function handleUpdateAggValues ($xeTable: VxeTableConstructor & VxeTablePrivateM
2792
2870
  function handleUpdateRowGroup ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, groupFields?: string[]) {
2793
2871
  const reactData = $xeTable as unknown as TableReactData
2794
2872
 
2795
- const aggFields: string[] = []
2796
- const aggConfs: { field: string }[] = []
2873
+ const aggGroupFields: string[] = []
2874
+ const aggGroupConfs: VxeTableDefines.RowGroupItem[] = []
2797
2875
  if (groupFields) {
2798
2876
  (XEUtils.isArray(groupFields) ? groupFields : [groupFields]).forEach(field => {
2799
- aggFields.push(field)
2800
- aggConfs.push({
2877
+ aggGroupFields.push(field)
2878
+ aggGroupConfs.push({
2801
2879
  field
2802
2880
  })
2803
2881
  })
2804
2882
  }
2805
- reactData.rowGroupList = aggConfs
2806
- reactData.aggHandleFields = aggFields
2883
+ reactData.rowGroupList = aggGroupConfs
2884
+ reactData.aggHandleFields = aggGroupFields
2807
2885
  handleUpdateAggValues($xeTable)
2808
2886
  }
2809
2887
 
@@ -3191,15 +3269,6 @@ function loadScrollXData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods
3191
3269
  $xeTable.closeTooltip()
3192
3270
  }
3193
3271
 
3194
- // 获取所有的列,排除分组
3195
- function getColumnList (columns: any[]) {
3196
- const result: any[] = []
3197
- columns.forEach((column) => {
3198
- result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]))
3199
- })
3200
- return result
3201
- }
3202
-
3203
3272
  function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, isReset: boolean) {
3204
3273
  const props = $xeTable
3205
3274
  const reactData = $xeTable as unknown as TableReactData
@@ -3223,7 +3292,7 @@ function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, i
3223
3292
  if (parentColumn && parentColumn.fixed) {
3224
3293
  column.fixed = parentColumn.fixed
3225
3294
  }
3226
- if (parentColumn && column.fixed !== parentColumn.fixed) {
3295
+ if (parentColumn && (column.fixed || '') !== (parentColumn.fixed || '')) {
3227
3296
  errLog('vxe.error.groupFixed')
3228
3297
  }
3229
3298
  if (isColGroup) {
@@ -3326,18 +3395,35 @@ function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, i
3326
3395
  return $xeTable.updateFooter()
3327
3396
  }
3328
3397
 
3329
- function initColumnSort ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
3398
+ function initColumnHierarchy ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
3330
3399
  const internalData = $xeTable as unknown as TableInternalData
3331
3400
 
3332
3401
  const { collectColumn } = internalData
3333
- collectColumn.forEach((column, index) => {
3334
- const sortIndex = index + 1
3402
+ const fullColIdData: Record<string, VxeTableDefines.ColumnCacheItem> = {}
3403
+ const fullColFieldData: Record<string, VxeTableDefines.ColumnCacheItem> = {}
3404
+ let sortIndex = 1
3405
+ XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
3406
+ const { id: colid, field } = column
3407
+ const parentId = parentColumn ? parentColumn.id : null
3408
+ const rest = { $index: -1, _index: -1, column, colid, index, items, parent: parentColumn || null, width: 0, oLeft: 0 }
3409
+ column.parentId = parentId
3410
+ column.defaultParentId = parentId
3335
3411
  column.sortNumber = sortIndex
3336
3412
  column.renderSortNumber = sortIndex
3413
+ sortIndex++
3414
+ if (field) {
3415
+ if (fullColFieldData[field]) {
3416
+ errLog('vxe.error.colRepet', ['field', field])
3417
+ }
3418
+ fullColFieldData[field] = rest
3419
+ }
3420
+ fullColIdData[colid] = rest
3337
3421
  })
3422
+ internalData.fullColumnIdData = fullColIdData
3423
+ internalData.fullColumnFieldData = fullColFieldData
3338
3424
  }
3339
3425
 
3340
- function handleColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, collectColumn: VxeTableDefines.ColumnInfo[]) {
3426
+ function handleInitColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, collectColumn: VxeTableDefines.ColumnInfo[]) {
3341
3427
  const $xeToolbar = $xeTable.$refs.$xeToolbar as VxeToolbarConstructor
3342
3428
  const reactData = $xeTable as unknown as TableReactData
3343
3429
  const internalData = $xeTable as unknown as TableInternalData
@@ -3347,7 +3433,7 @@ function handleColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, c
3347
3433
  const tableFullColumn = getColumnList(collectColumn)
3348
3434
  internalData.tableFullColumn = tableFullColumn
3349
3435
  reactData.isColLoading = true
3350
- initColumnSort($xeTable)
3436
+ initColumnHierarchy($xeTable)
3351
3437
  return Promise.resolve(
3352
3438
  restoreCustomStorage($xeTable)
3353
3439
  ).then(() => {
@@ -4029,7 +4115,7 @@ const Methods = {
4029
4115
 
4030
4116
  const { lastScrollLeft, lastScrollTop } = internalData
4031
4117
  const collectColumn = XEUtils.mapTree(columns, column => Cell.createColumn($xeTable, column), { children: 'children' })
4032
- return handleColumn($xeTable, collectColumn).then(() => {
4118
+ return handleInitColumn($xeTable, collectColumn).then(() => {
4033
4119
  let targetScrollLeft = lastScrollLeft
4034
4120
  let targetScrollTop = lastScrollTop
4035
4121
  const virtualXOpts = $xeTable.computeVirtualXOpts
@@ -4054,10 +4140,10 @@ const Methods = {
4054
4140
  return this.loadColumn(columns)
4055
4141
  })
4056
4142
  },
4057
- handleColumn (collectColumn: any[]) {
4143
+ handleInitColumn (collectColumn: any[]) {
4058
4144
  const $xeTable = this
4059
4145
 
4060
- return handleColumn($xeTable, collectColumn)
4146
+ return handleInitColumn($xeTable, collectColumn)
4061
4147
  },
4062
4148
  /**
4063
4149
  * 更新数据行的 Map
@@ -4078,7 +4164,7 @@ const Methods = {
4078
4164
  const handleRowCache = (row: any, index: number, items: any, currIndex: number, parentRow: any, rowid: string, level: number, seq: string | number) => {
4079
4165
  let rowRest = fullAllDataRowIdMaps[rowid]
4080
4166
  if (!rowRest) {
4081
- rowRest = { row, rowid, seq, index: -1, _index: -1, $index: -1, treeIndex: index, items, parent: parentRow, level, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
4167
+ 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 }
4082
4168
  }
4083
4169
  rowRest.treeLoaded = false
4084
4170
  rowRest.expandLoaded = false
@@ -4187,7 +4273,7 @@ const Methods = {
4187
4273
  XEUtils.eachTree(rows, (childRow, index, items, path, parentItem, nodes) => {
4188
4274
  const rowid = getRowid($xeTable, childRow)
4189
4275
  const parentRow = parentItem || parentRest.row
4190
- 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 }
4276
+ 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 }
4191
4277
  fullDataRowIdData[rowid] = rest
4192
4278
  fullAllDataRowIdData[rowid] = rest
4193
4279
  }, { children: childrenField })
@@ -5220,8 +5306,9 @@ const Methods = {
5220
5306
  const isCustomResizable = hangleStorageDefaultValue(storageOpts.resizable, isAllCustom)
5221
5307
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
5222
5308
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
5309
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom)
5223
5310
  const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom)
5224
- if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort)) {
5311
+ if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomAggGroup || isCustomSort)) {
5225
5312
  if (!tableId) {
5226
5313
  errLog('vxe.error.reqProp', ['id'])
5227
5314
  return
@@ -5244,11 +5331,13 @@ const Methods = {
5244
5331
  getCustomStoreData () {
5245
5332
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
5246
5333
  const props = $xeTable
5334
+ const reactData = $xeTable as unknown as TableReactData
5247
5335
  const internalData = $xeTable as unknown as TableInternalData
5248
5336
 
5249
5337
  const { id } = props
5250
5338
  const customOpts = $xeTable.computeCustomOpts
5251
- const { collectColumn } = internalData
5339
+ const { isRowGroupStatus, rowGroupList } = reactData
5340
+ const { fullColumnFieldData, collectColumn } = internalData
5252
5341
  const { storage, checkMethod, storeOptions } = customOpts
5253
5342
  const isAllCustom = storage === true
5254
5343
  const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {}, storeOptions)
@@ -5256,17 +5345,20 @@ const Methods = {
5256
5345
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
5257
5346
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
5258
5347
  const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom)
5348
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom)
5259
5349
  const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom)
5260
5350
  const resizableData: Record<string, number> = {}
5261
- const sortData: Record<string, number> = {}
5351
+ const sortData: VxeTableDefines.CustomSortStoreObj[] = []
5262
5352
  const visibleData: Record<string, boolean> = {}
5263
5353
  const fixedData: Record<string, VxeColumnPropTypes.Fixed> = {}
5354
+ const aggGroupData: Record<string, boolean> = {}
5264
5355
  const aggFuncData: Record<string, VxeColumnPropTypes.AggFunc> = {}
5265
5356
  const storeData: VxeTableDefines.CustomStoreData = {
5266
5357
  resizableData: undefined,
5267
5358
  sortData: undefined,
5268
5359
  visibleData: undefined,
5269
5360
  fixedData: undefined,
5361
+ aggGroupData: undefined,
5270
5362
  aggFuncData: undefined
5271
5363
  }
5272
5364
  if (!id) {
@@ -5280,19 +5372,36 @@ const Methods = {
5280
5372
  let hasFixed = 0
5281
5373
  let hasVisible = 0
5282
5374
  let hasAggFunc = 0
5375
+ const sortMaps: Record<string, VxeTableDefines.CustomSortStoreObj> = {}
5283
5376
  XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
5284
5377
  const colKey = column.getKey()
5285
5378
  if (!colKey) {
5286
5379
  errLog('vxe.error.reqProp', [`${column.getTitle() || column.type || ''} -> column.field=?`])
5287
5380
  return
5288
5381
  }
5289
- // 只支持一级
5290
- if (!parentColumn) {
5382
+ if (parentColumn) {
5291
5383
  if (isCustomSort) {
5384
+ const pColKey = parentColumn.getKey()
5385
+ const psObj = sortMaps[pColKey]
5292
5386
  hasSort = 1
5293
- sortData[colKey] = column.renderSortNumber
5387
+ if (psObj) {
5388
+ const sObj = { k: colKey }
5389
+ sortMaps[colKey] = sObj
5390
+ if (!psObj.c) {
5391
+ psObj.c = []
5392
+ }
5393
+ psObj.c.push(sObj)
5394
+ }
5294
5395
  }
5295
- if (isCustomFixed && column.fixed !== column.defaultFixed) {
5396
+ } else {
5397
+ if (isCustomSort) {
5398
+ hasSort = 1
5399
+ const sObj = { k: colKey }
5400
+ sortMaps[colKey] = sObj
5401
+ sortData.push(sObj)
5402
+ }
5403
+ // 只支持一级
5404
+ if (isCustomFixed && (column.fixed || '') !== (column.defaultFixed || '')) {
5296
5405
  hasFixed = 1
5297
5406
  fixedData[colKey] = column.fixed
5298
5407
  }
@@ -5310,7 +5419,7 @@ const Methods = {
5310
5419
  visibleData[colKey] = true
5311
5420
  }
5312
5421
  }
5313
- if (isCustomAggFunc && column.aggFunc !== column.defaultAggFunc) {
5422
+ if (isCustomAggFunc && (column.aggFunc || '') !== (column.defaultAggFunc || '')) {
5314
5423
  hasAggFunc = 1
5315
5424
  aggFuncData[colKey] = column.aggFunc
5316
5425
  }
@@ -5327,6 +5436,15 @@ const Methods = {
5327
5436
  if (hasVisible) {
5328
5437
  storeData.visibleData = visibleData
5329
5438
  }
5439
+ if (isCustomAggGroup && isRowGroupStatus) {
5440
+ rowGroupList.forEach(aggConf => {
5441
+ const colRest = fullColumnFieldData[aggConf.field]
5442
+ if (colRest) {
5443
+ aggGroupData[colRest.column.getKey()] = true
5444
+ }
5445
+ })
5446
+ storeData.aggGroupData = aggGroupData
5447
+ }
5330
5448
  if (hasAggFunc) {
5331
5449
  storeData.aggFuncData = aggFuncData
5332
5450
  }
@@ -5347,21 +5465,24 @@ const Methods = {
5347
5465
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
5348
5466
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
5349
5467
  const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom)
5468
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom)
5350
5469
  const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom)
5351
5470
  if (type !== 'reset') {
5352
5471
  reactData.isCustomStatus = true
5353
5472
  }
5354
- if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort || isCustomAggFunc)) {
5473
+ if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort || isCustomAggGroup || isCustomAggFunc)) {
5355
5474
  if (!tableId) {
5356
5475
  errLog('vxe.error.reqProp', ['id'])
5357
5476
  return this.$nextTick()
5358
5477
  }
5359
- const storeData = type === 'reset'
5478
+ const storeData: VxeTableDefines.CustomStoreData = type === 'reset'
5360
5479
  ? {
5361
5480
  resizableData: {},
5362
5481
  sortData: {},
5363
5482
  visibleData: {},
5364
- fixedData: {}
5483
+ fixedData: {},
5484
+ aggGroupData: {},
5485
+ aggFuncData: {}
5365
5486
  }
5366
5487
  : this.getCustomStoreData()
5367
5488
  if (updateStore) {
@@ -9000,10 +9121,10 @@ const Methods = {
9000
9121
 
9001
9122
  return handleSortEvent($xeTable, null, sortConfs, isUpdate)
9002
9123
  },
9003
- setSortByEvent (evnt: Event, sortConfs: VxeTableDefines.SortConfs | VxeTableDefines.SortConfs[], isUpdate?: boolean) {
9124
+ setSortByEvent (evnt: Event, sortConfs: VxeTableDefines.SortConfs | VxeTableDefines.SortConfs[]) {
9004
9125
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
9005
9126
 
9006
- return handleSortEvent($xeTable, evnt, sortConfs, isUpdate)
9127
+ return handleSortEvent($xeTable, evnt, sortConfs, true)
9007
9128
  },
9008
9129
  /**
9009
9130
  * 清空指定列的排序条件
@@ -9036,6 +9157,7 @@ const Methods = {
9036
9157
 
9037
9158
  const { tableFullColumn } = internalData
9038
9159
  const sortOpts = $xeTable.computeSortOpts
9160
+ const { multiple } = sortOpts
9039
9161
  const sortCols: VxeTableDefines.ColumnInfo[] = []
9040
9162
  let column: VxeTableDefines.ColumnInfo<any> | null = null
9041
9163
  if (evnt) {
@@ -9055,11 +9177,18 @@ const Methods = {
9055
9177
  if (!sortOpts.remote) {
9056
9178
  $xeTable.handleTableData(true)
9057
9179
  }
9058
- if (sortCols.length) {
9180
+
9181
+ if (!multiple) {
9182
+ column = sortCols[0]
9183
+ }
9184
+
9185
+ if (column) {
9186
+ $xeTable.handleColumnSortEvent(evnt, column)
9187
+ }
9188
+
9189
+ if (multiple && sortCols.length) {
9059
9190
  const params = { $table: $xeTable, $event: evnt, cols: sortCols, sortList: [] }
9060
9191
  $xeTable.dispatchEvent('clear-all-sort', params, evnt)
9061
- } else if (column) {
9062
- $xeTable.handleColumnSortEvent(evnt, column)
9063
9192
  }
9064
9193
  }
9065
9194
  return $xeTable.$nextTick().then(() => {
@@ -9093,21 +9222,13 @@ const Methods = {
9093
9222
  }
9094
9223
  return sortList
9095
9224
  },
9096
- setFilterByEvent (evnt: Event, fieldOrColumn: VxeColumnPropTypes.Field | VxeTableDefines.ColumnInfo<any>, options: VxeColumnPropTypes.FilterItem[], isUpdate?: boolean) {
9225
+ setFilterByEvent (evnt: Event, fieldOrColumn: VxeColumnPropTypes.Field | VxeTableDefines.ColumnInfo<any>, options: VxeColumnPropTypes.FilterItem[]) {
9097
9226
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
9098
- const reactData = $xeTable as unknown as TableReactData
9099
9227
 
9100
- const { filterStore } = reactData
9101
9228
  const column = handleFieldOrColumn($xeTable, fieldOrColumn)
9102
9229
  if (column && column.filters) {
9103
9230
  column.filters = toFilters(options || [])
9104
- if (isUpdate) {
9105
- return $xeTable.handleColumnConfirmFilter(column, evnt)
9106
- } else {
9107
- if (filterStore.visible) {
9108
- $xeTable.handleFilterOptions(column)
9109
- }
9110
- }
9231
+ return $xeTable.handleColumnConfirmFilter(column, evnt)
9111
9232
  }
9112
9233
  return $xeTable.$nextTick()
9113
9234
  },
@@ -9159,6 +9280,7 @@ const Methods = {
9159
9280
  const { filterStore } = reactData
9160
9281
  const { tableFullColumn } = internalData
9161
9282
  const filterOpts = $xeTable.computeFilterOpts
9283
+ const { multiple } = filterOpts
9162
9284
  const filterCols: VxeTableDefines.ColumnInfo[] = []
9163
9285
  let column: VxeTableDefines.ColumnInfo<any> | null = null
9164
9286
  if (fieldOrColumn) {
@@ -9181,19 +9303,49 @@ const Methods = {
9181
9303
  style: null,
9182
9304
  options: [],
9183
9305
  column: null,
9184
- multiple: false,
9306
+ multiple: false, // 选项是覅多选
9185
9307
  visible: false
9186
9308
  })
9187
9309
  }
9310
+
9188
9311
  if (!filterOpts.remote) {
9189
9312
  $xeTable.updateData()
9190
9313
  }
9191
- if (filterCols.length) {
9314
+
9315
+ if (!multiple) {
9316
+ column = filterCols[0]
9317
+ }
9318
+
9319
+ if (column) {
9320
+ const filterList = () => $xeTable.getCheckedFilters()
9321
+ const values: any[] = []
9322
+ const datas: any[] = []
9323
+ column.filters.forEach((item: any) => {
9324
+ if (item.checked) {
9325
+ values.push(item.value)
9326
+ datas.push(item.data)
9327
+ }
9328
+ })
9329
+ const params = {
9330
+ $table: $xeTable,
9331
+ $event: evnt as Event,
9332
+ column,
9333
+ field: column.field,
9334
+ property: column.field,
9335
+ values,
9336
+ datas,
9337
+ filters: filterList,
9338
+ filterList
9339
+ }
9340
+ $xeTable.dispatchEvent('filter-change', params, evnt)
9341
+ $xeTable.dispatchEvent('clear-filter', params, evnt)
9342
+ }
9343
+
9344
+ if (multiple && filterCols.length) {
9192
9345
  const params = { $table: $xeTable, $event: evnt, cols: filterCols, filterList: [] }
9193
9346
  $xeTable.dispatchEvent('clear-all-filter', params, evnt)
9194
- } else if (column) {
9195
- $xeTable.dispatchEvent('clear-filter', { filterList: () => $xeTable.getCheckedFilters() }, evnt)
9196
9347
  }
9348
+
9197
9349
  return $xeTable.$nextTick()
9198
9350
  },
9199
9351
  /**
@@ -11028,7 +11180,7 @@ const Methods = {
11028
11180
  } as any
11029
11181
 
11030
11182
  // Module methods
11031
- 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(',')
11183
+ 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(',')
11032
11184
 
11033
11185
  funcs.forEach(name => {
11034
11186
  Methods[name] = function (...args: any[]) {
@@ -278,5 +278,5 @@ export default {
278
278
  // (可能会被废弃的参数,不要使用)
279
279
  delayHover: { type: Number, default: () => getConfig().table.delayHover },
280
280
  // 额外的参数
281
- params: Object
281
+ params: Object as PropType<VxeTablePropTypes.Params>
282
282
  }