vxe-table 3.17.0-beta.8 → 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 (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 +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/cell.js +5 -5
  7. package/es/table/src/columnInfo.js +5 -0
  8. package/es/table/src/methods.js +201 -76
  9. package/es/table/src/table.js +7 -6
  10. package/es/table/src/util.js +9 -0
  11. package/es/ui/index.js +2 -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 +407 -131
  16. package/lib/index.umd.min.js +1 -1
  17. package/lib/style.css +1 -1
  18. package/lib/table/module/custom/mixin.js +25 -13
  19. package/lib/table/module/custom/mixin.min.js +1 -1
  20. package/lib/table/module/edit/mixin.js +5 -0
  21. package/lib/table/module/edit/mixin.min.js +1 -1
  22. package/lib/table/src/body.js +7 -6
  23. package/lib/table/src/body.min.js +1 -1
  24. package/lib/table/src/cell.js +5 -4
  25. package/lib/table/src/cell.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 +238 -73
  29. package/lib/table/src/methods.min.js +1 -1
  30. package/lib/table/src/table.js +7 -6
  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 +2 -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 +21 -13
  41. package/packages/table/module/edit/mixin.ts +5 -5
  42. package/packages/table/src/body.ts +7 -6
  43. package/packages/table/src/cell.ts +5 -5
  44. package/packages/table/src/columnInfo.ts +7 -0
  45. package/packages/table/src/methods.ts +215 -76
  46. package/packages/table/src/props.ts +1 -1
  47. package/packages/table/src/table.ts +7 -6
  48. package/packages/table/src/util.ts +10 -0
  49. package/packages/ui/index.ts +1 -0
  50. /package/es/{iconfont.1753445505513.ttf → iconfont.1753928711953.ttf} +0 -0
  51. /package/es/{iconfont.1753445505513.woff → iconfont.1753928711953.woff} +0 -0
  52. /package/es/{iconfont.1753445505513.woff2 → iconfont.1753928711953.woff2} +0 -0
  53. /package/lib/{iconfont.1753445505513.ttf → iconfont.1753928711953.ttf} +0 -0
  54. /package/lib/{iconfont.1753445505513.woff → iconfont.1753928711953.woff} +0 -0
  55. /package/lib/{iconfont.1753445505513.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'
@@ -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 {
@@ -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,22 @@ 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
+ let sortIndex = 1
3403
+ XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
3404
+ const parentId = parentColumn ? parentColumn.id : null
3405
+ column.parentId = parentId
3406
+ column.defaultParentId = parentId
3335
3407
  column.sortNumber = sortIndex
3336
3408
  column.renderSortNumber = sortIndex
3409
+ sortIndex++
3337
3410
  })
3338
3411
  }
3339
3412
 
3340
- function handleColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, collectColumn: VxeTableDefines.ColumnInfo[]) {
3413
+ function handleInitColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, collectColumn: VxeTableDefines.ColumnInfo[]) {
3341
3414
  const $xeToolbar = $xeTable.$refs.$xeToolbar as VxeToolbarConstructor
3342
3415
  const reactData = $xeTable as unknown as TableReactData
3343
3416
  const internalData = $xeTable as unknown as TableInternalData
@@ -3347,7 +3420,7 @@ function handleColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, c
3347
3420
  const tableFullColumn = getColumnList(collectColumn)
3348
3421
  internalData.tableFullColumn = tableFullColumn
3349
3422
  reactData.isColLoading = true
3350
- initColumnSort($xeTable)
3423
+ initColumnHierarchy($xeTable)
3351
3424
  return Promise.resolve(
3352
3425
  restoreCustomStorage($xeTable)
3353
3426
  ).then(() => {
@@ -4029,7 +4102,7 @@ const Methods = {
4029
4102
 
4030
4103
  const { lastScrollLeft, lastScrollTop } = internalData
4031
4104
  const collectColumn = XEUtils.mapTree(columns, column => Cell.createColumn($xeTable, column), { children: 'children' })
4032
- return handleColumn($xeTable, collectColumn).then(() => {
4105
+ return handleInitColumn($xeTable, collectColumn).then(() => {
4033
4106
  let targetScrollLeft = lastScrollLeft
4034
4107
  let targetScrollTop = lastScrollTop
4035
4108
  const virtualXOpts = $xeTable.computeVirtualXOpts
@@ -4054,10 +4127,10 @@ const Methods = {
4054
4127
  return this.loadColumn(columns)
4055
4128
  })
4056
4129
  },
4057
- handleColumn (collectColumn: any[]) {
4130
+ handleInitColumn (collectColumn: any[]) {
4058
4131
  const $xeTable = this
4059
4132
 
4060
- return handleColumn($xeTable, collectColumn)
4133
+ return handleInitColumn($xeTable, collectColumn)
4061
4134
  },
4062
4135
  /**
4063
4136
  * 更新数据行的 Map
@@ -4078,7 +4151,7 @@ const Methods = {
4078
4151
  const handleRowCache = (row: any, index: number, items: any, currIndex: number, parentRow: any, rowid: string, level: number, seq: string | number) => {
4079
4152
  let rowRest = fullAllDataRowIdMaps[rowid]
4080
4153
  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 }
4154
+ 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
4155
  }
4083
4156
  rowRest.treeLoaded = false
4084
4157
  rowRest.expandLoaded = false
@@ -4187,7 +4260,7 @@ const Methods = {
4187
4260
  XEUtils.eachTree(rows, (childRow, index, items, path, parentItem, nodes) => {
4188
4261
  const rowid = getRowid($xeTable, childRow)
4189
4262
  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 }
4263
+ 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
4264
  fullDataRowIdData[rowid] = rest
4192
4265
  fullAllDataRowIdData[rowid] = rest
4193
4266
  }, { children: childrenField })
@@ -5220,8 +5293,9 @@ const Methods = {
5220
5293
  const isCustomResizable = hangleStorageDefaultValue(storageOpts.resizable, isAllCustom)
5221
5294
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
5222
5295
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
5296
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom)
5223
5297
  const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom)
5224
- if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort)) {
5298
+ if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomAggGroup || isCustomSort)) {
5225
5299
  if (!tableId) {
5226
5300
  errLog('vxe.error.reqProp', ['id'])
5227
5301
  return
@@ -5244,11 +5318,13 @@ const Methods = {
5244
5318
  getCustomStoreData () {
5245
5319
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
5246
5320
  const props = $xeTable
5321
+ const reactData = $xeTable as unknown as TableReactData
5247
5322
  const internalData = $xeTable as unknown as TableInternalData
5248
5323
 
5249
5324
  const { id } = props
5250
5325
  const customOpts = $xeTable.computeCustomOpts
5251
- const { collectColumn } = internalData
5326
+ const { isRowGroupStatus, rowGroupList } = reactData
5327
+ const { fullColumnFieldData, collectColumn } = internalData
5252
5328
  const { storage, checkMethod, storeOptions } = customOpts
5253
5329
  const isAllCustom = storage === true
5254
5330
  const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {}, storeOptions)
@@ -5256,17 +5332,20 @@ const Methods = {
5256
5332
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
5257
5333
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
5258
5334
  const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom)
5335
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom)
5259
5336
  const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom)
5260
5337
  const resizableData: Record<string, number> = {}
5261
- const sortData: Record<string, number> = {}
5338
+ const sortData: VxeTableDefines.CustomSortStoreObj[] = []
5262
5339
  const visibleData: Record<string, boolean> = {}
5263
5340
  const fixedData: Record<string, VxeColumnPropTypes.Fixed> = {}
5341
+ const aggGroupData: Record<string, boolean> = {}
5264
5342
  const aggFuncData: Record<string, VxeColumnPropTypes.AggFunc> = {}
5265
5343
  const storeData: VxeTableDefines.CustomStoreData = {
5266
5344
  resizableData: undefined,
5267
5345
  sortData: undefined,
5268
5346
  visibleData: undefined,
5269
5347
  fixedData: undefined,
5348
+ aggGroupData: undefined,
5270
5349
  aggFuncData: undefined
5271
5350
  }
5272
5351
  if (!id) {
@@ -5280,19 +5359,36 @@ const Methods = {
5280
5359
  let hasFixed = 0
5281
5360
  let hasVisible = 0
5282
5361
  let hasAggFunc = 0
5362
+ const sortMaps: Record<string, VxeTableDefines.CustomSortStoreObj> = {}
5283
5363
  XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
5284
5364
  const colKey = column.getKey()
5285
5365
  if (!colKey) {
5286
5366
  errLog('vxe.error.reqProp', [`${column.getTitle() || column.type || ''} -> column.field=?`])
5287
5367
  return
5288
5368
  }
5289
- // 只支持一级
5290
- if (!parentColumn) {
5369
+ if (parentColumn) {
5291
5370
  if (isCustomSort) {
5371
+ const pColKey = parentColumn.getKey()
5372
+ const psObj = sortMaps[pColKey]
5292
5373
  hasSort = 1
5293
- sortData[colKey] = column.renderSortNumber
5374
+ if (psObj) {
5375
+ const sObj = { k: colKey }
5376
+ sortMaps[colKey] = sObj
5377
+ if (!psObj.c) {
5378
+ psObj.c = []
5379
+ }
5380
+ psObj.c.push(sObj)
5381
+ }
5382
+ }
5383
+ } else {
5384
+ if (isCustomSort) {
5385
+ hasSort = 1
5386
+ const sObj = { k: colKey }
5387
+ sortMaps[colKey] = sObj
5388
+ sortData.push(sObj)
5294
5389
  }
5295
- if (isCustomFixed && column.fixed !== column.defaultFixed) {
5390
+ // 只支持一级
5391
+ if (isCustomFixed && (column.fixed || '') !== (column.defaultFixed || '')) {
5296
5392
  hasFixed = 1
5297
5393
  fixedData[colKey] = column.fixed
5298
5394
  }
@@ -5310,7 +5406,7 @@ const Methods = {
5310
5406
  visibleData[colKey] = true
5311
5407
  }
5312
5408
  }
5313
- if (isCustomAggFunc && column.aggFunc !== column.defaultAggFunc) {
5409
+ if (isCustomAggFunc && (column.aggFunc || '') !== (column.defaultAggFunc || '')) {
5314
5410
  hasAggFunc = 1
5315
5411
  aggFuncData[colKey] = column.aggFunc
5316
5412
  }
@@ -5327,6 +5423,15 @@ const Methods = {
5327
5423
  if (hasVisible) {
5328
5424
  storeData.visibleData = visibleData
5329
5425
  }
5426
+ if (isCustomAggGroup && isRowGroupStatus) {
5427
+ rowGroupList.forEach(aggConf => {
5428
+ const colRest = fullColumnFieldData[aggConf.field]
5429
+ if (colRest) {
5430
+ aggGroupData[colRest.column.getKey()] = true
5431
+ }
5432
+ })
5433
+ storeData.aggGroupData = aggGroupData
5434
+ }
5330
5435
  if (hasAggFunc) {
5331
5436
  storeData.aggFuncData = aggFuncData
5332
5437
  }
@@ -5347,21 +5452,24 @@ const Methods = {
5347
5452
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
5348
5453
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
5349
5454
  const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom)
5455
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom)
5350
5456
  const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom)
5351
5457
  if (type !== 'reset') {
5352
5458
  reactData.isCustomStatus = true
5353
5459
  }
5354
- if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort || isCustomAggFunc)) {
5460
+ if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort || isCustomAggGroup || isCustomAggFunc)) {
5355
5461
  if (!tableId) {
5356
5462
  errLog('vxe.error.reqProp', ['id'])
5357
5463
  return this.$nextTick()
5358
5464
  }
5359
- const storeData = type === 'reset'
5465
+ const storeData: VxeTableDefines.CustomStoreData = type === 'reset'
5360
5466
  ? {
5361
5467
  resizableData: {},
5362
5468
  sortData: {},
5363
5469
  visibleData: {},
5364
- fixedData: {}
5470
+ fixedData: {},
5471
+ aggGroupData: {},
5472
+ aggFuncData: {}
5365
5473
  }
5366
5474
  : this.getCustomStoreData()
5367
5475
  if (updateStore) {
@@ -9000,10 +9108,10 @@ const Methods = {
9000
9108
 
9001
9109
  return handleSortEvent($xeTable, null, sortConfs, isUpdate)
9002
9110
  },
9003
- setSortByEvent (evnt: Event, sortConfs: VxeTableDefines.SortConfs | VxeTableDefines.SortConfs[], isUpdate?: boolean) {
9111
+ setSortByEvent (evnt: Event, sortConfs: VxeTableDefines.SortConfs | VxeTableDefines.SortConfs[]) {
9004
9112
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
9005
9113
 
9006
- return handleSortEvent($xeTable, evnt, sortConfs, isUpdate)
9114
+ return handleSortEvent($xeTable, evnt, sortConfs, true)
9007
9115
  },
9008
9116
  /**
9009
9117
  * 清空指定列的排序条件
@@ -9036,6 +9144,7 @@ const Methods = {
9036
9144
 
9037
9145
  const { tableFullColumn } = internalData
9038
9146
  const sortOpts = $xeTable.computeSortOpts
9147
+ const { multiple } = sortOpts
9039
9148
  const sortCols: VxeTableDefines.ColumnInfo[] = []
9040
9149
  let column: VxeTableDefines.ColumnInfo<any> | null = null
9041
9150
  if (evnt) {
@@ -9055,11 +9164,18 @@ const Methods = {
9055
9164
  if (!sortOpts.remote) {
9056
9165
  $xeTable.handleTableData(true)
9057
9166
  }
9058
- if (sortCols.length) {
9167
+
9168
+ if (!multiple) {
9169
+ column = sortCols[0]
9170
+ }
9171
+
9172
+ if (column) {
9173
+ $xeTable.handleColumnSortEvent(evnt, column)
9174
+ }
9175
+
9176
+ if (multiple && sortCols.length) {
9059
9177
  const params = { $table: $xeTable, $event: evnt, cols: sortCols, sortList: [] }
9060
9178
  $xeTable.dispatchEvent('clear-all-sort', params, evnt)
9061
- } else if (column) {
9062
- $xeTable.handleColumnSortEvent(evnt, column)
9063
9179
  }
9064
9180
  }
9065
9181
  return $xeTable.$nextTick().then(() => {
@@ -9093,21 +9209,13 @@ const Methods = {
9093
9209
  }
9094
9210
  return sortList
9095
9211
  },
9096
- setFilterByEvent (evnt: Event, fieldOrColumn: VxeColumnPropTypes.Field | VxeTableDefines.ColumnInfo<any>, options: VxeColumnPropTypes.FilterItem[], isUpdate?: boolean) {
9212
+ setFilterByEvent (evnt: Event, fieldOrColumn: VxeColumnPropTypes.Field | VxeTableDefines.ColumnInfo<any>, options: VxeColumnPropTypes.FilterItem[]) {
9097
9213
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
9098
- const reactData = $xeTable as unknown as TableReactData
9099
9214
 
9100
- const { filterStore } = reactData
9101
9215
  const column = handleFieldOrColumn($xeTable, fieldOrColumn)
9102
9216
  if (column && column.filters) {
9103
9217
  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
- }
9218
+ return $xeTable.handleColumnConfirmFilter(column, evnt)
9111
9219
  }
9112
9220
  return $xeTable.$nextTick()
9113
9221
  },
@@ -9159,6 +9267,7 @@ const Methods = {
9159
9267
  const { filterStore } = reactData
9160
9268
  const { tableFullColumn } = internalData
9161
9269
  const filterOpts = $xeTable.computeFilterOpts
9270
+ const { multiple } = filterOpts
9162
9271
  const filterCols: VxeTableDefines.ColumnInfo[] = []
9163
9272
  let column: VxeTableDefines.ColumnInfo<any> | null = null
9164
9273
  if (fieldOrColumn) {
@@ -9181,19 +9290,49 @@ const Methods = {
9181
9290
  style: null,
9182
9291
  options: [],
9183
9292
  column: null,
9184
- multiple: false,
9293
+ multiple: false, // 选项是覅多选
9185
9294
  visible: false
9186
9295
  })
9187
9296
  }
9297
+
9188
9298
  if (!filterOpts.remote) {
9189
9299
  $xeTable.updateData()
9190
9300
  }
9191
- if (filterCols.length) {
9301
+
9302
+ if (!multiple) {
9303
+ column = filterCols[0]
9304
+ }
9305
+
9306
+ if (column) {
9307
+ const filterList = () => $xeTable.getCheckedFilters()
9308
+ const values: any[] = []
9309
+ const datas: any[] = []
9310
+ column.filters.forEach((item: any) => {
9311
+ if (item.checked) {
9312
+ values.push(item.value)
9313
+ datas.push(item.data)
9314
+ }
9315
+ })
9316
+ const params = {
9317
+ $table: $xeTable,
9318
+ $event: evnt as Event,
9319
+ column,
9320
+ field: column.field,
9321
+ property: column.field,
9322
+ values,
9323
+ datas,
9324
+ filters: filterList,
9325
+ filterList
9326
+ }
9327
+ $xeTable.dispatchEvent('filter-change', params, evnt)
9328
+ $xeTable.dispatchEvent('clear-filter', params, evnt)
9329
+ }
9330
+
9331
+ if (multiple && filterCols.length) {
9192
9332
  const params = { $table: $xeTable, $event: evnt, cols: filterCols, filterList: [] }
9193
9333
  $xeTable.dispatchEvent('clear-all-filter', params, evnt)
9194
- } else if (column) {
9195
- $xeTable.dispatchEvent('clear-filter', { filterList: () => $xeTable.getCheckedFilters() }, evnt)
9196
9334
  }
9335
+
9197
9336
  return $xeTable.$nextTick()
9198
9337
  },
9199
9338
  /**
@@ -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
  }
@@ -256,15 +256,16 @@ function renderRowExpandedVNs (h: CreateElement, $xeTable: VxeTableConstructor &
256
256
  let rowIndex = -1
257
257
  let $rowIndex = -1
258
258
  if (rowRest) {
259
+ rowIndex = rowRest.index
260
+ $rowIndex = rowRest.$index
261
+ _rowIndex = rowRest._index
259
262
  rowLevel = rowRest.level
263
+ seq = rowRest.seq
260
264
  if (isRowGroupStatus || (treeConfig && transform && seqMode === 'increasing')) {
261
265
  seq = rowRest._index + 1
262
- } else {
263
- seq = rowRest.seq
266
+ } else if ((treeConfig && seqMode === 'fixed')) {
267
+ seq = rowRest._tIndex + 1
264
268
  }
265
- rowIndex = rowRest.index
266
- $rowIndex = rowRest.$index
267
- _rowIndex = rowRest._index
268
269
  }
269
270
  if (expandHeight) {
270
271
  cellStyle.height = `${expandHeight}px`
@@ -1368,7 +1369,7 @@ export default {
1368
1369
  })
1369
1370
  },
1370
1371
  staticColumns (value: any) {
1371
- this.handleColumn(XEUtils.clone(value))
1372
+ this.$nextTick(() => this.handleInitColumn(XEUtils.clone(value)))
1372
1373
  },
1373
1374
  tableColumn () {
1374
1375
  this.analyColumnWidth()
@@ -233,6 +233,7 @@ export function assembleColumn (_vm: any) {
233
233
  if (!groupConfig.children) {
234
234
  groupConfig.children = []
235
235
  }
236
+ columnConfig.defaultParentId = groupConfig.id
236
237
  groupConfig.children.splice(XEUtils.arrayIndexOf($xeColumn.$el.children, $el), 0, columnConfig)
237
238
  } else {
238
239
  staticColumns.splice(XEUtils.arrayIndexOf(($xeTable.$refs.hideColumn as any).children, $el), 0, columnConfig)
@@ -446,6 +447,15 @@ export function isColumnInfo (column: any) {
446
447
  return column instanceof ColumnInfo
447
448
  }
448
449
 
450
+ // 获取所有的列,排除分组
451
+ export function getColumnList (columns: VxeTableDefines.ColumnInfo[]) {
452
+ const result: VxeTableDefines.ColumnInfo[] = []
453
+ columns.forEach((column) => {
454
+ result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]))
455
+ })
456
+ return result
457
+ }
458
+
449
459
  export function createColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, options: any, renderOptions: any): any {
450
460
  return isColumnInfo(options) ? options : new ColumnInfo($xeTable, options, renderOptions)
451
461
  }
@@ -140,6 +140,7 @@ VxeUI.setConfig({
140
140
  // filterMethod: null,
141
141
  // destroyOnClose: false,
142
142
  // isEvery: false,
143
+ multiple: true,
143
144
  showIcon: true
144
145
  },
145
146
  aggregateConfig: {