vxe-table 3.14.0-beta.3 → 3.14.0-beta.30
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 +79 -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 +14 -5
- package/es/table/src/body.js +50 -26
- 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 +19 -9
- package/es/table/src/group.js +6 -5
- package/es/table/src/header.js +15 -9
- package/es/table/src/methods.js +1008 -789
- package/es/table/src/props.js +4 -0
- package/es/table/src/table.js +85 -49
- package/es/table/src/util.js +84 -19
- 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 +86 -67
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/index.umd.js +1907 -1344
- 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 +18 -5
- package/lib/table/render/index.min.js +1 -1
- package/lib/table/src/body.js +57 -25
- 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 +19 -7
- 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 +1166 -919
- 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 +96 -20
- 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 +93 -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 +14 -5
- package/packages/table/src/body.ts +49 -25
- 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 +19 -9
- package/packages/table/src/group.ts +9 -5
- package/packages/table/src/header.ts +16 -9
- package/packages/table/src/methods.ts +1110 -830
- package/packages/table/src/props.ts +16 -12
- package/packages/table/src/table.ts +99 -52
- package/packages/table/src/util.ts +95 -19
- package/packages/toolbar/src/toolbar.ts +3 -3
- package/packages/ui/index.ts +1 -0
- /package/es/{iconfont.1741160631070.ttf → iconfont.1742890796110.ttf} +0 -0
- /package/es/{iconfont.1741160631070.woff → iconfont.1742890796110.woff} +0 -0
- /package/es/{iconfont.1741160631070.woff2 → iconfont.1742890796110.woff2} +0 -0
- /package/lib/{iconfont.1741160631070.ttf → iconfont.1742890796110.ttf} +0 -0
- /package/lib/{iconfont.1741160631070.woff → iconfont.1742890796110.woff} +0 -0
- /package/lib/{iconfont.1741160631070.woff2 → iconfont.1742890796110.woff2} +0 -0
|
@@ -3,14 +3,15 @@ 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, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, getRefElem } from './util'
|
|
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
|
|
|
10
|
-
import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, ValueOf, TableReactData, VxeTableConstructor, VxeToolbarConstructor, TableInternalData, VxeTablePrivateMethods, VxeTooltipInstance, VxeTablePropTypes } from '../../../types'
|
|
10
|
+
import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, ValueOf, TableReactData, VxeTableConstructor, VxeToolbarConstructor, TableInternalData, VxeGridConstructor, GridPrivateMethods, VxeTablePrivateMethods, VxeTooltipInstance, VxeTablePropTypes } from '../../../types'
|
|
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,13 @@ 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)
|
|
825
|
+
// indeterminateField 仅支持读取
|
|
851
826
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
852
827
|
const selectRowMaps: Record<string, any> = {}
|
|
853
828
|
/**
|
|
@@ -858,7 +833,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
858
833
|
const checkValFn = (row: any) => {
|
|
859
834
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
860
835
|
if (checked) {
|
|
861
|
-
selectRowMaps[
|
|
836
|
+
selectRowMaps[handleGetRowId(row)] = row
|
|
862
837
|
}
|
|
863
838
|
XEUtils.set(row, checkField, checked)
|
|
864
839
|
}
|
|
@@ -886,7 +861,8 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
886
861
|
*/
|
|
887
862
|
XEUtils.eachTree(afterFullData, (row) => {
|
|
888
863
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
889
|
-
|
|
864
|
+
const rowid = handleGetRowId(row)
|
|
865
|
+
selectRowMaps[rowid] = row
|
|
890
866
|
}
|
|
891
867
|
}, { children: childrenField })
|
|
892
868
|
} else {
|
|
@@ -896,7 +872,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
896
872
|
*/
|
|
897
873
|
if (!isForce && checkMethod) {
|
|
898
874
|
XEUtils.eachTree(afterFullData, (row) => {
|
|
899
|
-
const rowid =
|
|
875
|
+
const rowid = handleGetRowId(row)
|
|
900
876
|
if (checkMethod({ row }) ? 0 : selectCheckboxMaps[rowid]) {
|
|
901
877
|
selectRowMaps[rowid] = row
|
|
902
878
|
}
|
|
@@ -912,14 +888,15 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
912
888
|
*/
|
|
913
889
|
if (!isForce && checkMethod) {
|
|
914
890
|
afterFullData.forEach((row) => {
|
|
915
|
-
const rowid =
|
|
891
|
+
const rowid = handleGetRowId(row)
|
|
916
892
|
if (selectCheckboxMaps[rowid] || checkMethod({ row })) {
|
|
917
893
|
selectRowMaps[rowid] = row
|
|
918
894
|
}
|
|
919
895
|
})
|
|
920
896
|
} else {
|
|
921
897
|
afterFullData.forEach(row => {
|
|
922
|
-
|
|
898
|
+
const rowid = handleGetRowId(row)
|
|
899
|
+
selectRowMaps[rowid] = row
|
|
923
900
|
})
|
|
924
901
|
}
|
|
925
902
|
} else {
|
|
@@ -930,7 +907,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
930
907
|
*/
|
|
931
908
|
if (!isForce && checkMethod) {
|
|
932
909
|
afterFullData.forEach((row) => {
|
|
933
|
-
const rowid =
|
|
910
|
+
const rowid = handleGetRowId(row)
|
|
934
911
|
if (checkMethod({ row }) ? 0 : selectCheckboxMaps[rowid]) {
|
|
935
912
|
selectRowMaps[rowid] = row
|
|
936
913
|
}
|
|
@@ -948,11 +925,11 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
948
925
|
afterFullData.forEach((row) => handleCheckboxReserveRow($xeTable, row, false))
|
|
949
926
|
}
|
|
950
927
|
}
|
|
951
|
-
reactData.
|
|
928
|
+
reactData.updateCheckboxFlag++
|
|
929
|
+
internalData.selectCheckboxMaps = checkField ? {} : selectRowMaps
|
|
952
930
|
|
|
953
931
|
reactData.isAllSelected = checked
|
|
954
932
|
reactData.isIndeterminate = false
|
|
955
|
-
reactData.treeIndeterminateMaps = {}
|
|
956
933
|
internalData.treeIndeterminateRowMaps = {}
|
|
957
934
|
$xeTable.checkSelectionStatus()
|
|
958
935
|
return $xeTable.$nextTick()
|
|
@@ -965,8 +942,8 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
965
942
|
const internalData = $xeTable as unknown as TableInternalData
|
|
966
943
|
|
|
967
944
|
const { treeConfig } = props
|
|
968
|
-
const { expandColumn, currentRow,
|
|
969
|
-
const { fullDataRowIdData, fullAllDataRowIdData, radioReserveRow } = internalData
|
|
945
|
+
const { expandColumn, currentRow, selectRadioRow } = reactData
|
|
946
|
+
const { fullDataRowIdData, fullAllDataRowIdData, radioReserveRow, selectCheckboxMaps, treeExpandedMaps, rowExpandedMaps } = internalData
|
|
970
947
|
const expandOpts = $xeTable.computeExpandOpts
|
|
971
948
|
const treeOpts = $xeTable.computeTreeOpts
|
|
972
949
|
const radioOpts = $xeTable.computeRadioOpts
|
|
@@ -983,7 +960,8 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
983
960
|
}
|
|
984
961
|
}
|
|
985
962
|
// 复选框
|
|
986
|
-
|
|
963
|
+
internalData.selectCheckboxMaps = getRecoverRowMaps($xeTable, selectCheckboxMaps) // 刷新多选行状态
|
|
964
|
+
reactData.updateCheckboxFlag++
|
|
987
965
|
// 还原保留选中状态
|
|
988
966
|
if (checkboxOpts.reserve) {
|
|
989
967
|
handleCheckedCheckboxRow($xeTable, handleReserveRow($xeTable, internalData.checkboxReserveRowMap), true, true)
|
|
@@ -992,18 +970,168 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
992
970
|
reactData.currentRow = null // 刷新当前行状态
|
|
993
971
|
}
|
|
994
972
|
// 行展开
|
|
995
|
-
|
|
973
|
+
internalData.rowExpandedMaps = expandColumn ? getRecoverRowMaps($xeTable, rowExpandedMaps) : {} // 刷新行展开状态
|
|
974
|
+
reactData.rowExpandedFlag++
|
|
996
975
|
// 还原保留状态
|
|
997
976
|
if (expandColumn && expandOpts.reserve) {
|
|
998
977
|
$xeTable.setRowExpand(handleReserveRow($xeTable, internalData.rowExpandedReserveRowMap), true)
|
|
999
978
|
}
|
|
1000
979
|
// 树展开
|
|
1001
|
-
|
|
980
|
+
internalData.treeExpandedMaps = treeConfig ? getRecoverRowMaps($xeTable, treeExpandedMaps) : {} // 刷新树展开状态
|
|
981
|
+
reactData.treeExpandedFlag++
|
|
1002
982
|
if (treeConfig && treeOpts.reserve) {
|
|
1003
983
|
$xeTable.setTreeExpand(handleReserveRow($xeTable, internalData.treeExpandedReserveRowMap), true)
|
|
1004
984
|
}
|
|
1005
985
|
}
|
|
1006
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
|
+
|
|
1007
1135
|
function calcVarRowHeightConfig ($xeTable: VxeTableConstructor, sizeKey: 'default' | 'medium' | 'small' | 'mini', sizeEl: Element) {
|
|
1008
1136
|
const reactData = $xeTable as unknown as TableReactData
|
|
1009
1137
|
|
|
@@ -1069,12 +1197,13 @@ function handleVirtualYVisible ($xeTable: VxeTableConstructor) {
|
|
|
1069
1197
|
toVisibleIndex = Math.floor(startTop / defaultRowHeight) - 1
|
|
1070
1198
|
visibleSize = Math.ceil(clientHeight / defaultRowHeight) + 1
|
|
1071
1199
|
} else {
|
|
1200
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
1072
1201
|
let leftIndex = 0
|
|
1073
1202
|
let rightIndex = afterFullData.length
|
|
1074
1203
|
while (leftIndex < rightIndex) {
|
|
1075
1204
|
const rIndex = Math.floor((leftIndex + rightIndex) / 2)
|
|
1076
1205
|
const row = afterFullData[rIndex]
|
|
1077
|
-
const rowid =
|
|
1206
|
+
const rowid = handleGetRowId(row)
|
|
1078
1207
|
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
1079
1208
|
if (rowRest.oTop <= startTop) {
|
|
1080
1209
|
leftIndex = rIndex + 1
|
|
@@ -1085,7 +1214,7 @@ function handleVirtualYVisible ($xeTable: VxeTableConstructor) {
|
|
|
1085
1214
|
toVisibleIndex = Math.max(0, leftIndex < afterFullData.length ? leftIndex - 2 : 0)
|
|
1086
1215
|
for (let rIndex = toVisibleIndex, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
|
|
1087
1216
|
const row = afterFullData[rIndex]
|
|
1088
|
-
const rowid =
|
|
1217
|
+
const rowid = handleGetRowId(row)
|
|
1089
1218
|
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
1090
1219
|
visibleSize++
|
|
1091
1220
|
if (rowRest.oTop > endTop || visibleSize >= 100) {
|
|
@@ -1117,16 +1246,20 @@ function calculateMergerOffsetIndex (list: any, offsetItem: any, type: any) {
|
|
|
1117
1246
|
}
|
|
1118
1247
|
}
|
|
1119
1248
|
|
|
1120
|
-
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
|
+
|
|
1121
1253
|
if (merges) {
|
|
1122
|
-
const { treeConfig
|
|
1254
|
+
const { treeConfig } = props
|
|
1255
|
+
const { visibleColumn } = internalData
|
|
1123
1256
|
if (!XEUtils.isArray(merges)) {
|
|
1124
1257
|
merges = [merges]
|
|
1125
1258
|
}
|
|
1126
1259
|
if (treeConfig && merges.length) {
|
|
1127
1260
|
errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
|
|
1128
1261
|
}
|
|
1129
|
-
merges.forEach((item
|
|
1262
|
+
merges.forEach((item) => {
|
|
1130
1263
|
let { row, col, rowspan, colspan } = item
|
|
1131
1264
|
if (rowList && XEUtils.isNumber(row)) {
|
|
1132
1265
|
row = rowList[row]
|
|
@@ -1165,10 +1298,14 @@ function setMerges (_vm: any, merges: any, mList: any, rowList: any) {
|
|
|
1165
1298
|
}
|
|
1166
1299
|
}
|
|
1167
1300
|
|
|
1168
|
-
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
|
+
|
|
1169
1305
|
const rest: any[] = []
|
|
1170
1306
|
if (merges) {
|
|
1171
|
-
const { treeConfig
|
|
1307
|
+
const { treeConfig } = props
|
|
1308
|
+
const { visibleColumn } = internalData
|
|
1172
1309
|
if (!XEUtils.isArray(merges)) {
|
|
1173
1310
|
merges = [merges]
|
|
1174
1311
|
}
|
|
@@ -1351,6 +1488,7 @@ function autoCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
|
|
|
1351
1488
|
internalData.headerHeight = headerHeight
|
|
1352
1489
|
internalData.footerHeight = footerHeight
|
|
1353
1490
|
reactData.overflowX = overflowX
|
|
1491
|
+
reactData.resizeWidthFlag++
|
|
1354
1492
|
updateColumnOffsetLeft($xeTable)
|
|
1355
1493
|
updateHeight($xeTable)
|
|
1356
1494
|
reactData.parentHeight = Math.max(internalData.headerHeight + footerHeight + 20, $xeTable.getParentHeight())
|
|
@@ -1381,8 +1519,9 @@ const calcCellHeight = ($xeTable: VxeTableConstructor) => {
|
|
|
1381
1519
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
1382
1520
|
const el = $xeTable.$refs.refElem as HTMLDivElement
|
|
1383
1521
|
if (!isAllOverflow && scrollYLoad && el) {
|
|
1522
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
1384
1523
|
tableData.forEach(row => {
|
|
1385
|
-
const rowid =
|
|
1524
|
+
const rowid = handleGetRowId(row)
|
|
1386
1525
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
1387
1526
|
if (rowRest) {
|
|
1388
1527
|
const height = calcCellAutoHeight(rowRest, el)
|
|
@@ -1630,10 +1769,11 @@ function hideDropTip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
1630
1769
|
* @param {Event} evnt 事件
|
|
1631
1770
|
* @param {Row} row 行对象
|
|
1632
1771
|
*/
|
|
1633
|
-
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) {
|
|
1634
1773
|
const reactData = $xeTable as unknown as TableReactData
|
|
1635
1774
|
|
|
1636
|
-
|
|
1775
|
+
const tipOverEl = overflowElem || tdEl
|
|
1776
|
+
if (!tipOverEl) {
|
|
1637
1777
|
return $xeTable.$nextTick()
|
|
1638
1778
|
}
|
|
1639
1779
|
params.cell = tdEl
|
|
@@ -1643,9 +1783,8 @@ function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
|
|
|
1643
1783
|
const { showAll, contentMethod } = tooltipOpts
|
|
1644
1784
|
const customContent = contentMethod ? contentMethod(params) : null
|
|
1645
1785
|
const useCustom = contentMethod && !XEUtils.eqNull(customContent)
|
|
1646
|
-
const content = useCustom ? customContent : XEUtils.toString(column.type === 'html' ?
|
|
1647
|
-
|
|
1648
|
-
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))) {
|
|
1649
1788
|
Object.assign(tooltipStore, {
|
|
1650
1789
|
row,
|
|
1651
1790
|
column,
|
|
@@ -1655,7 +1794,7 @@ function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
|
|
|
1655
1794
|
$xeTable.$nextTick(() => {
|
|
1656
1795
|
const $tooltip = $xeTable.$refs.refTooltip as VxeTooltipInstance
|
|
1657
1796
|
if ($tooltip && $tooltip.open) {
|
|
1658
|
-
$tooltip.open(
|
|
1797
|
+
$tooltip.open(tipOverEl, formatText(content))
|
|
1659
1798
|
}
|
|
1660
1799
|
})
|
|
1661
1800
|
}
|
|
@@ -1844,8 +1983,8 @@ function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, i
|
|
|
1844
1983
|
const reactData = $xeTable as unknown as TableReactData
|
|
1845
1984
|
const internalData = $xeTable as unknown as TableInternalData
|
|
1846
1985
|
|
|
1847
|
-
const { showOverflow } = props
|
|
1848
|
-
const rowOpts = $xeTable.computeRowOpts
|
|
1986
|
+
// const { showOverflow } = props
|
|
1987
|
+
// const rowOpts = $xeTable.computeRowOpts
|
|
1849
1988
|
const leftList: VxeTableDefines.ColumnInfo[] = []
|
|
1850
1989
|
const centerList: VxeTableDefines.ColumnInfo[] = []
|
|
1851
1990
|
const rightList: VxeTableDefines.ColumnInfo[] = []
|
|
@@ -1910,28 +2049,28 @@ function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, i
|
|
|
1910
2049
|
reactData.hasFixedColumn = leftList.length > 0 || rightList.length > 0
|
|
1911
2050
|
Object.assign(columnStore, { leftList, centerList, rightList })
|
|
1912
2051
|
if (scrollXLoad) {
|
|
1913
|
-
if (showOverflow) {
|
|
1914
|
-
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
}
|
|
1921
|
-
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
}
|
|
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
|
+
// }
|
|
1935
2074
|
if (isReset) {
|
|
1936
2075
|
const { visibleSize } = handleVirtualXVisible($xeTable)
|
|
1937
2076
|
scrollXStore.startIndex = 0
|
|
@@ -2054,6 +2193,39 @@ function loadScrollYData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods
|
|
|
2054
2193
|
}
|
|
2055
2194
|
}
|
|
2056
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
|
+
|
|
2057
2229
|
function lazyScrollXData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
2058
2230
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2059
2231
|
|
|
@@ -2220,7 +2392,7 @@ function calcCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
|
|
|
2220
2392
|
|
|
2221
2393
|
function handleUpdateColResize ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: MouseEvent, params: any) {
|
|
2222
2394
|
$xeTable.analyColumnWidth()
|
|
2223
|
-
$xeTable.recalculate(
|
|
2395
|
+
$xeTable.recalculate().then(() => {
|
|
2224
2396
|
$xeTable.saveCustomStore('update:width')
|
|
2225
2397
|
$xeTable.updateCellAreas()
|
|
2226
2398
|
$xeTable.dispatchEvent('column-resizable-change', params, evnt)
|
|
@@ -2234,7 +2406,7 @@ function handleUpdateRowResize ($xeTable: VxeTableConstructor & VxeTablePrivateM
|
|
|
2234
2406
|
const reactData = $xeTable as unknown as TableReactData
|
|
2235
2407
|
|
|
2236
2408
|
reactData.resizeHeightFlag++
|
|
2237
|
-
$xeTable.recalculate(
|
|
2409
|
+
$xeTable.recalculate().then(() => {
|
|
2238
2410
|
$xeTable.updateCellAreas()
|
|
2239
2411
|
$xeTable.dispatchEvent('row-resizable-change', params, evnt)
|
|
2240
2412
|
setTimeout(() => $xeTable.recalculate(true), 300)
|
|
@@ -2259,16 +2431,17 @@ function updateRowOffsetTop ($xeTable: VxeTableConstructor & VxeTablePrivateMeth
|
|
|
2259
2431
|
const reactData = $xeTable as unknown as TableReactData
|
|
2260
2432
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2261
2433
|
|
|
2262
|
-
const { expandColumn
|
|
2263
|
-
const { afterFullData, fullAllDataRowIdData } = internalData
|
|
2434
|
+
const { expandColumn } = reactData
|
|
2435
|
+
const { afterFullData, fullAllDataRowIdData, rowExpandedMaps } = internalData
|
|
2264
2436
|
const expandOpts = $xeTable.computeExpandOpts
|
|
2265
2437
|
const rowOpts = $xeTable.computeRowOpts
|
|
2266
2438
|
const cellOpts = $xeTable.computeCellOpts
|
|
2267
2439
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
2440
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
2268
2441
|
let offsetTop = 0
|
|
2269
2442
|
for (let rIndex = 0, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
|
|
2270
2443
|
const row = afterFullData[rIndex]
|
|
2271
|
-
const rowid =
|
|
2444
|
+
const rowid = handleGetRowId(row)
|
|
2272
2445
|
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
2273
2446
|
rowRest.oTop = offsetTop
|
|
2274
2447
|
offsetTop += rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight
|
|
@@ -2283,46 +2456,42 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
|
|
|
2283
2456
|
const reactData = $xeTable as unknown as TableReactData
|
|
2284
2457
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2285
2458
|
|
|
2286
|
-
const { expandColumn, scrollYLoad,
|
|
2459
|
+
const { expandColumn, scrollYLoad, scrollYTop, isScrollYBig } = reactData
|
|
2287
2460
|
const expandOpts = $xeTable.computeExpandOpts
|
|
2288
2461
|
const rowOpts = $xeTable.computeRowOpts
|
|
2289
2462
|
const cellOpts = $xeTable.computeCellOpts
|
|
2290
2463
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
2291
2464
|
const { mode } = expandOpts
|
|
2292
2465
|
if (expandColumn && mode === 'fixed') {
|
|
2293
|
-
const { elemStore,
|
|
2466
|
+
const { elemStore, fullAllDataRowIdData } = internalData
|
|
2294
2467
|
const rowExpandEl = $xeTable.$refs.refRowExpandElem as HTMLDivElement
|
|
2295
2468
|
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
2296
2469
|
if (rowExpandEl && bodyScrollElem) {
|
|
2297
2470
|
let isUpdateHeight = false
|
|
2298
|
-
if (scrollYLoad) {
|
|
2299
|
-
let offsetTop = 0
|
|
2300
|
-
for (let rIndex = 0, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
|
|
2301
|
-
const row = afterFullData[rIndex]
|
|
2302
|
-
const rowid = getRowid($xeTable, row)
|
|
2303
|
-
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
2304
|
-
rowRest.oTop = offsetTop
|
|
2305
|
-
offsetTop += rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight
|
|
2306
|
-
// 是否展开行
|
|
2307
|
-
if (expandColumn && rowExpandedMaps[rowid]) {
|
|
2308
|
-
offsetTop += rowRest.expandHeight || expandOpts.height || 0
|
|
2309
|
-
}
|
|
2310
|
-
}
|
|
2311
|
-
}
|
|
2312
2471
|
XEUtils.arrayEach(rowExpandEl.children, reEl => {
|
|
2313
2472
|
const expandEl = reEl as HTMLDivElement
|
|
2314
2473
|
const rowid = expandEl.getAttribute('rowid') || ''
|
|
2315
2474
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
2316
2475
|
if (rowRest) {
|
|
2317
2476
|
const expandHeight = expandEl.offsetHeight + 1
|
|
2477
|
+
const trEl = bodyScrollElem.querySelector(`.vxe-body--row[rowid="${rowid}"]`) as HTMLTableCellElement
|
|
2478
|
+
let offsetTop = 0
|
|
2318
2479
|
if (scrollYLoad) {
|
|
2319
|
-
|
|
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
|
+
}
|
|
2320
2485
|
} else {
|
|
2321
|
-
const trEl = bodyScrollElem.querySelector(`.vxe-body--row[rowid="${rowid}"]`) as HTMLTableCellElement
|
|
2322
2486
|
if (trEl) {
|
|
2323
|
-
|
|
2487
|
+
offsetTop = trEl.offsetTop + trEl.offsetHeight
|
|
2324
2488
|
}
|
|
2325
2489
|
}
|
|
2490
|
+
if (isScrollYBig) {
|
|
2491
|
+
offsetTop += scrollYTop
|
|
2492
|
+
}
|
|
2493
|
+
expandEl.style.top = toCssUnit(offsetTop)
|
|
2494
|
+
|
|
2326
2495
|
if (!isUpdateHeight) {
|
|
2327
2496
|
if (rowRest.expandHeight !== expandHeight) {
|
|
2328
2497
|
isUpdateHeight = true
|
|
@@ -2333,6 +2502,9 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
|
|
|
2333
2502
|
})
|
|
2334
2503
|
if (isUpdateHeight) {
|
|
2335
2504
|
reactData.rowExpandHeightFlag++
|
|
2505
|
+
$xeTable.$nextTick(() => {
|
|
2506
|
+
updateRowOffsetTop($xeTable)
|
|
2507
|
+
})
|
|
2336
2508
|
}
|
|
2337
2509
|
}
|
|
2338
2510
|
}
|
|
@@ -2351,10 +2523,12 @@ function handleRowExpandScroll ($xeTable: VxeTableConstructor & VxeTablePrivateM
|
|
|
2351
2523
|
|
|
2352
2524
|
const Methods = {
|
|
2353
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
|
+
|
|
2354
2529
|
if (slotFunc) {
|
|
2355
|
-
|
|
2356
|
-
|
|
2357
|
-
return $xegrid.callSlot(slotFunc, params, h, vNodes)
|
|
2530
|
+
if ($xeGrid) {
|
|
2531
|
+
return $xeGrid.callSlot(slotFunc, params, h, vNodes)
|
|
2358
2532
|
}
|
|
2359
2533
|
if (XEUtils.isFunction(slotFunc)) {
|
|
2360
2534
|
return getSlotVNs(slotFunc.call(this, params, h, vNodes))
|
|
@@ -2362,21 +2536,45 @@ const Methods = {
|
|
|
2362
2536
|
}
|
|
2363
2537
|
return []
|
|
2364
2538
|
},
|
|
2539
|
+
getEl () {
|
|
2540
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2541
|
+
|
|
2542
|
+
return $xeTable.$refs.refElem as HTMLDivElement
|
|
2543
|
+
},
|
|
2365
2544
|
/**
|
|
2366
2545
|
* 获取父容器元素
|
|
2367
2546
|
*/
|
|
2368
2547
|
getParentElem () {
|
|
2369
|
-
const
|
|
2370
|
-
|
|
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
|
|
2371
2553
|
},
|
|
2372
2554
|
/**
|
|
2373
2555
|
* 获取父容器的高度
|
|
2374
2556
|
*/
|
|
2375
2557
|
getParentHeight () {
|
|
2376
|
-
const
|
|
2377
|
-
const
|
|
2378
|
-
const
|
|
2379
|
-
|
|
2558
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2559
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
2560
|
+
const props = $xeTable
|
|
2561
|
+
|
|
2562
|
+
const { height } = props
|
|
2563
|
+
const el = $xeTable.$refs.refElem as HTMLDivElement
|
|
2564
|
+
if (el) {
|
|
2565
|
+
const parentElem = el.parentNode as HTMLElement
|
|
2566
|
+
const parentPaddingSize = height === '100%' || height === 'auto' ? getPaddingTopBottomSize(parentElem) : 0
|
|
2567
|
+
let parentWrapperHeight = 0
|
|
2568
|
+
if (parentElem) {
|
|
2569
|
+
if ($xeGrid && hasClass(parentElem, 'vxe-grid--table-wrapper')) {
|
|
2570
|
+
parentWrapperHeight = $xeGrid.getParentHeight()
|
|
2571
|
+
} else {
|
|
2572
|
+
parentWrapperHeight = parentElem.clientHeight
|
|
2573
|
+
}
|
|
2574
|
+
}
|
|
2575
|
+
return Math.floor(parentWrapperHeight - parentPaddingSize)
|
|
2576
|
+
}
|
|
2577
|
+
return 0
|
|
2380
2578
|
},
|
|
2381
2579
|
/**
|
|
2382
2580
|
* 获取需要排除的高度
|
|
@@ -2384,8 +2582,10 @@ const Methods = {
|
|
|
2384
2582
|
* 如果存在表尾合计滚动条,则需要排除滚动条高度
|
|
2385
2583
|
*/
|
|
2386
2584
|
getExcludeHeight () {
|
|
2387
|
-
const
|
|
2388
|
-
|
|
2585
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2586
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
2587
|
+
|
|
2588
|
+
return $xeGrid ? $xeGrid.getExcludeHeight() : 0
|
|
2389
2589
|
},
|
|
2390
2590
|
/**
|
|
2391
2591
|
* 重置表格的一切数据状态
|
|
@@ -2466,6 +2666,9 @@ const Methods = {
|
|
|
2466
2666
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
2467
2667
|
let treeData = []
|
|
2468
2668
|
let fullData = datas ? datas.slice(0) : []
|
|
2669
|
+
if (fullData.length > supportMaxRow) {
|
|
2670
|
+
errLog('vxe.error.errMaxRow', [supportMaxRow])
|
|
2671
|
+
}
|
|
2469
2672
|
if (treeConfig) {
|
|
2470
2673
|
// 树结构自动转换
|
|
2471
2674
|
if (treeOpts.transform) {
|
|
@@ -2710,35 +2913,17 @@ const Methods = {
|
|
|
2710
2913
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2711
2914
|
|
|
2712
2915
|
const { treeConfig } = props
|
|
2713
|
-
const { treeExpandedMaps } =
|
|
2714
|
-
const { fullAllDataRowIdData, tableFullData, tableFullTreeData } = internalData
|
|
2916
|
+
const { fullAllDataRowIdData, tableFullData, tableFullTreeData, treeExpandedMaps } = internalData
|
|
2715
2917
|
const treeOpts = $xeTable.computeTreeOpts
|
|
2716
2918
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
2717
2919
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
2718
|
-
const
|
|
2920
|
+
const { lazy } = treeOpts
|
|
2719
2921
|
const fullAllDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = { ...fullAllDataRowIdData } // 存在已删除数据
|
|
2720
2922
|
const fullDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = {}
|
|
2721
|
-
|
|
2722
|
-
const
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
const level = nodes ? nodes.length - 1 : 0
|
|
2726
|
-
if (eqEmptyValue(rowid)) {
|
|
2727
|
-
rowid = getRowUniqueId()
|
|
2728
|
-
XEUtils.set(row, rowkey, rowid)
|
|
2729
|
-
}
|
|
2730
|
-
if (treeConfig && treeOpts.lazy) {
|
|
2731
|
-
const treeExpRest = treeExpandedMaps[rowid]
|
|
2732
|
-
if (row[hasChildField] && XEUtils.isUndefined(row[childrenField])) {
|
|
2733
|
-
row[childrenField] = null
|
|
2734
|
-
}
|
|
2735
|
-
if (treeExpRest) {
|
|
2736
|
-
if (!row[childrenField] || !row[childrenField].length) {
|
|
2737
|
-
delete treeTempExpandedMaps[rowid]
|
|
2738
|
-
}
|
|
2739
|
-
}
|
|
2740
|
-
}
|
|
2741
|
-
let rowRest = fullAllDataRowIdData[rowid]
|
|
2923
|
+
|
|
2924
|
+
const { handleUpdateRowId } = createHandleUpdateRowId($xeTable)
|
|
2925
|
+
const handleRowCache = (row: any, index: number, items: any, currIndex: number, parentRow: any, rowid: string, level: number, seq: string | number) => {
|
|
2926
|
+
let rowRest = fullAllDataRowIdMaps[rowid]
|
|
2742
2927
|
if (!rowRest) {
|
|
2743
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 }
|
|
2744
2929
|
}
|
|
@@ -2749,34 +2934,51 @@ const Methods = {
|
|
|
2749
2934
|
rowRest.items = items
|
|
2750
2935
|
rowRest.parent = parentRow
|
|
2751
2936
|
rowRest.level = level
|
|
2752
|
-
rowRest.index =
|
|
2937
|
+
rowRest.index = currIndex
|
|
2938
|
+
rowRest.treeIndex = index
|
|
2939
|
+
|
|
2753
2940
|
fullDataRowIdMaps[rowid] = rowRest
|
|
2754
2941
|
fullAllDataRowIdMaps[rowid] = rowRest
|
|
2755
2942
|
}
|
|
2943
|
+
|
|
2756
2944
|
if (treeConfig) {
|
|
2757
|
-
XEUtils.eachTree(tableFullTreeData,
|
|
2945
|
+
XEUtils.eachTree(tableFullTreeData, (row, index, items, path, parentRow, nodes) => {
|
|
2946
|
+
const rowid = handleUpdateRowId(row)
|
|
2947
|
+
if (treeConfig && lazy) {
|
|
2948
|
+
if (row[hasChildField] && row[childrenField] === undefined) {
|
|
2949
|
+
row[childrenField] = null
|
|
2950
|
+
}
|
|
2951
|
+
if (treeExpandedMaps[rowid]) {
|
|
2952
|
+
if (!row[childrenField] || !row[childrenField].length) {
|
|
2953
|
+
delete treeExpandedMaps[rowid]
|
|
2954
|
+
}
|
|
2955
|
+
}
|
|
2956
|
+
}
|
|
2957
|
+
handleRowCache(row, index, items, parentRow ? -1 : index, parentRow, rowid, nodes.length - 1, toTreePathSeq(path))
|
|
2958
|
+
}, { children: childrenField })
|
|
2758
2959
|
} else {
|
|
2759
|
-
tableFullData.forEach(
|
|
2960
|
+
tableFullData.forEach((row, index, items) => {
|
|
2961
|
+
handleRowCache(row, index, items, index, null, handleUpdateRowId(row), 0, index + 1)
|
|
2962
|
+
})
|
|
2760
2963
|
}
|
|
2964
|
+
|
|
2761
2965
|
internalData.fullDataRowIdData = fullDataRowIdMaps
|
|
2762
2966
|
internalData.fullAllDataRowIdData = fullAllDataRowIdMaps
|
|
2763
|
-
reactData.
|
|
2967
|
+
reactData.treeExpandedFlag++
|
|
2764
2968
|
},
|
|
2765
2969
|
cacheSourceMap (fullData: any[]) {
|
|
2766
|
-
|
|
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
|
|
2767
2976
|
const sourceData = XEUtils.clone(fullData, true)
|
|
2768
|
-
const
|
|
2769
|
-
|
|
2977
|
+
const { handleUpdateRowId } = createHandleUpdateRowId($xeTable)
|
|
2978
|
+
const sourceRowIdData: Record<string, any> = {}
|
|
2770
2979
|
const handleSourceRow = (row: any) => {
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
rowid = getRowUniqueId()
|
|
2774
|
-
XEUtils.set(row, rowkey, rowid)
|
|
2775
|
-
}
|
|
2776
|
-
sourceDataRowIdData[rowid] = {
|
|
2777
|
-
row,
|
|
2778
|
-
rowid
|
|
2779
|
-
}
|
|
2980
|
+
const rowid = handleUpdateRowId(row)
|
|
2981
|
+
sourceRowIdData[rowid] = row
|
|
2780
2982
|
}
|
|
2781
2983
|
// 源数据缓存
|
|
2782
2984
|
if (treeConfig) {
|
|
@@ -2785,7 +2987,8 @@ const Methods = {
|
|
|
2785
2987
|
} else {
|
|
2786
2988
|
sourceData.forEach(handleSourceRow)
|
|
2787
2989
|
}
|
|
2788
|
-
|
|
2990
|
+
internalData.sourceDataRowIdData = sourceRowIdData
|
|
2991
|
+
internalData.tableSourceData = sourceData
|
|
2789
2992
|
},
|
|
2790
2993
|
getParams () {
|
|
2791
2994
|
return this.params
|
|
@@ -2873,47 +3076,22 @@ const Methods = {
|
|
|
2873
3076
|
* 根据 row 获取序号
|
|
2874
3077
|
* @param {Row} row 行对象
|
|
2875
3078
|
*/
|
|
2876
|
-
getRowSeq (
|
|
2877
|
-
const { fullAllDataRowIdData } = this
|
|
2878
|
-
if (row) {
|
|
2879
|
-
const rowid = getRowid(this, row)
|
|
2880
|
-
const rest = fullAllDataRowIdData[rowid]
|
|
2881
|
-
if (rest) {
|
|
2882
|
-
return rest.seq
|
|
2883
|
-
}
|
|
2884
|
-
}
|
|
2885
|
-
return -1
|
|
2886
|
-
},
|
|
3079
|
+
getRowSeq: createGetRowCacheProp('seq'),
|
|
2887
3080
|
/**
|
|
2888
3081
|
* 根据 row 获取相对于 data 中的索引
|
|
2889
3082
|
* @param {Row} row 行对象
|
|
2890
3083
|
*/
|
|
2891
|
-
getRowIndex (row: any)
|
|
2892
|
-
const { fullAllDataRowIdData } = this
|
|
2893
|
-
if (row) {
|
|
2894
|
-
const rowid = getRowid(this, row)
|
|
2895
|
-
const rest = fullAllDataRowIdData[rowid]
|
|
2896
|
-
if (rest) {
|
|
2897
|
-
return rest.index
|
|
2898
|
-
}
|
|
2899
|
-
}
|
|
2900
|
-
return -1
|
|
2901
|
-
},
|
|
3084
|
+
getRowIndex: createGetRowCacheProp('index') as ((row: any) => number),
|
|
2902
3085
|
/**
|
|
2903
3086
|
* 根据 row 获取相对于当前数据中的索引
|
|
2904
3087
|
* @param {Row} row 行对象
|
|
2905
3088
|
*/
|
|
2906
|
-
getVTRowIndex (row: any)
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
return rest._index
|
|
2913
|
-
}
|
|
2914
|
-
}
|
|
2915
|
-
return -1
|
|
2916
|
-
},
|
|
3089
|
+
getVTRowIndex: createGetRowCacheProp('_index') as ((row: any) => number),
|
|
3090
|
+
/**
|
|
3091
|
+
* 根据 row 获取渲染中的虚拟索引
|
|
3092
|
+
* @param {Row} row 行对象
|
|
3093
|
+
*/
|
|
3094
|
+
getVMRowIndex: createGetRowCacheProp('$index') as ((row: any) => number),
|
|
2917
3095
|
// 在 v3 中废弃
|
|
2918
3096
|
_getRowIndex (row: any) {
|
|
2919
3097
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -2921,21 +3099,6 @@ const Methods = {
|
|
|
2921
3099
|
}
|
|
2922
3100
|
return this.getVTRowIndex(row)
|
|
2923
3101
|
},
|
|
2924
|
-
/**
|
|
2925
|
-
* 根据 row 获取渲染中的虚拟索引
|
|
2926
|
-
* @param {Row} row 行对象
|
|
2927
|
-
*/
|
|
2928
|
-
getVMRowIndex (row: any) {
|
|
2929
|
-
const { fullAllDataRowIdData } = this
|
|
2930
|
-
if (row) {
|
|
2931
|
-
const rowid = getRowid(this, row)
|
|
2932
|
-
const rest = fullAllDataRowIdData[rowid]
|
|
2933
|
-
if (rest) {
|
|
2934
|
-
return rest.$index
|
|
2935
|
-
}
|
|
2936
|
-
}
|
|
2937
|
-
return -1
|
|
2938
|
-
},
|
|
2939
3102
|
// 在 v3 中废弃
|
|
2940
3103
|
$getRowIndex (row: any) {
|
|
2941
3104
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -2947,30 +3110,17 @@ const Methods = {
|
|
|
2947
3110
|
* 根据 column 获取相对于 columns 中的索引
|
|
2948
3111
|
* @param {ColumnInfo} column 列配置
|
|
2949
3112
|
*/
|
|
2950
|
-
getColumnIndex (
|
|
2951
|
-
const { fullColumnIdData } = this
|
|
2952
|
-
if (column) {
|
|
2953
|
-
const rest = fullColumnIdData[column.id]
|
|
2954
|
-
if (rest) {
|
|
2955
|
-
return rest.index
|
|
2956
|
-
}
|
|
2957
|
-
}
|
|
2958
|
-
return -1
|
|
2959
|
-
},
|
|
3113
|
+
getColumnIndex: createGetColumnCacheProp('index'),
|
|
2960
3114
|
/**
|
|
2961
3115
|
* 根据 column 获取相对于当前表格列中的索引
|
|
2962
3116
|
* @param {ColumnInfo} column 列配置
|
|
2963
3117
|
*/
|
|
2964
|
-
getVTColumnIndex (
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
}
|
|
2971
|
-
}
|
|
2972
|
-
return -1
|
|
2973
|
-
},
|
|
3118
|
+
getVTColumnIndex: createGetColumnCacheProp('_index'),
|
|
3119
|
+
/**
|
|
3120
|
+
* 根据 column 获取渲染中的虚拟索引
|
|
3121
|
+
* @param {ColumnInfo} column 列配置
|
|
3122
|
+
*/
|
|
3123
|
+
getVMColumnIndex: createGetColumnCacheProp('$index'),
|
|
2974
3124
|
// 在 v3 中废弃
|
|
2975
3125
|
_getColumnIndex (column: any) {
|
|
2976
3126
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -2978,20 +3128,6 @@ const Methods = {
|
|
|
2978
3128
|
}
|
|
2979
3129
|
return this.getVTColumnIndex(column)
|
|
2980
3130
|
},
|
|
2981
|
-
/**
|
|
2982
|
-
* 根据 column 获取渲染中的虚拟索引
|
|
2983
|
-
* @param {ColumnInfo} column 列配置
|
|
2984
|
-
*/
|
|
2985
|
-
getVMColumnIndex (column: any) {
|
|
2986
|
-
const { fullColumnIdData } = this
|
|
2987
|
-
if (column) {
|
|
2988
|
-
const rest = fullColumnIdData[column.id]
|
|
2989
|
-
if (rest) {
|
|
2990
|
-
return rest.$index
|
|
2991
|
-
}
|
|
2992
|
-
}
|
|
2993
|
-
return -1
|
|
2994
|
-
},
|
|
2995
3131
|
// 在 v3 中废弃
|
|
2996
3132
|
$getColumnIndex (column: any) {
|
|
2997
3133
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -3085,12 +3221,15 @@ const Methods = {
|
|
|
3085
3221
|
const internalData = $xeTable as unknown as TableInternalData
|
|
3086
3222
|
|
|
3087
3223
|
const { keepSource, treeConfig } = props
|
|
3088
|
-
const {
|
|
3224
|
+
const { editStore } = reactData
|
|
3225
|
+
const { fullAllDataRowIdData, fullDataRowIdData, tableSourceData, sourceDataRowIdData, tableFullData, afterFullData } = internalData
|
|
3226
|
+
const removeTempMaps = { ...editStore.removeMaps }
|
|
3089
3227
|
const treeOpts = $xeTable.computeTreeOpts
|
|
3090
3228
|
const { transform } = treeOpts
|
|
3229
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
3091
3230
|
if (!keepSource) {
|
|
3092
3231
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
3093
|
-
|
|
3232
|
+
errLog('vxe.error.reqProp', ['keep-source'])
|
|
3094
3233
|
}
|
|
3095
3234
|
return $xeTable.$nextTick()
|
|
3096
3235
|
}
|
|
@@ -3104,22 +3243,23 @@ const Methods = {
|
|
|
3104
3243
|
}
|
|
3105
3244
|
let reDelFlag = false
|
|
3106
3245
|
if (targetRows.length) {
|
|
3107
|
-
targetRows.forEach((
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3246
|
+
targetRows.forEach((item: any) => {
|
|
3247
|
+
const rowid = handleGetRowId(item)
|
|
3248
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
3249
|
+
if (rowRest) {
|
|
3250
|
+
const row = rowRest.row
|
|
3251
|
+
if (!$xeTable.isInsertByRow(row)) {
|
|
3252
|
+
const oRow = sourceDataRowIdData[rowid]
|
|
3253
|
+
if (oRow && row) {
|
|
3254
|
+
if (field) {
|
|
3255
|
+
XEUtils.set(row, field, XEUtils.clone(XEUtils.get(oRow, field), true))
|
|
3256
|
+
} else {
|
|
3257
|
+
XEUtils.destructuring(row, XEUtils.clone(oRow, true))
|
|
3258
|
+
}
|
|
3259
|
+
if (!fullDataRowIdData[rowid] && $xeTable.isRemoveByRow(row)) {
|
|
3260
|
+
delete removeTempMaps[rowid]
|
|
3261
|
+
tableFullData.unshift(row)
|
|
3262
|
+
afterFullData.unshift(row)
|
|
3123
3263
|
reDelFlag = true
|
|
3124
3264
|
}
|
|
3125
3265
|
}
|
|
@@ -3129,6 +3269,7 @@ const Methods = {
|
|
|
3129
3269
|
}
|
|
3130
3270
|
if (rows) {
|
|
3131
3271
|
if (reDelFlag) {
|
|
3272
|
+
editStore.removeMaps = removeTempMaps
|
|
3132
3273
|
$xeTable.updateFooter()
|
|
3133
3274
|
$xeTable.cacheRowMap(false)
|
|
3134
3275
|
$xeTable.handleTableData(treeConfig && transform)
|
|
@@ -3291,22 +3432,28 @@ const Methods = {
|
|
|
3291
3432
|
},
|
|
3292
3433
|
/**
|
|
3293
3434
|
* 检查行或列数据是否发生改变
|
|
3294
|
-
* @param {Row}
|
|
3435
|
+
* @param {Row} rowOrId 行对象
|
|
3295
3436
|
* @param {String} field 字段名
|
|
3296
3437
|
*/
|
|
3297
|
-
isUpdateByRow (
|
|
3298
|
-
const
|
|
3438
|
+
isUpdateByRow (rowOrId: any, field?: string | null) {
|
|
3439
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3440
|
+
const props = $xeTable
|
|
3441
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3442
|
+
|
|
3443
|
+
const { keepSource } = props
|
|
3444
|
+
const { tableFullColumn, fullDataRowIdData, sourceDataRowIdData } = internalData
|
|
3299
3445
|
if (keepSource) {
|
|
3300
|
-
const rowid = getRowid(
|
|
3446
|
+
const rowid = XEUtils.isString(rowOrId) || XEUtils.isNumber(rowOrId) ? rowOrId : getRowid($xeTable, rowOrId)
|
|
3447
|
+
const rowRest = fullDataRowIdData[rowid]
|
|
3301
3448
|
// 新增的数据不需要检测
|
|
3302
|
-
if (!
|
|
3449
|
+
if (!rowRest) {
|
|
3303
3450
|
return false
|
|
3304
3451
|
}
|
|
3305
|
-
const
|
|
3306
|
-
|
|
3307
|
-
|
|
3452
|
+
const row = rowRest.row
|
|
3453
|
+
const oRow = sourceDataRowIdData[rowid]
|
|
3454
|
+
if (oRow) {
|
|
3308
3455
|
if (arguments.length > 1) {
|
|
3309
|
-
return !eqCellValue(oRow, row, field)
|
|
3456
|
+
return !eqCellValue(oRow, row, field as string)
|
|
3310
3457
|
}
|
|
3311
3458
|
for (let index = 0, len = tableFullColumn.length; index < len; index++) {
|
|
3312
3459
|
const property = tableFullColumn[index].field
|
|
@@ -3366,6 +3513,107 @@ const Methods = {
|
|
|
3366
3513
|
tableColumn: this.tableColumn.slice(0)
|
|
3367
3514
|
}
|
|
3368
3515
|
},
|
|
3516
|
+
/**
|
|
3517
|
+
* 移动列到指定列的位置
|
|
3518
|
+
* @param fieldOrColumn
|
|
3519
|
+
* @param targetFieldOrColumn
|
|
3520
|
+
* @param options
|
|
3521
|
+
*/
|
|
3522
|
+
moveColumnTo (fieldOrColumn: VxeTableDefines.ColumnInfo, targetFieldOrColumn: VxeTableDefines.ColumnInfo, options?: {
|
|
3523
|
+
isCrossDrag?: boolean
|
|
3524
|
+
dragToChild?: boolean;
|
|
3525
|
+
dragPos?: 'left' | 'right' | '' | null;
|
|
3526
|
+
}) {
|
|
3527
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3528
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3529
|
+
|
|
3530
|
+
const { fullColumnIdData, visibleColumn } = internalData
|
|
3531
|
+
const { dragToChild, dragPos, isCrossDrag } = Object.assign({}, options)
|
|
3532
|
+
const dragCol = handleFieldOrColumn($xeTable, fieldOrColumn)
|
|
3533
|
+
let prevDragCol: VxeTableDefines.ColumnInfo | null = null
|
|
3534
|
+
const colRest = dragCol ? fullColumnIdData[dragCol.id] : null
|
|
3535
|
+
let defPos: 'left' | 'right' = 'left'
|
|
3536
|
+
if (XEUtils.isNumber(targetFieldOrColumn)) {
|
|
3537
|
+
if (colRest && targetFieldOrColumn) {
|
|
3538
|
+
let currList = colRest.items
|
|
3539
|
+
let offsetIndex = colRest._index + targetFieldOrColumn
|
|
3540
|
+
if (isCrossDrag) {
|
|
3541
|
+
currList = visibleColumn
|
|
3542
|
+
offsetIndex = colRest._index + targetFieldOrColumn
|
|
3543
|
+
}
|
|
3544
|
+
if (offsetIndex > 0 && offsetIndex < currList.length - 1) {
|
|
3545
|
+
prevDragCol = currList[offsetIndex]
|
|
3546
|
+
}
|
|
3547
|
+
if (targetFieldOrColumn > 0) {
|
|
3548
|
+
defPos = 'right'
|
|
3549
|
+
}
|
|
3550
|
+
}
|
|
3551
|
+
} else {
|
|
3552
|
+
prevDragCol = handleFieldOrColumn($xeTable, targetFieldOrColumn)
|
|
3553
|
+
const targetColRest = prevDragCol ? fullColumnIdData[prevDragCol.id] : null
|
|
3554
|
+
if (colRest && targetColRest) {
|
|
3555
|
+
if (targetColRest._index > colRest._index) {
|
|
3556
|
+
defPos = 'right'
|
|
3557
|
+
}
|
|
3558
|
+
}
|
|
3559
|
+
}
|
|
3560
|
+
return $xeTable.handleColDragSwapEvent(null, true, dragCol, prevDragCol, dragPos || defPos, dragToChild === true)
|
|
3561
|
+
},
|
|
3562
|
+
/**
|
|
3563
|
+
* 移动行到指定行的位置
|
|
3564
|
+
* @param rowidOrRow
|
|
3565
|
+
* @param targetRowidOrRow
|
|
3566
|
+
* @param options
|
|
3567
|
+
*/
|
|
3568
|
+
moveRowTo (rowidOrRow: any, targetRowidOrRow: any, options?: {
|
|
3569
|
+
isCrossDrag?: boolean
|
|
3570
|
+
dragToChild?: boolean;
|
|
3571
|
+
dragPos?: 'top' | 'bottom' | '' | null;
|
|
3572
|
+
}) {
|
|
3573
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3574
|
+
const props = $xeTable
|
|
3575
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3576
|
+
|
|
3577
|
+
const { treeConfig } = props
|
|
3578
|
+
const { fullAllDataRowIdData, afterFullData } = internalData
|
|
3579
|
+
const { dragToChild, dragPos, isCrossDrag } = Object.assign({}, options)
|
|
3580
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
3581
|
+
const dragRow = handleRowidOrRow($xeTable, rowidOrRow)
|
|
3582
|
+
let prevDragRow: any = null
|
|
3583
|
+
let defPos: 'top' | 'bottom' = 'top'
|
|
3584
|
+
const rowRest = dragRow ? fullAllDataRowIdData[getRowid($xeTable, dragRow)] : null
|
|
3585
|
+
if (XEUtils.isNumber(targetRowidOrRow)) {
|
|
3586
|
+
if (rowRest && targetRowidOrRow) {
|
|
3587
|
+
let currList = afterFullData
|
|
3588
|
+
let offsetIndex = rowRest._index + targetRowidOrRow
|
|
3589
|
+
if (treeConfig) {
|
|
3590
|
+
currList = rowRest.items
|
|
3591
|
+
if (treeOpts.transform) {
|
|
3592
|
+
offsetIndex = rowRest.treeIndex + targetRowidOrRow
|
|
3593
|
+
if (isCrossDrag) {
|
|
3594
|
+
currList = afterFullData
|
|
3595
|
+
offsetIndex = rowRest._index + targetRowidOrRow
|
|
3596
|
+
}
|
|
3597
|
+
}
|
|
3598
|
+
}
|
|
3599
|
+
if (offsetIndex >= 0 && offsetIndex <= currList.length - 1) {
|
|
3600
|
+
prevDragRow = currList[offsetIndex]
|
|
3601
|
+
}
|
|
3602
|
+
if (targetRowidOrRow > 0) {
|
|
3603
|
+
defPos = 'bottom'
|
|
3604
|
+
}
|
|
3605
|
+
}
|
|
3606
|
+
} else {
|
|
3607
|
+
prevDragRow = handleRowidOrRow($xeTable, targetRowidOrRow)
|
|
3608
|
+
const targetRowRest = prevDragRow ? fullAllDataRowIdData[getRowid($xeTable, prevDragRow)] : null
|
|
3609
|
+
if (rowRest && targetRowRest) {
|
|
3610
|
+
if (targetRowRest._index > rowRest._index) {
|
|
3611
|
+
defPos = 'bottom'
|
|
3612
|
+
}
|
|
3613
|
+
}
|
|
3614
|
+
}
|
|
3615
|
+
return $xeTable.handleRowDragSwapEvent(null, true, dragRow, prevDragRow, dragPos || defPos, dragToChild === true)
|
|
3616
|
+
},
|
|
3369
3617
|
/**
|
|
3370
3618
|
* 获取表格的全量列
|
|
3371
3619
|
*/
|
|
@@ -3386,21 +3634,28 @@ const Methods = {
|
|
|
3386
3634
|
/**
|
|
3387
3635
|
* 用于多选行,获取已选中的数据
|
|
3388
3636
|
*/
|
|
3389
|
-
getCheckboxRecords (isFull:
|
|
3390
|
-
const
|
|
3637
|
+
getCheckboxRecords (isFull: boolean) {
|
|
3638
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3639
|
+
const props = $xeTable
|
|
3640
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3641
|
+
|
|
3642
|
+
const { treeConfig } = props
|
|
3643
|
+
const { tableFullData, afterFullData, afterTreeFullData, tableFullTreeData, fullDataRowIdData, afterFullRowMaps, selectCheckboxMaps } = internalData
|
|
3644
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
3645
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
3391
3646
|
const { transform, mapChildrenField } = treeOpts
|
|
3392
3647
|
const { checkField } = checkboxOpts
|
|
3393
3648
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
3394
|
-
|
|
3395
|
-
let rowList = []
|
|
3649
|
+
let rowList: any[] = []
|
|
3396
3650
|
if (checkField) {
|
|
3397
3651
|
if (treeConfig) {
|
|
3652
|
+
const currTableData = isFull ? (transform ? tableFullTreeData : tableFullData) : (transform ? afterTreeFullData : afterFullData)
|
|
3398
3653
|
rowList = XEUtils.filterTree(currTableData, row => XEUtils.get(row, checkField), { children: transform ? mapChildrenField : childrenField })
|
|
3399
3654
|
} else {
|
|
3400
|
-
|
|
3655
|
+
const currTableData = isFull ? tableFullData : afterFullData
|
|
3656
|
+
rowList = currTableData.filter((row) => XEUtils.get(row, checkField))
|
|
3401
3657
|
}
|
|
3402
3658
|
} else {
|
|
3403
|
-
const { selectCheckboxMaps, fullDataRowIdData } = this
|
|
3404
3659
|
XEUtils.each(selectCheckboxMaps, (row, rowid) => {
|
|
3405
3660
|
if (isFull) {
|
|
3406
3661
|
if (fullDataRowIdData[rowid]) {
|
|
@@ -3431,7 +3686,7 @@ const Methods = {
|
|
|
3431
3686
|
const treeOpts = $xeTable.computeTreeOpts
|
|
3432
3687
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
3433
3688
|
const { transform, rowField, parentField, mapChildrenField } = treeOpts
|
|
3434
|
-
const { remote: allRemoteFilter, filterMethod: allFilterMethod } = filterOpts
|
|
3689
|
+
const { isEvery, remote: allRemoteFilter, filterMethod: allFilterMethod } = filterOpts
|
|
3435
3690
|
const { remote: allRemoteSort, sortMethod: allSortMethod, multiple: sortMultiple, chronological } = sortOpts
|
|
3436
3691
|
let tableData: any[] = []
|
|
3437
3692
|
let tableTree: any[] = []
|
|
@@ -3493,7 +3748,7 @@ const Methods = {
|
|
|
3493
3748
|
// 筛选虚拟树
|
|
3494
3749
|
tableTree = XEUtils.searchTree(tableFullTreeData, handleFilter, {
|
|
3495
3750
|
original: true,
|
|
3496
|
-
isEvery
|
|
3751
|
+
isEvery,
|
|
3497
3752
|
children: mapChildrenField,
|
|
3498
3753
|
mapChildren: childrenField
|
|
3499
3754
|
})
|
|
@@ -3507,7 +3762,7 @@ const Methods = {
|
|
|
3507
3762
|
// 还原虚拟树
|
|
3508
3763
|
tableTree = XEUtils.searchTree(tableFullTreeData, () => true, {
|
|
3509
3764
|
original: true,
|
|
3510
|
-
isEvery
|
|
3765
|
+
isEvery,
|
|
3511
3766
|
children: mapChildrenField,
|
|
3512
3767
|
mapChildren: childrenField
|
|
3513
3768
|
})
|
|
@@ -3568,7 +3823,7 @@ const Methods = {
|
|
|
3568
3823
|
// 还原虚拟树
|
|
3569
3824
|
tableTree = XEUtils.searchTree(tableFullTreeData, () => true, {
|
|
3570
3825
|
original: true,
|
|
3571
|
-
isEvery
|
|
3826
|
+
isEvery,
|
|
3572
3827
|
children: treeOpts.mapChildrenField,
|
|
3573
3828
|
mapChildren: childrenField
|
|
3574
3829
|
})
|
|
@@ -3722,6 +3977,8 @@ const Methods = {
|
|
|
3722
3977
|
* 默认执行一次,除非被重置
|
|
3723
3978
|
*/
|
|
3724
3979
|
handleLoadDefaults () {
|
|
3980
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3981
|
+
|
|
3725
3982
|
if (this.checkboxConfig) {
|
|
3726
3983
|
this.handleDefaultSelectionChecked()
|
|
3727
3984
|
}
|
|
@@ -3732,7 +3989,7 @@ const Methods = {
|
|
|
3732
3989
|
this.handleDefaultRowExpand()
|
|
3733
3990
|
}
|
|
3734
3991
|
if (this.treeConfig) {
|
|
3735
|
-
|
|
3992
|
+
handleDefaultTreeExpand($xeTable)
|
|
3736
3993
|
}
|
|
3737
3994
|
if (this.mergeCells) {
|
|
3738
3995
|
this.handleDefaultMergeCells()
|
|
@@ -3756,7 +4013,7 @@ const Methods = {
|
|
|
3756
4013
|
* 设置为固定列
|
|
3757
4014
|
*/
|
|
3758
4015
|
setColumnFixed (fieldOrColumn: any, fixed: any) {
|
|
3759
|
-
const $xeTable = this
|
|
4016
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3760
4017
|
|
|
3761
4018
|
let status = false
|
|
3762
4019
|
const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
|
|
@@ -3930,9 +4187,9 @@ const Methods = {
|
|
|
3930
4187
|
return this.refreshColumn(true)
|
|
3931
4188
|
},
|
|
3932
4189
|
handleCustomRestore (storeData: any) {
|
|
3933
|
-
const $
|
|
3934
|
-
const reactData = $
|
|
3935
|
-
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
|
|
3936
4193
|
|
|
3937
4194
|
let { collectColumn } = internalData
|
|
3938
4195
|
const { resizableData, sortData, visibleData, fixedData } = storeData
|
|
@@ -4002,13 +4259,25 @@ const Methods = {
|
|
|
4002
4259
|
}
|
|
4003
4260
|
},
|
|
4004
4261
|
getCustomStoreData () {
|
|
4005
|
-
const
|
|
4006
|
-
const
|
|
4007
|
-
const
|
|
4008
|
-
|
|
4009
|
-
const
|
|
4010
|
-
const
|
|
4011
|
-
const
|
|
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 = {
|
|
4012
4281
|
resizableData: undefined,
|
|
4013
4282
|
sortData: undefined,
|
|
4014
4283
|
visibleData: undefined,
|
|
@@ -4020,46 +4289,36 @@ const Methods = {
|
|
|
4020
4289
|
}
|
|
4021
4290
|
let hasResizable = 0
|
|
4022
4291
|
let hasSort = 0
|
|
4023
|
-
let
|
|
4292
|
+
let hasFixed = 0
|
|
4024
4293
|
let hasVisible = 0
|
|
4025
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
|
+
}
|
|
4026
4300
|
// 只支持一级
|
|
4027
4301
|
if (!parentColumn) {
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
hasSort = 1
|
|
4032
|
-
sortData[colKey] = column.renderSortNumber
|
|
4033
|
-
}
|
|
4034
|
-
})
|
|
4035
|
-
if (column.fixed !== column.defaultFixed) {
|
|
4036
|
-
const colKey = column.getKey()
|
|
4037
|
-
if (colKey) {
|
|
4038
|
-
hasFixedt = 1
|
|
4039
|
-
fixedData[colKey] = column.fixed
|
|
4040
|
-
}
|
|
4302
|
+
if (isCustomSort) {
|
|
4303
|
+
hasSort = 1
|
|
4304
|
+
sortData[colKey] = column.renderSortNumber
|
|
4041
4305
|
}
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
if (colKey) {
|
|
4046
|
-
hasResizable = 1
|
|
4047
|
-
resizableData[colKey] = column.renderWidth
|
|
4306
|
+
if (isCustomFixed && column.fixed !== column.defaultFixed) {
|
|
4307
|
+
hasFixed = 1
|
|
4308
|
+
fixedData[colKey] = column.fixed
|
|
4048
4309
|
}
|
|
4049
4310
|
}
|
|
4050
|
-
if (
|
|
4311
|
+
if (isCustomResizable && column.resizeWidth) {
|
|
4312
|
+
hasResizable = 1
|
|
4313
|
+
resizableData[colKey] = column.renderWidth
|
|
4314
|
+
}
|
|
4315
|
+
if (isCustomVisible && (!checkMethod || checkMethod({ column }))) {
|
|
4051
4316
|
if (!column.visible && column.defaultVisible) {
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
hasVisible = 1
|
|
4055
|
-
visibleData[colKey] = false
|
|
4056
|
-
}
|
|
4317
|
+
hasVisible = 1
|
|
4318
|
+
visibleData[colKey] = false
|
|
4057
4319
|
} else if (column.visible && !column.defaultVisible) {
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
hasVisible = 1
|
|
4061
|
-
visibleData[colKey] = true
|
|
4062
|
-
}
|
|
4320
|
+
hasVisible = 1
|
|
4321
|
+
visibleData[colKey] = true
|
|
4063
4322
|
}
|
|
4064
4323
|
}
|
|
4065
4324
|
})
|
|
@@ -4069,7 +4328,7 @@ const Methods = {
|
|
|
4069
4328
|
if (hasSort) {
|
|
4070
4329
|
storeData.sortData = sortData
|
|
4071
4330
|
}
|
|
4072
|
-
if (
|
|
4331
|
+
if (hasFixed) {
|
|
4073
4332
|
storeData.fixedData = fixedData
|
|
4074
4333
|
}
|
|
4075
4334
|
if (hasVisible) {
|
|
@@ -4078,9 +4337,9 @@ const Methods = {
|
|
|
4078
4337
|
return storeData
|
|
4079
4338
|
},
|
|
4080
4339
|
saveCustomStore (type: any) {
|
|
4081
|
-
const $xeTable = this
|
|
4340
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
4082
4341
|
const props = $xeTable
|
|
4083
|
-
const reactData = $xeTable as TableReactData
|
|
4342
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
4084
4343
|
|
|
4085
4344
|
const { customConfig } = props
|
|
4086
4345
|
const tableId = $xeTable.computeTableId
|
|
@@ -4558,12 +4817,13 @@ const Methods = {
|
|
|
4558
4817
|
const internalData = $xeTable as unknown as TableInternalData
|
|
4559
4818
|
|
|
4560
4819
|
const { fullAllDataRowIdData, afterFullData } = internalData
|
|
4820
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
4561
4821
|
const rowOpts = $xeTable.computeRowOpts
|
|
4562
4822
|
const cellOpts = $xeTable.computeCellOpts
|
|
4563
4823
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
4564
4824
|
const rest: Record<string, number> = {}
|
|
4565
4825
|
afterFullData.forEach(row => {
|
|
4566
|
-
const rowid =
|
|
4826
|
+
const rowid = handleGetRowId(row)
|
|
4567
4827
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
4568
4828
|
if (rowRest) {
|
|
4569
4829
|
const resizeHeight = rowRest.resizeHeight
|
|
@@ -4591,8 +4851,9 @@ const Methods = {
|
|
|
4591
4851
|
rHeight = Math.floor(rHeight * bodyHeight)
|
|
4592
4852
|
}
|
|
4593
4853
|
if (rHeight) {
|
|
4854
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
4594
4855
|
rows.forEach(row => {
|
|
4595
|
-
const rowid = XEUtils.isString(row) || XEUtils.isNumber(row) ? row :
|
|
4856
|
+
const rowid = XEUtils.isString(row) || XEUtils.isNumber(row) ? row : handleGetRowId(row)
|
|
4596
4857
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
4597
4858
|
if (rowRest) {
|
|
4598
4859
|
rowRest.resizeHeight = rHeight
|
|
@@ -4739,6 +5000,9 @@ const Methods = {
|
|
|
4739
5000
|
}
|
|
4740
5001
|
},
|
|
4741
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
|
+
|
|
4742
5006
|
let evntList = interceptor.get(type)
|
|
4743
5007
|
|
|
4744
5008
|
// 兼容老版本
|
|
@@ -4752,8 +5016,21 @@ const Methods = {
|
|
|
4752
5016
|
}
|
|
4753
5017
|
// 兼容老版本
|
|
4754
5018
|
|
|
4755
|
-
let rest
|
|
4756
|
-
|
|
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) {
|
|
4757
5034
|
if (next) {
|
|
4758
5035
|
rest = next()
|
|
4759
5036
|
}
|
|
@@ -4767,7 +5044,10 @@ const Methods = {
|
|
|
4767
5044
|
* 全局按下事件处理
|
|
4768
5045
|
*/
|
|
4769
5046
|
handleGlobalMousedownEvent (evnt: any) {
|
|
4770
|
-
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
|
|
4771
5051
|
const { actived } = editStore
|
|
4772
5052
|
const { customWrapper, refValidTooltip } = $refs
|
|
4773
5053
|
const tableFilter = $refs.refTableFilter
|
|
@@ -4853,7 +5133,7 @@ const Methods = {
|
|
|
4853
5133
|
}
|
|
4854
5134
|
}
|
|
4855
5135
|
} else if (mouseConfig) {
|
|
4856
|
-
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)) {
|
|
4857
5137
|
if (this.clearSelected) {
|
|
4858
5138
|
this.clearSelected()
|
|
4859
5139
|
}
|
|
@@ -4875,7 +5155,7 @@ const Methods = {
|
|
|
4875
5155
|
if (ctxMenuStore.visible && tableMenu && !getEventTargetNode(evnt, tableMenu.$el).flag) {
|
|
4876
5156
|
this.closeMenu()
|
|
4877
5157
|
}
|
|
4878
|
-
const isActivated = getEventTargetNode(evnt, ($
|
|
5158
|
+
const isActivated = getEventTargetNode(evnt, ($xeGrid || this).$el).flag
|
|
4879
5159
|
// 如果存在校验,点击了表格之外则清除
|
|
4880
5160
|
if (!isActivated && editRules && validOpts.autoClear) {
|
|
4881
5161
|
this.validErrorMaps = {}
|
|
@@ -4936,8 +5216,9 @@ const Methods = {
|
|
|
4936
5216
|
* 全局键盘事件
|
|
4937
5217
|
*/
|
|
4938
5218
|
handleGlobalKeydownEvent (evnt: any) {
|
|
4939
|
-
const $xeTable = this
|
|
4940
|
-
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
|
|
4941
5222
|
|
|
4942
5223
|
// 该行为只对当前激活的表格有效
|
|
4943
5224
|
if (this.isActivated) {
|
|
@@ -5028,7 +5309,7 @@ const Methods = {
|
|
|
5028
5309
|
if (keyboardOpts.enterToTab) {
|
|
5029
5310
|
this.moveTabSelected(activeParams, hasShiftKey, evnt)
|
|
5030
5311
|
} else {
|
|
5031
|
-
this.
|
|
5312
|
+
this.moveEnterSelected(activeParams, isLeftArrow, true, isRightArrow, false, evnt)
|
|
5032
5313
|
}
|
|
5033
5314
|
} else {
|
|
5034
5315
|
if (keyboardOpts.enterToTab) {
|
|
@@ -5060,7 +5341,7 @@ const Methods = {
|
|
|
5060
5341
|
return
|
|
5061
5342
|
}
|
|
5062
5343
|
}
|
|
5063
|
-
this.
|
|
5344
|
+
this.moveEnterSelected(activeParams, isLeftArrow, false, isRightArrow, true, evnt)
|
|
5064
5345
|
if (enterMethod) {
|
|
5065
5346
|
enterMethod(etrParams)
|
|
5066
5347
|
}
|
|
@@ -5084,10 +5365,7 @@ const Methods = {
|
|
|
5084
5365
|
if (!isEditStatus) {
|
|
5085
5366
|
// 如果按下了方向键
|
|
5086
5367
|
if (selected.row && selected.column) {
|
|
5087
|
-
|
|
5088
|
-
} else if ((isUpArrow || isDwArrow) && (rowOpts.isCurrent || highlightCurrentRow)) {
|
|
5089
|
-
// 当前行按键上下移动
|
|
5090
|
-
this.moveCurrentRow(isUpArrow, isDwArrow, evnt)
|
|
5368
|
+
$xeTable.moveArrowSelected(selected.args, isLeftArrow, isUpArrow, isRightArrow, isDwArrow, evnt)
|
|
5091
5369
|
}
|
|
5092
5370
|
}
|
|
5093
5371
|
} else if (isTab && keyboardConfig && keyboardOpts.isTab) {
|
|
@@ -5107,7 +5385,7 @@ const Methods = {
|
|
|
5107
5385
|
column: selected.column,
|
|
5108
5386
|
columnIndex: this.getColumnIndex(selected.column),
|
|
5109
5387
|
$table: this,
|
|
5110
|
-
$grid:
|
|
5388
|
+
$grid: $xeGrid
|
|
5111
5389
|
}
|
|
5112
5390
|
// 是否被禁用
|
|
5113
5391
|
if (!beforeEditMethod || beforeEditMethod(params)) {
|
|
@@ -5132,7 +5410,7 @@ const Methods = {
|
|
|
5132
5410
|
column: selected.column,
|
|
5133
5411
|
columnIndex: this.getColumnIndex(selected.column),
|
|
5134
5412
|
$table: this,
|
|
5135
|
-
$grid:
|
|
5413
|
+
$grid: $xeGrid
|
|
5136
5414
|
}
|
|
5137
5415
|
// 是否被禁用
|
|
5138
5416
|
if (!beforeEditMethod || beforeEditMethod(params)) {
|
|
@@ -5159,7 +5437,7 @@ const Methods = {
|
|
|
5159
5437
|
rowIndex: this.getRowIndex(parentRow),
|
|
5160
5438
|
$rowIndex: this.getVMRowIndex(parentRow),
|
|
5161
5439
|
$table: this,
|
|
5162
|
-
$grid:
|
|
5440
|
+
$grid: $xeGrid
|
|
5163
5441
|
}
|
|
5164
5442
|
this.setTreeExpand(parentRow, false)
|
|
5165
5443
|
.then(() => this.scrollToRow(parentRow))
|
|
@@ -5180,7 +5458,7 @@ const Methods = {
|
|
|
5180
5458
|
column: selected.column,
|
|
5181
5459
|
columnIndex: this.getColumnIndex(selected.column),
|
|
5182
5460
|
$table: this,
|
|
5183
|
-
$grid:
|
|
5461
|
+
$grid: $xeGrid
|
|
5184
5462
|
}
|
|
5185
5463
|
if (!beforeEditMethod || beforeEditMethod(params)) {
|
|
5186
5464
|
if (editMethod) {
|
|
@@ -5302,7 +5580,7 @@ const Methods = {
|
|
|
5302
5580
|
return
|
|
5303
5581
|
}
|
|
5304
5582
|
if (tooltipStore.column !== column || !tooltipStore.visible) {
|
|
5305
|
-
handleTooltip($xeTable, evnt, thEl, cellEl,
|
|
5583
|
+
handleTooltip($xeTable, evnt, thEl, thEl.querySelector<HTMLElement>('.vxe-cell--title') || cellEl, params)
|
|
5306
5584
|
}
|
|
5307
5585
|
},
|
|
5308
5586
|
/**
|
|
@@ -5333,7 +5611,7 @@ const Methods = {
|
|
|
5333
5611
|
}
|
|
5334
5612
|
}
|
|
5335
5613
|
if (tooltipStore.column !== column || tooltipStore.row !== row || !tooltipStore.visible) {
|
|
5336
|
-
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)
|
|
5337
5615
|
}
|
|
5338
5616
|
},
|
|
5339
5617
|
/**
|
|
@@ -5345,10 +5623,10 @@ const Methods = {
|
|
|
5345
5623
|
|
|
5346
5624
|
const { column } = params
|
|
5347
5625
|
const { tooltipStore } = reactData
|
|
5348
|
-
const
|
|
5626
|
+
const tdEl = evnt.currentTarget as HTMLTableCellElement
|
|
5349
5627
|
handleTargetEnterEvent($xeTable, tooltipStore.column !== column || !!tooltipStore.row)
|
|
5350
5628
|
if (tooltipStore.column !== column || !tooltipStore.visible) {
|
|
5351
|
-
handleTooltip($xeTable, evnt,
|
|
5629
|
+
handleTooltip($xeTable, evnt, tdEl, tdEl.querySelector<HTMLElement>('.vxe-cell--label') || tdEl.querySelector('.vxe-cell--wrapper') as HTMLElement, params)
|
|
5352
5630
|
}
|
|
5353
5631
|
},
|
|
5354
5632
|
openTooltip (target: any, content: any) {
|
|
@@ -5406,11 +5684,16 @@ const Methods = {
|
|
|
5406
5684
|
* 获取复选框半选状态的行数据
|
|
5407
5685
|
*/
|
|
5408
5686
|
getCheckboxIndeterminateRecords (isFull: any) {
|
|
5409
|
-
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
|
|
5410
5693
|
if (treeConfig) {
|
|
5411
5694
|
const fullRest: any[] = []
|
|
5412
5695
|
const defRest: any[] = []
|
|
5413
|
-
XEUtils.each(
|
|
5696
|
+
XEUtils.each(treeIndeterminateRowMaps, (item, rowid) => {
|
|
5414
5697
|
if (item) {
|
|
5415
5698
|
fullRest.push(item)
|
|
5416
5699
|
if (fullDataRowIdData[rowid]) {
|
|
@@ -5465,7 +5748,7 @@ const Methods = {
|
|
|
5465
5748
|
},
|
|
5466
5749
|
setCheckboxRowKey (keys: any, checked: boolean) {
|
|
5467
5750
|
const $xeTable = this
|
|
5468
|
-
const internalData = $xeTable
|
|
5751
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5469
5752
|
|
|
5470
5753
|
const { fullAllDataRowIdData } = internalData
|
|
5471
5754
|
if (keys && !XEUtils.isArray(keys)) {
|
|
@@ -5482,23 +5765,25 @@ const Methods = {
|
|
|
5482
5765
|
},
|
|
5483
5766
|
isCheckedByCheckboxRow (row: any) {
|
|
5484
5767
|
const $xeTable = this
|
|
5485
|
-
const reactData = $xeTable
|
|
5768
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
5769
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5486
5770
|
|
|
5487
|
-
const {
|
|
5771
|
+
const { updateCheckboxFlag } = reactData
|
|
5772
|
+
const { selectCheckboxMaps } = internalData
|
|
5488
5773
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5489
5774
|
const { checkField } = checkboxOpts
|
|
5490
5775
|
if (checkField) {
|
|
5491
5776
|
return XEUtils.get(row, checkField)
|
|
5492
5777
|
}
|
|
5493
|
-
return !!selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5778
|
+
return !!updateCheckboxFlag && !!selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5494
5779
|
},
|
|
5495
5780
|
isCheckedByCheckboxRowKey (rowid: string) {
|
|
5496
|
-
const $xeTable = this
|
|
5497
|
-
const reactData = $xeTable
|
|
5498
|
-
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
|
|
5499
5784
|
|
|
5500
|
-
const {
|
|
5501
|
-
const { fullAllDataRowIdData } = internalData
|
|
5785
|
+
const { updateCheckboxFlag } = reactData
|
|
5786
|
+
const { fullAllDataRowIdData, selectCheckboxMaps } = internalData
|
|
5502
5787
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5503
5788
|
const { checkField } = checkboxOpts
|
|
5504
5789
|
if (checkField) {
|
|
@@ -5508,21 +5793,21 @@ const Methods = {
|
|
|
5508
5793
|
}
|
|
5509
5794
|
return false
|
|
5510
5795
|
}
|
|
5511
|
-
return !!selectCheckboxMaps[rowid]
|
|
5796
|
+
return !!updateCheckboxFlag && !!selectCheckboxMaps[rowid]
|
|
5512
5797
|
},
|
|
5513
5798
|
isIndeterminateByCheckboxRow (row: any) {
|
|
5514
|
-
const $xeTable = this
|
|
5515
|
-
const
|
|
5799
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5800
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5516
5801
|
|
|
5517
|
-
const {
|
|
5518
|
-
return !!
|
|
5802
|
+
const { treeIndeterminateRowMaps } = internalData
|
|
5803
|
+
return !!treeIndeterminateRowMaps[getRowid($xeTable, row)] && !$xeTable.isCheckedByCheckboxRow(row)
|
|
5519
5804
|
},
|
|
5520
5805
|
isIndeterminateByCheckboxRowKey (rowid: string) {
|
|
5521
5806
|
const $xeTable = this
|
|
5522
|
-
const
|
|
5807
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5523
5808
|
|
|
5524
|
-
const {
|
|
5525
|
-
return !!
|
|
5809
|
+
const { treeIndeterminateRowMaps } = internalData
|
|
5810
|
+
return !!treeIndeterminateRowMaps[rowid] && !$xeTable.isCheckedByCheckboxRowKey(rowid)
|
|
5526
5811
|
},
|
|
5527
5812
|
/**
|
|
5528
5813
|
* 切换选中
|
|
@@ -5532,15 +5817,17 @@ const Methods = {
|
|
|
5532
5817
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5533
5818
|
const props = $xeTable
|
|
5534
5819
|
const reactData = $xeTable as unknown as TableReactData
|
|
5820
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5535
5821
|
|
|
5536
5822
|
const { treeConfig } = props
|
|
5537
|
-
const { selectCheckboxMaps } =
|
|
5538
|
-
const selectRowMaps = Object.assign({}, selectCheckboxMaps)
|
|
5823
|
+
const { selectCheckboxMaps } = internalData
|
|
5539
5824
|
const treeOpts = $xeTable.computeTreeOpts
|
|
5540
5825
|
const { transform, mapChildrenField } = treeOpts
|
|
5541
5826
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
5542
5827
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5543
5828
|
const { checkField, checkStrictly, checkMethod } = checkboxOpts
|
|
5829
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
5830
|
+
// indeterminateField 仅支持读取
|
|
5544
5831
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
5545
5832
|
if (checkField) {
|
|
5546
5833
|
// 树结构
|
|
@@ -5555,18 +5842,17 @@ const Methods = {
|
|
|
5555
5842
|
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5556
5843
|
}
|
|
5557
5844
|
}, { children: transform ? mapChildrenField : childrenField })
|
|
5558
|
-
reactData.
|
|
5845
|
+
reactData.updateCheckboxFlag++
|
|
5559
5846
|
return
|
|
5560
|
-
} else {
|
|
5561
|
-
// 列表
|
|
5562
|
-
rows.forEach(row => {
|
|
5563
|
-
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5564
|
-
XEUtils.set(row, checkField, checked)
|
|
5565
|
-
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5566
|
-
}
|
|
5567
|
-
})
|
|
5568
5847
|
}
|
|
5569
|
-
|
|
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++
|
|
5570
5856
|
return
|
|
5571
5857
|
}
|
|
5572
5858
|
|
|
@@ -5574,51 +5860,55 @@ const Methods = {
|
|
|
5574
5860
|
if (treeConfig && !checkStrictly) {
|
|
5575
5861
|
// 更新子节点状态
|
|
5576
5862
|
XEUtils.eachTree(rows, (row) => {
|
|
5577
|
-
const rowid =
|
|
5863
|
+
const rowid = handleGetRowId(row)
|
|
5578
5864
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5579
5865
|
if (checked) {
|
|
5580
|
-
|
|
5866
|
+
selectCheckboxMaps[rowid] = row
|
|
5581
5867
|
} else {
|
|
5582
|
-
if (
|
|
5583
|
-
delete
|
|
5868
|
+
if (selectCheckboxMaps[rowid]) {
|
|
5869
|
+
delete selectCheckboxMaps[rowid]
|
|
5584
5870
|
}
|
|
5585
5871
|
}
|
|
5586
5872
|
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5587
5873
|
}
|
|
5588
5874
|
}, { children: transform ? mapChildrenField : childrenField })
|
|
5589
|
-
reactData.
|
|
5875
|
+
reactData.updateCheckboxFlag++
|
|
5590
5876
|
return
|
|
5591
5877
|
}
|
|
5592
5878
|
|
|
5593
5879
|
// 列表
|
|
5594
5880
|
rows.forEach(row => {
|
|
5595
|
-
const rowid =
|
|
5881
|
+
const rowid = handleGetRowId(row)
|
|
5596
5882
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5597
5883
|
if (checked) {
|
|
5598
|
-
if (!
|
|
5599
|
-
|
|
5884
|
+
if (!selectCheckboxMaps[rowid]) {
|
|
5885
|
+
selectCheckboxMaps[rowid] = row
|
|
5600
5886
|
}
|
|
5601
5887
|
} else {
|
|
5602
|
-
if (
|
|
5603
|
-
delete
|
|
5888
|
+
if (selectCheckboxMaps[rowid]) {
|
|
5889
|
+
delete selectCheckboxMaps[rowid]
|
|
5604
5890
|
}
|
|
5605
5891
|
}
|
|
5606
5892
|
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5893
|
+
reactData.updateCheckboxFlag++
|
|
5607
5894
|
}
|
|
5608
5895
|
})
|
|
5609
|
-
reactData.selectCheckboxMaps = selectRowMaps
|
|
5610
5896
|
},
|
|
5611
5897
|
/**
|
|
5612
5898
|
* 即将移除
|
|
5613
5899
|
* @deprecated
|
|
5614
5900
|
*/
|
|
5615
5901
|
handleSelectRow ({ row }: any, checked: boolean, isForce?: boolean) {
|
|
5616
|
-
const $xeTable = this
|
|
5902
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5617
5903
|
|
|
5618
5904
|
$xeTable.handleBatchSelectRows([row], checked, isForce)
|
|
5619
5905
|
},
|
|
5620
5906
|
handleToggleCheckRowEvent (evnt: any, params: any) {
|
|
5621
|
-
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
|
|
5622
5912
|
const { checkField, trigger } = checkboxOpts
|
|
5623
5913
|
const { row } = params
|
|
5624
5914
|
if (trigger === 'manual') {
|
|
@@ -5628,47 +5918,52 @@ const Methods = {
|
|
|
5628
5918
|
if (checkField) {
|
|
5629
5919
|
checked = !XEUtils.get(row, checkField)
|
|
5630
5920
|
} else {
|
|
5631
|
-
checked = !selectCheckboxMaps[getRowid(
|
|
5921
|
+
checked = !selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5632
5922
|
}
|
|
5633
5923
|
if (evnt) {
|
|
5634
|
-
|
|
5924
|
+
$xeTable.triggerCheckRowEvent(evnt, params, checked)
|
|
5635
5925
|
} else {
|
|
5636
|
-
|
|
5637
|
-
|
|
5926
|
+
$xeTable.handleBatchSelectRows([row], checked)
|
|
5927
|
+
$xeTable.checkSelectionStatus()
|
|
5638
5928
|
}
|
|
5639
5929
|
},
|
|
5640
5930
|
triggerCheckRowEvent (evnt: any, params: any, checked: any) {
|
|
5641
|
-
const $xeTable = this
|
|
5931
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5932
|
+
const props = $xeTable
|
|
5933
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5642
5934
|
|
|
5643
|
-
const { checkboxOpts, afterFullData } = this
|
|
5644
|
-
const { checkMethod, trigger } = checkboxOpts
|
|
5645
5935
|
const { row } = params
|
|
5936
|
+
const { afterFullData } = internalData
|
|
5937
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5938
|
+
const { checkMethod, trigger } = checkboxOpts
|
|
5646
5939
|
if (trigger === 'manual') {
|
|
5647
5940
|
return
|
|
5648
5941
|
}
|
|
5649
5942
|
evnt.stopPropagation()
|
|
5650
|
-
if (checkboxOpts.isShiftKey && evnt.shiftKey && !
|
|
5651
|
-
const checkboxRecords =
|
|
5943
|
+
if (checkboxOpts.isShiftKey && evnt.shiftKey && !props.treeConfig) {
|
|
5944
|
+
const checkboxRecords = $xeTable.getCheckboxRecords()
|
|
5652
5945
|
if (checkboxRecords.length) {
|
|
5653
5946
|
const firstRow = checkboxRecords[0]
|
|
5654
|
-
const _rowIndex =
|
|
5655
|
-
const _firstRowIndex =
|
|
5947
|
+
const _rowIndex = $xeTable.getVTRowIndex(row)
|
|
5948
|
+
const _firstRowIndex = $xeTable.getVTRowIndex(firstRow)
|
|
5656
5949
|
if (_rowIndex !== _firstRowIndex) {
|
|
5657
|
-
|
|
5950
|
+
$xeTable.setAllCheckboxRow(false)
|
|
5658
5951
|
const rangeRows = _rowIndex < _firstRowIndex ? afterFullData.slice(_rowIndex, _firstRowIndex + 1) : afterFullData.slice(_firstRowIndex, _rowIndex + 1)
|
|
5659
|
-
|
|
5660
|
-
|
|
5952
|
+
$xeTable.$nextTick(() => {
|
|
5953
|
+
handleCheckedCheckboxRow($xeTable, rangeRows, true, false)
|
|
5954
|
+
})
|
|
5955
|
+
$xeTable.dispatchEvent('checkbox-range-select', Object.assign({ rangeRecords: rangeRows }, params), evnt)
|
|
5661
5956
|
return
|
|
5662
5957
|
}
|
|
5663
5958
|
}
|
|
5664
5959
|
}
|
|
5665
5960
|
if (!checkMethod || checkMethod({ row })) {
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
records:
|
|
5670
|
-
reserves:
|
|
5671
|
-
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(),
|
|
5672
5967
|
checked
|
|
5673
5968
|
}, params), evnt)
|
|
5674
5969
|
}
|
|
@@ -5677,9 +5972,11 @@ const Methods = {
|
|
|
5677
5972
|
* 多选,切换某一行的选中状态
|
|
5678
5973
|
*/
|
|
5679
5974
|
toggleCheckboxRow (row: any) {
|
|
5680
|
-
const $xeTable = this
|
|
5975
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5976
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5681
5977
|
|
|
5682
|
-
const { selectCheckboxMaps
|
|
5978
|
+
const { selectCheckboxMaps } = internalData
|
|
5979
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5683
5980
|
const { checkField } = checkboxOpts
|
|
5684
5981
|
const checked = checkField ? !XEUtils.get(row, checkField) : !selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5685
5982
|
$xeTable.handleBatchSelectRows([row], checked, true)
|
|
@@ -5702,9 +5999,7 @@ const Methods = {
|
|
|
5702
5999
|
const internalData = $xeTable as unknown as TableInternalData
|
|
5703
6000
|
|
|
5704
6001
|
const { treeConfig } = props
|
|
5705
|
-
const { selectCheckboxMaps,
|
|
5706
|
-
const selectRowMaps = Object.assign({}, selectCheckboxMaps)
|
|
5707
|
-
const halfRowMaps = Object.assign({}, treeIndeterminateMaps)
|
|
6002
|
+
const { selectCheckboxMaps, treeIndeterminateRowMaps } = internalData
|
|
5708
6003
|
const treeOpts = $xeTable.computeTreeOpts
|
|
5709
6004
|
const { transform, mapChildrenField } = treeOpts
|
|
5710
6005
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
@@ -5716,10 +6011,11 @@ const Methods = {
|
|
|
5716
6011
|
}
|
|
5717
6012
|
// 树结构
|
|
5718
6013
|
if (treeConfig) {
|
|
6014
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
5719
6015
|
const childRowMaps: Record<string, number> = {}
|
|
5720
6016
|
const childRowList: any[][] = []
|
|
5721
6017
|
XEUtils.eachTree(afterTreeFullData, (row: any) => {
|
|
5722
|
-
const rowid =
|
|
6018
|
+
const rowid = handleGetRowId(row)
|
|
5723
6019
|
const childList = row[transform ? mapChildrenField : childrenField]
|
|
5724
6020
|
if (childList && childList.length && !childRowMaps[rowid]) {
|
|
5725
6021
|
childRowMaps[rowid] = 1
|
|
@@ -5736,29 +6032,29 @@ const Methods = {
|
|
|
5736
6032
|
childList.forEach(
|
|
5737
6033
|
checkMethod
|
|
5738
6034
|
? (item) => {
|
|
5739
|
-
const childRowid =
|
|
5740
|
-
const isSelect = checkField ? XEUtils.get(item, checkField) :
|
|
6035
|
+
const childRowid = handleGetRowId(item)
|
|
6036
|
+
const isSelect = checkField ? XEUtils.get(item, checkField) : selectCheckboxMaps[childRowid]
|
|
5741
6037
|
if (checkMethod({ row: item })) {
|
|
5742
6038
|
if (isSelect) {
|
|
5743
6039
|
sLen++
|
|
5744
|
-
} else if (
|
|
6040
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5745
6041
|
hLen++
|
|
5746
6042
|
}
|
|
5747
6043
|
vLen++
|
|
5748
6044
|
} else {
|
|
5749
6045
|
if (isSelect) {
|
|
5750
6046
|
sLen++
|
|
5751
|
-
} else if (
|
|
6047
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5752
6048
|
hLen++
|
|
5753
6049
|
}
|
|
5754
6050
|
}
|
|
5755
6051
|
}
|
|
5756
6052
|
: item => {
|
|
5757
|
-
const childRowid =
|
|
5758
|
-
const isSelect = checkField ? XEUtils.get(item, checkField) :
|
|
6053
|
+
const childRowid = handleGetRowId(item)
|
|
6054
|
+
const isSelect = checkField ? XEUtils.get(item, checkField) : selectCheckboxMaps[childRowid]
|
|
5759
6055
|
if (isSelect) {
|
|
5760
6056
|
sLen++
|
|
5761
|
-
} else if (
|
|
6057
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5762
6058
|
hLen++
|
|
5763
6059
|
}
|
|
5764
6060
|
vLen++
|
|
@@ -5771,29 +6067,28 @@ const Methods = {
|
|
|
5771
6067
|
}
|
|
5772
6068
|
if (isSelected) {
|
|
5773
6069
|
if (!checkField) {
|
|
5774
|
-
|
|
6070
|
+
selectCheckboxMaps[rowid] = row
|
|
5775
6071
|
}
|
|
5776
|
-
if (
|
|
5777
|
-
delete
|
|
6072
|
+
if (treeIndeterminateRowMaps[rowid]) {
|
|
6073
|
+
delete treeIndeterminateRowMaps[rowid]
|
|
5778
6074
|
}
|
|
5779
6075
|
} else {
|
|
5780
6076
|
if (!checkField) {
|
|
5781
|
-
if (
|
|
5782
|
-
delete
|
|
6077
|
+
if (selectCheckboxMaps[rowid]) {
|
|
6078
|
+
delete selectCheckboxMaps[rowid]
|
|
5783
6079
|
}
|
|
5784
6080
|
}
|
|
5785
6081
|
if (halfSelect) {
|
|
5786
|
-
|
|
6082
|
+
treeIndeterminateRowMaps[rowid] = row
|
|
5787
6083
|
} else {
|
|
5788
|
-
if (
|
|
5789
|
-
delete
|
|
6084
|
+
if (treeIndeterminateRowMaps[rowid]) {
|
|
6085
|
+
delete treeIndeterminateRowMaps[rowid]
|
|
5790
6086
|
}
|
|
5791
6087
|
}
|
|
5792
6088
|
}
|
|
5793
6089
|
})
|
|
5794
6090
|
}
|
|
5795
|
-
reactData.
|
|
5796
|
-
reactData.treeIndeterminateMaps = halfRowMaps
|
|
6091
|
+
reactData.updateCheckboxFlag++
|
|
5797
6092
|
},
|
|
5798
6093
|
updateAllCheckboxStatus () {
|
|
5799
6094
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
@@ -5802,10 +6097,10 @@ const Methods = {
|
|
|
5802
6097
|
const internalData = $xeTable as unknown as TableInternalData
|
|
5803
6098
|
|
|
5804
6099
|
const { treeConfig } = props
|
|
5805
|
-
const { selectCheckboxMaps,
|
|
6100
|
+
const { afterFullData, afterTreeFullData, checkboxReserveRowMap, selectCheckboxMaps, treeIndeterminateRowMaps } = internalData
|
|
5806
6101
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5807
6102
|
const { checkField, checkMethod, showReserveStatus } = checkboxOpts
|
|
5808
|
-
const {
|
|
6103
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
5809
6104
|
|
|
5810
6105
|
let sLen = 0 // 已选
|
|
5811
6106
|
let hLen = 0 // 半选
|
|
@@ -5814,29 +6109,29 @@ const Methods = {
|
|
|
5814
6109
|
const rootList: any[] = (treeConfig ? afterTreeFullData : afterFullData)
|
|
5815
6110
|
rootList.forEach(checkMethod
|
|
5816
6111
|
? row => {
|
|
5817
|
-
const childRowid =
|
|
6112
|
+
const childRowid = handleGetRowId(row)
|
|
5818
6113
|
const selected = checkField ? XEUtils.get(row, checkField) : selectCheckboxMaps[childRowid]
|
|
5819
6114
|
if (checkMethod({ row })) {
|
|
5820
6115
|
if (selected) {
|
|
5821
6116
|
sLen++
|
|
5822
|
-
} else if (
|
|
6117
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5823
6118
|
hLen++
|
|
5824
6119
|
}
|
|
5825
6120
|
vLen++
|
|
5826
6121
|
} else {
|
|
5827
6122
|
if (selected) {
|
|
5828
6123
|
sLen++
|
|
5829
|
-
} else if (
|
|
6124
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5830
6125
|
hLen++
|
|
5831
6126
|
}
|
|
5832
6127
|
}
|
|
5833
6128
|
}
|
|
5834
6129
|
: row => {
|
|
5835
|
-
const childRowid =
|
|
6130
|
+
const childRowid = handleGetRowId(row)
|
|
5836
6131
|
const selected = checkField ? XEUtils.get(row, checkField) : selectCheckboxMaps[childRowid]
|
|
5837
6132
|
if (selected) {
|
|
5838
6133
|
sLen++
|
|
5839
|
-
} else if (
|
|
6134
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5840
6135
|
hLen++
|
|
5841
6136
|
}
|
|
5842
6137
|
vLen++
|
|
@@ -5895,18 +6190,26 @@ const Methods = {
|
|
|
5895
6190
|
* 获取复选框保留选中的行
|
|
5896
6191
|
*/
|
|
5897
6192
|
getCheckboxReserveRecords (isFull: any) {
|
|
5898
|
-
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
|
|
5899
6201
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
5900
6202
|
const reserveSelection: any[] = []
|
|
5901
6203
|
if (checkboxOpts.reserve) {
|
|
5902
|
-
const
|
|
6204
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
6205
|
+
const afterFullIdMaps: { [key: string]: number } = {}
|
|
5903
6206
|
if (treeConfig) {
|
|
5904
6207
|
XEUtils.eachTree(afterFullData, row => {
|
|
5905
|
-
afterFullIdMaps[
|
|
6208
|
+
afterFullIdMaps[handleGetRowId(row)] = 1
|
|
5906
6209
|
}, { children: childrenField })
|
|
5907
6210
|
} else {
|
|
5908
6211
|
afterFullData.forEach((row: any) => {
|
|
5909
|
-
afterFullIdMaps[
|
|
6212
|
+
afterFullIdMaps[handleGetRowId(row)] = 1
|
|
5910
6213
|
})
|
|
5911
6214
|
}
|
|
5912
6215
|
XEUtils.each(checkboxReserveRowMap, (oldRow, oldRowid) => {
|
|
@@ -5946,9 +6249,9 @@ const Methods = {
|
|
|
5946
6249
|
handleCheckedAllCheckboxRow($xeTable, value)
|
|
5947
6250
|
if (evnt) {
|
|
5948
6251
|
$xeTable.dispatchEvent('checkbox-all', {
|
|
5949
|
-
records: $xeTable.getCheckboxRecords(),
|
|
5950
|
-
reserves: $xeTable.getCheckboxReserveRecords(),
|
|
5951
|
-
indeterminates: $xeTable.getCheckboxIndeterminateRecords(),
|
|
6252
|
+
records: () => $xeTable.getCheckboxRecords(),
|
|
6253
|
+
reserves: () => $xeTable.getCheckboxReserveRecords(),
|
|
6254
|
+
indeterminates: () => $xeTable.getCheckboxIndeterminateRecords(),
|
|
5952
6255
|
checked: value
|
|
5953
6256
|
}, evnt)
|
|
5954
6257
|
}
|
|
@@ -5981,9 +6284,18 @@ const Methods = {
|
|
|
5981
6284
|
* 清空行为不管是否被禁用还是保留记录,都将彻底清空选中状态
|
|
5982
6285
|
*/
|
|
5983
6286
|
clearCheckboxRow () {
|
|
5984
|
-
const
|
|
5985
|
-
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
|
|
5986
6295
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
6296
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
6297
|
+
const { checkField, reserve } = checkboxOpts
|
|
6298
|
+
// indeterminateField 仅支持读取
|
|
5987
6299
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
5988
6300
|
if (checkField) {
|
|
5989
6301
|
const handleClearChecked = (item: any) => {
|
|
@@ -5999,12 +6311,13 @@ const Methods = {
|
|
|
5999
6311
|
}
|
|
6000
6312
|
}
|
|
6001
6313
|
if (reserve) {
|
|
6002
|
-
tableFullData.forEach((row
|
|
6314
|
+
tableFullData.forEach((row) => this.handleCheckboxReserveRow(row, false))
|
|
6003
6315
|
}
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6316
|
+
reactData.isAllSelected = false
|
|
6317
|
+
reactData.isIndeterminate = false
|
|
6318
|
+
internalData.selectCheckboxMaps = {}
|
|
6319
|
+
internalData.treeIndeterminateRowMaps = {}
|
|
6320
|
+
reactData.updateCheckboxFlag++
|
|
6008
6321
|
return this.$nextTick()
|
|
6009
6322
|
},
|
|
6010
6323
|
/**
|
|
@@ -6211,11 +6524,13 @@ const Methods = {
|
|
|
6211
6524
|
},
|
|
6212
6525
|
triggerHeaderCellClickEvent (evnt: MouseEvent, params: VxeTableDefines.CellRenderHeaderParams) {
|
|
6213
6526
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6527
|
+
const props = $xeTable
|
|
6214
6528
|
const internalData = $xeTable as unknown as TableInternalData
|
|
6215
6529
|
|
|
6216
6530
|
const { _lastResizeTime } = internalData
|
|
6217
6531
|
const sortOpts = $xeTable.computeSortOpts
|
|
6218
6532
|
const columnOpts = $xeTable.computeColumnOpts
|
|
6533
|
+
const currentColumnOpts = $xeTable.computeCurrentColumnOpts
|
|
6219
6534
|
const { column } = params
|
|
6220
6535
|
const cell = evnt.currentTarget
|
|
6221
6536
|
const triggerResizable = _lastResizeTime && _lastResizeTime > Date.now() - 300
|
|
@@ -6225,7 +6540,7 @@ const Methods = {
|
|
|
6225
6540
|
$xeTable.triggerSortEvent(evnt, column, getNextSortOrder($xeTable, column))
|
|
6226
6541
|
}
|
|
6227
6542
|
$xeTable.dispatchEvent('header-cell-click', Object.assign({ triggerResizable, triggerSort, triggerFilter, cell }, params), evnt)
|
|
6228
|
-
if (columnOpts.isCurrent ||
|
|
6543
|
+
if ((columnOpts.isCurrent || props.highlightCurrentColumn) && (!currentColumnOpts.trigger || ['header', 'default'].includes(currentColumnOpts.trigger))) {
|
|
6229
6544
|
$xeTable.triggerCurrentColumnEvent(evnt, params)
|
|
6230
6545
|
}
|
|
6231
6546
|
return $xeTable.$nextTick()
|
|
@@ -6241,13 +6556,24 @@ const Methods = {
|
|
|
6241
6556
|
* @param {ColumnInfo} fieldOrColumn 列配置
|
|
6242
6557
|
*/
|
|
6243
6558
|
setCurrentColumn (fieldOrColumn: any) {
|
|
6244
|
-
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)
|
|
6245
6567
|
if (column) {
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
this.currentColumn = column
|
|
6568
|
+
$xeTable.clearCurrentColumn()
|
|
6569
|
+
reactData.currentColumn = column
|
|
6249
6570
|
}
|
|
6250
|
-
return
|
|
6571
|
+
return $xeTable.$nextTick().then(() => {
|
|
6572
|
+
// 更新状选中态
|
|
6573
|
+
if (isMouseSelected) {
|
|
6574
|
+
$xeTable.addCellSelectedClass()
|
|
6575
|
+
}
|
|
6576
|
+
})
|
|
6251
6577
|
},
|
|
6252
6578
|
/**
|
|
6253
6579
|
* 用于当前列,手动清空当前高亮的状态
|
|
@@ -6256,36 +6582,17 @@ const Methods = {
|
|
|
6256
6582
|
this.currentColumn = null
|
|
6257
6583
|
return this.$nextTick()
|
|
6258
6584
|
},
|
|
6259
|
-
checkValidate (type: any) {
|
|
6260
|
-
if (this.triggerValidate) {
|
|
6261
|
-
return this.triggerValidate(type)
|
|
6262
|
-
}
|
|
6263
|
-
return this.$nextTick()
|
|
6264
|
-
},
|
|
6265
|
-
/**
|
|
6266
|
-
* 当单元格发生改变时
|
|
6267
|
-
* 如果存在规则,则校验
|
|
6268
|
-
*/
|
|
6269
|
-
handleChangeCell (evnt: Event, params: any) {
|
|
6270
|
-
this.checkValidate('blur')
|
|
6271
|
-
.catch((e: any) => e)
|
|
6272
|
-
.then(() => {
|
|
6273
|
-
this.handleEdit(params, evnt)
|
|
6274
|
-
.then(() => this.checkValidate('change'))
|
|
6275
|
-
.catch((e: any) => e)
|
|
6276
|
-
})
|
|
6277
|
-
},
|
|
6278
6585
|
/**
|
|
6279
6586
|
* 列点击事件
|
|
6280
6587
|
* 如果是单击模式,则激活为编辑状态
|
|
6281
6588
|
* 如果是双击模式,则单击后选中状态
|
|
6282
6589
|
*/
|
|
6283
6590
|
triggerCellClickEvent (evnt: MouseEvent, params: VxeTableDefines.CellRenderBodyParams) {
|
|
6284
|
-
const $xeTable = this
|
|
6591
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6285
6592
|
const props = $xeTable
|
|
6286
|
-
const reactData = $xeTable
|
|
6593
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
6287
6594
|
|
|
6288
|
-
const { highlightCurrentRow, editConfig } = props
|
|
6595
|
+
const { highlightCurrentRow, highlightCurrentColumn, editConfig } = props
|
|
6289
6596
|
const { editStore, isDragResize } = reactData
|
|
6290
6597
|
if (isDragResize) {
|
|
6291
6598
|
return
|
|
@@ -6297,6 +6604,8 @@ const Methods = {
|
|
|
6297
6604
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
6298
6605
|
const keyboardOpts = $xeTable.computeKeyboardOpts
|
|
6299
6606
|
const rowOpts = $xeTable.computeRowOpts
|
|
6607
|
+
const columnOpts = $xeTable.computeColumnOpts
|
|
6608
|
+
const currentColumnOpts = $xeTable.computeCurrentColumnOpts
|
|
6300
6609
|
const { actived, focused } = editStore
|
|
6301
6610
|
const { row, column } = params
|
|
6302
6611
|
const { type, treeNode } = column
|
|
@@ -6312,11 +6621,11 @@ const Methods = {
|
|
|
6312
6621
|
if (!triggerCheckbox && !triggerRadio) {
|
|
6313
6622
|
// 如果是展开行
|
|
6314
6623
|
if (!triggerExpandNode && (expandOpts.trigger === 'row' || (isExpandType && expandOpts.trigger === 'cell'))) {
|
|
6315
|
-
|
|
6624
|
+
$xeTable.triggerRowExpandEvent(evnt, params)
|
|
6316
6625
|
}
|
|
6317
6626
|
// 如果是树形表格
|
|
6318
6627
|
if ((treeOpts.trigger === 'row' || (treeNode && treeOpts.trigger === 'cell'))) {
|
|
6319
|
-
|
|
6628
|
+
$xeTable.triggerTreeExpandEvent(evnt, params)
|
|
6320
6629
|
}
|
|
6321
6630
|
}
|
|
6322
6631
|
// 如果点击了树节点
|
|
@@ -6325,16 +6634,22 @@ const Methods = {
|
|
|
6325
6634
|
// 如果是高亮行
|
|
6326
6635
|
if (rowOpts.isCurrent || highlightCurrentRow) {
|
|
6327
6636
|
if (!triggerCheckbox && !triggerRadio) {
|
|
6328
|
-
|
|
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)
|
|
6329
6644
|
}
|
|
6330
6645
|
}
|
|
6331
6646
|
// 如果是单选框
|
|
6332
6647
|
if (!triggerRadio && (radioOpts.trigger === 'row' || (isRadioType && radioOpts.trigger === 'cell'))) {
|
|
6333
|
-
|
|
6648
|
+
$xeTable.triggerRadioRowEvent(evnt, params)
|
|
6334
6649
|
}
|
|
6335
6650
|
// 如果是复选框
|
|
6336
6651
|
if (!triggerCheckbox && (checkboxOpts.trigger === 'row' || (isCheckboxType && checkboxOpts.trigger === 'cell'))) {
|
|
6337
|
-
|
|
6652
|
+
$xeTable.handleToggleCheckRowEvent(evnt, params)
|
|
6338
6653
|
}
|
|
6339
6654
|
}
|
|
6340
6655
|
// 如果设置了单元格选中功能,则不会使用点击事件去处理(只能支持双击模式)
|
|
@@ -6346,14 +6661,14 @@ const Methods = {
|
|
|
6346
6661
|
}
|
|
6347
6662
|
if (editOpts.trigger === 'manual') {
|
|
6348
6663
|
if (actived.args && actived.row === row && column !== actived.column) {
|
|
6349
|
-
|
|
6664
|
+
handleChangeCell($xeTable, evnt, params)
|
|
6350
6665
|
}
|
|
6351
6666
|
} else if (!actived.args || row !== actived.row || column !== actived.column) {
|
|
6352
6667
|
if (editOpts.trigger === 'click') {
|
|
6353
|
-
|
|
6668
|
+
handleChangeCell($xeTable, evnt, params)
|
|
6354
6669
|
} else if (editOpts.trigger === 'dblclick') {
|
|
6355
6670
|
if (editOpts.mode === 'row' && actived.row === row) {
|
|
6356
|
-
|
|
6671
|
+
handleChangeCell($xeTable, evnt, params)
|
|
6357
6672
|
}
|
|
6358
6673
|
}
|
|
6359
6674
|
}
|
|
@@ -6373,7 +6688,7 @@ const Methods = {
|
|
|
6373
6688
|
}
|
|
6374
6689
|
}
|
|
6375
6690
|
}
|
|
6376
|
-
|
|
6691
|
+
$xeTable.dispatchEvent('cell-click', params, evnt)
|
|
6377
6692
|
},
|
|
6378
6693
|
/**
|
|
6379
6694
|
* 列双击点击事件
|
|
@@ -6396,16 +6711,16 @@ const Methods = {
|
|
|
6396
6711
|
if (isEnableConf(editConfig) && editOpts.trigger === 'dblclick') {
|
|
6397
6712
|
if (!actived.args || evnt.currentTarget !== actived.args.cell) {
|
|
6398
6713
|
if (editOpts.mode === 'row') {
|
|
6399
|
-
|
|
6714
|
+
checkValidate($xeTable, 'blur')
|
|
6400
6715
|
.catch((e: any) => e)
|
|
6401
6716
|
.then(() => {
|
|
6402
6717
|
this.handleEdit(params, evnt)
|
|
6403
|
-
.then(() =>
|
|
6718
|
+
.then(() => checkValidate($xeTable, 'change'))
|
|
6404
6719
|
.catch((e: any) => e)
|
|
6405
6720
|
})
|
|
6406
6721
|
} else if (editOpts.mode === 'cell') {
|
|
6407
6722
|
this.handleEdit(params, evnt)
|
|
6408
|
-
.then(() =>
|
|
6723
|
+
.then(() => checkValidate($xeTable, 'change'))
|
|
6409
6724
|
.catch((e: any) => e)
|
|
6410
6725
|
}
|
|
6411
6726
|
}
|
|
@@ -6593,7 +6908,7 @@ const Methods = {
|
|
|
6593
6908
|
evnt.dataTransfer.setDragImage(getTpImg(), 0, 0)
|
|
6594
6909
|
}
|
|
6595
6910
|
},
|
|
6596
|
-
handleRowDragSwapEvent (evnt: DragEvent, isSyncRow: boolean | undefined, dragRow: any, prevDragRow: any, prevDragPos: '' | 'top' | 'bottom' | 'left' | 'right' | undefined, prevDragToChild: boolean | undefined) {
|
|
6911
|
+
handleRowDragSwapEvent (evnt: DragEvent | null, isSyncRow: boolean | undefined, dragRow: any, prevDragRow: any, prevDragPos: '' | 'top' | 'bottom' | 'left' | 'right' | undefined, prevDragToChild: boolean | undefined) {
|
|
6597
6912
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6598
6913
|
const props = $xeTable
|
|
6599
6914
|
const reactData = $xeTable as unknown as TableReactData
|
|
@@ -6601,14 +6916,16 @@ const Methods = {
|
|
|
6601
6916
|
|
|
6602
6917
|
const { treeConfig, dragConfig } = props
|
|
6603
6918
|
const rowDragOpts = $xeTable.computeRowDragOpts
|
|
6604
|
-
const { fullAllDataRowIdData } = internalData
|
|
6919
|
+
const { afterFullData, tableFullData, fullAllDataRowIdData } = internalData
|
|
6605
6920
|
const { isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod, dragToChildMethod } = rowDragOpts
|
|
6606
6921
|
const treeOpts = $xeTable.computeTreeOpts
|
|
6607
6922
|
const { transform, rowField, mapChildrenField, parentField } = treeOpts
|
|
6608
6923
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
6609
|
-
const { afterFullData, tableFullData } = internalData
|
|
6610
6924
|
const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null)
|
|
6611
6925
|
const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
|
|
6926
|
+
const errRest = {
|
|
6927
|
+
status: false
|
|
6928
|
+
}
|
|
6612
6929
|
if (prevDragRow && dragRow) {
|
|
6613
6930
|
// 判断是否有拖动
|
|
6614
6931
|
if (prevDragRow !== dragRow) {
|
|
@@ -6623,7 +6940,7 @@ const Methods = {
|
|
|
6623
6940
|
const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
|
|
6624
6941
|
return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then((status) => {
|
|
6625
6942
|
if (!status) {
|
|
6626
|
-
return
|
|
6943
|
+
return errRest
|
|
6627
6944
|
}
|
|
6628
6945
|
|
|
6629
6946
|
let oafIndex = -1
|
|
@@ -6654,11 +6971,11 @@ const Methods = {
|
|
|
6654
6971
|
if (isPeerDrag && !isCrossDrag) {
|
|
6655
6972
|
if (oldRest.row[parentField] !== newRest.row[parentField]) {
|
|
6656
6973
|
// 非同级
|
|
6657
|
-
return
|
|
6974
|
+
return errRest
|
|
6658
6975
|
}
|
|
6659
6976
|
} else {
|
|
6660
6977
|
if (!isCrossDrag) {
|
|
6661
|
-
return
|
|
6978
|
+
return errRest
|
|
6662
6979
|
}
|
|
6663
6980
|
if (oldAllMaps[newRowid]) {
|
|
6664
6981
|
isSelfToChildStatus = true
|
|
@@ -6669,7 +6986,7 @@ const Methods = {
|
|
|
6669
6986
|
content: getI18n('vxe.error.treeDragChild')
|
|
6670
6987
|
})
|
|
6671
6988
|
}
|
|
6672
|
-
return
|
|
6989
|
+
return errRest
|
|
6673
6990
|
}
|
|
6674
6991
|
}
|
|
6675
6992
|
}
|
|
@@ -6677,13 +6994,13 @@ const Methods = {
|
|
|
6677
6994
|
// 子到根
|
|
6678
6995
|
|
|
6679
6996
|
if (!isCrossDrag) {
|
|
6680
|
-
return
|
|
6997
|
+
return errRest
|
|
6681
6998
|
}
|
|
6682
6999
|
} else if (newLevel) {
|
|
6683
7000
|
// 根到子
|
|
6684
7001
|
|
|
6685
7002
|
if (!isCrossDrag) {
|
|
6686
|
-
return
|
|
7003
|
+
return errRest
|
|
6687
7004
|
}
|
|
6688
7005
|
if (oldAllMaps[newRowid]) {
|
|
6689
7006
|
isSelfToChildStatus = true
|
|
@@ -6694,7 +7011,7 @@ const Methods = {
|
|
|
6694
7011
|
content: getI18n('vxe.error.treeDragChild')
|
|
6695
7012
|
})
|
|
6696
7013
|
}
|
|
6697
|
-
return
|
|
7014
|
+
return errRest
|
|
6698
7015
|
}
|
|
6699
7016
|
}
|
|
6700
7017
|
} else {
|
|
@@ -6758,28 +7075,36 @@ const Methods = {
|
|
|
6758
7075
|
if (reactData.scrollYLoad) {
|
|
6759
7076
|
$xeTable.updateScrollYSpace()
|
|
6760
7077
|
}
|
|
6761
|
-
|
|
7078
|
+
|
|
7079
|
+
if (evnt) {
|
|
7080
|
+
$xeTable.dispatchEvent('row-dragend', {
|
|
7081
|
+
oldRow: dragRow,
|
|
7082
|
+
newRow: prevDragRow,
|
|
7083
|
+
dragRow,
|
|
7084
|
+
dragPos: prevDragPos as any,
|
|
7085
|
+
dragToChild: isDragToChildFlag,
|
|
7086
|
+
offsetIndex: dragOffsetIndex,
|
|
7087
|
+
_index: {
|
|
7088
|
+
newIndex: nafIndex,
|
|
7089
|
+
oldIndex: oafIndex
|
|
7090
|
+
}
|
|
7091
|
+
}, evnt)
|
|
7092
|
+
}
|
|
7093
|
+
|
|
7094
|
+
return $xeTable.$nextTick().then(() => {
|
|
6762
7095
|
$xeTable.updateCellAreas()
|
|
6763
7096
|
$xeTable.recalculate()
|
|
6764
|
-
})
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
oldRow: dragRow,
|
|
6768
|
-
newRow: prevDragRow,
|
|
6769
|
-
dragRow,
|
|
6770
|
-
dragPos: prevDragPos as any,
|
|
6771
|
-
dragToChild: isDragToChildFlag,
|
|
6772
|
-
offsetIndex: dragOffsetIndex,
|
|
6773
|
-
_index: {
|
|
6774
|
-
newIndex: nafIndex,
|
|
6775
|
-
oldIndex: oafIndex
|
|
7097
|
+
}).then(() => {
|
|
7098
|
+
return {
|
|
7099
|
+
status: true
|
|
6776
7100
|
}
|
|
6777
|
-
}
|
|
7101
|
+
})
|
|
6778
7102
|
}).catch(() => {
|
|
7103
|
+
return errRest
|
|
6779
7104
|
})
|
|
6780
7105
|
}
|
|
6781
7106
|
}
|
|
6782
|
-
return Promise.resolve()
|
|
7107
|
+
return Promise.resolve(errRest)
|
|
6783
7108
|
},
|
|
6784
7109
|
handleRowDragDragendEvent (evnt: DragEvent) {
|
|
6785
7110
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
@@ -6918,7 +7243,7 @@ const Methods = {
|
|
|
6918
7243
|
$xeTable.saveCustomStore('update:sort')
|
|
6919
7244
|
})
|
|
6920
7245
|
},
|
|
6921
|
-
handleColDragSwapEvent (evnt: DragEvent, isSyncColumn: boolean | undefined, dragCol: VxeTableDefines.ColumnInfo | null | undefined, prevDragCol: VxeTableDefines.ColumnInfo | undefined, prevDragPos: '' | 'top' | 'bottom' | 'left' | 'right' | undefined, prevDragToChild: boolean | undefined) {
|
|
7246
|
+
handleColDragSwapEvent (evnt: DragEvent | null, isSyncColumn: boolean | undefined, dragCol: VxeTableDefines.ColumnInfo | null | undefined, prevDragCol: VxeTableDefines.ColumnInfo | undefined, prevDragPos: '' | 'top' | 'bottom' | 'left' | 'right' | undefined, prevDragToChild: boolean | undefined) {
|
|
6922
7247
|
const $xeTable = this
|
|
6923
7248
|
const props = $xeTable
|
|
6924
7249
|
const reactData = $xeTable
|
|
@@ -6929,6 +7254,9 @@ const Methods = {
|
|
|
6929
7254
|
const { isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts
|
|
6930
7255
|
const { collectColumn } = internalData
|
|
6931
7256
|
const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0
|
|
7257
|
+
const errRest = {
|
|
7258
|
+
status: false
|
|
7259
|
+
}
|
|
6932
7260
|
if (prevDragCol && dragCol) {
|
|
6933
7261
|
// 判断是否有拖动
|
|
6934
7262
|
if (prevDragCol !== dragCol) {
|
|
@@ -6945,7 +7273,7 @@ const Methods = {
|
|
|
6945
7273
|
const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
|
|
6946
7274
|
return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
|
|
6947
7275
|
if (!status) {
|
|
6948
|
-
return
|
|
7276
|
+
return errRest
|
|
6949
7277
|
}
|
|
6950
7278
|
|
|
6951
7279
|
let oafIndex = -1
|
|
@@ -6964,11 +7292,11 @@ const Methods = {
|
|
|
6964
7292
|
if (isPeerDrag && !isCrossDrag) {
|
|
6965
7293
|
if (dragColumn.parentId !== newColumn.parentId) {
|
|
6966
7294
|
// 非同级
|
|
6967
|
-
return
|
|
7295
|
+
return errRest
|
|
6968
7296
|
}
|
|
6969
7297
|
} else {
|
|
6970
7298
|
if (!isCrossDrag) {
|
|
6971
|
-
return
|
|
7299
|
+
return errRest
|
|
6972
7300
|
}
|
|
6973
7301
|
|
|
6974
7302
|
if (oldAllMaps[newColumn.id]) {
|
|
@@ -6980,7 +7308,7 @@ const Methods = {
|
|
|
6980
7308
|
content: getI18n('vxe.error.treeDragChild')
|
|
6981
7309
|
})
|
|
6982
7310
|
}
|
|
6983
|
-
return
|
|
7311
|
+
return errRest
|
|
6984
7312
|
}
|
|
6985
7313
|
}
|
|
6986
7314
|
}
|
|
@@ -6988,13 +7316,13 @@ const Methods = {
|
|
|
6988
7316
|
// 子到根
|
|
6989
7317
|
|
|
6990
7318
|
if (!isCrossDrag) {
|
|
6991
|
-
return
|
|
7319
|
+
return errRest
|
|
6992
7320
|
}
|
|
6993
7321
|
} else if (newColumn.parentId) {
|
|
6994
7322
|
// 根到子
|
|
6995
7323
|
|
|
6996
7324
|
if (!isCrossDrag) {
|
|
6997
|
-
return
|
|
7325
|
+
return errRest
|
|
6998
7326
|
}
|
|
6999
7327
|
if (oldAllMaps[newColumn.id]) {
|
|
7000
7328
|
isSelfToChildStatus = true
|
|
@@ -7005,7 +7333,7 @@ const Methods = {
|
|
|
7005
7333
|
content: getI18n('vxe.error.treeDragChild')
|
|
7006
7334
|
})
|
|
7007
7335
|
}
|
|
7008
|
-
return
|
|
7336
|
+
return errRest
|
|
7009
7337
|
}
|
|
7010
7338
|
}
|
|
7011
7339
|
} else {
|
|
@@ -7069,27 +7397,34 @@ const Methods = {
|
|
|
7069
7397
|
}
|
|
7070
7398
|
}
|
|
7071
7399
|
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7400
|
+
if (evnt) {
|
|
7401
|
+
$xeTable.dispatchEvent('column-dragend', {
|
|
7402
|
+
oldColumn: dragColumn,
|
|
7403
|
+
newColumn,
|
|
7404
|
+
dragColumn,
|
|
7405
|
+
dragPos: prevDragPos,
|
|
7406
|
+
dragToChild: isDragToChildFlag,
|
|
7407
|
+
offsetIndex: dragOffsetIndex,
|
|
7408
|
+
_index: {
|
|
7409
|
+
newIndex: nafIndex,
|
|
7410
|
+
oldIndex: oafIndex
|
|
7411
|
+
}
|
|
7412
|
+
}, evnt)
|
|
7413
|
+
}
|
|
7084
7414
|
|
|
7085
7415
|
if (isSyncColumn) {
|
|
7086
7416
|
$xeTable.handleColDragSwapColumn()
|
|
7087
7417
|
}
|
|
7418
|
+
|
|
7419
|
+
return {
|
|
7420
|
+
status: true
|
|
7421
|
+
}
|
|
7088
7422
|
}).catch(() => {
|
|
7423
|
+
return errRest
|
|
7089
7424
|
})
|
|
7090
7425
|
}
|
|
7091
7426
|
}
|
|
7092
|
-
return Promise.resolve()
|
|
7427
|
+
return Promise.resolve(errRest)
|
|
7093
7428
|
},
|
|
7094
7429
|
handleHeaderCellDragDragendEvent (evnt: DragEvent) {
|
|
7095
7430
|
const $xeTable = this
|
|
@@ -7181,8 +7516,8 @@ const Methods = {
|
|
|
7181
7516
|
}
|
|
7182
7517
|
},
|
|
7183
7518
|
handleHeaderCellDragMousedownEvent (evnt: MouseEvent, params: any) {
|
|
7184
|
-
const $xeTable = this
|
|
7185
|
-
const reactData = $xeTable
|
|
7519
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7520
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7186
7521
|
|
|
7187
7522
|
evnt.stopPropagation()
|
|
7188
7523
|
const columnDragOpts = $xeTable.computeColumnDragOpts
|
|
@@ -7207,8 +7542,8 @@ const Methods = {
|
|
|
7207
7542
|
$xeTable.dispatchEvent('column-dragstart', params, evnt)
|
|
7208
7543
|
},
|
|
7209
7544
|
handleHeaderCellDragMouseupEvent () {
|
|
7210
|
-
const $xeTable = this
|
|
7211
|
-
const reactData = $xeTable
|
|
7545
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7546
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7212
7547
|
|
|
7213
7548
|
clearColDropOrigin($xeTable)
|
|
7214
7549
|
hideDropTip($xeTable)
|
|
@@ -7217,54 +7552,58 @@ const Methods = {
|
|
|
7217
7552
|
reactData.isDragColMove = false
|
|
7218
7553
|
},
|
|
7219
7554
|
setPendingRow (rows: any, status: any) {
|
|
7220
|
-
const $xeTable = this
|
|
7221
|
-
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
|
|
7222
7558
|
|
|
7223
|
-
const
|
|
7559
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
7560
|
+
const { pendingRowMaps } = internalData
|
|
7224
7561
|
if (rows && !XEUtils.isArray(rows)) {
|
|
7225
7562
|
rows = [rows]
|
|
7226
7563
|
}
|
|
7227
7564
|
if (status) {
|
|
7228
7565
|
rows.forEach((row: any) => {
|
|
7229
|
-
const rowid =
|
|
7230
|
-
if (rowid && !
|
|
7231
|
-
|
|
7566
|
+
const rowid = handleGetRowId(row)
|
|
7567
|
+
if (rowid && !pendingRowMaps[rowid]) {
|
|
7568
|
+
pendingRowMaps[rowid] = row
|
|
7232
7569
|
}
|
|
7233
7570
|
})
|
|
7234
7571
|
} else {
|
|
7235
7572
|
rows.forEach((row: any) => {
|
|
7236
|
-
const rowid =
|
|
7237
|
-
if (rowid &&
|
|
7238
|
-
delete
|
|
7573
|
+
const rowid = handleGetRowId(row)
|
|
7574
|
+
if (rowid && pendingRowMaps[rowid]) {
|
|
7575
|
+
delete pendingRowMaps[rowid]
|
|
7239
7576
|
}
|
|
7240
7577
|
})
|
|
7241
7578
|
}
|
|
7242
|
-
reactData.
|
|
7579
|
+
reactData.pendingRowFlag++
|
|
7243
7580
|
return $xeTable.$nextTick()
|
|
7244
7581
|
},
|
|
7245
7582
|
togglePendingRow (rows: any) {
|
|
7246
|
-
const $xeTable = this
|
|
7247
|
-
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
|
|
7248
7586
|
|
|
7249
|
-
const
|
|
7587
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
7588
|
+
const { pendingRowMaps } = internalData
|
|
7250
7589
|
if (rows && !XEUtils.isArray(rows)) {
|
|
7251
7590
|
rows = [rows]
|
|
7252
7591
|
}
|
|
7253
7592
|
rows.forEach((row: any) => {
|
|
7254
|
-
const rowid =
|
|
7593
|
+
const rowid = handleGetRowId(row)
|
|
7255
7594
|
if (rowid) {
|
|
7256
|
-
if (
|
|
7257
|
-
delete
|
|
7595
|
+
if (pendingRowMaps[rowid]) {
|
|
7596
|
+
delete pendingRowMaps[rowid]
|
|
7258
7597
|
} else {
|
|
7259
|
-
|
|
7598
|
+
pendingRowMaps[rowid] = row
|
|
7260
7599
|
}
|
|
7261
7600
|
}
|
|
7262
7601
|
})
|
|
7263
|
-
reactData.
|
|
7602
|
+
reactData.pendingRowFlag++
|
|
7264
7603
|
return $xeTable.$nextTick()
|
|
7265
7604
|
},
|
|
7266
7605
|
hasPendingByRow (row: any) {
|
|
7267
|
-
const $xeTable = this
|
|
7606
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7268
7607
|
|
|
7269
7608
|
return $xeTable.isPendingByRow(row)
|
|
7270
7609
|
},
|
|
@@ -7277,12 +7616,10 @@ const Methods = {
|
|
|
7277
7616
|
return !!pendingRowMaps[rowid]
|
|
7278
7617
|
},
|
|
7279
7618
|
getPendingRecords () {
|
|
7280
|
-
const $xeTable = this
|
|
7281
|
-
const
|
|
7282
|
-
const internalData = $xeTable
|
|
7619
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7620
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7283
7621
|
|
|
7284
|
-
const { pendingRowMaps } =
|
|
7285
|
-
const { fullAllDataRowIdData } = internalData
|
|
7622
|
+
const { fullAllDataRowIdData, pendingRowMaps } = internalData
|
|
7286
7623
|
const insertRecords: any[] = []
|
|
7287
7624
|
XEUtils.each(pendingRowMaps, (row, rowid) => {
|
|
7288
7625
|
if (fullAllDataRowIdData[rowid]) {
|
|
@@ -7292,11 +7629,16 @@ const Methods = {
|
|
|
7292
7629
|
return insertRecords
|
|
7293
7630
|
},
|
|
7294
7631
|
clearPendingRow () {
|
|
7295
|
-
|
|
7296
|
-
|
|
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()
|
|
7297
7639
|
},
|
|
7298
7640
|
sort (sortConfs: any, sortOrder: any) {
|
|
7299
|
-
const $xeTable = this
|
|
7641
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7300
7642
|
|
|
7301
7643
|
const { sortOpts } = this
|
|
7302
7644
|
const { multiple, remote, orders } = sortOpts
|
|
@@ -7446,7 +7788,10 @@ const Methods = {
|
|
|
7446
7788
|
* @param {Event} evnt 事件
|
|
7447
7789
|
*/
|
|
7448
7790
|
closeFilter () {
|
|
7449
|
-
const
|
|
7791
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7792
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7793
|
+
|
|
7794
|
+
const { filterStore } = reactData
|
|
7450
7795
|
const { column, visible } = filterStore
|
|
7451
7796
|
Object.assign(filterStore, {
|
|
7452
7797
|
isAllSelected: false,
|
|
@@ -7455,9 +7800,15 @@ const Methods = {
|
|
|
7455
7800
|
visible: false
|
|
7456
7801
|
})
|
|
7457
7802
|
if (visible) {
|
|
7458
|
-
|
|
7803
|
+
$xeTable.dispatchEvent('filter-visible', {
|
|
7804
|
+
column,
|
|
7805
|
+
field: column.field,
|
|
7806
|
+
property: column.field,
|
|
7807
|
+
filterList: () => $xeTable.getCheckedFilters(),
|
|
7808
|
+
visible: false
|
|
7809
|
+
}, null)
|
|
7459
7810
|
}
|
|
7460
|
-
return
|
|
7811
|
+
return $xeTable.$nextTick()
|
|
7461
7812
|
},
|
|
7462
7813
|
/**
|
|
7463
7814
|
* 判断指定列是否为筛选状态,如果为空则判断所有列
|
|
@@ -7490,17 +7841,16 @@ const Methods = {
|
|
|
7490
7841
|
const reactData = $xeTable as unknown as TableReactData
|
|
7491
7842
|
const internalData = $xeTable as unknown as TableInternalData
|
|
7492
7843
|
|
|
7493
|
-
const
|
|
7494
|
-
const { fullAllDataRowIdData } = internalData
|
|
7844
|
+
const { fullAllDataRowIdData, rowExpandLazyLoadedMaps } = internalData
|
|
7495
7845
|
const expandOpts = $xeTable.computeExpandOpts
|
|
7496
7846
|
const { lazy } = expandOpts
|
|
7497
7847
|
const rowid = getRowid($xeTable, row)
|
|
7498
7848
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
7499
7849
|
if (lazy && rowRest) {
|
|
7500
7850
|
rowRest.expandLoaded = false
|
|
7501
|
-
delete
|
|
7851
|
+
delete rowExpandLazyLoadedMaps[rowid]
|
|
7502
7852
|
}
|
|
7503
|
-
reactData.
|
|
7853
|
+
reactData.rowExpandedFlag++
|
|
7504
7854
|
return $xeTable.$nextTick()
|
|
7505
7855
|
},
|
|
7506
7856
|
/**
|
|
@@ -7508,14 +7858,18 @@ const Methods = {
|
|
|
7508
7858
|
* @param {Row} row 行对象
|
|
7509
7859
|
*/
|
|
7510
7860
|
reloadRowExpand (row: any) {
|
|
7511
|
-
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
|
|
7512
7866
|
const { lazy } = expandOpts
|
|
7513
7867
|
const rowid = getRowid(this, row)
|
|
7514
7868
|
if (lazy && !rowExpandLazyLoadedMaps[rowid]) {
|
|
7515
|
-
|
|
7516
|
-
.then(() =>
|
|
7869
|
+
$xeTable.clearRowExpandLoaded(row)
|
|
7870
|
+
.then(() => handleAsyncRowExpand($xeTable, row))
|
|
7517
7871
|
}
|
|
7518
|
-
return
|
|
7872
|
+
return $xeTable.$nextTick()
|
|
7519
7873
|
},
|
|
7520
7874
|
reloadExpandContent (row: any) {
|
|
7521
7875
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -7528,20 +7882,34 @@ const Methods = {
|
|
|
7528
7882
|
* 展开行事件
|
|
7529
7883
|
*/
|
|
7530
7884
|
triggerRowExpandEvent (evnt: any, params: any) {
|
|
7531
|
-
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
|
|
7532
7892
|
const { row } = params
|
|
7533
7893
|
const { lazy, trigger } = expandOpts
|
|
7534
7894
|
if (trigger === 'manual') {
|
|
7535
7895
|
return
|
|
7536
7896
|
}
|
|
7537
7897
|
evnt.stopPropagation()
|
|
7538
|
-
const rowid = getRowid(
|
|
7898
|
+
const rowid = getRowid($xeTable, row)
|
|
7539
7899
|
if (!lazy || !rowExpandLazyLoadedMaps[rowid]) {
|
|
7540
|
-
const expanded =
|
|
7541
|
-
const columnIndex =
|
|
7542
|
-
const $columnIndex =
|
|
7543
|
-
|
|
7544
|
-
|
|
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)
|
|
7545
7913
|
}
|
|
7546
7914
|
},
|
|
7547
7915
|
/**
|
|
@@ -7585,48 +7953,6 @@ const Methods = {
|
|
|
7585
7953
|
}
|
|
7586
7954
|
return this.setRowExpand(expandedRows, expanded)
|
|
7587
7955
|
},
|
|
7588
|
-
handleAsyncRowExpand (row: any) {
|
|
7589
|
-
const $xeTable = this
|
|
7590
|
-
const reactData = $xeTable as TableReactData
|
|
7591
|
-
const internalData = $xeTable as TableInternalData
|
|
7592
|
-
|
|
7593
|
-
return new Promise<void>(resolve => {
|
|
7594
|
-
const { expandOpts } = this
|
|
7595
|
-
const { loadMethod } = expandOpts
|
|
7596
|
-
if (loadMethod) {
|
|
7597
|
-
const { fullAllDataRowIdData } = internalData
|
|
7598
|
-
const rExpandLazyLoadedMaps = { ...reactData.rowExpandLazyLoadedMaps }
|
|
7599
|
-
const rowid = getRowid($xeTable, row)
|
|
7600
|
-
const rowRest = fullAllDataRowIdData[rowid]
|
|
7601
|
-
rExpandLazyLoadedMaps[rowid] = row
|
|
7602
|
-
reactData.rowExpandLazyLoadedMaps = rExpandLazyLoadedMaps
|
|
7603
|
-
loadMethod({ $table: $xeTable, row, rowIndex: $xeTable.getRowIndex(row), $rowIndex: $xeTable.getVMRowIndex(row) }).then(() => {
|
|
7604
|
-
const rExpandedMaps = { ...reactData.rowExpandedMaps }
|
|
7605
|
-
if (rowRest) {
|
|
7606
|
-
rowRest.expandLoaded = true
|
|
7607
|
-
}
|
|
7608
|
-
rExpandedMaps[rowid] = row
|
|
7609
|
-
reactData.rowExpandedMaps = rExpandedMaps
|
|
7610
|
-
}).catch(() => {
|
|
7611
|
-
if (rowRest) {
|
|
7612
|
-
rowRest.expandLoaded = false
|
|
7613
|
-
}
|
|
7614
|
-
}).finally(() => {
|
|
7615
|
-
const rExpandLazyLoadedMaps = { ...reactData.rowExpandLazyLoadedMaps }
|
|
7616
|
-
if (rExpandLazyLoadedMaps[rowid]) {
|
|
7617
|
-
delete rExpandLazyLoadedMaps[rowid]
|
|
7618
|
-
}
|
|
7619
|
-
reactData.rowExpandLazyLoadedMaps = rExpandLazyLoadedMaps
|
|
7620
|
-
$xeTable.$nextTick()
|
|
7621
|
-
.then(() => $xeTable.recalculate())
|
|
7622
|
-
.then(() => $xeTable.updateCellAreas())
|
|
7623
|
-
.then(() => resolve())
|
|
7624
|
-
})
|
|
7625
|
-
} else {
|
|
7626
|
-
resolve()
|
|
7627
|
-
}
|
|
7628
|
-
})
|
|
7629
|
-
},
|
|
7630
7956
|
/**
|
|
7631
7957
|
* 设置展开行,二个参数设置这一行展开与否
|
|
7632
7958
|
* 支持单行
|
|
@@ -7635,10 +7961,14 @@ const Methods = {
|
|
|
7635
7961
|
* @param {Boolean} expanded 是否展开
|
|
7636
7962
|
*/
|
|
7637
7963
|
setRowExpand (rows: any, expanded: any) {
|
|
7638
|
-
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
|
|
7639
7967
|
|
|
7640
|
-
const {
|
|
7641
|
-
let
|
|
7968
|
+
const { expandColumn } = reactData
|
|
7969
|
+
let { fullAllDataRowIdData, rowExpandedMaps, rowExpandLazyLoadedMaps } = internalData
|
|
7970
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
7971
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
7642
7972
|
const { reserve, lazy, accordion, toggleMethod } = expandOpts
|
|
7643
7973
|
const lazyRests: any[] = []
|
|
7644
7974
|
const columnIndex = $xeTable.getColumnIndex(expandColumn)
|
|
@@ -7649,28 +7979,29 @@ const Methods = {
|
|
|
7649
7979
|
}
|
|
7650
7980
|
if (accordion) {
|
|
7651
7981
|
// 只能同时展开一个
|
|
7652
|
-
|
|
7982
|
+
rowExpandedMaps = {}
|
|
7983
|
+
internalData.rowExpandedMaps = rowExpandedMaps
|
|
7653
7984
|
rows = rows.slice(rows.length - 1, rows.length)
|
|
7654
7985
|
}
|
|
7655
|
-
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
|
|
7656
7987
|
if (expanded) {
|
|
7657
7988
|
validRows.forEach((row: any) => {
|
|
7658
|
-
const rowid =
|
|
7659
|
-
if (!
|
|
7989
|
+
const rowid = handleGetRowId(row)
|
|
7990
|
+
if (!rowExpandedMaps[rowid]) {
|
|
7660
7991
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
7661
7992
|
const isLoad = lazy && !rowRest.expandLoaded && !rowExpandLazyLoadedMaps[rowid]
|
|
7662
7993
|
if (isLoad) {
|
|
7663
|
-
lazyRests.push(
|
|
7994
|
+
lazyRests.push(handleAsyncRowExpand($xeTable, row))
|
|
7664
7995
|
} else {
|
|
7665
|
-
|
|
7996
|
+
rowExpandedMaps[rowid] = row
|
|
7666
7997
|
}
|
|
7667
7998
|
}
|
|
7668
7999
|
})
|
|
7669
8000
|
} else {
|
|
7670
8001
|
validRows.forEach((item) => {
|
|
7671
|
-
const rowid =
|
|
7672
|
-
if (
|
|
7673
|
-
delete
|
|
8002
|
+
const rowid = handleGetRowId(item)
|
|
8003
|
+
if (rowExpandedMaps[rowid]) {
|
|
8004
|
+
delete rowExpandedMaps[rowid]
|
|
7674
8005
|
}
|
|
7675
8006
|
})
|
|
7676
8007
|
}
|
|
@@ -7678,7 +8009,7 @@ const Methods = {
|
|
|
7678
8009
|
validRows.forEach((row) => handleRowExpandReserve($xeTable, row, expanded))
|
|
7679
8010
|
}
|
|
7680
8011
|
}
|
|
7681
|
-
|
|
8012
|
+
reactData.rowExpandedFlag++
|
|
7682
8013
|
return Promise.all(lazyRests)
|
|
7683
8014
|
.then(() => $xeTable.$nextTick())
|
|
7684
8015
|
.then(() => $xeTable.recalculate(true))
|
|
@@ -7694,9 +8025,14 @@ const Methods = {
|
|
|
7694
8025
|
* @param {Row} row 行对象
|
|
7695
8026
|
*/
|
|
7696
8027
|
isRowExpandByRow (row: any) {
|
|
7697
|
-
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
|
|
7698
8034
|
const rowid = getRowid(this, row)
|
|
7699
|
-
return !!rowExpandedMaps[rowid]
|
|
8035
|
+
return !!rowExpandedFlag && !!rowExpandedMaps[rowid]
|
|
7700
8036
|
},
|
|
7701
8037
|
isExpandByRow (row: any) {
|
|
7702
8038
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -7717,7 +8053,8 @@ const Methods = {
|
|
|
7717
8053
|
const expandOpts = $xeTable.computeExpandOpts
|
|
7718
8054
|
const { reserve } = expandOpts
|
|
7719
8055
|
const expList = $xeTable.getRowExpandRecords()
|
|
7720
|
-
|
|
8056
|
+
internalData.rowExpandedMaps = {}
|
|
8057
|
+
reactData.rowExpandedFlag++
|
|
7721
8058
|
if (reserve) {
|
|
7722
8059
|
tableFullData.forEach((row) => handleRowExpandReserve($xeTable, row, false))
|
|
7723
8060
|
}
|
|
@@ -7737,8 +8074,11 @@ const Methods = {
|
|
|
7737
8074
|
return this.$nextTick()
|
|
7738
8075
|
},
|
|
7739
8076
|
getRowExpandRecords () {
|
|
8077
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8078
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8079
|
+
|
|
7740
8080
|
const rest: any[] = []
|
|
7741
|
-
XEUtils.each(
|
|
8081
|
+
XEUtils.each(internalData.rowExpandedMaps, item => {
|
|
7742
8082
|
if (item) {
|
|
7743
8083
|
rest.push(item)
|
|
7744
8084
|
}
|
|
@@ -7746,8 +8086,11 @@ const Methods = {
|
|
|
7746
8086
|
return rest
|
|
7747
8087
|
},
|
|
7748
8088
|
getTreeExpandRecords () {
|
|
8089
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8090
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8091
|
+
|
|
7749
8092
|
const rest: any[] = []
|
|
7750
|
-
XEUtils.each(
|
|
8093
|
+
XEUtils.each(internalData.treeExpandedMaps, item => {
|
|
7751
8094
|
if (item) {
|
|
7752
8095
|
rest.push(item)
|
|
7753
8096
|
}
|
|
@@ -7782,12 +8125,10 @@ const Methods = {
|
|
|
7782
8125
|
const reactData = $xeTable as unknown as TableReactData
|
|
7783
8126
|
const internalData = $xeTable as unknown as TableInternalData
|
|
7784
8127
|
|
|
7785
|
-
const { fullAllDataRowIdData } = internalData
|
|
8128
|
+
const { fullAllDataRowIdData, treeExpandedMaps } = internalData
|
|
7786
8129
|
const treeOpts = $xeTable.computeTreeOpts
|
|
7787
8130
|
const { transform } = treeOpts
|
|
7788
|
-
let tExpandedMaps: Record<string, any> = {}
|
|
7789
8131
|
if (rows) {
|
|
7790
|
-
tExpandedMaps = { ...reactData.treeExpandedMaps }
|
|
7791
8132
|
if (!XEUtils.isArray(rows)) {
|
|
7792
8133
|
rows = [rows]
|
|
7793
8134
|
}
|
|
@@ -7796,8 +8137,8 @@ const Methods = {
|
|
|
7796
8137
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
7797
8138
|
if (rowRest) {
|
|
7798
8139
|
rowRest.treeLoaded = false
|
|
7799
|
-
if (
|
|
7800
|
-
delete
|
|
8140
|
+
if (treeExpandedMaps[rowid]) {
|
|
8141
|
+
delete treeExpandedMaps[rowid]
|
|
7801
8142
|
}
|
|
7802
8143
|
}
|
|
7803
8144
|
})
|
|
@@ -7806,7 +8147,8 @@ const Methods = {
|
|
|
7806
8147
|
rowRest.treeLoaded = false
|
|
7807
8148
|
})
|
|
7808
8149
|
}
|
|
7809
|
-
|
|
8150
|
+
internalData.treeExpandedMaps = {}
|
|
8151
|
+
reactData.treeExpandedFlag++
|
|
7810
8152
|
if (transform) {
|
|
7811
8153
|
handleVirtualTreeToList($xeTable)
|
|
7812
8154
|
return $xeTable.handleTableData()
|
|
@@ -7819,37 +8161,45 @@ const Methods = {
|
|
|
7819
8161
|
*/
|
|
7820
8162
|
reloadTreeExpand (row: any) {
|
|
7821
8163
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8164
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7822
8165
|
|
|
7823
|
-
const {
|
|
8166
|
+
const { treeExpandLazyLoadedMaps } = internalData
|
|
8167
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
7824
8168
|
const { transform, lazy } = treeOpts
|
|
7825
8169
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
7826
|
-
const rowid = getRowid(
|
|
8170
|
+
const rowid = getRowid($xeTable, row)
|
|
7827
8171
|
if (lazy && row[hasChildField] && !treeExpandLazyLoadedMaps[rowid]) {
|
|
7828
|
-
return
|
|
7829
|
-
return
|
|
8172
|
+
return $xeTable.clearTreeExpandLoaded(row).then(() => {
|
|
8173
|
+
return handleAsyncTreeExpandChilds($xeTable, row)
|
|
7830
8174
|
}).then(() => {
|
|
7831
8175
|
if (transform) {
|
|
7832
8176
|
handleVirtualTreeToList($xeTable)
|
|
7833
|
-
return
|
|
8177
|
+
return $xeTable.handleTableData()
|
|
7834
8178
|
}
|
|
7835
8179
|
}).then(() => {
|
|
7836
|
-
return
|
|
8180
|
+
return $xeTable.recalculate()
|
|
7837
8181
|
})
|
|
7838
8182
|
}
|
|
7839
|
-
return
|
|
8183
|
+
return $xeTable.$nextTick()
|
|
7840
8184
|
},
|
|
7841
8185
|
reloadTreeChilds (row: any) {
|
|
8186
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8187
|
+
|
|
7842
8188
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
7843
8189
|
warnLog('vxe.error.delFunc', ['reloadTreeChilds', 'reloadTreeExpand'])
|
|
7844
8190
|
}
|
|
7845
8191
|
// 即将废弃
|
|
7846
|
-
return
|
|
8192
|
+
return $xeTable.reloadTreeExpand(row)
|
|
7847
8193
|
},
|
|
7848
8194
|
/**
|
|
7849
8195
|
* 展开树节点事件
|
|
7850
8196
|
*/
|
|
7851
8197
|
triggerTreeExpandEvent (evnt: any, params: any) {
|
|
7852
|
-
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
|
|
7853
8203
|
const { row, column } = params
|
|
7854
8204
|
const { lazy, trigger } = treeOpts
|
|
7855
8205
|
if (trigger === 'manual') {
|
|
@@ -7858,11 +8208,11 @@ const Methods = {
|
|
|
7858
8208
|
evnt.stopPropagation()
|
|
7859
8209
|
const rowid = getRowid(this, row)
|
|
7860
8210
|
if (!lazy || !treeExpandLazyLoadedMaps[rowid]) {
|
|
7861
|
-
const expanded =
|
|
7862
|
-
const columnIndex =
|
|
7863
|
-
const $columnIndex =
|
|
7864
|
-
|
|
7865
|
-
|
|
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)
|
|
7866
8216
|
}
|
|
7867
8217
|
},
|
|
7868
8218
|
/**
|
|
@@ -7871,88 +8221,6 @@ const Methods = {
|
|
|
7871
8221
|
toggleTreeExpand (row: any) {
|
|
7872
8222
|
return this.setTreeExpand(row, !this.isTreeExpandByRow(row))
|
|
7873
8223
|
},
|
|
7874
|
-
/**
|
|
7875
|
-
* 处理默认展开树节点
|
|
7876
|
-
*/
|
|
7877
|
-
handleDefaultTreeExpand () {
|
|
7878
|
-
const { treeConfig, treeOpts, tableFullData } = this
|
|
7879
|
-
if (treeConfig) {
|
|
7880
|
-
const { expandAll, expandRowKeys } = treeOpts
|
|
7881
|
-
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
7882
|
-
if (expandAll) {
|
|
7883
|
-
this.setAllTreeExpand(true)
|
|
7884
|
-
} else if (expandRowKeys) {
|
|
7885
|
-
const defExpandeds: any[] = []
|
|
7886
|
-
const rowkey = getRowkey(this)
|
|
7887
|
-
expandRowKeys.forEach((rowid: any) => {
|
|
7888
|
-
const matchObj = XEUtils.findTree(tableFullData, item => rowid === XEUtils.get(item, rowkey), { children: childrenField })
|
|
7889
|
-
if (matchObj) {
|
|
7890
|
-
defExpandeds.push(matchObj.item)
|
|
7891
|
-
}
|
|
7892
|
-
})
|
|
7893
|
-
this.setTreeExpand(defExpandeds, true)
|
|
7894
|
-
}
|
|
7895
|
-
}
|
|
7896
|
-
},
|
|
7897
|
-
handleAsyncTreeExpandChilds (row: any) {
|
|
7898
|
-
const $xeTable = this
|
|
7899
|
-
|
|
7900
|
-
const { treeOpts, checkboxOpts } = this
|
|
7901
|
-
const { transform, loadMethod } = treeOpts
|
|
7902
|
-
const { checkStrictly } = checkboxOpts
|
|
7903
|
-
return new Promise<void>(resolve => {
|
|
7904
|
-
if (loadMethod) {
|
|
7905
|
-
const { treeExpandLazyLoadedMaps, fullAllDataRowIdData } = this
|
|
7906
|
-
const rowid = getRowid($xeTable, row)
|
|
7907
|
-
const rowRest = fullAllDataRowIdData[rowid]
|
|
7908
|
-
treeExpandLazyLoadedMaps[rowid] = row
|
|
7909
|
-
Promise.resolve(
|
|
7910
|
-
loadMethod({ $table: $xeTable, row })
|
|
7911
|
-
).then((childRecords: any) => {
|
|
7912
|
-
if (rowRest) {
|
|
7913
|
-
rowRest.treeLoaded = true
|
|
7914
|
-
}
|
|
7915
|
-
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
7916
|
-
delete treeExpandLazyLoadedMaps[rowid]
|
|
7917
|
-
}
|
|
7918
|
-
if (!XEUtils.isArray(childRecords)) {
|
|
7919
|
-
childRecords = []
|
|
7920
|
-
}
|
|
7921
|
-
if (childRecords) {
|
|
7922
|
-
return this.loadTreeChildren(row, childRecords).then((childRows: any[]) => {
|
|
7923
|
-
const { treeExpandedMaps } = this
|
|
7924
|
-
if (childRows.length && !treeExpandedMaps[rowid]) {
|
|
7925
|
-
treeExpandedMaps[rowid] = row
|
|
7926
|
-
}
|
|
7927
|
-
// 如果当前节点已选中,则展开后子节点也被选中
|
|
7928
|
-
if (!checkStrictly && this.isCheckedByCheckboxRow(row)) {
|
|
7929
|
-
handleCheckedCheckboxRow($xeTable, childRows, true)
|
|
7930
|
-
}
|
|
7931
|
-
return this.$nextTick().then(() => {
|
|
7932
|
-
if (transform) {
|
|
7933
|
-
this.handleTableData()
|
|
7934
|
-
updateAfterDataIndex($xeTable)
|
|
7935
|
-
return this.$nextTick()
|
|
7936
|
-
}
|
|
7937
|
-
})
|
|
7938
|
-
})
|
|
7939
|
-
}
|
|
7940
|
-
}).catch(() => {
|
|
7941
|
-
const { treeExpandLazyLoadedMaps } = this
|
|
7942
|
-
if (rowRest) {
|
|
7943
|
-
rowRest.treeLoaded = false
|
|
7944
|
-
}
|
|
7945
|
-
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
7946
|
-
delete treeExpandLazyLoadedMaps[rowid]
|
|
7947
|
-
}
|
|
7948
|
-
}).finally(() => {
|
|
7949
|
-
this.$nextTick().then(() => this.recalculate()).then(() => resolve())
|
|
7950
|
-
})
|
|
7951
|
-
} else {
|
|
7952
|
-
resolve()
|
|
7953
|
-
}
|
|
7954
|
-
})
|
|
7955
|
-
},
|
|
7956
8224
|
/**
|
|
7957
8225
|
* 设置所有树节点的展开与否
|
|
7958
8226
|
* @param {Boolean} expanded 是否展开
|
|
@@ -7977,41 +8245,47 @@ const Methods = {
|
|
|
7977
8245
|
* @returns
|
|
7978
8246
|
*/
|
|
7979
8247
|
handleBaseTreeExpand (rows: any, expanded: any) {
|
|
7980
|
-
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
|
|
7981
8255
|
const { reserve, lazy, accordion, toggleMethod } = treeOpts
|
|
7982
|
-
const treeTempExpandedMaps = { ...treeExpandedMaps }
|
|
7983
8256
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
7984
8257
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
7985
8258
|
const result: any[] = []
|
|
7986
|
-
const columnIndex =
|
|
7987
|
-
const $columnIndex =
|
|
7988
|
-
|
|
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
|
|
7989
8263
|
if (accordion) {
|
|
7990
8264
|
validRows = validRows.length ? [validRows[validRows.length - 1]] : []
|
|
7991
8265
|
// 同一级只能展开一个
|
|
7992
8266
|
const matchObj = XEUtils.findTree(tableFullData, item => item === validRows[0], { children: childrenField })
|
|
7993
8267
|
if (matchObj) {
|
|
7994
8268
|
matchObj.items.forEach(item => {
|
|
7995
|
-
const rowid =
|
|
7996
|
-
if (
|
|
7997
|
-
delete
|
|
8269
|
+
const rowid = handleGetRowId(item)
|
|
8270
|
+
if (treeExpandedMaps[rowid]) {
|
|
8271
|
+
delete treeExpandedMaps[rowid]
|
|
7998
8272
|
}
|
|
7999
8273
|
})
|
|
8000
8274
|
}
|
|
8001
8275
|
}
|
|
8002
8276
|
if (expanded) {
|
|
8003
8277
|
validRows.forEach((row: any) => {
|
|
8004
|
-
const rowid =
|
|
8005
|
-
if (!
|
|
8278
|
+
const rowid = handleGetRowId(row)
|
|
8279
|
+
if (!treeExpandedMaps[rowid]) {
|
|
8006
8280
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
8007
8281
|
if (rowRest) {
|
|
8008
8282
|
const isLoad = lazy && row[hasChildField] && !rowRest.treeLoaded && !treeExpandLazyLoadedMaps[rowid]
|
|
8009
8283
|
// 是否使用懒加载
|
|
8010
8284
|
if (isLoad) {
|
|
8011
|
-
result.push(
|
|
8285
|
+
result.push(handleAsyncTreeExpandChilds($xeTable, row))
|
|
8012
8286
|
} else {
|
|
8013
8287
|
if (row[childrenField] && row[childrenField].length) {
|
|
8014
|
-
|
|
8288
|
+
treeExpandedMaps[rowid] = row
|
|
8015
8289
|
}
|
|
8016
8290
|
}
|
|
8017
8291
|
}
|
|
@@ -8019,18 +8293,18 @@ const Methods = {
|
|
|
8019
8293
|
})
|
|
8020
8294
|
} else {
|
|
8021
8295
|
validRows.forEach((item: any) => {
|
|
8022
|
-
const rowid =
|
|
8023
|
-
if (
|
|
8024
|
-
delete
|
|
8296
|
+
const rowid = handleGetRowId(item)
|
|
8297
|
+
if (treeExpandedMaps[rowid]) {
|
|
8298
|
+
delete treeExpandedMaps[rowid]
|
|
8025
8299
|
}
|
|
8026
8300
|
})
|
|
8027
8301
|
}
|
|
8028
8302
|
if (reserve) {
|
|
8029
|
-
validRows.forEach((row: any) =>
|
|
8303
|
+
validRows.forEach((row: any) => handleTreeExpandReserve($xeTable, row, expanded))
|
|
8030
8304
|
}
|
|
8031
|
-
|
|
8305
|
+
reactData.treeExpandedFlag++
|
|
8032
8306
|
return Promise.all(result).then(() => {
|
|
8033
|
-
return
|
|
8307
|
+
return $xeTable.recalculate()
|
|
8034
8308
|
})
|
|
8035
8309
|
},
|
|
8036
8310
|
/**
|
|
@@ -8084,31 +8358,40 @@ const Methods = {
|
|
|
8084
8358
|
* @param {Row} row 行对象
|
|
8085
8359
|
*/
|
|
8086
8360
|
isTreeExpandByRow (row: any) {
|
|
8087
|
-
const
|
|
8088
|
-
|
|
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)]
|
|
8089
8368
|
},
|
|
8090
8369
|
/**
|
|
8091
8370
|
* 手动清空树形节点的展开状态,数据会恢复成未展开的状态
|
|
8092
8371
|
*/
|
|
8093
8372
|
clearTreeExpand () {
|
|
8094
8373
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8374
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
8375
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8095
8376
|
|
|
8096
|
-
const {
|
|
8097
|
-
const
|
|
8377
|
+
const { tableFullTreeData } = internalData
|
|
8378
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
8098
8379
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
8099
|
-
const
|
|
8100
|
-
|
|
8380
|
+
const { transform, reserve } = treeOpts
|
|
8381
|
+
const expList = $xeTable.getTreeExpandRecords()
|
|
8382
|
+
internalData.treeExpandedMaps = {}
|
|
8383
|
+
reactData.treeExpandedFlag++
|
|
8101
8384
|
if (reserve) {
|
|
8102
|
-
XEUtils.eachTree(
|
|
8385
|
+
XEUtils.eachTree(tableFullTreeData, row => handleTreeExpandReserve($xeTable, row, false), { children: childrenField })
|
|
8103
8386
|
}
|
|
8104
|
-
return
|
|
8387
|
+
return $xeTable.handleTableData().then(() => {
|
|
8105
8388
|
if (transform) {
|
|
8106
8389
|
handleVirtualTreeToList($xeTable)
|
|
8107
|
-
return
|
|
8390
|
+
return $xeTable.handleTableData()
|
|
8108
8391
|
}
|
|
8109
8392
|
}).then(() => {
|
|
8110
8393
|
if (expList.length) {
|
|
8111
|
-
|
|
8394
|
+
$xeTable.recalculate()
|
|
8112
8395
|
}
|
|
8113
8396
|
})
|
|
8114
8397
|
},
|
|
@@ -8116,17 +8399,6 @@ const Methods = {
|
|
|
8116
8399
|
this.treeExpandedReserveRowMap = {}
|
|
8117
8400
|
return this.$nextTick()
|
|
8118
8401
|
},
|
|
8119
|
-
handleTreeExpandReserve (row: any, expanded: any) {
|
|
8120
|
-
const { treeExpandedReserveRowMap, treeOpts } = this
|
|
8121
|
-
if (treeOpts.reserve) {
|
|
8122
|
-
const rowid = getRowid(this, row)
|
|
8123
|
-
if (expanded) {
|
|
8124
|
-
treeExpandedReserveRowMap[rowid] = row
|
|
8125
|
-
} else if (treeExpandedReserveRowMap[rowid]) {
|
|
8126
|
-
delete treeExpandedReserveRowMap[rowid]
|
|
8127
|
-
}
|
|
8128
|
-
}
|
|
8129
|
-
},
|
|
8130
8402
|
/**
|
|
8131
8403
|
* 获取表格的滚动状态
|
|
8132
8404
|
*/
|
|
@@ -8451,10 +8723,10 @@ const Methods = {
|
|
|
8451
8723
|
}
|
|
8452
8724
|
|
|
8453
8725
|
const { highlightHoverRow } = tableProps
|
|
8454
|
-
const { scrollXLoad, scrollYLoad } = reactData
|
|
8726
|
+
const { scrollXLoad, scrollYLoad, expandColumn } = reactData
|
|
8455
8727
|
const leftFixedWidth = $xeTable.computeLeftFixedWidth
|
|
8456
8728
|
const rightFixedWidth = $xeTable.computeRightFixedWidth
|
|
8457
|
-
if (!(
|
|
8729
|
+
if (!(leftFixedWidth || rightFixedWidth || expandColumn)) {
|
|
8458
8730
|
return
|
|
8459
8731
|
}
|
|
8460
8732
|
|
|
@@ -8723,8 +8995,8 @@ const Methods = {
|
|
|
8723
8995
|
const reactData = $xeTable as unknown as TableReactData
|
|
8724
8996
|
const internalData = $xeTable as unknown as TableInternalData
|
|
8725
8997
|
|
|
8726
|
-
const { isAllOverflow, scrollYLoad, expandColumn
|
|
8727
|
-
const { scrollYStore, elemStore, isResizeCellHeight, afterFullData, fullAllDataRowIdData } = internalData
|
|
8998
|
+
const { isAllOverflow, scrollYLoad, expandColumn } = reactData
|
|
8999
|
+
const { scrollYStore, elemStore, isResizeCellHeight, afterFullData, fullAllDataRowIdData, rowExpandedMaps } = internalData
|
|
8728
9000
|
const { startIndex } = scrollYStore
|
|
8729
9001
|
const expandOpts = $xeTable.computeExpandOpts
|
|
8730
9002
|
const rowOpts = $xeTable.computeRowOpts
|
|
@@ -8971,12 +9243,15 @@ const Methods = {
|
|
|
8971
9243
|
* 更新表尾合计
|
|
8972
9244
|
*/
|
|
8973
9245
|
updateFooter () {
|
|
9246
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
9247
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
9248
|
+
|
|
8974
9249
|
const { showFooter, visibleColumn, footerData, footerMethod } = this
|
|
8975
9250
|
let footData = []
|
|
8976
9251
|
if (showFooter && footerData && footerData.length) {
|
|
8977
9252
|
footData = footerData.slice(0)
|
|
8978
9253
|
} else if (showFooter && footerMethod) {
|
|
8979
|
-
footData = visibleColumn.length ? footerMethod({ columns: visibleColumn, data: this.afterFullData, $table:
|
|
9254
|
+
footData = visibleColumn.length ? footerMethod({ columns: visibleColumn, data: this.afterFullData, $table: $xeTable, $grid: $xeGrid }) : []
|
|
8980
9255
|
}
|
|
8981
9256
|
this.footerTableData = footData
|
|
8982
9257
|
return this.$nextTick()
|
|
@@ -9059,7 +9334,7 @@ const Methods = {
|
|
|
9059
9334
|
if (this.footerSpanMethod) {
|
|
9060
9335
|
errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method'])
|
|
9061
9336
|
}
|
|
9062
|
-
setMerges(this, merges, this.mergeFooterList
|
|
9337
|
+
setMerges(this, merges, this.mergeFooterList)
|
|
9063
9338
|
return this.$nextTick().then(() => {
|
|
9064
9339
|
this.updateCellAreas()
|
|
9065
9340
|
return updateStyle($xeTable)
|
|
@@ -9114,12 +9389,17 @@ const Methods = {
|
|
|
9114
9389
|
return $xeTable.$nextTick()
|
|
9115
9390
|
},
|
|
9116
9391
|
dispatchEvent (type: ValueOf<VxeTableEmits>, params: Record<string, any>, evnt: Event | null) {
|
|
9117
|
-
const $xeTable = this
|
|
9118
|
-
|
|
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))
|
|
9119
9396
|
},
|
|
9120
9397
|
// 已废弃,使用 dispatchEvent
|
|
9121
9398
|
emitEvent (type: any, params: any, evnt: any) {
|
|
9122
|
-
|
|
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))
|
|
9123
9403
|
},
|
|
9124
9404
|
focus () {
|
|
9125
9405
|
this.isActivated = true
|