vxe-table 3.14.0-beta.9 → 3.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/grid/src/grid.js +62 -42
- package/es/locale/lang/ar-EG.js +7 -1
- package/es/locale/lang/de-DE.js +7 -1
- package/es/locale/lang/en-US.js +7 -1
- package/es/locale/lang/es-ES.js +7 -1
- package/es/locale/lang/fr-FR.js +7 -1
- package/es/locale/lang/hu-HU.js +7 -1
- package/es/locale/lang/hy-AM.js +7 -1
- package/es/locale/lang/id-ID.js +7 -1
- package/es/locale/lang/it-IT.js +7 -1
- package/es/locale/lang/ja-JP.js +7 -1
- package/es/locale/lang/ko-KR.js +7 -1
- package/es/locale/lang/nb-NO.js +7 -1
- package/es/locale/lang/pt-BR.js +7 -1
- package/es/locale/lang/ru-RU.js +7 -1
- package/es/locale/lang/th-TH.js +7 -1
- package/es/locale/lang/ug-CN.js +7 -1
- package/es/locale/lang/uk-UA.js +7 -1
- package/es/locale/lang/vi-VN.js +7 -1
- package/es/locale/lang/zh-CHT.js +7 -1
- package/es/locale/lang/zh-CN.js +7 -1
- package/es/style.css +1 -1
- package/es/table/module/custom/mixin.js +4 -2
- package/es/table/module/custom/panel.js +24 -23
- package/es/table/module/edit/mixin.js +17 -11
- package/es/table/module/export/export-panel.js +5 -4
- package/es/table/module/export/import-panel.js +8 -7
- package/es/table/module/export/mixin.js +30 -27
- package/es/table/module/filter/panel.js +21 -10
- package/es/table/module/keyboard/mixin.js +141 -41
- package/es/table/module/menu/mixin.js +6 -3
- package/es/table/module/menu/panel.js +7 -7
- package/es/table/module/validator/mixin.js +2 -2
- package/es/table/render/index.js +2 -2
- package/es/table/src/body.js +39 -20
- package/es/table/src/cell.js +27 -22
- package/es/table/src/column.js +11 -9
- package/es/table/src/columnInfo.js +6 -6
- package/es/table/src/footer.js +12 -7
- package/es/table/src/group.js +6 -5
- package/es/table/src/header.js +15 -9
- package/es/table/src/methods.js +761 -698
- package/es/table/src/props.js +4 -0
- package/es/table/src/table.js +85 -49
- package/es/table/src/util.js +55 -20
- package/es/toolbar/src/toolbar.js +3 -3
- package/es/ui/index.js +2 -1
- package/es/ui/src/log.js +1 -1
- package/helper/vetur/attributes.json +1 -1
- package/helper/vetur/tags.json +1 -1
- package/lib/grid/src/grid.js +69 -59
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/index.umd.js +1558 -1232
- package/lib/index.umd.min.js +1 -1
- package/lib/locale/lang/ar-EG.js +7 -1
- package/lib/locale/lang/ar-EG.min.js +1 -1
- package/lib/locale/lang/de-DE.js +7 -1
- package/lib/locale/lang/de-DE.min.js +1 -1
- package/lib/locale/lang/en-US.js +7 -1
- package/lib/locale/lang/en-US.min.js +1 -1
- package/lib/locale/lang/en-US.umd.js +7 -1
- package/lib/locale/lang/es-ES.js +7 -1
- package/lib/locale/lang/es-ES.min.js +1 -1
- package/lib/locale/lang/es-ES.umd.js +7 -1
- package/lib/locale/lang/fr-FR.js +7 -1
- package/lib/locale/lang/fr-FR.min.js +1 -1
- package/lib/locale/lang/hu-HU.js +7 -1
- package/lib/locale/lang/hu-HU.min.js +1 -1
- package/lib/locale/lang/hu-HU.umd.js +7 -1
- package/lib/locale/lang/hy-AM.js +7 -1
- package/lib/locale/lang/hy-AM.min.js +1 -1
- package/lib/locale/lang/id-ID.js +7 -1
- package/lib/locale/lang/id-ID.min.js +1 -1
- package/lib/locale/lang/it-IT.js +7 -1
- package/lib/locale/lang/it-IT.min.js +1 -1
- package/lib/locale/lang/ja-JP.js +7 -1
- package/lib/locale/lang/ja-JP.min.js +1 -1
- package/lib/locale/lang/ja-JP.umd.js +7 -1
- package/lib/locale/lang/ko-KR.js +7 -1
- package/lib/locale/lang/ko-KR.min.js +1 -1
- package/lib/locale/lang/ko-KR.umd.js +7 -1
- package/lib/locale/lang/nb-NO.js +7 -1
- package/lib/locale/lang/nb-NO.min.js +1 -1
- package/lib/locale/lang/pt-BR.js +7 -1
- package/lib/locale/lang/pt-BR.min.js +1 -1
- package/lib/locale/lang/pt-BR.umd.js +7 -1
- package/lib/locale/lang/ru-RU.js +7 -1
- package/lib/locale/lang/ru-RU.min.js +1 -1
- package/lib/locale/lang/ru-RU.umd.js +7 -1
- package/lib/locale/lang/th-TH.js +7 -1
- package/lib/locale/lang/th-TH.min.js +1 -1
- package/lib/locale/lang/ug-CN.js +7 -1
- package/lib/locale/lang/ug-CN.min.js +1 -1
- package/lib/locale/lang/uk-UA.js +7 -1
- package/lib/locale/lang/uk-UA.min.js +1 -1
- package/lib/locale/lang/uk-UA.umd.js +7 -1
- package/lib/locale/lang/vi-VN.js +7 -1
- package/lib/locale/lang/vi-VN.min.js +1 -1
- package/lib/locale/lang/zh-CHT.js +7 -1
- package/lib/locale/lang/zh-CHT.min.js +1 -1
- package/lib/locale/lang/zh-CHT.umd.js +7 -1
- package/lib/locale/lang/zh-CN.js +7 -1
- package/lib/locale/lang/zh-CN.min.js +1 -1
- package/lib/locale/lang/zh-CN.umd.js +7 -1
- package/lib/style.css +1 -1
- package/lib/table/module/custom/mixin.js +5 -3
- package/lib/table/module/custom/mixin.min.js +1 -1
- package/lib/table/module/custom/panel.js +22 -29
- package/lib/table/module/custom/panel.min.js +1 -1
- package/lib/table/module/edit/mixin.js +19 -13
- package/lib/table/module/edit/mixin.min.js +1 -1
- package/lib/table/module/export/export-panel.js +5 -4
- package/lib/table/module/export/export-panel.min.js +1 -1
- package/lib/table/module/export/import-panel.js +8 -7
- package/lib/table/module/export/import-panel.min.js +1 -1
- package/lib/table/module/export/mixin.js +35 -34
- package/lib/table/module/export/mixin.min.js +1 -1
- package/lib/table/module/filter/panel.js +16 -16
- package/lib/table/module/filter/panel.min.js +1 -1
- package/lib/table/module/keyboard/mixin.js +149 -47
- package/lib/table/module/keyboard/mixin.min.js +1 -1
- package/lib/table/module/menu/mixin.js +6 -3
- package/lib/table/module/menu/mixin.min.js +1 -1
- package/lib/table/module/menu/panel.js +7 -7
- package/lib/table/module/menu/panel.min.js +1 -1
- package/lib/table/module/validator/mixin.js +3 -3
- package/lib/table/module/validator/mixin.min.js +1 -1
- package/lib/table/render/index.js +3 -2
- package/lib/table/render/index.min.js +1 -1
- package/lib/table/src/body.js +47 -20
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +39 -23
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/column.js +11 -9
- package/lib/table/src/column.min.js +1 -1
- package/lib/table/src/columnInfo.js +6 -6
- package/lib/table/src/columnInfo.min.js +1 -1
- package/lib/table/src/footer.js +12 -5
- package/lib/table/src/footer.min.js +1 -1
- package/lib/table/src/group.js +6 -5
- package/lib/table/src/group.min.js +1 -1
- package/lib/table/src/header.js +16 -8
- package/lib/table/src/header.min.js +1 -1
- package/lib/table/src/methods.js +898 -825
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/props.js +4 -0
- package/lib/table/src/props.min.js +1 -1
- package/lib/table/src/table.js +93 -52
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +62 -21
- package/lib/table/src/util.min.js +1 -1
- package/lib/toolbar/src/toolbar.js +3 -3
- package/lib/ui/index.js +2 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +2 -2
- package/packages/grid/src/grid.ts +75 -51
- package/packages/locale/lang/ar-EG.ts +7 -1
- package/packages/locale/lang/de-DE.ts +7 -1
- package/packages/locale/lang/en-US.ts +7 -1
- package/packages/locale/lang/es-ES.ts +7 -1
- package/packages/locale/lang/fr-FR.ts +7 -1
- package/packages/locale/lang/hu-HU.ts +7 -1
- package/packages/locale/lang/hy-AM.ts +7 -1
- package/packages/locale/lang/id-ID.ts +7 -1
- package/packages/locale/lang/it-IT.ts +7 -1
- package/packages/locale/lang/ja-JP.ts +7 -1
- package/packages/locale/lang/ko-KR.ts +7 -1
- package/packages/locale/lang/nb-NO.ts +7 -1
- package/packages/locale/lang/pt-BR.ts +7 -1
- package/packages/locale/lang/ru-RU.ts +7 -1
- package/packages/locale/lang/th-TH.ts +7 -1
- package/packages/locale/lang/ug-CN.ts +7 -1
- package/packages/locale/lang/uk-UA.ts +7 -1
- package/packages/locale/lang/vi-VN.ts +7 -1
- package/packages/locale/lang/zh-CHT.ts +7 -1
- package/packages/locale/lang/zh-CN.ts +7 -1
- package/packages/table/module/custom/mixin.ts +6 -3
- package/packages/table/module/custom/panel.ts +42 -37
- package/packages/table/module/edit/mixin.ts +20 -14
- package/packages/table/module/export/export-panel.ts +8 -5
- package/packages/table/module/export/import-panel.ts +11 -7
- package/packages/table/module/export/mixin.ts +37 -32
- package/packages/table/module/filter/panel.ts +25 -10
- package/packages/table/module/keyboard/mixin.ts +155 -49
- package/packages/table/module/menu/mixin.ts +12 -6
- package/packages/table/module/menu/panel.ts +10 -7
- package/packages/table/module/validator/mixin.ts +2 -2
- package/packages/table/render/index.ts +2 -2
- package/packages/table/src/body.ts +39 -20
- package/packages/table/src/cell.ts +27 -22
- package/packages/table/src/column.ts +14 -10
- package/packages/table/src/columnInfo.ts +9 -6
- package/packages/table/src/footer.ts +12 -7
- package/packages/table/src/group.ts +9 -5
- package/packages/table/src/header.ts +16 -9
- package/packages/table/src/methods.ts +840 -734
- package/packages/table/src/props.ts +16 -12
- package/packages/table/src/table.ts +99 -52
- package/packages/table/src/util.ts +63 -21
- package/packages/toolbar/src/toolbar.ts +3 -3
- package/packages/ui/index.ts +1 -0
- /package/es/{iconfont.1741336976538.ttf → iconfont.1742955973002.ttf} +0 -0
- /package/es/{iconfont.1741336976538.woff → iconfont.1742955973002.woff} +0 -0
- /package/es/{iconfont.1741336976538.woff2 → iconfont.1742955973002.woff2} +0 -0
- /package/lib/{iconfont.1741336976538.ttf → iconfont.1742955973002.ttf} +0 -0
- /package/lib/{iconfont.1741336976538.woff → iconfont.1742955973002.woff} +0 -0
- /package/lib/{iconfont.1741336976538.woff2 → iconfont.1742955973002.woff2} +0 -0
|
@@ -3,7 +3,7 @@ import { browse, getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEv
|
|
|
3
3
|
import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils'
|
|
4
4
|
import { VxeUI } from '../../ui'
|
|
5
5
|
import Cell from './cell'
|
|
6
|
-
import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth,
|
|
6
|
+
import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getRefElem } from './util'
|
|
7
7
|
import { getSlotVNs } from '../../ui/src/vn'
|
|
8
8
|
import { warnLog, errLog } from '../../ui/src/log'
|
|
9
9
|
|
|
@@ -11,6 +11,7 @@ import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, ValueOf, Table
|
|
|
11
11
|
|
|
12
12
|
const { getConfig, getI18n, renderer, formats, interceptor, createEvent } = VxeUI
|
|
13
13
|
|
|
14
|
+
const supportMaxRow = 5e6
|
|
14
15
|
const customStorageKey = 'VXE_CUSTOM_STORE'
|
|
15
16
|
const maxYHeight = 5e6
|
|
16
17
|
const maxXWidth = 5e6
|
|
@@ -236,7 +237,7 @@ function cacheColumnMap ($xeTable: VxeTableConstructor) {
|
|
|
236
237
|
fullColumnFieldData[field] = rest
|
|
237
238
|
} else {
|
|
238
239
|
if ((storage && !type) || (columnOpts.drag && (isCrossDrag || isSelfToChildDrag))) {
|
|
239
|
-
errLog('vxe.error.reqProp', [`${column.getTitle() || type || ''} -> column.field
|
|
240
|
+
errLog('vxe.error.reqProp', [`${column.getTitle() || type || ''} -> column.field=?`])
|
|
240
241
|
}
|
|
241
242
|
}
|
|
242
243
|
if (!hasFixed && fixed) {
|
|
@@ -340,9 +341,10 @@ function updateAfterListIndex ($xeTable: VxeTableConstructor) {
|
|
|
340
341
|
|
|
341
342
|
const { treeConfig } = props
|
|
342
343
|
const { afterFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData
|
|
344
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
343
345
|
const fullMaps: Record<string, any> = {}
|
|
344
346
|
afterFullData.forEach((row, index) => {
|
|
345
|
-
const rowid =
|
|
347
|
+
const rowid = handleGetRowId(row)
|
|
346
348
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
347
349
|
const seq = index + 1
|
|
348
350
|
if (rowRest) {
|
|
@@ -375,8 +377,9 @@ function updateAfterDataIndex ($xeTable: VxeTableConstructor) {
|
|
|
375
377
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
376
378
|
const fullMaps: Record<string, any> = {}
|
|
377
379
|
if (treeConfig) {
|
|
380
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
378
381
|
XEUtils.eachTree(afterTreeFullData, (row, index, items, path) => {
|
|
379
|
-
const rowid =
|
|
382
|
+
const rowid = handleGetRowId(row)
|
|
380
383
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
381
384
|
const seq = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
|
|
382
385
|
if (rowRest) {
|
|
@@ -402,22 +405,21 @@ function updateAfterDataIndex ($xeTable: VxeTableConstructor) {
|
|
|
402
405
|
*/
|
|
403
406
|
function handleVirtualTreeToList ($xeTable: VxeTableConstructor) {
|
|
404
407
|
const props = $xeTable
|
|
405
|
-
const reactData = $xeTable as unknown as TableReactData
|
|
406
408
|
const internalData = $xeTable as unknown as TableInternalData
|
|
407
409
|
|
|
408
410
|
const { treeConfig } = props
|
|
409
|
-
const { treeExpandedMaps } =
|
|
410
|
-
const { fullAllDataRowIdData } = internalData
|
|
411
|
+
const { fullAllDataRowIdData, treeExpandedMaps } = internalData
|
|
411
412
|
const treeOpts = $xeTable.computeTreeOpts
|
|
412
413
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
413
414
|
if (treeConfig && treeOpts.transform) {
|
|
415
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
414
416
|
const fullData: any[] = []
|
|
415
417
|
const expandMaps: {
|
|
416
418
|
[key: string]: number
|
|
417
419
|
} = {}
|
|
418
420
|
XEUtils.eachTree(internalData.afterTreeFullData, (row, index, items, path, parentRow) => {
|
|
419
|
-
const rowid =
|
|
420
|
-
const parentRowid =
|
|
421
|
+
const rowid = handleGetRowId(row)
|
|
422
|
+
const parentRowid = handleGetRowId(parentRow)
|
|
421
423
|
if (!parentRow || (expandMaps[parentRowid] && treeExpandedMaps[parentRowid])) {
|
|
422
424
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
423
425
|
if (rowRest) {
|
|
@@ -441,7 +443,7 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
441
443
|
|
|
442
444
|
const { border, showHeaderOverflow: allColumnHeaderOverflow, showFooterOverflow: allColumnFooterOverflow, mouseConfig, spanMethod, footerSpanMethod } = props
|
|
443
445
|
const { isGroup, currentRow, tableColumn, scrollXLoad, scrollYLoad, overflowX, scrollbarWidth, overflowY, scrollbarHeight, scrollXWidth, columnStore, editStore, isAllOverflow, expandColumn } = reactData
|
|
444
|
-
const { visibleColumn,
|
|
446
|
+
const { visibleColumn, tableHeight, headerHeight, footerHeight, elemStore, customHeight, customMinHeight, customMaxHeight } = internalData
|
|
445
447
|
const el = $xeTable.$refs.refElem as HTMLDivElement
|
|
446
448
|
if (!el) {
|
|
447
449
|
return
|
|
@@ -450,7 +452,6 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
450
452
|
const osbWidth = overflowY ? scrollbarWidth : 0
|
|
451
453
|
const osbHeight = overflowX ? scrollbarHeight : 0
|
|
452
454
|
const emptyPlaceholderElem = $xeTable.$refs.refEmptyPlaceholder as HTMLDivElement
|
|
453
|
-
const cellOffsetWidth = $xeTable.computeCellOffsetWidth
|
|
454
455
|
const mouseOpts = $xeTable.computeMouseOpts
|
|
455
456
|
const expandOpts = $xeTable.computeExpandOpts
|
|
456
457
|
const bodyWrapperElem = getRefElem(elemStore['main-body-wrapper'])
|
|
@@ -732,54 +733,6 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
732
733
|
tableElem.style.width = tWidth ? `${tWidth}px` : ''
|
|
733
734
|
}
|
|
734
735
|
}
|
|
735
|
-
const colgroupElem = getRefElem(elemStore[`${name}-${layout}-colgroup`])
|
|
736
|
-
if (colgroupElem) {
|
|
737
|
-
XEUtils.arrayEach(colgroupElem.children, (colElem: any) => {
|
|
738
|
-
const colid = colElem.getAttribute('name')
|
|
739
|
-
if (fullColumnIdData[colid]) {
|
|
740
|
-
const colRest = fullColumnIdData[colid]
|
|
741
|
-
const column = colRest.column
|
|
742
|
-
const { showHeaderOverflow, showFooterOverflow, showOverflow } = column
|
|
743
|
-
let cellOverflow
|
|
744
|
-
colElem.style.width = `${column.renderWidth}px`
|
|
745
|
-
if (layout === 'header') {
|
|
746
|
-
cellOverflow = XEUtils.isUndefined(showHeaderOverflow) || XEUtils.isNull(showHeaderOverflow) ? allColumnHeaderOverflow : showHeaderOverflow
|
|
747
|
-
} else if (layout === 'footer') {
|
|
748
|
-
cellOverflow = XEUtils.isUndefined(showFooterOverflow) || XEUtils.isNull(showFooterOverflow) ? allColumnFooterOverflow : showFooterOverflow
|
|
749
|
-
} else {
|
|
750
|
-
cellOverflow = XEUtils.isUndefined(showOverflow) || XEUtils.isNull(showOverflow) ? isAllOverflow : showOverflow
|
|
751
|
-
}
|
|
752
|
-
const showEllipsis = cellOverflow === 'ellipsis'
|
|
753
|
-
const showTitle = cellOverflow === 'title'
|
|
754
|
-
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip'
|
|
755
|
-
let hasEllipsis = showTitle || showTooltip || showEllipsis
|
|
756
|
-
const listElem = getRefElem(elemStore[`${name}-${layout}-list`])
|
|
757
|
-
// 纵向虚拟滚动不支持动态行高
|
|
758
|
-
if (scrollYLoad && !hasEllipsis) {
|
|
759
|
-
hasEllipsis = true
|
|
760
|
-
}
|
|
761
|
-
if (listElem) {
|
|
762
|
-
XEUtils.arrayEach(listElem.querySelectorAll(`.${column.id}`), (elem: any) => {
|
|
763
|
-
const colspan = parseInt(elem.getAttribute('colspan') || 1)
|
|
764
|
-
const cellElem = elem.querySelector('.vxe-cell')
|
|
765
|
-
let colWidth = column.renderWidth
|
|
766
|
-
if (cellElem) {
|
|
767
|
-
if (colspan > 1) {
|
|
768
|
-
const columnIndex = $xeTable.getColumnIndex(column)
|
|
769
|
-
for (let index = 1; index < colspan; index++) {
|
|
770
|
-
const nextColumn = $xeTable.getColumns(columnIndex + index)
|
|
771
|
-
if (nextColumn) {
|
|
772
|
-
colWidth += nextColumn.renderWidth
|
|
773
|
-
}
|
|
774
|
-
}
|
|
775
|
-
}
|
|
776
|
-
cellElem.style.width = hasEllipsis ? `${colWidth - (cellOffsetWidth * colspan)}px` : ''
|
|
777
|
-
}
|
|
778
|
-
})
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
})
|
|
782
|
-
}
|
|
783
736
|
})
|
|
784
737
|
})
|
|
785
738
|
if (currentRow) {
|
|
@@ -791,6 +744,27 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
791
744
|
return $xeTable.$nextTick()
|
|
792
745
|
}
|
|
793
746
|
|
|
747
|
+
function checkValidate ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, type: any) {
|
|
748
|
+
if ($xeTable.triggerValidate) {
|
|
749
|
+
return $xeTable.triggerValidate(type)
|
|
750
|
+
}
|
|
751
|
+
return $xeTable.$nextTick()
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* 当单元格发生改变时
|
|
756
|
+
* 如果存在规则,则校验
|
|
757
|
+
*/
|
|
758
|
+
function handleChangeCell ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: Event, params: any) {
|
|
759
|
+
checkValidate($xeTable, 'blur')
|
|
760
|
+
.catch((e: any) => e)
|
|
761
|
+
.then(() => {
|
|
762
|
+
$xeTable.handleEdit(params, evnt)
|
|
763
|
+
.then(() => checkValidate($xeTable, 'change'))
|
|
764
|
+
.catch((e: any) => e)
|
|
765
|
+
})
|
|
766
|
+
}
|
|
767
|
+
|
|
794
768
|
function handleRadioReserveRow ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, row: any) {
|
|
795
769
|
const internalData = $xeTable as unknown as TableInternalData
|
|
796
770
|
|
|
@@ -842,12 +816,12 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
842
816
|
const internalData = $xeTable as unknown as TableInternalData
|
|
843
817
|
|
|
844
818
|
const { treeConfig } = props
|
|
845
|
-
const { selectCheckboxMaps } =
|
|
846
|
-
const { afterFullData, checkboxReserveRowMap } = internalData
|
|
819
|
+
const { afterFullData, checkboxReserveRowMap, selectCheckboxMaps } = internalData
|
|
847
820
|
const treeOpts = $xeTable.computeTreeOpts
|
|
848
821
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
849
822
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
850
823
|
const { checkField, reserve, checkMethod } = checkboxOpts
|
|
824
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
851
825
|
// indeterminateField 仅支持读取
|
|
852
826
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
853
827
|
const selectRowMaps: Record<string, any> = {}
|
|
@@ -859,7 +833,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
859
833
|
const checkValFn = (row: any) => {
|
|
860
834
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
861
835
|
if (checked) {
|
|
862
|
-
selectRowMaps[
|
|
836
|
+
selectRowMaps[handleGetRowId(row)] = row
|
|
863
837
|
}
|
|
864
838
|
XEUtils.set(row, checkField, checked)
|
|
865
839
|
}
|
|
@@ -887,7 +861,8 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
887
861
|
*/
|
|
888
862
|
XEUtils.eachTree(afterFullData, (row) => {
|
|
889
863
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
890
|
-
|
|
864
|
+
const rowid = handleGetRowId(row)
|
|
865
|
+
selectRowMaps[rowid] = row
|
|
891
866
|
}
|
|
892
867
|
}, { children: childrenField })
|
|
893
868
|
} else {
|
|
@@ -897,7 +872,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
897
872
|
*/
|
|
898
873
|
if (!isForce && checkMethod) {
|
|
899
874
|
XEUtils.eachTree(afterFullData, (row) => {
|
|
900
|
-
const rowid =
|
|
875
|
+
const rowid = handleGetRowId(row)
|
|
901
876
|
if (checkMethod({ row }) ? 0 : selectCheckboxMaps[rowid]) {
|
|
902
877
|
selectRowMaps[rowid] = row
|
|
903
878
|
}
|
|
@@ -913,14 +888,15 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
913
888
|
*/
|
|
914
889
|
if (!isForce && checkMethod) {
|
|
915
890
|
afterFullData.forEach((row) => {
|
|
916
|
-
const rowid =
|
|
891
|
+
const rowid = handleGetRowId(row)
|
|
917
892
|
if (selectCheckboxMaps[rowid] || checkMethod({ row })) {
|
|
918
893
|
selectRowMaps[rowid] = row
|
|
919
894
|
}
|
|
920
895
|
})
|
|
921
896
|
} else {
|
|
922
897
|
afterFullData.forEach(row => {
|
|
923
|
-
|
|
898
|
+
const rowid = handleGetRowId(row)
|
|
899
|
+
selectRowMaps[rowid] = row
|
|
924
900
|
})
|
|
925
901
|
}
|
|
926
902
|
} else {
|
|
@@ -931,7 +907,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
931
907
|
*/
|
|
932
908
|
if (!isForce && checkMethod) {
|
|
933
909
|
afterFullData.forEach((row) => {
|
|
934
|
-
const rowid =
|
|
910
|
+
const rowid = handleGetRowId(row)
|
|
935
911
|
if (checkMethod({ row }) ? 0 : selectCheckboxMaps[rowid]) {
|
|
936
912
|
selectRowMaps[rowid] = row
|
|
937
913
|
}
|
|
@@ -949,11 +925,11 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
949
925
|
afterFullData.forEach((row) => handleCheckboxReserveRow($xeTable, row, false))
|
|
950
926
|
}
|
|
951
927
|
}
|
|
952
|
-
reactData.
|
|
928
|
+
reactData.updateCheckboxFlag++
|
|
929
|
+
internalData.selectCheckboxMaps = checkField ? {} : selectRowMaps
|
|
953
930
|
|
|
954
931
|
reactData.isAllSelected = checked
|
|
955
932
|
reactData.isIndeterminate = false
|
|
956
|
-
reactData.treeIndeterminateMaps = {}
|
|
957
933
|
internalData.treeIndeterminateRowMaps = {}
|
|
958
934
|
$xeTable.checkSelectionStatus()
|
|
959
935
|
return $xeTable.$nextTick()
|
|
@@ -966,8 +942,8 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
966
942
|
const internalData = $xeTable as unknown as TableInternalData
|
|
967
943
|
|
|
968
944
|
const { treeConfig } = props
|
|
969
|
-
const { expandColumn, currentRow,
|
|
970
|
-
const { fullDataRowIdData, fullAllDataRowIdData, radioReserveRow } = internalData
|
|
945
|
+
const { expandColumn, currentRow, selectRadioRow } = reactData
|
|
946
|
+
const { fullDataRowIdData, fullAllDataRowIdData, radioReserveRow, selectCheckboxMaps, treeExpandedMaps, rowExpandedMaps } = internalData
|
|
971
947
|
const expandOpts = $xeTable.computeExpandOpts
|
|
972
948
|
const treeOpts = $xeTable.computeTreeOpts
|
|
973
949
|
const radioOpts = $xeTable.computeRadioOpts
|
|
@@ -984,7 +960,8 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
984
960
|
}
|
|
985
961
|
}
|
|
986
962
|
// 复选框
|
|
987
|
-
|
|
963
|
+
internalData.selectCheckboxMaps = getRecoverRowMaps($xeTable, selectCheckboxMaps) // 刷新多选行状态
|
|
964
|
+
reactData.updateCheckboxFlag++
|
|
988
965
|
// 还原保留选中状态
|
|
989
966
|
if (checkboxOpts.reserve) {
|
|
990
967
|
handleCheckedCheckboxRow($xeTable, handleReserveRow($xeTable, internalData.checkboxReserveRowMap), true, true)
|
|
@@ -993,18 +970,168 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
993
970
|
reactData.currentRow = null // 刷新当前行状态
|
|
994
971
|
}
|
|
995
972
|
// 行展开
|
|
996
|
-
|
|
973
|
+
internalData.rowExpandedMaps = expandColumn ? getRecoverRowMaps($xeTable, rowExpandedMaps) : {} // 刷新行展开状态
|
|
974
|
+
reactData.rowExpandedFlag++
|
|
997
975
|
// 还原保留状态
|
|
998
976
|
if (expandColumn && expandOpts.reserve) {
|
|
999
977
|
$xeTable.setRowExpand(handleReserveRow($xeTable, internalData.rowExpandedReserveRowMap), true)
|
|
1000
978
|
}
|
|
1001
979
|
// 树展开
|
|
1002
|
-
|
|
980
|
+
internalData.treeExpandedMaps = treeConfig ? getRecoverRowMaps($xeTable, treeExpandedMaps) : {} // 刷新树展开状态
|
|
981
|
+
reactData.treeExpandedFlag++
|
|
1003
982
|
if (treeConfig && treeOpts.reserve) {
|
|
1004
983
|
$xeTable.setTreeExpand(handleReserveRow($xeTable, internalData.treeExpandedReserveRowMap), true)
|
|
1005
984
|
}
|
|
1006
985
|
}
|
|
1007
986
|
|
|
987
|
+
/**
|
|
988
|
+
* 处理默认展开树节点
|
|
989
|
+
*/
|
|
990
|
+
const handleDefaultTreeExpand = ($xeTable: VxeTableConstructor) => {
|
|
991
|
+
const props = $xeTable
|
|
992
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
993
|
+
|
|
994
|
+
const { treeConfig } = props
|
|
995
|
+
if (treeConfig) {
|
|
996
|
+
const { tableFullData } = internalData
|
|
997
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
998
|
+
const { expandAll, expandRowKeys } = treeOpts
|
|
999
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
1000
|
+
if (expandAll) {
|
|
1001
|
+
$xeTable.setAllTreeExpand(true)
|
|
1002
|
+
} else if (expandRowKeys) {
|
|
1003
|
+
const defExpandeds: any[] = []
|
|
1004
|
+
const rowkey = getRowkey($xeTable)
|
|
1005
|
+
expandRowKeys.forEach((rowid: any) => {
|
|
1006
|
+
const matchObj = XEUtils.findTree(tableFullData, item => rowid === XEUtils.get(item, rowkey), { children: childrenField })
|
|
1007
|
+
if (matchObj) {
|
|
1008
|
+
defExpandeds.push(matchObj.item)
|
|
1009
|
+
}
|
|
1010
|
+
})
|
|
1011
|
+
$xeTable.setTreeExpand(defExpandeds, true)
|
|
1012
|
+
}
|
|
1013
|
+
}
|
|
1014
|
+
}
|
|
1015
|
+
|
|
1016
|
+
const handleAsyncTreeExpandChilds = ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, row: any): Promise<void> => {
|
|
1017
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
1018
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1019
|
+
|
|
1020
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
1021
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
1022
|
+
const { transform, loadMethod } = treeOpts
|
|
1023
|
+
const { checkStrictly } = checkboxOpts
|
|
1024
|
+
return new Promise<void>(resolve => {
|
|
1025
|
+
if (loadMethod) {
|
|
1026
|
+
const { fullAllDataRowIdData, treeExpandLazyLoadedMaps } = internalData
|
|
1027
|
+
const rowid = getRowid($xeTable, row)
|
|
1028
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
1029
|
+
treeExpandLazyLoadedMaps[rowid] = row
|
|
1030
|
+
Promise.resolve(
|
|
1031
|
+
loadMethod({ $table: $xeTable, row })
|
|
1032
|
+
).then((childRecords: any) => {
|
|
1033
|
+
if (rowRest) {
|
|
1034
|
+
rowRest.treeLoaded = true
|
|
1035
|
+
}
|
|
1036
|
+
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
1037
|
+
delete treeExpandLazyLoadedMaps[rowid]
|
|
1038
|
+
}
|
|
1039
|
+
if (!XEUtils.isArray(childRecords)) {
|
|
1040
|
+
childRecords = []
|
|
1041
|
+
}
|
|
1042
|
+
if (childRecords) {
|
|
1043
|
+
return $xeTable.loadTreeChildren(row, childRecords).then(childRows => {
|
|
1044
|
+
const { treeExpandedMaps } = internalData
|
|
1045
|
+
if (childRows.length && !treeExpandedMaps[rowid]) {
|
|
1046
|
+
treeExpandedMaps[rowid] = row
|
|
1047
|
+
}
|
|
1048
|
+
reactData.treeExpandedFlag++
|
|
1049
|
+
// 如果当前节点已选中,则展开后子节点也被选中
|
|
1050
|
+
if (!checkStrictly && $xeTable.isCheckedByCheckboxRow(row)) {
|
|
1051
|
+
handleCheckedCheckboxRow($xeTable, childRows, true)
|
|
1052
|
+
}
|
|
1053
|
+
return $xeTable.$nextTick().then(() => {
|
|
1054
|
+
if (transform) {
|
|
1055
|
+
$xeTable.handleTableData()
|
|
1056
|
+
updateAfterDataIndex($xeTable)
|
|
1057
|
+
return $xeTable.$nextTick()
|
|
1058
|
+
}
|
|
1059
|
+
})
|
|
1060
|
+
})
|
|
1061
|
+
}
|
|
1062
|
+
}).catch(() => {
|
|
1063
|
+
const { treeExpandLazyLoadedMaps } = internalData
|
|
1064
|
+
if (rowRest) {
|
|
1065
|
+
rowRest.treeLoaded = false
|
|
1066
|
+
}
|
|
1067
|
+
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
1068
|
+
delete treeExpandLazyLoadedMaps[rowid]
|
|
1069
|
+
}
|
|
1070
|
+
}).finally(() => {
|
|
1071
|
+
reactData.treeExpandedFlag++
|
|
1072
|
+
$xeTable.$nextTick().then(() => $xeTable.recalculate()).then(() => resolve())
|
|
1073
|
+
})
|
|
1074
|
+
} else {
|
|
1075
|
+
resolve()
|
|
1076
|
+
}
|
|
1077
|
+
})
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
const handleTreeExpandReserve = ($xeTable: VxeTableConstructor, row: any, expanded: boolean) => {
|
|
1081
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1082
|
+
|
|
1083
|
+
const { treeExpandedReserveRowMap } = internalData
|
|
1084
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
1085
|
+
if (treeOpts.reserve) {
|
|
1086
|
+
const rowid = getRowid($xeTable, row)
|
|
1087
|
+
if (expanded) {
|
|
1088
|
+
treeExpandedReserveRowMap[rowid] = row
|
|
1089
|
+
} else if (treeExpandedReserveRowMap[rowid]) {
|
|
1090
|
+
delete treeExpandedReserveRowMap[rowid]
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
const handleAsyncRowExpand = ($xeTable: VxeTableConstructor, row: any): Promise<void> => {
|
|
1096
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
1097
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1098
|
+
|
|
1099
|
+
return new Promise<void>(resolve => {
|
|
1100
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
1101
|
+
const { loadMethod } = expandOpts
|
|
1102
|
+
if (loadMethod) {
|
|
1103
|
+
const { fullAllDataRowIdData, rowExpandLazyLoadedMaps } = internalData
|
|
1104
|
+
const rowid = getRowid($xeTable, row)
|
|
1105
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
1106
|
+
rowExpandLazyLoadedMaps[rowid] = row
|
|
1107
|
+
loadMethod({ $table: $xeTable, row, rowIndex: $xeTable.getRowIndex(row), $rowIndex: $xeTable.getVMRowIndex(row) }).then(() => {
|
|
1108
|
+
const { rowExpandedMaps } = internalData
|
|
1109
|
+
if (rowRest) {
|
|
1110
|
+
rowRest.expandLoaded = true
|
|
1111
|
+
}
|
|
1112
|
+
rowExpandedMaps[rowid] = row
|
|
1113
|
+
reactData.rowExpandedFlag++
|
|
1114
|
+
}).catch(() => {
|
|
1115
|
+
if (rowRest) {
|
|
1116
|
+
rowRest.expandLoaded = false
|
|
1117
|
+
}
|
|
1118
|
+
}).finally(() => {
|
|
1119
|
+
const { rowExpandLazyLoadedMaps } = internalData
|
|
1120
|
+
if (rowExpandLazyLoadedMaps[rowid]) {
|
|
1121
|
+
delete rowExpandLazyLoadedMaps[rowid]
|
|
1122
|
+
}
|
|
1123
|
+
reactData.rowExpandedFlag++
|
|
1124
|
+
$xeTable.$nextTick()
|
|
1125
|
+
.then(() => $xeTable.recalculate())
|
|
1126
|
+
.then(() => $xeTable.updateCellAreas())
|
|
1127
|
+
.then(() => resolve())
|
|
1128
|
+
})
|
|
1129
|
+
} else {
|
|
1130
|
+
resolve()
|
|
1131
|
+
}
|
|
1132
|
+
})
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1008
1135
|
function calcVarRowHeightConfig ($xeTable: VxeTableConstructor, sizeKey: 'default' | 'medium' | 'small' | 'mini', sizeEl: Element) {
|
|
1009
1136
|
const reactData = $xeTable as unknown as TableReactData
|
|
1010
1137
|
|
|
@@ -1070,12 +1197,13 @@ function handleVirtualYVisible ($xeTable: VxeTableConstructor) {
|
|
|
1070
1197
|
toVisibleIndex = Math.floor(startTop / defaultRowHeight) - 1
|
|
1071
1198
|
visibleSize = Math.ceil(clientHeight / defaultRowHeight) + 1
|
|
1072
1199
|
} else {
|
|
1200
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
1073
1201
|
let leftIndex = 0
|
|
1074
1202
|
let rightIndex = afterFullData.length
|
|
1075
1203
|
while (leftIndex < rightIndex) {
|
|
1076
1204
|
const rIndex = Math.floor((leftIndex + rightIndex) / 2)
|
|
1077
1205
|
const row = afterFullData[rIndex]
|
|
1078
|
-
const rowid =
|
|
1206
|
+
const rowid = handleGetRowId(row)
|
|
1079
1207
|
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
1080
1208
|
if (rowRest.oTop <= startTop) {
|
|
1081
1209
|
leftIndex = rIndex + 1
|
|
@@ -1086,7 +1214,7 @@ function handleVirtualYVisible ($xeTable: VxeTableConstructor) {
|
|
|
1086
1214
|
toVisibleIndex = Math.max(0, leftIndex < afterFullData.length ? leftIndex - 2 : 0)
|
|
1087
1215
|
for (let rIndex = toVisibleIndex, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
|
|
1088
1216
|
const row = afterFullData[rIndex]
|
|
1089
|
-
const rowid =
|
|
1217
|
+
const rowid = handleGetRowId(row)
|
|
1090
1218
|
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
1091
1219
|
visibleSize++
|
|
1092
1220
|
if (rowRest.oTop > endTop || visibleSize >= 100) {
|
|
@@ -1118,16 +1246,20 @@ function calculateMergerOffsetIndex (list: any, offsetItem: any, type: any) {
|
|
|
1118
1246
|
}
|
|
1119
1247
|
}
|
|
1120
1248
|
|
|
1121
|
-
function setMerges (
|
|
1249
|
+
function setMerges ($xeTable: VxeTableConstructor, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[], mList: VxeTableDefines.MergeItem[], rowList?: any[]) {
|
|
1250
|
+
const props = $xeTable
|
|
1251
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1252
|
+
|
|
1122
1253
|
if (merges) {
|
|
1123
|
-
const { treeConfig
|
|
1254
|
+
const { treeConfig } = props
|
|
1255
|
+
const { visibleColumn } = internalData
|
|
1124
1256
|
if (!XEUtils.isArray(merges)) {
|
|
1125
1257
|
merges = [merges]
|
|
1126
1258
|
}
|
|
1127
1259
|
if (treeConfig && merges.length) {
|
|
1128
1260
|
errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
|
|
1129
1261
|
}
|
|
1130
|
-
merges.forEach((item
|
|
1262
|
+
merges.forEach((item) => {
|
|
1131
1263
|
let { row, col, rowspan, colspan } = item
|
|
1132
1264
|
if (rowList && XEUtils.isNumber(row)) {
|
|
1133
1265
|
row = rowList[row]
|
|
@@ -1166,10 +1298,14 @@ function setMerges (_vm: any, merges: any, mList: any, rowList: any) {
|
|
|
1166
1298
|
}
|
|
1167
1299
|
}
|
|
1168
1300
|
|
|
1169
|
-
function removeMerges (
|
|
1301
|
+
function removeMerges ($xeTable: VxeTableConstructor, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[], mList: VxeTableDefines.MergeItem[], rowList?: any) {
|
|
1302
|
+
const props = $xeTable
|
|
1303
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1304
|
+
|
|
1170
1305
|
const rest: any[] = []
|
|
1171
1306
|
if (merges) {
|
|
1172
|
-
const { treeConfig
|
|
1307
|
+
const { treeConfig } = props
|
|
1308
|
+
const { visibleColumn } = internalData
|
|
1173
1309
|
if (!XEUtils.isArray(merges)) {
|
|
1174
1310
|
merges = [merges]
|
|
1175
1311
|
}
|
|
@@ -1352,6 +1488,7 @@ function autoCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
|
|
|
1352
1488
|
internalData.headerHeight = headerHeight
|
|
1353
1489
|
internalData.footerHeight = footerHeight
|
|
1354
1490
|
reactData.overflowX = overflowX
|
|
1491
|
+
reactData.resizeWidthFlag++
|
|
1355
1492
|
updateColumnOffsetLeft($xeTable)
|
|
1356
1493
|
updateHeight($xeTable)
|
|
1357
1494
|
reactData.parentHeight = Math.max(internalData.headerHeight + footerHeight + 20, $xeTable.getParentHeight())
|
|
@@ -1382,8 +1519,9 @@ const calcCellHeight = ($xeTable: VxeTableConstructor) => {
|
|
|
1382
1519
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
1383
1520
|
const el = $xeTable.$refs.refElem as HTMLDivElement
|
|
1384
1521
|
if (!isAllOverflow && scrollYLoad && el) {
|
|
1522
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
1385
1523
|
tableData.forEach(row => {
|
|
1386
|
-
const rowid =
|
|
1524
|
+
const rowid = handleGetRowId(row)
|
|
1387
1525
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
1388
1526
|
if (rowRest) {
|
|
1389
1527
|
const height = calcCellAutoHeight(rowRest, el)
|
|
@@ -1631,10 +1769,11 @@ function hideDropTip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
1631
1769
|
* @param {Event} evnt 事件
|
|
1632
1770
|
* @param {Row} row 行对象
|
|
1633
1771
|
*/
|
|
1634
|
-
function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: MouseEvent, tdEl: HTMLTableCellElement, overflowElem: HTMLElement
|
|
1772
|
+
function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: MouseEvent, tdEl: HTMLTableCellElement, overflowElem: HTMLElement | null, params: any) {
|
|
1635
1773
|
const reactData = $xeTable as unknown as TableReactData
|
|
1636
1774
|
|
|
1637
|
-
|
|
1775
|
+
const tipOverEl = overflowElem || tdEl
|
|
1776
|
+
if (!tipOverEl) {
|
|
1638
1777
|
return $xeTable.$nextTick()
|
|
1639
1778
|
}
|
|
1640
1779
|
params.cell = tdEl
|
|
@@ -1644,9 +1783,8 @@ function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
|
|
|
1644
1783
|
const { showAll, contentMethod } = tooltipOpts
|
|
1645
1784
|
const customContent = contentMethod ? contentMethod(params) : null
|
|
1646
1785
|
const useCustom = contentMethod && !XEUtils.eqNull(customContent)
|
|
1647
|
-
const content = useCustom ? customContent : XEUtils.toString(column.type === 'html' ?
|
|
1648
|
-
|
|
1649
|
-
if (content && (showAll || useCustom || isCellOverflow)) {
|
|
1786
|
+
const content = useCustom ? customContent : XEUtils.toString(column.type === 'html' ? tipOverEl.innerText : tipOverEl.textContent).trim()
|
|
1787
|
+
if (content && (showAll || useCustom || (tipOverEl.scrollWidth > tipOverEl.clientWidth))) {
|
|
1650
1788
|
Object.assign(tooltipStore, {
|
|
1651
1789
|
row,
|
|
1652
1790
|
column,
|
|
@@ -1656,7 +1794,7 @@ function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
|
|
|
1656
1794
|
$xeTable.$nextTick(() => {
|
|
1657
1795
|
const $tooltip = $xeTable.$refs.refTooltip as VxeTooltipInstance
|
|
1658
1796
|
if ($tooltip && $tooltip.open) {
|
|
1659
|
-
$tooltip.open(
|
|
1797
|
+
$tooltip.open(tipOverEl, formatText(content))
|
|
1660
1798
|
}
|
|
1661
1799
|
})
|
|
1662
1800
|
}
|
|
@@ -1845,8 +1983,8 @@ function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, i
|
|
|
1845
1983
|
const reactData = $xeTable as unknown as TableReactData
|
|
1846
1984
|
const internalData = $xeTable as unknown as TableInternalData
|
|
1847
1985
|
|
|
1848
|
-
const { showOverflow } = props
|
|
1849
|
-
const rowOpts = $xeTable.computeRowOpts
|
|
1986
|
+
// const { showOverflow } = props
|
|
1987
|
+
// const rowOpts = $xeTable.computeRowOpts
|
|
1850
1988
|
const leftList: VxeTableDefines.ColumnInfo[] = []
|
|
1851
1989
|
const centerList: VxeTableDefines.ColumnInfo[] = []
|
|
1852
1990
|
const rightList: VxeTableDefines.ColumnInfo[] = []
|
|
@@ -1911,28 +2049,28 @@ function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, i
|
|
|
1911
2049
|
reactData.hasFixedColumn = leftList.length > 0 || rightList.length > 0
|
|
1912
2050
|
Object.assign(columnStore, { leftList, centerList, rightList })
|
|
1913
2051
|
if (scrollXLoad) {
|
|
1914
|
-
if (showOverflow) {
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
}
|
|
1922
|
-
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
}
|
|
2052
|
+
// if (showOverflow) {
|
|
2053
|
+
// if (!rowOpts.height) {
|
|
2054
|
+
// const errColumn = internalData.tableFullColumn.find(column => column.showOverflow === false)
|
|
2055
|
+
// if (errColumn) {
|
|
2056
|
+
// errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true'])
|
|
2057
|
+
// }
|
|
2058
|
+
// }
|
|
2059
|
+
// }
|
|
2060
|
+
// if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
2061
|
+
// if (props.showHeader && !props.showHeaderOverflow) {
|
|
2062
|
+
// warnLog('vxe.error.reqProp', ['show-header-overflow'])
|
|
2063
|
+
// }
|
|
2064
|
+
// if (props.showFooter && !props.showFooterOverflow) {
|
|
2065
|
+
// warnLog('vxe.error.reqProp', ['show-footer-overflow'])
|
|
2066
|
+
// }
|
|
2067
|
+
if (props.spanMethod) {
|
|
2068
|
+
warnLog('vxe.error.scrollErrProp', ['span-method'])
|
|
2069
|
+
}
|
|
2070
|
+
if (props.footerSpanMethod) {
|
|
2071
|
+
warnLog('vxe.error.scrollErrProp', ['footer-span-method'])
|
|
2072
|
+
}
|
|
2073
|
+
// }
|
|
1936
2074
|
if (isReset) {
|
|
1937
2075
|
const { visibleSize } = handleVirtualXVisible($xeTable)
|
|
1938
2076
|
scrollXStore.startIndex = 0
|
|
@@ -2055,6 +2193,39 @@ function loadScrollYData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods
|
|
|
2055
2193
|
}
|
|
2056
2194
|
}
|
|
2057
2195
|
|
|
2196
|
+
const createGetRowCacheProp = (prop: 'seq' | 'index' | '_index' | '$index') => {
|
|
2197
|
+
return function (this: VxeTableConstructor & VxeTablePrivateMethods, row: any) {
|
|
2198
|
+
const $xeTable = this
|
|
2199
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
2200
|
+
|
|
2201
|
+
const { fullAllDataRowIdData } = internalData
|
|
2202
|
+
if (row) {
|
|
2203
|
+
const rowid = getRowid($xeTable, row)
|
|
2204
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
2205
|
+
if (rowRest) {
|
|
2206
|
+
return rowRest[prop]
|
|
2207
|
+
}
|
|
2208
|
+
}
|
|
2209
|
+
return -1
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
const createGetColumnCacheProp = (prop: 'index' | '_index' | '$index') => {
|
|
2214
|
+
return function (this: VxeTableConstructor & VxeTablePrivateMethods, column: VxeTableDefines.ColumnInfo) {
|
|
2215
|
+
const $xeTable = this
|
|
2216
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
2217
|
+
|
|
2218
|
+
const { fullColumnIdData } = internalData
|
|
2219
|
+
if (column) {
|
|
2220
|
+
const colRest = fullColumnIdData[column.id]
|
|
2221
|
+
if (colRest) {
|
|
2222
|
+
return colRest[prop]
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2225
|
+
return -1
|
|
2226
|
+
}
|
|
2227
|
+
}
|
|
2228
|
+
|
|
2058
2229
|
function lazyScrollXData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
2059
2230
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2060
2231
|
|
|
@@ -2221,7 +2392,7 @@ function calcCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
|
|
|
2221
2392
|
|
|
2222
2393
|
function handleUpdateColResize ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: MouseEvent, params: any) {
|
|
2223
2394
|
$xeTable.analyColumnWidth()
|
|
2224
|
-
$xeTable.recalculate(
|
|
2395
|
+
$xeTable.recalculate().then(() => {
|
|
2225
2396
|
$xeTable.saveCustomStore('update:width')
|
|
2226
2397
|
$xeTable.updateCellAreas()
|
|
2227
2398
|
$xeTable.dispatchEvent('column-resizable-change', params, evnt)
|
|
@@ -2235,7 +2406,7 @@ function handleUpdateRowResize ($xeTable: VxeTableConstructor & VxeTablePrivateM
|
|
|
2235
2406
|
const reactData = $xeTable as unknown as TableReactData
|
|
2236
2407
|
|
|
2237
2408
|
reactData.resizeHeightFlag++
|
|
2238
|
-
$xeTable.recalculate(
|
|
2409
|
+
$xeTable.recalculate().then(() => {
|
|
2239
2410
|
$xeTable.updateCellAreas()
|
|
2240
2411
|
$xeTable.dispatchEvent('row-resizable-change', params, evnt)
|
|
2241
2412
|
setTimeout(() => $xeTable.recalculate(true), 300)
|
|
@@ -2260,16 +2431,17 @@ function updateRowOffsetTop ($xeTable: VxeTableConstructor & VxeTablePrivateMeth
|
|
|
2260
2431
|
const reactData = $xeTable as unknown as TableReactData
|
|
2261
2432
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2262
2433
|
|
|
2263
|
-
const { expandColumn
|
|
2264
|
-
const { afterFullData, fullAllDataRowIdData } = internalData
|
|
2434
|
+
const { expandColumn } = reactData
|
|
2435
|
+
const { afterFullData, fullAllDataRowIdData, rowExpandedMaps } = internalData
|
|
2265
2436
|
const expandOpts = $xeTable.computeExpandOpts
|
|
2266
2437
|
const rowOpts = $xeTable.computeRowOpts
|
|
2267
2438
|
const cellOpts = $xeTable.computeCellOpts
|
|
2268
2439
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
2440
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
2269
2441
|
let offsetTop = 0
|
|
2270
2442
|
for (let rIndex = 0, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
|
|
2271
2443
|
const row = afterFullData[rIndex]
|
|
2272
|
-
const rowid =
|
|
2444
|
+
const rowid = handleGetRowId(row)
|
|
2273
2445
|
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
2274
2446
|
rowRest.oTop = offsetTop
|
|
2275
2447
|
offsetTop += rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight
|
|
@@ -2284,46 +2456,42 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
|
|
|
2284
2456
|
const reactData = $xeTable as unknown as TableReactData
|
|
2285
2457
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2286
2458
|
|
|
2287
|
-
const { expandColumn, scrollYLoad,
|
|
2459
|
+
const { expandColumn, scrollYLoad, scrollYTop, isScrollYBig } = reactData
|
|
2288
2460
|
const expandOpts = $xeTable.computeExpandOpts
|
|
2289
2461
|
const rowOpts = $xeTable.computeRowOpts
|
|
2290
2462
|
const cellOpts = $xeTable.computeCellOpts
|
|
2291
2463
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
2292
2464
|
const { mode } = expandOpts
|
|
2293
2465
|
if (expandColumn && mode === 'fixed') {
|
|
2294
|
-
const { elemStore,
|
|
2466
|
+
const { elemStore, fullAllDataRowIdData } = internalData
|
|
2295
2467
|
const rowExpandEl = $xeTable.$refs.refRowExpandElem as HTMLDivElement
|
|
2296
2468
|
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
2297
2469
|
if (rowExpandEl && bodyScrollElem) {
|
|
2298
2470
|
let isUpdateHeight = false
|
|
2299
|
-
if (scrollYLoad) {
|
|
2300
|
-
let offsetTop = 0
|
|
2301
|
-
for (let rIndex = 0, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
|
|
2302
|
-
const row = afterFullData[rIndex]
|
|
2303
|
-
const rowid = getRowid($xeTable, row)
|
|
2304
|
-
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
2305
|
-
rowRest.oTop = offsetTop
|
|
2306
|
-
offsetTop += rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight
|
|
2307
|
-
// 是否展开行
|
|
2308
|
-
if (expandColumn && rowExpandedMaps[rowid]) {
|
|
2309
|
-
offsetTop += rowRest.expandHeight || expandOpts.height || 0
|
|
2310
|
-
}
|
|
2311
|
-
}
|
|
2312
|
-
}
|
|
2313
2471
|
XEUtils.arrayEach(rowExpandEl.children, reEl => {
|
|
2314
2472
|
const expandEl = reEl as HTMLDivElement
|
|
2315
2473
|
const rowid = expandEl.getAttribute('rowid') || ''
|
|
2316
2474
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
2317
2475
|
if (rowRest) {
|
|
2318
2476
|
const expandHeight = expandEl.offsetHeight + 1
|
|
2477
|
+
const trEl = bodyScrollElem.querySelector(`.vxe-body--row[rowid="${rowid}"]`) as HTMLTableCellElement
|
|
2478
|
+
let offsetTop = 0
|
|
2319
2479
|
if (scrollYLoad) {
|
|
2320
|
-
|
|
2480
|
+
if (isScrollYBig && trEl) {
|
|
2481
|
+
offsetTop = trEl.offsetTop + trEl.offsetHeight
|
|
2482
|
+
} else {
|
|
2483
|
+
offsetTop = rowRest.oTop + (rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight)
|
|
2484
|
+
}
|
|
2321
2485
|
} else {
|
|
2322
|
-
const trEl = bodyScrollElem.querySelector(`.vxe-body--row[rowid="${rowid}"]`) as HTMLTableCellElement
|
|
2323
2486
|
if (trEl) {
|
|
2324
|
-
|
|
2487
|
+
offsetTop = trEl.offsetTop + trEl.offsetHeight
|
|
2325
2488
|
}
|
|
2326
2489
|
}
|
|
2490
|
+
if (isScrollYBig) {
|
|
2491
|
+
offsetTop += scrollYTop
|
|
2492
|
+
}
|
|
2493
|
+
expandEl.style.top = toCssUnit(offsetTop)
|
|
2494
|
+
|
|
2327
2495
|
if (!isUpdateHeight) {
|
|
2328
2496
|
if (rowRest.expandHeight !== expandHeight) {
|
|
2329
2497
|
isUpdateHeight = true
|
|
@@ -2334,6 +2502,9 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
|
|
|
2334
2502
|
})
|
|
2335
2503
|
if (isUpdateHeight) {
|
|
2336
2504
|
reactData.rowExpandHeightFlag++
|
|
2505
|
+
$xeTable.$nextTick(() => {
|
|
2506
|
+
updateRowOffsetTop($xeTable)
|
|
2507
|
+
})
|
|
2337
2508
|
}
|
|
2338
2509
|
}
|
|
2339
2510
|
}
|
|
@@ -2352,10 +2523,12 @@ function handleRowExpandScroll ($xeTable: VxeTableConstructor & VxeTablePrivateM
|
|
|
2352
2523
|
|
|
2353
2524
|
const Methods = {
|
|
2354
2525
|
callSlot (slotFunc: any, params: any, h: any, vNodes: any) {
|
|
2526
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2527
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
2528
|
+
|
|
2355
2529
|
if (slotFunc) {
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
return $xegrid.callSlot(slotFunc, params, h, vNodes)
|
|
2530
|
+
if ($xeGrid) {
|
|
2531
|
+
return $xeGrid.callSlot(slotFunc, params, h, vNodes)
|
|
2359
2532
|
}
|
|
2360
2533
|
if (XEUtils.isFunction(slotFunc)) {
|
|
2361
2534
|
return getSlotVNs(slotFunc.call(this, params, h, vNodes))
|
|
@@ -2372,8 +2545,11 @@ const Methods = {
|
|
|
2372
2545
|
* 获取父容器元素
|
|
2373
2546
|
*/
|
|
2374
2547
|
getParentElem () {
|
|
2375
|
-
const
|
|
2376
|
-
|
|
2548
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2549
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
2550
|
+
|
|
2551
|
+
const { $el } = this
|
|
2552
|
+
return $xeGrid ? $xeGrid.$el.parentNode : $el.parentNode
|
|
2377
2553
|
},
|
|
2378
2554
|
/**
|
|
2379
2555
|
* 获取父容器的高度
|
|
@@ -2406,8 +2582,10 @@ const Methods = {
|
|
|
2406
2582
|
* 如果存在表尾合计滚动条,则需要排除滚动条高度
|
|
2407
2583
|
*/
|
|
2408
2584
|
getExcludeHeight () {
|
|
2409
|
-
const
|
|
2410
|
-
|
|
2585
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2586
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
2587
|
+
|
|
2588
|
+
return $xeGrid ? $xeGrid.getExcludeHeight() : 0
|
|
2411
2589
|
},
|
|
2412
2590
|
/**
|
|
2413
2591
|
* 重置表格的一切数据状态
|
|
@@ -2488,6 +2666,9 @@ const Methods = {
|
|
|
2488
2666
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
2489
2667
|
let treeData = []
|
|
2490
2668
|
let fullData = datas ? datas.slice(0) : []
|
|
2669
|
+
if (fullData.length > supportMaxRow) {
|
|
2670
|
+
errLog('vxe.error.errMaxRow', [supportMaxRow])
|
|
2671
|
+
}
|
|
2491
2672
|
if (treeConfig) {
|
|
2492
2673
|
// 树结构自动转换
|
|
2493
2674
|
if (treeOpts.transform) {
|
|
@@ -2732,19 +2913,15 @@ const Methods = {
|
|
|
2732
2913
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2733
2914
|
|
|
2734
2915
|
const { treeConfig } = props
|
|
2735
|
-
const { treeExpandedMaps } =
|
|
2736
|
-
const { fullAllDataRowIdData, tableFullData, tableFullTreeData } = internalData
|
|
2916
|
+
const { fullAllDataRowIdData, tableFullData, tableFullTreeData, treeExpandedMaps } = internalData
|
|
2737
2917
|
const treeOpts = $xeTable.computeTreeOpts
|
|
2738
2918
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
2739
2919
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
2740
2920
|
const { lazy } = treeOpts
|
|
2741
|
-
const rowkey = getRowkey($xeTable)
|
|
2742
|
-
const isDeepKey = rowkey.indexOf('.') > -1
|
|
2743
2921
|
const fullAllDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = { ...fullAllDataRowIdData } // 存在已删除数据
|
|
2744
2922
|
const fullDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = {}
|
|
2745
|
-
const treeTempExpandedMaps = { ...treeExpandedMaps }
|
|
2746
2923
|
|
|
2747
|
-
const
|
|
2924
|
+
const { handleUpdateRowId } = createHandleUpdateRowId($xeTable)
|
|
2748
2925
|
const handleRowCache = (row: any, index: number, items: any, currIndex: number, parentRow: any, rowid: string, level: number, seq: string | number) => {
|
|
2749
2926
|
let rowRest = fullAllDataRowIdMaps[rowid]
|
|
2750
2927
|
if (!rowRest) {
|
|
@@ -2766,15 +2943,14 @@ const Methods = {
|
|
|
2766
2943
|
|
|
2767
2944
|
if (treeConfig) {
|
|
2768
2945
|
XEUtils.eachTree(tableFullTreeData, (row, index, items, path, parentRow, nodes) => {
|
|
2769
|
-
const rowid =
|
|
2946
|
+
const rowid = handleUpdateRowId(row)
|
|
2770
2947
|
if (treeConfig && lazy) {
|
|
2771
|
-
const treeExpRest = treeTempExpandedMaps[rowid]
|
|
2772
2948
|
if (row[hasChildField] && row[childrenField] === undefined) {
|
|
2773
2949
|
row[childrenField] = null
|
|
2774
2950
|
}
|
|
2775
|
-
if (
|
|
2951
|
+
if (treeExpandedMaps[rowid]) {
|
|
2776
2952
|
if (!row[childrenField] || !row[childrenField].length) {
|
|
2777
|
-
delete
|
|
2953
|
+
delete treeExpandedMaps[rowid]
|
|
2778
2954
|
}
|
|
2779
2955
|
}
|
|
2780
2956
|
}
|
|
@@ -2782,13 +2958,13 @@ const Methods = {
|
|
|
2782
2958
|
}, { children: childrenField })
|
|
2783
2959
|
} else {
|
|
2784
2960
|
tableFullData.forEach((row, index, items) => {
|
|
2785
|
-
handleRowCache(row, index, items, index, null,
|
|
2961
|
+
handleRowCache(row, index, items, index, null, handleUpdateRowId(row), 0, index + 1)
|
|
2786
2962
|
})
|
|
2787
2963
|
}
|
|
2788
2964
|
|
|
2789
2965
|
internalData.fullDataRowIdData = fullDataRowIdMaps
|
|
2790
2966
|
internalData.fullAllDataRowIdData = fullAllDataRowIdMaps
|
|
2791
|
-
reactData.
|
|
2967
|
+
reactData.treeExpandedFlag++
|
|
2792
2968
|
},
|
|
2793
2969
|
cacheSourceMap (fullData: any[]) {
|
|
2794
2970
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
@@ -2797,17 +2973,12 @@ const Methods = {
|
|
|
2797
2973
|
|
|
2798
2974
|
const { treeConfig } = props
|
|
2799
2975
|
const treeOpts = $xeTable.computeTreeOpts
|
|
2800
|
-
let { sourceDataRowIdData } = internalData
|
|
2801
2976
|
const sourceData = XEUtils.clone(fullData, true)
|
|
2802
|
-
const
|
|
2803
|
-
|
|
2977
|
+
const { handleUpdateRowId } = createHandleUpdateRowId($xeTable)
|
|
2978
|
+
const sourceRowIdData: Record<string, any> = {}
|
|
2804
2979
|
const handleSourceRow = (row: any) => {
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
rowid = getRowUniqueId()
|
|
2808
|
-
XEUtils.set(row, rowkey, rowid)
|
|
2809
|
-
}
|
|
2810
|
-
sourceDataRowIdData[rowid] = row
|
|
2980
|
+
const rowid = handleUpdateRowId(row)
|
|
2981
|
+
sourceRowIdData[rowid] = row
|
|
2811
2982
|
}
|
|
2812
2983
|
// 源数据缓存
|
|
2813
2984
|
if (treeConfig) {
|
|
@@ -2816,6 +2987,7 @@ const Methods = {
|
|
|
2816
2987
|
} else {
|
|
2817
2988
|
sourceData.forEach(handleSourceRow)
|
|
2818
2989
|
}
|
|
2990
|
+
internalData.sourceDataRowIdData = sourceRowIdData
|
|
2819
2991
|
internalData.tableSourceData = sourceData
|
|
2820
2992
|
},
|
|
2821
2993
|
getParams () {
|
|
@@ -2904,47 +3076,22 @@ const Methods = {
|
|
|
2904
3076
|
* 根据 row 获取序号
|
|
2905
3077
|
* @param {Row} row 行对象
|
|
2906
3078
|
*/
|
|
2907
|
-
getRowSeq (
|
|
2908
|
-
const { fullAllDataRowIdData } = this
|
|
2909
|
-
if (row) {
|
|
2910
|
-
const rowid = getRowid(this, row)
|
|
2911
|
-
const rest = fullAllDataRowIdData[rowid]
|
|
2912
|
-
if (rest) {
|
|
2913
|
-
return rest.seq
|
|
2914
|
-
}
|
|
2915
|
-
}
|
|
2916
|
-
return -1
|
|
2917
|
-
},
|
|
3079
|
+
getRowSeq: createGetRowCacheProp('seq'),
|
|
2918
3080
|
/**
|
|
2919
3081
|
* 根据 row 获取相对于 data 中的索引
|
|
2920
3082
|
* @param {Row} row 行对象
|
|
2921
3083
|
*/
|
|
2922
|
-
getRowIndex (row: any)
|
|
2923
|
-
const { fullAllDataRowIdData } = this
|
|
2924
|
-
if (row) {
|
|
2925
|
-
const rowid = getRowid(this, row)
|
|
2926
|
-
const rest = fullAllDataRowIdData[rowid]
|
|
2927
|
-
if (rest) {
|
|
2928
|
-
return rest.index
|
|
2929
|
-
}
|
|
2930
|
-
}
|
|
2931
|
-
return -1
|
|
2932
|
-
},
|
|
3084
|
+
getRowIndex: createGetRowCacheProp('index') as ((row: any) => number),
|
|
2933
3085
|
/**
|
|
2934
3086
|
* 根据 row 获取相对于当前数据中的索引
|
|
2935
3087
|
* @param {Row} row 行对象
|
|
2936
3088
|
*/
|
|
2937
|
-
getVTRowIndex (row: any)
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
return rest._index
|
|
2944
|
-
}
|
|
2945
|
-
}
|
|
2946
|
-
return -1
|
|
2947
|
-
},
|
|
3089
|
+
getVTRowIndex: createGetRowCacheProp('_index') as ((row: any) => number),
|
|
3090
|
+
/**
|
|
3091
|
+
* 根据 row 获取渲染中的虚拟索引
|
|
3092
|
+
* @param {Row} row 行对象
|
|
3093
|
+
*/
|
|
3094
|
+
getVMRowIndex: createGetRowCacheProp('$index') as ((row: any) => number),
|
|
2948
3095
|
// 在 v3 中废弃
|
|
2949
3096
|
_getRowIndex (row: any) {
|
|
2950
3097
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -2952,21 +3099,6 @@ const Methods = {
|
|
|
2952
3099
|
}
|
|
2953
3100
|
return this.getVTRowIndex(row)
|
|
2954
3101
|
},
|
|
2955
|
-
/**
|
|
2956
|
-
* 根据 row 获取渲染中的虚拟索引
|
|
2957
|
-
* @param {Row} row 行对象
|
|
2958
|
-
*/
|
|
2959
|
-
getVMRowIndex (row: any) {
|
|
2960
|
-
const { fullAllDataRowIdData } = this
|
|
2961
|
-
if (row) {
|
|
2962
|
-
const rowid = getRowid(this, row)
|
|
2963
|
-
const rest = fullAllDataRowIdData[rowid]
|
|
2964
|
-
if (rest) {
|
|
2965
|
-
return rest.$index
|
|
2966
|
-
}
|
|
2967
|
-
}
|
|
2968
|
-
return -1
|
|
2969
|
-
},
|
|
2970
3102
|
// 在 v3 中废弃
|
|
2971
3103
|
$getRowIndex (row: any) {
|
|
2972
3104
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -2978,30 +3110,17 @@ const Methods = {
|
|
|
2978
3110
|
* 根据 column 获取相对于 columns 中的索引
|
|
2979
3111
|
* @param {ColumnInfo} column 列配置
|
|
2980
3112
|
*/
|
|
2981
|
-
getColumnIndex (
|
|
2982
|
-
const { fullColumnIdData } = this
|
|
2983
|
-
if (column) {
|
|
2984
|
-
const rest = fullColumnIdData[column.id]
|
|
2985
|
-
if (rest) {
|
|
2986
|
-
return rest.index
|
|
2987
|
-
}
|
|
2988
|
-
}
|
|
2989
|
-
return -1
|
|
2990
|
-
},
|
|
3113
|
+
getColumnIndex: createGetColumnCacheProp('index'),
|
|
2991
3114
|
/**
|
|
2992
3115
|
* 根据 column 获取相对于当前表格列中的索引
|
|
2993
3116
|
* @param {ColumnInfo} column 列配置
|
|
2994
3117
|
*/
|
|
2995
|
-
getVTColumnIndex (
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
}
|
|
3002
|
-
}
|
|
3003
|
-
return -1
|
|
3004
|
-
},
|
|
3118
|
+
getVTColumnIndex: createGetColumnCacheProp('_index'),
|
|
3119
|
+
/**
|
|
3120
|
+
* 根据 column 获取渲染中的虚拟索引
|
|
3121
|
+
* @param {ColumnInfo} column 列配置
|
|
3122
|
+
*/
|
|
3123
|
+
getVMColumnIndex: createGetColumnCacheProp('$index'),
|
|
3005
3124
|
// 在 v3 中废弃
|
|
3006
3125
|
_getColumnIndex (column: any) {
|
|
3007
3126
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -3009,20 +3128,6 @@ const Methods = {
|
|
|
3009
3128
|
}
|
|
3010
3129
|
return this.getVTColumnIndex(column)
|
|
3011
3130
|
},
|
|
3012
|
-
/**
|
|
3013
|
-
* 根据 column 获取渲染中的虚拟索引
|
|
3014
|
-
* @param {ColumnInfo} column 列配置
|
|
3015
|
-
*/
|
|
3016
|
-
getVMColumnIndex (column: any) {
|
|
3017
|
-
const { fullColumnIdData } = this
|
|
3018
|
-
if (column) {
|
|
3019
|
-
const rest = fullColumnIdData[column.id]
|
|
3020
|
-
if (rest) {
|
|
3021
|
-
return rest.$index
|
|
3022
|
-
}
|
|
3023
|
-
}
|
|
3024
|
-
return -1
|
|
3025
|
-
},
|
|
3026
3131
|
// 在 v3 中废弃
|
|
3027
3132
|
$getColumnIndex (column: any) {
|
|
3028
3133
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -3121,6 +3226,7 @@ const Methods = {
|
|
|
3121
3226
|
const removeTempMaps = { ...editStore.removeMaps }
|
|
3122
3227
|
const treeOpts = $xeTable.computeTreeOpts
|
|
3123
3228
|
const { transform } = treeOpts
|
|
3229
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
3124
3230
|
if (!keepSource) {
|
|
3125
3231
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
3126
3232
|
errLog('vxe.error.reqProp', ['keep-source'])
|
|
@@ -3138,7 +3244,7 @@ const Methods = {
|
|
|
3138
3244
|
let reDelFlag = false
|
|
3139
3245
|
if (targetRows.length) {
|
|
3140
3246
|
targetRows.forEach((item: any) => {
|
|
3141
|
-
const rowid =
|
|
3247
|
+
const rowid = handleGetRowId(item)
|
|
3142
3248
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
3143
3249
|
if (rowRest) {
|
|
3144
3250
|
const row = rowRest.row
|
|
@@ -3531,12 +3637,10 @@ const Methods = {
|
|
|
3531
3637
|
getCheckboxRecords (isFull: boolean) {
|
|
3532
3638
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3533
3639
|
const props = $xeTable
|
|
3534
|
-
const reactData = $xeTable as unknown as TableReactData
|
|
3535
3640
|
const internalData = $xeTable as unknown as TableInternalData
|
|
3536
3641
|
|
|
3537
3642
|
const { treeConfig } = props
|
|
3538
|
-
const { selectCheckboxMaps } =
|
|
3539
|
-
const { tableFullData, afterFullData, afterTreeFullData, tableFullTreeData, fullDataRowIdData, afterFullRowMaps } = internalData
|
|
3643
|
+
const { tableFullData, afterFullData, afterTreeFullData, tableFullTreeData, fullDataRowIdData, afterFullRowMaps, selectCheckboxMaps } = internalData
|
|
3540
3644
|
const treeOpts = $xeTable.computeTreeOpts
|
|
3541
3645
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
3542
3646
|
const { transform, mapChildrenField } = treeOpts
|
|
@@ -3582,7 +3686,7 @@ const Methods = {
|
|
|
3582
3686
|
const treeOpts = $xeTable.computeTreeOpts
|
|
3583
3687
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
3584
3688
|
const { transform, rowField, parentField, mapChildrenField } = treeOpts
|
|
3585
|
-
const { remote: allRemoteFilter, filterMethod: allFilterMethod } = filterOpts
|
|
3689
|
+
const { isEvery, remote: allRemoteFilter, filterMethod: allFilterMethod } = filterOpts
|
|
3586
3690
|
const { remote: allRemoteSort, sortMethod: allSortMethod, multiple: sortMultiple, chronological } = sortOpts
|
|
3587
3691
|
let tableData: any[] = []
|
|
3588
3692
|
let tableTree: any[] = []
|
|
@@ -3644,7 +3748,7 @@ const Methods = {
|
|
|
3644
3748
|
// 筛选虚拟树
|
|
3645
3749
|
tableTree = XEUtils.searchTree(tableFullTreeData, handleFilter, {
|
|
3646
3750
|
original: true,
|
|
3647
|
-
isEvery
|
|
3751
|
+
isEvery,
|
|
3648
3752
|
children: mapChildrenField,
|
|
3649
3753
|
mapChildren: childrenField
|
|
3650
3754
|
})
|
|
@@ -3658,7 +3762,7 @@ const Methods = {
|
|
|
3658
3762
|
// 还原虚拟树
|
|
3659
3763
|
tableTree = XEUtils.searchTree(tableFullTreeData, () => true, {
|
|
3660
3764
|
original: true,
|
|
3661
|
-
isEvery
|
|
3765
|
+
isEvery,
|
|
3662
3766
|
children: mapChildrenField,
|
|
3663
3767
|
mapChildren: childrenField
|
|
3664
3768
|
})
|
|
@@ -3719,7 +3823,7 @@ const Methods = {
|
|
|
3719
3823
|
// 还原虚拟树
|
|
3720
3824
|
tableTree = XEUtils.searchTree(tableFullTreeData, () => true, {
|
|
3721
3825
|
original: true,
|
|
3722
|
-
isEvery
|
|
3826
|
+
isEvery,
|
|
3723
3827
|
children: treeOpts.mapChildrenField,
|
|
3724
3828
|
mapChildren: childrenField
|
|
3725
3829
|
})
|
|
@@ -3873,6 +3977,8 @@ const Methods = {
|
|
|
3873
3977
|
* 默认执行一次,除非被重置
|
|
3874
3978
|
*/
|
|
3875
3979
|
handleLoadDefaults () {
|
|
3980
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3981
|
+
|
|
3876
3982
|
if (this.checkboxConfig) {
|
|
3877
3983
|
this.handleDefaultSelectionChecked()
|
|
3878
3984
|
}
|
|
@@ -3883,7 +3989,7 @@ const Methods = {
|
|
|
3883
3989
|
this.handleDefaultRowExpand()
|
|
3884
3990
|
}
|
|
3885
3991
|
if (this.treeConfig) {
|
|
3886
|
-
|
|
3992
|
+
handleDefaultTreeExpand($xeTable)
|
|
3887
3993
|
}
|
|
3888
3994
|
if (this.mergeCells) {
|
|
3889
3995
|
this.handleDefaultMergeCells()
|
|
@@ -3907,7 +4013,7 @@ const Methods = {
|
|
|
3907
4013
|
* 设置为固定列
|
|
3908
4014
|
*/
|
|
3909
4015
|
setColumnFixed (fieldOrColumn: any, fixed: any) {
|
|
3910
|
-
const $xeTable = this
|
|
4016
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3911
4017
|
|
|
3912
4018
|
let status = false
|
|
3913
4019
|
const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
|
|
@@ -4081,9 +4187,9 @@ const Methods = {
|
|
|
4081
4187
|
return this.refreshColumn(true)
|
|
4082
4188
|
},
|
|
4083
4189
|
handleCustomRestore (storeData: any) {
|
|
4084
|
-
const $
|
|
4085
|
-
const reactData = $
|
|
4086
|
-
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
|
|
4087
4193
|
|
|
4088
4194
|
let { collectColumn } = internalData
|
|
4089
4195
|
const { resizableData, sortData, visibleData, fixedData } = storeData
|
|
@@ -4153,13 +4259,25 @@ const Methods = {
|
|
|
4153
4259
|
}
|
|
4154
4260
|
},
|
|
4155
4261
|
getCustomStoreData () {
|
|
4156
|
-
const
|
|
4157
|
-
const
|
|
4158
|
-
const
|
|
4159
|
-
|
|
4160
|
-
const
|
|
4161
|
-
const
|
|
4162
|
-
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 = {
|
|
4163
4281
|
resizableData: undefined,
|
|
4164
4282
|
sortData: undefined,
|
|
4165
4283
|
visibleData: undefined,
|
|
@@ -4171,46 +4289,36 @@ const Methods = {
|
|
|
4171
4289
|
}
|
|
4172
4290
|
let hasResizable = 0
|
|
4173
4291
|
let hasSort = 0
|
|
4174
|
-
let
|
|
4292
|
+
let hasFixed = 0
|
|
4175
4293
|
let hasVisible = 0
|
|
4176
4294
|
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
4177
|
-
|
|
4178
|
-
if (!
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
if (colKey) {
|
|
4182
|
-
hasSort = 1
|
|
4183
|
-
sortData[colKey] = column.renderSortNumber
|
|
4184
|
-
}
|
|
4185
|
-
})
|
|
4186
|
-
if (column.fixed !== column.defaultFixed) {
|
|
4187
|
-
const colKey = column.getKey()
|
|
4188
|
-
if (colKey) {
|
|
4189
|
-
hasFixedt = 1
|
|
4190
|
-
fixedData[colKey] = column.fixed
|
|
4191
|
-
}
|
|
4192
|
-
}
|
|
4295
|
+
const colKey = column.getKey()
|
|
4296
|
+
if (!colKey) {
|
|
4297
|
+
errLog('vxe.error.reqProp', [`${column.getTitle() || column.type || ''} -> column.field=?`])
|
|
4298
|
+
return
|
|
4193
4299
|
}
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
if (
|
|
4197
|
-
|
|
4198
|
-
|
|
4300
|
+
// 只支持一级
|
|
4301
|
+
if (!parentColumn) {
|
|
4302
|
+
if (isCustomSort) {
|
|
4303
|
+
hasSort = 1
|
|
4304
|
+
sortData[colKey] = column.renderSortNumber
|
|
4305
|
+
}
|
|
4306
|
+
if (isCustomFixed && column.fixed !== column.defaultFixed) {
|
|
4307
|
+
hasFixed = 1
|
|
4308
|
+
fixedData[colKey] = column.fixed
|
|
4199
4309
|
}
|
|
4200
4310
|
}
|
|
4201
|
-
if (
|
|
4311
|
+
if (isCustomResizable && column.resizeWidth) {
|
|
4312
|
+
hasResizable = 1
|
|
4313
|
+
resizableData[colKey] = column.renderWidth
|
|
4314
|
+
}
|
|
4315
|
+
if (isCustomVisible && (!checkMethod || checkMethod({ column }))) {
|
|
4202
4316
|
if (!column.visible && column.defaultVisible) {
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
hasVisible = 1
|
|
4206
|
-
visibleData[colKey] = false
|
|
4207
|
-
}
|
|
4317
|
+
hasVisible = 1
|
|
4318
|
+
visibleData[colKey] = false
|
|
4208
4319
|
} else if (column.visible && !column.defaultVisible) {
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
hasVisible = 1
|
|
4212
|
-
visibleData[colKey] = true
|
|
4213
|
-
}
|
|
4320
|
+
hasVisible = 1
|
|
4321
|
+
visibleData[colKey] = true
|
|
4214
4322
|
}
|
|
4215
4323
|
}
|
|
4216
4324
|
})
|
|
@@ -4220,7 +4328,7 @@ const Methods = {
|
|
|
4220
4328
|
if (hasSort) {
|
|
4221
4329
|
storeData.sortData = sortData
|
|
4222
4330
|
}
|
|
4223
|
-
if (
|
|
4331
|
+
if (hasFixed) {
|
|
4224
4332
|
storeData.fixedData = fixedData
|
|
4225
4333
|
}
|
|
4226
4334
|
if (hasVisible) {
|
|
@@ -4229,9 +4337,9 @@ const Methods = {
|
|
|
4229
4337
|
return storeData
|
|
4230
4338
|
},
|
|
4231
4339
|
saveCustomStore (type: any) {
|
|
4232
|
-
const $xeTable = this
|
|
4340
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
4233
4341
|
const props = $xeTable
|
|
4234
|
-
const reactData = $xeTable as TableReactData
|
|
4342
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
4235
4343
|
|
|
4236
4344
|
const { customConfig } = props
|
|
4237
4345
|
const tableId = $xeTable.computeTableId
|
|
@@ -4709,12 +4817,13 @@ const Methods = {
|
|
|
4709
4817
|
const internalData = $xeTable as unknown as TableInternalData
|
|
4710
4818
|
|
|
4711
4819
|
const { fullAllDataRowIdData, afterFullData } = internalData
|
|
4820
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
4712
4821
|
const rowOpts = $xeTable.computeRowOpts
|
|
4713
4822
|
const cellOpts = $xeTable.computeCellOpts
|
|
4714
4823
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
4715
4824
|
const rest: Record<string, number> = {}
|
|
4716
4825
|
afterFullData.forEach(row => {
|
|
4717
|
-
const rowid =
|
|
4826
|
+
const rowid = handleGetRowId(row)
|
|
4718
4827
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
4719
4828
|
if (rowRest) {
|
|
4720
4829
|
const resizeHeight = rowRest.resizeHeight
|
|
@@ -4742,8 +4851,9 @@ const Methods = {
|
|
|
4742
4851
|
rHeight = Math.floor(rHeight * bodyHeight)
|
|
4743
4852
|
}
|
|
4744
4853
|
if (rHeight) {
|
|
4854
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
4745
4855
|
rows.forEach(row => {
|
|
4746
|
-
const rowid = XEUtils.isString(row) || XEUtils.isNumber(row) ? row :
|
|
4856
|
+
const rowid = XEUtils.isString(row) || XEUtils.isNumber(row) ? row : handleGetRowId(row)
|
|
4747
4857
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
4748
4858
|
if (rowRest) {
|
|
4749
4859
|
rowRest.resizeHeight = rHeight
|
|
@@ -4890,6 +5000,9 @@ const Methods = {
|
|
|
4890
5000
|
}
|
|
4891
5001
|
},
|
|
4892
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
|
+
|
|
4893
5006
|
let evntList = interceptor.get(type)
|
|
4894
5007
|
|
|
4895
5008
|
// 兼容老版本
|
|
@@ -4903,8 +5016,21 @@ const Methods = {
|
|
|
4903
5016
|
}
|
|
4904
5017
|
// 兼容老版本
|
|
4905
5018
|
|
|
4906
|
-
let rest
|
|
4907
|
-
|
|
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) {
|
|
4908
5034
|
if (next) {
|
|
4909
5035
|
rest = next()
|
|
4910
5036
|
}
|
|
@@ -4918,7 +5044,10 @@ const Methods = {
|
|
|
4918
5044
|
* 全局按下事件处理
|
|
4919
5045
|
*/
|
|
4920
5046
|
handleGlobalMousedownEvent (evnt: any) {
|
|
4921
|
-
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
|
|
4922
5051
|
const { actived } = editStore
|
|
4923
5052
|
const { customWrapper, refValidTooltip } = $refs
|
|
4924
5053
|
const tableFilter = $refs.refTableFilter
|
|
@@ -5004,7 +5133,7 @@ const Methods = {
|
|
|
5004
5133
|
}
|
|
5005
5134
|
}
|
|
5006
5135
|
} else if (mouseConfig) {
|
|
5007
|
-
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)) {
|
|
5008
5137
|
if (this.clearSelected) {
|
|
5009
5138
|
this.clearSelected()
|
|
5010
5139
|
}
|
|
@@ -5026,7 +5155,7 @@ const Methods = {
|
|
|
5026
5155
|
if (ctxMenuStore.visible && tableMenu && !getEventTargetNode(evnt, tableMenu.$el).flag) {
|
|
5027
5156
|
this.closeMenu()
|
|
5028
5157
|
}
|
|
5029
|
-
const isActivated = getEventTargetNode(evnt, ($
|
|
5158
|
+
const isActivated = getEventTargetNode(evnt, ($xeGrid || this).$el).flag
|
|
5030
5159
|
// 如果存在校验,点击了表格之外则清除
|
|
5031
5160
|
if (!isActivated && editRules && validOpts.autoClear) {
|
|
5032
5161
|
this.validErrorMaps = {}
|
|
@@ -5087,8 +5216,9 @@ const Methods = {
|
|
|
5087
5216
|
* 全局键盘事件
|
|
5088
5217
|
*/
|
|
5089
5218
|
handleGlobalKeydownEvent (evnt: any) {
|
|
5090
|
-
const $xeTable = this
|
|
5091
|
-
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
|
|
5092
5222
|
|
|
5093
5223
|
// 该行为只对当前激活的表格有效
|
|
5094
5224
|
if (this.isActivated) {
|
|
@@ -5179,7 +5309,7 @@ const Methods = {
|
|
|
5179
5309
|
if (keyboardOpts.enterToTab) {
|
|
5180
5310
|
this.moveTabSelected(activeParams, hasShiftKey, evnt)
|
|
5181
5311
|
} else {
|
|
5182
|
-
this.
|
|
5312
|
+
this.moveEnterSelected(activeParams, isLeftArrow, true, isRightArrow, false, evnt)
|
|
5183
5313
|
}
|
|
5184
5314
|
} else {
|
|
5185
5315
|
if (keyboardOpts.enterToTab) {
|
|
@@ -5211,7 +5341,7 @@ const Methods = {
|
|
|
5211
5341
|
return
|
|
5212
5342
|
}
|
|
5213
5343
|
}
|
|
5214
|
-
this.
|
|
5344
|
+
this.moveEnterSelected(activeParams, isLeftArrow, false, isRightArrow, true, evnt)
|
|
5215
5345
|
if (enterMethod) {
|
|
5216
5346
|
enterMethod(etrParams)
|
|
5217
5347
|
}
|
|
@@ -5235,10 +5365,7 @@ const Methods = {
|
|
|
5235
5365
|
if (!isEditStatus) {
|
|
5236
5366
|
// 如果按下了方向键
|
|
5237
5367
|
if (selected.row && selected.column) {
|
|
5238
|
-
|
|
5239
|
-
} else if ((isUpArrow || isDwArrow) && (rowOpts.isCurrent || highlightCurrentRow)) {
|
|
5240
|
-
// 当前行按键上下移动
|
|
5241
|
-
this.moveCurrentRow(isUpArrow, isDwArrow, evnt)
|
|
5368
|
+
$xeTable.moveArrowSelected(selected.args, isLeftArrow, isUpArrow, isRightArrow, isDwArrow, evnt)
|
|
5242
5369
|
}
|
|
5243
5370
|
}
|
|
5244
5371
|
} else if (isTab && keyboardConfig && keyboardOpts.isTab) {
|
|
@@ -5258,7 +5385,7 @@ const Methods = {
|
|
|
5258
5385
|
column: selected.column,
|
|
5259
5386
|
columnIndex: this.getColumnIndex(selected.column),
|
|
5260
5387
|
$table: this,
|
|
5261
|
-
$grid:
|
|
5388
|
+
$grid: $xeGrid
|
|
5262
5389
|
}
|
|
5263
5390
|
// 是否被禁用
|
|
5264
5391
|
if (!beforeEditMethod || beforeEditMethod(params)) {
|
|
@@ -5283,7 +5410,7 @@ const Methods = {
|
|
|
5283
5410
|
column: selected.column,
|
|
5284
5411
|
columnIndex: this.getColumnIndex(selected.column),
|
|
5285
5412
|
$table: this,
|
|
5286
|
-
$grid:
|
|
5413
|
+
$grid: $xeGrid
|
|
5287
5414
|
}
|
|
5288
5415
|
// 是否被禁用
|
|
5289
5416
|
if (!beforeEditMethod || beforeEditMethod(params)) {
|
|
@@ -5310,7 +5437,7 @@ const Methods = {
|
|
|
5310
5437
|
rowIndex: this.getRowIndex(parentRow),
|
|
5311
5438
|
$rowIndex: this.getVMRowIndex(parentRow),
|
|
5312
5439
|
$table: this,
|
|
5313
|
-
$grid:
|
|
5440
|
+
$grid: $xeGrid
|
|
5314
5441
|
}
|
|
5315
5442
|
this.setTreeExpand(parentRow, false)
|
|
5316
5443
|
.then(() => this.scrollToRow(parentRow))
|
|
@@ -5331,7 +5458,7 @@ const Methods = {
|
|
|
5331
5458
|
column: selected.column,
|
|
5332
5459
|
columnIndex: this.getColumnIndex(selected.column),
|
|
5333
5460
|
$table: this,
|
|
5334
|
-
$grid:
|
|
5461
|
+
$grid: $xeGrid
|
|
5335
5462
|
}
|
|
5336
5463
|
if (!beforeEditMethod || beforeEditMethod(params)) {
|
|
5337
5464
|
if (editMethod) {
|
|
@@ -5453,7 +5580,7 @@ const Methods = {
|
|
|
5453
5580
|
return
|
|
5454
5581
|
}
|
|
5455
5582
|
if (tooltipStore.column !== column || !tooltipStore.visible) {
|
|
5456
|
-
handleTooltip($xeTable, evnt, thEl, cellEl,
|
|
5583
|
+
handleTooltip($xeTable, evnt, thEl, thEl.querySelector<HTMLElement>('.vxe-cell--title') || cellEl, params)
|
|
5457
5584
|
}
|
|
5458
5585
|
},
|
|
5459
5586
|
/**
|
|
@@ -5484,7 +5611,7 @@ const Methods = {
|
|
|
5484
5611
|
}
|
|
5485
5612
|
}
|
|
5486
5613
|
if (tooltipStore.column !== column || tooltipStore.row !== row || !tooltipStore.visible) {
|
|
5487
|
-
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)
|
|
5488
5615
|
}
|
|
5489
5616
|
},
|
|
5490
5617
|
/**
|
|
@@ -5496,10 +5623,10 @@ const Methods = {
|
|
|
5496
5623
|
|
|
5497
5624
|
const { column } = params
|
|
5498
5625
|
const { tooltipStore } = reactData
|
|
5499
|
-
const
|
|
5626
|
+
const tdEl = evnt.currentTarget as HTMLTableCellElement
|
|
5500
5627
|
handleTargetEnterEvent($xeTable, tooltipStore.column !== column || !!tooltipStore.row)
|
|
5501
5628
|
if (tooltipStore.column !== column || !tooltipStore.visible) {
|
|
5502
|
-
handleTooltip($xeTable, evnt,
|
|
5629
|
+
handleTooltip($xeTable, evnt, tdEl, tdEl.querySelector<HTMLElement>('.vxe-cell--label') || tdEl.querySelector('.vxe-cell--wrapper') as HTMLElement, params)
|
|
5503
5630
|
}
|
|
5504
5631
|
},
|
|
5505
5632
|
openTooltip (target: any, content: any) {
|
|
@@ -5557,11 +5684,16 @@ const Methods = {
|
|
|
5557
5684
|
* 获取复选框半选状态的行数据
|
|
5558
5685
|
*/
|
|
5559
5686
|
getCheckboxIndeterminateRecords (isFull: any) {
|
|
5560
|
-
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
|
|
5561
5693
|
if (treeConfig) {
|
|
5562
5694
|
const fullRest: any[] = []
|
|
5563
5695
|
const defRest: any[] = []
|
|
5564
|
-
XEUtils.each(
|
|
5696
|
+
XEUtils.each(treeIndeterminateRowMaps, (item, rowid) => {
|
|
5565
5697
|
if (item) {
|
|
5566
5698
|
fullRest.push(item)
|
|
5567
5699
|
if (fullDataRowIdData[rowid]) {
|
|
@@ -5616,7 +5748,7 @@ const Methods = {
|
|
|
5616
5748
|
},
|
|
5617
5749
|
setCheckboxRowKey (keys: any, checked: boolean) {
|
|
5618
5750
|
const $xeTable = this
|
|
5619
|
-
const internalData = $xeTable
|
|
5751
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5620
5752
|
|
|
5621
5753
|
const { fullAllDataRowIdData } = internalData
|
|
5622
5754
|
if (keys && !XEUtils.isArray(keys)) {
|
|
@@ -5633,23 +5765,25 @@ const Methods = {
|
|
|
5633
5765
|
},
|
|
5634
5766
|
isCheckedByCheckboxRow (row: any) {
|
|
5635
5767
|
const $xeTable = this
|
|
5636
|
-
const reactData = $xeTable
|
|
5768
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
5769
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5637
5770
|
|
|
5638
|
-
const {
|
|
5771
|
+
const { updateCheckboxFlag } = reactData
|
|
5772
|
+
const { selectCheckboxMaps } = internalData
|
|
5639
5773
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5640
5774
|
const { checkField } = checkboxOpts
|
|
5641
5775
|
if (checkField) {
|
|
5642
5776
|
return XEUtils.get(row, checkField)
|
|
5643
5777
|
}
|
|
5644
|
-
return !!selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5778
|
+
return !!updateCheckboxFlag && !!selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5645
5779
|
},
|
|
5646
5780
|
isCheckedByCheckboxRowKey (rowid: string) {
|
|
5647
|
-
const $xeTable = this
|
|
5648
|
-
const reactData = $xeTable
|
|
5649
|
-
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
|
|
5650
5784
|
|
|
5651
|
-
const {
|
|
5652
|
-
const { fullAllDataRowIdData } = internalData
|
|
5785
|
+
const { updateCheckboxFlag } = reactData
|
|
5786
|
+
const { fullAllDataRowIdData, selectCheckboxMaps } = internalData
|
|
5653
5787
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5654
5788
|
const { checkField } = checkboxOpts
|
|
5655
5789
|
if (checkField) {
|
|
@@ -5659,21 +5793,21 @@ const Methods = {
|
|
|
5659
5793
|
}
|
|
5660
5794
|
return false
|
|
5661
5795
|
}
|
|
5662
|
-
return !!selectCheckboxMaps[rowid]
|
|
5796
|
+
return !!updateCheckboxFlag && !!selectCheckboxMaps[rowid]
|
|
5663
5797
|
},
|
|
5664
5798
|
isIndeterminateByCheckboxRow (row: any) {
|
|
5665
|
-
const $xeTable = this
|
|
5666
|
-
const
|
|
5799
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5800
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5667
5801
|
|
|
5668
|
-
const {
|
|
5669
|
-
return !!
|
|
5802
|
+
const { treeIndeterminateRowMaps } = internalData
|
|
5803
|
+
return !!treeIndeterminateRowMaps[getRowid($xeTable, row)] && !$xeTable.isCheckedByCheckboxRow(row)
|
|
5670
5804
|
},
|
|
5671
5805
|
isIndeterminateByCheckboxRowKey (rowid: string) {
|
|
5672
5806
|
const $xeTable = this
|
|
5673
|
-
const
|
|
5807
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5674
5808
|
|
|
5675
|
-
const {
|
|
5676
|
-
return !!
|
|
5809
|
+
const { treeIndeterminateRowMaps } = internalData
|
|
5810
|
+
return !!treeIndeterminateRowMaps[rowid] && !$xeTable.isCheckedByCheckboxRowKey(rowid)
|
|
5677
5811
|
},
|
|
5678
5812
|
/**
|
|
5679
5813
|
* 切换选中
|
|
@@ -5683,15 +5817,16 @@ const Methods = {
|
|
|
5683
5817
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5684
5818
|
const props = $xeTable
|
|
5685
5819
|
const reactData = $xeTable as unknown as TableReactData
|
|
5820
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5686
5821
|
|
|
5687
5822
|
const { treeConfig } = props
|
|
5688
|
-
const { selectCheckboxMaps } =
|
|
5689
|
-
const selectRowMaps = Object.assign({}, selectCheckboxMaps)
|
|
5823
|
+
const { selectCheckboxMaps } = internalData
|
|
5690
5824
|
const treeOpts = $xeTable.computeTreeOpts
|
|
5691
5825
|
const { transform, mapChildrenField } = treeOpts
|
|
5692
5826
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
5693
5827
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5694
5828
|
const { checkField, checkStrictly, checkMethod } = checkboxOpts
|
|
5829
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
5695
5830
|
// indeterminateField 仅支持读取
|
|
5696
5831
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
5697
5832
|
if (checkField) {
|
|
@@ -5707,18 +5842,17 @@ const Methods = {
|
|
|
5707
5842
|
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5708
5843
|
}
|
|
5709
5844
|
}, { children: transform ? mapChildrenField : childrenField })
|
|
5710
|
-
reactData.
|
|
5845
|
+
reactData.updateCheckboxFlag++
|
|
5711
5846
|
return
|
|
5712
|
-
} else {
|
|
5713
|
-
// 列表
|
|
5714
|
-
rows.forEach(row => {
|
|
5715
|
-
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5716
|
-
XEUtils.set(row, checkField, checked)
|
|
5717
|
-
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5718
|
-
}
|
|
5719
|
-
})
|
|
5720
5847
|
}
|
|
5721
|
-
|
|
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++
|
|
5722
5856
|
return
|
|
5723
5857
|
}
|
|
5724
5858
|
|
|
@@ -5726,51 +5860,55 @@ const Methods = {
|
|
|
5726
5860
|
if (treeConfig && !checkStrictly) {
|
|
5727
5861
|
// 更新子节点状态
|
|
5728
5862
|
XEUtils.eachTree(rows, (row) => {
|
|
5729
|
-
const rowid =
|
|
5863
|
+
const rowid = handleGetRowId(row)
|
|
5730
5864
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5731
5865
|
if (checked) {
|
|
5732
|
-
|
|
5866
|
+
selectCheckboxMaps[rowid] = row
|
|
5733
5867
|
} else {
|
|
5734
|
-
if (
|
|
5735
|
-
delete
|
|
5868
|
+
if (selectCheckboxMaps[rowid]) {
|
|
5869
|
+
delete selectCheckboxMaps[rowid]
|
|
5736
5870
|
}
|
|
5737
5871
|
}
|
|
5738
5872
|
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5739
5873
|
}
|
|
5740
5874
|
}, { children: transform ? mapChildrenField : childrenField })
|
|
5741
|
-
reactData.
|
|
5875
|
+
reactData.updateCheckboxFlag++
|
|
5742
5876
|
return
|
|
5743
5877
|
}
|
|
5744
5878
|
|
|
5745
5879
|
// 列表
|
|
5746
5880
|
rows.forEach(row => {
|
|
5747
|
-
const rowid =
|
|
5881
|
+
const rowid = handleGetRowId(row)
|
|
5748
5882
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5749
5883
|
if (checked) {
|
|
5750
|
-
if (!
|
|
5751
|
-
|
|
5884
|
+
if (!selectCheckboxMaps[rowid]) {
|
|
5885
|
+
selectCheckboxMaps[rowid] = row
|
|
5752
5886
|
}
|
|
5753
5887
|
} else {
|
|
5754
|
-
if (
|
|
5755
|
-
delete
|
|
5888
|
+
if (selectCheckboxMaps[rowid]) {
|
|
5889
|
+
delete selectCheckboxMaps[rowid]
|
|
5756
5890
|
}
|
|
5757
5891
|
}
|
|
5758
5892
|
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5893
|
+
reactData.updateCheckboxFlag++
|
|
5759
5894
|
}
|
|
5760
5895
|
})
|
|
5761
|
-
reactData.selectCheckboxMaps = selectRowMaps
|
|
5762
5896
|
},
|
|
5763
5897
|
/**
|
|
5764
5898
|
* 即将移除
|
|
5765
5899
|
* @deprecated
|
|
5766
5900
|
*/
|
|
5767
5901
|
handleSelectRow ({ row }: any, checked: boolean, isForce?: boolean) {
|
|
5768
|
-
const $xeTable = this
|
|
5902
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5769
5903
|
|
|
5770
5904
|
$xeTable.handleBatchSelectRows([row], checked, isForce)
|
|
5771
5905
|
},
|
|
5772
5906
|
handleToggleCheckRowEvent (evnt: any, params: any) {
|
|
5773
|
-
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
|
|
5774
5912
|
const { checkField, trigger } = checkboxOpts
|
|
5775
5913
|
const { row } = params
|
|
5776
5914
|
if (trigger === 'manual') {
|
|
@@ -5780,47 +5918,52 @@ const Methods = {
|
|
|
5780
5918
|
if (checkField) {
|
|
5781
5919
|
checked = !XEUtils.get(row, checkField)
|
|
5782
5920
|
} else {
|
|
5783
|
-
checked = !selectCheckboxMaps[getRowid(
|
|
5921
|
+
checked = !selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5784
5922
|
}
|
|
5785
5923
|
if (evnt) {
|
|
5786
|
-
|
|
5924
|
+
$xeTable.triggerCheckRowEvent(evnt, params, checked)
|
|
5787
5925
|
} else {
|
|
5788
|
-
|
|
5789
|
-
|
|
5926
|
+
$xeTable.handleBatchSelectRows([row], checked)
|
|
5927
|
+
$xeTable.checkSelectionStatus()
|
|
5790
5928
|
}
|
|
5791
5929
|
},
|
|
5792
5930
|
triggerCheckRowEvent (evnt: any, params: any, checked: any) {
|
|
5793
|
-
const $xeTable = this
|
|
5931
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5932
|
+
const props = $xeTable
|
|
5933
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5794
5934
|
|
|
5795
|
-
const { checkboxOpts, afterFullData } = this
|
|
5796
|
-
const { checkMethod, trigger } = checkboxOpts
|
|
5797
5935
|
const { row } = params
|
|
5936
|
+
const { afterFullData } = internalData
|
|
5937
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5938
|
+
const { checkMethod, trigger } = checkboxOpts
|
|
5798
5939
|
if (trigger === 'manual') {
|
|
5799
5940
|
return
|
|
5800
5941
|
}
|
|
5801
5942
|
evnt.stopPropagation()
|
|
5802
|
-
if (checkboxOpts.isShiftKey && evnt.shiftKey && !
|
|
5803
|
-
const checkboxRecords =
|
|
5943
|
+
if (checkboxOpts.isShiftKey && evnt.shiftKey && !props.treeConfig) {
|
|
5944
|
+
const checkboxRecords = $xeTable.getCheckboxRecords()
|
|
5804
5945
|
if (checkboxRecords.length) {
|
|
5805
5946
|
const firstRow = checkboxRecords[0]
|
|
5806
|
-
const _rowIndex =
|
|
5807
|
-
const _firstRowIndex =
|
|
5947
|
+
const _rowIndex = $xeTable.getVTRowIndex(row)
|
|
5948
|
+
const _firstRowIndex = $xeTable.getVTRowIndex(firstRow)
|
|
5808
5949
|
if (_rowIndex !== _firstRowIndex) {
|
|
5809
|
-
|
|
5950
|
+
$xeTable.setAllCheckboxRow(false)
|
|
5810
5951
|
const rangeRows = _rowIndex < _firstRowIndex ? afterFullData.slice(_rowIndex, _firstRowIndex + 1) : afterFullData.slice(_firstRowIndex, _rowIndex + 1)
|
|
5811
|
-
|
|
5812
|
-
|
|
5952
|
+
$xeTable.$nextTick(() => {
|
|
5953
|
+
handleCheckedCheckboxRow($xeTable, rangeRows, true, false)
|
|
5954
|
+
})
|
|
5955
|
+
$xeTable.dispatchEvent('checkbox-range-select', Object.assign({ rangeRecords: rangeRows }, params), evnt)
|
|
5813
5956
|
return
|
|
5814
5957
|
}
|
|
5815
5958
|
}
|
|
5816
5959
|
}
|
|
5817
5960
|
if (!checkMethod || checkMethod({ row })) {
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
records:
|
|
5822
|
-
reserves:
|
|
5823
|
-
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(),
|
|
5824
5967
|
checked
|
|
5825
5968
|
}, params), evnt)
|
|
5826
5969
|
}
|
|
@@ -5829,9 +5972,11 @@ const Methods = {
|
|
|
5829
5972
|
* 多选,切换某一行的选中状态
|
|
5830
5973
|
*/
|
|
5831
5974
|
toggleCheckboxRow (row: any) {
|
|
5832
|
-
const $xeTable = this
|
|
5975
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5976
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5833
5977
|
|
|
5834
|
-
const { selectCheckboxMaps
|
|
5978
|
+
const { selectCheckboxMaps } = internalData
|
|
5979
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5835
5980
|
const { checkField } = checkboxOpts
|
|
5836
5981
|
const checked = checkField ? !XEUtils.get(row, checkField) : !selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5837
5982
|
$xeTable.handleBatchSelectRows([row], checked, true)
|
|
@@ -5854,9 +5999,7 @@ const Methods = {
|
|
|
5854
5999
|
const internalData = $xeTable as unknown as TableInternalData
|
|
5855
6000
|
|
|
5856
6001
|
const { treeConfig } = props
|
|
5857
|
-
const { selectCheckboxMaps,
|
|
5858
|
-
const selectRowMaps = Object.assign({}, selectCheckboxMaps)
|
|
5859
|
-
const halfRowMaps = Object.assign({}, treeIndeterminateMaps)
|
|
6002
|
+
const { selectCheckboxMaps, treeIndeterminateRowMaps } = internalData
|
|
5860
6003
|
const treeOpts = $xeTable.computeTreeOpts
|
|
5861
6004
|
const { transform, mapChildrenField } = treeOpts
|
|
5862
6005
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
@@ -5868,10 +6011,11 @@ const Methods = {
|
|
|
5868
6011
|
}
|
|
5869
6012
|
// 树结构
|
|
5870
6013
|
if (treeConfig) {
|
|
6014
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
5871
6015
|
const childRowMaps: Record<string, number> = {}
|
|
5872
6016
|
const childRowList: any[][] = []
|
|
5873
6017
|
XEUtils.eachTree(afterTreeFullData, (row: any) => {
|
|
5874
|
-
const rowid =
|
|
6018
|
+
const rowid = handleGetRowId(row)
|
|
5875
6019
|
const childList = row[transform ? mapChildrenField : childrenField]
|
|
5876
6020
|
if (childList && childList.length && !childRowMaps[rowid]) {
|
|
5877
6021
|
childRowMaps[rowid] = 1
|
|
@@ -5888,29 +6032,29 @@ const Methods = {
|
|
|
5888
6032
|
childList.forEach(
|
|
5889
6033
|
checkMethod
|
|
5890
6034
|
? (item) => {
|
|
5891
|
-
const childRowid =
|
|
5892
|
-
const isSelect = checkField ? XEUtils.get(item, checkField) :
|
|
6035
|
+
const childRowid = handleGetRowId(item)
|
|
6036
|
+
const isSelect = checkField ? XEUtils.get(item, checkField) : selectCheckboxMaps[childRowid]
|
|
5893
6037
|
if (checkMethod({ row: item })) {
|
|
5894
6038
|
if (isSelect) {
|
|
5895
6039
|
sLen++
|
|
5896
|
-
} else if (
|
|
6040
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5897
6041
|
hLen++
|
|
5898
6042
|
}
|
|
5899
6043
|
vLen++
|
|
5900
6044
|
} else {
|
|
5901
6045
|
if (isSelect) {
|
|
5902
6046
|
sLen++
|
|
5903
|
-
} else if (
|
|
6047
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5904
6048
|
hLen++
|
|
5905
6049
|
}
|
|
5906
6050
|
}
|
|
5907
6051
|
}
|
|
5908
6052
|
: item => {
|
|
5909
|
-
const childRowid =
|
|
5910
|
-
const isSelect = checkField ? XEUtils.get(item, checkField) :
|
|
6053
|
+
const childRowid = handleGetRowId(item)
|
|
6054
|
+
const isSelect = checkField ? XEUtils.get(item, checkField) : selectCheckboxMaps[childRowid]
|
|
5911
6055
|
if (isSelect) {
|
|
5912
6056
|
sLen++
|
|
5913
|
-
} else if (
|
|
6057
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5914
6058
|
hLen++
|
|
5915
6059
|
}
|
|
5916
6060
|
vLen++
|
|
@@ -5923,29 +6067,28 @@ const Methods = {
|
|
|
5923
6067
|
}
|
|
5924
6068
|
if (isSelected) {
|
|
5925
6069
|
if (!checkField) {
|
|
5926
|
-
|
|
6070
|
+
selectCheckboxMaps[rowid] = row
|
|
5927
6071
|
}
|
|
5928
|
-
if (
|
|
5929
|
-
delete
|
|
6072
|
+
if (treeIndeterminateRowMaps[rowid]) {
|
|
6073
|
+
delete treeIndeterminateRowMaps[rowid]
|
|
5930
6074
|
}
|
|
5931
6075
|
} else {
|
|
5932
6076
|
if (!checkField) {
|
|
5933
|
-
if (
|
|
5934
|
-
delete
|
|
6077
|
+
if (selectCheckboxMaps[rowid]) {
|
|
6078
|
+
delete selectCheckboxMaps[rowid]
|
|
5935
6079
|
}
|
|
5936
6080
|
}
|
|
5937
6081
|
if (halfSelect) {
|
|
5938
|
-
|
|
6082
|
+
treeIndeterminateRowMaps[rowid] = row
|
|
5939
6083
|
} else {
|
|
5940
|
-
if (
|
|
5941
|
-
delete
|
|
6084
|
+
if (treeIndeterminateRowMaps[rowid]) {
|
|
6085
|
+
delete treeIndeterminateRowMaps[rowid]
|
|
5942
6086
|
}
|
|
5943
6087
|
}
|
|
5944
6088
|
}
|
|
5945
6089
|
})
|
|
5946
6090
|
}
|
|
5947
|
-
reactData.
|
|
5948
|
-
reactData.treeIndeterminateMaps = halfRowMaps
|
|
6091
|
+
reactData.updateCheckboxFlag++
|
|
5949
6092
|
},
|
|
5950
6093
|
updateAllCheckboxStatus () {
|
|
5951
6094
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
@@ -5954,10 +6097,10 @@ const Methods = {
|
|
|
5954
6097
|
const internalData = $xeTable as unknown as TableInternalData
|
|
5955
6098
|
|
|
5956
6099
|
const { treeConfig } = props
|
|
5957
|
-
const { selectCheckboxMaps,
|
|
6100
|
+
const { afterFullData, afterTreeFullData, checkboxReserveRowMap, selectCheckboxMaps, treeIndeterminateRowMaps } = internalData
|
|
5958
6101
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5959
6102
|
const { checkField, checkMethod, showReserveStatus } = checkboxOpts
|
|
5960
|
-
const {
|
|
6103
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
5961
6104
|
|
|
5962
6105
|
let sLen = 0 // 已选
|
|
5963
6106
|
let hLen = 0 // 半选
|
|
@@ -5966,29 +6109,29 @@ const Methods = {
|
|
|
5966
6109
|
const rootList: any[] = (treeConfig ? afterTreeFullData : afterFullData)
|
|
5967
6110
|
rootList.forEach(checkMethod
|
|
5968
6111
|
? row => {
|
|
5969
|
-
const childRowid =
|
|
6112
|
+
const childRowid = handleGetRowId(row)
|
|
5970
6113
|
const selected = checkField ? XEUtils.get(row, checkField) : selectCheckboxMaps[childRowid]
|
|
5971
6114
|
if (checkMethod({ row })) {
|
|
5972
6115
|
if (selected) {
|
|
5973
6116
|
sLen++
|
|
5974
|
-
} else if (
|
|
6117
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5975
6118
|
hLen++
|
|
5976
6119
|
}
|
|
5977
6120
|
vLen++
|
|
5978
6121
|
} else {
|
|
5979
6122
|
if (selected) {
|
|
5980
6123
|
sLen++
|
|
5981
|
-
} else if (
|
|
6124
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5982
6125
|
hLen++
|
|
5983
6126
|
}
|
|
5984
6127
|
}
|
|
5985
6128
|
}
|
|
5986
6129
|
: row => {
|
|
5987
|
-
const childRowid =
|
|
6130
|
+
const childRowid = handleGetRowId(row)
|
|
5988
6131
|
const selected = checkField ? XEUtils.get(row, checkField) : selectCheckboxMaps[childRowid]
|
|
5989
6132
|
if (selected) {
|
|
5990
6133
|
sLen++
|
|
5991
|
-
} else if (
|
|
6134
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5992
6135
|
hLen++
|
|
5993
6136
|
}
|
|
5994
6137
|
vLen++
|
|
@@ -6047,18 +6190,26 @@ const Methods = {
|
|
|
6047
6190
|
* 获取复选框保留选中的行
|
|
6048
6191
|
*/
|
|
6049
6192
|
getCheckboxReserveRecords (isFull: any) {
|
|
6050
|
-
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
|
|
6051
6201
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
6052
6202
|
const reserveSelection: any[] = []
|
|
6053
6203
|
if (checkboxOpts.reserve) {
|
|
6054
|
-
const
|
|
6204
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
6205
|
+
const afterFullIdMaps: { [key: string]: number } = {}
|
|
6055
6206
|
if (treeConfig) {
|
|
6056
6207
|
XEUtils.eachTree(afterFullData, row => {
|
|
6057
|
-
afterFullIdMaps[
|
|
6208
|
+
afterFullIdMaps[handleGetRowId(row)] = 1
|
|
6058
6209
|
}, { children: childrenField })
|
|
6059
6210
|
} else {
|
|
6060
6211
|
afterFullData.forEach((row: any) => {
|
|
6061
|
-
afterFullIdMaps[
|
|
6212
|
+
afterFullIdMaps[handleGetRowId(row)] = 1
|
|
6062
6213
|
})
|
|
6063
6214
|
}
|
|
6064
6215
|
XEUtils.each(checkboxReserveRowMap, (oldRow, oldRowid) => {
|
|
@@ -6098,9 +6249,9 @@ const Methods = {
|
|
|
6098
6249
|
handleCheckedAllCheckboxRow($xeTable, value)
|
|
6099
6250
|
if (evnt) {
|
|
6100
6251
|
$xeTable.dispatchEvent('checkbox-all', {
|
|
6101
|
-
records: $xeTable.getCheckboxRecords(),
|
|
6102
|
-
reserves: $xeTable.getCheckboxReserveRecords(),
|
|
6103
|
-
indeterminates: $xeTable.getCheckboxIndeterminateRecords(),
|
|
6252
|
+
records: () => $xeTable.getCheckboxRecords(),
|
|
6253
|
+
reserves: () => $xeTable.getCheckboxReserveRecords(),
|
|
6254
|
+
indeterminates: () => $xeTable.getCheckboxIndeterminateRecords(),
|
|
6104
6255
|
checked: value
|
|
6105
6256
|
}, evnt)
|
|
6106
6257
|
}
|
|
@@ -6133,9 +6284,17 @@ const Methods = {
|
|
|
6133
6284
|
* 清空行为不管是否被禁用还是保留记录,都将彻底清空选中状态
|
|
6134
6285
|
*/
|
|
6135
6286
|
clearCheckboxRow () {
|
|
6136
|
-
const
|
|
6137
|
-
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
|
|
6138
6295
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
6296
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
6297
|
+
const { checkField, reserve } = checkboxOpts
|
|
6139
6298
|
// indeterminateField 仅支持读取
|
|
6140
6299
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
6141
6300
|
if (checkField) {
|
|
@@ -6152,12 +6311,13 @@ const Methods = {
|
|
|
6152
6311
|
}
|
|
6153
6312
|
}
|
|
6154
6313
|
if (reserve) {
|
|
6155
|
-
tableFullData.forEach((row
|
|
6314
|
+
tableFullData.forEach((row) => this.handleCheckboxReserveRow(row, false))
|
|
6156
6315
|
}
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
|
|
6160
|
-
|
|
6316
|
+
reactData.isAllSelected = false
|
|
6317
|
+
reactData.isIndeterminate = false
|
|
6318
|
+
internalData.selectCheckboxMaps = {}
|
|
6319
|
+
internalData.treeIndeterminateRowMaps = {}
|
|
6320
|
+
reactData.updateCheckboxFlag++
|
|
6161
6321
|
return this.$nextTick()
|
|
6162
6322
|
},
|
|
6163
6323
|
/**
|
|
@@ -6364,11 +6524,13 @@ const Methods = {
|
|
|
6364
6524
|
},
|
|
6365
6525
|
triggerHeaderCellClickEvent (evnt: MouseEvent, params: VxeTableDefines.CellRenderHeaderParams) {
|
|
6366
6526
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6527
|
+
const props = $xeTable
|
|
6367
6528
|
const internalData = $xeTable as unknown as TableInternalData
|
|
6368
6529
|
|
|
6369
6530
|
const { _lastResizeTime } = internalData
|
|
6370
6531
|
const sortOpts = $xeTable.computeSortOpts
|
|
6371
6532
|
const columnOpts = $xeTable.computeColumnOpts
|
|
6533
|
+
const currentColumnOpts = $xeTable.computeCurrentColumnOpts
|
|
6372
6534
|
const { column } = params
|
|
6373
6535
|
const cell = evnt.currentTarget
|
|
6374
6536
|
const triggerResizable = _lastResizeTime && _lastResizeTime > Date.now() - 300
|
|
@@ -6378,7 +6540,7 @@ const Methods = {
|
|
|
6378
6540
|
$xeTable.triggerSortEvent(evnt, column, getNextSortOrder($xeTable, column))
|
|
6379
6541
|
}
|
|
6380
6542
|
$xeTable.dispatchEvent('header-cell-click', Object.assign({ triggerResizable, triggerSort, triggerFilter, cell }, params), evnt)
|
|
6381
|
-
if (columnOpts.isCurrent ||
|
|
6543
|
+
if ((columnOpts.isCurrent || props.highlightCurrentColumn) && (!currentColumnOpts.trigger || ['header', 'default'].includes(currentColumnOpts.trigger))) {
|
|
6382
6544
|
$xeTable.triggerCurrentColumnEvent(evnt, params)
|
|
6383
6545
|
}
|
|
6384
6546
|
return $xeTable.$nextTick()
|
|
@@ -6394,13 +6556,24 @@ const Methods = {
|
|
|
6394
6556
|
* @param {ColumnInfo} fieldOrColumn 列配置
|
|
6395
6557
|
*/
|
|
6396
6558
|
setCurrentColumn (fieldOrColumn: any) {
|
|
6397
|
-
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)
|
|
6398
6567
|
if (column) {
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
this.currentColumn = column
|
|
6568
|
+
$xeTable.clearCurrentColumn()
|
|
6569
|
+
reactData.currentColumn = column
|
|
6402
6570
|
}
|
|
6403
|
-
return
|
|
6571
|
+
return $xeTable.$nextTick().then(() => {
|
|
6572
|
+
// 更新状选中态
|
|
6573
|
+
if (isMouseSelected) {
|
|
6574
|
+
$xeTable.addCellSelectedClass()
|
|
6575
|
+
}
|
|
6576
|
+
})
|
|
6404
6577
|
},
|
|
6405
6578
|
/**
|
|
6406
6579
|
* 用于当前列,手动清空当前高亮的状态
|
|
@@ -6409,36 +6582,17 @@ const Methods = {
|
|
|
6409
6582
|
this.currentColumn = null
|
|
6410
6583
|
return this.$nextTick()
|
|
6411
6584
|
},
|
|
6412
|
-
checkValidate (type: any) {
|
|
6413
|
-
if (this.triggerValidate) {
|
|
6414
|
-
return this.triggerValidate(type)
|
|
6415
|
-
}
|
|
6416
|
-
return this.$nextTick()
|
|
6417
|
-
},
|
|
6418
|
-
/**
|
|
6419
|
-
* 当单元格发生改变时
|
|
6420
|
-
* 如果存在规则,则校验
|
|
6421
|
-
*/
|
|
6422
|
-
handleChangeCell (evnt: Event, params: any) {
|
|
6423
|
-
this.checkValidate('blur')
|
|
6424
|
-
.catch((e: any) => e)
|
|
6425
|
-
.then(() => {
|
|
6426
|
-
this.handleEdit(params, evnt)
|
|
6427
|
-
.then(() => this.checkValidate('change'))
|
|
6428
|
-
.catch((e: any) => e)
|
|
6429
|
-
})
|
|
6430
|
-
},
|
|
6431
6585
|
/**
|
|
6432
6586
|
* 列点击事件
|
|
6433
6587
|
* 如果是单击模式,则激活为编辑状态
|
|
6434
6588
|
* 如果是双击模式,则单击后选中状态
|
|
6435
6589
|
*/
|
|
6436
6590
|
triggerCellClickEvent (evnt: MouseEvent, params: VxeTableDefines.CellRenderBodyParams) {
|
|
6437
|
-
const $xeTable = this
|
|
6591
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6438
6592
|
const props = $xeTable
|
|
6439
|
-
const reactData = $xeTable
|
|
6593
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
6440
6594
|
|
|
6441
|
-
const { highlightCurrentRow, editConfig } = props
|
|
6595
|
+
const { highlightCurrentRow, highlightCurrentColumn, editConfig } = props
|
|
6442
6596
|
const { editStore, isDragResize } = reactData
|
|
6443
6597
|
if (isDragResize) {
|
|
6444
6598
|
return
|
|
@@ -6450,6 +6604,8 @@ const Methods = {
|
|
|
6450
6604
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
6451
6605
|
const keyboardOpts = $xeTable.computeKeyboardOpts
|
|
6452
6606
|
const rowOpts = $xeTable.computeRowOpts
|
|
6607
|
+
const columnOpts = $xeTable.computeColumnOpts
|
|
6608
|
+
const currentColumnOpts = $xeTable.computeCurrentColumnOpts
|
|
6453
6609
|
const { actived, focused } = editStore
|
|
6454
6610
|
const { row, column } = params
|
|
6455
6611
|
const { type, treeNode } = column
|
|
@@ -6465,11 +6621,11 @@ const Methods = {
|
|
|
6465
6621
|
if (!triggerCheckbox && !triggerRadio) {
|
|
6466
6622
|
// 如果是展开行
|
|
6467
6623
|
if (!triggerExpandNode && (expandOpts.trigger === 'row' || (isExpandType && expandOpts.trigger === 'cell'))) {
|
|
6468
|
-
|
|
6624
|
+
$xeTable.triggerRowExpandEvent(evnt, params)
|
|
6469
6625
|
}
|
|
6470
6626
|
// 如果是树形表格
|
|
6471
6627
|
if ((treeOpts.trigger === 'row' || (treeNode && treeOpts.trigger === 'cell'))) {
|
|
6472
|
-
|
|
6628
|
+
$xeTable.triggerTreeExpandEvent(evnt, params)
|
|
6473
6629
|
}
|
|
6474
6630
|
}
|
|
6475
6631
|
// 如果点击了树节点
|
|
@@ -6478,16 +6634,22 @@ const Methods = {
|
|
|
6478
6634
|
// 如果是高亮行
|
|
6479
6635
|
if (rowOpts.isCurrent || highlightCurrentRow) {
|
|
6480
6636
|
if (!triggerCheckbox && !triggerRadio) {
|
|
6481
|
-
|
|
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)
|
|
6482
6644
|
}
|
|
6483
6645
|
}
|
|
6484
6646
|
// 如果是单选框
|
|
6485
6647
|
if (!triggerRadio && (radioOpts.trigger === 'row' || (isRadioType && radioOpts.trigger === 'cell'))) {
|
|
6486
|
-
|
|
6648
|
+
$xeTable.triggerRadioRowEvent(evnt, params)
|
|
6487
6649
|
}
|
|
6488
6650
|
// 如果是复选框
|
|
6489
6651
|
if (!triggerCheckbox && (checkboxOpts.trigger === 'row' || (isCheckboxType && checkboxOpts.trigger === 'cell'))) {
|
|
6490
|
-
|
|
6652
|
+
$xeTable.handleToggleCheckRowEvent(evnt, params)
|
|
6491
6653
|
}
|
|
6492
6654
|
}
|
|
6493
6655
|
// 如果设置了单元格选中功能,则不会使用点击事件去处理(只能支持双击模式)
|
|
@@ -6499,14 +6661,14 @@ const Methods = {
|
|
|
6499
6661
|
}
|
|
6500
6662
|
if (editOpts.trigger === 'manual') {
|
|
6501
6663
|
if (actived.args && actived.row === row && column !== actived.column) {
|
|
6502
|
-
|
|
6664
|
+
handleChangeCell($xeTable, evnt, params)
|
|
6503
6665
|
}
|
|
6504
6666
|
} else if (!actived.args || row !== actived.row || column !== actived.column) {
|
|
6505
6667
|
if (editOpts.trigger === 'click') {
|
|
6506
|
-
|
|
6668
|
+
handleChangeCell($xeTable, evnt, params)
|
|
6507
6669
|
} else if (editOpts.trigger === 'dblclick') {
|
|
6508
6670
|
if (editOpts.mode === 'row' && actived.row === row) {
|
|
6509
|
-
|
|
6671
|
+
handleChangeCell($xeTable, evnt, params)
|
|
6510
6672
|
}
|
|
6511
6673
|
}
|
|
6512
6674
|
}
|
|
@@ -6526,7 +6688,7 @@ const Methods = {
|
|
|
6526
6688
|
}
|
|
6527
6689
|
}
|
|
6528
6690
|
}
|
|
6529
|
-
|
|
6691
|
+
$xeTable.dispatchEvent('cell-click', params, evnt)
|
|
6530
6692
|
},
|
|
6531
6693
|
/**
|
|
6532
6694
|
* 列双击点击事件
|
|
@@ -6549,16 +6711,16 @@ const Methods = {
|
|
|
6549
6711
|
if (isEnableConf(editConfig) && editOpts.trigger === 'dblclick') {
|
|
6550
6712
|
if (!actived.args || evnt.currentTarget !== actived.args.cell) {
|
|
6551
6713
|
if (editOpts.mode === 'row') {
|
|
6552
|
-
|
|
6714
|
+
checkValidate($xeTable, 'blur')
|
|
6553
6715
|
.catch((e: any) => e)
|
|
6554
6716
|
.then(() => {
|
|
6555
6717
|
this.handleEdit(params, evnt)
|
|
6556
|
-
.then(() =>
|
|
6718
|
+
.then(() => checkValidate($xeTable, 'change'))
|
|
6557
6719
|
.catch((e: any) => e)
|
|
6558
6720
|
})
|
|
6559
6721
|
} else if (editOpts.mode === 'cell') {
|
|
6560
6722
|
this.handleEdit(params, evnt)
|
|
6561
|
-
.then(() =>
|
|
6723
|
+
.then(() => checkValidate($xeTable, 'change'))
|
|
6562
6724
|
.catch((e: any) => e)
|
|
6563
6725
|
}
|
|
6564
6726
|
}
|
|
@@ -6754,12 +6916,11 @@ const Methods = {
|
|
|
6754
6916
|
|
|
6755
6917
|
const { treeConfig, dragConfig } = props
|
|
6756
6918
|
const rowDragOpts = $xeTable.computeRowDragOpts
|
|
6757
|
-
const { fullAllDataRowIdData } = internalData
|
|
6919
|
+
const { afterFullData, tableFullData, fullAllDataRowIdData } = internalData
|
|
6758
6920
|
const { isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod, dragToChildMethod } = rowDragOpts
|
|
6759
6921
|
const treeOpts = $xeTable.computeTreeOpts
|
|
6760
6922
|
const { transform, rowField, mapChildrenField, parentField } = treeOpts
|
|
6761
6923
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
6762
|
-
const { afterFullData, tableFullData } = internalData
|
|
6763
6924
|
const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null)
|
|
6764
6925
|
const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
|
|
6765
6926
|
const errRest = {
|
|
@@ -7355,8 +7516,8 @@ const Methods = {
|
|
|
7355
7516
|
}
|
|
7356
7517
|
},
|
|
7357
7518
|
handleHeaderCellDragMousedownEvent (evnt: MouseEvent, params: any) {
|
|
7358
|
-
const $xeTable = this
|
|
7359
|
-
const reactData = $xeTable
|
|
7519
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7520
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7360
7521
|
|
|
7361
7522
|
evnt.stopPropagation()
|
|
7362
7523
|
const columnDragOpts = $xeTable.computeColumnDragOpts
|
|
@@ -7381,8 +7542,8 @@ const Methods = {
|
|
|
7381
7542
|
$xeTable.dispatchEvent('column-dragstart', params, evnt)
|
|
7382
7543
|
},
|
|
7383
7544
|
handleHeaderCellDragMouseupEvent () {
|
|
7384
|
-
const $xeTable = this
|
|
7385
|
-
const reactData = $xeTable
|
|
7545
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7546
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7386
7547
|
|
|
7387
7548
|
clearColDropOrigin($xeTable)
|
|
7388
7549
|
hideDropTip($xeTable)
|
|
@@ -7391,54 +7552,58 @@ const Methods = {
|
|
|
7391
7552
|
reactData.isDragColMove = false
|
|
7392
7553
|
},
|
|
7393
7554
|
setPendingRow (rows: any, status: any) {
|
|
7394
|
-
const $xeTable = this
|
|
7395
|
-
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
|
|
7396
7558
|
|
|
7397
|
-
const
|
|
7559
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
7560
|
+
const { pendingRowMaps } = internalData
|
|
7398
7561
|
if (rows && !XEUtils.isArray(rows)) {
|
|
7399
7562
|
rows = [rows]
|
|
7400
7563
|
}
|
|
7401
7564
|
if (status) {
|
|
7402
7565
|
rows.forEach((row: any) => {
|
|
7403
|
-
const rowid =
|
|
7404
|
-
if (rowid && !
|
|
7405
|
-
|
|
7566
|
+
const rowid = handleGetRowId(row)
|
|
7567
|
+
if (rowid && !pendingRowMaps[rowid]) {
|
|
7568
|
+
pendingRowMaps[rowid] = row
|
|
7406
7569
|
}
|
|
7407
7570
|
})
|
|
7408
7571
|
} else {
|
|
7409
7572
|
rows.forEach((row: any) => {
|
|
7410
|
-
const rowid =
|
|
7411
|
-
if (rowid &&
|
|
7412
|
-
delete
|
|
7573
|
+
const rowid = handleGetRowId(row)
|
|
7574
|
+
if (rowid && pendingRowMaps[rowid]) {
|
|
7575
|
+
delete pendingRowMaps[rowid]
|
|
7413
7576
|
}
|
|
7414
7577
|
})
|
|
7415
7578
|
}
|
|
7416
|
-
reactData.
|
|
7579
|
+
reactData.pendingRowFlag++
|
|
7417
7580
|
return $xeTable.$nextTick()
|
|
7418
7581
|
},
|
|
7419
7582
|
togglePendingRow (rows: any) {
|
|
7420
|
-
const $xeTable = this
|
|
7421
|
-
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
|
|
7422
7586
|
|
|
7423
|
-
const
|
|
7587
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
7588
|
+
const { pendingRowMaps } = internalData
|
|
7424
7589
|
if (rows && !XEUtils.isArray(rows)) {
|
|
7425
7590
|
rows = [rows]
|
|
7426
7591
|
}
|
|
7427
7592
|
rows.forEach((row: any) => {
|
|
7428
|
-
const rowid =
|
|
7593
|
+
const rowid = handleGetRowId(row)
|
|
7429
7594
|
if (rowid) {
|
|
7430
|
-
if (
|
|
7431
|
-
delete
|
|
7595
|
+
if (pendingRowMaps[rowid]) {
|
|
7596
|
+
delete pendingRowMaps[rowid]
|
|
7432
7597
|
} else {
|
|
7433
|
-
|
|
7598
|
+
pendingRowMaps[rowid] = row
|
|
7434
7599
|
}
|
|
7435
7600
|
}
|
|
7436
7601
|
})
|
|
7437
|
-
reactData.
|
|
7602
|
+
reactData.pendingRowFlag++
|
|
7438
7603
|
return $xeTable.$nextTick()
|
|
7439
7604
|
},
|
|
7440
7605
|
hasPendingByRow (row: any) {
|
|
7441
|
-
const $xeTable = this
|
|
7606
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7442
7607
|
|
|
7443
7608
|
return $xeTable.isPendingByRow(row)
|
|
7444
7609
|
},
|
|
@@ -7451,12 +7616,10 @@ const Methods = {
|
|
|
7451
7616
|
return !!pendingRowMaps[rowid]
|
|
7452
7617
|
},
|
|
7453
7618
|
getPendingRecords () {
|
|
7454
|
-
const $xeTable = this
|
|
7455
|
-
const
|
|
7456
|
-
const internalData = $xeTable
|
|
7619
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7620
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7457
7621
|
|
|
7458
|
-
const { pendingRowMaps } =
|
|
7459
|
-
const { fullAllDataRowIdData } = internalData
|
|
7622
|
+
const { fullAllDataRowIdData, pendingRowMaps } = internalData
|
|
7460
7623
|
const insertRecords: any[] = []
|
|
7461
7624
|
XEUtils.each(pendingRowMaps, (row, rowid) => {
|
|
7462
7625
|
if (fullAllDataRowIdData[rowid]) {
|
|
@@ -7466,11 +7629,16 @@ const Methods = {
|
|
|
7466
7629
|
return insertRecords
|
|
7467
7630
|
},
|
|
7468
7631
|
clearPendingRow () {
|
|
7469
|
-
|
|
7470
|
-
|
|
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()
|
|
7471
7639
|
},
|
|
7472
7640
|
sort (sortConfs: any, sortOrder: any) {
|
|
7473
|
-
const $xeTable = this
|
|
7641
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7474
7642
|
|
|
7475
7643
|
const { sortOpts } = this
|
|
7476
7644
|
const { multiple, remote, orders } = sortOpts
|
|
@@ -7620,7 +7788,10 @@ const Methods = {
|
|
|
7620
7788
|
* @param {Event} evnt 事件
|
|
7621
7789
|
*/
|
|
7622
7790
|
closeFilter () {
|
|
7623
|
-
const
|
|
7791
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7792
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7793
|
+
|
|
7794
|
+
const { filterStore } = reactData
|
|
7624
7795
|
const { column, visible } = filterStore
|
|
7625
7796
|
Object.assign(filterStore, {
|
|
7626
7797
|
isAllSelected: false,
|
|
@@ -7629,9 +7800,15 @@ const Methods = {
|
|
|
7629
7800
|
visible: false
|
|
7630
7801
|
})
|
|
7631
7802
|
if (visible) {
|
|
7632
|
-
|
|
7803
|
+
$xeTable.dispatchEvent('filter-visible', {
|
|
7804
|
+
column,
|
|
7805
|
+
field: column.field,
|
|
7806
|
+
property: column.field,
|
|
7807
|
+
filterList: () => $xeTable.getCheckedFilters(),
|
|
7808
|
+
visible: false
|
|
7809
|
+
}, null)
|
|
7633
7810
|
}
|
|
7634
|
-
return
|
|
7811
|
+
return $xeTable.$nextTick()
|
|
7635
7812
|
},
|
|
7636
7813
|
/**
|
|
7637
7814
|
* 判断指定列是否为筛选状态,如果为空则判断所有列
|
|
@@ -7664,17 +7841,16 @@ const Methods = {
|
|
|
7664
7841
|
const reactData = $xeTable as unknown as TableReactData
|
|
7665
7842
|
const internalData = $xeTable as unknown as TableInternalData
|
|
7666
7843
|
|
|
7667
|
-
const
|
|
7668
|
-
const { fullAllDataRowIdData } = internalData
|
|
7844
|
+
const { fullAllDataRowIdData, rowExpandLazyLoadedMaps } = internalData
|
|
7669
7845
|
const expandOpts = $xeTable.computeExpandOpts
|
|
7670
7846
|
const { lazy } = expandOpts
|
|
7671
7847
|
const rowid = getRowid($xeTable, row)
|
|
7672
7848
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
7673
7849
|
if (lazy && rowRest) {
|
|
7674
7850
|
rowRest.expandLoaded = false
|
|
7675
|
-
delete
|
|
7851
|
+
delete rowExpandLazyLoadedMaps[rowid]
|
|
7676
7852
|
}
|
|
7677
|
-
reactData.
|
|
7853
|
+
reactData.rowExpandedFlag++
|
|
7678
7854
|
return $xeTable.$nextTick()
|
|
7679
7855
|
},
|
|
7680
7856
|
/**
|
|
@@ -7682,14 +7858,18 @@ const Methods = {
|
|
|
7682
7858
|
* @param {Row} row 行对象
|
|
7683
7859
|
*/
|
|
7684
7860
|
reloadRowExpand (row: any) {
|
|
7685
|
-
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
|
|
7686
7866
|
const { lazy } = expandOpts
|
|
7687
7867
|
const rowid = getRowid(this, row)
|
|
7688
7868
|
if (lazy && !rowExpandLazyLoadedMaps[rowid]) {
|
|
7689
|
-
|
|
7690
|
-
.then(() =>
|
|
7869
|
+
$xeTable.clearRowExpandLoaded(row)
|
|
7870
|
+
.then(() => handleAsyncRowExpand($xeTable, row))
|
|
7691
7871
|
}
|
|
7692
|
-
return
|
|
7872
|
+
return $xeTable.$nextTick()
|
|
7693
7873
|
},
|
|
7694
7874
|
reloadExpandContent (row: any) {
|
|
7695
7875
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -7702,20 +7882,34 @@ const Methods = {
|
|
|
7702
7882
|
* 展开行事件
|
|
7703
7883
|
*/
|
|
7704
7884
|
triggerRowExpandEvent (evnt: any, params: any) {
|
|
7705
|
-
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
|
|
7706
7892
|
const { row } = params
|
|
7707
7893
|
const { lazy, trigger } = expandOpts
|
|
7708
7894
|
if (trigger === 'manual') {
|
|
7709
7895
|
return
|
|
7710
7896
|
}
|
|
7711
7897
|
evnt.stopPropagation()
|
|
7712
|
-
const rowid = getRowid(
|
|
7898
|
+
const rowid = getRowid($xeTable, row)
|
|
7713
7899
|
if (!lazy || !rowExpandLazyLoadedMaps[rowid]) {
|
|
7714
|
-
const expanded =
|
|
7715
|
-
const columnIndex =
|
|
7716
|
-
const $columnIndex =
|
|
7717
|
-
|
|
7718
|
-
|
|
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)
|
|
7719
7913
|
}
|
|
7720
7914
|
},
|
|
7721
7915
|
/**
|
|
@@ -7759,48 +7953,6 @@ const Methods = {
|
|
|
7759
7953
|
}
|
|
7760
7954
|
return this.setRowExpand(expandedRows, expanded)
|
|
7761
7955
|
},
|
|
7762
|
-
handleAsyncRowExpand (row: any) {
|
|
7763
|
-
const $xeTable = this
|
|
7764
|
-
const reactData = $xeTable as TableReactData
|
|
7765
|
-
const internalData = $xeTable as TableInternalData
|
|
7766
|
-
|
|
7767
|
-
return new Promise<void>(resolve => {
|
|
7768
|
-
const { expandOpts } = this
|
|
7769
|
-
const { loadMethod } = expandOpts
|
|
7770
|
-
if (loadMethod) {
|
|
7771
|
-
const { fullAllDataRowIdData } = internalData
|
|
7772
|
-
const rExpandLazyLoadedMaps = { ...reactData.rowExpandLazyLoadedMaps }
|
|
7773
|
-
const rowid = getRowid($xeTable, row)
|
|
7774
|
-
const rowRest = fullAllDataRowIdData[rowid]
|
|
7775
|
-
rExpandLazyLoadedMaps[rowid] = row
|
|
7776
|
-
reactData.rowExpandLazyLoadedMaps = rExpandLazyLoadedMaps
|
|
7777
|
-
loadMethod({ $table: $xeTable, row, rowIndex: $xeTable.getRowIndex(row), $rowIndex: $xeTable.getVMRowIndex(row) }).then(() => {
|
|
7778
|
-
const rExpandedMaps = { ...reactData.rowExpandedMaps }
|
|
7779
|
-
if (rowRest) {
|
|
7780
|
-
rowRest.expandLoaded = true
|
|
7781
|
-
}
|
|
7782
|
-
rExpandedMaps[rowid] = row
|
|
7783
|
-
reactData.rowExpandedMaps = rExpandedMaps
|
|
7784
|
-
}).catch(() => {
|
|
7785
|
-
if (rowRest) {
|
|
7786
|
-
rowRest.expandLoaded = false
|
|
7787
|
-
}
|
|
7788
|
-
}).finally(() => {
|
|
7789
|
-
const rExpandLazyLoadedMaps = { ...reactData.rowExpandLazyLoadedMaps }
|
|
7790
|
-
if (rExpandLazyLoadedMaps[rowid]) {
|
|
7791
|
-
delete rExpandLazyLoadedMaps[rowid]
|
|
7792
|
-
}
|
|
7793
|
-
reactData.rowExpandLazyLoadedMaps = rExpandLazyLoadedMaps
|
|
7794
|
-
$xeTable.$nextTick()
|
|
7795
|
-
.then(() => $xeTable.recalculate())
|
|
7796
|
-
.then(() => $xeTable.updateCellAreas())
|
|
7797
|
-
.then(() => resolve())
|
|
7798
|
-
})
|
|
7799
|
-
} else {
|
|
7800
|
-
resolve()
|
|
7801
|
-
}
|
|
7802
|
-
})
|
|
7803
|
-
},
|
|
7804
7956
|
/**
|
|
7805
7957
|
* 设置展开行,二个参数设置这一行展开与否
|
|
7806
7958
|
* 支持单行
|
|
@@ -7809,10 +7961,14 @@ const Methods = {
|
|
|
7809
7961
|
* @param {Boolean} expanded 是否展开
|
|
7810
7962
|
*/
|
|
7811
7963
|
setRowExpand (rows: any, expanded: any) {
|
|
7812
|
-
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
|
|
7813
7967
|
|
|
7814
|
-
const {
|
|
7815
|
-
let
|
|
7968
|
+
const { expandColumn } = reactData
|
|
7969
|
+
let { fullAllDataRowIdData, rowExpandedMaps, rowExpandLazyLoadedMaps } = internalData
|
|
7970
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
7971
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
7816
7972
|
const { reserve, lazy, accordion, toggleMethod } = expandOpts
|
|
7817
7973
|
const lazyRests: any[] = []
|
|
7818
7974
|
const columnIndex = $xeTable.getColumnIndex(expandColumn)
|
|
@@ -7823,28 +7979,29 @@ const Methods = {
|
|
|
7823
7979
|
}
|
|
7824
7980
|
if (accordion) {
|
|
7825
7981
|
// 只能同时展开一个
|
|
7826
|
-
|
|
7982
|
+
rowExpandedMaps = {}
|
|
7983
|
+
internalData.rowExpandedMaps = rowExpandedMaps
|
|
7827
7984
|
rows = rows.slice(rows.length - 1, rows.length)
|
|
7828
7985
|
}
|
|
7829
|
-
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
|
|
7830
7987
|
if (expanded) {
|
|
7831
7988
|
validRows.forEach((row: any) => {
|
|
7832
|
-
const rowid =
|
|
7833
|
-
if (!
|
|
7989
|
+
const rowid = handleGetRowId(row)
|
|
7990
|
+
if (!rowExpandedMaps[rowid]) {
|
|
7834
7991
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
7835
7992
|
const isLoad = lazy && !rowRest.expandLoaded && !rowExpandLazyLoadedMaps[rowid]
|
|
7836
7993
|
if (isLoad) {
|
|
7837
|
-
lazyRests.push(
|
|
7994
|
+
lazyRests.push(handleAsyncRowExpand($xeTable, row))
|
|
7838
7995
|
} else {
|
|
7839
|
-
|
|
7996
|
+
rowExpandedMaps[rowid] = row
|
|
7840
7997
|
}
|
|
7841
7998
|
}
|
|
7842
7999
|
})
|
|
7843
8000
|
} else {
|
|
7844
8001
|
validRows.forEach((item) => {
|
|
7845
|
-
const rowid =
|
|
7846
|
-
if (
|
|
7847
|
-
delete
|
|
8002
|
+
const rowid = handleGetRowId(item)
|
|
8003
|
+
if (rowExpandedMaps[rowid]) {
|
|
8004
|
+
delete rowExpandedMaps[rowid]
|
|
7848
8005
|
}
|
|
7849
8006
|
})
|
|
7850
8007
|
}
|
|
@@ -7852,7 +8009,7 @@ const Methods = {
|
|
|
7852
8009
|
validRows.forEach((row) => handleRowExpandReserve($xeTable, row, expanded))
|
|
7853
8010
|
}
|
|
7854
8011
|
}
|
|
7855
|
-
|
|
8012
|
+
reactData.rowExpandedFlag++
|
|
7856
8013
|
return Promise.all(lazyRests)
|
|
7857
8014
|
.then(() => $xeTable.$nextTick())
|
|
7858
8015
|
.then(() => $xeTable.recalculate(true))
|
|
@@ -7868,9 +8025,14 @@ const Methods = {
|
|
|
7868
8025
|
* @param {Row} row 行对象
|
|
7869
8026
|
*/
|
|
7870
8027
|
isRowExpandByRow (row: any) {
|
|
7871
|
-
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
|
|
7872
8034
|
const rowid = getRowid(this, row)
|
|
7873
|
-
return !!rowExpandedMaps[rowid]
|
|
8035
|
+
return !!rowExpandedFlag && !!rowExpandedMaps[rowid]
|
|
7874
8036
|
},
|
|
7875
8037
|
isExpandByRow (row: any) {
|
|
7876
8038
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -7891,7 +8053,8 @@ const Methods = {
|
|
|
7891
8053
|
const expandOpts = $xeTable.computeExpandOpts
|
|
7892
8054
|
const { reserve } = expandOpts
|
|
7893
8055
|
const expList = $xeTable.getRowExpandRecords()
|
|
7894
|
-
|
|
8056
|
+
internalData.rowExpandedMaps = {}
|
|
8057
|
+
reactData.rowExpandedFlag++
|
|
7895
8058
|
if (reserve) {
|
|
7896
8059
|
tableFullData.forEach((row) => handleRowExpandReserve($xeTable, row, false))
|
|
7897
8060
|
}
|
|
@@ -7911,8 +8074,11 @@ const Methods = {
|
|
|
7911
8074
|
return this.$nextTick()
|
|
7912
8075
|
},
|
|
7913
8076
|
getRowExpandRecords () {
|
|
8077
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8078
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8079
|
+
|
|
7914
8080
|
const rest: any[] = []
|
|
7915
|
-
XEUtils.each(
|
|
8081
|
+
XEUtils.each(internalData.rowExpandedMaps, item => {
|
|
7916
8082
|
if (item) {
|
|
7917
8083
|
rest.push(item)
|
|
7918
8084
|
}
|
|
@@ -7920,8 +8086,11 @@ const Methods = {
|
|
|
7920
8086
|
return rest
|
|
7921
8087
|
},
|
|
7922
8088
|
getTreeExpandRecords () {
|
|
8089
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8090
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8091
|
+
|
|
7923
8092
|
const rest: any[] = []
|
|
7924
|
-
XEUtils.each(
|
|
8093
|
+
XEUtils.each(internalData.treeExpandedMaps, item => {
|
|
7925
8094
|
if (item) {
|
|
7926
8095
|
rest.push(item)
|
|
7927
8096
|
}
|
|
@@ -7956,12 +8125,10 @@ const Methods = {
|
|
|
7956
8125
|
const reactData = $xeTable as unknown as TableReactData
|
|
7957
8126
|
const internalData = $xeTable as unknown as TableInternalData
|
|
7958
8127
|
|
|
7959
|
-
const { fullAllDataRowIdData } = internalData
|
|
8128
|
+
const { fullAllDataRowIdData, treeExpandedMaps } = internalData
|
|
7960
8129
|
const treeOpts = $xeTable.computeTreeOpts
|
|
7961
8130
|
const { transform } = treeOpts
|
|
7962
|
-
let tExpandedMaps: Record<string, any> = {}
|
|
7963
8131
|
if (rows) {
|
|
7964
|
-
tExpandedMaps = { ...reactData.treeExpandedMaps }
|
|
7965
8132
|
if (!XEUtils.isArray(rows)) {
|
|
7966
8133
|
rows = [rows]
|
|
7967
8134
|
}
|
|
@@ -7970,8 +8137,8 @@ const Methods = {
|
|
|
7970
8137
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
7971
8138
|
if (rowRest) {
|
|
7972
8139
|
rowRest.treeLoaded = false
|
|
7973
|
-
if (
|
|
7974
|
-
delete
|
|
8140
|
+
if (treeExpandedMaps[rowid]) {
|
|
8141
|
+
delete treeExpandedMaps[rowid]
|
|
7975
8142
|
}
|
|
7976
8143
|
}
|
|
7977
8144
|
})
|
|
@@ -7980,7 +8147,8 @@ const Methods = {
|
|
|
7980
8147
|
rowRest.treeLoaded = false
|
|
7981
8148
|
})
|
|
7982
8149
|
}
|
|
7983
|
-
|
|
8150
|
+
internalData.treeExpandedMaps = {}
|
|
8151
|
+
reactData.treeExpandedFlag++
|
|
7984
8152
|
if (transform) {
|
|
7985
8153
|
handleVirtualTreeToList($xeTable)
|
|
7986
8154
|
return $xeTable.handleTableData()
|
|
@@ -7993,37 +8161,45 @@ const Methods = {
|
|
|
7993
8161
|
*/
|
|
7994
8162
|
reloadTreeExpand (row: any) {
|
|
7995
8163
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8164
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7996
8165
|
|
|
7997
|
-
const {
|
|
8166
|
+
const { treeExpandLazyLoadedMaps } = internalData
|
|
8167
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
7998
8168
|
const { transform, lazy } = treeOpts
|
|
7999
8169
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
8000
|
-
const rowid = getRowid(
|
|
8170
|
+
const rowid = getRowid($xeTable, row)
|
|
8001
8171
|
if (lazy && row[hasChildField] && !treeExpandLazyLoadedMaps[rowid]) {
|
|
8002
|
-
return
|
|
8003
|
-
return
|
|
8172
|
+
return $xeTable.clearTreeExpandLoaded(row).then(() => {
|
|
8173
|
+
return handleAsyncTreeExpandChilds($xeTable, row)
|
|
8004
8174
|
}).then(() => {
|
|
8005
8175
|
if (transform) {
|
|
8006
8176
|
handleVirtualTreeToList($xeTable)
|
|
8007
|
-
return
|
|
8177
|
+
return $xeTable.handleTableData()
|
|
8008
8178
|
}
|
|
8009
8179
|
}).then(() => {
|
|
8010
|
-
return
|
|
8180
|
+
return $xeTable.recalculate()
|
|
8011
8181
|
})
|
|
8012
8182
|
}
|
|
8013
|
-
return
|
|
8183
|
+
return $xeTable.$nextTick()
|
|
8014
8184
|
},
|
|
8015
8185
|
reloadTreeChilds (row: any) {
|
|
8186
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8187
|
+
|
|
8016
8188
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
8017
8189
|
warnLog('vxe.error.delFunc', ['reloadTreeChilds', 'reloadTreeExpand'])
|
|
8018
8190
|
}
|
|
8019
8191
|
// 即将废弃
|
|
8020
|
-
return
|
|
8192
|
+
return $xeTable.reloadTreeExpand(row)
|
|
8021
8193
|
},
|
|
8022
8194
|
/**
|
|
8023
8195
|
* 展开树节点事件
|
|
8024
8196
|
*/
|
|
8025
8197
|
triggerTreeExpandEvent (evnt: any, params: any) {
|
|
8026
|
-
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
|
|
8027
8203
|
const { row, column } = params
|
|
8028
8204
|
const { lazy, trigger } = treeOpts
|
|
8029
8205
|
if (trigger === 'manual') {
|
|
@@ -8032,11 +8208,11 @@ const Methods = {
|
|
|
8032
8208
|
evnt.stopPropagation()
|
|
8033
8209
|
const rowid = getRowid(this, row)
|
|
8034
8210
|
if (!lazy || !treeExpandLazyLoadedMaps[rowid]) {
|
|
8035
|
-
const expanded =
|
|
8036
|
-
const columnIndex =
|
|
8037
|
-
const $columnIndex =
|
|
8038
|
-
|
|
8039
|
-
|
|
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)
|
|
8040
8216
|
}
|
|
8041
8217
|
},
|
|
8042
8218
|
/**
|
|
@@ -8045,88 +8221,6 @@ const Methods = {
|
|
|
8045
8221
|
toggleTreeExpand (row: any) {
|
|
8046
8222
|
return this.setTreeExpand(row, !this.isTreeExpandByRow(row))
|
|
8047
8223
|
},
|
|
8048
|
-
/**
|
|
8049
|
-
* 处理默认展开树节点
|
|
8050
|
-
*/
|
|
8051
|
-
handleDefaultTreeExpand () {
|
|
8052
|
-
const { treeConfig, treeOpts, tableFullData } = this
|
|
8053
|
-
if (treeConfig) {
|
|
8054
|
-
const { expandAll, expandRowKeys } = treeOpts
|
|
8055
|
-
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
8056
|
-
if (expandAll) {
|
|
8057
|
-
this.setAllTreeExpand(true)
|
|
8058
|
-
} else if (expandRowKeys) {
|
|
8059
|
-
const defExpandeds: any[] = []
|
|
8060
|
-
const rowkey = getRowkey(this)
|
|
8061
|
-
expandRowKeys.forEach((rowid: any) => {
|
|
8062
|
-
const matchObj = XEUtils.findTree(tableFullData, item => rowid === XEUtils.get(item, rowkey), { children: childrenField })
|
|
8063
|
-
if (matchObj) {
|
|
8064
|
-
defExpandeds.push(matchObj.item)
|
|
8065
|
-
}
|
|
8066
|
-
})
|
|
8067
|
-
this.setTreeExpand(defExpandeds, true)
|
|
8068
|
-
}
|
|
8069
|
-
}
|
|
8070
|
-
},
|
|
8071
|
-
handleAsyncTreeExpandChilds (row: any) {
|
|
8072
|
-
const $xeTable = this
|
|
8073
|
-
|
|
8074
|
-
const { treeOpts, checkboxOpts } = this
|
|
8075
|
-
const { transform, loadMethod } = treeOpts
|
|
8076
|
-
const { checkStrictly } = checkboxOpts
|
|
8077
|
-
return new Promise<void>(resolve => {
|
|
8078
|
-
if (loadMethod) {
|
|
8079
|
-
const { treeExpandLazyLoadedMaps, fullAllDataRowIdData } = this
|
|
8080
|
-
const rowid = getRowid($xeTable, row)
|
|
8081
|
-
const rowRest = fullAllDataRowIdData[rowid]
|
|
8082
|
-
treeExpandLazyLoadedMaps[rowid] = row
|
|
8083
|
-
Promise.resolve(
|
|
8084
|
-
loadMethod({ $table: $xeTable, row })
|
|
8085
|
-
).then((childRecords: any) => {
|
|
8086
|
-
if (rowRest) {
|
|
8087
|
-
rowRest.treeLoaded = true
|
|
8088
|
-
}
|
|
8089
|
-
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
8090
|
-
delete treeExpandLazyLoadedMaps[rowid]
|
|
8091
|
-
}
|
|
8092
|
-
if (!XEUtils.isArray(childRecords)) {
|
|
8093
|
-
childRecords = []
|
|
8094
|
-
}
|
|
8095
|
-
if (childRecords) {
|
|
8096
|
-
return this.loadTreeChildren(row, childRecords).then((childRows: any[]) => {
|
|
8097
|
-
const { treeExpandedMaps } = this
|
|
8098
|
-
if (childRows.length && !treeExpandedMaps[rowid]) {
|
|
8099
|
-
treeExpandedMaps[rowid] = row
|
|
8100
|
-
}
|
|
8101
|
-
// 如果当前节点已选中,则展开后子节点也被选中
|
|
8102
|
-
if (!checkStrictly && this.isCheckedByCheckboxRow(row)) {
|
|
8103
|
-
handleCheckedCheckboxRow($xeTable, childRows, true)
|
|
8104
|
-
}
|
|
8105
|
-
return this.$nextTick().then(() => {
|
|
8106
|
-
if (transform) {
|
|
8107
|
-
this.handleTableData()
|
|
8108
|
-
updateAfterDataIndex($xeTable)
|
|
8109
|
-
return this.$nextTick()
|
|
8110
|
-
}
|
|
8111
|
-
})
|
|
8112
|
-
})
|
|
8113
|
-
}
|
|
8114
|
-
}).catch(() => {
|
|
8115
|
-
const { treeExpandLazyLoadedMaps } = this
|
|
8116
|
-
if (rowRest) {
|
|
8117
|
-
rowRest.treeLoaded = false
|
|
8118
|
-
}
|
|
8119
|
-
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
8120
|
-
delete treeExpandLazyLoadedMaps[rowid]
|
|
8121
|
-
}
|
|
8122
|
-
}).finally(() => {
|
|
8123
|
-
this.$nextTick().then(() => this.recalculate()).then(() => resolve())
|
|
8124
|
-
})
|
|
8125
|
-
} else {
|
|
8126
|
-
resolve()
|
|
8127
|
-
}
|
|
8128
|
-
})
|
|
8129
|
-
},
|
|
8130
8224
|
/**
|
|
8131
8225
|
* 设置所有树节点的展开与否
|
|
8132
8226
|
* @param {Boolean} expanded 是否展开
|
|
@@ -8151,41 +8245,47 @@ const Methods = {
|
|
|
8151
8245
|
* @returns
|
|
8152
8246
|
*/
|
|
8153
8247
|
handleBaseTreeExpand (rows: any, expanded: any) {
|
|
8154
|
-
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
|
|
8155
8255
|
const { reserve, lazy, accordion, toggleMethod } = treeOpts
|
|
8156
|
-
const treeTempExpandedMaps = { ...treeExpandedMaps }
|
|
8157
8256
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
8158
8257
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
8159
8258
|
const result: any[] = []
|
|
8160
|
-
const columnIndex =
|
|
8161
|
-
const $columnIndex =
|
|
8162
|
-
|
|
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
|
|
8163
8263
|
if (accordion) {
|
|
8164
8264
|
validRows = validRows.length ? [validRows[validRows.length - 1]] : []
|
|
8165
8265
|
// 同一级只能展开一个
|
|
8166
8266
|
const matchObj = XEUtils.findTree(tableFullData, item => item === validRows[0], { children: childrenField })
|
|
8167
8267
|
if (matchObj) {
|
|
8168
8268
|
matchObj.items.forEach(item => {
|
|
8169
|
-
const rowid =
|
|
8170
|
-
if (
|
|
8171
|
-
delete
|
|
8269
|
+
const rowid = handleGetRowId(item)
|
|
8270
|
+
if (treeExpandedMaps[rowid]) {
|
|
8271
|
+
delete treeExpandedMaps[rowid]
|
|
8172
8272
|
}
|
|
8173
8273
|
})
|
|
8174
8274
|
}
|
|
8175
8275
|
}
|
|
8176
8276
|
if (expanded) {
|
|
8177
8277
|
validRows.forEach((row: any) => {
|
|
8178
|
-
const rowid =
|
|
8179
|
-
if (!
|
|
8278
|
+
const rowid = handleGetRowId(row)
|
|
8279
|
+
if (!treeExpandedMaps[rowid]) {
|
|
8180
8280
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
8181
8281
|
if (rowRest) {
|
|
8182
8282
|
const isLoad = lazy && row[hasChildField] && !rowRest.treeLoaded && !treeExpandLazyLoadedMaps[rowid]
|
|
8183
8283
|
// 是否使用懒加载
|
|
8184
8284
|
if (isLoad) {
|
|
8185
|
-
result.push(
|
|
8285
|
+
result.push(handleAsyncTreeExpandChilds($xeTable, row))
|
|
8186
8286
|
} else {
|
|
8187
8287
|
if (row[childrenField] && row[childrenField].length) {
|
|
8188
|
-
|
|
8288
|
+
treeExpandedMaps[rowid] = row
|
|
8189
8289
|
}
|
|
8190
8290
|
}
|
|
8191
8291
|
}
|
|
@@ -8193,18 +8293,18 @@ const Methods = {
|
|
|
8193
8293
|
})
|
|
8194
8294
|
} else {
|
|
8195
8295
|
validRows.forEach((item: any) => {
|
|
8196
|
-
const rowid =
|
|
8197
|
-
if (
|
|
8198
|
-
delete
|
|
8296
|
+
const rowid = handleGetRowId(item)
|
|
8297
|
+
if (treeExpandedMaps[rowid]) {
|
|
8298
|
+
delete treeExpandedMaps[rowid]
|
|
8199
8299
|
}
|
|
8200
8300
|
})
|
|
8201
8301
|
}
|
|
8202
8302
|
if (reserve) {
|
|
8203
|
-
validRows.forEach((row: any) =>
|
|
8303
|
+
validRows.forEach((row: any) => handleTreeExpandReserve($xeTable, row, expanded))
|
|
8204
8304
|
}
|
|
8205
|
-
|
|
8305
|
+
reactData.treeExpandedFlag++
|
|
8206
8306
|
return Promise.all(result).then(() => {
|
|
8207
|
-
return
|
|
8307
|
+
return $xeTable.recalculate()
|
|
8208
8308
|
})
|
|
8209
8309
|
},
|
|
8210
8310
|
/**
|
|
@@ -8258,31 +8358,40 @@ const Methods = {
|
|
|
8258
8358
|
* @param {Row} row 行对象
|
|
8259
8359
|
*/
|
|
8260
8360
|
isTreeExpandByRow (row: any) {
|
|
8261
|
-
const
|
|
8262
|
-
|
|
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)]
|
|
8263
8368
|
},
|
|
8264
8369
|
/**
|
|
8265
8370
|
* 手动清空树形节点的展开状态,数据会恢复成未展开的状态
|
|
8266
8371
|
*/
|
|
8267
8372
|
clearTreeExpand () {
|
|
8268
8373
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8374
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
8375
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8269
8376
|
|
|
8270
|
-
const {
|
|
8271
|
-
const
|
|
8377
|
+
const { tableFullTreeData } = internalData
|
|
8378
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
8272
8379
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
8273
|
-
const
|
|
8274
|
-
|
|
8380
|
+
const { transform, reserve } = treeOpts
|
|
8381
|
+
const expList = $xeTable.getTreeExpandRecords()
|
|
8382
|
+
internalData.treeExpandedMaps = {}
|
|
8383
|
+
reactData.treeExpandedFlag++
|
|
8275
8384
|
if (reserve) {
|
|
8276
|
-
XEUtils.eachTree(
|
|
8385
|
+
XEUtils.eachTree(tableFullTreeData, row => handleTreeExpandReserve($xeTable, row, false), { children: childrenField })
|
|
8277
8386
|
}
|
|
8278
|
-
return
|
|
8387
|
+
return $xeTable.handleTableData().then(() => {
|
|
8279
8388
|
if (transform) {
|
|
8280
8389
|
handleVirtualTreeToList($xeTable)
|
|
8281
|
-
return
|
|
8390
|
+
return $xeTable.handleTableData()
|
|
8282
8391
|
}
|
|
8283
8392
|
}).then(() => {
|
|
8284
8393
|
if (expList.length) {
|
|
8285
|
-
|
|
8394
|
+
$xeTable.recalculate()
|
|
8286
8395
|
}
|
|
8287
8396
|
})
|
|
8288
8397
|
},
|
|
@@ -8290,17 +8399,6 @@ const Methods = {
|
|
|
8290
8399
|
this.treeExpandedReserveRowMap = {}
|
|
8291
8400
|
return this.$nextTick()
|
|
8292
8401
|
},
|
|
8293
|
-
handleTreeExpandReserve (row: any, expanded: any) {
|
|
8294
|
-
const { treeExpandedReserveRowMap, treeOpts } = this
|
|
8295
|
-
if (treeOpts.reserve) {
|
|
8296
|
-
const rowid = getRowid(this, row)
|
|
8297
|
-
if (expanded) {
|
|
8298
|
-
treeExpandedReserveRowMap[rowid] = row
|
|
8299
|
-
} else if (treeExpandedReserveRowMap[rowid]) {
|
|
8300
|
-
delete treeExpandedReserveRowMap[rowid]
|
|
8301
|
-
}
|
|
8302
|
-
}
|
|
8303
|
-
},
|
|
8304
8402
|
/**
|
|
8305
8403
|
* 获取表格的滚动状态
|
|
8306
8404
|
*/
|
|
@@ -8625,10 +8723,10 @@ const Methods = {
|
|
|
8625
8723
|
}
|
|
8626
8724
|
|
|
8627
8725
|
const { highlightHoverRow } = tableProps
|
|
8628
|
-
const { scrollXLoad, scrollYLoad } = reactData
|
|
8726
|
+
const { scrollXLoad, scrollYLoad, expandColumn } = reactData
|
|
8629
8727
|
const leftFixedWidth = $xeTable.computeLeftFixedWidth
|
|
8630
8728
|
const rightFixedWidth = $xeTable.computeRightFixedWidth
|
|
8631
|
-
if (!(
|
|
8729
|
+
if (!(leftFixedWidth || rightFixedWidth || expandColumn)) {
|
|
8632
8730
|
return
|
|
8633
8731
|
}
|
|
8634
8732
|
|
|
@@ -8897,8 +8995,8 @@ const Methods = {
|
|
|
8897
8995
|
const reactData = $xeTable as unknown as TableReactData
|
|
8898
8996
|
const internalData = $xeTable as unknown as TableInternalData
|
|
8899
8997
|
|
|
8900
|
-
const { isAllOverflow, scrollYLoad, expandColumn
|
|
8901
|
-
const { scrollYStore, elemStore, isResizeCellHeight, afterFullData, fullAllDataRowIdData } = internalData
|
|
8998
|
+
const { isAllOverflow, scrollYLoad, expandColumn } = reactData
|
|
8999
|
+
const { scrollYStore, elemStore, isResizeCellHeight, afterFullData, fullAllDataRowIdData, rowExpandedMaps } = internalData
|
|
8902
9000
|
const { startIndex } = scrollYStore
|
|
8903
9001
|
const expandOpts = $xeTable.computeExpandOpts
|
|
8904
9002
|
const rowOpts = $xeTable.computeRowOpts
|
|
@@ -9145,12 +9243,15 @@ const Methods = {
|
|
|
9145
9243
|
* 更新表尾合计
|
|
9146
9244
|
*/
|
|
9147
9245
|
updateFooter () {
|
|
9246
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
9247
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
9248
|
+
|
|
9148
9249
|
const { showFooter, visibleColumn, footerData, footerMethod } = this
|
|
9149
9250
|
let footData = []
|
|
9150
9251
|
if (showFooter && footerData && footerData.length) {
|
|
9151
9252
|
footData = footerData.slice(0)
|
|
9152
9253
|
} else if (showFooter && footerMethod) {
|
|
9153
|
-
footData = visibleColumn.length ? footerMethod({ columns: visibleColumn, data: this.afterFullData, $table:
|
|
9254
|
+
footData = visibleColumn.length ? footerMethod({ columns: visibleColumn, data: this.afterFullData, $table: $xeTable, $grid: $xeGrid }) : []
|
|
9154
9255
|
}
|
|
9155
9256
|
this.footerTableData = footData
|
|
9156
9257
|
return this.$nextTick()
|
|
@@ -9233,7 +9334,7 @@ const Methods = {
|
|
|
9233
9334
|
if (this.footerSpanMethod) {
|
|
9234
9335
|
errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method'])
|
|
9235
9336
|
}
|
|
9236
|
-
setMerges(this, merges, this.mergeFooterList
|
|
9337
|
+
setMerges(this, merges, this.mergeFooterList)
|
|
9237
9338
|
return this.$nextTick().then(() => {
|
|
9238
9339
|
this.updateCellAreas()
|
|
9239
9340
|
return updateStyle($xeTable)
|
|
@@ -9288,12 +9389,17 @@ const Methods = {
|
|
|
9288
9389
|
return $xeTable.$nextTick()
|
|
9289
9390
|
},
|
|
9290
9391
|
dispatchEvent (type: ValueOf<VxeTableEmits>, params: Record<string, any>, evnt: Event | null) {
|
|
9291
|
-
const $xeTable = this
|
|
9292
|
-
|
|
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))
|
|
9293
9396
|
},
|
|
9294
9397
|
// 已废弃,使用 dispatchEvent
|
|
9295
9398
|
emitEvent (type: any, params: any, evnt: any) {
|
|
9296
|
-
|
|
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))
|
|
9297
9403
|
},
|
|
9298
9404
|
focus () {
|
|
9299
9405
|
this.isActivated = true
|