vxe-table 3.14.0-beta.9 → 3.14.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 +103 -68
- 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 -5
- package/es/table/render/index.js +2 -2
- package/es/table/src/body.js +43 -25
- 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 +1047 -971
- package/es/table/src/props.js +4 -0
- package/es/table/src/table.js +100 -64
- 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 +2006 -1686
- 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 +119 -105
- 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 +4 -10
- 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 +51 -25
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +39 -23
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/column.js +11 -9
- package/lib/table/src/column.min.js +1 -1
- package/lib/table/src/columnInfo.js +6 -6
- package/lib/table/src/columnInfo.min.js +1 -1
- package/lib/table/src/footer.js +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 +1219 -1151
- 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 +108 -67
- 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 +139 -95
- 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 +3 -6
- package/packages/table/render/index.ts +2 -2
- package/packages/table/src/body.ts +43 -25
- package/packages/table/src/cell.ts +27 -22
- package/packages/table/src/column.ts +14 -10
- package/packages/table/src/columnInfo.ts +9 -6
- package/packages/table/src/footer.ts +12 -7
- package/packages/table/src/group.ts +9 -5
- package/packages/table/src/header.ts +16 -9
- package/packages/table/src/methods.ts +1174 -1027
- package/packages/table/src/props.ts +16 -12
- package/packages/table/src/table.ts +117 -70
- package/packages/table/src/util.ts +65 -23
- package/packages/toolbar/src/toolbar.ts +3 -3
- package/packages/ui/index.ts +1 -0
- /package/es/{iconfont.1741336976538.ttf → iconfont.1743045564244.ttf} +0 -0
- /package/es/{iconfont.1741336976538.woff → iconfont.1743045564244.woff} +0 -0
- /package/es/{iconfont.1741336976538.woff2 → iconfont.1743045564244.woff2} +0 -0
- /package/lib/{iconfont.1741336976538.ttf → iconfont.1743045564244.ttf} +0 -0
- /package/lib/{iconfont.1741336976538.woff → iconfont.1743045564244.woff} +0 -0
- /package/lib/{iconfont.1741336976538.woff2 → iconfont.1743045564244.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) {
|
|
@@ -324,12 +325,12 @@ const updateScrollYStatus = ($xeTable: VxeTableConstructor, fullData?: any[]) =>
|
|
|
324
325
|
const internalData = $xeTable as unknown as TableInternalData
|
|
325
326
|
|
|
326
327
|
const { treeConfig } = props
|
|
327
|
-
const
|
|
328
|
+
const virtualYOpts = $xeTable.computeVirtualYOpts
|
|
328
329
|
const treeOpts = $xeTable.computeTreeOpts
|
|
329
330
|
const { transform } = treeOpts
|
|
330
331
|
const allList = fullData || internalData.tableFullData
|
|
331
332
|
// 如果gt为0,则总是启用
|
|
332
|
-
const scrollYLoad = (transform || !treeConfig) && !!
|
|
333
|
+
const scrollYLoad = (transform || !treeConfig) && !!virtualYOpts.enabled && virtualYOpts.gt > -1 && (virtualYOpts.gt === 0 || virtualYOpts.gt < allList.length)
|
|
333
334
|
reactData.scrollYLoad = scrollYLoad
|
|
334
335
|
return scrollYLoad
|
|
335
336
|
}
|
|
@@ -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) {
|
|
@@ -439,9 +441,9 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
439
441
|
const reactData = $xeTable as unknown as TableReactData
|
|
440
442
|
const internalData = $xeTable as unknown as TableInternalData
|
|
441
443
|
|
|
442
|
-
const {
|
|
444
|
+
const { 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'])
|
|
@@ -601,33 +602,6 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
601
602
|
if (tableElem) {
|
|
602
603
|
tableElem.style.width = tWidth ? `${tWidth}px` : ''
|
|
603
604
|
}
|
|
604
|
-
|
|
605
|
-
const listElem = getRefElem(elemStore[`${name}-${layout}-list`])
|
|
606
|
-
if (isGroup && listElem) {
|
|
607
|
-
XEUtils.arrayEach(listElem.querySelectorAll('.col--group'), (thElem: any) => {
|
|
608
|
-
const colNode = $xeTable.getColumnNode(thElem)
|
|
609
|
-
if (colNode) {
|
|
610
|
-
const column = colNode.item
|
|
611
|
-
const { showHeaderOverflow } = column
|
|
612
|
-
const cellOverflow = XEUtils.isBoolean(showHeaderOverflow) ? showHeaderOverflow : allColumnHeaderOverflow
|
|
613
|
-
const showEllipsis = cellOverflow === 'ellipsis'
|
|
614
|
-
const showTitle = cellOverflow === 'title'
|
|
615
|
-
const showTooltip = cellOverflow === true || cellOverflow === 'tooltip'
|
|
616
|
-
const hasEllipsis = showTitle || showTooltip || showEllipsis
|
|
617
|
-
let childWidth = 0
|
|
618
|
-
let countChild = 0
|
|
619
|
-
if (hasEllipsis) {
|
|
620
|
-
XEUtils.eachTree(column.children, (item) => {
|
|
621
|
-
if (!item.children || !column.children.length) {
|
|
622
|
-
countChild++
|
|
623
|
-
}
|
|
624
|
-
childWidth += item.renderWidth
|
|
625
|
-
}, { children: 'children' })
|
|
626
|
-
}
|
|
627
|
-
thElem.style.width = hasEllipsis ? `${childWidth - countChild - (border ? 2 : 0)}px` : ''
|
|
628
|
-
}
|
|
629
|
-
})
|
|
630
|
-
}
|
|
631
605
|
} else if (layout === 'body') {
|
|
632
606
|
if (currScrollElem) {
|
|
633
607
|
currScrollElem.style.maxHeight = customMaxHeight ? `${bodyMaxHeight}px` : ''
|
|
@@ -732,54 +706,6 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
732
706
|
tableElem.style.width = tWidth ? `${tWidth}px` : ''
|
|
733
707
|
}
|
|
734
708
|
}
|
|
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
709
|
})
|
|
784
710
|
})
|
|
785
711
|
if (currentRow) {
|
|
@@ -791,6 +717,133 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
791
717
|
return $xeTable.$nextTick()
|
|
792
718
|
}
|
|
793
719
|
|
|
720
|
+
function checkValidate ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, type: any) {
|
|
721
|
+
if ($xeTable.triggerValidate) {
|
|
722
|
+
return $xeTable.triggerValidate(type)
|
|
723
|
+
}
|
|
724
|
+
return $xeTable.$nextTick()
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/**
|
|
728
|
+
* 当单元格发生改变时
|
|
729
|
+
* 如果存在规则,则校验
|
|
730
|
+
*/
|
|
731
|
+
function handleChangeCell ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: Event, params: any) {
|
|
732
|
+
checkValidate($xeTable, 'blur')
|
|
733
|
+
.catch((e: any) => e)
|
|
734
|
+
.then(() => {
|
|
735
|
+
$xeTable.handleEdit(params, evnt)
|
|
736
|
+
.then(() => checkValidate($xeTable, 'change'))
|
|
737
|
+
.catch((e: any) => e)
|
|
738
|
+
})
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
function handleDefaultSort ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
742
|
+
const props = $xeTable
|
|
743
|
+
|
|
744
|
+
const { sortConfig } = props
|
|
745
|
+
if (sortConfig) {
|
|
746
|
+
const sortOpts = $xeTable.computeSortOpts
|
|
747
|
+
let { defaultSort } = sortOpts
|
|
748
|
+
if (defaultSort) {
|
|
749
|
+
if (!XEUtils.isArray(defaultSort)) {
|
|
750
|
+
defaultSort = [defaultSort]
|
|
751
|
+
}
|
|
752
|
+
if (defaultSort.length) {
|
|
753
|
+
(sortConfig.multiple ? defaultSort : defaultSort.slice(0, 1)).forEach((item: any, index: number) => {
|
|
754
|
+
const { field, order } = item
|
|
755
|
+
if (field && order) {
|
|
756
|
+
const column = $xeTable.getColumnByField(field)
|
|
757
|
+
if (column && column.sortable) {
|
|
758
|
+
column.order = order
|
|
759
|
+
column.sortTime = Date.now() + index
|
|
760
|
+
}
|
|
761
|
+
}
|
|
762
|
+
})
|
|
763
|
+
if (!sortOpts.remote) {
|
|
764
|
+
$xeTable.handleTableData(true).then(updateStyle)
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
}
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
/**
|
|
772
|
+
* 处理默认勾选
|
|
773
|
+
*/
|
|
774
|
+
function handleDefaultSelectionChecked ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
775
|
+
const props = $xeTable
|
|
776
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
777
|
+
|
|
778
|
+
const { checkboxConfig } = props
|
|
779
|
+
if (checkboxConfig) {
|
|
780
|
+
const { fullDataRowIdData } = internalData
|
|
781
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
782
|
+
const { checkAll, checkRowKeys } = checkboxOpts
|
|
783
|
+
if (checkAll) {
|
|
784
|
+
handleCheckedAllCheckboxRow($xeTable, true, true)
|
|
785
|
+
} else if (checkRowKeys) {
|
|
786
|
+
const defSelection: any[] = []
|
|
787
|
+
checkRowKeys.forEach((rowid: any) => {
|
|
788
|
+
if (fullDataRowIdData[rowid]) {
|
|
789
|
+
defSelection.push(fullDataRowIdData[rowid].row)
|
|
790
|
+
}
|
|
791
|
+
})
|
|
792
|
+
handleCheckedCheckboxRow($xeTable, defSelection, true, true)
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/**
|
|
798
|
+
* 处理单选框默认勾选
|
|
799
|
+
*/
|
|
800
|
+
function handleDefaultRadioChecked ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
801
|
+
const props = $xeTable
|
|
802
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
803
|
+
|
|
804
|
+
const { radioConfig } = props
|
|
805
|
+
if (radioConfig) {
|
|
806
|
+
const { fullDataRowIdData } = internalData
|
|
807
|
+
const radioOpts = $xeTable.computeRadioOpts
|
|
808
|
+
const { checkRowKey: rowid, reserve } = radioOpts
|
|
809
|
+
if (rowid) {
|
|
810
|
+
if (fullDataRowIdData[rowid]) {
|
|
811
|
+
handleCheckedRadioRow(fullDataRowIdData[rowid].row, true)
|
|
812
|
+
}
|
|
813
|
+
if (reserve) {
|
|
814
|
+
const rowkey = getRowkey($xeTable)
|
|
815
|
+
internalData.radioReserveRow = { [rowkey]: rowid }
|
|
816
|
+
}
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
|
|
821
|
+
/**
|
|
822
|
+
* 处理默认展开行
|
|
823
|
+
*/
|
|
824
|
+
function handleDefaultRowExpand ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
825
|
+
const props = $xeTable
|
|
826
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
827
|
+
|
|
828
|
+
const { expandConfig } = props
|
|
829
|
+
if (expandConfig) {
|
|
830
|
+
const { fullDataRowIdData } = internalData
|
|
831
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
832
|
+
const { expandAll, expandRowKeys } = expandOpts
|
|
833
|
+
if (expandAll) {
|
|
834
|
+
$xeTable.setAllRowExpand(true)
|
|
835
|
+
} else if (expandRowKeys) {
|
|
836
|
+
const defExpandeds: any[] = []
|
|
837
|
+
expandRowKeys.forEach((rowid: any) => {
|
|
838
|
+
if (fullDataRowIdData[rowid]) {
|
|
839
|
+
defExpandeds.push(fullDataRowIdData[rowid].row)
|
|
840
|
+
}
|
|
841
|
+
})
|
|
842
|
+
$xeTable.setRowExpand(defExpandeds, true)
|
|
843
|
+
}
|
|
844
|
+
}
|
|
845
|
+
}
|
|
846
|
+
|
|
794
847
|
function handleRadioReserveRow ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, row: any) {
|
|
795
848
|
const internalData = $xeTable as unknown as TableInternalData
|
|
796
849
|
|
|
@@ -842,12 +895,12 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
842
895
|
const internalData = $xeTable as unknown as TableInternalData
|
|
843
896
|
|
|
844
897
|
const { treeConfig } = props
|
|
845
|
-
const { selectCheckboxMaps } =
|
|
846
|
-
const { afterFullData, checkboxReserveRowMap } = internalData
|
|
898
|
+
const { afterFullData, checkboxReserveRowMap, selectCheckboxMaps } = internalData
|
|
847
899
|
const treeOpts = $xeTable.computeTreeOpts
|
|
848
900
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
849
901
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
850
902
|
const { checkField, reserve, checkMethod } = checkboxOpts
|
|
903
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
851
904
|
// indeterminateField 仅支持读取
|
|
852
905
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
853
906
|
const selectRowMaps: Record<string, any> = {}
|
|
@@ -859,7 +912,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
859
912
|
const checkValFn = (row: any) => {
|
|
860
913
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
861
914
|
if (checked) {
|
|
862
|
-
selectRowMaps[
|
|
915
|
+
selectRowMaps[handleGetRowId(row)] = row
|
|
863
916
|
}
|
|
864
917
|
XEUtils.set(row, checkField, checked)
|
|
865
918
|
}
|
|
@@ -887,7 +940,8 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
887
940
|
*/
|
|
888
941
|
XEUtils.eachTree(afterFullData, (row) => {
|
|
889
942
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
890
|
-
|
|
943
|
+
const rowid = handleGetRowId(row)
|
|
944
|
+
selectRowMaps[rowid] = row
|
|
891
945
|
}
|
|
892
946
|
}, { children: childrenField })
|
|
893
947
|
} else {
|
|
@@ -897,7 +951,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
897
951
|
*/
|
|
898
952
|
if (!isForce && checkMethod) {
|
|
899
953
|
XEUtils.eachTree(afterFullData, (row) => {
|
|
900
|
-
const rowid =
|
|
954
|
+
const rowid = handleGetRowId(row)
|
|
901
955
|
if (checkMethod({ row }) ? 0 : selectCheckboxMaps[rowid]) {
|
|
902
956
|
selectRowMaps[rowid] = row
|
|
903
957
|
}
|
|
@@ -913,14 +967,15 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
913
967
|
*/
|
|
914
968
|
if (!isForce && checkMethod) {
|
|
915
969
|
afterFullData.forEach((row) => {
|
|
916
|
-
const rowid =
|
|
970
|
+
const rowid = handleGetRowId(row)
|
|
917
971
|
if (selectCheckboxMaps[rowid] || checkMethod({ row })) {
|
|
918
972
|
selectRowMaps[rowid] = row
|
|
919
973
|
}
|
|
920
974
|
})
|
|
921
975
|
} else {
|
|
922
976
|
afterFullData.forEach(row => {
|
|
923
|
-
|
|
977
|
+
const rowid = handleGetRowId(row)
|
|
978
|
+
selectRowMaps[rowid] = row
|
|
924
979
|
})
|
|
925
980
|
}
|
|
926
981
|
} else {
|
|
@@ -931,7 +986,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
931
986
|
*/
|
|
932
987
|
if (!isForce && checkMethod) {
|
|
933
988
|
afterFullData.forEach((row) => {
|
|
934
|
-
const rowid =
|
|
989
|
+
const rowid = handleGetRowId(row)
|
|
935
990
|
if (checkMethod({ row }) ? 0 : selectCheckboxMaps[rowid]) {
|
|
936
991
|
selectRowMaps[rowid] = row
|
|
937
992
|
}
|
|
@@ -949,11 +1004,11 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
949
1004
|
afterFullData.forEach((row) => handleCheckboxReserveRow($xeTable, row, false))
|
|
950
1005
|
}
|
|
951
1006
|
}
|
|
952
|
-
reactData.
|
|
1007
|
+
reactData.updateCheckboxFlag++
|
|
1008
|
+
internalData.selectCheckboxMaps = checkField ? {} : selectRowMaps
|
|
953
1009
|
|
|
954
1010
|
reactData.isAllSelected = checked
|
|
955
1011
|
reactData.isIndeterminate = false
|
|
956
|
-
reactData.treeIndeterminateMaps = {}
|
|
957
1012
|
internalData.treeIndeterminateRowMaps = {}
|
|
958
1013
|
$xeTable.checkSelectionStatus()
|
|
959
1014
|
return $xeTable.$nextTick()
|
|
@@ -966,8 +1021,8 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
966
1021
|
const internalData = $xeTable as unknown as TableInternalData
|
|
967
1022
|
|
|
968
1023
|
const { treeConfig } = props
|
|
969
|
-
const { expandColumn, currentRow,
|
|
970
|
-
const { fullDataRowIdData, fullAllDataRowIdData, radioReserveRow } = internalData
|
|
1024
|
+
const { expandColumn, currentRow, selectRadioRow } = reactData
|
|
1025
|
+
const { fullDataRowIdData, fullAllDataRowIdData, radioReserveRow, selectCheckboxMaps, treeExpandedMaps, rowExpandedMaps } = internalData
|
|
971
1026
|
const expandOpts = $xeTable.computeExpandOpts
|
|
972
1027
|
const treeOpts = $xeTable.computeTreeOpts
|
|
973
1028
|
const radioOpts = $xeTable.computeRadioOpts
|
|
@@ -984,7 +1039,8 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
984
1039
|
}
|
|
985
1040
|
}
|
|
986
1041
|
// 复选框
|
|
987
|
-
|
|
1042
|
+
internalData.selectCheckboxMaps = getRecoverRowMaps($xeTable, selectCheckboxMaps) // 刷新多选行状态
|
|
1043
|
+
reactData.updateCheckboxFlag++
|
|
988
1044
|
// 还原保留选中状态
|
|
989
1045
|
if (checkboxOpts.reserve) {
|
|
990
1046
|
handleCheckedCheckboxRow($xeTable, handleReserveRow($xeTable, internalData.checkboxReserveRowMap), true, true)
|
|
@@ -993,18 +1049,168 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
993
1049
|
reactData.currentRow = null // 刷新当前行状态
|
|
994
1050
|
}
|
|
995
1051
|
// 行展开
|
|
996
|
-
|
|
1052
|
+
internalData.rowExpandedMaps = expandColumn ? getRecoverRowMaps($xeTable, rowExpandedMaps) : {} // 刷新行展开状态
|
|
1053
|
+
reactData.rowExpandedFlag++
|
|
997
1054
|
// 还原保留状态
|
|
998
1055
|
if (expandColumn && expandOpts.reserve) {
|
|
999
1056
|
$xeTable.setRowExpand(handleReserveRow($xeTable, internalData.rowExpandedReserveRowMap), true)
|
|
1000
1057
|
}
|
|
1001
1058
|
// 树展开
|
|
1002
|
-
|
|
1059
|
+
internalData.treeExpandedMaps = treeConfig ? getRecoverRowMaps($xeTable, treeExpandedMaps) : {} // 刷新树展开状态
|
|
1060
|
+
reactData.treeExpandedFlag++
|
|
1003
1061
|
if (treeConfig && treeOpts.reserve) {
|
|
1004
1062
|
$xeTable.setTreeExpand(handleReserveRow($xeTable, internalData.treeExpandedReserveRowMap), true)
|
|
1005
1063
|
}
|
|
1006
1064
|
}
|
|
1007
1065
|
|
|
1066
|
+
/**
|
|
1067
|
+
* 处理默认展开树节点
|
|
1068
|
+
*/
|
|
1069
|
+
const handleDefaultTreeExpand = ($xeTable: VxeTableConstructor) => {
|
|
1070
|
+
const props = $xeTable
|
|
1071
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1072
|
+
|
|
1073
|
+
const { treeConfig } = props
|
|
1074
|
+
if (treeConfig) {
|
|
1075
|
+
const { tableFullData } = internalData
|
|
1076
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
1077
|
+
const { expandAll, expandRowKeys } = treeOpts
|
|
1078
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
1079
|
+
if (expandAll) {
|
|
1080
|
+
$xeTable.setAllTreeExpand(true)
|
|
1081
|
+
} else if (expandRowKeys) {
|
|
1082
|
+
const defExpandeds: any[] = []
|
|
1083
|
+
const rowkey = getRowkey($xeTable)
|
|
1084
|
+
expandRowKeys.forEach((rowid: any) => {
|
|
1085
|
+
const matchObj = XEUtils.findTree(tableFullData, item => rowid === XEUtils.get(item, rowkey), { children: childrenField })
|
|
1086
|
+
if (matchObj) {
|
|
1087
|
+
defExpandeds.push(matchObj.item)
|
|
1088
|
+
}
|
|
1089
|
+
})
|
|
1090
|
+
$xeTable.setTreeExpand(defExpandeds, true)
|
|
1091
|
+
}
|
|
1092
|
+
}
|
|
1093
|
+
}
|
|
1094
|
+
|
|
1095
|
+
const handleAsyncTreeExpandChilds = ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, row: any): Promise<void> => {
|
|
1096
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
1097
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1098
|
+
|
|
1099
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
1100
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
1101
|
+
const { transform, loadMethod } = treeOpts
|
|
1102
|
+
const { checkStrictly } = checkboxOpts
|
|
1103
|
+
return new Promise<void>(resolve => {
|
|
1104
|
+
if (loadMethod) {
|
|
1105
|
+
const { fullAllDataRowIdData, treeExpandLazyLoadedMaps } = internalData
|
|
1106
|
+
const rowid = getRowid($xeTable, row)
|
|
1107
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
1108
|
+
treeExpandLazyLoadedMaps[rowid] = row
|
|
1109
|
+
Promise.resolve(
|
|
1110
|
+
loadMethod({ $table: $xeTable, row })
|
|
1111
|
+
).then((childRecords: any) => {
|
|
1112
|
+
if (rowRest) {
|
|
1113
|
+
rowRest.treeLoaded = true
|
|
1114
|
+
}
|
|
1115
|
+
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
1116
|
+
delete treeExpandLazyLoadedMaps[rowid]
|
|
1117
|
+
}
|
|
1118
|
+
if (!XEUtils.isArray(childRecords)) {
|
|
1119
|
+
childRecords = []
|
|
1120
|
+
}
|
|
1121
|
+
if (childRecords) {
|
|
1122
|
+
return $xeTable.loadTreeChildren(row, childRecords).then(childRows => {
|
|
1123
|
+
const { treeExpandedMaps } = internalData
|
|
1124
|
+
if (childRows.length && !treeExpandedMaps[rowid]) {
|
|
1125
|
+
treeExpandedMaps[rowid] = row
|
|
1126
|
+
}
|
|
1127
|
+
reactData.treeExpandedFlag++
|
|
1128
|
+
// 如果当前节点已选中,则展开后子节点也被选中
|
|
1129
|
+
if (!checkStrictly && $xeTable.isCheckedByCheckboxRow(row)) {
|
|
1130
|
+
handleCheckedCheckboxRow($xeTable, childRows, true)
|
|
1131
|
+
}
|
|
1132
|
+
return $xeTable.$nextTick().then(() => {
|
|
1133
|
+
if (transform) {
|
|
1134
|
+
$xeTable.handleTableData()
|
|
1135
|
+
updateAfterDataIndex($xeTable)
|
|
1136
|
+
return $xeTable.$nextTick()
|
|
1137
|
+
}
|
|
1138
|
+
})
|
|
1139
|
+
})
|
|
1140
|
+
}
|
|
1141
|
+
}).catch(() => {
|
|
1142
|
+
const { treeExpandLazyLoadedMaps } = internalData
|
|
1143
|
+
if (rowRest) {
|
|
1144
|
+
rowRest.treeLoaded = false
|
|
1145
|
+
}
|
|
1146
|
+
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
1147
|
+
delete treeExpandLazyLoadedMaps[rowid]
|
|
1148
|
+
}
|
|
1149
|
+
}).finally(() => {
|
|
1150
|
+
reactData.treeExpandedFlag++
|
|
1151
|
+
$xeTable.$nextTick().then(() => $xeTable.recalculate()).then(() => resolve())
|
|
1152
|
+
})
|
|
1153
|
+
} else {
|
|
1154
|
+
resolve()
|
|
1155
|
+
}
|
|
1156
|
+
})
|
|
1157
|
+
}
|
|
1158
|
+
|
|
1159
|
+
const handleTreeExpandReserve = ($xeTable: VxeTableConstructor, row: any, expanded: boolean) => {
|
|
1160
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1161
|
+
|
|
1162
|
+
const { treeExpandedReserveRowMap } = internalData
|
|
1163
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
1164
|
+
if (treeOpts.reserve) {
|
|
1165
|
+
const rowid = getRowid($xeTable, row)
|
|
1166
|
+
if (expanded) {
|
|
1167
|
+
treeExpandedReserveRowMap[rowid] = row
|
|
1168
|
+
} else if (treeExpandedReserveRowMap[rowid]) {
|
|
1169
|
+
delete treeExpandedReserveRowMap[rowid]
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
}
|
|
1173
|
+
|
|
1174
|
+
const handleAsyncRowExpand = ($xeTable: VxeTableConstructor, row: any): Promise<void> => {
|
|
1175
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
1176
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1177
|
+
|
|
1178
|
+
return new Promise<void>(resolve => {
|
|
1179
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
1180
|
+
const { loadMethod } = expandOpts
|
|
1181
|
+
if (loadMethod) {
|
|
1182
|
+
const { fullAllDataRowIdData, rowExpandLazyLoadedMaps } = internalData
|
|
1183
|
+
const rowid = getRowid($xeTable, row)
|
|
1184
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
1185
|
+
rowExpandLazyLoadedMaps[rowid] = row
|
|
1186
|
+
loadMethod({ $table: $xeTable, row, rowIndex: $xeTable.getRowIndex(row), $rowIndex: $xeTable.getVMRowIndex(row) }).then(() => {
|
|
1187
|
+
const { rowExpandedMaps } = internalData
|
|
1188
|
+
if (rowRest) {
|
|
1189
|
+
rowRest.expandLoaded = true
|
|
1190
|
+
}
|
|
1191
|
+
rowExpandedMaps[rowid] = row
|
|
1192
|
+
reactData.rowExpandedFlag++
|
|
1193
|
+
}).catch(() => {
|
|
1194
|
+
if (rowRest) {
|
|
1195
|
+
rowRest.expandLoaded = false
|
|
1196
|
+
}
|
|
1197
|
+
}).finally(() => {
|
|
1198
|
+
const { rowExpandLazyLoadedMaps } = internalData
|
|
1199
|
+
if (rowExpandLazyLoadedMaps[rowid]) {
|
|
1200
|
+
delete rowExpandLazyLoadedMaps[rowid]
|
|
1201
|
+
}
|
|
1202
|
+
reactData.rowExpandedFlag++
|
|
1203
|
+
$xeTable.$nextTick()
|
|
1204
|
+
.then(() => $xeTable.recalculate())
|
|
1205
|
+
.then(() => $xeTable.updateCellAreas())
|
|
1206
|
+
.then(() => resolve())
|
|
1207
|
+
})
|
|
1208
|
+
} else {
|
|
1209
|
+
resolve()
|
|
1210
|
+
}
|
|
1211
|
+
})
|
|
1212
|
+
}
|
|
1213
|
+
|
|
1008
1214
|
function calcVarRowHeightConfig ($xeTable: VxeTableConstructor, sizeKey: 'default' | 'medium' | 'small' | 'mini', sizeEl: Element) {
|
|
1009
1215
|
const reactData = $xeTable as unknown as TableReactData
|
|
1010
1216
|
|
|
@@ -1070,12 +1276,13 @@ function handleVirtualYVisible ($xeTable: VxeTableConstructor) {
|
|
|
1070
1276
|
toVisibleIndex = Math.floor(startTop / defaultRowHeight) - 1
|
|
1071
1277
|
visibleSize = Math.ceil(clientHeight / defaultRowHeight) + 1
|
|
1072
1278
|
} else {
|
|
1279
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
1073
1280
|
let leftIndex = 0
|
|
1074
1281
|
let rightIndex = afterFullData.length
|
|
1075
1282
|
while (leftIndex < rightIndex) {
|
|
1076
1283
|
const rIndex = Math.floor((leftIndex + rightIndex) / 2)
|
|
1077
1284
|
const row = afterFullData[rIndex]
|
|
1078
|
-
const rowid =
|
|
1285
|
+
const rowid = handleGetRowId(row)
|
|
1079
1286
|
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
1080
1287
|
if (rowRest.oTop <= startTop) {
|
|
1081
1288
|
leftIndex = rIndex + 1
|
|
@@ -1086,7 +1293,7 @@ function handleVirtualYVisible ($xeTable: VxeTableConstructor) {
|
|
|
1086
1293
|
toVisibleIndex = Math.max(0, leftIndex < afterFullData.length ? leftIndex - 2 : 0)
|
|
1087
1294
|
for (let rIndex = toVisibleIndex, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
|
|
1088
1295
|
const row = afterFullData[rIndex]
|
|
1089
|
-
const rowid =
|
|
1296
|
+
const rowid = handleGetRowId(row)
|
|
1090
1297
|
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
1091
1298
|
visibleSize++
|
|
1092
1299
|
if (rowRest.oTop > endTop || visibleSize >= 100) {
|
|
@@ -1118,16 +1325,20 @@ function calculateMergerOffsetIndex (list: any, offsetItem: any, type: any) {
|
|
|
1118
1325
|
}
|
|
1119
1326
|
}
|
|
1120
1327
|
|
|
1121
|
-
function setMerges (
|
|
1328
|
+
function setMerges ($xeTable: VxeTableConstructor, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[], mList: VxeTableDefines.MergeItem[], rowList?: any[]) {
|
|
1329
|
+
// const props = $xeTable
|
|
1330
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1331
|
+
|
|
1122
1332
|
if (merges) {
|
|
1123
|
-
const { treeConfig
|
|
1333
|
+
// const { treeConfig } = props
|
|
1334
|
+
const { visibleColumn } = internalData
|
|
1124
1335
|
if (!XEUtils.isArray(merges)) {
|
|
1125
1336
|
merges = [merges]
|
|
1126
1337
|
}
|
|
1127
|
-
if (treeConfig && merges.length) {
|
|
1128
|
-
|
|
1129
|
-
}
|
|
1130
|
-
merges.forEach((item
|
|
1338
|
+
// if (treeConfig && merges.length) {
|
|
1339
|
+
// errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
|
|
1340
|
+
// }
|
|
1341
|
+
merges.forEach((item) => {
|
|
1131
1342
|
let { row, col, rowspan, colspan } = item
|
|
1132
1343
|
if (rowList && XEUtils.isNumber(row)) {
|
|
1133
1344
|
row = rowList[row]
|
|
@@ -1166,16 +1377,20 @@ function setMerges (_vm: any, merges: any, mList: any, rowList: any) {
|
|
|
1166
1377
|
}
|
|
1167
1378
|
}
|
|
1168
1379
|
|
|
1169
|
-
function removeMerges (
|
|
1380
|
+
function removeMerges ($xeTable: VxeTableConstructor, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[], mList: VxeTableDefines.MergeItem[], rowList?: any) {
|
|
1381
|
+
// const props = $xeTable
|
|
1382
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1383
|
+
|
|
1170
1384
|
const rest: any[] = []
|
|
1171
1385
|
if (merges) {
|
|
1172
|
-
const { treeConfig
|
|
1386
|
+
// const { treeConfig } = props
|
|
1387
|
+
const { visibleColumn } = internalData
|
|
1173
1388
|
if (!XEUtils.isArray(merges)) {
|
|
1174
1389
|
merges = [merges]
|
|
1175
1390
|
}
|
|
1176
|
-
if (treeConfig && merges.length) {
|
|
1177
|
-
|
|
1178
|
-
}
|
|
1391
|
+
// if (treeConfig && merges.length) {
|
|
1392
|
+
// errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
|
|
1393
|
+
// }
|
|
1179
1394
|
merges.forEach((item: any) => {
|
|
1180
1395
|
let { row, col } = item
|
|
1181
1396
|
if (rowList && XEUtils.isNumber(row)) {
|
|
@@ -1352,6 +1567,7 @@ function autoCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
|
|
|
1352
1567
|
internalData.headerHeight = headerHeight
|
|
1353
1568
|
internalData.footerHeight = footerHeight
|
|
1354
1569
|
reactData.overflowX = overflowX
|
|
1570
|
+
reactData.resizeWidthFlag++
|
|
1355
1571
|
updateColumnOffsetLeft($xeTable)
|
|
1356
1572
|
updateHeight($xeTable)
|
|
1357
1573
|
reactData.parentHeight = Math.max(internalData.headerHeight + footerHeight + 20, $xeTable.getParentHeight())
|
|
@@ -1382,8 +1598,9 @@ const calcCellHeight = ($xeTable: VxeTableConstructor) => {
|
|
|
1382
1598
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
1383
1599
|
const el = $xeTable.$refs.refElem as HTMLDivElement
|
|
1384
1600
|
if (!isAllOverflow && scrollYLoad && el) {
|
|
1601
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
1385
1602
|
tableData.forEach(row => {
|
|
1386
|
-
const rowid =
|
|
1603
|
+
const rowid = handleGetRowId(row)
|
|
1387
1604
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
1388
1605
|
if (rowRest) {
|
|
1389
1606
|
const height = calcCellAutoHeight(rowRest, el)
|
|
@@ -1631,10 +1848,11 @@ function hideDropTip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
1631
1848
|
* @param {Event} evnt 事件
|
|
1632
1849
|
* @param {Row} row 行对象
|
|
1633
1850
|
*/
|
|
1634
|
-
function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: MouseEvent, tdEl: HTMLTableCellElement, overflowElem: HTMLElement
|
|
1851
|
+
function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: MouseEvent, tdEl: HTMLTableCellElement, overflowElem: HTMLElement | null, params: any) {
|
|
1635
1852
|
const reactData = $xeTable as unknown as TableReactData
|
|
1636
1853
|
|
|
1637
|
-
|
|
1854
|
+
const tipOverEl = overflowElem || tdEl
|
|
1855
|
+
if (!tipOverEl) {
|
|
1638
1856
|
return $xeTable.$nextTick()
|
|
1639
1857
|
}
|
|
1640
1858
|
params.cell = tdEl
|
|
@@ -1644,9 +1862,8 @@ function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
|
|
|
1644
1862
|
const { showAll, contentMethod } = tooltipOpts
|
|
1645
1863
|
const customContent = contentMethod ? contentMethod(params) : null
|
|
1646
1864
|
const useCustom = contentMethod && !XEUtils.eqNull(customContent)
|
|
1647
|
-
const content = useCustom ? customContent : XEUtils.toString(column.type === 'html' ?
|
|
1648
|
-
|
|
1649
|
-
if (content && (showAll || useCustom || isCellOverflow)) {
|
|
1865
|
+
const content = useCustom ? customContent : XEUtils.toString(column.type === 'html' ? tipOverEl.innerText : tipOverEl.textContent).trim()
|
|
1866
|
+
if (content && (showAll || useCustom || (tipOverEl.scrollWidth > tipOverEl.clientWidth))) {
|
|
1650
1867
|
Object.assign(tooltipStore, {
|
|
1651
1868
|
row,
|
|
1652
1869
|
column,
|
|
@@ -1656,7 +1873,7 @@ function handleTooltip ($xeTable: VxeTableConstructor & VxeTablePrivateMethods,
|
|
|
1656
1873
|
$xeTable.$nextTick(() => {
|
|
1657
1874
|
const $tooltip = $xeTable.$refs.refTooltip as VxeTooltipInstance
|
|
1658
1875
|
if ($tooltip && $tooltip.open) {
|
|
1659
|
-
$tooltip.open(
|
|
1876
|
+
$tooltip.open(tipOverEl, formatText(content))
|
|
1660
1877
|
}
|
|
1661
1878
|
})
|
|
1662
1879
|
}
|
|
@@ -1674,7 +1891,7 @@ function handleScrollToRowColumn ($xeTable: VxeTableConstructor & VxeTablePrivat
|
|
|
1674
1891
|
return $xeTable.$nextTick()
|
|
1675
1892
|
}
|
|
1676
1893
|
|
|
1677
|
-
|
|
1894
|
+
function handleRowExpandReserve ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, row: any, expanded: boolean) {
|
|
1678
1895
|
const internalData = $xeTable as unknown as TableInternalData
|
|
1679
1896
|
|
|
1680
1897
|
const { rowExpandedReserveRowMap } = internalData
|
|
@@ -1689,6 +1906,24 @@ const handleRowExpandReserve = ($xeTable: VxeTableConstructor & VxeTablePrivateM
|
|
|
1689
1906
|
}
|
|
1690
1907
|
}
|
|
1691
1908
|
|
|
1909
|
+
function handleDefaultMergeCells ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
1910
|
+
const props = $xeTable
|
|
1911
|
+
|
|
1912
|
+
const { mergeCells } = props
|
|
1913
|
+
if (mergeCells) {
|
|
1914
|
+
$xeTable.setMergeCells(mergeCells)
|
|
1915
|
+
}
|
|
1916
|
+
}
|
|
1917
|
+
|
|
1918
|
+
function handleDefaultMergeFooterItems ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
1919
|
+
const props = $xeTable
|
|
1920
|
+
|
|
1921
|
+
const { mergeFooterItems } = props
|
|
1922
|
+
if (mergeFooterItems) {
|
|
1923
|
+
$xeTable.setMergeFooterItems(mergeFooterItems)
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
|
|
1692
1927
|
// 计算可视渲染相关数据
|
|
1693
1928
|
function computeScrollLoad ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
1694
1929
|
const reactData = $xeTable as unknown as TableReactData
|
|
@@ -1778,6 +2013,28 @@ function handleRecalculateLayout ($xeTable: VxeTableConstructor & VxeTablePrivat
|
|
|
1778
2013
|
})
|
|
1779
2014
|
}
|
|
1780
2015
|
|
|
2016
|
+
/**
|
|
2017
|
+
* 处理数据加载默认行为
|
|
2018
|
+
* 默认执行一次,除非被重置
|
|
2019
|
+
*/
|
|
2020
|
+
function handleLoadDefaults ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
2021
|
+
handleDefaultSelectionChecked($xeTable)
|
|
2022
|
+
handleDefaultRadioChecked($xeTable)
|
|
2023
|
+
handleDefaultRowExpand($xeTable)
|
|
2024
|
+
handleDefaultTreeExpand($xeTable)
|
|
2025
|
+
handleDefaultMergeCells($xeTable)
|
|
2026
|
+
handleDefaultMergeFooterItems($xeTable)
|
|
2027
|
+
$xeTable.$nextTick(() => setTimeout(() => $xeTable.recalculate()))
|
|
2028
|
+
}
|
|
2029
|
+
|
|
2030
|
+
/**
|
|
2031
|
+
* 处理初始化的默认行为
|
|
2032
|
+
* 只会执行一次
|
|
2033
|
+
*/
|
|
2034
|
+
function handleInitDefaults ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
2035
|
+
handleDefaultSort($xeTable)
|
|
2036
|
+
}
|
|
2037
|
+
|
|
1781
2038
|
function handleTableColumn ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
1782
2039
|
const reactData = $xeTable as unknown as TableReactData
|
|
1783
2040
|
const internalData = $xeTable as unknown as TableInternalData
|
|
@@ -1845,13 +2102,13 @@ function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, i
|
|
|
1845
2102
|
const reactData = $xeTable as unknown as TableReactData
|
|
1846
2103
|
const internalData = $xeTable as unknown as TableInternalData
|
|
1847
2104
|
|
|
1848
|
-
const { showOverflow } = props
|
|
1849
|
-
const rowOpts = $xeTable.computeRowOpts
|
|
2105
|
+
// const { showOverflow } = props
|
|
2106
|
+
// const rowOpts = $xeTable.computeRowOpts
|
|
1850
2107
|
const leftList: VxeTableDefines.ColumnInfo[] = []
|
|
1851
2108
|
const centerList: VxeTableDefines.ColumnInfo[] = []
|
|
1852
2109
|
const rightList: VxeTableDefines.ColumnInfo[] = []
|
|
1853
2110
|
const { isGroup, columnStore } = reactData
|
|
1854
|
-
const
|
|
2111
|
+
const virtualXOpts = $xeTable.computeVirtualXOpts
|
|
1855
2112
|
const { collectColumn, tableFullColumn, scrollXStore, fullColumnIdData } = internalData
|
|
1856
2113
|
// 如果是分组表头,如果子列全部被隐藏,则根列也隐藏
|
|
1857
2114
|
if (isGroup) {
|
|
@@ -1907,32 +2164,32 @@ function parseColumns ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, i
|
|
|
1907
2164
|
}
|
|
1908
2165
|
const visibleColumn = leftList.concat(centerList).concat(rightList)
|
|
1909
2166
|
// 如果gt为0,则总是启用
|
|
1910
|
-
const scrollXLoad = !!
|
|
2167
|
+
const scrollXLoad = !!virtualXOpts.enabled && virtualXOpts.gt > -1 && (virtualXOpts.gt === 0 || virtualXOpts.gt < tableFullColumn.length)
|
|
1911
2168
|
reactData.hasFixedColumn = leftList.length > 0 || rightList.length > 0
|
|
1912
2169
|
Object.assign(columnStore, { leftList, centerList, rightList })
|
|
1913
2170
|
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
|
-
}
|
|
2171
|
+
// if (showOverflow) {
|
|
2172
|
+
// if (!rowOpts.height) {
|
|
2173
|
+
// const errColumn = internalData.tableFullColumn.find(column => column.showOverflow === false)
|
|
2174
|
+
// if (errColumn) {
|
|
2175
|
+
// errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true'])
|
|
2176
|
+
// }
|
|
2177
|
+
// }
|
|
2178
|
+
// }
|
|
2179
|
+
// if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
2180
|
+
// if (props.showHeader && !props.showHeaderOverflow) {
|
|
2181
|
+
// warnLog('vxe.error.reqProp', ['show-header-overflow'])
|
|
2182
|
+
// }
|
|
2183
|
+
// if (props.showFooter && !props.showFooterOverflow) {
|
|
2184
|
+
// warnLog('vxe.error.reqProp', ['show-footer-overflow'])
|
|
2185
|
+
// }
|
|
2186
|
+
if (props.spanMethod) {
|
|
2187
|
+
warnLog('vxe.error.scrollErrProp', ['span-method'])
|
|
2188
|
+
}
|
|
2189
|
+
if (props.footerSpanMethod) {
|
|
2190
|
+
warnLog('vxe.error.scrollErrProp', ['footer-span-method'])
|
|
2191
|
+
}
|
|
2192
|
+
// }
|
|
1936
2193
|
if (isReset) {
|
|
1937
2194
|
const { visibleSize } = handleVirtualXVisible($xeTable)
|
|
1938
2195
|
scrollXStore.startIndex = 0
|
|
@@ -2055,6 +2312,39 @@ function loadScrollYData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods
|
|
|
2055
2312
|
}
|
|
2056
2313
|
}
|
|
2057
2314
|
|
|
2315
|
+
const createGetRowCacheProp = (prop: 'seq' | 'index' | '_index' | '$index') => {
|
|
2316
|
+
return function (this: VxeTableConstructor & VxeTablePrivateMethods, row: any) {
|
|
2317
|
+
const $xeTable = this
|
|
2318
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
2319
|
+
|
|
2320
|
+
const { fullAllDataRowIdData } = internalData
|
|
2321
|
+
if (row) {
|
|
2322
|
+
const rowid = getRowid($xeTable, row)
|
|
2323
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
2324
|
+
if (rowRest) {
|
|
2325
|
+
return rowRest[prop]
|
|
2326
|
+
}
|
|
2327
|
+
}
|
|
2328
|
+
return -1
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
|
|
2332
|
+
const createGetColumnCacheProp = (prop: 'index' | '_index' | '$index') => {
|
|
2333
|
+
return function (this: VxeTableConstructor & VxeTablePrivateMethods, column: VxeTableDefines.ColumnInfo) {
|
|
2334
|
+
const $xeTable = this
|
|
2335
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
2336
|
+
|
|
2337
|
+
const { fullColumnIdData } = internalData
|
|
2338
|
+
if (column) {
|
|
2339
|
+
const colRest = fullColumnIdData[column.id]
|
|
2340
|
+
if (colRest) {
|
|
2341
|
+
return colRest[prop]
|
|
2342
|
+
}
|
|
2343
|
+
}
|
|
2344
|
+
return -1
|
|
2345
|
+
}
|
|
2346
|
+
}
|
|
2347
|
+
|
|
2058
2348
|
function lazyScrollXData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
2059
2349
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2060
2350
|
|
|
@@ -2221,7 +2511,7 @@ function calcCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
|
|
|
2221
2511
|
|
|
2222
2512
|
function handleUpdateColResize ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: MouseEvent, params: any) {
|
|
2223
2513
|
$xeTable.analyColumnWidth()
|
|
2224
|
-
$xeTable.recalculate(
|
|
2514
|
+
$xeTable.recalculate().then(() => {
|
|
2225
2515
|
$xeTable.saveCustomStore('update:width')
|
|
2226
2516
|
$xeTable.updateCellAreas()
|
|
2227
2517
|
$xeTable.dispatchEvent('column-resizable-change', params, evnt)
|
|
@@ -2235,7 +2525,7 @@ function handleUpdateRowResize ($xeTable: VxeTableConstructor & VxeTablePrivateM
|
|
|
2235
2525
|
const reactData = $xeTable as unknown as TableReactData
|
|
2236
2526
|
|
|
2237
2527
|
reactData.resizeHeightFlag++
|
|
2238
|
-
$xeTable.recalculate(
|
|
2528
|
+
$xeTable.recalculate().then(() => {
|
|
2239
2529
|
$xeTable.updateCellAreas()
|
|
2240
2530
|
$xeTable.dispatchEvent('row-resizable-change', params, evnt)
|
|
2241
2531
|
setTimeout(() => $xeTable.recalculate(true), 300)
|
|
@@ -2260,16 +2550,17 @@ function updateRowOffsetTop ($xeTable: VxeTableConstructor & VxeTablePrivateMeth
|
|
|
2260
2550
|
const reactData = $xeTable as unknown as TableReactData
|
|
2261
2551
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2262
2552
|
|
|
2263
|
-
const { expandColumn
|
|
2264
|
-
const { afterFullData, fullAllDataRowIdData } = internalData
|
|
2553
|
+
const { expandColumn } = reactData
|
|
2554
|
+
const { afterFullData, fullAllDataRowIdData, rowExpandedMaps } = internalData
|
|
2265
2555
|
const expandOpts = $xeTable.computeExpandOpts
|
|
2266
2556
|
const rowOpts = $xeTable.computeRowOpts
|
|
2267
2557
|
const cellOpts = $xeTable.computeCellOpts
|
|
2268
2558
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
2559
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
2269
2560
|
let offsetTop = 0
|
|
2270
2561
|
for (let rIndex = 0, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
|
|
2271
2562
|
const row = afterFullData[rIndex]
|
|
2272
|
-
const rowid =
|
|
2563
|
+
const rowid = handleGetRowId(row)
|
|
2273
2564
|
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
2274
2565
|
rowRest.oTop = offsetTop
|
|
2275
2566
|
offsetTop += rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight
|
|
@@ -2284,46 +2575,42 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
|
|
|
2284
2575
|
const reactData = $xeTable as unknown as TableReactData
|
|
2285
2576
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2286
2577
|
|
|
2287
|
-
const { expandColumn, scrollYLoad,
|
|
2578
|
+
const { expandColumn, scrollYLoad, scrollYTop, isScrollYBig } = reactData
|
|
2288
2579
|
const expandOpts = $xeTable.computeExpandOpts
|
|
2289
2580
|
const rowOpts = $xeTable.computeRowOpts
|
|
2290
2581
|
const cellOpts = $xeTable.computeCellOpts
|
|
2291
2582
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
2292
2583
|
const { mode } = expandOpts
|
|
2293
2584
|
if (expandColumn && mode === 'fixed') {
|
|
2294
|
-
const { elemStore,
|
|
2585
|
+
const { elemStore, fullAllDataRowIdData } = internalData
|
|
2295
2586
|
const rowExpandEl = $xeTable.$refs.refRowExpandElem as HTMLDivElement
|
|
2296
2587
|
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
2297
2588
|
if (rowExpandEl && bodyScrollElem) {
|
|
2298
2589
|
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
2590
|
XEUtils.arrayEach(rowExpandEl.children, reEl => {
|
|
2314
2591
|
const expandEl = reEl as HTMLDivElement
|
|
2315
2592
|
const rowid = expandEl.getAttribute('rowid') || ''
|
|
2316
2593
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
2317
2594
|
if (rowRest) {
|
|
2318
2595
|
const expandHeight = expandEl.offsetHeight + 1
|
|
2596
|
+
const trEl = bodyScrollElem.querySelector(`.vxe-body--row[rowid="${rowid}"]`) as HTMLTableCellElement
|
|
2597
|
+
let offsetTop = 0
|
|
2319
2598
|
if (scrollYLoad) {
|
|
2320
|
-
|
|
2599
|
+
if (isScrollYBig && trEl) {
|
|
2600
|
+
offsetTop = trEl.offsetTop + trEl.offsetHeight
|
|
2601
|
+
} else {
|
|
2602
|
+
offsetTop = rowRest.oTop + (rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight)
|
|
2603
|
+
}
|
|
2321
2604
|
} else {
|
|
2322
|
-
const trEl = bodyScrollElem.querySelector(`.vxe-body--row[rowid="${rowid}"]`) as HTMLTableCellElement
|
|
2323
2605
|
if (trEl) {
|
|
2324
|
-
|
|
2606
|
+
offsetTop = trEl.offsetTop + trEl.offsetHeight
|
|
2325
2607
|
}
|
|
2326
2608
|
}
|
|
2609
|
+
if (isScrollYBig) {
|
|
2610
|
+
offsetTop += scrollYTop
|
|
2611
|
+
}
|
|
2612
|
+
expandEl.style.top = toCssUnit(offsetTop)
|
|
2613
|
+
|
|
2327
2614
|
if (!isUpdateHeight) {
|
|
2328
2615
|
if (rowRest.expandHeight !== expandHeight) {
|
|
2329
2616
|
isUpdateHeight = true
|
|
@@ -2334,6 +2621,9 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
|
|
|
2334
2621
|
})
|
|
2335
2622
|
if (isUpdateHeight) {
|
|
2336
2623
|
reactData.rowExpandHeightFlag++
|
|
2624
|
+
$xeTable.$nextTick(() => {
|
|
2625
|
+
updateRowOffsetTop($xeTable)
|
|
2626
|
+
})
|
|
2337
2627
|
}
|
|
2338
2628
|
}
|
|
2339
2629
|
}
|
|
@@ -2352,10 +2642,12 @@ function handleRowExpandScroll ($xeTable: VxeTableConstructor & VxeTablePrivateM
|
|
|
2352
2642
|
|
|
2353
2643
|
const Methods = {
|
|
2354
2644
|
callSlot (slotFunc: any, params: any, h: any, vNodes: any) {
|
|
2645
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2646
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
2647
|
+
|
|
2355
2648
|
if (slotFunc) {
|
|
2356
|
-
|
|
2357
|
-
|
|
2358
|
-
return $xegrid.callSlot(slotFunc, params, h, vNodes)
|
|
2649
|
+
if ($xeGrid) {
|
|
2650
|
+
return $xeGrid.callSlot(slotFunc, params, h, vNodes)
|
|
2359
2651
|
}
|
|
2360
2652
|
if (XEUtils.isFunction(slotFunc)) {
|
|
2361
2653
|
return getSlotVNs(slotFunc.call(this, params, h, vNodes))
|
|
@@ -2372,8 +2664,11 @@ const Methods = {
|
|
|
2372
2664
|
* 获取父容器元素
|
|
2373
2665
|
*/
|
|
2374
2666
|
getParentElem () {
|
|
2375
|
-
const
|
|
2376
|
-
|
|
2667
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2668
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
2669
|
+
|
|
2670
|
+
const { $el } = this
|
|
2671
|
+
return $xeGrid ? $xeGrid.$el.parentNode : $el.parentNode
|
|
2377
2672
|
},
|
|
2378
2673
|
/**
|
|
2379
2674
|
* 获取父容器的高度
|
|
@@ -2406,8 +2701,10 @@ const Methods = {
|
|
|
2406
2701
|
* 如果存在表尾合计滚动条,则需要排除滚动条高度
|
|
2407
2702
|
*/
|
|
2408
2703
|
getExcludeHeight () {
|
|
2409
|
-
const
|
|
2410
|
-
|
|
2704
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2705
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
2706
|
+
|
|
2707
|
+
return $xeGrid ? $xeGrid.getExcludeHeight() : 0
|
|
2411
2708
|
},
|
|
2412
2709
|
/**
|
|
2413
2710
|
* 重置表格的一切数据状态
|
|
@@ -2481,16 +2778,24 @@ const Methods = {
|
|
|
2481
2778
|
*/
|
|
2482
2779
|
loadTableData (datas: any[], isReset: boolean) {
|
|
2483
2780
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2781
|
+
const props = $xeTable
|
|
2484
2782
|
const reactData = $xeTable as unknown as TableReactData
|
|
2485
2783
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2486
2784
|
|
|
2487
|
-
const { keepSource, treeConfig
|
|
2785
|
+
const { keepSource, treeConfig } = props
|
|
2786
|
+
const { scrollYLoad: oldScrollYLoad } = reactData
|
|
2787
|
+
const { scrollYStore, scrollXStore, lastScrollLeft, lastScrollTop } = internalData
|
|
2788
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
2789
|
+
const { transform } = treeOpts
|
|
2488
2790
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
2489
2791
|
let treeData = []
|
|
2490
2792
|
let fullData = datas ? datas.slice(0) : []
|
|
2793
|
+
if (fullData.length > supportMaxRow) {
|
|
2794
|
+
errLog('vxe.error.errMaxRow', [supportMaxRow])
|
|
2795
|
+
}
|
|
2491
2796
|
if (treeConfig) {
|
|
2492
2797
|
// 树结构自动转换
|
|
2493
|
-
if (
|
|
2798
|
+
if (transform) {
|
|
2494
2799
|
if (!treeOpts.rowField) {
|
|
2495
2800
|
errLog('vxe.error.reqProp', ['table.tree-config.rowField'])
|
|
2496
2801
|
}
|
|
@@ -2528,8 +2833,8 @@ const Methods = {
|
|
|
2528
2833
|
scrollXStore.endIndex = 1
|
|
2529
2834
|
reactData.isRowLoading = true
|
|
2530
2835
|
reactData.scrollVMLoading = false
|
|
2531
|
-
|
|
2532
|
-
|
|
2836
|
+
internalData.insertRowMaps = {}
|
|
2837
|
+
internalData.removeRowMaps = {}
|
|
2533
2838
|
const sYLoad = updateScrollYStatus($xeTable, fullData)
|
|
2534
2839
|
reactData.isDragColMove = false
|
|
2535
2840
|
reactData.isDragRowMove = false
|
|
@@ -2547,15 +2852,15 @@ const Methods = {
|
|
|
2547
2852
|
if (keepSource) {
|
|
2548
2853
|
$xeTable.cacheSourceMap(fullData)
|
|
2549
2854
|
}
|
|
2550
|
-
if (
|
|
2551
|
-
|
|
2552
|
-
|
|
2855
|
+
if ($xeTable.clearCellAreas && props.mouseConfig) {
|
|
2856
|
+
$xeTable.clearCellAreas()
|
|
2857
|
+
$xeTable.clearCopyCellArea()
|
|
2553
2858
|
}
|
|
2554
|
-
|
|
2555
|
-
|
|
2556
|
-
|
|
2557
|
-
|
|
2558
|
-
return
|
|
2859
|
+
$xeTable.clearMergeCells()
|
|
2860
|
+
$xeTable.clearMergeFooterItems()
|
|
2861
|
+
$xeTable.handleTableData(true)
|
|
2862
|
+
$xeTable.updateFooter()
|
|
2863
|
+
return $xeTable.$nextTick().then(() => {
|
|
2559
2864
|
updateHeight($xeTable)
|
|
2560
2865
|
updateStyle($xeTable)
|
|
2561
2866
|
}).then(() => {
|
|
@@ -2569,50 +2874,52 @@ const Methods = {
|
|
|
2569
2874
|
if (sYLoad) {
|
|
2570
2875
|
// if (showOverflow) {
|
|
2571
2876
|
// if (!rowOpts.height) {
|
|
2572
|
-
// const errColumn =
|
|
2877
|
+
// const errColumn = internalData.tableFullColumn.find((column: any) => column.showOverflow === false)
|
|
2573
2878
|
// if (errColumn) {
|
|
2574
2879
|
// errLog('vxe.error.errProp', [`column[field="${errColumn.field}"].show-overflow=false`, 'show-overflow=true'])
|
|
2575
2880
|
// }
|
|
2576
2881
|
// }
|
|
2577
2882
|
// }
|
|
2578
2883
|
|
|
2579
|
-
if (!(
|
|
2884
|
+
if (!(props.height || props.maxHeight)) {
|
|
2580
2885
|
errLog('vxe.error.reqProp', ['table.height | table.max-height | table.scroll-y={enabled: false}'])
|
|
2581
2886
|
}
|
|
2582
|
-
// if (!
|
|
2887
|
+
// if (!props.showOverflow) {
|
|
2583
2888
|
// warnLog('vxe.error.reqProp', ['table.show-overflow'])
|
|
2584
2889
|
// }
|
|
2585
|
-
if (
|
|
2890
|
+
if (props.spanMethod) {
|
|
2586
2891
|
errLog('vxe.error.scrollErrProp', ['table.span-method'])
|
|
2587
2892
|
}
|
|
2588
2893
|
}
|
|
2589
2894
|
|
|
2590
2895
|
handleReserveStatus($xeTable)
|
|
2591
|
-
|
|
2896
|
+
$xeTable.checkSelectionStatus()
|
|
2592
2897
|
return new Promise<void>(resolve => {
|
|
2593
2898
|
this.$nextTick()
|
|
2594
|
-
.then(() =>
|
|
2899
|
+
.then(() => $xeTable.recalculate())
|
|
2595
2900
|
.then(() => {
|
|
2596
2901
|
let targetScrollLeft = lastScrollLeft
|
|
2597
2902
|
let targetScrollTop = lastScrollTop
|
|
2903
|
+
const virtualXOpts = $xeTable.computeVirtualXOpts
|
|
2904
|
+
const virtualYOpts = $xeTable.computeVirtualYOpts
|
|
2598
2905
|
// 是否在更新数据之后自动滚动重置滚动条
|
|
2599
|
-
if (
|
|
2906
|
+
if (virtualXOpts.scrollToLeftOnChange) {
|
|
2600
2907
|
targetScrollLeft = 0
|
|
2601
2908
|
}
|
|
2602
|
-
if (
|
|
2909
|
+
if (virtualYOpts.scrollToTopOnChange) {
|
|
2603
2910
|
targetScrollTop = 0
|
|
2604
2911
|
}
|
|
2605
2912
|
reactData.isRowLoading = false
|
|
2606
2913
|
calcCellHeight($xeTable)
|
|
2607
2914
|
// 是否变更虚拟滚动
|
|
2608
2915
|
if (oldScrollYLoad === sYLoad) {
|
|
2609
|
-
restoreScrollLocation(
|
|
2916
|
+
restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
|
|
2610
2917
|
.then(() => {
|
|
2611
2918
|
resolve()
|
|
2612
2919
|
})
|
|
2613
2920
|
} else {
|
|
2614
2921
|
setTimeout(() => {
|
|
2615
|
-
restoreScrollLocation(
|
|
2922
|
+
restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
|
|
2616
2923
|
.then(() => {
|
|
2617
2924
|
resolve()
|
|
2618
2925
|
})
|
|
@@ -2627,12 +2934,14 @@ const Methods = {
|
|
|
2627
2934
|
* @param {Array} datas 数据
|
|
2628
2935
|
*/
|
|
2629
2936
|
loadData (datas: any) {
|
|
2937
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2938
|
+
|
|
2630
2939
|
const { initStatus } = this
|
|
2631
2940
|
return this.loadTableData(datas, false).then(() => {
|
|
2632
2941
|
this.inited = true
|
|
2633
2942
|
this.initStatus = true
|
|
2634
2943
|
if (!initStatus) {
|
|
2635
|
-
|
|
2944
|
+
handleLoadDefaults($xeTable)
|
|
2636
2945
|
}
|
|
2637
2946
|
return this.recalculate()
|
|
2638
2947
|
})
|
|
@@ -2642,6 +2951,8 @@ const Methods = {
|
|
|
2642
2951
|
* @param {Array} datas 数据
|
|
2643
2952
|
*/
|
|
2644
2953
|
reloadData (datas: any) {
|
|
2954
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2955
|
+
|
|
2645
2956
|
return this.clearAll()
|
|
2646
2957
|
.then(() => {
|
|
2647
2958
|
this.inited = true
|
|
@@ -2649,7 +2960,7 @@ const Methods = {
|
|
|
2649
2960
|
return this.loadTableData(datas, true)
|
|
2650
2961
|
})
|
|
2651
2962
|
.then(() => {
|
|
2652
|
-
|
|
2963
|
+
handleLoadDefaults($xeTable)
|
|
2653
2964
|
return this.recalculate()
|
|
2654
2965
|
})
|
|
2655
2966
|
},
|
|
@@ -2732,19 +3043,15 @@ const Methods = {
|
|
|
2732
3043
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2733
3044
|
|
|
2734
3045
|
const { treeConfig } = props
|
|
2735
|
-
const { treeExpandedMaps } =
|
|
2736
|
-
const { fullAllDataRowIdData, tableFullData, tableFullTreeData } = internalData
|
|
3046
|
+
const { fullAllDataRowIdData, tableFullData, tableFullTreeData, treeExpandedMaps } = internalData
|
|
2737
3047
|
const treeOpts = $xeTable.computeTreeOpts
|
|
2738
3048
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
2739
3049
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
2740
3050
|
const { lazy } = treeOpts
|
|
2741
|
-
const rowkey = getRowkey($xeTable)
|
|
2742
|
-
const isDeepKey = rowkey.indexOf('.') > -1
|
|
2743
3051
|
const fullAllDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = { ...fullAllDataRowIdData } // 存在已删除数据
|
|
2744
3052
|
const fullDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = {}
|
|
2745
|
-
const treeTempExpandedMaps = { ...treeExpandedMaps }
|
|
2746
3053
|
|
|
2747
|
-
const
|
|
3054
|
+
const { handleUpdateRowId } = createHandleUpdateRowId($xeTable)
|
|
2748
3055
|
const handleRowCache = (row: any, index: number, items: any, currIndex: number, parentRow: any, rowid: string, level: number, seq: string | number) => {
|
|
2749
3056
|
let rowRest = fullAllDataRowIdMaps[rowid]
|
|
2750
3057
|
if (!rowRest) {
|
|
@@ -2766,15 +3073,14 @@ const Methods = {
|
|
|
2766
3073
|
|
|
2767
3074
|
if (treeConfig) {
|
|
2768
3075
|
XEUtils.eachTree(tableFullTreeData, (row, index, items, path, parentRow, nodes) => {
|
|
2769
|
-
const rowid =
|
|
3076
|
+
const rowid = handleUpdateRowId(row)
|
|
2770
3077
|
if (treeConfig && lazy) {
|
|
2771
|
-
const treeExpRest = treeTempExpandedMaps[rowid]
|
|
2772
3078
|
if (row[hasChildField] && row[childrenField] === undefined) {
|
|
2773
3079
|
row[childrenField] = null
|
|
2774
3080
|
}
|
|
2775
|
-
if (
|
|
3081
|
+
if (treeExpandedMaps[rowid]) {
|
|
2776
3082
|
if (!row[childrenField] || !row[childrenField].length) {
|
|
2777
|
-
delete
|
|
3083
|
+
delete treeExpandedMaps[rowid]
|
|
2778
3084
|
}
|
|
2779
3085
|
}
|
|
2780
3086
|
}
|
|
@@ -2782,13 +3088,13 @@ const Methods = {
|
|
|
2782
3088
|
}, { children: childrenField })
|
|
2783
3089
|
} else {
|
|
2784
3090
|
tableFullData.forEach((row, index, items) => {
|
|
2785
|
-
handleRowCache(row, index, items, index, null,
|
|
3091
|
+
handleRowCache(row, index, items, index, null, handleUpdateRowId(row), 0, index + 1)
|
|
2786
3092
|
})
|
|
2787
3093
|
}
|
|
2788
3094
|
|
|
2789
3095
|
internalData.fullDataRowIdData = fullDataRowIdMaps
|
|
2790
3096
|
internalData.fullAllDataRowIdData = fullAllDataRowIdMaps
|
|
2791
|
-
reactData.
|
|
3097
|
+
reactData.treeExpandedFlag++
|
|
2792
3098
|
},
|
|
2793
3099
|
cacheSourceMap (fullData: any[]) {
|
|
2794
3100
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
@@ -2797,17 +3103,12 @@ const Methods = {
|
|
|
2797
3103
|
|
|
2798
3104
|
const { treeConfig } = props
|
|
2799
3105
|
const treeOpts = $xeTable.computeTreeOpts
|
|
2800
|
-
let { sourceDataRowIdData } = internalData
|
|
2801
3106
|
const sourceData = XEUtils.clone(fullData, true)
|
|
2802
|
-
const
|
|
2803
|
-
|
|
3107
|
+
const { handleUpdateRowId } = createHandleUpdateRowId($xeTable)
|
|
3108
|
+
const sourceRowIdData: Record<string, any> = {}
|
|
2804
3109
|
const handleSourceRow = (row: any) => {
|
|
2805
|
-
|
|
2806
|
-
|
|
2807
|
-
rowid = getRowUniqueId()
|
|
2808
|
-
XEUtils.set(row, rowkey, rowid)
|
|
2809
|
-
}
|
|
2810
|
-
sourceDataRowIdData[rowid] = row
|
|
3110
|
+
const rowid = handleUpdateRowId(row)
|
|
3111
|
+
sourceRowIdData[rowid] = row
|
|
2811
3112
|
}
|
|
2812
3113
|
// 源数据缓存
|
|
2813
3114
|
if (treeConfig) {
|
|
@@ -2816,15 +3117,23 @@ const Methods = {
|
|
|
2816
3117
|
} else {
|
|
2817
3118
|
sourceData.forEach(handleSourceRow)
|
|
2818
3119
|
}
|
|
3120
|
+
internalData.sourceDataRowIdData = sourceRowIdData
|
|
2819
3121
|
internalData.tableSourceData = sourceData
|
|
2820
3122
|
},
|
|
2821
3123
|
getParams () {
|
|
2822
|
-
|
|
3124
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3125
|
+
const props = $xeTable
|
|
3126
|
+
|
|
3127
|
+
return props.params
|
|
2823
3128
|
},
|
|
2824
3129
|
loadTreeChildren (row: any, childRecords: any) {
|
|
2825
|
-
const $xeTable = this
|
|
3130
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3131
|
+
const props = $xeTable
|
|
3132
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
2826
3133
|
|
|
2827
|
-
const { keepSource
|
|
3134
|
+
const { keepSource } = props
|
|
3135
|
+
const { tableSourceData, fullDataRowIdData, fullAllDataRowIdData, sourceDataRowIdData } = internalData
|
|
3136
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
2828
3137
|
const { transform, mapChildrenField } = treeOpts
|
|
2829
3138
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
2830
3139
|
const parentRest = fullAllDataRowIdData[getRowid($xeTable, row)]
|
|
@@ -2832,7 +3141,7 @@ const Methods = {
|
|
|
2832
3141
|
return this.createData(childRecords).then((rows: any) => {
|
|
2833
3142
|
if (keepSource) {
|
|
2834
3143
|
const rowid = getRowid(this, row)
|
|
2835
|
-
const matchObj = XEUtils.findTree(tableSourceData
|
|
3144
|
+
const matchObj = XEUtils.findTree(tableSourceData, (item) => rowid === getRowid(this, item), { children: childrenField })
|
|
2836
3145
|
if (matchObj) {
|
|
2837
3146
|
matchObj.item[childrenField] = XEUtils.clone(rows, true)
|
|
2838
3147
|
}
|
|
@@ -2860,18 +3169,23 @@ const Methods = {
|
|
|
2860
3169
|
* 根据 tr 元素获取对应的 row 信息
|
|
2861
3170
|
* @param {Element} tr 元素
|
|
2862
3171
|
*/
|
|
2863
|
-
getRowNode (tr:
|
|
3172
|
+
getRowNode (tr: HTMLElement) {
|
|
3173
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3174
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3175
|
+
|
|
2864
3176
|
if (tr) {
|
|
2865
|
-
const { fullAllDataRowIdData } =
|
|
3177
|
+
const { fullAllDataRowIdData } = internalData
|
|
2866
3178
|
const rowid = tr.getAttribute('rowid')
|
|
2867
|
-
|
|
2868
|
-
|
|
2869
|
-
|
|
2870
|
-
|
|
2871
|
-
|
|
2872
|
-
|
|
2873
|
-
|
|
2874
|
-
|
|
3179
|
+
if (rowid) {
|
|
3180
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
3181
|
+
if (rowRest) {
|
|
3182
|
+
return {
|
|
3183
|
+
rowid: rowRest.rowid,
|
|
3184
|
+
item: rowRest.row,
|
|
3185
|
+
index: rowRest.index,
|
|
3186
|
+
items: rowRest.items,
|
|
3187
|
+
parent: rowRest.parent
|
|
3188
|
+
}
|
|
2875
3189
|
}
|
|
2876
3190
|
}
|
|
2877
3191
|
}
|
|
@@ -2881,9 +3195,12 @@ const Methods = {
|
|
|
2881
3195
|
* 根据 th/td 元素获取对应的 column 信息
|
|
2882
3196
|
* @param {Element} cell 元素
|
|
2883
3197
|
*/
|
|
2884
|
-
getColumnNode (cell:
|
|
3198
|
+
getColumnNode (cell: HTMLElement) {
|
|
3199
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3200
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3201
|
+
|
|
2885
3202
|
if (cell) {
|
|
2886
|
-
const { fullColumnIdData } =
|
|
3203
|
+
const { fullColumnIdData } = internalData
|
|
2887
3204
|
const colid = cell.getAttribute('colid')
|
|
2888
3205
|
if (colid) {
|
|
2889
3206
|
const colRest = fullColumnIdData[colid]
|
|
@@ -2904,47 +3221,22 @@ const Methods = {
|
|
|
2904
3221
|
* 根据 row 获取序号
|
|
2905
3222
|
* @param {Row} row 行对象
|
|
2906
3223
|
*/
|
|
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
|
-
},
|
|
3224
|
+
getRowSeq: createGetRowCacheProp('seq'),
|
|
2918
3225
|
/**
|
|
2919
3226
|
* 根据 row 获取相对于 data 中的索引
|
|
2920
3227
|
* @param {Row} row 行对象
|
|
2921
3228
|
*/
|
|
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
|
-
},
|
|
3229
|
+
getRowIndex: createGetRowCacheProp('index') as ((row: any) => number),
|
|
2933
3230
|
/**
|
|
2934
3231
|
* 根据 row 获取相对于当前数据中的索引
|
|
2935
3232
|
* @param {Row} row 行对象
|
|
2936
3233
|
*/
|
|
2937
|
-
getVTRowIndex (row: any)
|
|
2938
|
-
|
|
2939
|
-
|
|
2940
|
-
|
|
2941
|
-
|
|
2942
|
-
|
|
2943
|
-
return rest._index
|
|
2944
|
-
}
|
|
2945
|
-
}
|
|
2946
|
-
return -1
|
|
2947
|
-
},
|
|
3234
|
+
getVTRowIndex: createGetRowCacheProp('_index') as ((row: any) => number),
|
|
3235
|
+
/**
|
|
3236
|
+
* 根据 row 获取渲染中的虚拟索引
|
|
3237
|
+
* @param {Row} row 行对象
|
|
3238
|
+
*/
|
|
3239
|
+
getVMRowIndex: createGetRowCacheProp('$index') as ((row: any) => number),
|
|
2948
3240
|
// 在 v3 中废弃
|
|
2949
3241
|
_getRowIndex (row: any) {
|
|
2950
3242
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -2952,21 +3244,6 @@ const Methods = {
|
|
|
2952
3244
|
}
|
|
2953
3245
|
return this.getVTRowIndex(row)
|
|
2954
3246
|
},
|
|
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
3247
|
// 在 v3 中废弃
|
|
2971
3248
|
$getRowIndex (row: any) {
|
|
2972
3249
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -2978,30 +3255,17 @@ const Methods = {
|
|
|
2978
3255
|
* 根据 column 获取相对于 columns 中的索引
|
|
2979
3256
|
* @param {ColumnInfo} column 列配置
|
|
2980
3257
|
*/
|
|
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
|
-
},
|
|
3258
|
+
getColumnIndex: createGetColumnCacheProp('index'),
|
|
2991
3259
|
/**
|
|
2992
3260
|
* 根据 column 获取相对于当前表格列中的索引
|
|
2993
3261
|
* @param {ColumnInfo} column 列配置
|
|
2994
3262
|
*/
|
|
2995
|
-
getVTColumnIndex (
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
2999
|
-
|
|
3000
|
-
|
|
3001
|
-
}
|
|
3002
|
-
}
|
|
3003
|
-
return -1
|
|
3004
|
-
},
|
|
3263
|
+
getVTColumnIndex: createGetColumnCacheProp('_index'),
|
|
3264
|
+
/**
|
|
3265
|
+
* 根据 column 获取渲染中的虚拟索引
|
|
3266
|
+
* @param {ColumnInfo} column 列配置
|
|
3267
|
+
*/
|
|
3268
|
+
getVMColumnIndex: createGetColumnCacheProp('$index'),
|
|
3005
3269
|
// 在 v3 中废弃
|
|
3006
3270
|
_getColumnIndex (column: any) {
|
|
3007
3271
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -3009,20 +3273,6 @@ const Methods = {
|
|
|
3009
3273
|
}
|
|
3010
3274
|
return this.getVTColumnIndex(column)
|
|
3011
3275
|
},
|
|
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
3276
|
// 在 v3 中废弃
|
|
3027
3277
|
$getColumnIndex (column: any) {
|
|
3028
3278
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -3041,15 +3291,23 @@ const Methods = {
|
|
|
3041
3291
|
* 定义行数据中的列属性,如果不存在则定义
|
|
3042
3292
|
* @param {Row} records 行数据
|
|
3043
3293
|
*/
|
|
3044
|
-
defineField (records: any) {
|
|
3045
|
-
const
|
|
3294
|
+
defineField (records: any[]) {
|
|
3295
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3296
|
+
const props = $xeTable
|
|
3297
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3298
|
+
|
|
3299
|
+
const { treeConfig } = props
|
|
3300
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
3301
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
3302
|
+
const radioOpts = $xeTable.computeRadioOpts
|
|
3303
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
3046
3304
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
3047
|
-
const rowkey = getRowkey(
|
|
3305
|
+
const rowkey = getRowkey($xeTable)
|
|
3048
3306
|
if (!XEUtils.isArray(records)) {
|
|
3049
3307
|
records = [records || {}]
|
|
3050
3308
|
}
|
|
3051
|
-
return records.map((record
|
|
3052
|
-
|
|
3309
|
+
return records.map((record) => {
|
|
3310
|
+
internalData.tableFullColumn.forEach(column => {
|
|
3053
3311
|
const { field, editRender } = column
|
|
3054
3312
|
if (field && !XEUtils.has(record, field)) {
|
|
3055
3313
|
let cellValue = null
|
|
@@ -3086,8 +3344,10 @@ const Methods = {
|
|
|
3086
3344
|
* @param {Array} records 新数据
|
|
3087
3345
|
*/
|
|
3088
3346
|
createData (records: any) {
|
|
3089
|
-
|
|
3090
|
-
|
|
3347
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3348
|
+
|
|
3349
|
+
return $xeTable.$nextTick().then(() => {
|
|
3350
|
+
return $xeTable.defineField(records)
|
|
3091
3351
|
})
|
|
3092
3352
|
},
|
|
3093
3353
|
/**
|
|
@@ -3096,11 +3356,13 @@ const Methods = {
|
|
|
3096
3356
|
* @param {Array/Object} records 新数据
|
|
3097
3357
|
*/
|
|
3098
3358
|
createRow (records: any) {
|
|
3359
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3360
|
+
|
|
3099
3361
|
const isArr = XEUtils.isArray(records)
|
|
3100
3362
|
if (!isArr) {
|
|
3101
3363
|
records = [records]
|
|
3102
3364
|
}
|
|
3103
|
-
return
|
|
3365
|
+
return $xeTable.createData(records).then((rows: any) => isArr ? rows : rows[0])
|
|
3104
3366
|
},
|
|
3105
3367
|
/**
|
|
3106
3368
|
* 还原数据
|
|
@@ -3116,11 +3378,10 @@ const Methods = {
|
|
|
3116
3378
|
const internalData = $xeTable as unknown as TableInternalData
|
|
3117
3379
|
|
|
3118
3380
|
const { keepSource, treeConfig } = props
|
|
3119
|
-
const {
|
|
3120
|
-
const { fullAllDataRowIdData, fullDataRowIdData, tableSourceData, sourceDataRowIdData, tableFullData, afterFullData } = internalData
|
|
3121
|
-
const removeTempMaps = { ...editStore.removeMaps }
|
|
3381
|
+
const { fullAllDataRowIdData, fullDataRowIdData, tableSourceData, sourceDataRowIdData, tableFullData, afterFullData, removeRowMaps } = internalData
|
|
3122
3382
|
const treeOpts = $xeTable.computeTreeOpts
|
|
3123
3383
|
const { transform } = treeOpts
|
|
3384
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
3124
3385
|
if (!keepSource) {
|
|
3125
3386
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
3126
3387
|
errLog('vxe.error.reqProp', ['keep-source'])
|
|
@@ -3138,7 +3399,7 @@ const Methods = {
|
|
|
3138
3399
|
let reDelFlag = false
|
|
3139
3400
|
if (targetRows.length) {
|
|
3140
3401
|
targetRows.forEach((item: any) => {
|
|
3141
|
-
const rowid =
|
|
3402
|
+
const rowid = handleGetRowId(item)
|
|
3142
3403
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
3143
3404
|
if (rowRest) {
|
|
3144
3405
|
const row = rowRest.row
|
|
@@ -3151,7 +3412,9 @@ const Methods = {
|
|
|
3151
3412
|
XEUtils.destructuring(row, XEUtils.clone(oRow, true))
|
|
3152
3413
|
}
|
|
3153
3414
|
if (!fullDataRowIdData[rowid] && $xeTable.isRemoveByRow(row)) {
|
|
3154
|
-
|
|
3415
|
+
if (removeRowMaps[rowid]) {
|
|
3416
|
+
delete removeRowMaps[rowid]
|
|
3417
|
+
}
|
|
3155
3418
|
tableFullData.unshift(row)
|
|
3156
3419
|
afterFullData.unshift(row)
|
|
3157
3420
|
reDelFlag = true
|
|
@@ -3163,7 +3426,7 @@ const Methods = {
|
|
|
3163
3426
|
}
|
|
3164
3427
|
if (rows) {
|
|
3165
3428
|
if (reDelFlag) {
|
|
3166
|
-
|
|
3429
|
+
reactData.removeRowFlag++
|
|
3167
3430
|
$xeTable.updateFooter()
|
|
3168
3431
|
$xeTable.cacheRowMap(false)
|
|
3169
3432
|
$xeTable.handleTableData(treeConfig && transform)
|
|
@@ -3192,7 +3455,10 @@ const Methods = {
|
|
|
3192
3455
|
* @param {String} field 字段名
|
|
3193
3456
|
*/
|
|
3194
3457
|
clearData (rows: any, field: any) {
|
|
3195
|
-
const
|
|
3458
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3459
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3460
|
+
|
|
3461
|
+
const { tableFullData, visibleColumn } = internalData
|
|
3196
3462
|
if (!arguments.length) {
|
|
3197
3463
|
rows = tableFullData
|
|
3198
3464
|
} else if (rows && !XEUtils.isArray(rows)) {
|
|
@@ -3209,7 +3475,7 @@ const Methods = {
|
|
|
3209
3475
|
})
|
|
3210
3476
|
})
|
|
3211
3477
|
}
|
|
3212
|
-
return
|
|
3478
|
+
return $xeTable.$nextTick()
|
|
3213
3479
|
},
|
|
3214
3480
|
getCellElement (row: any, fieldOrColumn: any) {
|
|
3215
3481
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
@@ -3299,18 +3565,18 @@ const Methods = {
|
|
|
3299
3565
|
isInsertByRow (row: any) {
|
|
3300
3566
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3301
3567
|
const reactData = $xeTable as unknown as TableReactData
|
|
3568
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3302
3569
|
|
|
3303
|
-
const { editStore } = reactData
|
|
3304
3570
|
const rowid = getRowid($xeTable, row)
|
|
3305
|
-
return !!
|
|
3571
|
+
return !!reactData.insertRowFlag && !!internalData.insertRowMaps[rowid]
|
|
3306
3572
|
},
|
|
3307
3573
|
isRemoveByRow (row: any) {
|
|
3308
3574
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3309
3575
|
const reactData = $xeTable as unknown as TableReactData
|
|
3576
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3310
3577
|
|
|
3311
|
-
const { editStore } = reactData
|
|
3312
3578
|
const rowid = getRowid($xeTable, row)
|
|
3313
|
-
return !!
|
|
3579
|
+
return !!reactData.removeRowFlag && !!internalData.removeRowMaps[rowid]
|
|
3314
3580
|
},
|
|
3315
3581
|
/**
|
|
3316
3582
|
* 删除所有新增的临时数据
|
|
@@ -3318,10 +3584,9 @@ const Methods = {
|
|
|
3318
3584
|
*/
|
|
3319
3585
|
removeInsertRow () {
|
|
3320
3586
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3321
|
-
const
|
|
3587
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3322
3588
|
|
|
3323
|
-
|
|
3324
|
-
editStore.insertMaps = {}
|
|
3589
|
+
internalData.insertRowMaps = {}
|
|
3325
3590
|
return $xeTable.remove($xeTable.getInsertRecords())
|
|
3326
3591
|
},
|
|
3327
3592
|
/**
|
|
@@ -3364,14 +3629,19 @@ const Methods = {
|
|
|
3364
3629
|
* @param {Number} columnIndex 索引
|
|
3365
3630
|
*/
|
|
3366
3631
|
getColumns (columnIndex: any) {
|
|
3367
|
-
const
|
|
3368
|
-
|
|
3632
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3633
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3634
|
+
|
|
3635
|
+
const { visibleColumn } = internalData
|
|
3636
|
+
return XEUtils.isUndefined(columnIndex) ? visibleColumn.slice(0) : visibleColumn[columnIndex]
|
|
3369
3637
|
},
|
|
3370
3638
|
/**
|
|
3371
3639
|
* 根据列获取列的唯一主键
|
|
3372
3640
|
*/
|
|
3373
3641
|
getColid (fieldOrColumn: any) {
|
|
3374
|
-
const
|
|
3642
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3643
|
+
|
|
3644
|
+
const column = handleFieldOrColumn($xeTable, fieldOrColumn)
|
|
3375
3645
|
return column ? column.id : null
|
|
3376
3646
|
},
|
|
3377
3647
|
/**
|
|
@@ -3379,7 +3649,10 @@ const Methods = {
|
|
|
3379
3649
|
* @param {String} colid 列主键
|
|
3380
3650
|
*/
|
|
3381
3651
|
getColumnById (colid: any) {
|
|
3382
|
-
const
|
|
3652
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3653
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3654
|
+
|
|
3655
|
+
const { fullColumnIdData } = internalData
|
|
3383
3656
|
return fullColumnIdData[colid] ? fullColumnIdData[colid].column : null
|
|
3384
3657
|
},
|
|
3385
3658
|
/**
|
|
@@ -3387,7 +3660,10 @@ const Methods = {
|
|
|
3387
3660
|
* @param {String} field 字段名
|
|
3388
3661
|
*/
|
|
3389
3662
|
getColumnByField (field: any) {
|
|
3390
|
-
const
|
|
3663
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3664
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3665
|
+
|
|
3666
|
+
const { fullColumnFieldData } = internalData
|
|
3391
3667
|
return fullColumnFieldData[field] ? fullColumnFieldData[field].column : null
|
|
3392
3668
|
},
|
|
3393
3669
|
getParentColumn (fieldOrColumn: any) {
|
|
@@ -3400,11 +3676,15 @@ const Methods = {
|
|
|
3400
3676
|
* 收集到的全量列、全量表头列、处理条件之后的全量表头列、当前渲染中的表头列
|
|
3401
3677
|
*/
|
|
3402
3678
|
getTableColumn () {
|
|
3679
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3680
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
3681
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3682
|
+
|
|
3403
3683
|
return {
|
|
3404
|
-
collectColumn:
|
|
3405
|
-
fullColumn:
|
|
3406
|
-
visibleColumn:
|
|
3407
|
-
tableColumn:
|
|
3684
|
+
collectColumn: internalData.collectColumn.slice(0),
|
|
3685
|
+
fullColumn: internalData.tableFullColumn.slice(0),
|
|
3686
|
+
visibleColumn: internalData.visibleColumn.slice(0),
|
|
3687
|
+
tableColumn: reactData.tableColumn.slice(0)
|
|
3408
3688
|
}
|
|
3409
3689
|
},
|
|
3410
3690
|
/**
|
|
@@ -3531,12 +3811,10 @@ const Methods = {
|
|
|
3531
3811
|
getCheckboxRecords (isFull: boolean) {
|
|
3532
3812
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3533
3813
|
const props = $xeTable
|
|
3534
|
-
const reactData = $xeTable as unknown as TableReactData
|
|
3535
3814
|
const internalData = $xeTable as unknown as TableInternalData
|
|
3536
3815
|
|
|
3537
3816
|
const { treeConfig } = props
|
|
3538
|
-
const { selectCheckboxMaps } =
|
|
3539
|
-
const { tableFullData, afterFullData, afterTreeFullData, tableFullTreeData, fullDataRowIdData, afterFullRowMaps } = internalData
|
|
3817
|
+
const { tableFullData, afterFullData, afterTreeFullData, tableFullTreeData, fullDataRowIdData, afterFullRowMaps, selectCheckboxMaps } = internalData
|
|
3540
3818
|
const treeOpts = $xeTable.computeTreeOpts
|
|
3541
3819
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
3542
3820
|
const { transform, mapChildrenField } = treeOpts
|
|
@@ -3582,7 +3860,7 @@ const Methods = {
|
|
|
3582
3860
|
const treeOpts = $xeTable.computeTreeOpts
|
|
3583
3861
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
3584
3862
|
const { transform, rowField, parentField, mapChildrenField } = treeOpts
|
|
3585
|
-
const { remote: allRemoteFilter, filterMethod: allFilterMethod } = filterOpts
|
|
3863
|
+
const { isEvery, remote: allRemoteFilter, filterMethod: allFilterMethod } = filterOpts
|
|
3586
3864
|
const { remote: allRemoteSort, sortMethod: allSortMethod, multiple: sortMultiple, chronological } = sortOpts
|
|
3587
3865
|
let tableData: any[] = []
|
|
3588
3866
|
let tableTree: any[] = []
|
|
@@ -3644,7 +3922,7 @@ const Methods = {
|
|
|
3644
3922
|
// 筛选虚拟树
|
|
3645
3923
|
tableTree = XEUtils.searchTree(tableFullTreeData, handleFilter, {
|
|
3646
3924
|
original: true,
|
|
3647
|
-
isEvery
|
|
3925
|
+
isEvery,
|
|
3648
3926
|
children: mapChildrenField,
|
|
3649
3927
|
mapChildren: childrenField
|
|
3650
3928
|
})
|
|
@@ -3658,7 +3936,7 @@ const Methods = {
|
|
|
3658
3936
|
// 还原虚拟树
|
|
3659
3937
|
tableTree = XEUtils.searchTree(tableFullTreeData, () => true, {
|
|
3660
3938
|
original: true,
|
|
3661
|
-
isEvery
|
|
3939
|
+
isEvery,
|
|
3662
3940
|
children: mapChildrenField,
|
|
3663
3941
|
mapChildren: childrenField
|
|
3664
3942
|
})
|
|
@@ -3719,7 +3997,7 @@ const Methods = {
|
|
|
3719
3997
|
// 还原虚拟树
|
|
3720
3998
|
tableTree = XEUtils.searchTree(tableFullTreeData, () => true, {
|
|
3721
3999
|
original: true,
|
|
3722
|
-
isEvery
|
|
4000
|
+
isEvery,
|
|
3723
4001
|
children: treeOpts.mapChildrenField,
|
|
3724
4002
|
mapChildren: childrenField
|
|
3725
4003
|
})
|
|
@@ -3746,9 +4024,9 @@ const Methods = {
|
|
|
3746
4024
|
* 只对 tree-config 有效,获取行的子级
|
|
3747
4025
|
*/
|
|
3748
4026
|
getTreeRowChildren (rowOrRowid: any) {
|
|
3749
|
-
const $xeTable = this
|
|
4027
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3750
4028
|
const props = $xeTable
|
|
3751
|
-
const internalData = $xeTable
|
|
4029
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3752
4030
|
|
|
3753
4031
|
const { treeConfig } = props
|
|
3754
4032
|
const { fullAllDataRowIdData } = internalData
|
|
@@ -3829,9 +4107,15 @@ const Methods = {
|
|
|
3829
4107
|
* 如果存在排序,继续处理
|
|
3830
4108
|
*/
|
|
3831
4109
|
getTableData () {
|
|
3832
|
-
const
|
|
4110
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
4111
|
+
const props = $xeTable
|
|
4112
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
4113
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
4114
|
+
|
|
4115
|
+
const { tableData, footerTableData } = reactData
|
|
4116
|
+
const { tableFullData, afterFullData, tableFullTreeData } = internalData
|
|
3833
4117
|
return {
|
|
3834
|
-
fullData: treeConfig ? tableFullTreeData.slice(0) : tableFullData.slice(0),
|
|
4118
|
+
fullData: props.treeConfig ? tableFullTreeData.slice(0) : tableFullData.slice(0),
|
|
3835
4119
|
visibleData: afterFullData.slice(0),
|
|
3836
4120
|
tableData: tableData.slice(0),
|
|
3837
4121
|
footerData: footerTableData.slice(0)
|
|
@@ -3873,41 +4157,24 @@ const Methods = {
|
|
|
3873
4157
|
* 默认执行一次,除非被重置
|
|
3874
4158
|
*/
|
|
3875
4159
|
handleLoadDefaults () {
|
|
3876
|
-
|
|
3877
|
-
|
|
3878
|
-
|
|
3879
|
-
if (this.radioConfig) {
|
|
3880
|
-
this.handleDefaultRadioChecked()
|
|
3881
|
-
}
|
|
3882
|
-
if (this.expandConfig) {
|
|
3883
|
-
this.handleDefaultRowExpand()
|
|
3884
|
-
}
|
|
3885
|
-
if (this.treeConfig) {
|
|
3886
|
-
this.handleDefaultTreeExpand()
|
|
3887
|
-
}
|
|
3888
|
-
if (this.mergeCells) {
|
|
3889
|
-
this.handleDefaultMergeCells()
|
|
3890
|
-
}
|
|
3891
|
-
if (this.mergeFooterItems) {
|
|
3892
|
-
this.handleDefaultMergeFooterItems()
|
|
3893
|
-
}
|
|
3894
|
-
this.$nextTick(() => setTimeout(this.recalculate))
|
|
4160
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
4161
|
+
|
|
4162
|
+
handleLoadDefaults($xeTable)
|
|
3895
4163
|
},
|
|
3896
4164
|
/**
|
|
3897
4165
|
* 处理初始化的默认行为
|
|
3898
4166
|
* 只会执行一次
|
|
3899
4167
|
*/
|
|
3900
4168
|
handleInitDefaults () {
|
|
3901
|
-
const
|
|
3902
|
-
|
|
3903
|
-
|
|
3904
|
-
}
|
|
4169
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
4170
|
+
|
|
4171
|
+
handleInitDefaults($xeTable)
|
|
3905
4172
|
},
|
|
3906
4173
|
/**
|
|
3907
4174
|
* 设置为固定列
|
|
3908
4175
|
*/
|
|
3909
4176
|
setColumnFixed (fieldOrColumn: any, fixed: any) {
|
|
3910
|
-
const $xeTable = this
|
|
4177
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3911
4178
|
|
|
3912
4179
|
let status = false
|
|
3913
4180
|
const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
|
|
@@ -3945,8 +4212,8 @@ const Methods = {
|
|
|
3945
4212
|
/**
|
|
3946
4213
|
* 取消指定固定列
|
|
3947
4214
|
*/
|
|
3948
|
-
clearColumnFixed (fieldOrColumn:
|
|
3949
|
-
const $xeTable = this
|
|
4215
|
+
clearColumnFixed (fieldOrColumn: string | string[] | VxeTableDefines.ColumnInfo | VxeTableDefines.ColumnInfo[]) {
|
|
4216
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3950
4217
|
|
|
3951
4218
|
let status = false
|
|
3952
4219
|
const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
|
|
@@ -3971,8 +4238,8 @@ const Methods = {
|
|
|
3971
4238
|
/**
|
|
3972
4239
|
* 隐藏指定列
|
|
3973
4240
|
*/
|
|
3974
|
-
hideColumn (fieldOrColumn:
|
|
3975
|
-
const $xeTable = this
|
|
4241
|
+
hideColumn (fieldOrColumn: string | string[] | VxeTableDefines.ColumnInfo | VxeTableDefines.ColumnInfo[]) {
|
|
4242
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3976
4243
|
|
|
3977
4244
|
let status = false
|
|
3978
4245
|
const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
|
|
@@ -3993,8 +4260,8 @@ const Methods = {
|
|
|
3993
4260
|
/**
|
|
3994
4261
|
* 显示指定列
|
|
3995
4262
|
*/
|
|
3996
|
-
showColumn (fieldOrColumn:
|
|
3997
|
-
const $xeTable = this
|
|
4263
|
+
showColumn (fieldOrColumn: string | string[] | VxeTableDefines.ColumnInfo | VxeTableDefines.ColumnInfo[]) {
|
|
4264
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3998
4265
|
|
|
3999
4266
|
let status = false
|
|
4000
4267
|
const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
|
|
@@ -4067,67 +4334,35 @@ const Methods = {
|
|
|
4067
4334
|
return this.resetCustom(options)
|
|
4068
4335
|
},
|
|
4069
4336
|
handleCustom () {
|
|
4070
|
-
const
|
|
4337
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
4338
|
+
const props = $xeTable
|
|
4339
|
+
|
|
4340
|
+
const { mouseConfig } = props
|
|
4071
4341
|
if (mouseConfig) {
|
|
4072
|
-
if (
|
|
4073
|
-
|
|
4074
|
-
}
|
|
4075
|
-
if (
|
|
4076
|
-
|
|
4077
|
-
|
|
4078
|
-
}
|
|
4079
|
-
}
|
|
4080
|
-
this.analyColumnWidth()
|
|
4081
|
-
return this.refreshColumn(true)
|
|
4082
|
-
},
|
|
4083
|
-
handleCustomRestore (storeData: any) {
|
|
4084
|
-
const $xetable = this
|
|
4085
|
-
const reactData = $xetable
|
|
4086
|
-
const internalData = $xetable
|
|
4087
|
-
|
|
4088
|
-
let { collectColumn } = internalData
|
|
4089
|
-
const { resizableData, sortData, visibleData, fixedData } = storeData
|
|
4090
|
-
let hasCustomSort = false
|
|
4091
|
-
// 处理还原
|
|
4092
|
-
if (resizableData || sortData || visibleData || fixedData) {
|
|
4093
|
-
XEUtils.eachTree(collectColumn, (column, index, items, path, parentRow) => {
|
|
4094
|
-
const colKey = column.getKey()
|
|
4095
|
-
// 支持一级
|
|
4096
|
-
if (!parentRow) {
|
|
4097
|
-
if (fixedData && fixedData[colKey] !== undefined) {
|
|
4098
|
-
column.fixed = fixedData[colKey]
|
|
4099
|
-
}
|
|
4100
|
-
if (sortData && XEUtils.isNumber(sortData[colKey])) {
|
|
4101
|
-
hasCustomSort = true
|
|
4102
|
-
column.renderSortNumber = sortData[colKey]
|
|
4103
|
-
}
|
|
4104
|
-
}
|
|
4105
|
-
if (resizableData && XEUtils.isNumber(resizableData[colKey])) {
|
|
4106
|
-
column.resizeWidth = resizableData[colKey]
|
|
4107
|
-
}
|
|
4108
|
-
if (visibleData && XEUtils.isBoolean(visibleData[colKey])) {
|
|
4109
|
-
column.visible = visibleData[colKey]
|
|
4110
|
-
}
|
|
4111
|
-
})
|
|
4112
|
-
// 如果自定义了顺序
|
|
4113
|
-
if (hasCustomSort) {
|
|
4114
|
-
collectColumn = XEUtils.orderBy(collectColumn, 'renderSortNumber')
|
|
4115
|
-
internalData.collectColumn = collectColumn
|
|
4116
|
-
internalData.tableFullColumn = getColumnList(collectColumn)
|
|
4342
|
+
if ($xeTable.clearSelected) {
|
|
4343
|
+
$xeTable.clearSelected()
|
|
4344
|
+
}
|
|
4345
|
+
if ($xeTable.clearCellAreas) {
|
|
4346
|
+
$xeTable.clearCellAreas()
|
|
4347
|
+
$xeTable.clearCopyCellArea()
|
|
4117
4348
|
}
|
|
4118
|
-
reactData.isCustomStatus = true
|
|
4119
|
-
} else {
|
|
4120
|
-
reactData.isCustomStatus = false
|
|
4121
4349
|
}
|
|
4350
|
+
$xeTable.analyColumnWidth()
|
|
4351
|
+
return $xeTable.refreshColumn(true)
|
|
4122
4352
|
},
|
|
4123
4353
|
/**
|
|
4124
4354
|
* 还原自定义列操作状态
|
|
4125
4355
|
*/
|
|
4126
4356
|
restoreCustomStorage () {
|
|
4127
|
-
const
|
|
4357
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
4358
|
+
const props = $xeTable
|
|
4359
|
+
|
|
4360
|
+
const { customConfig } = props
|
|
4361
|
+
const tableId = $xeTable.computeTableId
|
|
4362
|
+
const customOpts = $xeTable.computeCustomOpts
|
|
4128
4363
|
const { storage, restoreStore } = customOpts
|
|
4129
4364
|
const isAllCustom = storage === true
|
|
4130
|
-
const storageOpts = isAllCustom ? {} : Object.assign({}, storage || {})
|
|
4365
|
+
const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {})
|
|
4131
4366
|
const isCustomResizable = isAllCustom || storageOpts.resizable
|
|
4132
4367
|
const isCustomVisible = isAllCustom || storageOpts.visible
|
|
4133
4368
|
const isCustomFixed = isAllCustom || storageOpts.fixed
|
|
@@ -4145,21 +4380,33 @@ const Methods = {
|
|
|
4145
4380
|
if (!storeData) {
|
|
4146
4381
|
return
|
|
4147
4382
|
}
|
|
4148
|
-
return
|
|
4383
|
+
return handleCustomRestore($xeTable, storeData)
|
|
4149
4384
|
}).catch(e => e)
|
|
4150
4385
|
} else {
|
|
4151
|
-
return
|
|
4386
|
+
return handleCustomRestore($xeTable, storeData)
|
|
4152
4387
|
}
|
|
4153
4388
|
}
|
|
4154
4389
|
},
|
|
4155
4390
|
getCustomStoreData () {
|
|
4156
|
-
const
|
|
4157
|
-
const
|
|
4158
|
-
const
|
|
4159
|
-
|
|
4160
|
-
const
|
|
4161
|
-
const
|
|
4162
|
-
const
|
|
4391
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
4392
|
+
const props = $xeTable
|
|
4393
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
4394
|
+
|
|
4395
|
+
const { id } = props
|
|
4396
|
+
const customOpts = $xeTable.computeCustomOpts
|
|
4397
|
+
const { collectColumn } = internalData
|
|
4398
|
+
const { storage, checkMethod } = customOpts
|
|
4399
|
+
const isAllCustom = storage === true
|
|
4400
|
+
const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {})
|
|
4401
|
+
const isCustomResizable = isAllCustom || storageOpts.resizable
|
|
4402
|
+
const isCustomVisible = isAllCustom || storageOpts.visible
|
|
4403
|
+
const isCustomFixed = isAllCustom || storageOpts.fixed
|
|
4404
|
+
const isCustomSort = isAllCustom || storageOpts.sort
|
|
4405
|
+
const resizableData: Record<string, number> = {}
|
|
4406
|
+
const sortData: Record<string, number> = {}
|
|
4407
|
+
const visibleData: Record<string, boolean> = {}
|
|
4408
|
+
const fixedData: Record<string, VxeColumnPropTypes.Fixed> = {}
|
|
4409
|
+
const storeData: VxeTableDefines.CustomStoreData = {
|
|
4163
4410
|
resizableData: undefined,
|
|
4164
4411
|
sortData: undefined,
|
|
4165
4412
|
visibleData: undefined,
|
|
@@ -4171,46 +4418,36 @@ const Methods = {
|
|
|
4171
4418
|
}
|
|
4172
4419
|
let hasResizable = 0
|
|
4173
4420
|
let hasSort = 0
|
|
4174
|
-
let
|
|
4421
|
+
let hasFixed = 0
|
|
4175
4422
|
let hasVisible = 0
|
|
4176
4423
|
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
4424
|
+
const colKey = column.getKey()
|
|
4425
|
+
if (!colKey) {
|
|
4426
|
+
errLog('vxe.error.reqProp', [`${column.getTitle() || column.type || ''} -> column.field=?`])
|
|
4427
|
+
return
|
|
4428
|
+
}
|
|
4177
4429
|
// 只支持一级
|
|
4178
4430
|
if (!parentColumn) {
|
|
4179
|
-
|
|
4180
|
-
|
|
4181
|
-
|
|
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
|
-
}
|
|
4431
|
+
if (isCustomSort) {
|
|
4432
|
+
hasSort = 1
|
|
4433
|
+
sortData[colKey] = column.renderSortNumber
|
|
4192
4434
|
}
|
|
4193
|
-
|
|
4194
|
-
|
|
4195
|
-
|
|
4196
|
-
if (colKey) {
|
|
4197
|
-
hasResizable = 1
|
|
4198
|
-
resizableData[colKey] = column.renderWidth
|
|
4435
|
+
if (isCustomFixed && column.fixed !== column.defaultFixed) {
|
|
4436
|
+
hasFixed = 1
|
|
4437
|
+
fixedData[colKey] = column.fixed
|
|
4199
4438
|
}
|
|
4200
4439
|
}
|
|
4201
|
-
if (
|
|
4440
|
+
if (isCustomResizable && column.resizeWidth) {
|
|
4441
|
+
hasResizable = 1
|
|
4442
|
+
resizableData[colKey] = column.renderWidth
|
|
4443
|
+
}
|
|
4444
|
+
if (isCustomVisible && (!checkMethod || checkMethod({ column }))) {
|
|
4202
4445
|
if (!column.visible && column.defaultVisible) {
|
|
4203
|
-
|
|
4204
|
-
|
|
4205
|
-
hasVisible = 1
|
|
4206
|
-
visibleData[colKey] = false
|
|
4207
|
-
}
|
|
4446
|
+
hasVisible = 1
|
|
4447
|
+
visibleData[colKey] = false
|
|
4208
4448
|
} else if (column.visible && !column.defaultVisible) {
|
|
4209
|
-
|
|
4210
|
-
|
|
4211
|
-
hasVisible = 1
|
|
4212
|
-
visibleData[colKey] = true
|
|
4213
|
-
}
|
|
4449
|
+
hasVisible = 1
|
|
4450
|
+
visibleData[colKey] = true
|
|
4214
4451
|
}
|
|
4215
4452
|
}
|
|
4216
4453
|
})
|
|
@@ -4220,7 +4457,7 @@ const Methods = {
|
|
|
4220
4457
|
if (hasSort) {
|
|
4221
4458
|
storeData.sortData = sortData
|
|
4222
4459
|
}
|
|
4223
|
-
if (
|
|
4460
|
+
if (hasFixed) {
|
|
4224
4461
|
storeData.fixedData = fixedData
|
|
4225
4462
|
}
|
|
4226
4463
|
if (hasVisible) {
|
|
@@ -4229,9 +4466,9 @@ const Methods = {
|
|
|
4229
4466
|
return storeData
|
|
4230
4467
|
},
|
|
4231
4468
|
saveCustomStore (type: any) {
|
|
4232
|
-
const $xeTable = this
|
|
4469
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
4233
4470
|
const props = $xeTable
|
|
4234
|
-
const reactData = $xeTable as TableReactData
|
|
4471
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
4235
4472
|
|
|
4236
4473
|
const { customConfig } = props
|
|
4237
4474
|
const tableId = $xeTable.computeTableId
|
|
@@ -4709,12 +4946,13 @@ const Methods = {
|
|
|
4709
4946
|
const internalData = $xeTable as unknown as TableInternalData
|
|
4710
4947
|
|
|
4711
4948
|
const { fullAllDataRowIdData, afterFullData } = internalData
|
|
4949
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
4712
4950
|
const rowOpts = $xeTable.computeRowOpts
|
|
4713
4951
|
const cellOpts = $xeTable.computeCellOpts
|
|
4714
4952
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
4715
4953
|
const rest: Record<string, number> = {}
|
|
4716
4954
|
afterFullData.forEach(row => {
|
|
4717
|
-
const rowid =
|
|
4955
|
+
const rowid = handleGetRowId(row)
|
|
4718
4956
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
4719
4957
|
if (rowRest) {
|
|
4720
4958
|
const resizeHeight = rowRest.resizeHeight
|
|
@@ -4742,8 +4980,9 @@ const Methods = {
|
|
|
4742
4980
|
rHeight = Math.floor(rHeight * bodyHeight)
|
|
4743
4981
|
}
|
|
4744
4982
|
if (rHeight) {
|
|
4983
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
4745
4984
|
rows.forEach(row => {
|
|
4746
|
-
const rowid = XEUtils.isString(row) || XEUtils.isNumber(row) ? row :
|
|
4985
|
+
const rowid = XEUtils.isString(row) || XEUtils.isNumber(row) ? row : handleGetRowId(row)
|
|
4747
4986
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
4748
4987
|
if (rowRest) {
|
|
4749
4988
|
rowRest.resizeHeight = rHeight
|
|
@@ -4890,6 +5129,9 @@ const Methods = {
|
|
|
4890
5129
|
}
|
|
4891
5130
|
},
|
|
4892
5131
|
preventEvent (evnt: any, type: any, args: any, next: any, end: any) {
|
|
5132
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5133
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
5134
|
+
|
|
4893
5135
|
let evntList = interceptor.get(type)
|
|
4894
5136
|
|
|
4895
5137
|
// 兼容老版本
|
|
@@ -4903,8 +5145,21 @@ const Methods = {
|
|
|
4903
5145
|
}
|
|
4904
5146
|
// 兼容老版本
|
|
4905
5147
|
|
|
4906
|
-
let rest
|
|
4907
|
-
|
|
5148
|
+
let rest = null
|
|
5149
|
+
let isStop = false
|
|
5150
|
+
for (let i = 0; i < evntList.length; i++) {
|
|
5151
|
+
const func = evntList[i]
|
|
5152
|
+
const fnRest = func(Object.assign({ $grid: $xeGrid, $table: $xeTable, $event: evnt }, args))
|
|
5153
|
+
if (fnRest === false) {
|
|
5154
|
+
isStop = true
|
|
5155
|
+
break
|
|
5156
|
+
} else if (fnRest && fnRest.status === false) {
|
|
5157
|
+
rest = fnRest.result
|
|
5158
|
+
isStop = true
|
|
5159
|
+
break
|
|
5160
|
+
}
|
|
5161
|
+
}
|
|
5162
|
+
if (!isStop) {
|
|
4908
5163
|
if (next) {
|
|
4909
5164
|
rest = next()
|
|
4910
5165
|
}
|
|
@@ -4918,7 +5173,10 @@ const Methods = {
|
|
|
4918
5173
|
* 全局按下事件处理
|
|
4919
5174
|
*/
|
|
4920
5175
|
handleGlobalMousedownEvent (evnt: any) {
|
|
4921
|
-
const
|
|
5176
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5177
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
5178
|
+
|
|
5179
|
+
const { $el, $refs, $toolbar, mouseConfig, editStore, ctxMenuStore, editRules, editOpts, validOpts, areaOpts, filterStore, customStore, getRowNode } = this
|
|
4922
5180
|
const { actived } = editStore
|
|
4923
5181
|
const { customWrapper, refValidTooltip } = $refs
|
|
4924
5182
|
const tableFilter = $refs.refTableFilter
|
|
@@ -5004,7 +5262,7 @@ const Methods = {
|
|
|
5004
5262
|
}
|
|
5005
5263
|
}
|
|
5006
5264
|
} else if (mouseConfig) {
|
|
5007
|
-
if (!getEventTargetNode(evnt, $el).flag && !($
|
|
5265
|
+
if (!getEventTargetNode(evnt, $el).flag && !($xeGrid && getEventTargetNode(evnt, $xeGrid.$el).flag) && !(tableMenu && getEventTargetNode(evnt, tableMenu.$el).flag) && !($toolbar && getEventTargetNode(evnt, $toolbar.$el).flag)) {
|
|
5008
5266
|
if (this.clearSelected) {
|
|
5009
5267
|
this.clearSelected()
|
|
5010
5268
|
}
|
|
@@ -5026,7 +5284,7 @@ const Methods = {
|
|
|
5026
5284
|
if (ctxMenuStore.visible && tableMenu && !getEventTargetNode(evnt, tableMenu.$el).flag) {
|
|
5027
5285
|
this.closeMenu()
|
|
5028
5286
|
}
|
|
5029
|
-
const isActivated = getEventTargetNode(evnt, ($
|
|
5287
|
+
const isActivated = getEventTargetNode(evnt, ($xeGrid || this).$el).flag
|
|
5030
5288
|
// 如果存在校验,点击了表格之外则清除
|
|
5031
5289
|
if (!isActivated && editRules && validOpts.autoClear) {
|
|
5032
5290
|
this.validErrorMaps = {}
|
|
@@ -5087,8 +5345,9 @@ const Methods = {
|
|
|
5087
5345
|
* 全局键盘事件
|
|
5088
5346
|
*/
|
|
5089
5347
|
handleGlobalKeydownEvent (evnt: any) {
|
|
5090
|
-
const $xeTable = this
|
|
5091
|
-
const internalData = $xeTable
|
|
5348
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5349
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5350
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
5092
5351
|
|
|
5093
5352
|
// 该行为只对当前激活的表格有效
|
|
5094
5353
|
if (this.isActivated) {
|
|
@@ -5179,7 +5438,7 @@ const Methods = {
|
|
|
5179
5438
|
if (keyboardOpts.enterToTab) {
|
|
5180
5439
|
this.moveTabSelected(activeParams, hasShiftKey, evnt)
|
|
5181
5440
|
} else {
|
|
5182
|
-
this.
|
|
5441
|
+
this.moveEnterSelected(activeParams, isLeftArrow, true, isRightArrow, false, evnt)
|
|
5183
5442
|
}
|
|
5184
5443
|
} else {
|
|
5185
5444
|
if (keyboardOpts.enterToTab) {
|
|
@@ -5211,7 +5470,7 @@ const Methods = {
|
|
|
5211
5470
|
return
|
|
5212
5471
|
}
|
|
5213
5472
|
}
|
|
5214
|
-
this.
|
|
5473
|
+
this.moveEnterSelected(activeParams, isLeftArrow, false, isRightArrow, true, evnt)
|
|
5215
5474
|
if (enterMethod) {
|
|
5216
5475
|
enterMethod(etrParams)
|
|
5217
5476
|
}
|
|
@@ -5235,10 +5494,7 @@ const Methods = {
|
|
|
5235
5494
|
if (!isEditStatus) {
|
|
5236
5495
|
// 如果按下了方向键
|
|
5237
5496
|
if (selected.row && selected.column) {
|
|
5238
|
-
|
|
5239
|
-
} else if ((isUpArrow || isDwArrow) && (rowOpts.isCurrent || highlightCurrentRow)) {
|
|
5240
|
-
// 当前行按键上下移动
|
|
5241
|
-
this.moveCurrentRow(isUpArrow, isDwArrow, evnt)
|
|
5497
|
+
$xeTable.moveArrowSelected(selected.args, isLeftArrow, isUpArrow, isRightArrow, isDwArrow, evnt)
|
|
5242
5498
|
}
|
|
5243
5499
|
}
|
|
5244
5500
|
} else if (isTab && keyboardConfig && keyboardOpts.isTab) {
|
|
@@ -5258,7 +5514,7 @@ const Methods = {
|
|
|
5258
5514
|
column: selected.column,
|
|
5259
5515
|
columnIndex: this.getColumnIndex(selected.column),
|
|
5260
5516
|
$table: this,
|
|
5261
|
-
$grid:
|
|
5517
|
+
$grid: $xeGrid
|
|
5262
5518
|
}
|
|
5263
5519
|
// 是否被禁用
|
|
5264
5520
|
if (!beforeEditMethod || beforeEditMethod(params)) {
|
|
@@ -5283,7 +5539,7 @@ const Methods = {
|
|
|
5283
5539
|
column: selected.column,
|
|
5284
5540
|
columnIndex: this.getColumnIndex(selected.column),
|
|
5285
5541
|
$table: this,
|
|
5286
|
-
$grid:
|
|
5542
|
+
$grid: $xeGrid
|
|
5287
5543
|
}
|
|
5288
5544
|
// 是否被禁用
|
|
5289
5545
|
if (!beforeEditMethod || beforeEditMethod(params)) {
|
|
@@ -5310,7 +5566,7 @@ const Methods = {
|
|
|
5310
5566
|
rowIndex: this.getRowIndex(parentRow),
|
|
5311
5567
|
$rowIndex: this.getVMRowIndex(parentRow),
|
|
5312
5568
|
$table: this,
|
|
5313
|
-
$grid:
|
|
5569
|
+
$grid: $xeGrid
|
|
5314
5570
|
}
|
|
5315
5571
|
this.setTreeExpand(parentRow, false)
|
|
5316
5572
|
.then(() => this.scrollToRow(parentRow))
|
|
@@ -5331,7 +5587,7 @@ const Methods = {
|
|
|
5331
5587
|
column: selected.column,
|
|
5332
5588
|
columnIndex: this.getColumnIndex(selected.column),
|
|
5333
5589
|
$table: this,
|
|
5334
|
-
$grid:
|
|
5590
|
+
$grid: $xeGrid
|
|
5335
5591
|
}
|
|
5336
5592
|
if (!beforeEditMethod || beforeEditMethod(params)) {
|
|
5337
5593
|
if (editMethod) {
|
|
@@ -5453,7 +5709,7 @@ const Methods = {
|
|
|
5453
5709
|
return
|
|
5454
5710
|
}
|
|
5455
5711
|
if (tooltipStore.column !== column || !tooltipStore.visible) {
|
|
5456
|
-
handleTooltip($xeTable, evnt, thEl, cellEl,
|
|
5712
|
+
handleTooltip($xeTable, evnt, thEl, thEl.querySelector<HTMLElement>('.vxe-cell--title') || cellEl, params)
|
|
5457
5713
|
}
|
|
5458
5714
|
},
|
|
5459
5715
|
/**
|
|
@@ -5484,7 +5740,7 @@ const Methods = {
|
|
|
5484
5740
|
}
|
|
5485
5741
|
}
|
|
5486
5742
|
if (tooltipStore.column !== column || tooltipStore.row !== row || !tooltipStore.visible) {
|
|
5487
|
-
handleTooltip($xeTable, evnt, tdEl, tdEl.querySelector('.vxe-cell--
|
|
5743
|
+
handleTooltip($xeTable, evnt, tdEl, tdEl.querySelector<HTMLElement>('.vxe-cell--label') || tdEl.querySelector<HTMLElement>('.vxe-cell--wrapper'), params)
|
|
5488
5744
|
}
|
|
5489
5745
|
},
|
|
5490
5746
|
/**
|
|
@@ -5496,10 +5752,10 @@ const Methods = {
|
|
|
5496
5752
|
|
|
5497
5753
|
const { column } = params
|
|
5498
5754
|
const { tooltipStore } = reactData
|
|
5499
|
-
const
|
|
5755
|
+
const tdEl = evnt.currentTarget as HTMLTableCellElement
|
|
5500
5756
|
handleTargetEnterEvent($xeTable, tooltipStore.column !== column || !!tooltipStore.row)
|
|
5501
5757
|
if (tooltipStore.column !== column || !tooltipStore.visible) {
|
|
5502
|
-
handleTooltip($xeTable, evnt,
|
|
5758
|
+
handleTooltip($xeTable, evnt, tdEl, tdEl.querySelector<HTMLElement>('.vxe-cell--label') || tdEl.querySelector('.vxe-cell--wrapper') as HTMLElement, params)
|
|
5503
5759
|
}
|
|
5504
5760
|
},
|
|
5505
5761
|
openTooltip (target: any, content: any) {
|
|
@@ -5557,11 +5813,16 @@ const Methods = {
|
|
|
5557
5813
|
* 获取复选框半选状态的行数据
|
|
5558
5814
|
*/
|
|
5559
5815
|
getCheckboxIndeterminateRecords (isFull: any) {
|
|
5560
|
-
const
|
|
5816
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5817
|
+
const props = $xeTable
|
|
5818
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5819
|
+
|
|
5820
|
+
const { treeConfig } = props
|
|
5821
|
+
const { fullDataRowIdData, treeIndeterminateRowMaps } = internalData
|
|
5561
5822
|
if (treeConfig) {
|
|
5562
5823
|
const fullRest: any[] = []
|
|
5563
5824
|
const defRest: any[] = []
|
|
5564
|
-
XEUtils.each(
|
|
5825
|
+
XEUtils.each(treeIndeterminateRowMaps, (item, rowid) => {
|
|
5565
5826
|
if (item) {
|
|
5566
5827
|
fullRest.push(item)
|
|
5567
5828
|
if (fullDataRowIdData[rowid]) {
|
|
@@ -5576,26 +5837,6 @@ const Methods = {
|
|
|
5576
5837
|
}
|
|
5577
5838
|
return []
|
|
5578
5839
|
},
|
|
5579
|
-
/**
|
|
5580
|
-
* 处理默认勾选
|
|
5581
|
-
*/
|
|
5582
|
-
handleDefaultSelectionChecked () {
|
|
5583
|
-
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5584
|
-
|
|
5585
|
-
const { fullDataRowIdData, checkboxOpts } = this
|
|
5586
|
-
const { checkAll, checkRowKeys } = checkboxOpts
|
|
5587
|
-
if (checkAll) {
|
|
5588
|
-
handleCheckedAllCheckboxRow($xeTable, true, true)
|
|
5589
|
-
} else if (checkRowKeys) {
|
|
5590
|
-
const defSelection: any[] = []
|
|
5591
|
-
checkRowKeys.forEach((rowid: any) => {
|
|
5592
|
-
if (fullDataRowIdData[rowid]) {
|
|
5593
|
-
defSelection.push(fullDataRowIdData[rowid].row)
|
|
5594
|
-
}
|
|
5595
|
-
})
|
|
5596
|
-
handleCheckedCheckboxRow($xeTable, defSelection, true, true)
|
|
5597
|
-
}
|
|
5598
|
-
},
|
|
5599
5840
|
handleCheckedCheckboxRow (rows: any[], value: boolean, isForce?: boolean) {
|
|
5600
5841
|
const $xeTable = this
|
|
5601
5842
|
|
|
@@ -5616,7 +5857,7 @@ const Methods = {
|
|
|
5616
5857
|
},
|
|
5617
5858
|
setCheckboxRowKey (keys: any, checked: boolean) {
|
|
5618
5859
|
const $xeTable = this
|
|
5619
|
-
const internalData = $xeTable
|
|
5860
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5620
5861
|
|
|
5621
5862
|
const { fullAllDataRowIdData } = internalData
|
|
5622
5863
|
if (keys && !XEUtils.isArray(keys)) {
|
|
@@ -5633,23 +5874,25 @@ const Methods = {
|
|
|
5633
5874
|
},
|
|
5634
5875
|
isCheckedByCheckboxRow (row: any) {
|
|
5635
5876
|
const $xeTable = this
|
|
5636
|
-
const reactData = $xeTable
|
|
5877
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
5878
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5637
5879
|
|
|
5638
|
-
const {
|
|
5880
|
+
const { updateCheckboxFlag } = reactData
|
|
5881
|
+
const { selectCheckboxMaps } = internalData
|
|
5639
5882
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5640
5883
|
const { checkField } = checkboxOpts
|
|
5641
5884
|
if (checkField) {
|
|
5642
5885
|
return XEUtils.get(row, checkField)
|
|
5643
5886
|
}
|
|
5644
|
-
return !!selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5887
|
+
return !!updateCheckboxFlag && !!selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5645
5888
|
},
|
|
5646
5889
|
isCheckedByCheckboxRowKey (rowid: string) {
|
|
5647
|
-
const $xeTable = this
|
|
5648
|
-
const reactData = $xeTable
|
|
5649
|
-
const internalData = $xeTable
|
|
5890
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5891
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
5892
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5650
5893
|
|
|
5651
|
-
const {
|
|
5652
|
-
const { fullAllDataRowIdData } = internalData
|
|
5894
|
+
const { updateCheckboxFlag } = reactData
|
|
5895
|
+
const { fullAllDataRowIdData, selectCheckboxMaps } = internalData
|
|
5653
5896
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5654
5897
|
const { checkField } = checkboxOpts
|
|
5655
5898
|
if (checkField) {
|
|
@@ -5659,21 +5902,21 @@ const Methods = {
|
|
|
5659
5902
|
}
|
|
5660
5903
|
return false
|
|
5661
5904
|
}
|
|
5662
|
-
return !!selectCheckboxMaps[rowid]
|
|
5905
|
+
return !!updateCheckboxFlag && !!selectCheckboxMaps[rowid]
|
|
5663
5906
|
},
|
|
5664
5907
|
isIndeterminateByCheckboxRow (row: any) {
|
|
5665
|
-
const $xeTable = this
|
|
5666
|
-
const
|
|
5908
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5909
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5667
5910
|
|
|
5668
|
-
const {
|
|
5669
|
-
return !!
|
|
5911
|
+
const { treeIndeterminateRowMaps } = internalData
|
|
5912
|
+
return !!treeIndeterminateRowMaps[getRowid($xeTable, row)] && !$xeTable.isCheckedByCheckboxRow(row)
|
|
5670
5913
|
},
|
|
5671
5914
|
isIndeterminateByCheckboxRowKey (rowid: string) {
|
|
5672
5915
|
const $xeTable = this
|
|
5673
|
-
const
|
|
5916
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5674
5917
|
|
|
5675
|
-
const {
|
|
5676
|
-
return !!
|
|
5918
|
+
const { treeIndeterminateRowMaps } = internalData
|
|
5919
|
+
return !!treeIndeterminateRowMaps[rowid] && !$xeTable.isCheckedByCheckboxRowKey(rowid)
|
|
5677
5920
|
},
|
|
5678
5921
|
/**
|
|
5679
5922
|
* 切换选中
|
|
@@ -5683,15 +5926,16 @@ const Methods = {
|
|
|
5683
5926
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5684
5927
|
const props = $xeTable
|
|
5685
5928
|
const reactData = $xeTable as unknown as TableReactData
|
|
5929
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5686
5930
|
|
|
5687
5931
|
const { treeConfig } = props
|
|
5688
|
-
const { selectCheckboxMaps } =
|
|
5689
|
-
const selectRowMaps = Object.assign({}, selectCheckboxMaps)
|
|
5932
|
+
const { selectCheckboxMaps } = internalData
|
|
5690
5933
|
const treeOpts = $xeTable.computeTreeOpts
|
|
5691
5934
|
const { transform, mapChildrenField } = treeOpts
|
|
5692
5935
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
5693
5936
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5694
5937
|
const { checkField, checkStrictly, checkMethod } = checkboxOpts
|
|
5938
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
5695
5939
|
// indeterminateField 仅支持读取
|
|
5696
5940
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
5697
5941
|
if (checkField) {
|
|
@@ -5707,18 +5951,17 @@ const Methods = {
|
|
|
5707
5951
|
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5708
5952
|
}
|
|
5709
5953
|
}, { children: transform ? mapChildrenField : childrenField })
|
|
5710
|
-
reactData.
|
|
5954
|
+
reactData.updateCheckboxFlag++
|
|
5711
5955
|
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
5956
|
}
|
|
5721
|
-
|
|
5957
|
+
// 列表
|
|
5958
|
+
rows.forEach(row => {
|
|
5959
|
+
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5960
|
+
XEUtils.set(row, checkField, checked)
|
|
5961
|
+
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5962
|
+
}
|
|
5963
|
+
})
|
|
5964
|
+
reactData.updateCheckboxFlag++
|
|
5722
5965
|
return
|
|
5723
5966
|
}
|
|
5724
5967
|
|
|
@@ -5726,51 +5969,55 @@ const Methods = {
|
|
|
5726
5969
|
if (treeConfig && !checkStrictly) {
|
|
5727
5970
|
// 更新子节点状态
|
|
5728
5971
|
XEUtils.eachTree(rows, (row) => {
|
|
5729
|
-
const rowid =
|
|
5972
|
+
const rowid = handleGetRowId(row)
|
|
5730
5973
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5731
5974
|
if (checked) {
|
|
5732
|
-
|
|
5975
|
+
selectCheckboxMaps[rowid] = row
|
|
5733
5976
|
} else {
|
|
5734
|
-
if (
|
|
5735
|
-
delete
|
|
5977
|
+
if (selectCheckboxMaps[rowid]) {
|
|
5978
|
+
delete selectCheckboxMaps[rowid]
|
|
5736
5979
|
}
|
|
5737
5980
|
}
|
|
5738
5981
|
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5739
5982
|
}
|
|
5740
5983
|
}, { children: transform ? mapChildrenField : childrenField })
|
|
5741
|
-
reactData.
|
|
5984
|
+
reactData.updateCheckboxFlag++
|
|
5742
5985
|
return
|
|
5743
5986
|
}
|
|
5744
5987
|
|
|
5745
5988
|
// 列表
|
|
5746
5989
|
rows.forEach(row => {
|
|
5747
|
-
const rowid =
|
|
5990
|
+
const rowid = handleGetRowId(row)
|
|
5748
5991
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5749
5992
|
if (checked) {
|
|
5750
|
-
if (!
|
|
5751
|
-
|
|
5993
|
+
if (!selectCheckboxMaps[rowid]) {
|
|
5994
|
+
selectCheckboxMaps[rowid] = row
|
|
5752
5995
|
}
|
|
5753
5996
|
} else {
|
|
5754
|
-
if (
|
|
5755
|
-
delete
|
|
5997
|
+
if (selectCheckboxMaps[rowid]) {
|
|
5998
|
+
delete selectCheckboxMaps[rowid]
|
|
5756
5999
|
}
|
|
5757
6000
|
}
|
|
5758
6001
|
handleCheckboxReserveRow($xeTable, row, checked)
|
|
6002
|
+
reactData.updateCheckboxFlag++
|
|
5759
6003
|
}
|
|
5760
6004
|
})
|
|
5761
|
-
reactData.selectCheckboxMaps = selectRowMaps
|
|
5762
6005
|
},
|
|
5763
6006
|
/**
|
|
5764
6007
|
* 即将移除
|
|
5765
6008
|
* @deprecated
|
|
5766
6009
|
*/
|
|
5767
6010
|
handleSelectRow ({ row }: any, checked: boolean, isForce?: boolean) {
|
|
5768
|
-
const $xeTable = this
|
|
6011
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5769
6012
|
|
|
5770
6013
|
$xeTable.handleBatchSelectRows([row], checked, isForce)
|
|
5771
6014
|
},
|
|
5772
6015
|
handleToggleCheckRowEvent (evnt: any, params: any) {
|
|
5773
|
-
const
|
|
6016
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6017
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
6018
|
+
|
|
6019
|
+
const { selectCheckboxMaps } = internalData
|
|
6020
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5774
6021
|
const { checkField, trigger } = checkboxOpts
|
|
5775
6022
|
const { row } = params
|
|
5776
6023
|
if (trigger === 'manual') {
|
|
@@ -5780,47 +6027,52 @@ const Methods = {
|
|
|
5780
6027
|
if (checkField) {
|
|
5781
6028
|
checked = !XEUtils.get(row, checkField)
|
|
5782
6029
|
} else {
|
|
5783
|
-
checked = !selectCheckboxMaps[getRowid(
|
|
6030
|
+
checked = !selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5784
6031
|
}
|
|
5785
6032
|
if (evnt) {
|
|
5786
|
-
|
|
6033
|
+
$xeTable.triggerCheckRowEvent(evnt, params, checked)
|
|
5787
6034
|
} else {
|
|
5788
|
-
|
|
5789
|
-
|
|
6035
|
+
$xeTable.handleBatchSelectRows([row], checked)
|
|
6036
|
+
$xeTable.checkSelectionStatus()
|
|
5790
6037
|
}
|
|
5791
6038
|
},
|
|
5792
6039
|
triggerCheckRowEvent (evnt: any, params: any, checked: any) {
|
|
5793
|
-
const $xeTable = this
|
|
6040
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6041
|
+
const props = $xeTable
|
|
6042
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5794
6043
|
|
|
5795
|
-
const { checkboxOpts, afterFullData } = this
|
|
5796
|
-
const { checkMethod, trigger } = checkboxOpts
|
|
5797
6044
|
const { row } = params
|
|
6045
|
+
const { afterFullData } = internalData
|
|
6046
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
6047
|
+
const { checkMethod, trigger } = checkboxOpts
|
|
5798
6048
|
if (trigger === 'manual') {
|
|
5799
6049
|
return
|
|
5800
6050
|
}
|
|
5801
6051
|
evnt.stopPropagation()
|
|
5802
|
-
if (checkboxOpts.isShiftKey && evnt.shiftKey && !
|
|
5803
|
-
const checkboxRecords =
|
|
6052
|
+
if (checkboxOpts.isShiftKey && evnt.shiftKey && !props.treeConfig) {
|
|
6053
|
+
const checkboxRecords = $xeTable.getCheckboxRecords()
|
|
5804
6054
|
if (checkboxRecords.length) {
|
|
5805
6055
|
const firstRow = checkboxRecords[0]
|
|
5806
|
-
const _rowIndex =
|
|
5807
|
-
const _firstRowIndex =
|
|
6056
|
+
const _rowIndex = $xeTable.getVTRowIndex(row)
|
|
6057
|
+
const _firstRowIndex = $xeTable.getVTRowIndex(firstRow)
|
|
5808
6058
|
if (_rowIndex !== _firstRowIndex) {
|
|
5809
|
-
|
|
6059
|
+
$xeTable.setAllCheckboxRow(false)
|
|
5810
6060
|
const rangeRows = _rowIndex < _firstRowIndex ? afterFullData.slice(_rowIndex, _firstRowIndex + 1) : afterFullData.slice(_firstRowIndex, _rowIndex + 1)
|
|
5811
|
-
|
|
5812
|
-
|
|
6061
|
+
$xeTable.$nextTick(() => {
|
|
6062
|
+
handleCheckedCheckboxRow($xeTable, rangeRows, true, false)
|
|
6063
|
+
})
|
|
6064
|
+
$xeTable.dispatchEvent('checkbox-range-select', Object.assign({ rangeRecords: rangeRows }, params), evnt)
|
|
5813
6065
|
return
|
|
5814
6066
|
}
|
|
5815
6067
|
}
|
|
5816
6068
|
}
|
|
5817
6069
|
if (!checkMethod || checkMethod({ row })) {
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
records:
|
|
5822
|
-
reserves:
|
|
5823
|
-
indeterminates:
|
|
6070
|
+
$xeTable.handleBatchSelectRows([row], checked)
|
|
6071
|
+
$xeTable.checkSelectionStatus()
|
|
6072
|
+
$xeTable.dispatchEvent('checkbox-change', Object.assign({
|
|
6073
|
+
records: () => $xeTable.getCheckboxRecords(),
|
|
6074
|
+
reserves: () => $xeTable.getCheckboxReserveRecords(),
|
|
6075
|
+
indeterminates: () => $xeTable.getCheckboxIndeterminateRecords(),
|
|
5824
6076
|
checked
|
|
5825
6077
|
}, params), evnt)
|
|
5826
6078
|
}
|
|
@@ -5829,9 +6081,11 @@ const Methods = {
|
|
|
5829
6081
|
* 多选,切换某一行的选中状态
|
|
5830
6082
|
*/
|
|
5831
6083
|
toggleCheckboxRow (row: any) {
|
|
5832
|
-
const $xeTable = this
|
|
6084
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6085
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5833
6086
|
|
|
5834
|
-
const { selectCheckboxMaps
|
|
6087
|
+
const { selectCheckboxMaps } = internalData
|
|
6088
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5835
6089
|
const { checkField } = checkboxOpts
|
|
5836
6090
|
const checked = checkField ? !XEUtils.get(row, checkField) : !selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5837
6091
|
$xeTable.handleBatchSelectRows([row], checked, true)
|
|
@@ -5854,9 +6108,7 @@ const Methods = {
|
|
|
5854
6108
|
const internalData = $xeTable as unknown as TableInternalData
|
|
5855
6109
|
|
|
5856
6110
|
const { treeConfig } = props
|
|
5857
|
-
const { selectCheckboxMaps,
|
|
5858
|
-
const selectRowMaps = Object.assign({}, selectCheckboxMaps)
|
|
5859
|
-
const halfRowMaps = Object.assign({}, treeIndeterminateMaps)
|
|
6111
|
+
const { selectCheckboxMaps, treeIndeterminateRowMaps } = internalData
|
|
5860
6112
|
const treeOpts = $xeTable.computeTreeOpts
|
|
5861
6113
|
const { transform, mapChildrenField } = treeOpts
|
|
5862
6114
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
@@ -5868,10 +6120,11 @@ const Methods = {
|
|
|
5868
6120
|
}
|
|
5869
6121
|
// 树结构
|
|
5870
6122
|
if (treeConfig) {
|
|
6123
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
5871
6124
|
const childRowMaps: Record<string, number> = {}
|
|
5872
6125
|
const childRowList: any[][] = []
|
|
5873
6126
|
XEUtils.eachTree(afterTreeFullData, (row: any) => {
|
|
5874
|
-
const rowid =
|
|
6127
|
+
const rowid = handleGetRowId(row)
|
|
5875
6128
|
const childList = row[transform ? mapChildrenField : childrenField]
|
|
5876
6129
|
if (childList && childList.length && !childRowMaps[rowid]) {
|
|
5877
6130
|
childRowMaps[rowid] = 1
|
|
@@ -5888,29 +6141,29 @@ const Methods = {
|
|
|
5888
6141
|
childList.forEach(
|
|
5889
6142
|
checkMethod
|
|
5890
6143
|
? (item) => {
|
|
5891
|
-
const childRowid =
|
|
5892
|
-
const isSelect = checkField ? XEUtils.get(item, checkField) :
|
|
6144
|
+
const childRowid = handleGetRowId(item)
|
|
6145
|
+
const isSelect = checkField ? XEUtils.get(item, checkField) : selectCheckboxMaps[childRowid]
|
|
5893
6146
|
if (checkMethod({ row: item })) {
|
|
5894
6147
|
if (isSelect) {
|
|
5895
6148
|
sLen++
|
|
5896
|
-
} else if (
|
|
6149
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5897
6150
|
hLen++
|
|
5898
6151
|
}
|
|
5899
6152
|
vLen++
|
|
5900
6153
|
} else {
|
|
5901
6154
|
if (isSelect) {
|
|
5902
6155
|
sLen++
|
|
5903
|
-
} else if (
|
|
6156
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5904
6157
|
hLen++
|
|
5905
6158
|
}
|
|
5906
6159
|
}
|
|
5907
6160
|
}
|
|
5908
6161
|
: item => {
|
|
5909
|
-
const childRowid =
|
|
5910
|
-
const isSelect = checkField ? XEUtils.get(item, checkField) :
|
|
6162
|
+
const childRowid = handleGetRowId(item)
|
|
6163
|
+
const isSelect = checkField ? XEUtils.get(item, checkField) : selectCheckboxMaps[childRowid]
|
|
5911
6164
|
if (isSelect) {
|
|
5912
6165
|
sLen++
|
|
5913
|
-
} else if (
|
|
6166
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5914
6167
|
hLen++
|
|
5915
6168
|
}
|
|
5916
6169
|
vLen++
|
|
@@ -5923,29 +6176,28 @@ const Methods = {
|
|
|
5923
6176
|
}
|
|
5924
6177
|
if (isSelected) {
|
|
5925
6178
|
if (!checkField) {
|
|
5926
|
-
|
|
6179
|
+
selectCheckboxMaps[rowid] = row
|
|
5927
6180
|
}
|
|
5928
|
-
if (
|
|
5929
|
-
delete
|
|
6181
|
+
if (treeIndeterminateRowMaps[rowid]) {
|
|
6182
|
+
delete treeIndeterminateRowMaps[rowid]
|
|
5930
6183
|
}
|
|
5931
6184
|
} else {
|
|
5932
6185
|
if (!checkField) {
|
|
5933
|
-
if (
|
|
5934
|
-
delete
|
|
6186
|
+
if (selectCheckboxMaps[rowid]) {
|
|
6187
|
+
delete selectCheckboxMaps[rowid]
|
|
5935
6188
|
}
|
|
5936
6189
|
}
|
|
5937
6190
|
if (halfSelect) {
|
|
5938
|
-
|
|
6191
|
+
treeIndeterminateRowMaps[rowid] = row
|
|
5939
6192
|
} else {
|
|
5940
|
-
if (
|
|
5941
|
-
delete
|
|
6193
|
+
if (treeIndeterminateRowMaps[rowid]) {
|
|
6194
|
+
delete treeIndeterminateRowMaps[rowid]
|
|
5942
6195
|
}
|
|
5943
6196
|
}
|
|
5944
6197
|
}
|
|
5945
6198
|
})
|
|
5946
6199
|
}
|
|
5947
|
-
reactData.
|
|
5948
|
-
reactData.treeIndeterminateMaps = halfRowMaps
|
|
6200
|
+
reactData.updateCheckboxFlag++
|
|
5949
6201
|
},
|
|
5950
6202
|
updateAllCheckboxStatus () {
|
|
5951
6203
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
@@ -5954,10 +6206,10 @@ const Methods = {
|
|
|
5954
6206
|
const internalData = $xeTable as unknown as TableInternalData
|
|
5955
6207
|
|
|
5956
6208
|
const { treeConfig } = props
|
|
5957
|
-
const { selectCheckboxMaps,
|
|
6209
|
+
const { afterFullData, afterTreeFullData, checkboxReserveRowMap, selectCheckboxMaps, treeIndeterminateRowMaps } = internalData
|
|
5958
6210
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5959
6211
|
const { checkField, checkMethod, showReserveStatus } = checkboxOpts
|
|
5960
|
-
const {
|
|
6212
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
5961
6213
|
|
|
5962
6214
|
let sLen = 0 // 已选
|
|
5963
6215
|
let hLen = 0 // 半选
|
|
@@ -5966,29 +6218,29 @@ const Methods = {
|
|
|
5966
6218
|
const rootList: any[] = (treeConfig ? afterTreeFullData : afterFullData)
|
|
5967
6219
|
rootList.forEach(checkMethod
|
|
5968
6220
|
? row => {
|
|
5969
|
-
const childRowid =
|
|
6221
|
+
const childRowid = handleGetRowId(row)
|
|
5970
6222
|
const selected = checkField ? XEUtils.get(row, checkField) : selectCheckboxMaps[childRowid]
|
|
5971
6223
|
if (checkMethod({ row })) {
|
|
5972
6224
|
if (selected) {
|
|
5973
6225
|
sLen++
|
|
5974
|
-
} else if (
|
|
6226
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5975
6227
|
hLen++
|
|
5976
6228
|
}
|
|
5977
6229
|
vLen++
|
|
5978
6230
|
} else {
|
|
5979
6231
|
if (selected) {
|
|
5980
6232
|
sLen++
|
|
5981
|
-
} else if (
|
|
6233
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5982
6234
|
hLen++
|
|
5983
6235
|
}
|
|
5984
6236
|
}
|
|
5985
6237
|
}
|
|
5986
6238
|
: row => {
|
|
5987
|
-
const childRowid =
|
|
6239
|
+
const childRowid = handleGetRowId(row)
|
|
5988
6240
|
const selected = checkField ? XEUtils.get(row, checkField) : selectCheckboxMaps[childRowid]
|
|
5989
6241
|
if (selected) {
|
|
5990
6242
|
sLen++
|
|
5991
|
-
} else if (
|
|
6243
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5992
6244
|
hLen++
|
|
5993
6245
|
}
|
|
5994
6246
|
vLen++
|
|
@@ -6047,18 +6299,26 @@ const Methods = {
|
|
|
6047
6299
|
* 获取复选框保留选中的行
|
|
6048
6300
|
*/
|
|
6049
6301
|
getCheckboxReserveRecords (isFull: any) {
|
|
6050
|
-
const
|
|
6302
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6303
|
+
const props = $xeTable
|
|
6304
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
6305
|
+
|
|
6306
|
+
const { treeConfig } = props
|
|
6307
|
+
const { afterFullData, fullDataRowIdData, checkboxReserveRowMap } = internalData
|
|
6308
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
6309
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
6051
6310
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
6052
6311
|
const reserveSelection: any[] = []
|
|
6053
6312
|
if (checkboxOpts.reserve) {
|
|
6054
|
-
const
|
|
6313
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
6314
|
+
const afterFullIdMaps: { [key: string]: number } = {}
|
|
6055
6315
|
if (treeConfig) {
|
|
6056
6316
|
XEUtils.eachTree(afterFullData, row => {
|
|
6057
|
-
afterFullIdMaps[
|
|
6317
|
+
afterFullIdMaps[handleGetRowId(row)] = 1
|
|
6058
6318
|
}, { children: childrenField })
|
|
6059
6319
|
} else {
|
|
6060
6320
|
afterFullData.forEach((row: any) => {
|
|
6061
|
-
afterFullIdMaps[
|
|
6321
|
+
afterFullIdMaps[handleGetRowId(row)] = 1
|
|
6062
6322
|
})
|
|
6063
6323
|
}
|
|
6064
6324
|
XEUtils.each(checkboxReserveRowMap, (oldRow, oldRowid) => {
|
|
@@ -6098,9 +6358,9 @@ const Methods = {
|
|
|
6098
6358
|
handleCheckedAllCheckboxRow($xeTable, value)
|
|
6099
6359
|
if (evnt) {
|
|
6100
6360
|
$xeTable.dispatchEvent('checkbox-all', {
|
|
6101
|
-
records: $xeTable.getCheckboxRecords(),
|
|
6102
|
-
reserves: $xeTable.getCheckboxReserveRecords(),
|
|
6103
|
-
indeterminates: $xeTable.getCheckboxIndeterminateRecords(),
|
|
6361
|
+
records: () => $xeTable.getCheckboxRecords(),
|
|
6362
|
+
reserves: () => $xeTable.getCheckboxReserveRecords(),
|
|
6363
|
+
indeterminates: () => $xeTable.getCheckboxIndeterminateRecords(),
|
|
6104
6364
|
checked: value
|
|
6105
6365
|
}, evnt)
|
|
6106
6366
|
}
|
|
@@ -6133,50 +6393,41 @@ const Methods = {
|
|
|
6133
6393
|
* 清空行为不管是否被禁用还是保留记录,都将彻底清空选中状态
|
|
6134
6394
|
*/
|
|
6135
6395
|
clearCheckboxRow () {
|
|
6136
|
-
const
|
|
6137
|
-
const
|
|
6396
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6397
|
+
const props = $xeTable
|
|
6398
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
6399
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
6400
|
+
|
|
6401
|
+
const { treeConfig } = props
|
|
6402
|
+
const { tableFullData } = internalData
|
|
6403
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
6138
6404
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
6405
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
6406
|
+
const { checkField, reserve } = checkboxOpts
|
|
6139
6407
|
// indeterminateField 仅支持读取
|
|
6140
6408
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
6141
6409
|
if (checkField) {
|
|
6142
6410
|
const handleClearChecked = (item: any) => {
|
|
6143
6411
|
if (treeConfig && indeterminateField) {
|
|
6144
6412
|
XEUtils.set(item, indeterminateField, false)
|
|
6145
|
-
}
|
|
6146
|
-
XEUtils.set(item, checkField, false)
|
|
6147
|
-
}
|
|
6148
|
-
if (treeConfig) {
|
|
6149
|
-
XEUtils.eachTree(tableFullData, handleClearChecked, { children: childrenField })
|
|
6150
|
-
} else {
|
|
6151
|
-
tableFullData.forEach(handleClearChecked)
|
|
6152
|
-
}
|
|
6153
|
-
}
|
|
6154
|
-
if (reserve) {
|
|
6155
|
-
tableFullData.forEach((row: any) => this.handleCheckboxReserveRow(row, false))
|
|
6156
|
-
}
|
|
6157
|
-
this.isAllSelected = false
|
|
6158
|
-
this.isIndeterminate = false
|
|
6159
|
-
this.selectCheckboxMaps = {}
|
|
6160
|
-
this.treeIndeterminateMaps = {}
|
|
6161
|
-
return this.$nextTick()
|
|
6162
|
-
},
|
|
6163
|
-
/**
|
|
6164
|
-
* 处理单选框默认勾选
|
|
6165
|
-
*/
|
|
6166
|
-
handleDefaultRadioChecked () {
|
|
6167
|
-
const $xeTable = this
|
|
6168
|
-
|
|
6169
|
-
const { radioOpts, fullDataRowIdData } = this
|
|
6170
|
-
const { checkRowKey: rowid, reserve } = radioOpts
|
|
6171
|
-
if (rowid) {
|
|
6172
|
-
if (fullDataRowIdData[rowid]) {
|
|
6173
|
-
handleCheckedRadioRow($xeTable, fullDataRowIdData[rowid].row, true)
|
|
6413
|
+
}
|
|
6414
|
+
XEUtils.set(item, checkField, false)
|
|
6174
6415
|
}
|
|
6175
|
-
if (
|
|
6176
|
-
|
|
6177
|
-
|
|
6416
|
+
if (treeConfig) {
|
|
6417
|
+
XEUtils.eachTree(tableFullData, handleClearChecked, { children: childrenField })
|
|
6418
|
+
} else {
|
|
6419
|
+
tableFullData.forEach(handleClearChecked)
|
|
6178
6420
|
}
|
|
6179
6421
|
}
|
|
6422
|
+
if (reserve) {
|
|
6423
|
+
tableFullData.forEach((row) => this.handleCheckboxReserveRow(row, false))
|
|
6424
|
+
}
|
|
6425
|
+
reactData.isAllSelected = false
|
|
6426
|
+
reactData.isIndeterminate = false
|
|
6427
|
+
internalData.selectCheckboxMaps = {}
|
|
6428
|
+
internalData.treeIndeterminateRowMaps = {}
|
|
6429
|
+
reactData.updateCheckboxFlag++
|
|
6430
|
+
return this.$nextTick()
|
|
6180
6431
|
},
|
|
6181
6432
|
/**
|
|
6182
6433
|
* 单选,行选中事件
|
|
@@ -6364,11 +6615,13 @@ const Methods = {
|
|
|
6364
6615
|
},
|
|
6365
6616
|
triggerHeaderCellClickEvent (evnt: MouseEvent, params: VxeTableDefines.CellRenderHeaderParams) {
|
|
6366
6617
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6618
|
+
const props = $xeTable
|
|
6367
6619
|
const internalData = $xeTable as unknown as TableInternalData
|
|
6368
6620
|
|
|
6369
6621
|
const { _lastResizeTime } = internalData
|
|
6370
6622
|
const sortOpts = $xeTable.computeSortOpts
|
|
6371
6623
|
const columnOpts = $xeTable.computeColumnOpts
|
|
6624
|
+
const currentColumnOpts = $xeTable.computeCurrentColumnOpts
|
|
6372
6625
|
const { column } = params
|
|
6373
6626
|
const cell = evnt.currentTarget
|
|
6374
6627
|
const triggerResizable = _lastResizeTime && _lastResizeTime > Date.now() - 300
|
|
@@ -6378,7 +6631,7 @@ const Methods = {
|
|
|
6378
6631
|
$xeTable.triggerSortEvent(evnt, column, getNextSortOrder($xeTable, column))
|
|
6379
6632
|
}
|
|
6380
6633
|
$xeTable.dispatchEvent('header-cell-click', Object.assign({ triggerResizable, triggerSort, triggerFilter, cell }, params), evnt)
|
|
6381
|
-
if (columnOpts.isCurrent ||
|
|
6634
|
+
if ((columnOpts.isCurrent || props.highlightCurrentColumn) && (!currentColumnOpts.trigger || ['header', 'default'].includes(currentColumnOpts.trigger))) {
|
|
6382
6635
|
$xeTable.triggerCurrentColumnEvent(evnt, params)
|
|
6383
6636
|
}
|
|
6384
6637
|
return $xeTable.$nextTick()
|
|
@@ -6394,13 +6647,24 @@ const Methods = {
|
|
|
6394
6647
|
* @param {ColumnInfo} fieldOrColumn 列配置
|
|
6395
6648
|
*/
|
|
6396
6649
|
setCurrentColumn (fieldOrColumn: any) {
|
|
6397
|
-
const
|
|
6650
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6651
|
+
const props = $xeTable
|
|
6652
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
6653
|
+
|
|
6654
|
+
const { mouseConfig } = props
|
|
6655
|
+
const mouseOpts = $xeTable.computeMouseOpts
|
|
6656
|
+
const isMouseSelected = mouseConfig && mouseOpts.selected
|
|
6657
|
+
const column = handleFieldOrColumn($xeTable, fieldOrColumn)
|
|
6398
6658
|
if (column) {
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
this.currentColumn = column
|
|
6659
|
+
$xeTable.clearCurrentColumn()
|
|
6660
|
+
reactData.currentColumn = column
|
|
6402
6661
|
}
|
|
6403
|
-
return
|
|
6662
|
+
return $xeTable.$nextTick().then(() => {
|
|
6663
|
+
// 更新状选中态
|
|
6664
|
+
if (isMouseSelected) {
|
|
6665
|
+
$xeTable.addCellSelectedClass()
|
|
6666
|
+
}
|
|
6667
|
+
})
|
|
6404
6668
|
},
|
|
6405
6669
|
/**
|
|
6406
6670
|
* 用于当前列,手动清空当前高亮的状态
|
|
@@ -6409,36 +6673,17 @@ const Methods = {
|
|
|
6409
6673
|
this.currentColumn = null
|
|
6410
6674
|
return this.$nextTick()
|
|
6411
6675
|
},
|
|
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
6676
|
/**
|
|
6432
6677
|
* 列点击事件
|
|
6433
6678
|
* 如果是单击模式,则激活为编辑状态
|
|
6434
6679
|
* 如果是双击模式,则单击后选中状态
|
|
6435
6680
|
*/
|
|
6436
6681
|
triggerCellClickEvent (evnt: MouseEvent, params: VxeTableDefines.CellRenderBodyParams) {
|
|
6437
|
-
const $xeTable = this
|
|
6682
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6438
6683
|
const props = $xeTable
|
|
6439
|
-
const reactData = $xeTable
|
|
6684
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
6440
6685
|
|
|
6441
|
-
const { highlightCurrentRow, editConfig } = props
|
|
6686
|
+
const { highlightCurrentRow, highlightCurrentColumn, editConfig } = props
|
|
6442
6687
|
const { editStore, isDragResize } = reactData
|
|
6443
6688
|
if (isDragResize) {
|
|
6444
6689
|
return
|
|
@@ -6450,6 +6695,8 @@ const Methods = {
|
|
|
6450
6695
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
6451
6696
|
const keyboardOpts = $xeTable.computeKeyboardOpts
|
|
6452
6697
|
const rowOpts = $xeTable.computeRowOpts
|
|
6698
|
+
const columnOpts = $xeTable.computeColumnOpts
|
|
6699
|
+
const currentColumnOpts = $xeTable.computeCurrentColumnOpts
|
|
6453
6700
|
const { actived, focused } = editStore
|
|
6454
6701
|
const { row, column } = params
|
|
6455
6702
|
const { type, treeNode } = column
|
|
@@ -6465,11 +6712,11 @@ const Methods = {
|
|
|
6465
6712
|
if (!triggerCheckbox && !triggerRadio) {
|
|
6466
6713
|
// 如果是展开行
|
|
6467
6714
|
if (!triggerExpandNode && (expandOpts.trigger === 'row' || (isExpandType && expandOpts.trigger === 'cell'))) {
|
|
6468
|
-
|
|
6715
|
+
$xeTable.triggerRowExpandEvent(evnt, params)
|
|
6469
6716
|
}
|
|
6470
6717
|
// 如果是树形表格
|
|
6471
6718
|
if ((treeOpts.trigger === 'row' || (treeNode && treeOpts.trigger === 'cell'))) {
|
|
6472
|
-
|
|
6719
|
+
$xeTable.triggerTreeExpandEvent(evnt, params)
|
|
6473
6720
|
}
|
|
6474
6721
|
}
|
|
6475
6722
|
// 如果点击了树节点
|
|
@@ -6478,16 +6725,22 @@ const Methods = {
|
|
|
6478
6725
|
// 如果是高亮行
|
|
6479
6726
|
if (rowOpts.isCurrent || highlightCurrentRow) {
|
|
6480
6727
|
if (!triggerCheckbox && !triggerRadio) {
|
|
6481
|
-
|
|
6728
|
+
$xeTable.triggerCurrentRowEvent(evnt, params)
|
|
6729
|
+
}
|
|
6730
|
+
}
|
|
6731
|
+
// 如果是当前列
|
|
6732
|
+
if ((columnOpts.isCurrent || highlightCurrentColumn) && (!currentColumnOpts.trigger || ['cell', 'default'].includes(currentColumnOpts.trigger))) {
|
|
6733
|
+
if (!triggerCheckbox && !triggerRadio) {
|
|
6734
|
+
$xeTable.triggerCurrentColumnEvent(evnt, params)
|
|
6482
6735
|
}
|
|
6483
6736
|
}
|
|
6484
6737
|
// 如果是单选框
|
|
6485
6738
|
if (!triggerRadio && (radioOpts.trigger === 'row' || (isRadioType && radioOpts.trigger === 'cell'))) {
|
|
6486
|
-
|
|
6739
|
+
$xeTable.triggerRadioRowEvent(evnt, params)
|
|
6487
6740
|
}
|
|
6488
6741
|
// 如果是复选框
|
|
6489
6742
|
if (!triggerCheckbox && (checkboxOpts.trigger === 'row' || (isCheckboxType && checkboxOpts.trigger === 'cell'))) {
|
|
6490
|
-
|
|
6743
|
+
$xeTable.handleToggleCheckRowEvent(evnt, params)
|
|
6491
6744
|
}
|
|
6492
6745
|
}
|
|
6493
6746
|
// 如果设置了单元格选中功能,则不会使用点击事件去处理(只能支持双击模式)
|
|
@@ -6499,14 +6752,14 @@ const Methods = {
|
|
|
6499
6752
|
}
|
|
6500
6753
|
if (editOpts.trigger === 'manual') {
|
|
6501
6754
|
if (actived.args && actived.row === row && column !== actived.column) {
|
|
6502
|
-
|
|
6755
|
+
handleChangeCell($xeTable, evnt, params)
|
|
6503
6756
|
}
|
|
6504
6757
|
} else if (!actived.args || row !== actived.row || column !== actived.column) {
|
|
6505
6758
|
if (editOpts.trigger === 'click') {
|
|
6506
|
-
|
|
6759
|
+
handleChangeCell($xeTable, evnt, params)
|
|
6507
6760
|
} else if (editOpts.trigger === 'dblclick') {
|
|
6508
6761
|
if (editOpts.mode === 'row' && actived.row === row) {
|
|
6509
|
-
|
|
6762
|
+
handleChangeCell($xeTable, evnt, params)
|
|
6510
6763
|
}
|
|
6511
6764
|
}
|
|
6512
6765
|
}
|
|
@@ -6526,7 +6779,7 @@ const Methods = {
|
|
|
6526
6779
|
}
|
|
6527
6780
|
}
|
|
6528
6781
|
}
|
|
6529
|
-
|
|
6782
|
+
$xeTable.dispatchEvent('cell-click', params, evnt)
|
|
6530
6783
|
},
|
|
6531
6784
|
/**
|
|
6532
6785
|
* 列双击点击事件
|
|
@@ -6549,48 +6802,22 @@ const Methods = {
|
|
|
6549
6802
|
if (isEnableConf(editConfig) && editOpts.trigger === 'dblclick') {
|
|
6550
6803
|
if (!actived.args || evnt.currentTarget !== actived.args.cell) {
|
|
6551
6804
|
if (editOpts.mode === 'row') {
|
|
6552
|
-
|
|
6805
|
+
checkValidate($xeTable, 'blur')
|
|
6553
6806
|
.catch((e: any) => e)
|
|
6554
6807
|
.then(() => {
|
|
6555
6808
|
this.handleEdit(params, evnt)
|
|
6556
|
-
.then(() =>
|
|
6809
|
+
.then(() => checkValidate($xeTable, 'change'))
|
|
6557
6810
|
.catch((e: any) => e)
|
|
6558
6811
|
})
|
|
6559
6812
|
} else if (editOpts.mode === 'cell') {
|
|
6560
6813
|
this.handleEdit(params, evnt)
|
|
6561
|
-
.then(() =>
|
|
6814
|
+
.then(() => checkValidate($xeTable, 'change'))
|
|
6562
6815
|
.catch((e: any) => e)
|
|
6563
6816
|
}
|
|
6564
6817
|
}
|
|
6565
6818
|
}
|
|
6566
6819
|
this.emitEvent('cell-dblclick', params, evnt)
|
|
6567
6820
|
},
|
|
6568
|
-
handleDefaultSort () {
|
|
6569
|
-
const $xeTable = this
|
|
6570
|
-
|
|
6571
|
-
const { sortConfig, sortOpts } = this
|
|
6572
|
-
let { defaultSort } = sortOpts
|
|
6573
|
-
if (defaultSort) {
|
|
6574
|
-
if (!XEUtils.isArray(defaultSort)) {
|
|
6575
|
-
defaultSort = [defaultSort]
|
|
6576
|
-
}
|
|
6577
|
-
if (defaultSort.length) {
|
|
6578
|
-
(sortConfig.multiple ? defaultSort : defaultSort.slice(0, 1)).forEach((item: any, index: any) => {
|
|
6579
|
-
const { field, order } = item
|
|
6580
|
-
if (field && order) {
|
|
6581
|
-
const column = this.getColumnByField(field)
|
|
6582
|
-
if (column && column.sortable) {
|
|
6583
|
-
column.order = order
|
|
6584
|
-
column.sortTime = Date.now() + index
|
|
6585
|
-
}
|
|
6586
|
-
}
|
|
6587
|
-
})
|
|
6588
|
-
if (!sortOpts.remote) {
|
|
6589
|
-
this.handleTableData(true).then(() => updateStyle($xeTable))
|
|
6590
|
-
}
|
|
6591
|
-
}
|
|
6592
|
-
}
|
|
6593
|
-
},
|
|
6594
6821
|
handleColumnSortEvent (evnt: any, column: any) {
|
|
6595
6822
|
const $xeTable = this
|
|
6596
6823
|
const props = $xeTable
|
|
@@ -6754,12 +6981,11 @@ const Methods = {
|
|
|
6754
6981
|
|
|
6755
6982
|
const { treeConfig, dragConfig } = props
|
|
6756
6983
|
const rowDragOpts = $xeTable.computeRowDragOpts
|
|
6757
|
-
const { fullAllDataRowIdData } = internalData
|
|
6984
|
+
const { afterFullData, tableFullData, fullAllDataRowIdData } = internalData
|
|
6758
6985
|
const { isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod, dragToChildMethod } = rowDragOpts
|
|
6759
6986
|
const treeOpts = $xeTable.computeTreeOpts
|
|
6760
6987
|
const { transform, rowField, mapChildrenField, parentField } = treeOpts
|
|
6761
6988
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
6762
|
-
const { afterFullData, tableFullData } = internalData
|
|
6763
6989
|
const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null)
|
|
6764
6990
|
const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
|
|
6765
6991
|
const errRest = {
|
|
@@ -7355,8 +7581,8 @@ const Methods = {
|
|
|
7355
7581
|
}
|
|
7356
7582
|
},
|
|
7357
7583
|
handleHeaderCellDragMousedownEvent (evnt: MouseEvent, params: any) {
|
|
7358
|
-
const $xeTable = this
|
|
7359
|
-
const reactData = $xeTable
|
|
7584
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7585
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7360
7586
|
|
|
7361
7587
|
evnt.stopPropagation()
|
|
7362
7588
|
const columnDragOpts = $xeTable.computeColumnDragOpts
|
|
@@ -7381,8 +7607,8 @@ const Methods = {
|
|
|
7381
7607
|
$xeTable.dispatchEvent('column-dragstart', params, evnt)
|
|
7382
7608
|
},
|
|
7383
7609
|
handleHeaderCellDragMouseupEvent () {
|
|
7384
|
-
const $xeTable = this
|
|
7385
|
-
const reactData = $xeTable
|
|
7610
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7611
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7386
7612
|
|
|
7387
7613
|
clearColDropOrigin($xeTable)
|
|
7388
7614
|
hideDropTip($xeTable)
|
|
@@ -7391,54 +7617,58 @@ const Methods = {
|
|
|
7391
7617
|
reactData.isDragColMove = false
|
|
7392
7618
|
},
|
|
7393
7619
|
setPendingRow (rows: any, status: any) {
|
|
7394
|
-
const $xeTable = this
|
|
7395
|
-
const reactData = $xeTable
|
|
7620
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7621
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7622
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7396
7623
|
|
|
7397
|
-
const
|
|
7624
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
7625
|
+
const { pendingRowMaps } = internalData
|
|
7398
7626
|
if (rows && !XEUtils.isArray(rows)) {
|
|
7399
7627
|
rows = [rows]
|
|
7400
7628
|
}
|
|
7401
7629
|
if (status) {
|
|
7402
7630
|
rows.forEach((row: any) => {
|
|
7403
|
-
const rowid =
|
|
7404
|
-
if (rowid && !
|
|
7405
|
-
|
|
7631
|
+
const rowid = handleGetRowId(row)
|
|
7632
|
+
if (rowid && !pendingRowMaps[rowid]) {
|
|
7633
|
+
pendingRowMaps[rowid] = row
|
|
7406
7634
|
}
|
|
7407
7635
|
})
|
|
7408
7636
|
} else {
|
|
7409
7637
|
rows.forEach((row: any) => {
|
|
7410
|
-
const rowid =
|
|
7411
|
-
if (rowid &&
|
|
7412
|
-
delete
|
|
7638
|
+
const rowid = handleGetRowId(row)
|
|
7639
|
+
if (rowid && pendingRowMaps[rowid]) {
|
|
7640
|
+
delete pendingRowMaps[rowid]
|
|
7413
7641
|
}
|
|
7414
7642
|
})
|
|
7415
7643
|
}
|
|
7416
|
-
reactData.
|
|
7644
|
+
reactData.pendingRowFlag++
|
|
7417
7645
|
return $xeTable.$nextTick()
|
|
7418
7646
|
},
|
|
7419
7647
|
togglePendingRow (rows: any) {
|
|
7420
|
-
const $xeTable = this
|
|
7421
|
-
const reactData = $xeTable
|
|
7648
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7649
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7650
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7422
7651
|
|
|
7423
|
-
const
|
|
7652
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
7653
|
+
const { pendingRowMaps } = internalData
|
|
7424
7654
|
if (rows && !XEUtils.isArray(rows)) {
|
|
7425
7655
|
rows = [rows]
|
|
7426
7656
|
}
|
|
7427
7657
|
rows.forEach((row: any) => {
|
|
7428
|
-
const rowid =
|
|
7658
|
+
const rowid = handleGetRowId(row)
|
|
7429
7659
|
if (rowid) {
|
|
7430
|
-
if (
|
|
7431
|
-
delete
|
|
7660
|
+
if (pendingRowMaps[rowid]) {
|
|
7661
|
+
delete pendingRowMaps[rowid]
|
|
7432
7662
|
} else {
|
|
7433
|
-
|
|
7663
|
+
pendingRowMaps[rowid] = row
|
|
7434
7664
|
}
|
|
7435
7665
|
}
|
|
7436
7666
|
})
|
|
7437
|
-
reactData.
|
|
7667
|
+
reactData.pendingRowFlag++
|
|
7438
7668
|
return $xeTable.$nextTick()
|
|
7439
7669
|
},
|
|
7440
7670
|
hasPendingByRow (row: any) {
|
|
7441
|
-
const $xeTable = this
|
|
7671
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7442
7672
|
|
|
7443
7673
|
return $xeTable.isPendingByRow(row)
|
|
7444
7674
|
},
|
|
@@ -7451,12 +7681,10 @@ const Methods = {
|
|
|
7451
7681
|
return !!pendingRowMaps[rowid]
|
|
7452
7682
|
},
|
|
7453
7683
|
getPendingRecords () {
|
|
7454
|
-
const $xeTable = this
|
|
7455
|
-
const
|
|
7456
|
-
const internalData = $xeTable
|
|
7684
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7685
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7457
7686
|
|
|
7458
|
-
const { pendingRowMaps } =
|
|
7459
|
-
const { fullAllDataRowIdData } = internalData
|
|
7687
|
+
const { fullAllDataRowIdData, pendingRowMaps } = internalData
|
|
7460
7688
|
const insertRecords: any[] = []
|
|
7461
7689
|
XEUtils.each(pendingRowMaps, (row, rowid) => {
|
|
7462
7690
|
if (fullAllDataRowIdData[rowid]) {
|
|
@@ -7466,11 +7694,16 @@ const Methods = {
|
|
|
7466
7694
|
return insertRecords
|
|
7467
7695
|
},
|
|
7468
7696
|
clearPendingRow () {
|
|
7469
|
-
|
|
7470
|
-
|
|
7697
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7698
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7699
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7700
|
+
|
|
7701
|
+
internalData.pendingRowMaps = {}
|
|
7702
|
+
reactData.pendingRowFlag++
|
|
7703
|
+
return $xeTable.$nextTick()
|
|
7471
7704
|
},
|
|
7472
7705
|
sort (sortConfs: any, sortOrder: any) {
|
|
7473
|
-
const $xeTable = this
|
|
7706
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7474
7707
|
|
|
7475
7708
|
const { sortOpts } = this
|
|
7476
7709
|
const { multiple, remote, orders } = sortOpts
|
|
@@ -7620,7 +7853,10 @@ const Methods = {
|
|
|
7620
7853
|
* @param {Event} evnt 事件
|
|
7621
7854
|
*/
|
|
7622
7855
|
closeFilter () {
|
|
7623
|
-
const
|
|
7856
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7857
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7858
|
+
|
|
7859
|
+
const { filterStore } = reactData
|
|
7624
7860
|
const { column, visible } = filterStore
|
|
7625
7861
|
Object.assign(filterStore, {
|
|
7626
7862
|
isAllSelected: false,
|
|
@@ -7629,9 +7865,15 @@ const Methods = {
|
|
|
7629
7865
|
visible: false
|
|
7630
7866
|
})
|
|
7631
7867
|
if (visible) {
|
|
7632
|
-
|
|
7868
|
+
$xeTable.dispatchEvent('filter-visible', {
|
|
7869
|
+
column,
|
|
7870
|
+
field: column.field,
|
|
7871
|
+
property: column.field,
|
|
7872
|
+
filterList: () => $xeTable.getCheckedFilters(),
|
|
7873
|
+
visible: false
|
|
7874
|
+
}, null)
|
|
7633
7875
|
}
|
|
7634
|
-
return
|
|
7876
|
+
return $xeTable.$nextTick()
|
|
7635
7877
|
},
|
|
7636
7878
|
/**
|
|
7637
7879
|
* 判断指定列是否为筛选状态,如果为空则判断所有列
|
|
@@ -7664,17 +7906,16 @@ const Methods = {
|
|
|
7664
7906
|
const reactData = $xeTable as unknown as TableReactData
|
|
7665
7907
|
const internalData = $xeTable as unknown as TableInternalData
|
|
7666
7908
|
|
|
7667
|
-
const
|
|
7668
|
-
const { fullAllDataRowIdData } = internalData
|
|
7909
|
+
const { fullAllDataRowIdData, rowExpandLazyLoadedMaps } = internalData
|
|
7669
7910
|
const expandOpts = $xeTable.computeExpandOpts
|
|
7670
7911
|
const { lazy } = expandOpts
|
|
7671
7912
|
const rowid = getRowid($xeTable, row)
|
|
7672
7913
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
7673
7914
|
if (lazy && rowRest) {
|
|
7674
7915
|
rowRest.expandLoaded = false
|
|
7675
|
-
delete
|
|
7916
|
+
delete rowExpandLazyLoadedMaps[rowid]
|
|
7676
7917
|
}
|
|
7677
|
-
reactData.
|
|
7918
|
+
reactData.rowExpandedFlag++
|
|
7678
7919
|
return $xeTable.$nextTick()
|
|
7679
7920
|
},
|
|
7680
7921
|
/**
|
|
@@ -7682,14 +7923,18 @@ const Methods = {
|
|
|
7682
7923
|
* @param {Row} row 行对象
|
|
7683
7924
|
*/
|
|
7684
7925
|
reloadRowExpand (row: any) {
|
|
7685
|
-
const
|
|
7926
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7927
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7928
|
+
|
|
7929
|
+
const { rowExpandLazyLoadedMaps } = internalData
|
|
7930
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
7686
7931
|
const { lazy } = expandOpts
|
|
7687
7932
|
const rowid = getRowid(this, row)
|
|
7688
7933
|
if (lazy && !rowExpandLazyLoadedMaps[rowid]) {
|
|
7689
|
-
|
|
7690
|
-
.then(() =>
|
|
7934
|
+
$xeTable.clearRowExpandLoaded(row)
|
|
7935
|
+
.then(() => handleAsyncRowExpand($xeTable, row))
|
|
7691
7936
|
}
|
|
7692
|
-
return
|
|
7937
|
+
return $xeTable.$nextTick()
|
|
7693
7938
|
},
|
|
7694
7939
|
reloadExpandContent (row: any) {
|
|
7695
7940
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -7702,20 +7947,34 @@ const Methods = {
|
|
|
7702
7947
|
* 展开行事件
|
|
7703
7948
|
*/
|
|
7704
7949
|
triggerRowExpandEvent (evnt: any, params: any) {
|
|
7705
|
-
const
|
|
7950
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7951
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7952
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7953
|
+
|
|
7954
|
+
const { expandColumn: column } = reactData
|
|
7955
|
+
const { rowExpandLazyLoadedMaps } = internalData
|
|
7956
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
7706
7957
|
const { row } = params
|
|
7707
7958
|
const { lazy, trigger } = expandOpts
|
|
7708
7959
|
if (trigger === 'manual') {
|
|
7709
7960
|
return
|
|
7710
7961
|
}
|
|
7711
7962
|
evnt.stopPropagation()
|
|
7712
|
-
const rowid = getRowid(
|
|
7963
|
+
const rowid = getRowid($xeTable, row)
|
|
7713
7964
|
if (!lazy || !rowExpandLazyLoadedMaps[rowid]) {
|
|
7714
|
-
const expanded =
|
|
7715
|
-
const columnIndex =
|
|
7716
|
-
const $columnIndex =
|
|
7717
|
-
|
|
7718
|
-
|
|
7965
|
+
const expanded = !$xeTable.isRowExpandByRow(row)
|
|
7966
|
+
const columnIndex = $xeTable.getColumnIndex(column)
|
|
7967
|
+
const $columnIndex = $xeTable.getVMColumnIndex(column)
|
|
7968
|
+
$xeTable.setRowExpand(row, expanded)
|
|
7969
|
+
$xeTable.dispatchEvent('toggle-row-expand', {
|
|
7970
|
+
expanded,
|
|
7971
|
+
column,
|
|
7972
|
+
columnIndex,
|
|
7973
|
+
$columnIndex,
|
|
7974
|
+
row,
|
|
7975
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
7976
|
+
$rowIndex: $xeTable.getVMRowIndex(row)
|
|
7977
|
+
}, evnt)
|
|
7719
7978
|
}
|
|
7720
7979
|
},
|
|
7721
7980
|
/**
|
|
@@ -7724,24 +7983,6 @@ const Methods = {
|
|
|
7724
7983
|
toggleRowExpand (row: any) {
|
|
7725
7984
|
return this.setRowExpand(row, !this.isRowExpandByRow(row))
|
|
7726
7985
|
},
|
|
7727
|
-
/**
|
|
7728
|
-
* 处理默认展开行
|
|
7729
|
-
*/
|
|
7730
|
-
handleDefaultRowExpand () {
|
|
7731
|
-
const { expandOpts, fullDataRowIdData } = this
|
|
7732
|
-
const { expandAll, expandRowKeys } = expandOpts
|
|
7733
|
-
if (expandAll) {
|
|
7734
|
-
this.setAllRowExpand(true)
|
|
7735
|
-
} else if (expandRowKeys) {
|
|
7736
|
-
const defExpandeds: any[] = []
|
|
7737
|
-
expandRowKeys.forEach((rowid: any) => {
|
|
7738
|
-
if (fullDataRowIdData[rowid]) {
|
|
7739
|
-
defExpandeds.push(fullDataRowIdData[rowid].row)
|
|
7740
|
-
}
|
|
7741
|
-
})
|
|
7742
|
-
this.setRowExpand(defExpandeds, true)
|
|
7743
|
-
}
|
|
7744
|
-
},
|
|
7745
7986
|
/**
|
|
7746
7987
|
* 设置所有行的展开与否
|
|
7747
7988
|
* @param {Boolean} expanded 是否展开
|
|
@@ -7759,48 +8000,6 @@ const Methods = {
|
|
|
7759
8000
|
}
|
|
7760
8001
|
return this.setRowExpand(expandedRows, expanded)
|
|
7761
8002
|
},
|
|
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
8003
|
/**
|
|
7805
8004
|
* 设置展开行,二个参数设置这一行展开与否
|
|
7806
8005
|
* 支持单行
|
|
@@ -7809,10 +8008,14 @@ const Methods = {
|
|
|
7809
8008
|
* @param {Boolean} expanded 是否展开
|
|
7810
8009
|
*/
|
|
7811
8010
|
setRowExpand (rows: any, expanded: any) {
|
|
7812
|
-
const $xeTable = this
|
|
8011
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8012
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
8013
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7813
8014
|
|
|
7814
|
-
const {
|
|
7815
|
-
let
|
|
8015
|
+
const { expandColumn } = reactData
|
|
8016
|
+
let { fullAllDataRowIdData, rowExpandedMaps, rowExpandLazyLoadedMaps } = internalData
|
|
8017
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
8018
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
7816
8019
|
const { reserve, lazy, accordion, toggleMethod } = expandOpts
|
|
7817
8020
|
const lazyRests: any[] = []
|
|
7818
8021
|
const columnIndex = $xeTable.getColumnIndex(expandColumn)
|
|
@@ -7823,28 +8026,29 @@ const Methods = {
|
|
|
7823
8026
|
}
|
|
7824
8027
|
if (accordion) {
|
|
7825
8028
|
// 只能同时展开一个
|
|
7826
|
-
|
|
8029
|
+
rowExpandedMaps = {}
|
|
8030
|
+
internalData.rowExpandedMaps = rowExpandedMaps
|
|
7827
8031
|
rows = rows.slice(rows.length - 1, rows.length)
|
|
7828
8032
|
}
|
|
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
|
|
8033
|
+
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
8034
|
if (expanded) {
|
|
7831
8035
|
validRows.forEach((row: any) => {
|
|
7832
|
-
const rowid =
|
|
7833
|
-
if (!
|
|
8036
|
+
const rowid = handleGetRowId(row)
|
|
8037
|
+
if (!rowExpandedMaps[rowid]) {
|
|
7834
8038
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
7835
8039
|
const isLoad = lazy && !rowRest.expandLoaded && !rowExpandLazyLoadedMaps[rowid]
|
|
7836
8040
|
if (isLoad) {
|
|
7837
|
-
lazyRests.push(
|
|
8041
|
+
lazyRests.push(handleAsyncRowExpand($xeTable, row))
|
|
7838
8042
|
} else {
|
|
7839
|
-
|
|
8043
|
+
rowExpandedMaps[rowid] = row
|
|
7840
8044
|
}
|
|
7841
8045
|
}
|
|
7842
8046
|
})
|
|
7843
8047
|
} else {
|
|
7844
8048
|
validRows.forEach((item) => {
|
|
7845
|
-
const rowid =
|
|
7846
|
-
if (
|
|
7847
|
-
delete
|
|
8049
|
+
const rowid = handleGetRowId(item)
|
|
8050
|
+
if (rowExpandedMaps[rowid]) {
|
|
8051
|
+
delete rowExpandedMaps[rowid]
|
|
7848
8052
|
}
|
|
7849
8053
|
})
|
|
7850
8054
|
}
|
|
@@ -7852,7 +8056,7 @@ const Methods = {
|
|
|
7852
8056
|
validRows.forEach((row) => handleRowExpandReserve($xeTable, row, expanded))
|
|
7853
8057
|
}
|
|
7854
8058
|
}
|
|
7855
|
-
|
|
8059
|
+
reactData.rowExpandedFlag++
|
|
7856
8060
|
return Promise.all(lazyRests)
|
|
7857
8061
|
.then(() => $xeTable.$nextTick())
|
|
7858
8062
|
.then(() => $xeTable.recalculate(true))
|
|
@@ -7868,9 +8072,14 @@ const Methods = {
|
|
|
7868
8072
|
* @param {Row} row 行对象
|
|
7869
8073
|
*/
|
|
7870
8074
|
isRowExpandByRow (row: any) {
|
|
7871
|
-
const
|
|
8075
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8076
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
8077
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8078
|
+
|
|
8079
|
+
const { rowExpandedFlag } = reactData
|
|
8080
|
+
const { rowExpandedMaps } = internalData
|
|
7872
8081
|
const rowid = getRowid(this, row)
|
|
7873
|
-
return !!rowExpandedMaps[rowid]
|
|
8082
|
+
return !!rowExpandedFlag && !!rowExpandedMaps[rowid]
|
|
7874
8083
|
},
|
|
7875
8084
|
isExpandByRow (row: any) {
|
|
7876
8085
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -7891,7 +8100,8 @@ const Methods = {
|
|
|
7891
8100
|
const expandOpts = $xeTable.computeExpandOpts
|
|
7892
8101
|
const { reserve } = expandOpts
|
|
7893
8102
|
const expList = $xeTable.getRowExpandRecords()
|
|
7894
|
-
|
|
8103
|
+
internalData.rowExpandedMaps = {}
|
|
8104
|
+
reactData.rowExpandedFlag++
|
|
7895
8105
|
if (reserve) {
|
|
7896
8106
|
tableFullData.forEach((row) => handleRowExpandReserve($xeTable, row, false))
|
|
7897
8107
|
}
|
|
@@ -7911,8 +8121,11 @@ const Methods = {
|
|
|
7911
8121
|
return this.$nextTick()
|
|
7912
8122
|
},
|
|
7913
8123
|
getRowExpandRecords () {
|
|
8124
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8125
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8126
|
+
|
|
7914
8127
|
const rest: any[] = []
|
|
7915
|
-
XEUtils.each(
|
|
8128
|
+
XEUtils.each(internalData.rowExpandedMaps, item => {
|
|
7916
8129
|
if (item) {
|
|
7917
8130
|
rest.push(item)
|
|
7918
8131
|
}
|
|
@@ -7920,8 +8133,11 @@ const Methods = {
|
|
|
7920
8133
|
return rest
|
|
7921
8134
|
},
|
|
7922
8135
|
getTreeExpandRecords () {
|
|
8136
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8137
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8138
|
+
|
|
7923
8139
|
const rest: any[] = []
|
|
7924
|
-
XEUtils.each(
|
|
8140
|
+
XEUtils.each(internalData.treeExpandedMaps, item => {
|
|
7925
8141
|
if (item) {
|
|
7926
8142
|
rest.push(item)
|
|
7927
8143
|
}
|
|
@@ -7956,12 +8172,10 @@ const Methods = {
|
|
|
7956
8172
|
const reactData = $xeTable as unknown as TableReactData
|
|
7957
8173
|
const internalData = $xeTable as unknown as TableInternalData
|
|
7958
8174
|
|
|
7959
|
-
const { fullAllDataRowIdData } = internalData
|
|
8175
|
+
const { fullAllDataRowIdData, treeExpandedMaps } = internalData
|
|
7960
8176
|
const treeOpts = $xeTable.computeTreeOpts
|
|
7961
8177
|
const { transform } = treeOpts
|
|
7962
|
-
let tExpandedMaps: Record<string, any> = {}
|
|
7963
8178
|
if (rows) {
|
|
7964
|
-
tExpandedMaps = { ...reactData.treeExpandedMaps }
|
|
7965
8179
|
if (!XEUtils.isArray(rows)) {
|
|
7966
8180
|
rows = [rows]
|
|
7967
8181
|
}
|
|
@@ -7970,8 +8184,8 @@ const Methods = {
|
|
|
7970
8184
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
7971
8185
|
if (rowRest) {
|
|
7972
8186
|
rowRest.treeLoaded = false
|
|
7973
|
-
if (
|
|
7974
|
-
delete
|
|
8187
|
+
if (treeExpandedMaps[rowid]) {
|
|
8188
|
+
delete treeExpandedMaps[rowid]
|
|
7975
8189
|
}
|
|
7976
8190
|
}
|
|
7977
8191
|
})
|
|
@@ -7980,7 +8194,8 @@ const Methods = {
|
|
|
7980
8194
|
rowRest.treeLoaded = false
|
|
7981
8195
|
})
|
|
7982
8196
|
}
|
|
7983
|
-
|
|
8197
|
+
internalData.treeExpandedMaps = {}
|
|
8198
|
+
reactData.treeExpandedFlag++
|
|
7984
8199
|
if (transform) {
|
|
7985
8200
|
handleVirtualTreeToList($xeTable)
|
|
7986
8201
|
return $xeTable.handleTableData()
|
|
@@ -7993,37 +8208,45 @@ const Methods = {
|
|
|
7993
8208
|
*/
|
|
7994
8209
|
reloadTreeExpand (row: any) {
|
|
7995
8210
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8211
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7996
8212
|
|
|
7997
|
-
const {
|
|
8213
|
+
const { treeExpandLazyLoadedMaps } = internalData
|
|
8214
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
7998
8215
|
const { transform, lazy } = treeOpts
|
|
7999
8216
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
8000
|
-
const rowid = getRowid(
|
|
8217
|
+
const rowid = getRowid($xeTable, row)
|
|
8001
8218
|
if (lazy && row[hasChildField] && !treeExpandLazyLoadedMaps[rowid]) {
|
|
8002
|
-
return
|
|
8003
|
-
return
|
|
8219
|
+
return $xeTable.clearTreeExpandLoaded(row).then(() => {
|
|
8220
|
+
return handleAsyncTreeExpandChilds($xeTable, row)
|
|
8004
8221
|
}).then(() => {
|
|
8005
8222
|
if (transform) {
|
|
8006
8223
|
handleVirtualTreeToList($xeTable)
|
|
8007
|
-
return
|
|
8224
|
+
return $xeTable.handleTableData()
|
|
8008
8225
|
}
|
|
8009
8226
|
}).then(() => {
|
|
8010
|
-
return
|
|
8227
|
+
return $xeTable.recalculate()
|
|
8011
8228
|
})
|
|
8012
8229
|
}
|
|
8013
|
-
return
|
|
8230
|
+
return $xeTable.$nextTick()
|
|
8014
8231
|
},
|
|
8015
8232
|
reloadTreeChilds (row: any) {
|
|
8233
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8234
|
+
|
|
8016
8235
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
8017
8236
|
warnLog('vxe.error.delFunc', ['reloadTreeChilds', 'reloadTreeExpand'])
|
|
8018
8237
|
}
|
|
8019
8238
|
// 即将废弃
|
|
8020
|
-
return
|
|
8239
|
+
return $xeTable.reloadTreeExpand(row)
|
|
8021
8240
|
},
|
|
8022
8241
|
/**
|
|
8023
8242
|
* 展开树节点事件
|
|
8024
8243
|
*/
|
|
8025
8244
|
triggerTreeExpandEvent (evnt: any, params: any) {
|
|
8026
|
-
const
|
|
8245
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8246
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8247
|
+
|
|
8248
|
+
const { treeExpandLazyLoadedMaps } = internalData
|
|
8249
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
8027
8250
|
const { row, column } = params
|
|
8028
8251
|
const { lazy, trigger } = treeOpts
|
|
8029
8252
|
if (trigger === 'manual') {
|
|
@@ -8032,11 +8255,11 @@ const Methods = {
|
|
|
8032
8255
|
evnt.stopPropagation()
|
|
8033
8256
|
const rowid = getRowid(this, row)
|
|
8034
8257
|
if (!lazy || !treeExpandLazyLoadedMaps[rowid]) {
|
|
8035
|
-
const expanded =
|
|
8036
|
-
const columnIndex =
|
|
8037
|
-
const $columnIndex =
|
|
8038
|
-
|
|
8039
|
-
|
|
8258
|
+
const expanded = !$xeTable.isTreeExpandByRow(row)
|
|
8259
|
+
const columnIndex = $xeTable.getColumnIndex(column)
|
|
8260
|
+
const $columnIndex = $xeTable.getVMColumnIndex(column)
|
|
8261
|
+
$xeTable.setTreeExpand(row, expanded)
|
|
8262
|
+
$xeTable.dispatchEvent('toggle-tree-expand', { expanded, column, columnIndex, $columnIndex, row }, evnt)
|
|
8040
8263
|
}
|
|
8041
8264
|
},
|
|
8042
8265
|
/**
|
|
@@ -8045,88 +8268,6 @@ const Methods = {
|
|
|
8045
8268
|
toggleTreeExpand (row: any) {
|
|
8046
8269
|
return this.setTreeExpand(row, !this.isTreeExpandByRow(row))
|
|
8047
8270
|
},
|
|
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
8271
|
/**
|
|
8131
8272
|
* 设置所有树节点的展开与否
|
|
8132
8273
|
* @param {Boolean} expanded 是否展开
|
|
@@ -8151,41 +8292,47 @@ const Methods = {
|
|
|
8151
8292
|
* @returns
|
|
8152
8293
|
*/
|
|
8153
8294
|
handleBaseTreeExpand (rows: any, expanded: any) {
|
|
8154
|
-
const
|
|
8295
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8296
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
8297
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8298
|
+
|
|
8299
|
+
const { treeNodeColumn } = reactData
|
|
8300
|
+
const { fullAllDataRowIdData, tableFullData, treeExpandedMaps, treeExpandLazyLoadedMaps } = internalData
|
|
8301
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
8155
8302
|
const { reserve, lazy, accordion, toggleMethod } = treeOpts
|
|
8156
|
-
const treeTempExpandedMaps = { ...treeExpandedMaps }
|
|
8157
8303
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
8158
8304
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
8159
8305
|
const result: any[] = []
|
|
8160
|
-
const columnIndex =
|
|
8161
|
-
const $columnIndex =
|
|
8162
|
-
|
|
8306
|
+
const columnIndex = $xeTable.getColumnIndex(treeNodeColumn)
|
|
8307
|
+
const $columnIndex = $xeTable.getVMColumnIndex(treeNodeColumn)
|
|
8308
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
8309
|
+
let validRows = toggleMethod ? rows.filter((row: any) => toggleMethod({ $table: $xeTable, expanded, column: treeNodeColumn, columnIndex, $columnIndex, row })) : rows
|
|
8163
8310
|
if (accordion) {
|
|
8164
8311
|
validRows = validRows.length ? [validRows[validRows.length - 1]] : []
|
|
8165
8312
|
// 同一级只能展开一个
|
|
8166
8313
|
const matchObj = XEUtils.findTree(tableFullData, item => item === validRows[0], { children: childrenField })
|
|
8167
8314
|
if (matchObj) {
|
|
8168
8315
|
matchObj.items.forEach(item => {
|
|
8169
|
-
const rowid =
|
|
8170
|
-
if (
|
|
8171
|
-
delete
|
|
8316
|
+
const rowid = handleGetRowId(item)
|
|
8317
|
+
if (treeExpandedMaps[rowid]) {
|
|
8318
|
+
delete treeExpandedMaps[rowid]
|
|
8172
8319
|
}
|
|
8173
8320
|
})
|
|
8174
8321
|
}
|
|
8175
8322
|
}
|
|
8176
8323
|
if (expanded) {
|
|
8177
8324
|
validRows.forEach((row: any) => {
|
|
8178
|
-
const rowid =
|
|
8179
|
-
if (!
|
|
8325
|
+
const rowid = handleGetRowId(row)
|
|
8326
|
+
if (!treeExpandedMaps[rowid]) {
|
|
8180
8327
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
8181
8328
|
if (rowRest) {
|
|
8182
8329
|
const isLoad = lazy && row[hasChildField] && !rowRest.treeLoaded && !treeExpandLazyLoadedMaps[rowid]
|
|
8183
8330
|
// 是否使用懒加载
|
|
8184
8331
|
if (isLoad) {
|
|
8185
|
-
result.push(
|
|
8332
|
+
result.push(handleAsyncTreeExpandChilds($xeTable, row))
|
|
8186
8333
|
} else {
|
|
8187
8334
|
if (row[childrenField] && row[childrenField].length) {
|
|
8188
|
-
|
|
8335
|
+
treeExpandedMaps[rowid] = row
|
|
8189
8336
|
}
|
|
8190
8337
|
}
|
|
8191
8338
|
}
|
|
@@ -8193,18 +8340,18 @@ const Methods = {
|
|
|
8193
8340
|
})
|
|
8194
8341
|
} else {
|
|
8195
8342
|
validRows.forEach((item: any) => {
|
|
8196
|
-
const rowid =
|
|
8197
|
-
if (
|
|
8198
|
-
delete
|
|
8343
|
+
const rowid = handleGetRowId(item)
|
|
8344
|
+
if (treeExpandedMaps[rowid]) {
|
|
8345
|
+
delete treeExpandedMaps[rowid]
|
|
8199
8346
|
}
|
|
8200
8347
|
})
|
|
8201
8348
|
}
|
|
8202
8349
|
if (reserve) {
|
|
8203
|
-
validRows.forEach((row: any) =>
|
|
8350
|
+
validRows.forEach((row: any) => handleTreeExpandReserve($xeTable, row, expanded))
|
|
8204
8351
|
}
|
|
8205
|
-
|
|
8352
|
+
reactData.treeExpandedFlag++
|
|
8206
8353
|
return Promise.all(result).then(() => {
|
|
8207
|
-
return
|
|
8354
|
+
return $xeTable.recalculate()
|
|
8208
8355
|
})
|
|
8209
8356
|
},
|
|
8210
8357
|
/**
|
|
@@ -8258,31 +8405,40 @@ const Methods = {
|
|
|
8258
8405
|
* @param {Row} row 行对象
|
|
8259
8406
|
*/
|
|
8260
8407
|
isTreeExpandByRow (row: any) {
|
|
8261
|
-
const
|
|
8262
|
-
|
|
8408
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8409
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
8410
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8411
|
+
|
|
8412
|
+
const { treeExpandedFlag } = reactData
|
|
8413
|
+
const { treeExpandedMaps } = internalData
|
|
8414
|
+
return !!treeExpandedFlag && !!treeExpandedMaps[getRowid($xeTable, row)]
|
|
8263
8415
|
},
|
|
8264
8416
|
/**
|
|
8265
8417
|
* 手动清空树形节点的展开状态,数据会恢复成未展开的状态
|
|
8266
8418
|
*/
|
|
8267
8419
|
clearTreeExpand () {
|
|
8268
8420
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8421
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
8422
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8269
8423
|
|
|
8270
|
-
const {
|
|
8271
|
-
const
|
|
8424
|
+
const { tableFullTreeData } = internalData
|
|
8425
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
8272
8426
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
8273
|
-
const
|
|
8274
|
-
|
|
8427
|
+
const { transform, reserve } = treeOpts
|
|
8428
|
+
const expList = $xeTable.getTreeExpandRecords()
|
|
8429
|
+
internalData.treeExpandedMaps = {}
|
|
8430
|
+
reactData.treeExpandedFlag++
|
|
8275
8431
|
if (reserve) {
|
|
8276
|
-
XEUtils.eachTree(
|
|
8432
|
+
XEUtils.eachTree(tableFullTreeData, row => handleTreeExpandReserve($xeTable, row, false), { children: childrenField })
|
|
8277
8433
|
}
|
|
8278
|
-
return
|
|
8434
|
+
return $xeTable.handleTableData().then(() => {
|
|
8279
8435
|
if (transform) {
|
|
8280
8436
|
handleVirtualTreeToList($xeTable)
|
|
8281
|
-
return
|
|
8437
|
+
return $xeTable.handleTableData()
|
|
8282
8438
|
}
|
|
8283
8439
|
}).then(() => {
|
|
8284
8440
|
if (expList.length) {
|
|
8285
|
-
|
|
8441
|
+
$xeTable.recalculate()
|
|
8286
8442
|
}
|
|
8287
8443
|
})
|
|
8288
8444
|
},
|
|
@@ -8290,17 +8446,6 @@ const Methods = {
|
|
|
8290
8446
|
this.treeExpandedReserveRowMap = {}
|
|
8291
8447
|
return this.$nextTick()
|
|
8292
8448
|
},
|
|
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
8449
|
/**
|
|
8305
8450
|
* 获取表格的滚动状态
|
|
8306
8451
|
*/
|
|
@@ -8428,8 +8573,8 @@ const Methods = {
|
|
|
8428
8573
|
triggerScrollXEvent () {
|
|
8429
8574
|
const $xeTable = this
|
|
8430
8575
|
|
|
8431
|
-
const
|
|
8432
|
-
if (
|
|
8576
|
+
const virtualXOpts = $xeTable.computeVirtualXOpts
|
|
8577
|
+
if (virtualXOpts.immediate) {
|
|
8433
8578
|
loadScrollXData($xeTable)
|
|
8434
8579
|
} else {
|
|
8435
8580
|
lazyScrollXData($xeTable)
|
|
@@ -8441,8 +8586,8 @@ const Methods = {
|
|
|
8441
8586
|
triggerScrollYEvent () {
|
|
8442
8587
|
const $xeTable = this
|
|
8443
8588
|
|
|
8444
|
-
const
|
|
8445
|
-
if (
|
|
8589
|
+
const virtualYOpts = $xeTable.computeVirtualYOpts
|
|
8590
|
+
if (virtualYOpts.immediate) {
|
|
8446
8591
|
loadScrollYData($xeTable)
|
|
8447
8592
|
} else {
|
|
8448
8593
|
lazyScrollYData($xeTable)
|
|
@@ -8625,10 +8770,10 @@ const Methods = {
|
|
|
8625
8770
|
}
|
|
8626
8771
|
|
|
8627
8772
|
const { highlightHoverRow } = tableProps
|
|
8628
|
-
const { scrollXLoad, scrollYLoad } = reactData
|
|
8773
|
+
const { scrollXLoad, scrollYLoad, expandColumn } = reactData
|
|
8629
8774
|
const leftFixedWidth = $xeTable.computeLeftFixedWidth
|
|
8630
8775
|
const rightFixedWidth = $xeTable.computeRightFixedWidth
|
|
8631
|
-
if (!(
|
|
8776
|
+
if (!(leftFixedWidth || rightFixedWidth || expandColumn)) {
|
|
8632
8777
|
return
|
|
8633
8778
|
}
|
|
8634
8779
|
|
|
@@ -8653,8 +8798,8 @@ const Methods = {
|
|
|
8653
8798
|
}
|
|
8654
8799
|
|
|
8655
8800
|
const wheelSpeed = getWheelSpeed(reactData.lastScrollTime)
|
|
8656
|
-
const deltaTop =
|
|
8657
|
-
const deltaLeft = Math.ceil((shiftKey ? deltaY : deltaX) * wheelSpeed)
|
|
8801
|
+
const deltaTop = shiftKey ? 0 : Math.ceil(deltaY * wheelSpeed)
|
|
8802
|
+
const deltaLeft = Math.ceil((shiftKey ? (deltaY || deltaX) : deltaX) * wheelSpeed)
|
|
8658
8803
|
|
|
8659
8804
|
const isTopWheel = deltaTop < 0
|
|
8660
8805
|
const currScrollTop = bodyScrollElem.scrollTop
|
|
@@ -8897,8 +9042,8 @@ const Methods = {
|
|
|
8897
9042
|
const reactData = $xeTable as unknown as TableReactData
|
|
8898
9043
|
const internalData = $xeTable as unknown as TableInternalData
|
|
8899
9044
|
|
|
8900
|
-
const { isAllOverflow, scrollYLoad, expandColumn
|
|
8901
|
-
const { scrollYStore, elemStore, isResizeCellHeight, afterFullData, fullAllDataRowIdData } = internalData
|
|
9045
|
+
const { isAllOverflow, scrollYLoad, expandColumn } = reactData
|
|
9046
|
+
const { scrollYStore, elemStore, isResizeCellHeight, afterFullData, fullAllDataRowIdData, rowExpandedMaps } = internalData
|
|
8902
9047
|
const { startIndex } = scrollYStore
|
|
8903
9048
|
const expandOpts = $xeTable.computeExpandOpts
|
|
8904
9049
|
const rowOpts = $xeTable.computeRowOpts
|
|
@@ -9145,12 +9290,15 @@ const Methods = {
|
|
|
9145
9290
|
* 更新表尾合计
|
|
9146
9291
|
*/
|
|
9147
9292
|
updateFooter () {
|
|
9293
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
9294
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
9295
|
+
|
|
9148
9296
|
const { showFooter, visibleColumn, footerData, footerMethod } = this
|
|
9149
9297
|
let footData = []
|
|
9150
9298
|
if (showFooter && footerData && footerData.length) {
|
|
9151
9299
|
footData = footerData.slice(0)
|
|
9152
9300
|
} else if (showFooter && footerMethod) {
|
|
9153
|
-
footData = visibleColumn.length ? footerMethod({ columns: visibleColumn, data: this.afterFullData, $table:
|
|
9301
|
+
footData = visibleColumn.length ? footerMethod({ columns: visibleColumn, data: this.afterFullData, $table: $xeTable, $grid: $xeGrid }) : []
|
|
9154
9302
|
}
|
|
9155
9303
|
this.footerTableData = footData
|
|
9156
9304
|
return this.$nextTick()
|
|
@@ -9171,9 +9319,6 @@ const Methods = {
|
|
|
9171
9319
|
}
|
|
9172
9320
|
})
|
|
9173
9321
|
},
|
|
9174
|
-
handleDefaultMergeCells () {
|
|
9175
|
-
this.setMergeCells(this.mergeCells)
|
|
9176
|
-
},
|
|
9177
9322
|
/**
|
|
9178
9323
|
* 设置合并单元格
|
|
9179
9324
|
* @param {TableMergeConfig[]} merges { row: Row|number, column: ColumnInfo|number, rowspan: number, colspan: number }
|
|
@@ -9224,16 +9369,13 @@ const Methods = {
|
|
|
9224
9369
|
return updateStyle($xeTable)
|
|
9225
9370
|
})
|
|
9226
9371
|
},
|
|
9227
|
-
handleDefaultMergeFooterItems () {
|
|
9228
|
-
this.setMergeFooterItems(this.mergeFooterItems)
|
|
9229
|
-
},
|
|
9230
9372
|
setMergeFooterItems (merges: any) {
|
|
9231
9373
|
const $xeTable = this
|
|
9232
9374
|
|
|
9233
9375
|
if (this.footerSpanMethod) {
|
|
9234
9376
|
errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method'])
|
|
9235
9377
|
}
|
|
9236
|
-
setMerges(this, merges, this.mergeFooterList
|
|
9378
|
+
setMerges(this, merges, this.mergeFooterList)
|
|
9237
9379
|
return this.$nextTick().then(() => {
|
|
9238
9380
|
this.updateCellAreas()
|
|
9239
9381
|
return updateStyle($xeTable)
|
|
@@ -9288,12 +9430,17 @@ const Methods = {
|
|
|
9288
9430
|
return $xeTable.$nextTick()
|
|
9289
9431
|
},
|
|
9290
9432
|
dispatchEvent (type: ValueOf<VxeTableEmits>, params: Record<string, any>, evnt: Event | null) {
|
|
9291
|
-
const $xeTable = this
|
|
9292
|
-
|
|
9433
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
9434
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
9435
|
+
|
|
9436
|
+
$xeTable.$emit(type, createEvent(evnt, { $table: $xeTable, $grid: $xeGrid }, params))
|
|
9293
9437
|
},
|
|
9294
9438
|
// 已废弃,使用 dispatchEvent
|
|
9295
9439
|
emitEvent (type: any, params: any, evnt: any) {
|
|
9296
|
-
|
|
9440
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
9441
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
9442
|
+
|
|
9443
|
+
this.$emit(type, Object.assign({ $table: $xeTable, $grid: $xeGrid, $event: evnt }, params))
|
|
9297
9444
|
},
|
|
9298
9445
|
focus () {
|
|
9299
9446
|
this.isActivated = true
|