vxe-table 3.14.0-beta.8 → 3.14.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 +75 -50
- package/es/locale/lang/ar-EG.js +7 -1
- package/es/locale/lang/de-DE.js +7 -1
- package/es/locale/lang/en-US.js +7 -1
- package/es/locale/lang/es-ES.js +7 -1
- package/es/locale/lang/fr-FR.js +7 -1
- package/es/locale/lang/hu-HU.js +7 -1
- package/es/locale/lang/hy-AM.js +7 -1
- package/es/locale/lang/id-ID.js +7 -1
- package/es/locale/lang/it-IT.js +7 -1
- package/es/locale/lang/ja-JP.js +7 -1
- package/es/locale/lang/ko-KR.js +7 -1
- package/es/locale/lang/nb-NO.js +7 -1
- package/es/locale/lang/pt-BR.js +7 -1
- package/es/locale/lang/ru-RU.js +7 -1
- package/es/locale/lang/th-TH.js +7 -1
- package/es/locale/lang/ug-CN.js +7 -1
- package/es/locale/lang/uk-UA.js +7 -1
- package/es/locale/lang/vi-VN.js +7 -1
- package/es/locale/lang/zh-CHT.js +7 -1
- package/es/locale/lang/zh-CN.js +7 -1
- package/es/style.css +1 -1
- package/es/table/module/custom/mixin.js +4 -2
- package/es/table/module/custom/panel.js +24 -23
- package/es/table/module/edit/mixin.js +17 -11
- package/es/table/module/export/export-panel.js +5 -4
- package/es/table/module/export/import-panel.js +8 -7
- package/es/table/module/export/mixin.js +30 -27
- package/es/table/module/filter/panel.js +21 -10
- package/es/table/module/keyboard/mixin.js +141 -41
- package/es/table/module/menu/mixin.js +6 -3
- package/es/table/module/menu/panel.js +7 -7
- package/es/table/module/validator/mixin.js +2 -2
- package/es/table/render/index.js +2 -2
- package/es/table/src/body.js +39 -20
- package/es/table/src/cell.js +27 -22
- package/es/table/src/column.js +11 -9
- package/es/table/src/columnInfo.js +6 -6
- package/es/table/src/footer.js +12 -7
- package/es/table/src/group.js +6 -5
- package/es/table/src/header.js +15 -9
- package/es/table/src/methods.js +773 -704
- package/es/table/src/props.js +4 -0
- package/es/table/src/table.js +85 -49
- package/es/table/src/util.js +55 -20
- package/es/toolbar/src/toolbar.js +3 -3
- package/es/ui/index.js +2 -1
- package/es/ui/src/log.js +1 -1
- package/helper/vetur/attributes.json +1 -1
- package/helper/vetur/tags.json +1 -1
- package/lib/grid/src/grid.js +82 -67
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/index.umd.js +1590 -1249
- package/lib/index.umd.min.js +1 -1
- package/lib/locale/lang/ar-EG.js +7 -1
- package/lib/locale/lang/ar-EG.min.js +1 -1
- package/lib/locale/lang/de-DE.js +7 -1
- package/lib/locale/lang/de-DE.min.js +1 -1
- package/lib/locale/lang/en-US.js +7 -1
- package/lib/locale/lang/en-US.min.js +1 -1
- package/lib/locale/lang/en-US.umd.js +7 -1
- package/lib/locale/lang/es-ES.js +7 -1
- package/lib/locale/lang/es-ES.min.js +1 -1
- package/lib/locale/lang/es-ES.umd.js +7 -1
- package/lib/locale/lang/fr-FR.js +7 -1
- package/lib/locale/lang/fr-FR.min.js +1 -1
- package/lib/locale/lang/hu-HU.js +7 -1
- package/lib/locale/lang/hu-HU.min.js +1 -1
- package/lib/locale/lang/hu-HU.umd.js +7 -1
- package/lib/locale/lang/hy-AM.js +7 -1
- package/lib/locale/lang/hy-AM.min.js +1 -1
- package/lib/locale/lang/id-ID.js +7 -1
- package/lib/locale/lang/id-ID.min.js +1 -1
- package/lib/locale/lang/it-IT.js +7 -1
- package/lib/locale/lang/it-IT.min.js +1 -1
- package/lib/locale/lang/ja-JP.js +7 -1
- package/lib/locale/lang/ja-JP.min.js +1 -1
- package/lib/locale/lang/ja-JP.umd.js +7 -1
- package/lib/locale/lang/ko-KR.js +7 -1
- package/lib/locale/lang/ko-KR.min.js +1 -1
- package/lib/locale/lang/ko-KR.umd.js +7 -1
- package/lib/locale/lang/nb-NO.js +7 -1
- package/lib/locale/lang/nb-NO.min.js +1 -1
- package/lib/locale/lang/pt-BR.js +7 -1
- package/lib/locale/lang/pt-BR.min.js +1 -1
- package/lib/locale/lang/pt-BR.umd.js +7 -1
- package/lib/locale/lang/ru-RU.js +7 -1
- package/lib/locale/lang/ru-RU.min.js +1 -1
- package/lib/locale/lang/ru-RU.umd.js +7 -1
- package/lib/locale/lang/th-TH.js +7 -1
- package/lib/locale/lang/th-TH.min.js +1 -1
- package/lib/locale/lang/ug-CN.js +7 -1
- package/lib/locale/lang/ug-CN.min.js +1 -1
- package/lib/locale/lang/uk-UA.js +7 -1
- package/lib/locale/lang/uk-UA.min.js +1 -1
- package/lib/locale/lang/uk-UA.umd.js +7 -1
- package/lib/locale/lang/vi-VN.js +7 -1
- package/lib/locale/lang/vi-VN.min.js +1 -1
- package/lib/locale/lang/zh-CHT.js +7 -1
- package/lib/locale/lang/zh-CHT.min.js +1 -1
- package/lib/locale/lang/zh-CHT.umd.js +7 -1
- package/lib/locale/lang/zh-CN.js +7 -1
- package/lib/locale/lang/zh-CN.min.js +1 -1
- package/lib/locale/lang/zh-CN.umd.js +7 -1
- package/lib/style.css +1 -1
- package/lib/table/module/custom/mixin.js +5 -3
- package/lib/table/module/custom/mixin.min.js +1 -1
- package/lib/table/module/custom/panel.js +22 -29
- package/lib/table/module/custom/panel.min.js +1 -1
- package/lib/table/module/edit/mixin.js +19 -13
- package/lib/table/module/edit/mixin.min.js +1 -1
- package/lib/table/module/export/export-panel.js +5 -4
- package/lib/table/module/export/export-panel.min.js +1 -1
- package/lib/table/module/export/import-panel.js +8 -7
- package/lib/table/module/export/import-panel.min.js +1 -1
- package/lib/table/module/export/mixin.js +35 -34
- package/lib/table/module/export/mixin.min.js +1 -1
- package/lib/table/module/filter/panel.js +16 -16
- package/lib/table/module/filter/panel.min.js +1 -1
- package/lib/table/module/keyboard/mixin.js +149 -47
- package/lib/table/module/keyboard/mixin.min.js +1 -1
- package/lib/table/module/menu/mixin.js +6 -3
- package/lib/table/module/menu/mixin.min.js +1 -1
- package/lib/table/module/menu/panel.js +7 -7
- package/lib/table/module/menu/panel.min.js +1 -1
- package/lib/table/module/validator/mixin.js +3 -3
- package/lib/table/module/validator/mixin.min.js +1 -1
- package/lib/table/render/index.js +3 -2
- package/lib/table/render/index.min.js +1 -1
- package/lib/table/src/body.js +47 -20
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +39 -23
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/column.js +11 -9
- package/lib/table/src/column.min.js +1 -1
- package/lib/table/src/columnInfo.js +6 -6
- package/lib/table/src/columnInfo.min.js +1 -1
- package/lib/table/src/footer.js +12 -5
- package/lib/table/src/footer.min.js +1 -1
- package/lib/table/src/group.js +6 -5
- package/lib/table/src/group.min.js +1 -1
- package/lib/table/src/header.js +16 -8
- package/lib/table/src/header.min.js +1 -1
- package/lib/table/src/methods.js +911 -830
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/props.js +4 -0
- package/lib/table/src/props.min.js +1 -1
- package/lib/table/src/table.js +93 -52
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +62 -21
- package/lib/table/src/util.min.js +1 -1
- package/lib/toolbar/src/toolbar.js +3 -3
- 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 +88 -59
- package/packages/locale/lang/ar-EG.ts +7 -1
- package/packages/locale/lang/de-DE.ts +7 -1
- package/packages/locale/lang/en-US.ts +7 -1
- package/packages/locale/lang/es-ES.ts +7 -1
- package/packages/locale/lang/fr-FR.ts +7 -1
- package/packages/locale/lang/hu-HU.ts +7 -1
- package/packages/locale/lang/hy-AM.ts +7 -1
- package/packages/locale/lang/id-ID.ts +7 -1
- package/packages/locale/lang/it-IT.ts +7 -1
- package/packages/locale/lang/ja-JP.ts +7 -1
- package/packages/locale/lang/ko-KR.ts +7 -1
- package/packages/locale/lang/nb-NO.ts +7 -1
- package/packages/locale/lang/pt-BR.ts +7 -1
- package/packages/locale/lang/ru-RU.ts +7 -1
- package/packages/locale/lang/th-TH.ts +7 -1
- package/packages/locale/lang/ug-CN.ts +7 -1
- package/packages/locale/lang/uk-UA.ts +7 -1
- package/packages/locale/lang/vi-VN.ts +7 -1
- package/packages/locale/lang/zh-CHT.ts +7 -1
- package/packages/locale/lang/zh-CN.ts +7 -1
- package/packages/table/module/custom/mixin.ts +6 -3
- package/packages/table/module/custom/panel.ts +42 -37
- package/packages/table/module/edit/mixin.ts +20 -14
- package/packages/table/module/export/export-panel.ts +8 -5
- package/packages/table/module/export/import-panel.ts +11 -7
- package/packages/table/module/export/mixin.ts +37 -32
- package/packages/table/module/filter/panel.ts +25 -10
- package/packages/table/module/keyboard/mixin.ts +155 -49
- package/packages/table/module/menu/mixin.ts +12 -6
- package/packages/table/module/menu/panel.ts +10 -7
- package/packages/table/module/validator/mixin.ts +2 -2
- package/packages/table/render/index.ts +2 -2
- package/packages/table/src/body.ts +39 -20
- package/packages/table/src/cell.ts +27 -22
- package/packages/table/src/column.ts +14 -10
- package/packages/table/src/columnInfo.ts +9 -6
- package/packages/table/src/footer.ts +12 -7
- package/packages/table/src/group.ts +9 -5
- package/packages/table/src/header.ts +16 -9
- package/packages/table/src/methods.ts +854 -740
- package/packages/table/src/props.ts +16 -12
- package/packages/table/src/table.ts +99 -52
- package/packages/table/src/util.ts +63 -21
- package/packages/toolbar/src/toolbar.ts +3 -3
- package/packages/ui/index.ts +1 -0
- /package/es/{iconfont.1741333630357.ttf → iconfont.1742955973002.ttf} +0 -0
- /package/es/{iconfont.1741333630357.woff → iconfont.1742955973002.woff} +0 -0
- /package/es/{iconfont.1741333630357.woff2 → iconfont.1742955973002.woff2} +0 -0
- /package/lib/{iconfont.1741333630357.ttf → iconfont.1742955973002.ttf} +0 -0
- /package/lib/{iconfont.1741333630357.woff → iconfont.1742955973002.woff} +0 -0
- /package/lib/{iconfont.1741333630357.woff2 → iconfont.1742955973002.woff2} +0 -0
|
@@ -3,7 +3,7 @@ import { browse, getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEv
|
|
|
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, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth,
|
|
6
|
+
import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getRefElem } from './util'
|
|
7
7
|
import { getSlotVNs } from '../../ui/src/vn'
|
|
8
8
|
import { warnLog, errLog } from '../../ui/src/log'
|
|
9
9
|
|
|
@@ -11,6 +11,7 @@ import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, ValueOf, Table
|
|
|
11
11
|
|
|
12
12
|
const { getConfig, getI18n, renderer, formats, interceptor, createEvent } = VxeUI
|
|
13
13
|
|
|
14
|
+
const supportMaxRow = 5e6
|
|
14
15
|
const customStorageKey = 'VXE_CUSTOM_STORE'
|
|
15
16
|
const maxYHeight = 5e6
|
|
16
17
|
const maxXWidth = 5e6
|
|
@@ -236,7 +237,7 @@ function cacheColumnMap ($xeTable: VxeTableConstructor) {
|
|
|
236
237
|
fullColumnFieldData[field] = rest
|
|
237
238
|
} else {
|
|
238
239
|
if ((storage && !type) || (columnOpts.drag && (isCrossDrag || isSelfToChildDrag))) {
|
|
239
|
-
errLog('vxe.error.reqProp', [`${column.getTitle() || type || ''} -> column.field
|
|
240
|
+
errLog('vxe.error.reqProp', [`${column.getTitle() || type || ''} -> column.field=?`])
|
|
240
241
|
}
|
|
241
242
|
}
|
|
242
243
|
if (!hasFixed && fixed) {
|
|
@@ -340,9 +341,10 @@ function updateAfterListIndex ($xeTable: VxeTableConstructor) {
|
|
|
340
341
|
|
|
341
342
|
const { treeConfig } = props
|
|
342
343
|
const { afterFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData
|
|
344
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
343
345
|
const fullMaps: Record<string, any> = {}
|
|
344
346
|
afterFullData.forEach((row, index) => {
|
|
345
|
-
const rowid =
|
|
347
|
+
const rowid = handleGetRowId(row)
|
|
346
348
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
347
349
|
const seq = index + 1
|
|
348
350
|
if (rowRest) {
|
|
@@ -375,8 +377,9 @@ function updateAfterDataIndex ($xeTable: VxeTableConstructor) {
|
|
|
375
377
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
376
378
|
const fullMaps: Record<string, any> = {}
|
|
377
379
|
if (treeConfig) {
|
|
380
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
378
381
|
XEUtils.eachTree(afterTreeFullData, (row, index, items, path) => {
|
|
379
|
-
const rowid =
|
|
382
|
+
const rowid = handleGetRowId(row)
|
|
380
383
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
381
384
|
const seq = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
|
|
382
385
|
if (rowRest) {
|
|
@@ -402,22 +405,21 @@ function updateAfterDataIndex ($xeTable: VxeTableConstructor) {
|
|
|
402
405
|
*/
|
|
403
406
|
function handleVirtualTreeToList ($xeTable: VxeTableConstructor) {
|
|
404
407
|
const props = $xeTable
|
|
405
|
-
const reactData = $xeTable as unknown as TableReactData
|
|
406
408
|
const internalData = $xeTable as unknown as TableInternalData
|
|
407
409
|
|
|
408
410
|
const { treeConfig } = props
|
|
409
|
-
const { treeExpandedMaps } =
|
|
410
|
-
const { fullAllDataRowIdData } = internalData
|
|
411
|
+
const { fullAllDataRowIdData, treeExpandedMaps } = internalData
|
|
411
412
|
const treeOpts = $xeTable.computeTreeOpts
|
|
412
413
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
413
414
|
if (treeConfig && treeOpts.transform) {
|
|
415
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
414
416
|
const fullData: any[] = []
|
|
415
417
|
const expandMaps: {
|
|
416
418
|
[key: string]: number
|
|
417
419
|
} = {}
|
|
418
420
|
XEUtils.eachTree(internalData.afterTreeFullData, (row, index, items, path, parentRow) => {
|
|
419
|
-
const rowid =
|
|
420
|
-
const parentRowid =
|
|
421
|
+
const rowid = handleGetRowId(row)
|
|
422
|
+
const parentRowid = handleGetRowId(parentRow)
|
|
421
423
|
if (!parentRow || (expandMaps[parentRowid] && treeExpandedMaps[parentRowid])) {
|
|
422
424
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
423
425
|
if (rowRest) {
|
|
@@ -441,7 +443,7 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
441
443
|
|
|
442
444
|
const { border, showHeaderOverflow: allColumnHeaderOverflow, showFooterOverflow: allColumnFooterOverflow, mouseConfig, spanMethod, footerSpanMethod } = props
|
|
443
445
|
const { isGroup, currentRow, tableColumn, scrollXLoad, scrollYLoad, overflowX, scrollbarWidth, overflowY, scrollbarHeight, scrollXWidth, columnStore, editStore, isAllOverflow, expandColumn } = reactData
|
|
444
|
-
const { visibleColumn,
|
|
446
|
+
const { visibleColumn, tableHeight, headerHeight, footerHeight, elemStore, customHeight, customMinHeight, customMaxHeight } = internalData
|
|
445
447
|
const el = $xeTable.$refs.refElem as HTMLDivElement
|
|
446
448
|
if (!el) {
|
|
447
449
|
return
|
|
@@ -450,7 +452,6 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
450
452
|
const osbWidth = overflowY ? scrollbarWidth : 0
|
|
451
453
|
const osbHeight = overflowX ? scrollbarHeight : 0
|
|
452
454
|
const emptyPlaceholderElem = $xeTable.$refs.refEmptyPlaceholder as HTMLDivElement
|
|
453
|
-
const cellOffsetWidth = $xeTable.computeCellOffsetWidth
|
|
454
455
|
const mouseOpts = $xeTable.computeMouseOpts
|
|
455
456
|
const expandOpts = $xeTable.computeExpandOpts
|
|
456
457
|
const bodyWrapperElem = getRefElem(elemStore['main-body-wrapper'])
|
|
@@ -732,54 +733,6 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
732
733
|
tableElem.style.width = tWidth ? `${tWidth}px` : ''
|
|
733
734
|
}
|
|
734
735
|
}
|
|
735
|
-
const colgroupElem = getRefElem(elemStore[`${name}-${layout}-colgroup`])
|
|
736
|
-
if (colgroupElem) {
|
|
737
|
-
XEUtils.arrayEach(colgroupElem.children, (colElem: any) => {
|
|
738
|
-
const colid = colElem.getAttribute('name')
|
|
739
|
-
if (fullColumnIdData[colid]) {
|
|
740
|
-
const colRest = fullColumnIdData[colid]
|
|
741
|
-
const column = colRest.column
|
|
742
|
-
const { showHeaderOverflow, showFooterOverflow, showOverflow } = column
|
|
743
|
-
let cellOverflow
|
|
744
|
-
colElem.style.width = `${column.renderWidth}px`
|
|
745
|
-
if (layout === 'header') {
|
|
746
|
-
cellOverflow = XEUtils.isUndefined(showHeaderOverflow) || XEUtils.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow
|
|
747
|
-
} else if (layout === 'footer') {
|
|
748
|
-
cellOverflow = XEUtils.isUndefined(showFooterOverflow) || XEUtils.isNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow
|
|
749
|
-
} else {
|
|
750
|
-
cellOverflow = XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow) ? isAllOverflow : showOverflow
|
|
751
|
-
}
|
|
752
|
-
const showEllipsis = cellOverflow === 'ellipsis'
|
|
753
|
-
const showTitle = cellOverflow === 'title'
|
|
754
|
-
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip'
|
|
755
|
-
let hasEllipsis = showTitle || showTooltip || showEllipsis
|
|
756
|
-
const listElem = getRefElem(elemStore[`${name}-${layout}-list`])
|
|
757
|
-
// 纵向虚拟滚动不支持动态行高
|
|
758
|
-
if (scrollYLoad && !hasEllipsis) {
|
|
759
|
-
hasEllipsis = true
|
|
760
|
-
}
|
|
761
|
-
if (listElem) {
|
|
762
|
-
XEUtils.arrayEach(listElem.querySelectorAll(`.${column.id}`), (elem: any) => {
|
|
763
|
-
const colspan = parseInt(elem.getAttribute('colspan') || 1)
|
|
764
|
-
const cellElem = elem.querySelector('.vxe-cell')
|
|
765
|
-
let colWidth = column.renderWidth
|
|
766
|
-
if (cellElem) {
|
|
767
|
-
if (colspan > 1) {
|
|
768
|
-
const columnIndex = $xeTable.getColumnIndex(column)
|
|
769
|
-
for (let index = 1; index < colspan; index++) {
|
|
770
|
-
const nextColumn = $xeTable.getColumns(columnIndex + index)
|
|
771
|
-
if (nextColumn) {
|
|
772
|
-
colWidth += nextColumn.renderWidth
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
cellElem.style.width = hasEllipsis ? `${colWidth - (cellOffsetWidth * colspan)}px` : ''
|
|
777
|
-
}
|
|
778
|
-
})
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
})
|
|
782
|
-
}
|
|
783
736
|
})
|
|
784
737
|
})
|
|
785
738
|
if (currentRow) {
|
|
@@ -791,6 +744,27 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
791
744
|
return $xeTable.$nextTick()
|
|
792
745
|
}
|
|
793
746
|
|
|
747
|
+
function checkValidate ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, type: any) {
|
|
748
|
+
if ($xeTable.triggerValidate) {
|
|
749
|
+
return $xeTable.triggerValidate(type)
|
|
750
|
+
}
|
|
751
|
+
return $xeTable.$nextTick()
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* 当单元格发生改变时
|
|
756
|
+
* 如果存在规则,则校验
|
|
757
|
+
*/
|
|
758
|
+
function handleChangeCell ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: Event, params: any) {
|
|
759
|
+
checkValidate($xeTable, 'blur')
|
|
760
|
+
.catch((e: any) => e)
|
|
761
|
+
.then(() => {
|
|
762
|
+
$xeTable.handleEdit(params, evnt)
|
|
763
|
+
.then(() => checkValidate($xeTable, 'change'))
|
|
764
|
+
.catch((e: any) => e)
|
|
765
|
+
})
|
|
766
|
+
}
|
|
767
|
+
|
|
794
768
|
function handleRadioReserveRow ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, row: any) {
|
|
795
769
|
const internalData = $xeTable as unknown as TableInternalData
|
|
796
770
|
|
|
@@ -842,12 +816,12 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
842
816
|
const internalData = $xeTable as unknown as TableInternalData
|
|
843
817
|
|
|
844
818
|
const { treeConfig } = props
|
|
845
|
-
const { selectCheckboxMaps } =
|
|
846
|
-
const { afterFullData, checkboxReserveRowMap } = internalData
|
|
819
|
+
const { afterFullData, checkboxReserveRowMap, selectCheckboxMaps } = internalData
|
|
847
820
|
const treeOpts = $xeTable.computeTreeOpts
|
|
848
821
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
849
822
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
850
823
|
const { checkField, reserve, checkMethod } = checkboxOpts
|
|
824
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
851
825
|
// indeterminateField 仅支持读取
|
|
852
826
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
853
827
|
const selectRowMaps: Record<string, any> = {}
|
|
@@ -859,7 +833,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
859
833
|
const checkValFn = (row: any) => {
|
|
860
834
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
861
835
|
if (checked) {
|
|
862
|
-
selectRowMaps[
|
|
836
|
+
selectRowMaps[handleGetRowId(row)] = row
|
|
863
837
|
}
|
|
864
838
|
XEUtils.set(row, checkField, checked)
|
|
865
839
|
}
|
|
@@ -887,7 +861,8 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
887
861
|
*/
|
|
888
862
|
XEUtils.eachTree(afterFullData, (row) => {
|
|
889
863
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
890
|
-
|
|
864
|
+
const rowid = handleGetRowId(row)
|
|
865
|
+
selectRowMaps[rowid] = row
|
|
891
866
|
}
|
|
892
867
|
}, { children: childrenField })
|
|
893
868
|
} else {
|
|
@@ -897,7 +872,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
897
872
|
*/
|
|
898
873
|
if (!isForce && checkMethod) {
|
|
899
874
|
XEUtils.eachTree(afterFullData, (row) => {
|
|
900
|
-
const rowid =
|
|
875
|
+
const rowid = handleGetRowId(row)
|
|
901
876
|
if (checkMethod({ row }) ? 0 : selectCheckboxMaps[rowid]) {
|
|
902
877
|
selectRowMaps[rowid] = row
|
|
903
878
|
}
|
|
@@ -913,14 +888,15 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
913
888
|
*/
|
|
914
889
|
if (!isForce && checkMethod) {
|
|
915
890
|
afterFullData.forEach((row) => {
|
|
916
|
-
const rowid =
|
|
891
|
+
const rowid = handleGetRowId(row)
|
|
917
892
|
if (selectCheckboxMaps[rowid] || checkMethod({ row })) {
|
|
918
893
|
selectRowMaps[rowid] = row
|
|
919
894
|
}
|
|
920
895
|
})
|
|
921
896
|
} else {
|
|
922
897
|
afterFullData.forEach(row => {
|
|
923
|
-
|
|
898
|
+
const rowid = handleGetRowId(row)
|
|
899
|
+
selectRowMaps[rowid] = row
|
|
924
900
|
})
|
|
925
901
|
}
|
|
926
902
|
} else {
|
|
@@ -931,7 +907,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
931
907
|
*/
|
|
932
908
|
if (!isForce && checkMethod) {
|
|
933
909
|
afterFullData.forEach((row) => {
|
|
934
|
-
const rowid =
|
|
910
|
+
const rowid = handleGetRowId(row)
|
|
935
911
|
if (checkMethod({ row }) ? 0 : selectCheckboxMaps[rowid]) {
|
|
936
912
|
selectRowMaps[rowid] = row
|
|
937
913
|
}
|
|
@@ -949,11 +925,11 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
949
925
|
afterFullData.forEach((row) => handleCheckboxReserveRow($xeTable, row, false))
|
|
950
926
|
}
|
|
951
927
|
}
|
|
952
|
-
reactData.
|
|
928
|
+
reactData.updateCheckboxFlag++
|
|
929
|
+
internalData.selectCheckboxMaps = checkField ? {} : selectRowMaps
|
|
953
930
|
|
|
954
931
|
reactData.isAllSelected = checked
|
|
955
932
|
reactData.isIndeterminate = false
|
|
956
|
-
reactData.treeIndeterminateMaps = {}
|
|
957
933
|
internalData.treeIndeterminateRowMaps = {}
|
|
958
934
|
$xeTable.checkSelectionStatus()
|
|
959
935
|
return $xeTable.$nextTick()
|
|
@@ -966,8 +942,8 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
966
942
|
const internalData = $xeTable as unknown as TableInternalData
|
|
967
943
|
|
|
968
944
|
const { treeConfig } = props
|
|
969
|
-
const { expandColumn, currentRow,
|
|
970
|
-
const { fullDataRowIdData, fullAllDataRowIdData, radioReserveRow } = internalData
|
|
945
|
+
const { expandColumn, currentRow, selectRadioRow } = reactData
|
|
946
|
+
const { fullDataRowIdData, fullAllDataRowIdData, radioReserveRow, selectCheckboxMaps, treeExpandedMaps, rowExpandedMaps } = internalData
|
|
971
947
|
const expandOpts = $xeTable.computeExpandOpts
|
|
972
948
|
const treeOpts = $xeTable.computeTreeOpts
|
|
973
949
|
const radioOpts = $xeTable.computeRadioOpts
|
|
@@ -984,7 +960,8 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
984
960
|
}
|
|
985
961
|
}
|
|
986
962
|
// 复选框
|
|
987
|
-
|
|
963
|
+
internalData.selectCheckboxMaps = getRecoverRowMaps($xeTable, selectCheckboxMaps) // 刷新多选行状态
|
|
964
|
+
reactData.updateCheckboxFlag++
|
|
988
965
|
// 还原保留选中状态
|
|
989
966
|
if (checkboxOpts.reserve) {
|
|
990
967
|
handleCheckedCheckboxRow($xeTable, handleReserveRow($xeTable, internalData.checkboxReserveRowMap), true, true)
|
|
@@ -993,18 +970,168 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
993
970
|
reactData.currentRow = null // 刷新当前行状态
|
|
994
971
|
}
|
|
995
972
|
// 行展开
|
|
996
|
-
|
|
973
|
+
internalData.rowExpandedMaps = expandColumn ? getRecoverRowMaps($xeTable, rowExpandedMaps) : {} // 刷新行展开状态
|
|
974
|
+
reactData.rowExpandedFlag++
|
|
997
975
|
// 还原保留状态
|
|
998
976
|
if (expandColumn && expandOpts.reserve) {
|
|
999
977
|
$xeTable.setRowExpand(handleReserveRow($xeTable, internalData.rowExpandedReserveRowMap), true)
|
|
1000
978
|
}
|
|
1001
979
|
// 树展开
|
|
1002
|
-
|
|
980
|
+
internalData.treeExpandedMaps = treeConfig ? getRecoverRowMaps($xeTable, treeExpandedMaps) : {} // 刷新树展开状态
|
|
981
|
+
reactData.treeExpandedFlag++
|
|
1003
982
|
if (treeConfig && treeOpts.reserve) {
|
|
1004
983
|
$xeTable.setTreeExpand(handleReserveRow($xeTable, internalData.treeExpandedReserveRowMap), true)
|
|
1005
984
|
}
|
|
1006
985
|
}
|
|
1007
986
|
|
|
987
|
+
/**
|
|
988
|
+
* 处理默认展开树节点
|
|
989
|
+
*/
|
|
990
|
+
const handleDefaultTreeExpand = ($xeTable: VxeTableConstructor) => {
|
|
991
|
+
const props = $xeTable
|
|
992
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
993
|
+
|
|
994
|
+
const { treeConfig } = props
|
|
995
|
+
if (treeConfig) {
|
|
996
|
+
const { tableFullData } = internalData
|
|
997
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
998
|
+
const { expandAll, expandRowKeys } = treeOpts
|
|
999
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
1000
|
+
if (expandAll) {
|
|
1001
|
+
$xeTable.setAllTreeExpand(true)
|
|
1002
|
+
} else if (expandRowKeys) {
|
|
1003
|
+
const defExpandeds: any[] = []
|
|
1004
|
+
const rowkey = getRowkey($xeTable)
|
|
1005
|
+
expandRowKeys.forEach((rowid: any) => {
|
|
1006
|
+
const matchObj = XEUtils.findTree(tableFullData, item => rowid === XEUtils.get(item, rowkey), { children: childrenField })
|
|
1007
|
+
if (matchObj) {
|
|
1008
|
+
defExpandeds.push(matchObj.item)
|
|
1009
|
+
}
|
|
1010
|
+
})
|
|
1011
|
+
$xeTable.setTreeExpand(defExpandeds, true)
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
const handleAsyncTreeExpandChilds = ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, row: any): Promise<void> => {
|
|
1017
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
1018
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1019
|
+
|
|
1020
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
1021
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
1022
|
+
const { transform, loadMethod } = treeOpts
|
|
1023
|
+
const { checkStrictly } = checkboxOpts
|
|
1024
|
+
return new Promise<void>(resolve => {
|
|
1025
|
+
if (loadMethod) {
|
|
1026
|
+
const { fullAllDataRowIdData, treeExpandLazyLoadedMaps } = internalData
|
|
1027
|
+
const rowid = getRowid($xeTable, row)
|
|
1028
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
1029
|
+
treeExpandLazyLoadedMaps[rowid] = row
|
|
1030
|
+
Promise.resolve(
|
|
1031
|
+
loadMethod({ $table: $xeTable, row })
|
|
1032
|
+
).then((childRecords: any) => {
|
|
1033
|
+
if (rowRest) {
|
|
1034
|
+
rowRest.treeLoaded = true
|
|
1035
|
+
}
|
|
1036
|
+
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
1037
|
+
delete treeExpandLazyLoadedMaps[rowid]
|
|
1038
|
+
}
|
|
1039
|
+
if (!XEUtils.isArray(childRecords)) {
|
|
1040
|
+
childRecords = []
|
|
1041
|
+
}
|
|
1042
|
+
if (childRecords) {
|
|
1043
|
+
return $xeTable.loadTreeChildren(row, childRecords).then(childRows => {
|
|
1044
|
+
const { treeExpandedMaps } = internalData
|
|
1045
|
+
if (childRows.length && !treeExpandedMaps[rowid]) {
|
|
1046
|
+
treeExpandedMaps[rowid] = row
|
|
1047
|
+
}
|
|
1048
|
+
reactData.treeExpandedFlag++
|
|
1049
|
+
// 如果当前节点已选中,则展开后子节点也被选中
|
|
1050
|
+
if (!checkStrictly && $xeTable.isCheckedByCheckboxRow(row)) {
|
|
1051
|
+
handleCheckedCheckboxRow($xeTable, childRows, true)
|
|
1052
|
+
}
|
|
1053
|
+
return $xeTable.$nextTick().then(() => {
|
|
1054
|
+
if (transform) {
|
|
1055
|
+
$xeTable.handleTableData()
|
|
1056
|
+
updateAfterDataIndex($xeTable)
|
|
1057
|
+
return $xeTable.$nextTick()
|
|
1058
|
+
}
|
|
1059
|
+
})
|
|
1060
|
+
})
|
|
1061
|
+
}
|
|
1062
|
+
}).catch(() => {
|
|
1063
|
+
const { treeExpandLazyLoadedMaps } = internalData
|
|
1064
|
+
if (rowRest) {
|
|
1065
|
+
rowRest.treeLoaded = false
|
|
1066
|
+
}
|
|
1067
|
+
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
1068
|
+
delete treeExpandLazyLoadedMaps[rowid]
|
|
1069
|
+
}
|
|
1070
|
+
}).finally(() => {
|
|
1071
|
+
reactData.treeExpandedFlag++
|
|
1072
|
+
$xeTable.$nextTick().then(() => $xeTable.recalculate()).then(() => resolve())
|
|
1073
|
+
})
|
|
1074
|
+
} else {
|
|
1075
|
+
resolve()
|
|
1076
|
+
}
|
|
1077
|
+
})
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
const handleTreeExpandReserve = ($xeTable: VxeTableConstructor, row: any, expanded: boolean) => {
|
|
1081
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1082
|
+
|
|
1083
|
+
const { treeExpandedReserveRowMap } = internalData
|
|
1084
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
1085
|
+
if (treeOpts.reserve) {
|
|
1086
|
+
const rowid = getRowid($xeTable, row)
|
|
1087
|
+
if (expanded) {
|
|
1088
|
+
treeExpandedReserveRowMap[rowid] = row
|
|
1089
|
+
} else if (treeExpandedReserveRowMap[rowid]) {
|
|
1090
|
+
delete treeExpandedReserveRowMap[rowid]
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
const handleAsyncRowExpand = ($xeTable: VxeTableConstructor, row: any): Promise<void> => {
|
|
1096
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
1097
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1098
|
+
|
|
1099
|
+
return new Promise<void>(resolve => {
|
|
1100
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
1101
|
+
const { loadMethod } = expandOpts
|
|
1102
|
+
if (loadMethod) {
|
|
1103
|
+
const { fullAllDataRowIdData, rowExpandLazyLoadedMaps } = internalData
|
|
1104
|
+
const rowid = getRowid($xeTable, row)
|
|
1105
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
1106
|
+
rowExpandLazyLoadedMaps[rowid] = row
|
|
1107
|
+
loadMethod({ $table: $xeTable, row, rowIndex: $xeTable.getRowIndex(row), $rowIndex: $xeTable.getVMRowIndex(row) }).then(() => {
|
|
1108
|
+
const { rowExpandedMaps } = internalData
|
|
1109
|
+
if (rowRest) {
|
|
1110
|
+
rowRest.expandLoaded = true
|
|
1111
|
+
}
|
|
1112
|
+
rowExpandedMaps[rowid] = row
|
|
1113
|
+
reactData.rowExpandedFlag++
|
|
1114
|
+
}).catch(() => {
|
|
1115
|
+
if (rowRest) {
|
|
1116
|
+
rowRest.expandLoaded = false
|
|
1117
|
+
}
|
|
1118
|
+
}).finally(() => {
|
|
1119
|
+
const { rowExpandLazyLoadedMaps } = internalData
|
|
1120
|
+
if (rowExpandLazyLoadedMaps[rowid]) {
|
|
1121
|
+
delete rowExpandLazyLoadedMaps[rowid]
|
|
1122
|
+
}
|
|
1123
|
+
reactData.rowExpandedFlag++
|
|
1124
|
+
$xeTable.$nextTick()
|
|
1125
|
+
.then(() => $xeTable.recalculate())
|
|
1126
|
+
.then(() => $xeTable.updateCellAreas())
|
|
1127
|
+
.then(() => resolve())
|
|
1128
|
+
})
|
|
1129
|
+
} else {
|
|
1130
|
+
resolve()
|
|
1131
|
+
}
|
|
1132
|
+
})
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1008
1135
|
function calcVarRowHeightConfig ($xeTable: VxeTableConstructor, sizeKey: 'default' | 'medium' | 'small' | 'mini', sizeEl: Element) {
|
|
1009
1136
|
const reactData = $xeTable as unknown as TableReactData
|
|
1010
1137
|
|
|
@@ -1070,12 +1197,13 @@ function handleVirtualYVisible ($xeTable: VxeTableConstructor) {
|
|
|
1070
1197
|
toVisibleIndex = Math.floor(startTop / defaultRowHeight) - 1
|
|
1071
1198
|
visibleSize = Math.ceil(clientHeight / defaultRowHeight) + 1
|
|
1072
1199
|
} else {
|
|
1200
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
1073
1201
|
let leftIndex = 0
|
|
1074
1202
|
let rightIndex = afterFullData.length
|
|
1075
1203
|
while (leftIndex < rightIndex) {
|
|
1076
1204
|
const rIndex = Math.floor((leftIndex + rightIndex) / 2)
|
|
1077
1205
|
const row = afterFullData[rIndex]
|
|
1078
|
-
const rowid =
|
|
1206
|
+
const rowid = handleGetRowId(row)
|
|
1079
1207
|
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
1080
1208
|
if (rowRest.oTop <= startTop) {
|
|
1081
1209
|
leftIndex = rIndex + 1
|
|
@@ -1086,7 +1214,7 @@ function handleVirtualYVisible ($xeTable: VxeTableConstructor) {
|
|
|
1086
1214
|
toVisibleIndex = Math.max(0, leftIndex < afterFullData.length ? leftIndex - 2 : 0)
|
|
1087
1215
|
for (let rIndex = toVisibleIndex, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
|
|
1088
1216
|
const row = afterFullData[rIndex]
|
|
1089
|
-
const rowid =
|
|
1217
|
+
const rowid = handleGetRowId(row)
|
|
1090
1218
|
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
1091
1219
|
visibleSize++
|
|
1092
1220
|
if (rowRest.oTop > endTop || visibleSize >= 100) {
|
|
@@ -1118,16 +1246,20 @@ function calculateMergerOffsetIndex (list: any, offsetItem: any, type: any) {
|
|
|
1118
1246
|
}
|
|
1119
1247
|
}
|
|
1120
1248
|
|
|
1121
|
-
function setMerges (
|
|
1249
|
+
function setMerges ($xeTable: VxeTableConstructor, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[], mList: VxeTableDefines.MergeItem[], rowList?: any[]) {
|
|
1250
|
+
const props = $xeTable
|
|
1251
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1252
|
+
|
|
1122
1253
|
if (merges) {
|
|
1123
|
-
const { treeConfig
|
|
1254
|
+
const { treeConfig } = props
|
|
1255
|
+
const { visibleColumn } = internalData
|
|
1124
1256
|
if (!XEUtils.isArray(merges)) {
|
|
1125
1257
|
merges = [merges]
|
|
1126
1258
|
}
|
|
1127
1259
|
if (treeConfig && merges.length) {
|
|
1128
1260
|
errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
|
|
1129
1261
|
}
|
|
1130
|
-
merges.forEach((item
|
|
1262
|
+
merges.forEach((item) => {
|
|
1131
1263
|
let { row, col, rowspan, colspan } = item
|
|
1132
1264
|
if (rowList && XEUtils.isNumber(row)) {
|
|
1133
1265
|
row = rowList[row]
|
|
@@ -1166,10 +1298,14 @@ function setMerges (_vm: any, merges: any, mList: any, rowList: any) {
|
|
|
1166
1298
|
}
|
|
1167
1299
|
}
|
|
1168
1300
|
|
|
1169
|
-
function removeMerges (
|
|
1301
|
+
function removeMerges ($xeTable: VxeTableConstructor, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[], mList: VxeTableDefines.MergeItem[], rowList?: any) {
|
|
1302
|
+
const props = $xeTable
|
|
1303
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1304
|
+
|
|
1170
1305
|
const rest: any[] = []
|
|
1171
1306
|
if (merges) {
|
|
1172
|
-
const { treeConfig
|
|
1307
|
+
const { treeConfig } = props
|
|
1308
|
+
const { visibleColumn } = internalData
|
|
1173
1309
|
if (!XEUtils.isArray(merges)) {
|
|
1174
1310
|
merges = [merges]
|
|
1175
1311
|
}
|
|
@@ -1352,6 +1488,7 @@ function autoCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
|
|
|
1352
1488
|
internalData.headerHeight = headerHeight
|
|
1353
1489
|
internalData.footerHeight = footerHeight
|
|
1354
1490
|
reactData.overflowX = overflowX
|
|
1491
|
+
reactData.resizeWidthFlag++
|
|
1355
1492
|
updateColumnOffsetLeft($xeTable)
|
|
1356
1493
|
updateHeight($xeTable)
|
|
1357
1494
|
reactData.parentHeight = Math.max(internalData.headerHeight + footerHeight + 20, $xeTable.getParentHeight())
|
|
@@ -1382,8 +1519,9 @@ const calcCellHeight = ($xeTable: VxeTableConstructor) => {
|
|
|
1382
1519
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
1383
1520
|
const el = $xeTable.$refs.refElem as HTMLDivElement
|
|
1384
1521
|
if (!isAllOverflow && scrollYLoad && el) {
|
|
1522
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
1385
1523
|
tableData.forEach(row => {
|
|
1386
|
-
const rowid =
|
|
1524
|
+
const rowid = handleGetRowId(row)
|
|
1387
1525
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
1388
1526
|
if (rowRest) {
|
|
1389
1527
|
const height = calcCellAutoHeight(rowRest, el)
|
|
@@ -1631,10 +1769,11 @@ function hideDropTip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
1631
1769
|
* @param {Event} evnt 事件
|
|
1632
1770
|
* @param {Row} row 行对象
|
|
1633
1771
|
*/
|
|
1634
|
-
function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: MouseEvent, tdEl: HTMLTableCellElement, overflowElem: HTMLElement
|
|
1772
|
+
function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: MouseEvent, tdEl: HTMLTableCellElement, overflowElem: HTMLElement | null, params: any) {
|
|
1635
1773
|
const reactData = $xeTable as unknown as TableReactData
|
|
1636
1774
|
|
|
1637
|
-
|
|
1775
|
+
const tipOverEl = overflowElem || tdEl
|
|
1776
|
+
if (!tipOverEl) {
|
|
1638
1777
|
return $xeTable.$nextTick()
|
|
1639
1778
|
}
|
|
1640
1779
|
params.cell = tdEl
|
|
@@ -1644,9 +1783,8 @@ function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
|
|
|
1644
1783
|
const { showAll, contentMethod } = tooltipOpts
|
|
1645
1784
|
const customContent = contentMethod ? contentMethod(params) : null
|
|
1646
1785
|
const useCustom = contentMethod && !XEUtils.eqNull(customContent)
|
|
1647
|
-
const content = useCustom ? customContent : XEUtils.toString(column.type === 'html' ?
|
|
1648
|
-
|
|
1649
|
-
if (content && (showAll || useCustom || isCellOverflow)) {
|
|
1786
|
+
const content = useCustom ? customContent : XEUtils.toString(column.type === 'html' ? tipOverEl.innerText : tipOverEl.textContent).trim()
|
|
1787
|
+
if (content && (showAll || useCustom || (tipOverEl.scrollWidth > tipOverEl.clientWidth))) {
|
|
1650
1788
|
Object.assign(tooltipStore, {
|
|
1651
1789
|
row,
|
|
1652
1790
|
column,
|
|
@@ -1656,7 +1794,7 @@ function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
|
|
|
1656
1794
|
$xeTable.$nextTick(() => {
|
|
1657
1795
|
const $tooltip = $xeTable.$refs.refTooltip as VxeTooltipInstance
|
|
1658
1796
|
if ($tooltip && $tooltip.open) {
|
|
1659
|
-
$tooltip.open(
|
|
1797
|
+
$tooltip.open(tipOverEl, formatText(content))
|
|
1660
1798
|
}
|
|
1661
1799
|
})
|
|
1662
1800
|
}
|
|
@@ -1845,8 +1983,8 @@ function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, i
|
|
|
1845
1983
|
const reactData = $xeTable as unknown as TableReactData
|
|
1846
1984
|
const internalData = $xeTable as unknown as TableInternalData
|
|
1847
1985
|
|
|
1848
|
-
const { showOverflow } = props
|
|
1849
|
-
const rowOpts = $xeTable.computeRowOpts
|
|
1986
|
+
// const { showOverflow } = props
|
|
1987
|
+
// const rowOpts = $xeTable.computeRowOpts
|
|
1850
1988
|
const leftList: VxeTableDefines.ColumnInfo[] = []
|
|
1851
1989
|
const centerList: VxeTableDefines.ColumnInfo[] = []
|
|
1852
1990
|
const rightList: VxeTableDefines.ColumnInfo[] = []
|
|
@@ -1911,28 +2049,28 @@ function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, i
|
|
|
1911
2049
|
reactData.hasFixedColumn = leftList.length > 0 || rightList.length > 0
|
|
1912
2050
|
Object.assign(columnStore, { leftList, centerList, rightList })
|
|
1913
2051
|
if (scrollXLoad) {
|
|
1914
|
-
if (showOverflow) {
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
}
|
|
1922
|
-
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
}
|
|
2052
|
+
// if (showOverflow) {
|
|
2053
|
+
// if (!rowOpts.height) {
|
|
2054
|
+
// const errColumn = internalData.tableFullColumn.find(column => column.showOverflow === false)
|
|
2055
|
+
// if (errColumn) {
|
|
2056
|
+
// errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true'])
|
|
2057
|
+
// }
|
|
2058
|
+
// }
|
|
2059
|
+
// }
|
|
2060
|
+
// if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
2061
|
+
// if (props.showHeader && !props.showHeaderOverflow) {
|
|
2062
|
+
// warnLog('vxe.error.reqProp', ['show-header-overflow'])
|
|
2063
|
+
// }
|
|
2064
|
+
// if (props.showFooter && !props.showFooterOverflow) {
|
|
2065
|
+
// warnLog('vxe.error.reqProp', ['show-footer-overflow'])
|
|
2066
|
+
// }
|
|
2067
|
+
if (props.spanMethod) {
|
|
2068
|
+
warnLog('vxe.error.scrollErrProp', ['span-method'])
|
|
2069
|
+
}
|
|
2070
|
+
if (props.footerSpanMethod) {
|
|
2071
|
+
warnLog('vxe.error.scrollErrProp', ['footer-span-method'])
|
|
2072
|
+
}
|
|
2073
|
+
// }
|
|
1936
2074
|
if (isReset) {
|
|
1937
2075
|
const { visibleSize } = handleVirtualXVisible($xeTable)
|
|
1938
2076
|
scrollXStore.startIndex = 0
|
|
@@ -2055,6 +2193,39 @@ function loadScrollYData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods
|
|
|
2055
2193
|
}
|
|
2056
2194
|
}
|
|
2057
2195
|
|
|
2196
|
+
const createGetRowCacheProp = (prop: 'seq' | 'index' | '_index' | '$index') => {
|
|
2197
|
+
return function (this: VxeTableConstructor & VxeTablePrivateMethods, row: any) {
|
|
2198
|
+
const $xeTable = this
|
|
2199
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
2200
|
+
|
|
2201
|
+
const { fullAllDataRowIdData } = internalData
|
|
2202
|
+
if (row) {
|
|
2203
|
+
const rowid = getRowid($xeTable, row)
|
|
2204
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
2205
|
+
if (rowRest) {
|
|
2206
|
+
return rowRest[prop]
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
return -1
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
const createGetColumnCacheProp = (prop: 'index' | '_index' | '$index') => {
|
|
2214
|
+
return function (this: VxeTableConstructor & VxeTablePrivateMethods, column: VxeTableDefines.ColumnInfo) {
|
|
2215
|
+
const $xeTable = this
|
|
2216
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
2217
|
+
|
|
2218
|
+
const { fullColumnIdData } = internalData
|
|
2219
|
+
if (column) {
|
|
2220
|
+
const colRest = fullColumnIdData[column.id]
|
|
2221
|
+
if (colRest) {
|
|
2222
|
+
return colRest[prop]
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
return -1
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2058
2229
|
function lazyScrollXData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
2059
2230
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2060
2231
|
|
|
@@ -2221,7 +2392,7 @@ function calcCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
|
|
|
2221
2392
|
|
|
2222
2393
|
function handleUpdateColResize ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: MouseEvent, params: any) {
|
|
2223
2394
|
$xeTable.analyColumnWidth()
|
|
2224
|
-
$xeTable.recalculate(
|
|
2395
|
+
$xeTable.recalculate().then(() => {
|
|
2225
2396
|
$xeTable.saveCustomStore('update:width')
|
|
2226
2397
|
$xeTable.updateCellAreas()
|
|
2227
2398
|
$xeTable.dispatchEvent('column-resizable-change', params, evnt)
|
|
@@ -2235,7 +2406,7 @@ function handleUpdateRowResize ($xeTable: VxeTableConstructor & VxeTablePrivateM
|
|
|
2235
2406
|
const reactData = $xeTable as unknown as TableReactData
|
|
2236
2407
|
|
|
2237
2408
|
reactData.resizeHeightFlag++
|
|
2238
|
-
$xeTable.recalculate(
|
|
2409
|
+
$xeTable.recalculate().then(() => {
|
|
2239
2410
|
$xeTable.updateCellAreas()
|
|
2240
2411
|
$xeTable.dispatchEvent('row-resizable-change', params, evnt)
|
|
2241
2412
|
setTimeout(() => $xeTable.recalculate(true), 300)
|
|
@@ -2260,16 +2431,17 @@ function updateRowOffsetTop ($xeTable: VxeTableConstructor & VxeTablePrivateMeth
|
|
|
2260
2431
|
const reactData = $xeTable as unknown as TableReactData
|
|
2261
2432
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2262
2433
|
|
|
2263
|
-
const { expandColumn
|
|
2264
|
-
const { afterFullData, fullAllDataRowIdData } = internalData
|
|
2434
|
+
const { expandColumn } = reactData
|
|
2435
|
+
const { afterFullData, fullAllDataRowIdData, rowExpandedMaps } = internalData
|
|
2265
2436
|
const expandOpts = $xeTable.computeExpandOpts
|
|
2266
2437
|
const rowOpts = $xeTable.computeRowOpts
|
|
2267
2438
|
const cellOpts = $xeTable.computeCellOpts
|
|
2268
2439
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
2440
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
2269
2441
|
let offsetTop = 0
|
|
2270
2442
|
for (let rIndex = 0, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
|
|
2271
2443
|
const row = afterFullData[rIndex]
|
|
2272
|
-
const rowid =
|
|
2444
|
+
const rowid = handleGetRowId(row)
|
|
2273
2445
|
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
2274
2446
|
rowRest.oTop = offsetTop
|
|
2275
2447
|
offsetTop += rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight
|
|
@@ -2284,46 +2456,42 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
|
|
|
2284
2456
|
const reactData = $xeTable as unknown as TableReactData
|
|
2285
2457
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2286
2458
|
|
|
2287
|
-
const { expandColumn, scrollYLoad,
|
|
2459
|
+
const { expandColumn, scrollYLoad, scrollYTop, isScrollYBig } = reactData
|
|
2288
2460
|
const expandOpts = $xeTable.computeExpandOpts
|
|
2289
2461
|
const rowOpts = $xeTable.computeRowOpts
|
|
2290
2462
|
const cellOpts = $xeTable.computeCellOpts
|
|
2291
2463
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
2292
2464
|
const { mode } = expandOpts
|
|
2293
2465
|
if (expandColumn && mode === 'fixed') {
|
|
2294
|
-
const { elemStore,
|
|
2466
|
+
const { elemStore, fullAllDataRowIdData } = internalData
|
|
2295
2467
|
const rowExpandEl = $xeTable.$refs.refRowExpandElem as HTMLDivElement
|
|
2296
2468
|
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
2297
2469
|
if (rowExpandEl && bodyScrollElem) {
|
|
2298
2470
|
let isUpdateHeight = false
|
|
2299
|
-
if (scrollYLoad) {
|
|
2300
|
-
let offsetTop = 0
|
|
2301
|
-
for (let rIndex = 0, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
|
|
2302
|
-
const row = afterFullData[rIndex]
|
|
2303
|
-
const rowid = getRowid($xeTable, row)
|
|
2304
|
-
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
2305
|
-
rowRest.oTop = offsetTop
|
|
2306
|
-
offsetTop += rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight
|
|
2307
|
-
// 是否展开行
|
|
2308
|
-
if (expandColumn && rowExpandedMaps[rowid]) {
|
|
2309
|
-
offsetTop += rowRest.expandHeight || expandOpts.height || 0
|
|
2310
|
-
}
|
|
2311
|
-
}
|
|
2312
|
-
}
|
|
2313
2471
|
XEUtils.arrayEach(rowExpandEl.children, reEl => {
|
|
2314
2472
|
const expandEl = reEl as HTMLDivElement
|
|
2315
2473
|
const rowid = expandEl.getAttribute('rowid') || ''
|
|
2316
2474
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
2317
2475
|
if (rowRest) {
|
|
2318
2476
|
const expandHeight = expandEl.offsetHeight + 1
|
|
2477
|
+
const trEl = bodyScrollElem.querySelector(`.vxe-body--row[rowid="${rowid}"]`) as HTMLTableCellElement
|
|
2478
|
+
let offsetTop = 0
|
|
2319
2479
|
if (scrollYLoad) {
|
|
2320
|
-
|
|
2480
|
+
if (isScrollYBig && trEl) {
|
|
2481
|
+
offsetTop = trEl.offsetTop + trEl.offsetHeight
|
|
2482
|
+
} else {
|
|
2483
|
+
offsetTop = rowRest.oTop + (rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight)
|
|
2484
|
+
}
|
|
2321
2485
|
} else {
|
|
2322
|
-
const trEl = bodyScrollElem.querySelector(`.vxe-body--row[rowid="${rowid}"]`) as HTMLTableCellElement
|
|
2323
2486
|
if (trEl) {
|
|
2324
|
-
|
|
2487
|
+
offsetTop = trEl.offsetTop + trEl.offsetHeight
|
|
2325
2488
|
}
|
|
2326
2489
|
}
|
|
2490
|
+
if (isScrollYBig) {
|
|
2491
|
+
offsetTop += scrollYTop
|
|
2492
|
+
}
|
|
2493
|
+
expandEl.style.top = toCssUnit(offsetTop)
|
|
2494
|
+
|
|
2327
2495
|
if (!isUpdateHeight) {
|
|
2328
2496
|
if (rowRest.expandHeight !== expandHeight) {
|
|
2329
2497
|
isUpdateHeight = true
|
|
@@ -2334,6 +2502,9 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
|
|
|
2334
2502
|
})
|
|
2335
2503
|
if (isUpdateHeight) {
|
|
2336
2504
|
reactData.rowExpandHeightFlag++
|
|
2505
|
+
$xeTable.$nextTick(() => {
|
|
2506
|
+
updateRowOffsetTop($xeTable)
|
|
2507
|
+
})
|
|
2337
2508
|
}
|
|
2338
2509
|
}
|
|
2339
2510
|
}
|
|
@@ -2352,10 +2523,12 @@ function handleRowExpandScroll ($xeTable: VxeTableConstructor & VxeTablePrivateM
|
|
|
2352
2523
|
|
|
2353
2524
|
const Methods = {
|
|
2354
2525
|
callSlot (slotFunc: any, params: any, h: any, vNodes: any) {
|
|
2526
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2527
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
2528
|
+
|
|
2355
2529
|
if (slotFunc) {
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
return $xegrid.callSlot(slotFunc, params, h, vNodes)
|
|
2530
|
+
if ($xeGrid) {
|
|
2531
|
+
return $xeGrid.callSlot(slotFunc, params, h, vNodes)
|
|
2359
2532
|
}
|
|
2360
2533
|
if (XEUtils.isFunction(slotFunc)) {
|
|
2361
2534
|
return getSlotVNs(slotFunc.call(this, params, h, vNodes))
|
|
@@ -2372,8 +2545,11 @@ const Methods = {
|
|
|
2372
2545
|
* 获取父容器元素
|
|
2373
2546
|
*/
|
|
2374
2547
|
getParentElem () {
|
|
2375
|
-
const
|
|
2376
|
-
|
|
2548
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2549
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
2550
|
+
|
|
2551
|
+
const { $el } = this
|
|
2552
|
+
return $xeGrid ? $xeGrid.$el.parentNode : $el.parentNode
|
|
2377
2553
|
},
|
|
2378
2554
|
/**
|
|
2379
2555
|
* 获取父容器的高度
|
|
@@ -2406,8 +2582,10 @@ const Methods = {
|
|
|
2406
2582
|
* 如果存在表尾合计滚动条,则需要排除滚动条高度
|
|
2407
2583
|
*/
|
|
2408
2584
|
getExcludeHeight () {
|
|
2409
|
-
const
|
|
2410
|
-
|
|
2585
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2586
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
2587
|
+
|
|
2588
|
+
return $xeGrid ? $xeGrid.getExcludeHeight() : 0
|
|
2411
2589
|
},
|
|
2412
2590
|
/**
|
|
2413
2591
|
* 重置表格的一切数据状态
|
|
@@ -2488,6 +2666,9 @@ const Methods = {
|
|
|
2488
2666
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
2489
2667
|
let treeData = []
|
|
2490
2668
|
let fullData = datas ? datas.slice(0) : []
|
|
2669
|
+
if (fullData.length > supportMaxRow) {
|
|
2670
|
+
errLog('vxe.error.errMaxRow', [supportMaxRow])
|
|
2671
|
+
}
|
|
2491
2672
|
if (treeConfig) {
|
|
2492
2673
|
// 树结构自动转换
|
|
2493
2674
|
if (treeOpts.transform) {
|
|
@@ -2732,25 +2913,19 @@ const Methods = {
|
|
|
2732
2913
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2733
2914
|
|
|
2734
2915
|
const { treeConfig } = props
|
|
2735
|
-
const { treeExpandedMaps } =
|
|
2736
|
-
const { fullAllDataRowIdData, tableFullData, tableFullTreeData } = internalData
|
|
2916
|
+
const { fullAllDataRowIdData, tableFullData, tableFullTreeData, treeExpandedMaps } = internalData
|
|
2737
2917
|
const treeOpts = $xeTable.computeTreeOpts
|
|
2738
2918
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
2739
2919
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
2740
2920
|
const { lazy } = treeOpts
|
|
2741
|
-
const rowkey = getRowkey($xeTable)
|
|
2742
|
-
const isDeepKey = rowkey.indexOf('.') > -1
|
|
2743
2921
|
const fullAllDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = { ...fullAllDataRowIdData } // 存在已删除数据
|
|
2744
2922
|
const fullDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = {}
|
|
2745
|
-
const treeTempExpandedMaps = { ...treeExpandedMaps }
|
|
2746
2923
|
|
|
2747
|
-
const
|
|
2924
|
+
const { handleUpdateRowId } = createHandleUpdateRowId($xeTable)
|
|
2748
2925
|
const handleRowCache = (row: any, index: number, items: any, currIndex: number, parentRow: any, rowid: string, level: number, seq: string | number) => {
|
|
2749
2926
|
let rowRest = fullAllDataRowIdMaps[rowid]
|
|
2750
2927
|
if (!rowRest) {
|
|
2751
2928
|
rowRest = { row, rowid, seq, index: -1, _index: -1, $index: -1, treeIndex: index, items, parent: parentRow, level, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
|
|
2752
|
-
fullDataRowIdMaps[rowid] = rowRest
|
|
2753
|
-
fullAllDataRowIdMaps[rowid] = rowRest
|
|
2754
2929
|
}
|
|
2755
2930
|
rowRest.treeLoaded = false
|
|
2756
2931
|
rowRest.expandLoaded = false
|
|
@@ -2761,19 +2936,21 @@ const Methods = {
|
|
|
2761
2936
|
rowRest.level = level
|
|
2762
2937
|
rowRest.index = currIndex
|
|
2763
2938
|
rowRest.treeIndex = index
|
|
2939
|
+
|
|
2940
|
+
fullDataRowIdMaps[rowid] = rowRest
|
|
2941
|
+
fullAllDataRowIdMaps[rowid] = rowRest
|
|
2764
2942
|
}
|
|
2765
2943
|
|
|
2766
2944
|
if (treeConfig) {
|
|
2767
2945
|
XEUtils.eachTree(tableFullTreeData, (row, index, items, path, parentRow, nodes) => {
|
|
2768
|
-
const rowid =
|
|
2946
|
+
const rowid = handleUpdateRowId(row)
|
|
2769
2947
|
if (treeConfig && lazy) {
|
|
2770
|
-
const treeExpRest = treeTempExpandedMaps[rowid]
|
|
2771
2948
|
if (row[hasChildField] && row[childrenField] === undefined) {
|
|
2772
2949
|
row[childrenField] = null
|
|
2773
2950
|
}
|
|
2774
|
-
if (
|
|
2951
|
+
if (treeExpandedMaps[rowid]) {
|
|
2775
2952
|
if (!row[childrenField] || !row[childrenField].length) {
|
|
2776
|
-
delete
|
|
2953
|
+
delete treeExpandedMaps[rowid]
|
|
2777
2954
|
}
|
|
2778
2955
|
}
|
|
2779
2956
|
}
|
|
@@ -2781,29 +2958,27 @@ const Methods = {
|
|
|
2781
2958
|
}, { children: childrenField })
|
|
2782
2959
|
} else {
|
|
2783
2960
|
tableFullData.forEach((row, index, items) => {
|
|
2784
|
-
handleRowCache(row, index, items, index, null,
|
|
2961
|
+
handleRowCache(row, index, items, index, null, handleUpdateRowId(row), 0, index + 1)
|
|
2785
2962
|
})
|
|
2786
2963
|
}
|
|
2787
2964
|
|
|
2788
2965
|
internalData.fullDataRowIdData = fullDataRowIdMaps
|
|
2789
2966
|
internalData.fullAllDataRowIdData = fullAllDataRowIdMaps
|
|
2790
|
-
reactData.
|
|
2967
|
+
reactData.treeExpandedFlag++
|
|
2791
2968
|
},
|
|
2792
2969
|
cacheSourceMap (fullData: any[]) {
|
|
2793
|
-
|
|
2970
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2971
|
+
const props = $xeTable
|
|
2972
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
2973
|
+
|
|
2974
|
+
const { treeConfig } = props
|
|
2975
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
2794
2976
|
const sourceData = XEUtils.clone(fullData, true)
|
|
2795
|
-
const
|
|
2796
|
-
|
|
2977
|
+
const { handleUpdateRowId } = createHandleUpdateRowId($xeTable)
|
|
2978
|
+
const sourceRowIdData: Record<string, any> = {}
|
|
2797
2979
|
const handleSourceRow = (row: any) => {
|
|
2798
|
-
|
|
2799
|
-
|
|
2800
|
-
rowid = getRowUniqueId()
|
|
2801
|
-
XEUtils.set(row, rowkey, rowid)
|
|
2802
|
-
}
|
|
2803
|
-
sourceDataRowIdData[rowid] = {
|
|
2804
|
-
row,
|
|
2805
|
-
rowid
|
|
2806
|
-
}
|
|
2980
|
+
const rowid = handleUpdateRowId(row)
|
|
2981
|
+
sourceRowIdData[rowid] = row
|
|
2807
2982
|
}
|
|
2808
2983
|
// 源数据缓存
|
|
2809
2984
|
if (treeConfig) {
|
|
@@ -2812,7 +2987,8 @@ const Methods = {
|
|
|
2812
2987
|
} else {
|
|
2813
2988
|
sourceData.forEach(handleSourceRow)
|
|
2814
2989
|
}
|
|
2815
|
-
|
|
2990
|
+
internalData.sourceDataRowIdData = sourceRowIdData
|
|
2991
|
+
internalData.tableSourceData = sourceData
|
|
2816
2992
|
},
|
|
2817
2993
|
getParams () {
|
|
2818
2994
|
return this.params
|
|
@@ -2900,47 +3076,22 @@ const Methods = {
|
|
|
2900
3076
|
* 根据 row 获取序号
|
|
2901
3077
|
* @param {Row} row 行对象
|
|
2902
3078
|
*/
|
|
2903
|
-
getRowSeq (
|
|
2904
|
-
const { fullAllDataRowIdData } = this
|
|
2905
|
-
if (row) {
|
|
2906
|
-
const rowid = getRowid(this, row)
|
|
2907
|
-
const rest = fullAllDataRowIdData[rowid]
|
|
2908
|
-
if (rest) {
|
|
2909
|
-
return rest.seq
|
|
2910
|
-
}
|
|
2911
|
-
}
|
|
2912
|
-
return -1
|
|
2913
|
-
},
|
|
3079
|
+
getRowSeq: createGetRowCacheProp('seq'),
|
|
2914
3080
|
/**
|
|
2915
3081
|
* 根据 row 获取相对于 data 中的索引
|
|
2916
3082
|
* @param {Row} row 行对象
|
|
2917
3083
|
*/
|
|
2918
|
-
getRowIndex (row: any)
|
|
2919
|
-
const { fullAllDataRowIdData } = this
|
|
2920
|
-
if (row) {
|
|
2921
|
-
const rowid = getRowid(this, row)
|
|
2922
|
-
const rest = fullAllDataRowIdData[rowid]
|
|
2923
|
-
if (rest) {
|
|
2924
|
-
return rest.index
|
|
2925
|
-
}
|
|
2926
|
-
}
|
|
2927
|
-
return -1
|
|
2928
|
-
},
|
|
3084
|
+
getRowIndex: createGetRowCacheProp('index') as ((row: any) => number),
|
|
2929
3085
|
/**
|
|
2930
3086
|
* 根据 row 获取相对于当前数据中的索引
|
|
2931
3087
|
* @param {Row} row 行对象
|
|
2932
3088
|
*/
|
|
2933
|
-
getVTRowIndex (row: any)
|
|
2934
|
-
|
|
2935
|
-
|
|
2936
|
-
|
|
2937
|
-
|
|
2938
|
-
|
|
2939
|
-
return rest._index
|
|
2940
|
-
}
|
|
2941
|
-
}
|
|
2942
|
-
return -1
|
|
2943
|
-
},
|
|
3089
|
+
getVTRowIndex: createGetRowCacheProp('_index') as ((row: any) => number),
|
|
3090
|
+
/**
|
|
3091
|
+
* 根据 row 获取渲染中的虚拟索引
|
|
3092
|
+
* @param {Row} row 行对象
|
|
3093
|
+
*/
|
|
3094
|
+
getVMRowIndex: createGetRowCacheProp('$index') as ((row: any) => number),
|
|
2944
3095
|
// 在 v3 中废弃
|
|
2945
3096
|
_getRowIndex (row: any) {
|
|
2946
3097
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -2948,21 +3099,6 @@ const Methods = {
|
|
|
2948
3099
|
}
|
|
2949
3100
|
return this.getVTRowIndex(row)
|
|
2950
3101
|
},
|
|
2951
|
-
/**
|
|
2952
|
-
* 根据 row 获取渲染中的虚拟索引
|
|
2953
|
-
* @param {Row} row 行对象
|
|
2954
|
-
*/
|
|
2955
|
-
getVMRowIndex (row: any) {
|
|
2956
|
-
const { fullAllDataRowIdData } = this
|
|
2957
|
-
if (row) {
|
|
2958
|
-
const rowid = getRowid(this, row)
|
|
2959
|
-
const rest = fullAllDataRowIdData[rowid]
|
|
2960
|
-
if (rest) {
|
|
2961
|
-
return rest.$index
|
|
2962
|
-
}
|
|
2963
|
-
}
|
|
2964
|
-
return -1
|
|
2965
|
-
},
|
|
2966
3102
|
// 在 v3 中废弃
|
|
2967
3103
|
$getRowIndex (row: any) {
|
|
2968
3104
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -2974,30 +3110,17 @@ const Methods = {
|
|
|
2974
3110
|
* 根据 column 获取相对于 columns 中的索引
|
|
2975
3111
|
* @param {ColumnInfo} column 列配置
|
|
2976
3112
|
*/
|
|
2977
|
-
getColumnIndex (
|
|
2978
|
-
const { fullColumnIdData } = this
|
|
2979
|
-
if (column) {
|
|
2980
|
-
const rest = fullColumnIdData[column.id]
|
|
2981
|
-
if (rest) {
|
|
2982
|
-
return rest.index
|
|
2983
|
-
}
|
|
2984
|
-
}
|
|
2985
|
-
return -1
|
|
2986
|
-
},
|
|
3113
|
+
getColumnIndex: createGetColumnCacheProp('index'),
|
|
2987
3114
|
/**
|
|
2988
3115
|
* 根据 column 获取相对于当前表格列中的索引
|
|
2989
3116
|
* @param {ColumnInfo} column 列配置
|
|
2990
3117
|
*/
|
|
2991
|
-
getVTColumnIndex (
|
|
2992
|
-
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
}
|
|
2998
|
-
}
|
|
2999
|
-
return -1
|
|
3000
|
-
},
|
|
3118
|
+
getVTColumnIndex: createGetColumnCacheProp('_index'),
|
|
3119
|
+
/**
|
|
3120
|
+
* 根据 column 获取渲染中的虚拟索引
|
|
3121
|
+
* @param {ColumnInfo} column 列配置
|
|
3122
|
+
*/
|
|
3123
|
+
getVMColumnIndex: createGetColumnCacheProp('$index'),
|
|
3001
3124
|
// 在 v3 中废弃
|
|
3002
3125
|
_getColumnIndex (column: any) {
|
|
3003
3126
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -3005,20 +3128,6 @@ const Methods = {
|
|
|
3005
3128
|
}
|
|
3006
3129
|
return this.getVTColumnIndex(column)
|
|
3007
3130
|
},
|
|
3008
|
-
/**
|
|
3009
|
-
* 根据 column 获取渲染中的虚拟索引
|
|
3010
|
-
* @param {ColumnInfo} column 列配置
|
|
3011
|
-
*/
|
|
3012
|
-
getVMColumnIndex (column: any) {
|
|
3013
|
-
const { fullColumnIdData } = this
|
|
3014
|
-
if (column) {
|
|
3015
|
-
const rest = fullColumnIdData[column.id]
|
|
3016
|
-
if (rest) {
|
|
3017
|
-
return rest.$index
|
|
3018
|
-
}
|
|
3019
|
-
}
|
|
3020
|
-
return -1
|
|
3021
|
-
},
|
|
3022
3131
|
// 在 v3 中废弃
|
|
3023
3132
|
$getColumnIndex (column: any) {
|
|
3024
3133
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -3112,9 +3221,12 @@ const Methods = {
|
|
|
3112
3221
|
const internalData = $xeTable as unknown as TableInternalData
|
|
3113
3222
|
|
|
3114
3223
|
const { keepSource, treeConfig } = props
|
|
3224
|
+
const { editStore } = reactData
|
|
3115
3225
|
const { fullAllDataRowIdData, fullDataRowIdData, tableSourceData, sourceDataRowIdData, tableFullData, afterFullData } = internalData
|
|
3226
|
+
const removeTempMaps = { ...editStore.removeMaps }
|
|
3116
3227
|
const treeOpts = $xeTable.computeTreeOpts
|
|
3117
3228
|
const { transform } = treeOpts
|
|
3229
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
3118
3230
|
if (!keepSource) {
|
|
3119
3231
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
3120
3232
|
errLog('vxe.error.reqProp', ['keep-source'])
|
|
@@ -3132,7 +3244,7 @@ const Methods = {
|
|
|
3132
3244
|
let reDelFlag = false
|
|
3133
3245
|
if (targetRows.length) {
|
|
3134
3246
|
targetRows.forEach((item: any) => {
|
|
3135
|
-
const rowid =
|
|
3247
|
+
const rowid = handleGetRowId(item)
|
|
3136
3248
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
3137
3249
|
if (rowRest) {
|
|
3138
3250
|
const row = rowRest.row
|
|
@@ -3145,6 +3257,7 @@ const Methods = {
|
|
|
3145
3257
|
XEUtils.destructuring(row, XEUtils.clone(oRow, true))
|
|
3146
3258
|
}
|
|
3147
3259
|
if (!fullDataRowIdData[rowid] && $xeTable.isRemoveByRow(row)) {
|
|
3260
|
+
delete removeTempMaps[rowid]
|
|
3148
3261
|
tableFullData.unshift(row)
|
|
3149
3262
|
afterFullData.unshift(row)
|
|
3150
3263
|
reDelFlag = true
|
|
@@ -3156,6 +3269,7 @@ const Methods = {
|
|
|
3156
3269
|
}
|
|
3157
3270
|
if (rows) {
|
|
3158
3271
|
if (reDelFlag) {
|
|
3272
|
+
editStore.removeMaps = removeTempMaps
|
|
3159
3273
|
$xeTable.updateFooter()
|
|
3160
3274
|
$xeTable.cacheRowMap(false)
|
|
3161
3275
|
$xeTable.handleTableData(treeConfig && transform)
|
|
@@ -3523,12 +3637,10 @@ const Methods = {
|
|
|
3523
3637
|
getCheckboxRecords (isFull: boolean) {
|
|
3524
3638
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3525
3639
|
const props = $xeTable
|
|
3526
|
-
const reactData = $xeTable as unknown as TableReactData
|
|
3527
3640
|
const internalData = $xeTable as unknown as TableInternalData
|
|
3528
3641
|
|
|
3529
3642
|
const { treeConfig } = props
|
|
3530
|
-
const { selectCheckboxMaps } =
|
|
3531
|
-
const { tableFullData, afterFullData, afterTreeFullData, tableFullTreeData, fullDataRowIdData, afterFullRowMaps } = internalData
|
|
3643
|
+
const { tableFullData, afterFullData, afterTreeFullData, tableFullTreeData, fullDataRowIdData, afterFullRowMaps, selectCheckboxMaps } = internalData
|
|
3532
3644
|
const treeOpts = $xeTable.computeTreeOpts
|
|
3533
3645
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
3534
3646
|
const { transform, mapChildrenField } = treeOpts
|
|
@@ -3574,7 +3686,7 @@ const Methods = {
|
|
|
3574
3686
|
const treeOpts = $xeTable.computeTreeOpts
|
|
3575
3687
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
3576
3688
|
const { transform, rowField, parentField, mapChildrenField } = treeOpts
|
|
3577
|
-
const { remote: allRemoteFilter, filterMethod: allFilterMethod } = filterOpts
|
|
3689
|
+
const { isEvery, remote: allRemoteFilter, filterMethod: allFilterMethod } = filterOpts
|
|
3578
3690
|
const { remote: allRemoteSort, sortMethod: allSortMethod, multiple: sortMultiple, chronological } = sortOpts
|
|
3579
3691
|
let tableData: any[] = []
|
|
3580
3692
|
let tableTree: any[] = []
|
|
@@ -3636,7 +3748,7 @@ const Methods = {
|
|
|
3636
3748
|
// 筛选虚拟树
|
|
3637
3749
|
tableTree = XEUtils.searchTree(tableFullTreeData, handleFilter, {
|
|
3638
3750
|
original: true,
|
|
3639
|
-
isEvery
|
|
3751
|
+
isEvery,
|
|
3640
3752
|
children: mapChildrenField,
|
|
3641
3753
|
mapChildren: childrenField
|
|
3642
3754
|
})
|
|
@@ -3650,7 +3762,7 @@ const Methods = {
|
|
|
3650
3762
|
// 还原虚拟树
|
|
3651
3763
|
tableTree = XEUtils.searchTree(tableFullTreeData, () => true, {
|
|
3652
3764
|
original: true,
|
|
3653
|
-
isEvery
|
|
3765
|
+
isEvery,
|
|
3654
3766
|
children: mapChildrenField,
|
|
3655
3767
|
mapChildren: childrenField
|
|
3656
3768
|
})
|
|
@@ -3711,7 +3823,7 @@ const Methods = {
|
|
|
3711
3823
|
// 还原虚拟树
|
|
3712
3824
|
tableTree = XEUtils.searchTree(tableFullTreeData, () => true, {
|
|
3713
3825
|
original: true,
|
|
3714
|
-
isEvery
|
|
3826
|
+
isEvery,
|
|
3715
3827
|
children: treeOpts.mapChildrenField,
|
|
3716
3828
|
mapChildren: childrenField
|
|
3717
3829
|
})
|
|
@@ -3865,6 +3977,8 @@ const Methods = {
|
|
|
3865
3977
|
* 默认执行一次,除非被重置
|
|
3866
3978
|
*/
|
|
3867
3979
|
handleLoadDefaults () {
|
|
3980
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3981
|
+
|
|
3868
3982
|
if (this.checkboxConfig) {
|
|
3869
3983
|
this.handleDefaultSelectionChecked()
|
|
3870
3984
|
}
|
|
@@ -3875,7 +3989,7 @@ const Methods = {
|
|
|
3875
3989
|
this.handleDefaultRowExpand()
|
|
3876
3990
|
}
|
|
3877
3991
|
if (this.treeConfig) {
|
|
3878
|
-
|
|
3992
|
+
handleDefaultTreeExpand($xeTable)
|
|
3879
3993
|
}
|
|
3880
3994
|
if (this.mergeCells) {
|
|
3881
3995
|
this.handleDefaultMergeCells()
|
|
@@ -3899,7 +4013,7 @@ const Methods = {
|
|
|
3899
4013
|
* 设置为固定列
|
|
3900
4014
|
*/
|
|
3901
4015
|
setColumnFixed (fieldOrColumn: any, fixed: any) {
|
|
3902
|
-
const $xeTable = this
|
|
4016
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3903
4017
|
|
|
3904
4018
|
let status = false
|
|
3905
4019
|
const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
|
|
@@ -4073,9 +4187,9 @@ const Methods = {
|
|
|
4073
4187
|
return this.refreshColumn(true)
|
|
4074
4188
|
},
|
|
4075
4189
|
handleCustomRestore (storeData: any) {
|
|
4076
|
-
const $
|
|
4077
|
-
const reactData = $
|
|
4078
|
-
const internalData = $
|
|
4190
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
4191
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
4192
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
4079
4193
|
|
|
4080
4194
|
let { collectColumn } = internalData
|
|
4081
4195
|
const { resizableData, sortData, visibleData, fixedData } = storeData
|
|
@@ -4145,15 +4259,27 @@ const Methods = {
|
|
|
4145
4259
|
}
|
|
4146
4260
|
},
|
|
4147
4261
|
getCustomStoreData () {
|
|
4148
|
-
const
|
|
4149
|
-
const
|
|
4150
|
-
const
|
|
4151
|
-
|
|
4152
|
-
const
|
|
4153
|
-
const
|
|
4154
|
-
const
|
|
4155
|
-
|
|
4156
|
-
|
|
4262
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
4263
|
+
const props = $xeTable
|
|
4264
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
4265
|
+
|
|
4266
|
+
const { id } = props
|
|
4267
|
+
const customOpts = $xeTable.computeCustomOpts
|
|
4268
|
+
const { collectColumn } = internalData
|
|
4269
|
+
const { storage, checkMethod } = customOpts
|
|
4270
|
+
const isAllCustom = storage === true
|
|
4271
|
+
const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {})
|
|
4272
|
+
const isCustomResizable = isAllCustom || storageOpts.resizable
|
|
4273
|
+
const isCustomVisible = isAllCustom || storageOpts.visible
|
|
4274
|
+
const isCustomFixed = isAllCustom || storageOpts.fixed
|
|
4275
|
+
const isCustomSort = isAllCustom || storageOpts.sort
|
|
4276
|
+
const resizableData: Record<string, number> = {}
|
|
4277
|
+
const sortData: Record<string, number> = {}
|
|
4278
|
+
const visibleData: Record<string, boolean> = {}
|
|
4279
|
+
const fixedData: Record<string, VxeColumnPropTypes.Fixed> = {}
|
|
4280
|
+
const storeData: VxeTableDefines.CustomStoreData = {
|
|
4281
|
+
resizableData: undefined,
|
|
4282
|
+
sortData: undefined,
|
|
4157
4283
|
visibleData: undefined,
|
|
4158
4284
|
fixedData: undefined
|
|
4159
4285
|
}
|
|
@@ -4163,46 +4289,36 @@ const Methods = {
|
|
|
4163
4289
|
}
|
|
4164
4290
|
let hasResizable = 0
|
|
4165
4291
|
let hasSort = 0
|
|
4166
|
-
let
|
|
4292
|
+
let hasFixed = 0
|
|
4167
4293
|
let hasVisible = 0
|
|
4168
4294
|
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
4295
|
+
const colKey = column.getKey()
|
|
4296
|
+
if (!colKey) {
|
|
4297
|
+
errLog('vxe.error.reqProp', [`${column.getTitle() || column.type || ''} -> column.field=?`])
|
|
4298
|
+
return
|
|
4299
|
+
}
|
|
4169
4300
|
// 只支持一级
|
|
4170
4301
|
if (!parentColumn) {
|
|
4171
|
-
|
|
4172
|
-
|
|
4173
|
-
|
|
4174
|
-
hasSort = 1
|
|
4175
|
-
sortData[colKey] = column.renderSortNumber
|
|
4176
|
-
}
|
|
4177
|
-
})
|
|
4178
|
-
if (column.fixed !== column.defaultFixed) {
|
|
4179
|
-
const colKey = column.getKey()
|
|
4180
|
-
if (colKey) {
|
|
4181
|
-
hasFixedt = 1
|
|
4182
|
-
fixedData[colKey] = column.fixed
|
|
4183
|
-
}
|
|
4302
|
+
if (isCustomSort) {
|
|
4303
|
+
hasSort = 1
|
|
4304
|
+
sortData[colKey] = column.renderSortNumber
|
|
4184
4305
|
}
|
|
4185
|
-
|
|
4186
|
-
|
|
4187
|
-
|
|
4188
|
-
if (colKey) {
|
|
4189
|
-
hasResizable = 1
|
|
4190
|
-
resizableData[colKey] = column.renderWidth
|
|
4306
|
+
if (isCustomFixed && column.fixed !== column.defaultFixed) {
|
|
4307
|
+
hasFixed = 1
|
|
4308
|
+
fixedData[colKey] = column.fixed
|
|
4191
4309
|
}
|
|
4192
4310
|
}
|
|
4193
|
-
if (
|
|
4311
|
+
if (isCustomResizable && column.resizeWidth) {
|
|
4312
|
+
hasResizable = 1
|
|
4313
|
+
resizableData[colKey] = column.renderWidth
|
|
4314
|
+
}
|
|
4315
|
+
if (isCustomVisible && (!checkMethod || checkMethod({ column }))) {
|
|
4194
4316
|
if (!column.visible && column.defaultVisible) {
|
|
4195
|
-
|
|
4196
|
-
|
|
4197
|
-
hasVisible = 1
|
|
4198
|
-
visibleData[colKey] = false
|
|
4199
|
-
}
|
|
4317
|
+
hasVisible = 1
|
|
4318
|
+
visibleData[colKey] = false
|
|
4200
4319
|
} else if (column.visible && !column.defaultVisible) {
|
|
4201
|
-
|
|
4202
|
-
|
|
4203
|
-
hasVisible = 1
|
|
4204
|
-
visibleData[colKey] = true
|
|
4205
|
-
}
|
|
4320
|
+
hasVisible = 1
|
|
4321
|
+
visibleData[colKey] = true
|
|
4206
4322
|
}
|
|
4207
4323
|
}
|
|
4208
4324
|
})
|
|
@@ -4212,7 +4328,7 @@ const Methods = {
|
|
|
4212
4328
|
if (hasSort) {
|
|
4213
4329
|
storeData.sortData = sortData
|
|
4214
4330
|
}
|
|
4215
|
-
if (
|
|
4331
|
+
if (hasFixed) {
|
|
4216
4332
|
storeData.fixedData = fixedData
|
|
4217
4333
|
}
|
|
4218
4334
|
if (hasVisible) {
|
|
@@ -4221,9 +4337,9 @@ const Methods = {
|
|
|
4221
4337
|
return storeData
|
|
4222
4338
|
},
|
|
4223
4339
|
saveCustomStore (type: any) {
|
|
4224
|
-
const $xeTable = this
|
|
4340
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
4225
4341
|
const props = $xeTable
|
|
4226
|
-
const reactData = $xeTable as TableReactData
|
|
4342
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
4227
4343
|
|
|
4228
4344
|
const { customConfig } = props
|
|
4229
4345
|
const tableId = $xeTable.computeTableId
|
|
@@ -4701,12 +4817,13 @@ const Methods = {
|
|
|
4701
4817
|
const internalData = $xeTable as unknown as TableInternalData
|
|
4702
4818
|
|
|
4703
4819
|
const { fullAllDataRowIdData, afterFullData } = internalData
|
|
4820
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
4704
4821
|
const rowOpts = $xeTable.computeRowOpts
|
|
4705
4822
|
const cellOpts = $xeTable.computeCellOpts
|
|
4706
4823
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
4707
4824
|
const rest: Record<string, number> = {}
|
|
4708
4825
|
afterFullData.forEach(row => {
|
|
4709
|
-
const rowid =
|
|
4826
|
+
const rowid = handleGetRowId(row)
|
|
4710
4827
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
4711
4828
|
if (rowRest) {
|
|
4712
4829
|
const resizeHeight = rowRest.resizeHeight
|
|
@@ -4734,8 +4851,9 @@ const Methods = {
|
|
|
4734
4851
|
rHeight = Math.floor(rHeight * bodyHeight)
|
|
4735
4852
|
}
|
|
4736
4853
|
if (rHeight) {
|
|
4854
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
4737
4855
|
rows.forEach(row => {
|
|
4738
|
-
const rowid = XEUtils.isString(row) || XEUtils.isNumber(row) ? row :
|
|
4856
|
+
const rowid = XEUtils.isString(row) || XEUtils.isNumber(row) ? row : handleGetRowId(row)
|
|
4739
4857
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
4740
4858
|
if (rowRest) {
|
|
4741
4859
|
rowRest.resizeHeight = rHeight
|
|
@@ -4882,6 +5000,9 @@ const Methods = {
|
|
|
4882
5000
|
}
|
|
4883
5001
|
},
|
|
4884
5002
|
preventEvent (evnt: any, type: any, args: any, next: any, end: any) {
|
|
5003
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5004
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
5005
|
+
|
|
4885
5006
|
let evntList = interceptor.get(type)
|
|
4886
5007
|
|
|
4887
5008
|
// 兼容老版本
|
|
@@ -4895,8 +5016,21 @@ const Methods = {
|
|
|
4895
5016
|
}
|
|
4896
5017
|
// 兼容老版本
|
|
4897
5018
|
|
|
4898
|
-
let rest
|
|
4899
|
-
|
|
5019
|
+
let rest = null
|
|
5020
|
+
let isStop = false
|
|
5021
|
+
for (let i = 0; i < evntList.length; i++) {
|
|
5022
|
+
const func = evntList[i]
|
|
5023
|
+
const fnRest = func(Object.assign({ $grid: $xeGrid, $table: $xeTable, $event: evnt }, args))
|
|
5024
|
+
if (fnRest === false) {
|
|
5025
|
+
isStop = true
|
|
5026
|
+
break
|
|
5027
|
+
} else if (fnRest && fnRest.status === false) {
|
|
5028
|
+
rest = fnRest.result
|
|
5029
|
+
isStop = true
|
|
5030
|
+
break
|
|
5031
|
+
}
|
|
5032
|
+
}
|
|
5033
|
+
if (!isStop) {
|
|
4900
5034
|
if (next) {
|
|
4901
5035
|
rest = next()
|
|
4902
5036
|
}
|
|
@@ -4910,7 +5044,10 @@ const Methods = {
|
|
|
4910
5044
|
* 全局按下事件处理
|
|
4911
5045
|
*/
|
|
4912
5046
|
handleGlobalMousedownEvent (evnt: any) {
|
|
4913
|
-
const
|
|
5047
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5048
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
5049
|
+
|
|
5050
|
+
const { $el, $refs, $toolbar, mouseConfig, editStore, ctxMenuStore, editRules, editOpts, validOpts, areaOpts, filterStore, customStore, getRowNode } = this
|
|
4914
5051
|
const { actived } = editStore
|
|
4915
5052
|
const { customWrapper, refValidTooltip } = $refs
|
|
4916
5053
|
const tableFilter = $refs.refTableFilter
|
|
@@ -4996,7 +5133,7 @@ const Methods = {
|
|
|
4996
5133
|
}
|
|
4997
5134
|
}
|
|
4998
5135
|
} else if (mouseConfig) {
|
|
4999
|
-
if (!getEventTargetNode(evnt, $el).flag && !($
|
|
5136
|
+
if (!getEventTargetNode(evnt, $el).flag && !($xeGrid && getEventTargetNode(evnt, $xeGrid.$el).flag) && !(tableMenu && getEventTargetNode(evnt, tableMenu.$el).flag) && !($toolbar && getEventTargetNode(evnt, $toolbar.$el).flag)) {
|
|
5000
5137
|
if (this.clearSelected) {
|
|
5001
5138
|
this.clearSelected()
|
|
5002
5139
|
}
|
|
@@ -5018,7 +5155,7 @@ const Methods = {
|
|
|
5018
5155
|
if (ctxMenuStore.visible && tableMenu && !getEventTargetNode(evnt, tableMenu.$el).flag) {
|
|
5019
5156
|
this.closeMenu()
|
|
5020
5157
|
}
|
|
5021
|
-
const isActivated = getEventTargetNode(evnt, ($
|
|
5158
|
+
const isActivated = getEventTargetNode(evnt, ($xeGrid || this).$el).flag
|
|
5022
5159
|
// 如果存在校验,点击了表格之外则清除
|
|
5023
5160
|
if (!isActivated && editRules && validOpts.autoClear) {
|
|
5024
5161
|
this.validErrorMaps = {}
|
|
@@ -5079,8 +5216,9 @@ const Methods = {
|
|
|
5079
5216
|
* 全局键盘事件
|
|
5080
5217
|
*/
|
|
5081
5218
|
handleGlobalKeydownEvent (evnt: any) {
|
|
5082
|
-
const $xeTable = this
|
|
5083
|
-
const internalData = $xeTable
|
|
5219
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5220
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5221
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
5084
5222
|
|
|
5085
5223
|
// 该行为只对当前激活的表格有效
|
|
5086
5224
|
if (this.isActivated) {
|
|
@@ -5171,7 +5309,7 @@ const Methods = {
|
|
|
5171
5309
|
if (keyboardOpts.enterToTab) {
|
|
5172
5310
|
this.moveTabSelected(activeParams, hasShiftKey, evnt)
|
|
5173
5311
|
} else {
|
|
5174
|
-
this.
|
|
5312
|
+
this.moveEnterSelected(activeParams, isLeftArrow, true, isRightArrow, false, evnt)
|
|
5175
5313
|
}
|
|
5176
5314
|
} else {
|
|
5177
5315
|
if (keyboardOpts.enterToTab) {
|
|
@@ -5203,7 +5341,7 @@ const Methods = {
|
|
|
5203
5341
|
return
|
|
5204
5342
|
}
|
|
5205
5343
|
}
|
|
5206
|
-
this.
|
|
5344
|
+
this.moveEnterSelected(activeParams, isLeftArrow, false, isRightArrow, true, evnt)
|
|
5207
5345
|
if (enterMethod) {
|
|
5208
5346
|
enterMethod(etrParams)
|
|
5209
5347
|
}
|
|
@@ -5227,10 +5365,7 @@ const Methods = {
|
|
|
5227
5365
|
if (!isEditStatus) {
|
|
5228
5366
|
// 如果按下了方向键
|
|
5229
5367
|
if (selected.row && selected.column) {
|
|
5230
|
-
|
|
5231
|
-
} else if ((isUpArrow || isDwArrow) && (rowOpts.isCurrent || highlightCurrentRow)) {
|
|
5232
|
-
// 当前行按键上下移动
|
|
5233
|
-
this.moveCurrentRow(isUpArrow, isDwArrow, evnt)
|
|
5368
|
+
$xeTable.moveArrowSelected(selected.args, isLeftArrow, isUpArrow, isRightArrow, isDwArrow, evnt)
|
|
5234
5369
|
}
|
|
5235
5370
|
}
|
|
5236
5371
|
} else if (isTab && keyboardConfig && keyboardOpts.isTab) {
|
|
@@ -5250,7 +5385,7 @@ const Methods = {
|
|
|
5250
5385
|
column: selected.column,
|
|
5251
5386
|
columnIndex: this.getColumnIndex(selected.column),
|
|
5252
5387
|
$table: this,
|
|
5253
|
-
$grid:
|
|
5388
|
+
$grid: $xeGrid
|
|
5254
5389
|
}
|
|
5255
5390
|
// 是否被禁用
|
|
5256
5391
|
if (!beforeEditMethod || beforeEditMethod(params)) {
|
|
@@ -5275,7 +5410,7 @@ const Methods = {
|
|
|
5275
5410
|
column: selected.column,
|
|
5276
5411
|
columnIndex: this.getColumnIndex(selected.column),
|
|
5277
5412
|
$table: this,
|
|
5278
|
-
$grid:
|
|
5413
|
+
$grid: $xeGrid
|
|
5279
5414
|
}
|
|
5280
5415
|
// 是否被禁用
|
|
5281
5416
|
if (!beforeEditMethod || beforeEditMethod(params)) {
|
|
@@ -5302,7 +5437,7 @@ const Methods = {
|
|
|
5302
5437
|
rowIndex: this.getRowIndex(parentRow),
|
|
5303
5438
|
$rowIndex: this.getVMRowIndex(parentRow),
|
|
5304
5439
|
$table: this,
|
|
5305
|
-
$grid:
|
|
5440
|
+
$grid: $xeGrid
|
|
5306
5441
|
}
|
|
5307
5442
|
this.setTreeExpand(parentRow, false)
|
|
5308
5443
|
.then(() => this.scrollToRow(parentRow))
|
|
@@ -5323,7 +5458,7 @@ const Methods = {
|
|
|
5323
5458
|
column: selected.column,
|
|
5324
5459
|
columnIndex: this.getColumnIndex(selected.column),
|
|
5325
5460
|
$table: this,
|
|
5326
|
-
$grid:
|
|
5461
|
+
$grid: $xeGrid
|
|
5327
5462
|
}
|
|
5328
5463
|
if (!beforeEditMethod || beforeEditMethod(params)) {
|
|
5329
5464
|
if (editMethod) {
|
|
@@ -5445,7 +5580,7 @@ const Methods = {
|
|
|
5445
5580
|
return
|
|
5446
5581
|
}
|
|
5447
5582
|
if (tooltipStore.column !== column || !tooltipStore.visible) {
|
|
5448
|
-
handleTooltip($xeTable, evnt, thEl, cellEl,
|
|
5583
|
+
handleTooltip($xeTable, evnt, thEl, thEl.querySelector<HTMLElement>('.vxe-cell--title') || cellEl, params)
|
|
5449
5584
|
}
|
|
5450
5585
|
},
|
|
5451
5586
|
/**
|
|
@@ -5476,7 +5611,7 @@ const Methods = {
|
|
|
5476
5611
|
}
|
|
5477
5612
|
}
|
|
5478
5613
|
if (tooltipStore.column !== column || tooltipStore.row !== row || !tooltipStore.visible) {
|
|
5479
|
-
handleTooltip($xeTable, evnt, tdEl, tdEl.querySelector('.vxe-cell--
|
|
5614
|
+
handleTooltip($xeTable, evnt, tdEl, tdEl.querySelector<HTMLElement>('.vxe-cell--label') || tdEl.querySelector<HTMLElement>('.vxe-cell--wrapper'), params)
|
|
5480
5615
|
}
|
|
5481
5616
|
},
|
|
5482
5617
|
/**
|
|
@@ -5488,10 +5623,10 @@ const Methods = {
|
|
|
5488
5623
|
|
|
5489
5624
|
const { column } = params
|
|
5490
5625
|
const { tooltipStore } = reactData
|
|
5491
|
-
const
|
|
5626
|
+
const tdEl = evnt.currentTarget as HTMLTableCellElement
|
|
5492
5627
|
handleTargetEnterEvent($xeTable, tooltipStore.column !== column || !!tooltipStore.row)
|
|
5493
5628
|
if (tooltipStore.column !== column || !tooltipStore.visible) {
|
|
5494
|
-
handleTooltip($xeTable, evnt,
|
|
5629
|
+
handleTooltip($xeTable, evnt, tdEl, tdEl.querySelector<HTMLElement>('.vxe-cell--label') || tdEl.querySelector('.vxe-cell--wrapper') as HTMLElement, params)
|
|
5495
5630
|
}
|
|
5496
5631
|
},
|
|
5497
5632
|
openTooltip (target: any, content: any) {
|
|
@@ -5549,11 +5684,16 @@ const Methods = {
|
|
|
5549
5684
|
* 获取复选框半选状态的行数据
|
|
5550
5685
|
*/
|
|
5551
5686
|
getCheckboxIndeterminateRecords (isFull: any) {
|
|
5552
|
-
const
|
|
5687
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5688
|
+
const props = $xeTable
|
|
5689
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5690
|
+
|
|
5691
|
+
const { treeConfig } = props
|
|
5692
|
+
const { fullDataRowIdData, treeIndeterminateRowMaps } = internalData
|
|
5553
5693
|
if (treeConfig) {
|
|
5554
5694
|
const fullRest: any[] = []
|
|
5555
5695
|
const defRest: any[] = []
|
|
5556
|
-
XEUtils.each(
|
|
5696
|
+
XEUtils.each(treeIndeterminateRowMaps, (item, rowid) => {
|
|
5557
5697
|
if (item) {
|
|
5558
5698
|
fullRest.push(item)
|
|
5559
5699
|
if (fullDataRowIdData[rowid]) {
|
|
@@ -5608,7 +5748,7 @@ const Methods = {
|
|
|
5608
5748
|
},
|
|
5609
5749
|
setCheckboxRowKey (keys: any, checked: boolean) {
|
|
5610
5750
|
const $xeTable = this
|
|
5611
|
-
const internalData = $xeTable
|
|
5751
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5612
5752
|
|
|
5613
5753
|
const { fullAllDataRowIdData } = internalData
|
|
5614
5754
|
if (keys && !XEUtils.isArray(keys)) {
|
|
@@ -5625,23 +5765,25 @@ const Methods = {
|
|
|
5625
5765
|
},
|
|
5626
5766
|
isCheckedByCheckboxRow (row: any) {
|
|
5627
5767
|
const $xeTable = this
|
|
5628
|
-
const reactData = $xeTable
|
|
5768
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
5769
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5629
5770
|
|
|
5630
|
-
const {
|
|
5771
|
+
const { updateCheckboxFlag } = reactData
|
|
5772
|
+
const { selectCheckboxMaps } = internalData
|
|
5631
5773
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5632
5774
|
const { checkField } = checkboxOpts
|
|
5633
5775
|
if (checkField) {
|
|
5634
5776
|
return XEUtils.get(row, checkField)
|
|
5635
5777
|
}
|
|
5636
|
-
return !!selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5778
|
+
return !!updateCheckboxFlag && !!selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5637
5779
|
},
|
|
5638
5780
|
isCheckedByCheckboxRowKey (rowid: string) {
|
|
5639
|
-
const $xeTable = this
|
|
5640
|
-
const reactData = $xeTable
|
|
5641
|
-
const internalData = $xeTable
|
|
5781
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5782
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
5783
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5642
5784
|
|
|
5643
|
-
const {
|
|
5644
|
-
const { fullAllDataRowIdData } = internalData
|
|
5785
|
+
const { updateCheckboxFlag } = reactData
|
|
5786
|
+
const { fullAllDataRowIdData, selectCheckboxMaps } = internalData
|
|
5645
5787
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5646
5788
|
const { checkField } = checkboxOpts
|
|
5647
5789
|
if (checkField) {
|
|
@@ -5651,21 +5793,21 @@ const Methods = {
|
|
|
5651
5793
|
}
|
|
5652
5794
|
return false
|
|
5653
5795
|
}
|
|
5654
|
-
return !!selectCheckboxMaps[rowid]
|
|
5796
|
+
return !!updateCheckboxFlag && !!selectCheckboxMaps[rowid]
|
|
5655
5797
|
},
|
|
5656
5798
|
isIndeterminateByCheckboxRow (row: any) {
|
|
5657
|
-
const $xeTable = this
|
|
5658
|
-
const
|
|
5799
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5800
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5659
5801
|
|
|
5660
|
-
const {
|
|
5661
|
-
return !!
|
|
5802
|
+
const { treeIndeterminateRowMaps } = internalData
|
|
5803
|
+
return !!treeIndeterminateRowMaps[getRowid($xeTable, row)] && !$xeTable.isCheckedByCheckboxRow(row)
|
|
5662
5804
|
},
|
|
5663
5805
|
isIndeterminateByCheckboxRowKey (rowid: string) {
|
|
5664
5806
|
const $xeTable = this
|
|
5665
|
-
const
|
|
5807
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5666
5808
|
|
|
5667
|
-
const {
|
|
5668
|
-
return !!
|
|
5809
|
+
const { treeIndeterminateRowMaps } = internalData
|
|
5810
|
+
return !!treeIndeterminateRowMaps[rowid] && !$xeTable.isCheckedByCheckboxRowKey(rowid)
|
|
5669
5811
|
},
|
|
5670
5812
|
/**
|
|
5671
5813
|
* 切换选中
|
|
@@ -5675,15 +5817,16 @@ const Methods = {
|
|
|
5675
5817
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5676
5818
|
const props = $xeTable
|
|
5677
5819
|
const reactData = $xeTable as unknown as TableReactData
|
|
5820
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5678
5821
|
|
|
5679
5822
|
const { treeConfig } = props
|
|
5680
|
-
const { selectCheckboxMaps } =
|
|
5681
|
-
const selectRowMaps = Object.assign({}, selectCheckboxMaps)
|
|
5823
|
+
const { selectCheckboxMaps } = internalData
|
|
5682
5824
|
const treeOpts = $xeTable.computeTreeOpts
|
|
5683
5825
|
const { transform, mapChildrenField } = treeOpts
|
|
5684
5826
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
5685
5827
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5686
5828
|
const { checkField, checkStrictly, checkMethod } = checkboxOpts
|
|
5829
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
5687
5830
|
// indeterminateField 仅支持读取
|
|
5688
5831
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
5689
5832
|
if (checkField) {
|
|
@@ -5699,18 +5842,17 @@ const Methods = {
|
|
|
5699
5842
|
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5700
5843
|
}
|
|
5701
5844
|
}, { children: transform ? mapChildrenField : childrenField })
|
|
5702
|
-
reactData.
|
|
5845
|
+
reactData.updateCheckboxFlag++
|
|
5703
5846
|
return
|
|
5704
|
-
} else {
|
|
5705
|
-
// 列表
|
|
5706
|
-
rows.forEach(row => {
|
|
5707
|
-
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5708
|
-
XEUtils.set(row, checkField, checked)
|
|
5709
|
-
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5710
|
-
}
|
|
5711
|
-
})
|
|
5712
5847
|
}
|
|
5713
|
-
|
|
5848
|
+
// 列表
|
|
5849
|
+
rows.forEach(row => {
|
|
5850
|
+
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5851
|
+
XEUtils.set(row, checkField, checked)
|
|
5852
|
+
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5853
|
+
}
|
|
5854
|
+
})
|
|
5855
|
+
reactData.updateCheckboxFlag++
|
|
5714
5856
|
return
|
|
5715
5857
|
}
|
|
5716
5858
|
|
|
@@ -5718,51 +5860,55 @@ const Methods = {
|
|
|
5718
5860
|
if (treeConfig && !checkStrictly) {
|
|
5719
5861
|
// 更新子节点状态
|
|
5720
5862
|
XEUtils.eachTree(rows, (row) => {
|
|
5721
|
-
const rowid =
|
|
5863
|
+
const rowid = handleGetRowId(row)
|
|
5722
5864
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5723
5865
|
if (checked) {
|
|
5724
|
-
|
|
5866
|
+
selectCheckboxMaps[rowid] = row
|
|
5725
5867
|
} else {
|
|
5726
|
-
if (
|
|
5727
|
-
delete
|
|
5868
|
+
if (selectCheckboxMaps[rowid]) {
|
|
5869
|
+
delete selectCheckboxMaps[rowid]
|
|
5728
5870
|
}
|
|
5729
5871
|
}
|
|
5730
5872
|
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5731
5873
|
}
|
|
5732
5874
|
}, { children: transform ? mapChildrenField : childrenField })
|
|
5733
|
-
reactData.
|
|
5875
|
+
reactData.updateCheckboxFlag++
|
|
5734
5876
|
return
|
|
5735
5877
|
}
|
|
5736
5878
|
|
|
5737
5879
|
// 列表
|
|
5738
5880
|
rows.forEach(row => {
|
|
5739
|
-
const rowid =
|
|
5881
|
+
const rowid = handleGetRowId(row)
|
|
5740
5882
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5741
5883
|
if (checked) {
|
|
5742
|
-
if (!
|
|
5743
|
-
|
|
5884
|
+
if (!selectCheckboxMaps[rowid]) {
|
|
5885
|
+
selectCheckboxMaps[rowid] = row
|
|
5744
5886
|
}
|
|
5745
5887
|
} else {
|
|
5746
|
-
if (
|
|
5747
|
-
delete
|
|
5888
|
+
if (selectCheckboxMaps[rowid]) {
|
|
5889
|
+
delete selectCheckboxMaps[rowid]
|
|
5748
5890
|
}
|
|
5749
5891
|
}
|
|
5750
5892
|
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5893
|
+
reactData.updateCheckboxFlag++
|
|
5751
5894
|
}
|
|
5752
5895
|
})
|
|
5753
|
-
reactData.selectCheckboxMaps = selectRowMaps
|
|
5754
5896
|
},
|
|
5755
5897
|
/**
|
|
5756
5898
|
* 即将移除
|
|
5757
5899
|
* @deprecated
|
|
5758
5900
|
*/
|
|
5759
5901
|
handleSelectRow ({ row }: any, checked: boolean, isForce?: boolean) {
|
|
5760
|
-
const $xeTable = this
|
|
5902
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5761
5903
|
|
|
5762
5904
|
$xeTable.handleBatchSelectRows([row], checked, isForce)
|
|
5763
5905
|
},
|
|
5764
5906
|
handleToggleCheckRowEvent (evnt: any, params: any) {
|
|
5765
|
-
const
|
|
5907
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5908
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5909
|
+
|
|
5910
|
+
const { selectCheckboxMaps } = internalData
|
|
5911
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5766
5912
|
const { checkField, trigger } = checkboxOpts
|
|
5767
5913
|
const { row } = params
|
|
5768
5914
|
if (trigger === 'manual') {
|
|
@@ -5772,47 +5918,52 @@ const Methods = {
|
|
|
5772
5918
|
if (checkField) {
|
|
5773
5919
|
checked = !XEUtils.get(row, checkField)
|
|
5774
5920
|
} else {
|
|
5775
|
-
checked = !selectCheckboxMaps[getRowid(
|
|
5921
|
+
checked = !selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5776
5922
|
}
|
|
5777
5923
|
if (evnt) {
|
|
5778
|
-
|
|
5924
|
+
$xeTable.triggerCheckRowEvent(evnt, params, checked)
|
|
5779
5925
|
} else {
|
|
5780
|
-
|
|
5781
|
-
|
|
5926
|
+
$xeTable.handleBatchSelectRows([row], checked)
|
|
5927
|
+
$xeTable.checkSelectionStatus()
|
|
5782
5928
|
}
|
|
5783
5929
|
},
|
|
5784
5930
|
triggerCheckRowEvent (evnt: any, params: any, checked: any) {
|
|
5785
|
-
const $xeTable = this
|
|
5931
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5932
|
+
const props = $xeTable
|
|
5933
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5786
5934
|
|
|
5787
|
-
const { checkboxOpts, afterFullData } = this
|
|
5788
|
-
const { checkMethod, trigger } = checkboxOpts
|
|
5789
5935
|
const { row } = params
|
|
5936
|
+
const { afterFullData } = internalData
|
|
5937
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5938
|
+
const { checkMethod, trigger } = checkboxOpts
|
|
5790
5939
|
if (trigger === 'manual') {
|
|
5791
5940
|
return
|
|
5792
5941
|
}
|
|
5793
5942
|
evnt.stopPropagation()
|
|
5794
|
-
if (checkboxOpts.isShiftKey && evnt.shiftKey && !
|
|
5795
|
-
const checkboxRecords =
|
|
5943
|
+
if (checkboxOpts.isShiftKey && evnt.shiftKey && !props.treeConfig) {
|
|
5944
|
+
const checkboxRecords = $xeTable.getCheckboxRecords()
|
|
5796
5945
|
if (checkboxRecords.length) {
|
|
5797
5946
|
const firstRow = checkboxRecords[0]
|
|
5798
|
-
const _rowIndex =
|
|
5799
|
-
const _firstRowIndex =
|
|
5947
|
+
const _rowIndex = $xeTable.getVTRowIndex(row)
|
|
5948
|
+
const _firstRowIndex = $xeTable.getVTRowIndex(firstRow)
|
|
5800
5949
|
if (_rowIndex !== _firstRowIndex) {
|
|
5801
|
-
|
|
5950
|
+
$xeTable.setAllCheckboxRow(false)
|
|
5802
5951
|
const rangeRows = _rowIndex < _firstRowIndex ? afterFullData.slice(_rowIndex, _firstRowIndex + 1) : afterFullData.slice(_firstRowIndex, _rowIndex + 1)
|
|
5803
|
-
|
|
5804
|
-
|
|
5952
|
+
$xeTable.$nextTick(() => {
|
|
5953
|
+
handleCheckedCheckboxRow($xeTable, rangeRows, true, false)
|
|
5954
|
+
})
|
|
5955
|
+
$xeTable.dispatchEvent('checkbox-range-select', Object.assign({ rangeRecords: rangeRows }, params), evnt)
|
|
5805
5956
|
return
|
|
5806
5957
|
}
|
|
5807
5958
|
}
|
|
5808
5959
|
}
|
|
5809
5960
|
if (!checkMethod || checkMethod({ row })) {
|
|
5810
|
-
|
|
5811
|
-
|
|
5812
|
-
|
|
5813
|
-
records:
|
|
5814
|
-
reserves:
|
|
5815
|
-
indeterminates:
|
|
5961
|
+
$xeTable.handleBatchSelectRows([row], checked)
|
|
5962
|
+
$xeTable.checkSelectionStatus()
|
|
5963
|
+
$xeTable.dispatchEvent('checkbox-change', Object.assign({
|
|
5964
|
+
records: () => $xeTable.getCheckboxRecords(),
|
|
5965
|
+
reserves: () => $xeTable.getCheckboxReserveRecords(),
|
|
5966
|
+
indeterminates: () => $xeTable.getCheckboxIndeterminateRecords(),
|
|
5816
5967
|
checked
|
|
5817
5968
|
}, params), evnt)
|
|
5818
5969
|
}
|
|
@@ -5821,9 +5972,11 @@ const Methods = {
|
|
|
5821
5972
|
* 多选,切换某一行的选中状态
|
|
5822
5973
|
*/
|
|
5823
5974
|
toggleCheckboxRow (row: any) {
|
|
5824
|
-
const $xeTable = this
|
|
5975
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5976
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5825
5977
|
|
|
5826
|
-
const { selectCheckboxMaps
|
|
5978
|
+
const { selectCheckboxMaps } = internalData
|
|
5979
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5827
5980
|
const { checkField } = checkboxOpts
|
|
5828
5981
|
const checked = checkField ? !XEUtils.get(row, checkField) : !selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5829
5982
|
$xeTable.handleBatchSelectRows([row], checked, true)
|
|
@@ -5846,9 +5999,7 @@ const Methods = {
|
|
|
5846
5999
|
const internalData = $xeTable as unknown as TableInternalData
|
|
5847
6000
|
|
|
5848
6001
|
const { treeConfig } = props
|
|
5849
|
-
const { selectCheckboxMaps,
|
|
5850
|
-
const selectRowMaps = Object.assign({}, selectCheckboxMaps)
|
|
5851
|
-
const halfRowMaps = Object.assign({}, treeIndeterminateMaps)
|
|
6002
|
+
const { selectCheckboxMaps, treeIndeterminateRowMaps } = internalData
|
|
5852
6003
|
const treeOpts = $xeTable.computeTreeOpts
|
|
5853
6004
|
const { transform, mapChildrenField } = treeOpts
|
|
5854
6005
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
@@ -5860,10 +6011,11 @@ const Methods = {
|
|
|
5860
6011
|
}
|
|
5861
6012
|
// 树结构
|
|
5862
6013
|
if (treeConfig) {
|
|
6014
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
5863
6015
|
const childRowMaps: Record<string, number> = {}
|
|
5864
6016
|
const childRowList: any[][] = []
|
|
5865
6017
|
XEUtils.eachTree(afterTreeFullData, (row: any) => {
|
|
5866
|
-
const rowid =
|
|
6018
|
+
const rowid = handleGetRowId(row)
|
|
5867
6019
|
const childList = row[transform ? mapChildrenField : childrenField]
|
|
5868
6020
|
if (childList && childList.length && !childRowMaps[rowid]) {
|
|
5869
6021
|
childRowMaps[rowid] = 1
|
|
@@ -5880,29 +6032,29 @@ const Methods = {
|
|
|
5880
6032
|
childList.forEach(
|
|
5881
6033
|
checkMethod
|
|
5882
6034
|
? (item) => {
|
|
5883
|
-
const childRowid =
|
|
5884
|
-
const isSelect = checkField ? XEUtils.get(item, checkField) :
|
|
6035
|
+
const childRowid = handleGetRowId(item)
|
|
6036
|
+
const isSelect = checkField ? XEUtils.get(item, checkField) : selectCheckboxMaps[childRowid]
|
|
5885
6037
|
if (checkMethod({ row: item })) {
|
|
5886
6038
|
if (isSelect) {
|
|
5887
6039
|
sLen++
|
|
5888
|
-
} else if (
|
|
6040
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5889
6041
|
hLen++
|
|
5890
6042
|
}
|
|
5891
6043
|
vLen++
|
|
5892
6044
|
} else {
|
|
5893
6045
|
if (isSelect) {
|
|
5894
6046
|
sLen++
|
|
5895
|
-
} else if (
|
|
6047
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5896
6048
|
hLen++
|
|
5897
6049
|
}
|
|
5898
6050
|
}
|
|
5899
6051
|
}
|
|
5900
6052
|
: item => {
|
|
5901
|
-
const childRowid =
|
|
5902
|
-
const isSelect = checkField ? XEUtils.get(item, checkField) :
|
|
6053
|
+
const childRowid = handleGetRowId(item)
|
|
6054
|
+
const isSelect = checkField ? XEUtils.get(item, checkField) : selectCheckboxMaps[childRowid]
|
|
5903
6055
|
if (isSelect) {
|
|
5904
6056
|
sLen++
|
|
5905
|
-
} else if (
|
|
6057
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5906
6058
|
hLen++
|
|
5907
6059
|
}
|
|
5908
6060
|
vLen++
|
|
@@ -5915,29 +6067,28 @@ const Methods = {
|
|
|
5915
6067
|
}
|
|
5916
6068
|
if (isSelected) {
|
|
5917
6069
|
if (!checkField) {
|
|
5918
|
-
|
|
6070
|
+
selectCheckboxMaps[rowid] = row
|
|
5919
6071
|
}
|
|
5920
|
-
if (
|
|
5921
|
-
delete
|
|
6072
|
+
if (treeIndeterminateRowMaps[rowid]) {
|
|
6073
|
+
delete treeIndeterminateRowMaps[rowid]
|
|
5922
6074
|
}
|
|
5923
6075
|
} else {
|
|
5924
6076
|
if (!checkField) {
|
|
5925
|
-
if (
|
|
5926
|
-
delete
|
|
6077
|
+
if (selectCheckboxMaps[rowid]) {
|
|
6078
|
+
delete selectCheckboxMaps[rowid]
|
|
5927
6079
|
}
|
|
5928
6080
|
}
|
|
5929
6081
|
if (halfSelect) {
|
|
5930
|
-
|
|
6082
|
+
treeIndeterminateRowMaps[rowid] = row
|
|
5931
6083
|
} else {
|
|
5932
|
-
if (
|
|
5933
|
-
delete
|
|
6084
|
+
if (treeIndeterminateRowMaps[rowid]) {
|
|
6085
|
+
delete treeIndeterminateRowMaps[rowid]
|
|
5934
6086
|
}
|
|
5935
6087
|
}
|
|
5936
6088
|
}
|
|
5937
6089
|
})
|
|
5938
6090
|
}
|
|
5939
|
-
reactData.
|
|
5940
|
-
reactData.treeIndeterminateMaps = halfRowMaps
|
|
6091
|
+
reactData.updateCheckboxFlag++
|
|
5941
6092
|
},
|
|
5942
6093
|
updateAllCheckboxStatus () {
|
|
5943
6094
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
@@ -5946,10 +6097,10 @@ const Methods = {
|
|
|
5946
6097
|
const internalData = $xeTable as unknown as TableInternalData
|
|
5947
6098
|
|
|
5948
6099
|
const { treeConfig } = props
|
|
5949
|
-
const { selectCheckboxMaps,
|
|
6100
|
+
const { afterFullData, afterTreeFullData, checkboxReserveRowMap, selectCheckboxMaps, treeIndeterminateRowMaps } = internalData
|
|
5950
6101
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5951
6102
|
const { checkField, checkMethod, showReserveStatus } = checkboxOpts
|
|
5952
|
-
const {
|
|
6103
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
5953
6104
|
|
|
5954
6105
|
let sLen = 0 // 已选
|
|
5955
6106
|
let hLen = 0 // 半选
|
|
@@ -5958,29 +6109,29 @@ const Methods = {
|
|
|
5958
6109
|
const rootList: any[] = (treeConfig ? afterTreeFullData : afterFullData)
|
|
5959
6110
|
rootList.forEach(checkMethod
|
|
5960
6111
|
? row => {
|
|
5961
|
-
const childRowid =
|
|
6112
|
+
const childRowid = handleGetRowId(row)
|
|
5962
6113
|
const selected = checkField ? XEUtils.get(row, checkField) : selectCheckboxMaps[childRowid]
|
|
5963
6114
|
if (checkMethod({ row })) {
|
|
5964
6115
|
if (selected) {
|
|
5965
6116
|
sLen++
|
|
5966
|
-
} else if (
|
|
6117
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5967
6118
|
hLen++
|
|
5968
6119
|
}
|
|
5969
6120
|
vLen++
|
|
5970
6121
|
} else {
|
|
5971
6122
|
if (selected) {
|
|
5972
6123
|
sLen++
|
|
5973
|
-
} else if (
|
|
6124
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5974
6125
|
hLen++
|
|
5975
6126
|
}
|
|
5976
6127
|
}
|
|
5977
6128
|
}
|
|
5978
6129
|
: row => {
|
|
5979
|
-
const childRowid =
|
|
6130
|
+
const childRowid = handleGetRowId(row)
|
|
5980
6131
|
const selected = checkField ? XEUtils.get(row, checkField) : selectCheckboxMaps[childRowid]
|
|
5981
6132
|
if (selected) {
|
|
5982
6133
|
sLen++
|
|
5983
|
-
} else if (
|
|
6134
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5984
6135
|
hLen++
|
|
5985
6136
|
}
|
|
5986
6137
|
vLen++
|
|
@@ -6039,18 +6190,26 @@ const Methods = {
|
|
|
6039
6190
|
* 获取复选框保留选中的行
|
|
6040
6191
|
*/
|
|
6041
6192
|
getCheckboxReserveRecords (isFull: any) {
|
|
6042
|
-
const
|
|
6193
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6194
|
+
const props = $xeTable
|
|
6195
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
6196
|
+
|
|
6197
|
+
const { treeConfig } = props
|
|
6198
|
+
const { afterFullData, fullDataRowIdData, checkboxReserveRowMap } = internalData
|
|
6199
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
6200
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
6043
6201
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
6044
6202
|
const reserveSelection: any[] = []
|
|
6045
6203
|
if (checkboxOpts.reserve) {
|
|
6046
|
-
const
|
|
6204
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
6205
|
+
const afterFullIdMaps: { [key: string]: number } = {}
|
|
6047
6206
|
if (treeConfig) {
|
|
6048
6207
|
XEUtils.eachTree(afterFullData, row => {
|
|
6049
|
-
afterFullIdMaps[
|
|
6208
|
+
afterFullIdMaps[handleGetRowId(row)] = 1
|
|
6050
6209
|
}, { children: childrenField })
|
|
6051
6210
|
} else {
|
|
6052
6211
|
afterFullData.forEach((row: any) => {
|
|
6053
|
-
afterFullIdMaps[
|
|
6212
|
+
afterFullIdMaps[handleGetRowId(row)] = 1
|
|
6054
6213
|
})
|
|
6055
6214
|
}
|
|
6056
6215
|
XEUtils.each(checkboxReserveRowMap, (oldRow, oldRowid) => {
|
|
@@ -6090,9 +6249,9 @@ const Methods = {
|
|
|
6090
6249
|
handleCheckedAllCheckboxRow($xeTable, value)
|
|
6091
6250
|
if (evnt) {
|
|
6092
6251
|
$xeTable.dispatchEvent('checkbox-all', {
|
|
6093
|
-
records: $xeTable.getCheckboxRecords(),
|
|
6094
|
-
reserves: $xeTable.getCheckboxReserveRecords(),
|
|
6095
|
-
indeterminates: $xeTable.getCheckboxIndeterminateRecords(),
|
|
6252
|
+
records: () => $xeTable.getCheckboxRecords(),
|
|
6253
|
+
reserves: () => $xeTable.getCheckboxReserveRecords(),
|
|
6254
|
+
indeterminates: () => $xeTable.getCheckboxIndeterminateRecords(),
|
|
6096
6255
|
checked: value
|
|
6097
6256
|
}, evnt)
|
|
6098
6257
|
}
|
|
@@ -6125,9 +6284,17 @@ const Methods = {
|
|
|
6125
6284
|
* 清空行为不管是否被禁用还是保留记录,都将彻底清空选中状态
|
|
6126
6285
|
*/
|
|
6127
6286
|
clearCheckboxRow () {
|
|
6128
|
-
const
|
|
6129
|
-
const
|
|
6287
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6288
|
+
const props = $xeTable
|
|
6289
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
6290
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
6291
|
+
|
|
6292
|
+
const { treeConfig } = props
|
|
6293
|
+
const { tableFullData } = internalData
|
|
6294
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
6130
6295
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
6296
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
6297
|
+
const { checkField, reserve } = checkboxOpts
|
|
6131
6298
|
// indeterminateField 仅支持读取
|
|
6132
6299
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
6133
6300
|
if (checkField) {
|
|
@@ -6144,12 +6311,13 @@ const Methods = {
|
|
|
6144
6311
|
}
|
|
6145
6312
|
}
|
|
6146
6313
|
if (reserve) {
|
|
6147
|
-
tableFullData.forEach((row
|
|
6314
|
+
tableFullData.forEach((row) => this.handleCheckboxReserveRow(row, false))
|
|
6148
6315
|
}
|
|
6149
|
-
|
|
6150
|
-
|
|
6151
|
-
|
|
6152
|
-
|
|
6316
|
+
reactData.isAllSelected = false
|
|
6317
|
+
reactData.isIndeterminate = false
|
|
6318
|
+
internalData.selectCheckboxMaps = {}
|
|
6319
|
+
internalData.treeIndeterminateRowMaps = {}
|
|
6320
|
+
reactData.updateCheckboxFlag++
|
|
6153
6321
|
return this.$nextTick()
|
|
6154
6322
|
},
|
|
6155
6323
|
/**
|
|
@@ -6356,11 +6524,13 @@ const Methods = {
|
|
|
6356
6524
|
},
|
|
6357
6525
|
triggerHeaderCellClickEvent (evnt: MouseEvent, params: VxeTableDefines.CellRenderHeaderParams) {
|
|
6358
6526
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6527
|
+
const props = $xeTable
|
|
6359
6528
|
const internalData = $xeTable as unknown as TableInternalData
|
|
6360
6529
|
|
|
6361
6530
|
const { _lastResizeTime } = internalData
|
|
6362
6531
|
const sortOpts = $xeTable.computeSortOpts
|
|
6363
6532
|
const columnOpts = $xeTable.computeColumnOpts
|
|
6533
|
+
const currentColumnOpts = $xeTable.computeCurrentColumnOpts
|
|
6364
6534
|
const { column } = params
|
|
6365
6535
|
const cell = evnt.currentTarget
|
|
6366
6536
|
const triggerResizable = _lastResizeTime && _lastResizeTime > Date.now() - 300
|
|
@@ -6370,7 +6540,7 @@ const Methods = {
|
|
|
6370
6540
|
$xeTable.triggerSortEvent(evnt, column, getNextSortOrder($xeTable, column))
|
|
6371
6541
|
}
|
|
6372
6542
|
$xeTable.dispatchEvent('header-cell-click', Object.assign({ triggerResizable, triggerSort, triggerFilter, cell }, params), evnt)
|
|
6373
|
-
if (columnOpts.isCurrent ||
|
|
6543
|
+
if ((columnOpts.isCurrent || props.highlightCurrentColumn) && (!currentColumnOpts.trigger || ['header', 'default'].includes(currentColumnOpts.trigger))) {
|
|
6374
6544
|
$xeTable.triggerCurrentColumnEvent(evnt, params)
|
|
6375
6545
|
}
|
|
6376
6546
|
return $xeTable.$nextTick()
|
|
@@ -6386,13 +6556,24 @@ const Methods = {
|
|
|
6386
6556
|
* @param {ColumnInfo} fieldOrColumn 列配置
|
|
6387
6557
|
*/
|
|
6388
6558
|
setCurrentColumn (fieldOrColumn: any) {
|
|
6389
|
-
const
|
|
6559
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6560
|
+
const props = $xeTable
|
|
6561
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
6562
|
+
|
|
6563
|
+
const { mouseConfig } = props
|
|
6564
|
+
const mouseOpts = $xeTable.computeMouseOpts
|
|
6565
|
+
const isMouseSelected = mouseConfig && mouseOpts.selected
|
|
6566
|
+
const column = handleFieldOrColumn($xeTable, fieldOrColumn)
|
|
6390
6567
|
if (column) {
|
|
6391
|
-
|
|
6392
|
-
|
|
6393
|
-
this.currentColumn = column
|
|
6568
|
+
$xeTable.clearCurrentColumn()
|
|
6569
|
+
reactData.currentColumn = column
|
|
6394
6570
|
}
|
|
6395
|
-
return
|
|
6571
|
+
return $xeTable.$nextTick().then(() => {
|
|
6572
|
+
// 更新状选中态
|
|
6573
|
+
if (isMouseSelected) {
|
|
6574
|
+
$xeTable.addCellSelectedClass()
|
|
6575
|
+
}
|
|
6576
|
+
})
|
|
6396
6577
|
},
|
|
6397
6578
|
/**
|
|
6398
6579
|
* 用于当前列,手动清空当前高亮的状态
|
|
@@ -6401,36 +6582,17 @@ const Methods = {
|
|
|
6401
6582
|
this.currentColumn = null
|
|
6402
6583
|
return this.$nextTick()
|
|
6403
6584
|
},
|
|
6404
|
-
checkValidate (type: any) {
|
|
6405
|
-
if (this.triggerValidate) {
|
|
6406
|
-
return this.triggerValidate(type)
|
|
6407
|
-
}
|
|
6408
|
-
return this.$nextTick()
|
|
6409
|
-
},
|
|
6410
|
-
/**
|
|
6411
|
-
* 当单元格发生改变时
|
|
6412
|
-
* 如果存在规则,则校验
|
|
6413
|
-
*/
|
|
6414
|
-
handleChangeCell (evnt: Event, params: any) {
|
|
6415
|
-
this.checkValidate('blur')
|
|
6416
|
-
.catch((e: any) => e)
|
|
6417
|
-
.then(() => {
|
|
6418
|
-
this.handleEdit(params, evnt)
|
|
6419
|
-
.then(() => this.checkValidate('change'))
|
|
6420
|
-
.catch((e: any) => e)
|
|
6421
|
-
})
|
|
6422
|
-
},
|
|
6423
6585
|
/**
|
|
6424
6586
|
* 列点击事件
|
|
6425
6587
|
* 如果是单击模式,则激活为编辑状态
|
|
6426
6588
|
* 如果是双击模式,则单击后选中状态
|
|
6427
6589
|
*/
|
|
6428
6590
|
triggerCellClickEvent (evnt: MouseEvent, params: VxeTableDefines.CellRenderBodyParams) {
|
|
6429
|
-
const $xeTable = this
|
|
6591
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6430
6592
|
const props = $xeTable
|
|
6431
|
-
const reactData = $xeTable
|
|
6593
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
6432
6594
|
|
|
6433
|
-
const { highlightCurrentRow, editConfig } = props
|
|
6595
|
+
const { highlightCurrentRow, highlightCurrentColumn, editConfig } = props
|
|
6434
6596
|
const { editStore, isDragResize } = reactData
|
|
6435
6597
|
if (isDragResize) {
|
|
6436
6598
|
return
|
|
@@ -6442,6 +6604,8 @@ const Methods = {
|
|
|
6442
6604
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
6443
6605
|
const keyboardOpts = $xeTable.computeKeyboardOpts
|
|
6444
6606
|
const rowOpts = $xeTable.computeRowOpts
|
|
6607
|
+
const columnOpts = $xeTable.computeColumnOpts
|
|
6608
|
+
const currentColumnOpts = $xeTable.computeCurrentColumnOpts
|
|
6445
6609
|
const { actived, focused } = editStore
|
|
6446
6610
|
const { row, column } = params
|
|
6447
6611
|
const { type, treeNode } = column
|
|
@@ -6457,11 +6621,11 @@ const Methods = {
|
|
|
6457
6621
|
if (!triggerCheckbox && !triggerRadio) {
|
|
6458
6622
|
// 如果是展开行
|
|
6459
6623
|
if (!triggerExpandNode && (expandOpts.trigger === 'row' || (isExpandType && expandOpts.trigger === 'cell'))) {
|
|
6460
|
-
|
|
6624
|
+
$xeTable.triggerRowExpandEvent(evnt, params)
|
|
6461
6625
|
}
|
|
6462
6626
|
// 如果是树形表格
|
|
6463
6627
|
if ((treeOpts.trigger === 'row' || (treeNode && treeOpts.trigger === 'cell'))) {
|
|
6464
|
-
|
|
6628
|
+
$xeTable.triggerTreeExpandEvent(evnt, params)
|
|
6465
6629
|
}
|
|
6466
6630
|
}
|
|
6467
6631
|
// 如果点击了树节点
|
|
@@ -6470,16 +6634,22 @@ const Methods = {
|
|
|
6470
6634
|
// 如果是高亮行
|
|
6471
6635
|
if (rowOpts.isCurrent || highlightCurrentRow) {
|
|
6472
6636
|
if (!triggerCheckbox && !triggerRadio) {
|
|
6473
|
-
|
|
6637
|
+
$xeTable.triggerCurrentRowEvent(evnt, params)
|
|
6638
|
+
}
|
|
6639
|
+
}
|
|
6640
|
+
// 如果是当前列
|
|
6641
|
+
if ((columnOpts.isCurrent || highlightCurrentColumn) && (!currentColumnOpts.trigger || ['cell', 'default'].includes(currentColumnOpts.trigger))) {
|
|
6642
|
+
if (!triggerCheckbox && !triggerRadio) {
|
|
6643
|
+
$xeTable.triggerCurrentColumnEvent(evnt, params)
|
|
6474
6644
|
}
|
|
6475
6645
|
}
|
|
6476
6646
|
// 如果是单选框
|
|
6477
6647
|
if (!triggerRadio && (radioOpts.trigger === 'row' || (isRadioType && radioOpts.trigger === 'cell'))) {
|
|
6478
|
-
|
|
6648
|
+
$xeTable.triggerRadioRowEvent(evnt, params)
|
|
6479
6649
|
}
|
|
6480
6650
|
// 如果是复选框
|
|
6481
6651
|
if (!triggerCheckbox && (checkboxOpts.trigger === 'row' || (isCheckboxType && checkboxOpts.trigger === 'cell'))) {
|
|
6482
|
-
|
|
6652
|
+
$xeTable.handleToggleCheckRowEvent(evnt, params)
|
|
6483
6653
|
}
|
|
6484
6654
|
}
|
|
6485
6655
|
// 如果设置了单元格选中功能,则不会使用点击事件去处理(只能支持双击模式)
|
|
@@ -6491,14 +6661,14 @@ const Methods = {
|
|
|
6491
6661
|
}
|
|
6492
6662
|
if (editOpts.trigger === 'manual') {
|
|
6493
6663
|
if (actived.args && actived.row === row && column !== actived.column) {
|
|
6494
|
-
|
|
6664
|
+
handleChangeCell($xeTable, evnt, params)
|
|
6495
6665
|
}
|
|
6496
6666
|
} else if (!actived.args || row !== actived.row || column !== actived.column) {
|
|
6497
6667
|
if (editOpts.trigger === 'click') {
|
|
6498
|
-
|
|
6668
|
+
handleChangeCell($xeTable, evnt, params)
|
|
6499
6669
|
} else if (editOpts.trigger === 'dblclick') {
|
|
6500
6670
|
if (editOpts.mode === 'row' && actived.row === row) {
|
|
6501
|
-
|
|
6671
|
+
handleChangeCell($xeTable, evnt, params)
|
|
6502
6672
|
}
|
|
6503
6673
|
}
|
|
6504
6674
|
}
|
|
@@ -6518,7 +6688,7 @@ const Methods = {
|
|
|
6518
6688
|
}
|
|
6519
6689
|
}
|
|
6520
6690
|
}
|
|
6521
|
-
|
|
6691
|
+
$xeTable.dispatchEvent('cell-click', params, evnt)
|
|
6522
6692
|
},
|
|
6523
6693
|
/**
|
|
6524
6694
|
* 列双击点击事件
|
|
@@ -6541,16 +6711,16 @@ const Methods = {
|
|
|
6541
6711
|
if (isEnableConf(editConfig) && editOpts.trigger === 'dblclick') {
|
|
6542
6712
|
if (!actived.args || evnt.currentTarget !== actived.args.cell) {
|
|
6543
6713
|
if (editOpts.mode === 'row') {
|
|
6544
|
-
|
|
6714
|
+
checkValidate($xeTable, 'blur')
|
|
6545
6715
|
.catch((e: any) => e)
|
|
6546
6716
|
.then(() => {
|
|
6547
6717
|
this.handleEdit(params, evnt)
|
|
6548
|
-
.then(() =>
|
|
6718
|
+
.then(() => checkValidate($xeTable, 'change'))
|
|
6549
6719
|
.catch((e: any) => e)
|
|
6550
6720
|
})
|
|
6551
6721
|
} else if (editOpts.mode === 'cell') {
|
|
6552
6722
|
this.handleEdit(params, evnt)
|
|
6553
|
-
.then(() =>
|
|
6723
|
+
.then(() => checkValidate($xeTable, 'change'))
|
|
6554
6724
|
.catch((e: any) => e)
|
|
6555
6725
|
}
|
|
6556
6726
|
}
|
|
@@ -6746,12 +6916,11 @@ const Methods = {
|
|
|
6746
6916
|
|
|
6747
6917
|
const { treeConfig, dragConfig } = props
|
|
6748
6918
|
const rowDragOpts = $xeTable.computeRowDragOpts
|
|
6749
|
-
const { fullAllDataRowIdData } = internalData
|
|
6919
|
+
const { afterFullData, tableFullData, fullAllDataRowIdData } = internalData
|
|
6750
6920
|
const { isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod, dragToChildMethod } = rowDragOpts
|
|
6751
6921
|
const treeOpts = $xeTable.computeTreeOpts
|
|
6752
6922
|
const { transform, rowField, mapChildrenField, parentField } = treeOpts
|
|
6753
6923
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
6754
|
-
const { afterFullData, tableFullData } = internalData
|
|
6755
6924
|
const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null)
|
|
6756
6925
|
const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
|
|
6757
6926
|
const errRest = {
|
|
@@ -7347,8 +7516,8 @@ const Methods = {
|
|
|
7347
7516
|
}
|
|
7348
7517
|
},
|
|
7349
7518
|
handleHeaderCellDragMousedownEvent (evnt: MouseEvent, params: any) {
|
|
7350
|
-
const $xeTable = this
|
|
7351
|
-
const reactData = $xeTable
|
|
7519
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7520
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7352
7521
|
|
|
7353
7522
|
evnt.stopPropagation()
|
|
7354
7523
|
const columnDragOpts = $xeTable.computeColumnDragOpts
|
|
@@ -7373,8 +7542,8 @@ const Methods = {
|
|
|
7373
7542
|
$xeTable.dispatchEvent('column-dragstart', params, evnt)
|
|
7374
7543
|
},
|
|
7375
7544
|
handleHeaderCellDragMouseupEvent () {
|
|
7376
|
-
const $xeTable = this
|
|
7377
|
-
const reactData = $xeTable
|
|
7545
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7546
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7378
7547
|
|
|
7379
7548
|
clearColDropOrigin($xeTable)
|
|
7380
7549
|
hideDropTip($xeTable)
|
|
@@ -7383,54 +7552,58 @@ const Methods = {
|
|
|
7383
7552
|
reactData.isDragColMove = false
|
|
7384
7553
|
},
|
|
7385
7554
|
setPendingRow (rows: any, status: any) {
|
|
7386
|
-
const $xeTable = this
|
|
7387
|
-
const reactData = $xeTable
|
|
7555
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7556
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7557
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7388
7558
|
|
|
7389
|
-
const
|
|
7559
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
7560
|
+
const { pendingRowMaps } = internalData
|
|
7390
7561
|
if (rows && !XEUtils.isArray(rows)) {
|
|
7391
7562
|
rows = [rows]
|
|
7392
7563
|
}
|
|
7393
7564
|
if (status) {
|
|
7394
7565
|
rows.forEach((row: any) => {
|
|
7395
|
-
const rowid =
|
|
7396
|
-
if (rowid && !
|
|
7397
|
-
|
|
7566
|
+
const rowid = handleGetRowId(row)
|
|
7567
|
+
if (rowid && !pendingRowMaps[rowid]) {
|
|
7568
|
+
pendingRowMaps[rowid] = row
|
|
7398
7569
|
}
|
|
7399
7570
|
})
|
|
7400
7571
|
} else {
|
|
7401
7572
|
rows.forEach((row: any) => {
|
|
7402
|
-
const rowid =
|
|
7403
|
-
if (rowid &&
|
|
7404
|
-
delete
|
|
7573
|
+
const rowid = handleGetRowId(row)
|
|
7574
|
+
if (rowid && pendingRowMaps[rowid]) {
|
|
7575
|
+
delete pendingRowMaps[rowid]
|
|
7405
7576
|
}
|
|
7406
7577
|
})
|
|
7407
7578
|
}
|
|
7408
|
-
reactData.
|
|
7579
|
+
reactData.pendingRowFlag++
|
|
7409
7580
|
return $xeTable.$nextTick()
|
|
7410
7581
|
},
|
|
7411
7582
|
togglePendingRow (rows: any) {
|
|
7412
|
-
const $xeTable = this
|
|
7413
|
-
const reactData = $xeTable
|
|
7583
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7584
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7585
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7414
7586
|
|
|
7415
|
-
const
|
|
7587
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
7588
|
+
const { pendingRowMaps } = internalData
|
|
7416
7589
|
if (rows && !XEUtils.isArray(rows)) {
|
|
7417
7590
|
rows = [rows]
|
|
7418
7591
|
}
|
|
7419
7592
|
rows.forEach((row: any) => {
|
|
7420
|
-
const rowid =
|
|
7593
|
+
const rowid = handleGetRowId(row)
|
|
7421
7594
|
if (rowid) {
|
|
7422
|
-
if (
|
|
7423
|
-
delete
|
|
7595
|
+
if (pendingRowMaps[rowid]) {
|
|
7596
|
+
delete pendingRowMaps[rowid]
|
|
7424
7597
|
} else {
|
|
7425
|
-
|
|
7598
|
+
pendingRowMaps[rowid] = row
|
|
7426
7599
|
}
|
|
7427
7600
|
}
|
|
7428
7601
|
})
|
|
7429
|
-
reactData.
|
|
7602
|
+
reactData.pendingRowFlag++
|
|
7430
7603
|
return $xeTable.$nextTick()
|
|
7431
7604
|
},
|
|
7432
7605
|
hasPendingByRow (row: any) {
|
|
7433
|
-
const $xeTable = this
|
|
7606
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7434
7607
|
|
|
7435
7608
|
return $xeTable.isPendingByRow(row)
|
|
7436
7609
|
},
|
|
@@ -7443,12 +7616,10 @@ const Methods = {
|
|
|
7443
7616
|
return !!pendingRowMaps[rowid]
|
|
7444
7617
|
},
|
|
7445
7618
|
getPendingRecords () {
|
|
7446
|
-
const $xeTable = this
|
|
7447
|
-
const
|
|
7448
|
-
const internalData = $xeTable
|
|
7619
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7620
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7449
7621
|
|
|
7450
|
-
const { pendingRowMaps } =
|
|
7451
|
-
const { fullAllDataRowIdData } = internalData
|
|
7622
|
+
const { fullAllDataRowIdData, pendingRowMaps } = internalData
|
|
7452
7623
|
const insertRecords: any[] = []
|
|
7453
7624
|
XEUtils.each(pendingRowMaps, (row, rowid) => {
|
|
7454
7625
|
if (fullAllDataRowIdData[rowid]) {
|
|
@@ -7458,11 +7629,16 @@ const Methods = {
|
|
|
7458
7629
|
return insertRecords
|
|
7459
7630
|
},
|
|
7460
7631
|
clearPendingRow () {
|
|
7461
|
-
|
|
7462
|
-
|
|
7632
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7633
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7634
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7635
|
+
|
|
7636
|
+
internalData.pendingRowMaps = {}
|
|
7637
|
+
reactData.pendingRowFlag++
|
|
7638
|
+
return $xeTable.$nextTick()
|
|
7463
7639
|
},
|
|
7464
7640
|
sort (sortConfs: any, sortOrder: any) {
|
|
7465
|
-
const $xeTable = this
|
|
7641
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7466
7642
|
|
|
7467
7643
|
const { sortOpts } = this
|
|
7468
7644
|
const { multiple, remote, orders } = sortOpts
|
|
@@ -7612,7 +7788,10 @@ const Methods = {
|
|
|
7612
7788
|
* @param {Event} evnt 事件
|
|
7613
7789
|
*/
|
|
7614
7790
|
closeFilter () {
|
|
7615
|
-
const
|
|
7791
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7792
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7793
|
+
|
|
7794
|
+
const { filterStore } = reactData
|
|
7616
7795
|
const { column, visible } = filterStore
|
|
7617
7796
|
Object.assign(filterStore, {
|
|
7618
7797
|
isAllSelected: false,
|
|
@@ -7621,9 +7800,15 @@ const Methods = {
|
|
|
7621
7800
|
visible: false
|
|
7622
7801
|
})
|
|
7623
7802
|
if (visible) {
|
|
7624
|
-
|
|
7803
|
+
$xeTable.dispatchEvent('filter-visible', {
|
|
7804
|
+
column,
|
|
7805
|
+
field: column.field,
|
|
7806
|
+
property: column.field,
|
|
7807
|
+
filterList: () => $xeTable.getCheckedFilters(),
|
|
7808
|
+
visible: false
|
|
7809
|
+
}, null)
|
|
7625
7810
|
}
|
|
7626
|
-
return
|
|
7811
|
+
return $xeTable.$nextTick()
|
|
7627
7812
|
},
|
|
7628
7813
|
/**
|
|
7629
7814
|
* 判断指定列是否为筛选状态,如果为空则判断所有列
|
|
@@ -7656,17 +7841,16 @@ const Methods = {
|
|
|
7656
7841
|
const reactData = $xeTable as unknown as TableReactData
|
|
7657
7842
|
const internalData = $xeTable as unknown as TableInternalData
|
|
7658
7843
|
|
|
7659
|
-
const
|
|
7660
|
-
const { fullAllDataRowIdData } = internalData
|
|
7844
|
+
const { fullAllDataRowIdData, rowExpandLazyLoadedMaps } = internalData
|
|
7661
7845
|
const expandOpts = $xeTable.computeExpandOpts
|
|
7662
7846
|
const { lazy } = expandOpts
|
|
7663
7847
|
const rowid = getRowid($xeTable, row)
|
|
7664
7848
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
7665
7849
|
if (lazy && rowRest) {
|
|
7666
7850
|
rowRest.expandLoaded = false
|
|
7667
|
-
delete
|
|
7851
|
+
delete rowExpandLazyLoadedMaps[rowid]
|
|
7668
7852
|
}
|
|
7669
|
-
reactData.
|
|
7853
|
+
reactData.rowExpandedFlag++
|
|
7670
7854
|
return $xeTable.$nextTick()
|
|
7671
7855
|
},
|
|
7672
7856
|
/**
|
|
@@ -7674,14 +7858,18 @@ const Methods = {
|
|
|
7674
7858
|
* @param {Row} row 行对象
|
|
7675
7859
|
*/
|
|
7676
7860
|
reloadRowExpand (row: any) {
|
|
7677
|
-
const
|
|
7861
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7862
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7863
|
+
|
|
7864
|
+
const { rowExpandLazyLoadedMaps } = internalData
|
|
7865
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
7678
7866
|
const { lazy } = expandOpts
|
|
7679
7867
|
const rowid = getRowid(this, row)
|
|
7680
7868
|
if (lazy && !rowExpandLazyLoadedMaps[rowid]) {
|
|
7681
|
-
|
|
7682
|
-
.then(() =>
|
|
7869
|
+
$xeTable.clearRowExpandLoaded(row)
|
|
7870
|
+
.then(() => handleAsyncRowExpand($xeTable, row))
|
|
7683
7871
|
}
|
|
7684
|
-
return
|
|
7872
|
+
return $xeTable.$nextTick()
|
|
7685
7873
|
},
|
|
7686
7874
|
reloadExpandContent (row: any) {
|
|
7687
7875
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -7694,20 +7882,34 @@ const Methods = {
|
|
|
7694
7882
|
* 展开行事件
|
|
7695
7883
|
*/
|
|
7696
7884
|
triggerRowExpandEvent (evnt: any, params: any) {
|
|
7697
|
-
const
|
|
7885
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7886
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7887
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7888
|
+
|
|
7889
|
+
const { expandColumn: column } = reactData
|
|
7890
|
+
const { rowExpandLazyLoadedMaps } = internalData
|
|
7891
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
7698
7892
|
const { row } = params
|
|
7699
7893
|
const { lazy, trigger } = expandOpts
|
|
7700
7894
|
if (trigger === 'manual') {
|
|
7701
7895
|
return
|
|
7702
7896
|
}
|
|
7703
7897
|
evnt.stopPropagation()
|
|
7704
|
-
const rowid = getRowid(
|
|
7898
|
+
const rowid = getRowid($xeTable, row)
|
|
7705
7899
|
if (!lazy || !rowExpandLazyLoadedMaps[rowid]) {
|
|
7706
|
-
const expanded =
|
|
7707
|
-
const columnIndex =
|
|
7708
|
-
const $columnIndex =
|
|
7709
|
-
|
|
7710
|
-
|
|
7900
|
+
const expanded = !$xeTable.isRowExpandByRow(row)
|
|
7901
|
+
const columnIndex = $xeTable.getColumnIndex(column)
|
|
7902
|
+
const $columnIndex = $xeTable.getVMColumnIndex(column)
|
|
7903
|
+
$xeTable.setRowExpand(row, expanded)
|
|
7904
|
+
$xeTable.dispatchEvent('toggle-row-expand', {
|
|
7905
|
+
expanded,
|
|
7906
|
+
column,
|
|
7907
|
+
columnIndex,
|
|
7908
|
+
$columnIndex,
|
|
7909
|
+
row,
|
|
7910
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
7911
|
+
$rowIndex: $xeTable.getVMRowIndex(row)
|
|
7912
|
+
}, evnt)
|
|
7711
7913
|
}
|
|
7712
7914
|
},
|
|
7713
7915
|
/**
|
|
@@ -7751,48 +7953,6 @@ const Methods = {
|
|
|
7751
7953
|
}
|
|
7752
7954
|
return this.setRowExpand(expandedRows, expanded)
|
|
7753
7955
|
},
|
|
7754
|
-
handleAsyncRowExpand (row: any) {
|
|
7755
|
-
const $xeTable = this
|
|
7756
|
-
const reactData = $xeTable as TableReactData
|
|
7757
|
-
const internalData = $xeTable as TableInternalData
|
|
7758
|
-
|
|
7759
|
-
return new Promise<void>(resolve => {
|
|
7760
|
-
const { expandOpts } = this
|
|
7761
|
-
const { loadMethod } = expandOpts
|
|
7762
|
-
if (loadMethod) {
|
|
7763
|
-
const { fullAllDataRowIdData } = internalData
|
|
7764
|
-
const rExpandLazyLoadedMaps = { ...reactData.rowExpandLazyLoadedMaps }
|
|
7765
|
-
const rowid = getRowid($xeTable, row)
|
|
7766
|
-
const rowRest = fullAllDataRowIdData[rowid]
|
|
7767
|
-
rExpandLazyLoadedMaps[rowid] = row
|
|
7768
|
-
reactData.rowExpandLazyLoadedMaps = rExpandLazyLoadedMaps
|
|
7769
|
-
loadMethod({ $table: $xeTable, row, rowIndex: $xeTable.getRowIndex(row), $rowIndex: $xeTable.getVMRowIndex(row) }).then(() => {
|
|
7770
|
-
const rExpandedMaps = { ...reactData.rowExpandedMaps }
|
|
7771
|
-
if (rowRest) {
|
|
7772
|
-
rowRest.expandLoaded = true
|
|
7773
|
-
}
|
|
7774
|
-
rExpandedMaps[rowid] = row
|
|
7775
|
-
reactData.rowExpandedMaps = rExpandedMaps
|
|
7776
|
-
}).catch(() => {
|
|
7777
|
-
if (rowRest) {
|
|
7778
|
-
rowRest.expandLoaded = false
|
|
7779
|
-
}
|
|
7780
|
-
}).finally(() => {
|
|
7781
|
-
const rExpandLazyLoadedMaps = { ...reactData.rowExpandLazyLoadedMaps }
|
|
7782
|
-
if (rExpandLazyLoadedMaps[rowid]) {
|
|
7783
|
-
delete rExpandLazyLoadedMaps[rowid]
|
|
7784
|
-
}
|
|
7785
|
-
reactData.rowExpandLazyLoadedMaps = rExpandLazyLoadedMaps
|
|
7786
|
-
$xeTable.$nextTick()
|
|
7787
|
-
.then(() => $xeTable.recalculate())
|
|
7788
|
-
.then(() => $xeTable.updateCellAreas())
|
|
7789
|
-
.then(() => resolve())
|
|
7790
|
-
})
|
|
7791
|
-
} else {
|
|
7792
|
-
resolve()
|
|
7793
|
-
}
|
|
7794
|
-
})
|
|
7795
|
-
},
|
|
7796
7956
|
/**
|
|
7797
7957
|
* 设置展开行,二个参数设置这一行展开与否
|
|
7798
7958
|
* 支持单行
|
|
@@ -7801,10 +7961,14 @@ const Methods = {
|
|
|
7801
7961
|
* @param {Boolean} expanded 是否展开
|
|
7802
7962
|
*/
|
|
7803
7963
|
setRowExpand (rows: any, expanded: any) {
|
|
7804
|
-
const $xeTable = this
|
|
7964
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7965
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7966
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7805
7967
|
|
|
7806
|
-
const {
|
|
7807
|
-
let
|
|
7968
|
+
const { expandColumn } = reactData
|
|
7969
|
+
let { fullAllDataRowIdData, rowExpandedMaps, rowExpandLazyLoadedMaps } = internalData
|
|
7970
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
7971
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
7808
7972
|
const { reserve, lazy, accordion, toggleMethod } = expandOpts
|
|
7809
7973
|
const lazyRests: any[] = []
|
|
7810
7974
|
const columnIndex = $xeTable.getColumnIndex(expandColumn)
|
|
@@ -7815,28 +7979,29 @@ const Methods = {
|
|
|
7815
7979
|
}
|
|
7816
7980
|
if (accordion) {
|
|
7817
7981
|
// 只能同时展开一个
|
|
7818
|
-
|
|
7982
|
+
rowExpandedMaps = {}
|
|
7983
|
+
internalData.rowExpandedMaps = rowExpandedMaps
|
|
7819
7984
|
rows = rows.slice(rows.length - 1, rows.length)
|
|
7820
7985
|
}
|
|
7821
|
-
const validRows: any[] = toggleMethod ? rows.filter((row: any) => toggleMethod({ expanded, column: expandColumn, columnIndex, $columnIndex, row, rowIndex: this.getRowIndex(row), $rowIndex: this.getVMRowIndex(row) })) : rows
|
|
7986
|
+
const validRows: any[] = toggleMethod ? rows.filter((row: any) => toggleMethod({ $table: $xeTable, expanded, column: expandColumn, columnIndex, $columnIndex, row, rowIndex: this.getRowIndex(row), $rowIndex: this.getVMRowIndex(row) })) : rows
|
|
7822
7987
|
if (expanded) {
|
|
7823
7988
|
validRows.forEach((row: any) => {
|
|
7824
|
-
const rowid =
|
|
7825
|
-
if (!
|
|
7989
|
+
const rowid = handleGetRowId(row)
|
|
7990
|
+
if (!rowExpandedMaps[rowid]) {
|
|
7826
7991
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
7827
7992
|
const isLoad = lazy && !rowRest.expandLoaded && !rowExpandLazyLoadedMaps[rowid]
|
|
7828
7993
|
if (isLoad) {
|
|
7829
|
-
lazyRests.push(
|
|
7994
|
+
lazyRests.push(handleAsyncRowExpand($xeTable, row))
|
|
7830
7995
|
} else {
|
|
7831
|
-
|
|
7996
|
+
rowExpandedMaps[rowid] = row
|
|
7832
7997
|
}
|
|
7833
7998
|
}
|
|
7834
7999
|
})
|
|
7835
8000
|
} else {
|
|
7836
8001
|
validRows.forEach((item) => {
|
|
7837
|
-
const rowid =
|
|
7838
|
-
if (
|
|
7839
|
-
delete
|
|
8002
|
+
const rowid = handleGetRowId(item)
|
|
8003
|
+
if (rowExpandedMaps[rowid]) {
|
|
8004
|
+
delete rowExpandedMaps[rowid]
|
|
7840
8005
|
}
|
|
7841
8006
|
})
|
|
7842
8007
|
}
|
|
@@ -7844,7 +8009,7 @@ const Methods = {
|
|
|
7844
8009
|
validRows.forEach((row) => handleRowExpandReserve($xeTable, row, expanded))
|
|
7845
8010
|
}
|
|
7846
8011
|
}
|
|
7847
|
-
|
|
8012
|
+
reactData.rowExpandedFlag++
|
|
7848
8013
|
return Promise.all(lazyRests)
|
|
7849
8014
|
.then(() => $xeTable.$nextTick())
|
|
7850
8015
|
.then(() => $xeTable.recalculate(true))
|
|
@@ -7860,9 +8025,14 @@ const Methods = {
|
|
|
7860
8025
|
* @param {Row} row 行对象
|
|
7861
8026
|
*/
|
|
7862
8027
|
isRowExpandByRow (row: any) {
|
|
7863
|
-
const
|
|
8028
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8029
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
8030
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8031
|
+
|
|
8032
|
+
const { rowExpandedFlag } = reactData
|
|
8033
|
+
const { rowExpandedMaps } = internalData
|
|
7864
8034
|
const rowid = getRowid(this, row)
|
|
7865
|
-
return !!rowExpandedMaps[rowid]
|
|
8035
|
+
return !!rowExpandedFlag && !!rowExpandedMaps[rowid]
|
|
7866
8036
|
},
|
|
7867
8037
|
isExpandByRow (row: any) {
|
|
7868
8038
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -7883,7 +8053,8 @@ const Methods = {
|
|
|
7883
8053
|
const expandOpts = $xeTable.computeExpandOpts
|
|
7884
8054
|
const { reserve } = expandOpts
|
|
7885
8055
|
const expList = $xeTable.getRowExpandRecords()
|
|
7886
|
-
|
|
8056
|
+
internalData.rowExpandedMaps = {}
|
|
8057
|
+
reactData.rowExpandedFlag++
|
|
7887
8058
|
if (reserve) {
|
|
7888
8059
|
tableFullData.forEach((row) => handleRowExpandReserve($xeTable, row, false))
|
|
7889
8060
|
}
|
|
@@ -7903,8 +8074,11 @@ const Methods = {
|
|
|
7903
8074
|
return this.$nextTick()
|
|
7904
8075
|
},
|
|
7905
8076
|
getRowExpandRecords () {
|
|
8077
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8078
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8079
|
+
|
|
7906
8080
|
const rest: any[] = []
|
|
7907
|
-
XEUtils.each(
|
|
8081
|
+
XEUtils.each(internalData.rowExpandedMaps, item => {
|
|
7908
8082
|
if (item) {
|
|
7909
8083
|
rest.push(item)
|
|
7910
8084
|
}
|
|
@@ -7912,8 +8086,11 @@ const Methods = {
|
|
|
7912
8086
|
return rest
|
|
7913
8087
|
},
|
|
7914
8088
|
getTreeExpandRecords () {
|
|
8089
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8090
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8091
|
+
|
|
7915
8092
|
const rest: any[] = []
|
|
7916
|
-
XEUtils.each(
|
|
8093
|
+
XEUtils.each(internalData.treeExpandedMaps, item => {
|
|
7917
8094
|
if (item) {
|
|
7918
8095
|
rest.push(item)
|
|
7919
8096
|
}
|
|
@@ -7948,12 +8125,10 @@ const Methods = {
|
|
|
7948
8125
|
const reactData = $xeTable as unknown as TableReactData
|
|
7949
8126
|
const internalData = $xeTable as unknown as TableInternalData
|
|
7950
8127
|
|
|
7951
|
-
const { fullAllDataRowIdData } = internalData
|
|
8128
|
+
const { fullAllDataRowIdData, treeExpandedMaps } = internalData
|
|
7952
8129
|
const treeOpts = $xeTable.computeTreeOpts
|
|
7953
8130
|
const { transform } = treeOpts
|
|
7954
|
-
let tExpandedMaps: Record<string, any> = {}
|
|
7955
8131
|
if (rows) {
|
|
7956
|
-
tExpandedMaps = { ...reactData.treeExpandedMaps }
|
|
7957
8132
|
if (!XEUtils.isArray(rows)) {
|
|
7958
8133
|
rows = [rows]
|
|
7959
8134
|
}
|
|
@@ -7962,8 +8137,8 @@ const Methods = {
|
|
|
7962
8137
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
7963
8138
|
if (rowRest) {
|
|
7964
8139
|
rowRest.treeLoaded = false
|
|
7965
|
-
if (
|
|
7966
|
-
delete
|
|
8140
|
+
if (treeExpandedMaps[rowid]) {
|
|
8141
|
+
delete treeExpandedMaps[rowid]
|
|
7967
8142
|
}
|
|
7968
8143
|
}
|
|
7969
8144
|
})
|
|
@@ -7972,7 +8147,8 @@ const Methods = {
|
|
|
7972
8147
|
rowRest.treeLoaded = false
|
|
7973
8148
|
})
|
|
7974
8149
|
}
|
|
7975
|
-
|
|
8150
|
+
internalData.treeExpandedMaps = {}
|
|
8151
|
+
reactData.treeExpandedFlag++
|
|
7976
8152
|
if (transform) {
|
|
7977
8153
|
handleVirtualTreeToList($xeTable)
|
|
7978
8154
|
return $xeTable.handleTableData()
|
|
@@ -7985,37 +8161,45 @@ const Methods = {
|
|
|
7985
8161
|
*/
|
|
7986
8162
|
reloadTreeExpand (row: any) {
|
|
7987
8163
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8164
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7988
8165
|
|
|
7989
|
-
const {
|
|
8166
|
+
const { treeExpandLazyLoadedMaps } = internalData
|
|
8167
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
7990
8168
|
const { transform, lazy } = treeOpts
|
|
7991
8169
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
7992
|
-
const rowid = getRowid(
|
|
8170
|
+
const rowid = getRowid($xeTable, row)
|
|
7993
8171
|
if (lazy && row[hasChildField] && !treeExpandLazyLoadedMaps[rowid]) {
|
|
7994
|
-
return
|
|
7995
|
-
return
|
|
8172
|
+
return $xeTable.clearTreeExpandLoaded(row).then(() => {
|
|
8173
|
+
return handleAsyncTreeExpandChilds($xeTable, row)
|
|
7996
8174
|
}).then(() => {
|
|
7997
8175
|
if (transform) {
|
|
7998
8176
|
handleVirtualTreeToList($xeTable)
|
|
7999
|
-
return
|
|
8177
|
+
return $xeTable.handleTableData()
|
|
8000
8178
|
}
|
|
8001
8179
|
}).then(() => {
|
|
8002
|
-
return
|
|
8180
|
+
return $xeTable.recalculate()
|
|
8003
8181
|
})
|
|
8004
8182
|
}
|
|
8005
|
-
return
|
|
8183
|
+
return $xeTable.$nextTick()
|
|
8006
8184
|
},
|
|
8007
8185
|
reloadTreeChilds (row: any) {
|
|
8186
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8187
|
+
|
|
8008
8188
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
8009
8189
|
warnLog('vxe.error.delFunc', ['reloadTreeChilds', 'reloadTreeExpand'])
|
|
8010
8190
|
}
|
|
8011
8191
|
// 即将废弃
|
|
8012
|
-
return
|
|
8192
|
+
return $xeTable.reloadTreeExpand(row)
|
|
8013
8193
|
},
|
|
8014
8194
|
/**
|
|
8015
8195
|
* 展开树节点事件
|
|
8016
8196
|
*/
|
|
8017
8197
|
triggerTreeExpandEvent (evnt: any, params: any) {
|
|
8018
|
-
const
|
|
8198
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8199
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8200
|
+
|
|
8201
|
+
const { treeExpandLazyLoadedMaps } = internalData
|
|
8202
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
8019
8203
|
const { row, column } = params
|
|
8020
8204
|
const { lazy, trigger } = treeOpts
|
|
8021
8205
|
if (trigger === 'manual') {
|
|
@@ -8024,11 +8208,11 @@ const Methods = {
|
|
|
8024
8208
|
evnt.stopPropagation()
|
|
8025
8209
|
const rowid = getRowid(this, row)
|
|
8026
8210
|
if (!lazy || !treeExpandLazyLoadedMaps[rowid]) {
|
|
8027
|
-
const expanded =
|
|
8028
|
-
const columnIndex =
|
|
8029
|
-
const $columnIndex =
|
|
8030
|
-
|
|
8031
|
-
|
|
8211
|
+
const expanded = !$xeTable.isTreeExpandByRow(row)
|
|
8212
|
+
const columnIndex = $xeTable.getColumnIndex(column)
|
|
8213
|
+
const $columnIndex = $xeTable.getVMColumnIndex(column)
|
|
8214
|
+
$xeTable.setTreeExpand(row, expanded)
|
|
8215
|
+
$xeTable.dispatchEvent('toggle-tree-expand', { expanded, column, columnIndex, $columnIndex, row }, evnt)
|
|
8032
8216
|
}
|
|
8033
8217
|
},
|
|
8034
8218
|
/**
|
|
@@ -8037,88 +8221,6 @@ const Methods = {
|
|
|
8037
8221
|
toggleTreeExpand (row: any) {
|
|
8038
8222
|
return this.setTreeExpand(row, !this.isTreeExpandByRow(row))
|
|
8039
8223
|
},
|
|
8040
|
-
/**
|
|
8041
|
-
* 处理默认展开树节点
|
|
8042
|
-
*/
|
|
8043
|
-
handleDefaultTreeExpand () {
|
|
8044
|
-
const { treeConfig, treeOpts, tableFullData } = this
|
|
8045
|
-
if (treeConfig) {
|
|
8046
|
-
const { expandAll, expandRowKeys } = treeOpts
|
|
8047
|
-
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
8048
|
-
if (expandAll) {
|
|
8049
|
-
this.setAllTreeExpand(true)
|
|
8050
|
-
} else if (expandRowKeys) {
|
|
8051
|
-
const defExpandeds: any[] = []
|
|
8052
|
-
const rowkey = getRowkey(this)
|
|
8053
|
-
expandRowKeys.forEach((rowid: any) => {
|
|
8054
|
-
const matchObj = XEUtils.findTree(tableFullData, item => rowid === XEUtils.get(item, rowkey), { children: childrenField })
|
|
8055
|
-
if (matchObj) {
|
|
8056
|
-
defExpandeds.push(matchObj.item)
|
|
8057
|
-
}
|
|
8058
|
-
})
|
|
8059
|
-
this.setTreeExpand(defExpandeds, true)
|
|
8060
|
-
}
|
|
8061
|
-
}
|
|
8062
|
-
},
|
|
8063
|
-
handleAsyncTreeExpandChilds (row: any) {
|
|
8064
|
-
const $xeTable = this
|
|
8065
|
-
|
|
8066
|
-
const { treeOpts, checkboxOpts } = this
|
|
8067
|
-
const { transform, loadMethod } = treeOpts
|
|
8068
|
-
const { checkStrictly } = checkboxOpts
|
|
8069
|
-
return new Promise<void>(resolve => {
|
|
8070
|
-
if (loadMethod) {
|
|
8071
|
-
const { treeExpandLazyLoadedMaps, fullAllDataRowIdData } = this
|
|
8072
|
-
const rowid = getRowid($xeTable, row)
|
|
8073
|
-
const rowRest = fullAllDataRowIdData[rowid]
|
|
8074
|
-
treeExpandLazyLoadedMaps[rowid] = row
|
|
8075
|
-
Promise.resolve(
|
|
8076
|
-
loadMethod({ $table: $xeTable, row })
|
|
8077
|
-
).then((childRecords: any) => {
|
|
8078
|
-
if (rowRest) {
|
|
8079
|
-
rowRest.treeLoaded = true
|
|
8080
|
-
}
|
|
8081
|
-
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
8082
|
-
delete treeExpandLazyLoadedMaps[rowid]
|
|
8083
|
-
}
|
|
8084
|
-
if (!XEUtils.isArray(childRecords)) {
|
|
8085
|
-
childRecords = []
|
|
8086
|
-
}
|
|
8087
|
-
if (childRecords) {
|
|
8088
|
-
return this.loadTreeChildren(row, childRecords).then((childRows: any[]) => {
|
|
8089
|
-
const { treeExpandedMaps } = this
|
|
8090
|
-
if (childRows.length && !treeExpandedMaps[rowid]) {
|
|
8091
|
-
treeExpandedMaps[rowid] = row
|
|
8092
|
-
}
|
|
8093
|
-
// 如果当前节点已选中,则展开后子节点也被选中
|
|
8094
|
-
if (!checkStrictly && this.isCheckedByCheckboxRow(row)) {
|
|
8095
|
-
handleCheckedCheckboxRow($xeTable, childRows, true)
|
|
8096
|
-
}
|
|
8097
|
-
return this.$nextTick().then(() => {
|
|
8098
|
-
if (transform) {
|
|
8099
|
-
this.handleTableData()
|
|
8100
|
-
updateAfterDataIndex($xeTable)
|
|
8101
|
-
return this.$nextTick()
|
|
8102
|
-
}
|
|
8103
|
-
})
|
|
8104
|
-
})
|
|
8105
|
-
}
|
|
8106
|
-
}).catch(() => {
|
|
8107
|
-
const { treeExpandLazyLoadedMaps } = this
|
|
8108
|
-
if (rowRest) {
|
|
8109
|
-
rowRest.treeLoaded = false
|
|
8110
|
-
}
|
|
8111
|
-
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
8112
|
-
delete treeExpandLazyLoadedMaps[rowid]
|
|
8113
|
-
}
|
|
8114
|
-
}).finally(() => {
|
|
8115
|
-
this.$nextTick().then(() => this.recalculate()).then(() => resolve())
|
|
8116
|
-
})
|
|
8117
|
-
} else {
|
|
8118
|
-
resolve()
|
|
8119
|
-
}
|
|
8120
|
-
})
|
|
8121
|
-
},
|
|
8122
8224
|
/**
|
|
8123
8225
|
* 设置所有树节点的展开与否
|
|
8124
8226
|
* @param {Boolean} expanded 是否展开
|
|
@@ -8143,41 +8245,47 @@ const Methods = {
|
|
|
8143
8245
|
* @returns
|
|
8144
8246
|
*/
|
|
8145
8247
|
handleBaseTreeExpand (rows: any, expanded: any) {
|
|
8146
|
-
const
|
|
8248
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8249
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
8250
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8251
|
+
|
|
8252
|
+
const { treeNodeColumn } = reactData
|
|
8253
|
+
const { fullAllDataRowIdData, tableFullData, treeExpandedMaps, treeExpandLazyLoadedMaps } = internalData
|
|
8254
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
8147
8255
|
const { reserve, lazy, accordion, toggleMethod } = treeOpts
|
|
8148
|
-
const treeTempExpandedMaps = { ...treeExpandedMaps }
|
|
8149
8256
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
8150
8257
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
8151
8258
|
const result: any[] = []
|
|
8152
|
-
const columnIndex =
|
|
8153
|
-
const $columnIndex =
|
|
8154
|
-
|
|
8259
|
+
const columnIndex = $xeTable.getColumnIndex(treeNodeColumn)
|
|
8260
|
+
const $columnIndex = $xeTable.getVMColumnIndex(treeNodeColumn)
|
|
8261
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
8262
|
+
let validRows = toggleMethod ? rows.filter((row: any) => toggleMethod({ $table: $xeTable, expanded, column: treeNodeColumn, columnIndex, $columnIndex, row })) : rows
|
|
8155
8263
|
if (accordion) {
|
|
8156
8264
|
validRows = validRows.length ? [validRows[validRows.length - 1]] : []
|
|
8157
8265
|
// 同一级只能展开一个
|
|
8158
8266
|
const matchObj = XEUtils.findTree(tableFullData, item => item === validRows[0], { children: childrenField })
|
|
8159
8267
|
if (matchObj) {
|
|
8160
8268
|
matchObj.items.forEach(item => {
|
|
8161
|
-
const rowid =
|
|
8162
|
-
if (
|
|
8163
|
-
delete
|
|
8269
|
+
const rowid = handleGetRowId(item)
|
|
8270
|
+
if (treeExpandedMaps[rowid]) {
|
|
8271
|
+
delete treeExpandedMaps[rowid]
|
|
8164
8272
|
}
|
|
8165
8273
|
})
|
|
8166
8274
|
}
|
|
8167
8275
|
}
|
|
8168
8276
|
if (expanded) {
|
|
8169
8277
|
validRows.forEach((row: any) => {
|
|
8170
|
-
const rowid =
|
|
8171
|
-
if (!
|
|
8278
|
+
const rowid = handleGetRowId(row)
|
|
8279
|
+
if (!treeExpandedMaps[rowid]) {
|
|
8172
8280
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
8173
8281
|
if (rowRest) {
|
|
8174
8282
|
const isLoad = lazy && row[hasChildField] && !rowRest.treeLoaded && !treeExpandLazyLoadedMaps[rowid]
|
|
8175
8283
|
// 是否使用懒加载
|
|
8176
8284
|
if (isLoad) {
|
|
8177
|
-
result.push(
|
|
8285
|
+
result.push(handleAsyncTreeExpandChilds($xeTable, row))
|
|
8178
8286
|
} else {
|
|
8179
8287
|
if (row[childrenField] && row[childrenField].length) {
|
|
8180
|
-
|
|
8288
|
+
treeExpandedMaps[rowid] = row
|
|
8181
8289
|
}
|
|
8182
8290
|
}
|
|
8183
8291
|
}
|
|
@@ -8185,18 +8293,18 @@ const Methods = {
|
|
|
8185
8293
|
})
|
|
8186
8294
|
} else {
|
|
8187
8295
|
validRows.forEach((item: any) => {
|
|
8188
|
-
const rowid =
|
|
8189
|
-
if (
|
|
8190
|
-
delete
|
|
8296
|
+
const rowid = handleGetRowId(item)
|
|
8297
|
+
if (treeExpandedMaps[rowid]) {
|
|
8298
|
+
delete treeExpandedMaps[rowid]
|
|
8191
8299
|
}
|
|
8192
8300
|
})
|
|
8193
8301
|
}
|
|
8194
8302
|
if (reserve) {
|
|
8195
|
-
validRows.forEach((row: any) =>
|
|
8303
|
+
validRows.forEach((row: any) => handleTreeExpandReserve($xeTable, row, expanded))
|
|
8196
8304
|
}
|
|
8197
|
-
|
|
8305
|
+
reactData.treeExpandedFlag++
|
|
8198
8306
|
return Promise.all(result).then(() => {
|
|
8199
|
-
return
|
|
8307
|
+
return $xeTable.recalculate()
|
|
8200
8308
|
})
|
|
8201
8309
|
},
|
|
8202
8310
|
/**
|
|
@@ -8250,31 +8358,40 @@ const Methods = {
|
|
|
8250
8358
|
* @param {Row} row 行对象
|
|
8251
8359
|
*/
|
|
8252
8360
|
isTreeExpandByRow (row: any) {
|
|
8253
|
-
const
|
|
8254
|
-
|
|
8361
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8362
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
8363
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8364
|
+
|
|
8365
|
+
const { treeExpandedFlag } = reactData
|
|
8366
|
+
const { treeExpandedMaps } = internalData
|
|
8367
|
+
return !!treeExpandedFlag && !!treeExpandedMaps[getRowid($xeTable, row)]
|
|
8255
8368
|
},
|
|
8256
8369
|
/**
|
|
8257
8370
|
* 手动清空树形节点的展开状态,数据会恢复成未展开的状态
|
|
8258
8371
|
*/
|
|
8259
8372
|
clearTreeExpand () {
|
|
8260
8373
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8374
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
8375
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8261
8376
|
|
|
8262
|
-
const {
|
|
8263
|
-
const
|
|
8377
|
+
const { tableFullTreeData } = internalData
|
|
8378
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
8264
8379
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
8265
|
-
const
|
|
8266
|
-
|
|
8380
|
+
const { transform, reserve } = treeOpts
|
|
8381
|
+
const expList = $xeTable.getTreeExpandRecords()
|
|
8382
|
+
internalData.treeExpandedMaps = {}
|
|
8383
|
+
reactData.treeExpandedFlag++
|
|
8267
8384
|
if (reserve) {
|
|
8268
|
-
XEUtils.eachTree(
|
|
8385
|
+
XEUtils.eachTree(tableFullTreeData, row => handleTreeExpandReserve($xeTable, row, false), { children: childrenField })
|
|
8269
8386
|
}
|
|
8270
|
-
return
|
|
8387
|
+
return $xeTable.handleTableData().then(() => {
|
|
8271
8388
|
if (transform) {
|
|
8272
8389
|
handleVirtualTreeToList($xeTable)
|
|
8273
|
-
return
|
|
8390
|
+
return $xeTable.handleTableData()
|
|
8274
8391
|
}
|
|
8275
8392
|
}).then(() => {
|
|
8276
8393
|
if (expList.length) {
|
|
8277
|
-
|
|
8394
|
+
$xeTable.recalculate()
|
|
8278
8395
|
}
|
|
8279
8396
|
})
|
|
8280
8397
|
},
|
|
@@ -8282,17 +8399,6 @@ const Methods = {
|
|
|
8282
8399
|
this.treeExpandedReserveRowMap = {}
|
|
8283
8400
|
return this.$nextTick()
|
|
8284
8401
|
},
|
|
8285
|
-
handleTreeExpandReserve (row: any, expanded: any) {
|
|
8286
|
-
const { treeExpandedReserveRowMap, treeOpts } = this
|
|
8287
|
-
if (treeOpts.reserve) {
|
|
8288
|
-
const rowid = getRowid(this, row)
|
|
8289
|
-
if (expanded) {
|
|
8290
|
-
treeExpandedReserveRowMap[rowid] = row
|
|
8291
|
-
} else if (treeExpandedReserveRowMap[rowid]) {
|
|
8292
|
-
delete treeExpandedReserveRowMap[rowid]
|
|
8293
|
-
}
|
|
8294
|
-
}
|
|
8295
|
-
},
|
|
8296
8402
|
/**
|
|
8297
8403
|
* 获取表格的滚动状态
|
|
8298
8404
|
*/
|
|
@@ -8617,10 +8723,10 @@ const Methods = {
|
|
|
8617
8723
|
}
|
|
8618
8724
|
|
|
8619
8725
|
const { highlightHoverRow } = tableProps
|
|
8620
|
-
const { scrollXLoad, scrollYLoad } = reactData
|
|
8726
|
+
const { scrollXLoad, scrollYLoad, expandColumn } = reactData
|
|
8621
8727
|
const leftFixedWidth = $xeTable.computeLeftFixedWidth
|
|
8622
8728
|
const rightFixedWidth = $xeTable.computeRightFixedWidth
|
|
8623
|
-
if (!(
|
|
8729
|
+
if (!(leftFixedWidth || rightFixedWidth || expandColumn)) {
|
|
8624
8730
|
return
|
|
8625
8731
|
}
|
|
8626
8732
|
|
|
@@ -8889,8 +8995,8 @@ const Methods = {
|
|
|
8889
8995
|
const reactData = $xeTable as unknown as TableReactData
|
|
8890
8996
|
const internalData = $xeTable as unknown as TableInternalData
|
|
8891
8997
|
|
|
8892
|
-
const { isAllOverflow, scrollYLoad, expandColumn
|
|
8893
|
-
const { scrollYStore, elemStore, isResizeCellHeight, afterFullData, fullAllDataRowIdData } = internalData
|
|
8998
|
+
const { isAllOverflow, scrollYLoad, expandColumn } = reactData
|
|
8999
|
+
const { scrollYStore, elemStore, isResizeCellHeight, afterFullData, fullAllDataRowIdData, rowExpandedMaps } = internalData
|
|
8894
9000
|
const { startIndex } = scrollYStore
|
|
8895
9001
|
const expandOpts = $xeTable.computeExpandOpts
|
|
8896
9002
|
const rowOpts = $xeTable.computeRowOpts
|
|
@@ -9137,12 +9243,15 @@ const Methods = {
|
|
|
9137
9243
|
* 更新表尾合计
|
|
9138
9244
|
*/
|
|
9139
9245
|
updateFooter () {
|
|
9246
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
9247
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
9248
|
+
|
|
9140
9249
|
const { showFooter, visibleColumn, footerData, footerMethod } = this
|
|
9141
9250
|
let footData = []
|
|
9142
9251
|
if (showFooter && footerData && footerData.length) {
|
|
9143
9252
|
footData = footerData.slice(0)
|
|
9144
9253
|
} else if (showFooter && footerMethod) {
|
|
9145
|
-
footData = visibleColumn.length ? footerMethod({ columns: visibleColumn, data: this.afterFullData, $table:
|
|
9254
|
+
footData = visibleColumn.length ? footerMethod({ columns: visibleColumn, data: this.afterFullData, $table: $xeTable, $grid: $xeGrid }) : []
|
|
9146
9255
|
}
|
|
9147
9256
|
this.footerTableData = footData
|
|
9148
9257
|
return this.$nextTick()
|
|
@@ -9225,7 +9334,7 @@ const Methods = {
|
|
|
9225
9334
|
if (this.footerSpanMethod) {
|
|
9226
9335
|
errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method'])
|
|
9227
9336
|
}
|
|
9228
|
-
setMerges(this, merges, this.mergeFooterList
|
|
9337
|
+
setMerges(this, merges, this.mergeFooterList)
|
|
9229
9338
|
return this.$nextTick().then(() => {
|
|
9230
9339
|
this.updateCellAreas()
|
|
9231
9340
|
return updateStyle($xeTable)
|
|
@@ -9280,12 +9389,17 @@ const Methods = {
|
|
|
9280
9389
|
return $xeTable.$nextTick()
|
|
9281
9390
|
},
|
|
9282
9391
|
dispatchEvent (type: ValueOf<VxeTableEmits>, params: Record<string, any>, evnt: Event | null) {
|
|
9283
|
-
const $xeTable = this
|
|
9284
|
-
|
|
9392
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
9393
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
9394
|
+
|
|
9395
|
+
$xeTable.$emit(type, createEvent(evnt, { $table: $xeTable, $grid: $xeGrid }, params))
|
|
9285
9396
|
},
|
|
9286
9397
|
// 已废弃,使用 dispatchEvent
|
|
9287
9398
|
emitEvent (type: any, params: any, evnt: any) {
|
|
9288
|
-
|
|
9399
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
9400
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
9401
|
+
|
|
9402
|
+
this.$emit(type, Object.assign({ $table: $xeTable, $grid: $xeGrid, $event: evnt }, params))
|
|
9289
9403
|
},
|
|
9290
9404
|
focus () {
|
|
9291
9405
|
this.isActivated = true
|