vxe-table 4.15.0-beta.8 → 4.15.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.
- package/es/grid/src/grid.js +57 -9
- package/es/style.css +1 -1
- package/es/table/module/custom/hook.js +22 -14
- package/es/table/module/edit/hook.js +5 -5
- package/es/table/src/body.js +7 -6
- package/es/table/src/cell.js +5 -5
- package/es/table/src/columnInfo.js +2 -0
- package/es/table/src/table.js +204 -80
- package/es/table/src/util.js +9 -0
- package/es/ui/index.js +2 -1
- package/es/ui/src/log.js +1 -1
- package/lib/grid/src/grid.js +67 -9
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/index.umd.js +148 -58
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/module/custom/hook.js +25 -13
- package/lib/table/module/custom/hook.min.js +1 -1
- package/lib/table/module/edit/hook.js +5 -0
- package/lib/table/module/edit/hook.min.js +1 -1
- package/lib/table/src/body.js +7 -6
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +5 -4
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/columnInfo.js +2 -0
- package/lib/table/src/columnInfo.min.js +1 -1
- package/lib/table/src/table.js +24 -24
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +10 -0
- package/lib/table/src/util.min.js +1 -1
- package/lib/ui/index.js +2 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +2 -2
- package/packages/grid/src/grid.ts +62 -9
- package/packages/table/module/custom/hook.ts +21 -13
- package/packages/table/module/edit/hook.ts +5 -5
- package/packages/table/src/body.ts +7 -6
- package/packages/table/src/cell.ts +5 -5
- package/packages/table/src/columnInfo.ts +3 -0
- package/packages/table/src/table.ts +217 -80
- package/packages/table/src/util.ts +10 -0
- package/packages/ui/index.ts +1 -0
- /package/es/{iconfont.1753445535983.ttf → iconfont.1753928735749.ttf} +0 -0
- /package/es/{iconfont.1753445535983.woff → iconfont.1753928735749.woff} +0 -0
- /package/es/{iconfont.1753445535983.woff2 → iconfont.1753928735749.woff2} +0 -0
- /package/lib/{iconfont.1753445535983.ttf → iconfont.1753928735749.ttf} +0 -0
- /package/lib/{iconfont.1753445535983.woff → iconfont.1753928735749.woff} +0 -0
- /package/lib/{iconfont.1753445535983.woff2 → iconfont.1753928735749.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'
|
|
@@ -1443,16 +1443,23 @@ export default defineVxeComponent({
|
|
|
1443
1443
|
}
|
|
1444
1444
|
|
|
1445
1445
|
const handleSortEvent = (evnt: Event | null, sortConfs: VxeTableDefines.SortConfs | VxeTableDefines.SortConfs[], isUpdate?: boolean) => {
|
|
1446
|
+
const { tableFullColumn } = internalData
|
|
1446
1447
|
const sortOpts = computeSortOpts.value
|
|
1447
1448
|
const { multiple, remote, orders } = sortOpts
|
|
1448
1449
|
if (!XEUtils.isArray(sortConfs)) {
|
|
1449
1450
|
sortConfs = [sortConfs]
|
|
1450
1451
|
}
|
|
1451
1452
|
if (sortConfs && sortConfs.length) {
|
|
1453
|
+
const orderActiveMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
|
|
1452
1454
|
if (!multiple) {
|
|
1453
1455
|
sortConfs = [sortConfs[0]]
|
|
1454
|
-
|
|
1456
|
+
tableFullColumn.forEach((column) => {
|
|
1457
|
+
if (column.order) {
|
|
1458
|
+
orderActiveMaps[column.id] = column
|
|
1459
|
+
}
|
|
1460
|
+
})
|
|
1455
1461
|
}
|
|
1462
|
+
const sortColMpps: Record<string, VxeTableDefines.ColumnInfo> = {}
|
|
1456
1463
|
let firstColumn: any = null
|
|
1457
1464
|
sortConfs.forEach((confs: any, index: number) => {
|
|
1458
1465
|
let { field, order } = confs
|
|
@@ -1471,8 +1478,16 @@ export default defineVxeComponent({
|
|
|
1471
1478
|
column.order = order
|
|
1472
1479
|
}
|
|
1473
1480
|
column.sortTime = Date.now() + index
|
|
1481
|
+
sortColMpps[column.id] = column
|
|
1474
1482
|
}
|
|
1475
1483
|
})
|
|
1484
|
+
if (!multiple) {
|
|
1485
|
+
XEUtils.each(orderActiveMaps, (oaCol: VxeTableDefines.ColumnInfo, oaId) => {
|
|
1486
|
+
if (!sortColMpps[oaId]) {
|
|
1487
|
+
oaCol.order = null
|
|
1488
|
+
}
|
|
1489
|
+
})
|
|
1490
|
+
}
|
|
1476
1491
|
if (isUpdate) {
|
|
1477
1492
|
if (!remote) {
|
|
1478
1493
|
$xeTable.handleTableData(true)
|
|
@@ -1518,35 +1533,92 @@ export default defineVxeComponent({
|
|
|
1518
1533
|
}
|
|
1519
1534
|
|
|
1520
1535
|
const handleCustomRestore = (storeData: VxeTableDefines.CustomStoreData) => {
|
|
1521
|
-
|
|
1522
|
-
const {
|
|
1523
|
-
|
|
1536
|
+
const { aggregateConfig, rowGroupConfig } = props
|
|
1537
|
+
const { collectColumn } = internalData
|
|
1538
|
+
const customOpts = computeCustomOpts.value
|
|
1539
|
+
const { storage, storeOptions } = customOpts
|
|
1540
|
+
const isAllCustom = storage === true
|
|
1541
|
+
const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {}, storeOptions)
|
|
1542
|
+
const isCustomResizable = hangleStorageDefaultValue(storageOpts.resizable, isAllCustom)
|
|
1543
|
+
const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
|
|
1544
|
+
const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
|
|
1545
|
+
const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom)
|
|
1546
|
+
const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom)
|
|
1547
|
+
const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom)
|
|
1548
|
+
let { resizableData, sortData, visibleData, fixedData, aggGroupData, aggFuncData } = storeData
|
|
1524
1549
|
// 处理还原
|
|
1525
|
-
if (resizableData || sortData || visibleData || fixedData) {
|
|
1550
|
+
if ((isCustomResizable && resizableData) || (isCustomSort && sortData) || (isCustomVisible && visibleData) || (isCustomFixed && fixedData) || (isCustomAggGroup && aggGroupData) || (isCustomAggFunc && aggFuncData)) {
|
|
1551
|
+
const sortColMaps: Record<string, {
|
|
1552
|
+
key: string
|
|
1553
|
+
sNum: number
|
|
1554
|
+
pKey: string | null
|
|
1555
|
+
}> = {}
|
|
1556
|
+
if (isCustomSort && sortData) {
|
|
1557
|
+
// 转换兼容老版本数据,即将废弃兼容
|
|
1558
|
+
if (!XEUtils.isArray(sortData)) {
|
|
1559
|
+
const sortRests: {key: string, index: number}[] = []
|
|
1560
|
+
XEUtils.each(sortData, (index: number, colKey: string) => {
|
|
1561
|
+
sortRests.push({ key: colKey, index })
|
|
1562
|
+
})
|
|
1563
|
+
sortData = XEUtils.orderBy(sortRests, { field: 'index', order: 'asc' }).map(item => ({ k: item.key }))
|
|
1564
|
+
}
|
|
1565
|
+
let colNum = 1
|
|
1566
|
+
XEUtils.eachTree(sortData, (sObj, index, sOjs, path, pSObj) => {
|
|
1567
|
+
sortColMaps[sObj.k] = {
|
|
1568
|
+
key: sObj.k,
|
|
1569
|
+
sNum: colNum++,
|
|
1570
|
+
pKey: pSObj ? pSObj.k : null
|
|
1571
|
+
}
|
|
1572
|
+
}, { children: 'c' })
|
|
1573
|
+
}
|
|
1574
|
+
const colKeyMaps: Record<string, VxeTableDefines.ColumnInfo> = {}
|
|
1575
|
+
const allCols: VxeTableDefines.ColumnInfo[] = []
|
|
1576
|
+
const aggGroupConfs: VxeTableDefines.RowGroupItem[] = []
|
|
1526
1577
|
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
1527
1578
|
const colKey = column.getKey()
|
|
1528
1579
|
// 支持一级
|
|
1529
1580
|
if (!parentColumn) {
|
|
1530
|
-
if (fixedData && fixedData[colKey] !== undefined) {
|
|
1581
|
+
if (isCustomFixed && fixedData && fixedData[colKey] !== undefined) {
|
|
1531
1582
|
column.fixed = fixedData[colKey]
|
|
1532
1583
|
}
|
|
1533
|
-
if (sortData && XEUtils.isNumber(sortData[colKey])) {
|
|
1534
|
-
hasCustomSort = true
|
|
1535
|
-
column.renderSortNumber = sortData[colKey]
|
|
1536
|
-
}
|
|
1537
1584
|
}
|
|
1538
|
-
if (resizableData && XEUtils.isNumber(resizableData[colKey])) {
|
|
1585
|
+
if (isCustomResizable && resizableData && XEUtils.isNumber(resizableData[colKey])) {
|
|
1539
1586
|
column.resizeWidth = resizableData[colKey]
|
|
1540
1587
|
}
|
|
1541
|
-
if (visibleData && XEUtils.isBoolean(visibleData[colKey])) {
|
|
1588
|
+
if (isCustomVisible && visibleData && XEUtils.isBoolean(visibleData[colKey])) {
|
|
1542
1589
|
column.visible = visibleData[colKey]
|
|
1543
1590
|
}
|
|
1591
|
+
if (isCustomAggFunc && aggFuncData && (aggregateConfig || rowGroupConfig) && aggFuncData[colKey]) {
|
|
1592
|
+
column.aggFunc = aggFuncData[colKey]
|
|
1593
|
+
}
|
|
1594
|
+
if (isCustomAggGroup && aggGroupData && aggGroupData[colKey]) {
|
|
1595
|
+
aggGroupConfs.push({ field: column.field })
|
|
1596
|
+
}
|
|
1597
|
+
colKeyMaps[colKey] = column
|
|
1598
|
+
allCols.push(column)
|
|
1544
1599
|
})
|
|
1600
|
+
if ((aggregateConfig || rowGroupConfig) && aggGroupConfs.length) {
|
|
1601
|
+
const groupRest = handleGroupData(internalData.tableFullData, aggGroupConfs)
|
|
1602
|
+
internalData.tableFullTreeData = []
|
|
1603
|
+
internalData.tableFullGroupData = groupRest.treeData
|
|
1604
|
+
reactData.isRowGroupStatus = true
|
|
1605
|
+
reactData.rowGroupList = aggGroupConfs
|
|
1606
|
+
$xeTable.cacheRowMap(false)
|
|
1607
|
+
}
|
|
1545
1608
|
// 如果自定义了顺序
|
|
1546
|
-
if (
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1609
|
+
if (isCustomSort && sortData) {
|
|
1610
|
+
allCols.forEach(column => {
|
|
1611
|
+
const colKey = column.getKey()
|
|
1612
|
+
const scItem = sortColMaps[colKey]
|
|
1613
|
+
if (scItem) {
|
|
1614
|
+
const parentColumn = scItem.pKey ? colKeyMaps[scItem.pKey] : null
|
|
1615
|
+
column.parentId = parentColumn ? parentColumn.id : null
|
|
1616
|
+
column.renderSortNumber = scItem.sNum
|
|
1617
|
+
}
|
|
1618
|
+
})
|
|
1619
|
+
const newCollectCols = XEUtils.toArrayTree(XEUtils.orderBy(allCols, 'renderSortNumber'), { key: 'id', parentKey: 'parentId', children: 'children' })
|
|
1620
|
+
internalData.collectColumn = newCollectCols
|
|
1621
|
+
internalData.tableFullColumn = getColumnList(newCollectCols)
|
|
1550
1622
|
}
|
|
1551
1623
|
reactData.isCustomStatus = true
|
|
1552
1624
|
} else {
|
|
@@ -1568,8 +1640,9 @@ export default defineVxeComponent({
|
|
|
1568
1640
|
const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
|
|
1569
1641
|
const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
|
|
1570
1642
|
const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom)
|
|
1643
|
+
const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom)
|
|
1571
1644
|
const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom)
|
|
1572
|
-
if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort || isCustomAggFunc)) {
|
|
1645
|
+
if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort || isCustomAggGroup || isCustomAggFunc)) {
|
|
1573
1646
|
if (!tableId) {
|
|
1574
1647
|
errLog('vxe.error.reqProp', ['id'])
|
|
1575
1648
|
return
|
|
@@ -1905,7 +1978,7 @@ export default defineVxeComponent({
|
|
|
1905
1978
|
const { fullAllDataRowIdData } = internalData
|
|
1906
1979
|
const defaultRowHeight = computeDefaultRowHeight.value
|
|
1907
1980
|
const el = refElem.value
|
|
1908
|
-
if (!isAllOverflow && scrollYLoad && el) {
|
|
1981
|
+
if (!isAllOverflow && (scrollYLoad || scrollXLoad) && el) {
|
|
1909
1982
|
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
1910
1983
|
el.setAttribute('data-calc-row', 'Y')
|
|
1911
1984
|
tableData.forEach(row => {
|
|
@@ -1956,7 +2029,7 @@ export default defineVxeComponent({
|
|
|
1956
2029
|
}
|
|
1957
2030
|
rowRest._index = index
|
|
1958
2031
|
} 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 }
|
|
2032
|
+
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
2033
|
fullAllDataRowIdData[rowid] = rest
|
|
1961
2034
|
fullDataRowIdData[rowid] = rest
|
|
1962
2035
|
}
|
|
@@ -1977,6 +2050,7 @@ export default defineVxeComponent({
|
|
|
1977
2050
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
1978
2051
|
const fullMaps: Record<string, any> = {}
|
|
1979
2052
|
if (treeConfig) {
|
|
2053
|
+
let _treeIndex = 0
|
|
1980
2054
|
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
1981
2055
|
XEUtils.eachTree(afterTreeFullData, (row, index, items, path) => {
|
|
1982
2056
|
const rowid = handleGetRowId(row)
|
|
@@ -1985,11 +2059,13 @@ export default defineVxeComponent({
|
|
|
1985
2059
|
if (rowRest) {
|
|
1986
2060
|
rowRest.seq = seq
|
|
1987
2061
|
rowRest.treeIndex = index
|
|
2062
|
+
rowRest._tIndex = _treeIndex
|
|
1988
2063
|
} 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 }
|
|
2064
|
+
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
2065
|
fullAllDataRowIdData[rowid] = rest
|
|
1991
2066
|
fullDataRowIdData[rowid] = rest
|
|
1992
2067
|
}
|
|
2068
|
+
_treeIndex++
|
|
1993
2069
|
fullMaps[rowid] = row
|
|
1994
2070
|
}, { children: transform ? treeOpts.mapChildrenField : childrenField })
|
|
1995
2071
|
if (transform) {
|
|
@@ -3238,18 +3314,18 @@ export default defineVxeComponent({
|
|
|
3238
3314
|
}
|
|
3239
3315
|
|
|
3240
3316
|
const handleUpdateRowGroup = (groupFields?: string[]) => {
|
|
3241
|
-
const
|
|
3242
|
-
const
|
|
3317
|
+
const aggGroupFields: string[] = []
|
|
3318
|
+
const aggGroupConfs: { field: string }[] = []
|
|
3243
3319
|
if (groupFields) {
|
|
3244
3320
|
(XEUtils.isArray(groupFields) ? groupFields : [groupFields]).forEach(field => {
|
|
3245
|
-
|
|
3246
|
-
|
|
3321
|
+
aggGroupFields.push(field)
|
|
3322
|
+
aggGroupConfs.push({
|
|
3247
3323
|
field
|
|
3248
3324
|
})
|
|
3249
3325
|
})
|
|
3250
3326
|
}
|
|
3251
|
-
reactData.rowGroupList =
|
|
3252
|
-
reactData.aggHandleFields =
|
|
3327
|
+
reactData.rowGroupList = aggGroupConfs
|
|
3328
|
+
reactData.aggHandleFields = aggGroupFields
|
|
3253
3329
|
handleUpdateAggValues()
|
|
3254
3330
|
}
|
|
3255
3331
|
|
|
@@ -3621,15 +3697,6 @@ export default defineVxeComponent({
|
|
|
3621
3697
|
$xeTable.closeTooltip()
|
|
3622
3698
|
}
|
|
3623
3699
|
|
|
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
3700
|
const parseColumns = (isReset: boolean) => {
|
|
3634
3701
|
// const { showOverflow } = props
|
|
3635
3702
|
// const rowOpts = computeRowOpts.value
|
|
@@ -3649,7 +3716,7 @@ export default defineVxeComponent({
|
|
|
3649
3716
|
if (parentColumn && parentColumn.fixed) {
|
|
3650
3717
|
column.fixed = parentColumn.fixed
|
|
3651
3718
|
}
|
|
3652
|
-
if (parentColumn && column.fixed !== parentColumn.fixed) {
|
|
3719
|
+
if (parentColumn && (column.fixed || '') !== (parentColumn.fixed || '')) {
|
|
3653
3720
|
errLog('vxe.error.groupFixed')
|
|
3654
3721
|
}
|
|
3655
3722
|
if (isColGroup) {
|
|
@@ -3753,22 +3820,26 @@ export default defineVxeComponent({
|
|
|
3753
3820
|
return $xeTable.updateFooter()
|
|
3754
3821
|
}
|
|
3755
3822
|
|
|
3756
|
-
const
|
|
3823
|
+
const initColumnHierarchy = () => {
|
|
3757
3824
|
const { collectColumn } = internalData
|
|
3758
|
-
|
|
3759
|
-
|
|
3825
|
+
let sortIndex = 1
|
|
3826
|
+
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
3827
|
+
const parentId = parentColumn ? parentColumn.id : null
|
|
3828
|
+
column.parentId = parentId
|
|
3829
|
+
column.defaultParentId = parentId
|
|
3760
3830
|
column.sortNumber = sortIndex
|
|
3761
3831
|
column.renderSortNumber = sortIndex
|
|
3832
|
+
sortIndex++
|
|
3762
3833
|
})
|
|
3763
3834
|
}
|
|
3764
3835
|
|
|
3765
|
-
const
|
|
3836
|
+
const handleInitColumn = (collectColumn: VxeTableDefines.ColumnInfo[]) => {
|
|
3766
3837
|
const expandOpts = computeExpandOpts.value
|
|
3767
3838
|
internalData.collectColumn = collectColumn
|
|
3768
3839
|
const tableFullColumn = getColumnList(collectColumn)
|
|
3769
3840
|
internalData.tableFullColumn = tableFullColumn
|
|
3770
3841
|
reactData.isColLoading = true
|
|
3771
|
-
|
|
3842
|
+
initColumnHierarchy()
|
|
3772
3843
|
return Promise.resolve(
|
|
3773
3844
|
restoreCustomStorage()
|
|
3774
3845
|
).then(() => {
|
|
@@ -4491,7 +4562,7 @@ export default defineVxeComponent({
|
|
|
4491
4562
|
XEUtils.eachTree(rows, (childRow, index, items, path, parentItem, nodes) => {
|
|
4492
4563
|
const rowid = getRowid($xeTable, childRow)
|
|
4493
4564
|
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 }
|
|
4565
|
+
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
4566
|
fullDataRowIdData[rowid] = rest
|
|
4496
4567
|
fullAllDataRowIdData[rowid] = rest
|
|
4497
4568
|
}, { children: childrenField })
|
|
@@ -4511,7 +4582,7 @@ export default defineVxeComponent({
|
|
|
4511
4582
|
loadColumn (columns) {
|
|
4512
4583
|
const { lastScrollLeft, lastScrollTop } = internalData
|
|
4513
4584
|
const collectColumn = XEUtils.mapTree(columns, column => reactive(Cell.createColumn($xeTable, column)))
|
|
4514
|
-
return
|
|
4585
|
+
return handleInitColumn(collectColumn).then(() => {
|
|
4515
4586
|
let targetScrollLeft = lastScrollLeft
|
|
4516
4587
|
let targetScrollTop = lastScrollTop
|
|
4517
4588
|
const virtualXOpts = computeVirtualXOpts.value
|
|
@@ -5957,8 +6028,8 @@ export default defineVxeComponent({
|
|
|
5957
6028
|
setSort (sortConfs, isUpdate) {
|
|
5958
6029
|
return handleSortEvent(null, sortConfs, isUpdate)
|
|
5959
6030
|
},
|
|
5960
|
-
setSortByEvent (evnt, sortConfs
|
|
5961
|
-
return handleSortEvent(evnt, sortConfs,
|
|
6031
|
+
setSortByEvent (evnt, sortConfs) {
|
|
6032
|
+
return handleSortEvent(evnt, sortConfs, true)
|
|
5962
6033
|
},
|
|
5963
6034
|
/**
|
|
5964
6035
|
* 清空指定列的排序条件
|
|
@@ -5986,6 +6057,7 @@ export default defineVxeComponent({
|
|
|
5986
6057
|
clearSortByEvent (evnt, fieldOrColumn) {
|
|
5987
6058
|
const { tableFullColumn } = internalData
|
|
5988
6059
|
const sortOpts = computeSortOpts.value
|
|
6060
|
+
const { multiple } = sortOpts
|
|
5989
6061
|
const sortCols: VxeTableDefines.ColumnInfo[] = []
|
|
5990
6062
|
let column: VxeTableDefines.ColumnInfo<any> | null = null
|
|
5991
6063
|
if (evnt) {
|
|
@@ -6005,11 +6077,18 @@ export default defineVxeComponent({
|
|
|
6005
6077
|
if (!sortOpts.remote) {
|
|
6006
6078
|
$xeTable.handleTableData(true)
|
|
6007
6079
|
}
|
|
6008
|
-
|
|
6080
|
+
|
|
6081
|
+
if (!multiple) {
|
|
6082
|
+
column = sortCols[0]
|
|
6083
|
+
}
|
|
6084
|
+
|
|
6085
|
+
if (column) {
|
|
6086
|
+
$xeTable.handleColumnSortEvent(evnt, column)
|
|
6087
|
+
}
|
|
6088
|
+
|
|
6089
|
+
if (multiple && sortCols.length) {
|
|
6009
6090
|
const params = { $table: $xeTable, $event: evnt, cols: sortCols, sortList: [] }
|
|
6010
6091
|
dispatchEvent('clear-all-sort', params, evnt)
|
|
6011
|
-
} else if (column) {
|
|
6012
|
-
$xeTable.handleColumnSortEvent(evnt, column)
|
|
6013
6092
|
}
|
|
6014
6093
|
}
|
|
6015
6094
|
return nextTick().then(() => {
|
|
@@ -6040,18 +6119,11 @@ export default defineVxeComponent({
|
|
|
6040
6119
|
}
|
|
6041
6120
|
return sortList
|
|
6042
6121
|
},
|
|
6043
|
-
setFilterByEvent (evnt, fieldOrColumn, options
|
|
6044
|
-
const { filterStore } = reactData
|
|
6122
|
+
setFilterByEvent (evnt, fieldOrColumn, options) {
|
|
6045
6123
|
const column = handleFieldOrColumn($xeTable, fieldOrColumn)
|
|
6046
6124
|
if (column && column.filters) {
|
|
6047
6125
|
column.filters = toFilters(options || [])
|
|
6048
|
-
|
|
6049
|
-
return $xeTable.handleColumnConfirmFilter(column, evnt)
|
|
6050
|
-
} else {
|
|
6051
|
-
if (filterStore.visible) {
|
|
6052
|
-
$xeTable.handleFilterOptions(column)
|
|
6053
|
-
}
|
|
6054
|
-
}
|
|
6126
|
+
return $xeTable.handleColumnConfirmFilter(column, evnt)
|
|
6055
6127
|
}
|
|
6056
6128
|
return nextTick()
|
|
6057
6129
|
},
|
|
@@ -6095,6 +6167,7 @@ export default defineVxeComponent({
|
|
|
6095
6167
|
const { filterStore } = reactData
|
|
6096
6168
|
const { tableFullColumn } = internalData
|
|
6097
6169
|
const filterOpts = computeFilterOpts.value
|
|
6170
|
+
const { multiple } = filterOpts
|
|
6098
6171
|
const filterCols: VxeTableDefines.ColumnInfo[] = []
|
|
6099
6172
|
let column: VxeTableDefines.ColumnInfo<any> | null = null
|
|
6100
6173
|
if (fieldOrColumn) {
|
|
@@ -6117,19 +6190,49 @@ export default defineVxeComponent({
|
|
|
6117
6190
|
style: null,
|
|
6118
6191
|
options: [],
|
|
6119
6192
|
column: null,
|
|
6120
|
-
multiple: false,
|
|
6193
|
+
multiple: false, // 选项是覅多选
|
|
6121
6194
|
visible: false
|
|
6122
6195
|
})
|
|
6123
6196
|
}
|
|
6197
|
+
|
|
6124
6198
|
if (!filterOpts.remote) {
|
|
6125
6199
|
$xeTable.updateData()
|
|
6126
6200
|
}
|
|
6127
|
-
|
|
6201
|
+
|
|
6202
|
+
if (!multiple) {
|
|
6203
|
+
column = filterCols[0]
|
|
6204
|
+
}
|
|
6205
|
+
|
|
6206
|
+
if (column) {
|
|
6207
|
+
const filterList = () => $xeTable.getCheckedFilters()
|
|
6208
|
+
const values: any[] = []
|
|
6209
|
+
const datas: any[] = []
|
|
6210
|
+
column.filters.forEach((item: any) => {
|
|
6211
|
+
if (item.checked) {
|
|
6212
|
+
values.push(item.value)
|
|
6213
|
+
datas.push(item.data)
|
|
6214
|
+
}
|
|
6215
|
+
})
|
|
6216
|
+
const params = {
|
|
6217
|
+
$table: $xeTable,
|
|
6218
|
+
$event: evnt as Event,
|
|
6219
|
+
column,
|
|
6220
|
+
field: column.field,
|
|
6221
|
+
property: column.field,
|
|
6222
|
+
values,
|
|
6223
|
+
datas,
|
|
6224
|
+
filters: filterList,
|
|
6225
|
+
filterList
|
|
6226
|
+
}
|
|
6227
|
+
$xeTable.dispatchEvent('filter-change', params, evnt)
|
|
6228
|
+
$xeTable.dispatchEvent('clear-filter', params, evnt)
|
|
6229
|
+
}
|
|
6230
|
+
|
|
6231
|
+
if (multiple && filterCols.length) {
|
|
6128
6232
|
const params = { $table: $xeTable, $event: evnt, cols: filterCols, filterList: [] }
|
|
6129
6233
|
dispatchEvent('clear-all-filter', params, evnt)
|
|
6130
|
-
} else if (column) {
|
|
6131
|
-
$xeTable.dispatchEvent('clear-filter', { filterList: () => $xeTable.getCheckedFilters() }, evnt)
|
|
6132
6234
|
}
|
|
6235
|
+
|
|
6133
6236
|
return nextTick()
|
|
6134
6237
|
},
|
|
6135
6238
|
/**
|
|
@@ -6884,7 +6987,8 @@ export default defineVxeComponent({
|
|
|
6884
6987
|
getCustomStoreData () {
|
|
6885
6988
|
const { id } = props
|
|
6886
6989
|
const customOpts = computeCustomOpts.value
|
|
6887
|
-
const {
|
|
6990
|
+
const { isRowGroupStatus, rowGroupList } = reactData
|
|
6991
|
+
const { fullColumnFieldData, collectColumn } = internalData
|
|
6888
6992
|
const { storage, checkMethod, storeOptions } = customOpts
|
|
6889
6993
|
const isAllCustom = storage === true
|
|
6890
6994
|
const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {}, storeOptions)
|
|
@@ -6892,17 +6996,20 @@ export default defineVxeComponent({
|
|
|
6892
6996
|
const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
|
|
6893
6997
|
const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
|
|
6894
6998
|
const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom)
|
|
6999
|
+
const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom)
|
|
6895
7000
|
const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom)
|
|
6896
7001
|
const resizableData: Record<string, number> = {}
|
|
6897
|
-
const sortData:
|
|
7002
|
+
const sortData: VxeTableDefines.CustomSortStoreObj[] = []
|
|
6898
7003
|
const visibleData: Record<string, boolean> = {}
|
|
6899
7004
|
const fixedData: Record<string, VxeColumnPropTypes.Fixed> = {}
|
|
7005
|
+
const aggGroupData: Record<string, boolean> = {}
|
|
6900
7006
|
const aggFuncData: Record<string, VxeColumnPropTypes.AggFunc> = {}
|
|
6901
7007
|
const storeData: VxeTableDefines.CustomStoreData = {
|
|
6902
7008
|
resizableData: undefined,
|
|
6903
7009
|
sortData: undefined,
|
|
6904
7010
|
visibleData: undefined,
|
|
6905
7011
|
fixedData: undefined,
|
|
7012
|
+
aggGroupData: undefined,
|
|
6906
7013
|
aggFuncData: undefined
|
|
6907
7014
|
}
|
|
6908
7015
|
if (!id) {
|
|
@@ -6916,19 +7023,36 @@ export default defineVxeComponent({
|
|
|
6916
7023
|
let hasFixed = 0
|
|
6917
7024
|
let hasVisible = 0
|
|
6918
7025
|
let hasAggFunc = 0
|
|
7026
|
+
const sortMaps: Record<string, VxeTableDefines.CustomSortStoreObj> = {}
|
|
6919
7027
|
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
6920
7028
|
const colKey = column.getKey()
|
|
6921
7029
|
if (!colKey) {
|
|
6922
7030
|
errLog('vxe.error.reqProp', [`${column.getTitle() || column.type || ''} -> column.field=?`])
|
|
6923
7031
|
return
|
|
6924
7032
|
}
|
|
6925
|
-
|
|
6926
|
-
|
|
7033
|
+
if (parentColumn) {
|
|
7034
|
+
if (isCustomSort) {
|
|
7035
|
+
const pColKey = parentColumn.getKey()
|
|
7036
|
+
const psObj = sortMaps[pColKey]
|
|
7037
|
+
hasSort = 1
|
|
7038
|
+
if (psObj) {
|
|
7039
|
+
const sObj = { k: colKey }
|
|
7040
|
+
sortMaps[colKey] = sObj
|
|
7041
|
+
if (!psObj.c) {
|
|
7042
|
+
psObj.c = []
|
|
7043
|
+
}
|
|
7044
|
+
psObj.c.push(sObj)
|
|
7045
|
+
}
|
|
7046
|
+
}
|
|
7047
|
+
} else {
|
|
6927
7048
|
if (isCustomSort) {
|
|
6928
7049
|
hasSort = 1
|
|
6929
|
-
|
|
7050
|
+
const sObj = { k: colKey }
|
|
7051
|
+
sortMaps[colKey] = sObj
|
|
7052
|
+
sortData.push(sObj)
|
|
6930
7053
|
}
|
|
6931
|
-
|
|
7054
|
+
// 只支持一级
|
|
7055
|
+
if (isCustomFixed && (column.fixed || '') !== (column.defaultFixed || '')) {
|
|
6932
7056
|
hasFixed = 1
|
|
6933
7057
|
fixedData[colKey] = column.fixed
|
|
6934
7058
|
}
|
|
@@ -6946,7 +7070,7 @@ export default defineVxeComponent({
|
|
|
6946
7070
|
visibleData[colKey] = true
|
|
6947
7071
|
}
|
|
6948
7072
|
}
|
|
6949
|
-
if (isCustomAggFunc && column.aggFunc !== column.defaultAggFunc) {
|
|
7073
|
+
if (isCustomAggFunc && (column.aggFunc || '') !== (column.defaultAggFunc || '')) {
|
|
6950
7074
|
hasAggFunc = 1
|
|
6951
7075
|
aggFuncData[colKey] = column.aggFunc
|
|
6952
7076
|
}
|
|
@@ -6963,6 +7087,15 @@ export default defineVxeComponent({
|
|
|
6963
7087
|
if (hasVisible) {
|
|
6964
7088
|
storeData.visibleData = visibleData
|
|
6965
7089
|
}
|
|
7090
|
+
if (isCustomAggGroup && isRowGroupStatus) {
|
|
7091
|
+
rowGroupList.forEach(aggConf => {
|
|
7092
|
+
const colRest = fullColumnFieldData[aggConf.field]
|
|
7093
|
+
if (colRest) {
|
|
7094
|
+
aggGroupData[colRest.column.getKey()] = true
|
|
7095
|
+
}
|
|
7096
|
+
})
|
|
7097
|
+
storeData.aggGroupData = aggGroupData
|
|
7098
|
+
}
|
|
6966
7099
|
if (hasAggFunc) {
|
|
6967
7100
|
storeData.aggFuncData = aggFuncData
|
|
6968
7101
|
}
|
|
@@ -7931,7 +8064,7 @@ export default defineVxeComponent({
|
|
|
7931
8064
|
const handleRowCache = (row: any, index: number, items: any, currIndex: number, parentRow: any, rowid: string, level: number, seq: string | number) => {
|
|
7932
8065
|
let rowRest = fullAllDataRowIdMaps[rowid]
|
|
7933
8066
|
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 }
|
|
8067
|
+
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
8068
|
fullDataRowIdMaps[rowid] = rowRest
|
|
7936
8069
|
fullAllDataRowIdMaps[rowid] = rowRest
|
|
7937
8070
|
}
|
|
@@ -8397,22 +8530,25 @@ export default defineVxeComponent({
|
|
|
8397
8530
|
const isCustomVisible = hangleStorageDefaultValue(storageOpts.visible, isAllCustom)
|
|
8398
8531
|
const isCustomFixed = hangleStorageDefaultValue(storageOpts.fixed, isAllCustom)
|
|
8399
8532
|
const isCustomSort = hangleStorageDefaultValue(storageOpts.sort, isAllCustom)
|
|
8533
|
+
const isCustomAggGroup = hangleStorageDefaultValue(storageOpts.aggGroup, isAllCustom)
|
|
8400
8534
|
const isCustomAggFunc = hangleStorageDefaultValue(storageOpts.aggFunc, isAllCustom)
|
|
8401
8535
|
if (type !== 'reset') {
|
|
8402
8536
|
// fix:修复拖动列宽,重置按钮无法点击的问题
|
|
8403
8537
|
reactData.isCustomStatus = true
|
|
8404
8538
|
}
|
|
8405
|
-
if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort || isCustomAggFunc)) {
|
|
8539
|
+
if (storage && (customConfig ? isEnableConf(customOpts) : customOpts.enabled) && (isCustomResizable || isCustomVisible || isCustomFixed || isCustomSort || isCustomAggGroup || isCustomAggFunc)) {
|
|
8406
8540
|
if (!tableId) {
|
|
8407
8541
|
errLog('vxe.error.reqProp', ['id'])
|
|
8408
8542
|
return nextTick()
|
|
8409
8543
|
}
|
|
8410
|
-
const storeData = type === 'reset'
|
|
8544
|
+
const storeData: VxeTableDefines.CustomStoreData = type === 'reset'
|
|
8411
8545
|
? {
|
|
8412
8546
|
resizableData: {},
|
|
8413
|
-
sortData:
|
|
8547
|
+
sortData: [],
|
|
8414
8548
|
visibleData: {},
|
|
8415
|
-
fixedData: {}
|
|
8549
|
+
fixedData: {},
|
|
8550
|
+
aggGroupData: {},
|
|
8551
|
+
aggFuncData: {}
|
|
8416
8552
|
}
|
|
8417
8553
|
: tableMethods.getCustomStoreData()
|
|
8418
8554
|
if (updateStore) {
|
|
@@ -11219,15 +11355,16 @@ export default defineVxeComponent({
|
|
|
11219
11355
|
let rowIndex = -1
|
|
11220
11356
|
let $rowIndex = -1
|
|
11221
11357
|
if (rowRest) {
|
|
11358
|
+
rowIndex = rowRest.index
|
|
11359
|
+
$rowIndex = rowRest.$index
|
|
11360
|
+
_rowIndex = rowRest._index
|
|
11222
11361
|
rowLevel = rowRest.level
|
|
11362
|
+
seq = rowRest.seq
|
|
11223
11363
|
if (isRowGroupStatus || (treeConfig && transform && seqMode === 'increasing')) {
|
|
11224
11364
|
seq = rowRest._index + 1
|
|
11225
|
-
} else {
|
|
11226
|
-
seq = rowRest.
|
|
11365
|
+
} else if ((treeConfig && seqMode === 'fixed')) {
|
|
11366
|
+
seq = rowRest._tIndex + 1
|
|
11227
11367
|
}
|
|
11228
|
-
rowIndex = rowRest.index
|
|
11229
|
-
$rowIndex = rowRest.$index
|
|
11230
|
-
_rowIndex = rowRest._index
|
|
11231
11368
|
}
|
|
11232
11369
|
if (expandHeight) {
|
|
11233
11370
|
cellStyle.height = `${expandHeight}px`
|
|
@@ -11720,7 +11857,7 @@ export default defineVxeComponent({
|
|
|
11720
11857
|
staticColumnFlag.value++
|
|
11721
11858
|
})
|
|
11722
11859
|
watch(staticColumnFlag, () => {
|
|
11723
|
-
|
|
11860
|
+
nextTick(() => handleInitColumn(XEUtils.clone(reactData.staticColumns)))
|
|
11724
11861
|
})
|
|
11725
11862
|
|
|
11726
11863
|
const tableColumnFlag = ref(0)
|
|
@@ -342,6 +342,15 @@ export function isColumnInfo (column: any): column is ColumnInfo {
|
|
|
342
342
|
return column && (column.constructor === ColumnInfo || column instanceof ColumnInfo)
|
|
343
343
|
}
|
|
344
344
|
|
|
345
|
+
// 获取所有的列,排除分组
|
|
346
|
+
export function getColumnList (columns: VxeTableDefines.ColumnInfo[]) {
|
|
347
|
+
const result: VxeTableDefines.ColumnInfo[] = []
|
|
348
|
+
columns.forEach((column) => {
|
|
349
|
+
result.push(...(column.children && column.children.length ? getColumnList(column.children) : [column]))
|
|
350
|
+
})
|
|
351
|
+
return result
|
|
352
|
+
}
|
|
353
|
+
|
|
345
354
|
export function createColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, options: VxeTableDefines.ColumnOptions | VxeTableDefines.ColumnInfo, renderOptions: any): any {
|
|
346
355
|
return isColumnInfo(options) ? options : reactive(new ColumnInfo($xeTable, options, renderOptions))
|
|
347
356
|
}
|
|
@@ -369,6 +378,7 @@ export function assembleColumn ($xeTable: VxeTableConstructor & VxeTablePrivateM
|
|
|
369
378
|
const parentColumn = colgroup ? colgroup.columnConfig : null
|
|
370
379
|
const parentCols = parentColumn ? parentColumn.children : staticColumns
|
|
371
380
|
if (parentElem && parentCols) {
|
|
381
|
+
column.defaultParentId = parentColumn ? parentColumn.id : null
|
|
372
382
|
parentCols.splice(XEUtils.arrayIndexOf(parentElem.children, elem), 0, column)
|
|
373
383
|
reactData.staticColumns = staticColumns.slice(0)
|
|
374
384
|
}
|
package/packages/ui/index.ts
CHANGED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|