vxe-table 4.15.0-beta.9 → 4.15.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 (50) hide show
  1. package/es/grid/src/grid.js +57 -9
  2. package/es/style.css +1 -1
  3. package/es/table/module/custom/hook.js +29 -14
  4. package/es/table/module/custom/panel.js +1 -1
  5. package/es/table/module/edit/hook.js +5 -5
  6. package/es/table/src/body.js +7 -6
  7. package/es/table/src/columnInfo.js +2 -0
  8. package/es/table/src/table.js +235 -90
  9. package/es/table/src/util.js +9 -0
  10. package/es/ui/index.js +3 -1
  11. package/es/ui/src/log.js +1 -1
  12. package/lib/grid/src/grid.js +67 -9
  13. package/lib/grid/src/grid.min.js +1 -1
  14. package/lib/index.umd.js +156 -57
  15. package/lib/index.umd.min.js +1 -1
  16. package/lib/style.css +1 -1
  17. package/lib/table/module/custom/hook.js +34 -13
  18. package/lib/table/module/custom/hook.min.js +1 -1
  19. package/lib/table/module/custom/panel.js +1 -1
  20. package/lib/table/module/custom/panel.min.js +1 -1
  21. package/lib/table/module/edit/hook.js +5 -0
  22. package/lib/table/module/edit/hook.min.js +1 -1
  23. package/lib/table/src/body.js +7 -6
  24. package/lib/table/src/body.min.js +1 -1
  25. package/lib/table/src/columnInfo.js +2 -0
  26. package/lib/table/src/columnInfo.min.js +1 -1
  27. package/lib/table/src/table.js +26 -26
  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 +3 -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 +62 -9
  37. package/packages/table/module/custom/hook.ts +28 -13
  38. package/packages/table/module/custom/panel.ts +1 -1
  39. package/packages/table/module/edit/hook.ts +5 -5
  40. package/packages/table/src/body.ts +7 -6
  41. package/packages/table/src/columnInfo.ts +3 -0
  42. package/packages/table/src/table.ts +248 -90
  43. package/packages/table/src/util.ts +10 -0
  44. package/packages/ui/index.ts +2 -0
  45. /package/es/{iconfont.1753497319436.ttf → iconfont.1754358078563.ttf} +0 -0
  46. /package/es/{iconfont.1753497319436.woff → iconfont.1754358078563.woff} +0 -0
  47. /package/es/{iconfont.1753497319436.woff2 → iconfont.1754358078563.woff2} +0 -0
  48. /package/lib/{iconfont.1753497319436.ttf → iconfont.1754358078563.ttf} +0 -0
  49. /package/lib/{iconfont.1753497319436.woff → iconfont.1754358078563.woff} +0 -0
  50. /package/lib/{iconfont.1753497319436.woff2 → iconfont.1754358078563.woff2} +0 -0
@@ -4,7 +4,7 @@ import XEUtils from 'xe-utils'
4
4
  import { initTpImg, getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTargetNode, getPaddingTopBottomSize, setScrollTop, setScrollLeft, toCssUnit, hasControlKey } from '../../ui/src/dom'
5
5
  import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils'
6
6
  import { VxeUI } from '../../ui'
7
- import { getRowUniqueId, clearTableAllStatus, toFilters, hasDeepKey, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getRefElem, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getCalcHeight, getCellRestHeight } from './util'
7
+ import { getRowUniqueId, clearTableAllStatus, getColumnList, toFilters, hasDeepKey, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getRefElem, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getCalcHeight, getCellRestHeight } from './util'
8
8
  import { getSlotVNs } from '../../ui/src/vn'
9
9
  import { moveRowAnimateToTb, clearRowAnimate, moveColAnimateToLr, clearColAnimate } from './anime'
10
10
  import { warnLog, errLog } from '../../ui/src/log'
@@ -514,11 +514,19 @@ export default defineVxeComponent({
514
514
  })
515
515
 
516
516
  const computeVirtualXOpts = computed(() => {
517
- return Object.assign({}, getConfig().table.virtualXConfig || getConfig().table.scrollX, props.virtualXConfig || props.scrollX) as VxeTablePropTypes.VirtualXConfig & { gt: number }
517
+ const { virtualXConfig } = props
518
+ if (virtualXConfig) {
519
+ return Object.assign({}, getConfig().table.virtualXConfig, virtualXConfig) as VxeTablePropTypes.VirtualXConfig & { gt: number }
520
+ }
521
+ return Object.assign({}, getConfig().table.virtualXConfig, getConfig().table.scrollX, props.scrollX) as VxeTablePropTypes.VirtualXConfig & { gt: number }
518
522
  })
519
523
 
520
524
  const computeVirtualYOpts = computed(() => {
521
- return Object.assign({}, getConfig().table.virtualYConfig || getConfig().table.scrollY, props.virtualYConfig || props.scrollY) as VxeTablePropTypes.VirtualYConfig & { gt: number }
525
+ const { virtualYConfig } = props
526
+ if (virtualYConfig) {
527
+ return Object.assign({}, getConfig().table.virtualYConfig, virtualYConfig) as VxeTablePropTypes.VirtualYConfig & { gt: number }
528
+ }
529
+ return Object.assign({}, getConfig().table.virtualYConfig, getConfig().table.scrollY, props.scrollY) as VxeTablePropTypes.VirtualYConfig & { gt: number }
522
530
  })
523
531
 
524
532
  const computeScrollbarOpts = computed(() => {
@@ -1443,16 +1451,23 @@ export default defineVxeComponent({
1443
1451
  }
1444
1452
 
1445
1453
  const handleSortEvent = (evnt: Event | null, sortConfs: VxeTableDefines.SortConfs | VxeTableDefines.SortConfs[], isUpdate?: boolean) => {
1454
+ const { tableFullColumn } = internalData
1446
1455
  const sortOpts = computeSortOpts.value
1447
1456
  const { multiple, remote, orders } = sortOpts
1448
1457
  if (!XEUtils.isArray(sortConfs)) {
1449
1458
  sortConfs = [sortConfs]
1450
1459
  }
1451
1460
  if (sortConfs && sortConfs.length) {
1461
+ const orderActiveMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
1452
1462
  if (!multiple) {
1453
1463
  sortConfs = [sortConfs[0]]
1454
- clearAllSort()
1464
+ tableFullColumn.forEach((column) => {
1465
+ if (column.order) {
1466
+ orderActiveMaps[column.id] = column
1467
+ }
1468
+ })
1455
1469
  }
1470
+ const sortColMpps: Record<string, VxeTableDefines.ColumnInfo> = {}
1456
1471
  let firstColumn: any = null
1457
1472
  sortConfs.forEach((confs: any, index: number) => {
1458
1473
  let { field, order } = confs
@@ -1471,8 +1486,16 @@ export default defineVxeComponent({
1471
1486
  column.order = order
1472
1487
  }
1473
1488
  column.sortTime = Date.now() + index
1489
+ sortColMpps[column.id] = column
1474
1490
  }
1475
1491
  })
1492
+ if (!multiple) {
1493
+ XEUtils.each(orderActiveMaps, (oaCol: VxeTableDefines.ColumnInfo, oaId) => {
1494
+ if (!sortColMpps[oaId]) {
1495
+ oaCol.order = null
1496
+ }
1497
+ })
1498
+ }
1476
1499
  if (isUpdate) {
1477
1500
  if (!remote) {
1478
1501
  $xeTable.handleTableData(true)
@@ -1518,35 +1541,92 @@ export default defineVxeComponent({
1518
1541
  }
1519
1542
 
1520
1543
  const handleCustomRestore = (storeData: VxeTableDefines.CustomStoreData) => {
1521
- let { collectColumn } = internalData
1522
- const { resizableData, sortData, visibleData, fixedData } = storeData
1523
- let hasCustomSort = false
1544
+ const { aggregateConfig, rowGroupConfig } = props
1545
+ const { collectColumn } = internalData
1546
+ const customOpts = computeCustomOpts.value
1547
+ const { storage, storeOptions } = customOpts
1548
+ const isAllCustom = storage === true
1549
+ const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {}, storeOptions)
1550
+ const isCustomResizable = hangleStorageDefaultValue(storageOpts.resizable, isAllCustom)
1551
+ const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
1552
+ const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
1553
+ const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom)
1554
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom)
1555
+ const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom)
1556
+ let { resizableData, sortData, visibleData, fixedData, aggGroupData, aggFuncData } = storeData
1524
1557
  // 处理还原
1525
- if (resizableData || sortData || visibleData || fixedData) {
1558
+ if ((isCustomResizable && resizableData) || (isCustomSort && sortData) || (isCustomVisible && visibleData) || (isCustomFixed && fixedData) || (isCustomAggGroup && aggGroupData) || (isCustomAggFunc && aggFuncData)) {
1559
+ const sortColMaps: Record<string, {
1560
+ key: string
1561
+ sNum: number
1562
+ pKey: string | null
1563
+ }> = {}
1564
+ if (isCustomSort && sortData) {
1565
+ // 转换兼容老版本数据,即将废弃兼容
1566
+ if (!XEUtils.isArray(sortData)) {
1567
+ const sortRests: {key: string, index: number}[] = []
1568
+ XEUtils.each(sortData, (index: number, colKey: string) => {
1569
+ sortRests.push({ key: colKey, index })
1570
+ })
1571
+ sortData = XEUtils.orderBy(sortRests, { field: 'index', order: 'asc' }).map(item => ({ k: item.key }))
1572
+ }
1573
+ let colNum = 1
1574
+ XEUtils.eachTree(sortData, (sObj, index, sOjs, path, pSObj) => {
1575
+ sortColMaps[sObj.k] = {
1576
+ key: sObj.k,
1577
+ sNum: colNum++,
1578
+ pKey: pSObj ? pSObj.k : null
1579
+ }
1580
+ }, { children: 'c' })
1581
+ }
1582
+ const colKeyMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
1583
+ const allCols: VxeTableDefines.ColumnInfo[] = []
1584
+ const aggGroupConfs: VxeTableDefines.RowGroupItem[] = []
1526
1585
  XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
1527
1586
  const colKey = column.getKey()
1528
1587
  // 支持一级
1529
1588
  if (!parentColumn) {
1530
- if (fixedData && fixedData[colKey] !== undefined) {
1589
+ if (isCustomFixed && fixedData && fixedData[colKey] !== undefined) {
1531
1590
  column.fixed = fixedData[colKey]
1532
1591
  }
1533
- if (sortData && XEUtils.isNumber(sortData[colKey])) {
1534
- hasCustomSort = true
1535
- column.renderSortNumber = sortData[colKey]
1536
- }
1537
1592
  }
1538
- if (resizableData && XEUtils.isNumber(resizableData[colKey])) {
1593
+ if (isCustomResizable && resizableData && XEUtils.isNumber(resizableData[colKey])) {
1539
1594
  column.resizeWidth = resizableData[colKey]
1540
1595
  }
1541
- if (visibleData && XEUtils.isBoolean(visibleData[colKey])) {
1596
+ if (isCustomVisible && visibleData && XEUtils.isBoolean(visibleData[colKey])) {
1542
1597
  column.visible = visibleData[colKey]
1543
1598
  }
1599
+ if (isCustomAggFunc && aggFuncData && (aggregateConfig || rowGroupConfig) && aggFuncData[colKey]) {
1600
+ column.aggFunc = aggFuncData[colKey]
1601
+ }
1602
+ if (isCustomAggGroup && aggGroupData && aggGroupData[colKey]) {
1603
+ aggGroupConfs.push({ field: column.field })
1604
+ }
1605
+ colKeyMaps[colKey] = column
1606
+ allCols.push(column)
1544
1607
  })
1608
+ if ((aggregateConfig || rowGroupConfig) && aggGroupConfs.length) {
1609
+ const groupRest = handleGroupData(internalData.tableFullData, aggGroupConfs)
1610
+ internalData.tableFullTreeData = []
1611
+ internalData.tableFullGroupData = groupRest.treeData
1612
+ reactData.isRowGroupStatus = true
1613
+ reactData.rowGroupList = aggGroupConfs
1614
+ $xeTable.cacheRowMap(false)
1615
+ }
1545
1616
  // 如果自定义了顺序
1546
- if (hasCustomSort) {
1547
- collectColumn = XEUtils.orderBy(collectColumn, 'renderSortNumber')
1548
- internalData.collectColumn = collectColumn
1549
- internalData.tableFullColumn = getColumnList(collectColumn)
1617
+ if (isCustomSort && sortData) {
1618
+ allCols.forEach(column => {
1619
+ const colKey = column.getKey()
1620
+ const scItem = sortColMaps[colKey]
1621
+ if (scItem) {
1622
+ const parentColumn = scItem.pKey ? colKeyMaps[scItem.pKey] : null
1623
+ column.parentId = parentColumn ? parentColumn.id : null
1624
+ column.renderSortNumber = scItem.sNum
1625
+ }
1626
+ })
1627
+ const newCollectCols = XEUtils.toArrayTree(XEUtils.orderBy(allCols, 'renderSortNumber'), { key: 'id', parentKey: 'parentId', children: 'children' })
1628
+ internalData.collectColumn = newCollectCols
1629
+ internalData.tableFullColumn = getColumnList(newCollectCols)
1550
1630
  }
1551
1631
  reactData.isCustomStatus = true
1552
1632
  } else {
@@ -1568,8 +1648,9 @@ export default defineVxeComponent({
1568
1648
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
1569
1649
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
1570
1650
  const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom)
1651
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom)
1571
1652
  const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom)
1572
- if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort || isCustomAggFunc)) {
1653
+ if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort || isCustomAggGroup || isCustomAggFunc)) {
1573
1654
  if (!tableId) {
1574
1655
  errLog('vxe.error.reqProp', ['id'])
1575
1656
  return
@@ -1596,8 +1677,8 @@ export default defineVxeComponent({
1596
1677
  */
1597
1678
  const cacheColumnMap = () => {
1598
1679
  const { tableFullColumn, collectColumn } = internalData
1599
- const fullColumnIdData: Record<string, VxeTableDefines.ColumnCacheItem> = internalData.fullColumnIdData = {}
1600
- const fullColumnFieldData: Record<string, VxeTableDefines.ColumnCacheItem> = internalData.fullColumnFieldData = {}
1680
+ const fullColIdData: Record<string, VxeTableDefines.ColumnCacheItem> = internalData.fullColumnIdData = {}
1681
+ const fullColFieldData: Record<string, VxeTableDefines.ColumnCacheItem> = internalData.fullColumnFieldData = {}
1601
1682
  const mouseOpts = computeMouseOpts.value
1602
1683
  const expandOpts = computeExpandOpts.value
1603
1684
  const columnOpts = computeColumnOpts.value
@@ -1620,10 +1701,10 @@ export default defineVxeComponent({
1620
1701
  const { id: colid, field, fixed, type, treeNode, rowGroupNode } = column
1621
1702
  const rest = { $index: -1, _index: -1, column, colid, index, items, parent: parentColumn || null, width: 0, oLeft: 0 }
1622
1703
  if (field) {
1623
- if (fullColumnFieldData[field]) {
1704
+ if (fullColFieldData[field]) {
1624
1705
  errLog('vxe.error.colRepet', ['field', field])
1625
1706
  }
1626
- fullColumnFieldData[field] = rest
1707
+ fullColFieldData[field] = rest
1627
1708
  } else {
1628
1709
  if ((storage && !type) || (columnOpts.drag && (isCrossDrag || isSelfToChildDrag))) {
1629
1710
  errLog('vxe.error.reqProp', [`${column.getTitle() || type || ''} -> column.field=?`])
@@ -1677,10 +1758,10 @@ export default defineVxeComponent({
1677
1758
  if (isAllOverflow && column.showOverflow === false) {
1678
1759
  isAllOverflow = false
1679
1760
  }
1680
- if (fullColumnIdData[colid]) {
1761
+ if (fullColIdData[colid]) {
1681
1762
  errLog('vxe.error.colRepet', ['colId', colid])
1682
1763
  }
1683
- fullColumnIdData[colid] = rest
1764
+ fullColIdData[colid] = rest
1684
1765
  }
1685
1766
  if (isGroup) {
1686
1767
  XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn, nodes) => {
@@ -1700,10 +1781,10 @@ export default defineVxeComponent({
1700
1781
 
1701
1782
  if (htmlColumn) {
1702
1783
  if (!columnOpts.useKey) {
1703
- errLog('vxe.error.reqProp', ['column-config.useKey & column.type=html'])
1784
+ errLog('vxe.error.notSupportProp', ['column.type=html', 'column-config.useKey=false', 'column-config.useKey=true'])
1704
1785
  }
1705
1786
  if (!rowOpts.useKey) {
1706
- errLog('vxe.error.reqProp', ['row-config.useKey & column.type=html'])
1787
+ errLog('vxe.error.notSupportProp', ['column.type=html', 'row-config.useKey=false', 'row-config.useKey=true'])
1707
1788
  }
1708
1789
  }
1709
1790
 
@@ -1905,7 +1986,7 @@ export default defineVxeComponent({
1905
1986
  const { fullAllDataRowIdData } = internalData
1906
1987
  const defaultRowHeight = computeDefaultRowHeight.value
1907
1988
  const el = refElem.value
1908
- if (!isAllOverflow && scrollYLoad && el) {
1989
+ if (!isAllOverflow && (scrollYLoad || scrollXLoad) && el) {
1909
1990
  const { handleGetRowId } = createHandleGetRowId($xeTable)
1910
1991
  el.setAttribute('data-calc-row', 'Y')
1911
1992
  tableData.forEach(row => {
@@ -1956,7 +2037,7 @@ export default defineVxeComponent({
1956
2037
  }
1957
2038
  rowRest._index = index
1958
2039
  } else {
1959
- 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 }
2040
+ 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 }
1960
2041
  fullAllDataRowIdData[rowid] = rest
1961
2042
  fullDataRowIdData[rowid] = rest
1962
2043
  }
@@ -1977,6 +2058,7 @@ export default defineVxeComponent({
1977
2058
  const childrenField = treeOpts.children || treeOpts.childrenField
1978
2059
  const fullMaps: Record<string, any> = {}
1979
2060
  if (treeConfig) {
2061
+ let _treeIndex = 0
1980
2062
  const { handleGetRowId } = createHandleGetRowId($xeTable)
1981
2063
  XEUtils.eachTree(afterTreeFullData, (row, index, items, path) => {
1982
2064
  const rowid = handleGetRowId(row)
@@ -1985,11 +2067,13 @@ export default defineVxeComponent({
1985
2067
  if (rowRest) {
1986
2068
  rowRest.seq = seq
1987
2069
  rowRest.treeIndex = index
2070
+ rowRest._tIndex = _treeIndex
1988
2071
  } else {
1989
- 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 }
2072
+ 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 }
1990
2073
  fullAllDataRowIdData[rowid] = rest
1991
2074
  fullDataRowIdData[rowid] = rest
1992
2075
  }
2076
+ _treeIndex++
1993
2077
  fullMaps[rowid] = row
1994
2078
  }, { children: transform ? treeOpts.mapChildrenField : childrenField })
1995
2079
  if (transform) {
@@ -3238,18 +3322,18 @@ export default defineVxeComponent({
3238
3322
  }
3239
3323
 
3240
3324
  const handleUpdateRowGroup = (groupFields?: string[]) => {
3241
- const aggFields: string[] = []
3242
- const aggConfs: { field: string }[] = []
3325
+ const aggGroupFields: string[] = []
3326
+ const aggGroupConfs: { field: string }[] = []
3243
3327
  if (groupFields) {
3244
3328
  (XEUtils.isArray(groupFields) ? groupFields : [groupFields]).forEach(field => {
3245
- aggFields.push(field)
3246
- aggConfs.push({
3329
+ aggGroupFields.push(field)
3330
+ aggGroupConfs.push({
3247
3331
  field
3248
3332
  })
3249
3333
  })
3250
3334
  }
3251
- reactData.rowGroupList = aggConfs
3252
- reactData.aggHandleFields = aggFields
3335
+ reactData.rowGroupList = aggGroupConfs
3336
+ reactData.aggHandleFields = aggGroupFields
3253
3337
  handleUpdateAggValues()
3254
3338
  }
3255
3339
 
@@ -3621,15 +3705,6 @@ export default defineVxeComponent({
3621
3705
  $xeTable.closeTooltip()
3622
3706
  }
3623
3707
 
3624
- // 获取所有的列,排除分组
3625
- const getColumnList = (columns: VxeTableDefines.ColumnInfo[]) => {
3626
- const result: VxeTableDefines.ColumnInfo[] = []
3627
- columns.forEach((column) => {
3628
- result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]))
3629
- })
3630
- return result
3631
- }
3632
-
3633
3708
  const parseColumns = (isReset: boolean) => {
3634
3709
  // const { showOverflow } = props
3635
3710
  // const rowOpts = computeRowOpts.value
@@ -3649,7 +3724,7 @@ export default defineVxeComponent({
3649
3724
  if (parentColumn && parentColumn.fixed) {
3650
3725
  column.fixed = parentColumn.fixed
3651
3726
  }
3652
- if (parentColumn && column.fixed !== parentColumn.fixed) {
3727
+ if (parentColumn && (column.fixed || '') !== (parentColumn.fixed || '')) {
3653
3728
  errLog('vxe.error.groupFixed')
3654
3729
  }
3655
3730
  if (isColGroup) {
@@ -3753,22 +3828,39 @@ export default defineVxeComponent({
3753
3828
  return $xeTable.updateFooter()
3754
3829
  }
3755
3830
 
3756
- const initColumnSort = () => {
3831
+ const initColumnHierarchy = () => {
3757
3832
  const { collectColumn } = internalData
3758
- collectColumn.forEach((column, index) => {
3759
- const sortIndex = index + 1
3833
+ const fullColIdData: Record<string, VxeTableDefines.ColumnCacheItem> = {}
3834
+ const fullColFieldData: Record<string, VxeTableDefines.ColumnCacheItem> = {}
3835
+ let sortIndex = 1
3836
+ XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
3837
+ const { id: colid, field } = column
3838
+ const parentId = parentColumn ? parentColumn.id : null
3839
+ const rest = { $index: -1, _index: -1, column, colid, index, items, parent: parentColumn || null, width: 0, oLeft: 0 }
3840
+ column.parentId = parentId
3841
+ column.defaultParentId = parentId
3760
3842
  column.sortNumber = sortIndex
3761
3843
  column.renderSortNumber = sortIndex
3844
+ sortIndex++
3845
+ if (field) {
3846
+ if (fullColFieldData[field]) {
3847
+ errLog('vxe.error.colRepet', ['field', field])
3848
+ }
3849
+ fullColFieldData[field] = rest
3850
+ }
3851
+ fullColIdData[colid] = rest
3762
3852
  })
3853
+ internalData.fullColumnIdData = fullColIdData
3854
+ internalData.fullColumnFieldData = fullColFieldData
3763
3855
  }
3764
3856
 
3765
- const handleColumn = (collectColumn: VxeTableDefines.ColumnInfo[]) => {
3857
+ const handleInitColumn = (collectColumn: VxeTableDefines.ColumnInfo[]) => {
3766
3858
  const expandOpts = computeExpandOpts.value
3767
3859
  internalData.collectColumn = collectColumn
3768
3860
  const tableFullColumn = getColumnList(collectColumn)
3769
3861
  internalData.tableFullColumn = tableFullColumn
3770
3862
  reactData.isColLoading = true
3771
- initColumnSort()
3863
+ initColumnHierarchy()
3772
3864
  return Promise.resolve(
3773
3865
  restoreCustomStorage()
3774
3866
  ).then(() => {
@@ -4491,7 +4583,7 @@ export default defineVxeComponent({
4491
4583
  XEUtils.eachTree(rows, (childRow, index, items, path, parentItem, nodes) => {
4492
4584
  const rowid = getRowid($xeTable, childRow)
4493
4585
  const parentRow = parentItem || parentRest.row
4494
- 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 }
4586
+ 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 }
4495
4587
  fullDataRowIdData[rowid] = rest
4496
4588
  fullAllDataRowIdData[rowid] = rest
4497
4589
  }, { children: childrenField })
@@ -4511,7 +4603,7 @@ export default defineVxeComponent({
4511
4603
  loadColumn (columns) {
4512
4604
  const { lastScrollLeft, lastScrollTop } = internalData
4513
4605
  const collectColumn = XEUtils.mapTree(columns, column => reactive(Cell.createColumn($xeTable, column)))
4514
- return handleColumn(collectColumn).then(() => {
4606
+ return handleInitColumn(collectColumn).then(() => {
4515
4607
  let targetScrollLeft = lastScrollLeft
4516
4608
  let targetScrollTop = lastScrollTop
4517
4609
  const virtualXOpts = computeVirtualXOpts.value
@@ -5957,8 +6049,8 @@ export default defineVxeComponent({
5957
6049
  setSort (sortConfs, isUpdate) {
5958
6050
  return handleSortEvent(null, sortConfs, isUpdate)
5959
6051
  },
5960
- setSortByEvent (evnt, sortConfs, isUpdate) {
5961
- return handleSortEvent(evnt, sortConfs, isUpdate)
6052
+ setSortByEvent (evnt, sortConfs) {
6053
+ return handleSortEvent(evnt, sortConfs, true)
5962
6054
  },
5963
6055
  /**
5964
6056
  * 清空指定列的排序条件
@@ -5986,6 +6078,7 @@ export default defineVxeComponent({
5986
6078
  clearSortByEvent (evnt, fieldOrColumn) {
5987
6079
  const { tableFullColumn } = internalData
5988
6080
  const sortOpts = computeSortOpts.value
6081
+ const { multiple } = sortOpts
5989
6082
  const sortCols: VxeTableDefines.ColumnInfo[] = []
5990
6083
  let column: VxeTableDefines.ColumnInfo<any> | null = null
5991
6084
  if (evnt) {
@@ -6005,11 +6098,18 @@ export default defineVxeComponent({
6005
6098
  if (!sortOpts.remote) {
6006
6099
  $xeTable.handleTableData(true)
6007
6100
  }
6008
- if (sortCols.length) {
6101
+
6102
+ if (!multiple) {
6103
+ column = sortCols[0]
6104
+ }
6105
+
6106
+ if (column) {
6107
+ $xeTable.handleColumnSortEvent(evnt, column)
6108
+ }
6109
+
6110
+ if (multiple && sortCols.length) {
6009
6111
  const params = { $table: $xeTable, $event: evnt, cols: sortCols, sortList: [] }
6010
6112
  dispatchEvent('clear-all-sort', params, evnt)
6011
- } else if (column) {
6012
- $xeTable.handleColumnSortEvent(evnt, column)
6013
6113
  }
6014
6114
  }
6015
6115
  return nextTick().then(() => {
@@ -6040,18 +6140,11 @@ export default defineVxeComponent({
6040
6140
  }
6041
6141
  return sortList
6042
6142
  },
6043
- setFilterByEvent (evnt, fieldOrColumn, options, isUpdate) {
6044
- const { filterStore } = reactData
6143
+ setFilterByEvent (evnt, fieldOrColumn, options) {
6045
6144
  const column = handleFieldOrColumn($xeTable, fieldOrColumn)
6046
6145
  if (column && column.filters) {
6047
6146
  column.filters = toFilters(options || [])
6048
- if (isUpdate) {
6049
- return $xeTable.handleColumnConfirmFilter(column, evnt)
6050
- } else {
6051
- if (filterStore.visible) {
6052
- $xeTable.handleFilterOptions(column)
6053
- }
6054
- }
6147
+ return $xeTable.handleColumnConfirmFilter(column, evnt)
6055
6148
  }
6056
6149
  return nextTick()
6057
6150
  },
@@ -6095,6 +6188,7 @@ export default defineVxeComponent({
6095
6188
  const { filterStore } = reactData
6096
6189
  const { tableFullColumn } = internalData
6097
6190
  const filterOpts = computeFilterOpts.value
6191
+ const { multiple } = filterOpts
6098
6192
  const filterCols: VxeTableDefines.ColumnInfo[] = []
6099
6193
  let column: VxeTableDefines.ColumnInfo<any> | null = null
6100
6194
  if (fieldOrColumn) {
@@ -6117,19 +6211,49 @@ export default defineVxeComponent({
6117
6211
  style: null,
6118
6212
  options: [],
6119
6213
  column: null,
6120
- multiple: false,
6214
+ multiple: false, // 选项是覅多选
6121
6215
  visible: false
6122
6216
  })
6123
6217
  }
6218
+
6124
6219
  if (!filterOpts.remote) {
6125
6220
  $xeTable.updateData()
6126
6221
  }
6127
- if (filterCols.length) {
6222
+
6223
+ if (!multiple) {
6224
+ column = filterCols[0]
6225
+ }
6226
+
6227
+ if (column) {
6228
+ const filterList = () => $xeTable.getCheckedFilters()
6229
+ const values: any[] = []
6230
+ const datas: any[] = []
6231
+ column.filters.forEach((item: any) => {
6232
+ if (item.checked) {
6233
+ values.push(item.value)
6234
+ datas.push(item.data)
6235
+ }
6236
+ })
6237
+ const params = {
6238
+ $table: $xeTable,
6239
+ $event: evnt as Event,
6240
+ column,
6241
+ field: column.field,
6242
+ property: column.field,
6243
+ values,
6244
+ datas,
6245
+ filters: filterList,
6246
+ filterList
6247
+ }
6248
+ $xeTable.dispatchEvent('filter-change', params, evnt)
6249
+ $xeTable.dispatchEvent('clear-filter', params, evnt)
6250
+ }
6251
+
6252
+ if (multiple && filterCols.length) {
6128
6253
  const params = { $table: $xeTable, $event: evnt, cols: filterCols, filterList: [] }
6129
6254
  dispatchEvent('clear-all-filter', params, evnt)
6130
- } else if (column) {
6131
- $xeTable.dispatchEvent('clear-filter', { filterList: () => $xeTable.getCheckedFilters() }, evnt)
6132
6255
  }
6256
+
6133
6257
  return nextTick()
6134
6258
  },
6135
6259
  /**
@@ -6884,7 +7008,8 @@ export default defineVxeComponent({
6884
7008
  getCustomStoreData () {
6885
7009
  const { id } = props
6886
7010
  const customOpts = computeCustomOpts.value
6887
- const { collectColumn } = internalData
7011
+ const { isRowGroupStatus, rowGroupList } = reactData
7012
+ const { fullColumnFieldData, collectColumn } = internalData
6888
7013
  const { storage, checkMethod, storeOptions } = customOpts
6889
7014
  const isAllCustom = storage === true
6890
7015
  const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {}, storeOptions)
@@ -6892,17 +7017,20 @@ export default defineVxeComponent({
6892
7017
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
6893
7018
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
6894
7019
  const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom)
7020
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom)
6895
7021
  const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom)
6896
7022
  const resizableData: Record<string, number> = {}
6897
- const sortData: Record<string, number> = {}
7023
+ const sortData: VxeTableDefines.CustomSortStoreObj[] = []
6898
7024
  const visibleData: Record<string, boolean> = {}
6899
7025
  const fixedData: Record<string, VxeColumnPropTypes.Fixed> = {}
7026
+ const aggGroupData: Record<string, boolean> = {}
6900
7027
  const aggFuncData: Record<string, VxeColumnPropTypes.AggFunc> = {}
6901
7028
  const storeData: VxeTableDefines.CustomStoreData = {
6902
7029
  resizableData: undefined,
6903
7030
  sortData: undefined,
6904
7031
  visibleData: undefined,
6905
7032
  fixedData: undefined,
7033
+ aggGroupData: undefined,
6906
7034
  aggFuncData: undefined
6907
7035
  }
6908
7036
  if (!id) {
@@ -6916,19 +7044,36 @@ export default defineVxeComponent({
6916
7044
  let hasFixed = 0
6917
7045
  let hasVisible = 0
6918
7046
  let hasAggFunc = 0
7047
+ const sortMaps: Record<string, VxeTableDefines.CustomSortStoreObj> = {}
6919
7048
  XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
6920
7049
  const colKey = column.getKey()
6921
7050
  if (!colKey) {
6922
7051
  errLog('vxe.error.reqProp', [`${column.getTitle() || column.type || ''} -> column.field=?`])
6923
7052
  return
6924
7053
  }
6925
- // 只支持一级
6926
- if (!parentColumn) {
7054
+ if (parentColumn) {
6927
7055
  if (isCustomSort) {
7056
+ const pColKey = parentColumn.getKey()
7057
+ const psObj = sortMaps[pColKey]
6928
7058
  hasSort = 1
6929
- sortData[colKey] = column.renderSortNumber
7059
+ if (psObj) {
7060
+ const sObj = { k: colKey }
7061
+ sortMaps[colKey] = sObj
7062
+ if (!psObj.c) {
7063
+ psObj.c = []
7064
+ }
7065
+ psObj.c.push(sObj)
7066
+ }
6930
7067
  }
6931
- if (isCustomFixed && column.fixed !== column.defaultFixed) {
7068
+ } else {
7069
+ if (isCustomSort) {
7070
+ hasSort = 1
7071
+ const sObj = { k: colKey }
7072
+ sortMaps[colKey] = sObj
7073
+ sortData.push(sObj)
7074
+ }
7075
+ // 只支持一级
7076
+ if (isCustomFixed && (column.fixed || '') !== (column.defaultFixed || '')) {
6932
7077
  hasFixed = 1
6933
7078
  fixedData[colKey] = column.fixed
6934
7079
  }
@@ -6946,7 +7091,7 @@ export default defineVxeComponent({
6946
7091
  visibleData[colKey] = true
6947
7092
  }
6948
7093
  }
6949
- if (isCustomAggFunc && column.aggFunc !== column.defaultAggFunc) {
7094
+ if (isCustomAggFunc && (column.aggFunc || '') !== (column.defaultAggFunc || '')) {
6950
7095
  hasAggFunc = 1
6951
7096
  aggFuncData[colKey] = column.aggFunc
6952
7097
  }
@@ -6963,6 +7108,15 @@ export default defineVxeComponent({
6963
7108
  if (hasVisible) {
6964
7109
  storeData.visibleData = visibleData
6965
7110
  }
7111
+ if (isCustomAggGroup && isRowGroupStatus) {
7112
+ rowGroupList.forEach(aggConf => {
7113
+ const colRest = fullColumnFieldData[aggConf.field]
7114
+ if (colRest) {
7115
+ aggGroupData[colRest.column.getKey()] = true
7116
+ }
7117
+ })
7118
+ storeData.aggGroupData = aggGroupData
7119
+ }
6966
7120
  if (hasAggFunc) {
6967
7121
  storeData.aggFuncData = aggFuncData
6968
7122
  }
@@ -7931,7 +8085,7 @@ export default defineVxeComponent({
7931
8085
  const handleRowCache = (row: any, index: number, items: any, currIndex: number, parentRow: any, rowid: string, level: number, seq: string | number) => {
7932
8086
  let rowRest = fullAllDataRowIdMaps[rowid]
7933
8087
  if (!rowRest) {
7934
- rowRest = { row, rowid, seq, index: -1, _index: -1, $index: -1, treeIndex: index, items, parent: parentRow, level, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
8088
+ 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 }
7935
8089
  fullDataRowIdMaps[rowid] = rowRest
7936
8090
  fullAllDataRowIdMaps[rowid] = rowRest
7937
8091
  }
@@ -8397,22 +8551,25 @@ export default defineVxeComponent({
8397
8551
  const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
8398
8552
  const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
8399
8553
  const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom)
8554
+ const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom)
8400
8555
  const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom)
8401
8556
  if (type !== 'reset') {
8402
8557
  // fix:修复拖动列宽,重置按钮无法点击的问题
8403
8558
  reactData.isCustomStatus = true
8404
8559
  }
8405
- if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort || isCustomAggFunc)) {
8560
+ if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort || isCustomAggGroup || isCustomAggFunc)) {
8406
8561
  if (!tableId) {
8407
8562
  errLog('vxe.error.reqProp', ['id'])
8408
8563
  return nextTick()
8409
8564
  }
8410
- const storeData = type === 'reset'
8565
+ const storeData: VxeTableDefines.CustomStoreData = type === 'reset'
8411
8566
  ? {
8412
8567
  resizableData: {},
8413
- sortData: {},
8568
+ sortData: [],
8414
8569
  visibleData: {},
8415
- fixedData: {}
8570
+ fixedData: {},
8571
+ aggGroupData: {},
8572
+ aggFuncData: {}
8416
8573
  }
8417
8574
  : tableMethods.getCustomStoreData()
8418
8575
  if (updateStore) {
@@ -11219,15 +11376,16 @@ export default defineVxeComponent({
11219
11376
  let rowIndex = -1
11220
11377
  let $rowIndex = -1
11221
11378
  if (rowRest) {
11379
+ rowIndex = rowRest.index
11380
+ $rowIndex = rowRest.$index
11381
+ _rowIndex = rowRest._index
11222
11382
  rowLevel = rowRest.level
11383
+ seq = rowRest.seq
11223
11384
  if (isRowGroupStatus || (treeConfig && transform && seqMode === 'increasing')) {
11224
11385
  seq = rowRest._index + 1
11225
- } else {
11226
- seq = rowRest.seq
11386
+ } else if ((treeConfig && seqMode === 'fixed')) {
11387
+ seq = rowRest._tIndex + 1
11227
11388
  }
11228
- rowIndex = rowRest.index
11229
- $rowIndex = rowRest.$index
11230
- _rowIndex = rowRest._index
11231
11389
  }
11232
11390
  if (expandHeight) {
11233
11391
  cellStyle.height = `${expandHeight}px`
@@ -11720,7 +11878,7 @@ export default defineVxeComponent({
11720
11878
  staticColumnFlag.value++
11721
11879
  })
11722
11880
  watch(staticColumnFlag, () => {
11723
- handleColumn(XEUtils.clone(reactData.staticColumns))
11881
+ nextTick(() => handleInitColumn(XEUtils.clone(reactData.staticColumns)))
11724
11882
  })
11725
11883
 
11726
11884
  const tableColumnFlag = ref(0)