vxe-table 3.14.0-beta.2 → 3.14.0-beta.21
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 +78 -48
- 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/edit/mixin.js +14 -9
- package/es/table/module/filter/panel.js +12 -2
- package/es/table/module/keyboard/mixin.js +86 -21
- package/es/table/module/validator/mixin.js +2 -2
- package/es/table/render/index.js +90 -59
- package/es/table/src/body.js +22 -17
- package/es/table/src/cell.js +25 -20
- package/es/table/src/footer.js +9 -4
- package/es/table/src/header.js +2 -2
- package/es/table/src/methods.js +942 -678
- package/es/table/src/props.js +4 -0
- package/es/table/src/table.js +74 -32
- package/es/table/src/util.js +65 -7
- package/es/ui/index.js +1 -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 +85 -65
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/index.umd.js +1641 -1076
- 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/edit/mixin.js +16 -11
- package/lib/table/module/edit/mixin.min.js +1 -1
- package/lib/table/module/filter/panel.js +8 -2
- package/lib/table/module/filter/panel.min.js +1 -1
- package/lib/table/module/keyboard/mixin.js +89 -25
- package/lib/table/module/keyboard/mixin.min.js +1 -1
- package/lib/table/module/validator/mixin.js +3 -3
- package/lib/table/module/validator/mixin.min.js +1 -1
- package/lib/table/render/index.js +99 -64
- package/lib/table/render/index.min.js +1 -1
- package/lib/table/src/body.js +27 -17
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +37 -21
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/footer.js +9 -3
- package/lib/table/src/footer.min.js +1 -1
- package/lib/table/src/header.js +2 -1
- package/lib/table/src/header.min.js +1 -1
- package/lib/table/src/methods.js +1101 -798
- 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 +79 -31
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/src/util.js +72 -7
- package/lib/table/src/util.min.js +1 -1
- package/lib/ui/index.js +1 -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 +92 -57
- 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/edit/mixin.ts +17 -12
- package/packages/table/module/filter/panel.ts +12 -2
- package/packages/table/module/keyboard/mixin.ts +94 -27
- package/packages/table/module/validator/mixin.ts +2 -2
- package/packages/table/render/index.ts +89 -57
- package/packages/table/src/body.ts +21 -16
- package/packages/table/src/cell.ts +25 -20
- package/packages/table/src/footer.ts +9 -4
- package/packages/table/src/header.ts +2 -2
- package/packages/table/src/methods.ts +1035 -720
- package/packages/table/src/props.ts +16 -12
- package/packages/table/src/table.ts +87 -35
- package/packages/table/src/util.ts +73 -7
- /package/es/{iconfont.1741079977180.ttf → iconfont.1742437924038.ttf} +0 -0
- /package/es/{iconfont.1741079977180.woff → iconfont.1742437924038.woff} +0 -0
- /package/es/{iconfont.1741079977180.woff2 → iconfont.1742437924038.woff2} +0 -0
- /package/lib/{iconfont.1741079977180.ttf → iconfont.1742437924038.ttf} +0 -0
- /package/lib/{iconfont.1741079977180.woff → iconfont.1742437924038.woff} +0 -0
- /package/lib/{iconfont.1741079977180.woff2 → iconfont.1742437924038.woff2} +0 -0
|
@@ -3,14 +3,15 @@ import { browse, getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEv
|
|
|
3
3
|
import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils'
|
|
4
4
|
import { VxeUI } from '../../ui'
|
|
5
5
|
import Cell from './cell'
|
|
6
|
-
import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, getRefElem } from './util'
|
|
6
|
+
import { getRowUniqueId, clearTableAllStatus, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getRefElem } from './util'
|
|
7
7
|
import { getSlotVNs } from '../../ui/src/vn'
|
|
8
8
|
import { warnLog, errLog } from '../../ui/src/log'
|
|
9
9
|
|
|
10
|
-
import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, ValueOf, TableReactData, VxeTableConstructor, VxeToolbarConstructor, TableInternalData, VxeTablePrivateMethods, VxeTooltipInstance, VxeTablePropTypes } from '../../../types'
|
|
10
|
+
import type { VxeTableDefines, VxeColumnPropTypes, VxeTableEmits, ValueOf, TableReactData, VxeTableConstructor, VxeToolbarConstructor, TableInternalData, VxeGridConstructor, GridPrivateMethods, VxeTablePrivateMethods, VxeTooltipInstance, VxeTablePropTypes } from '../../../types'
|
|
11
11
|
|
|
12
12
|
const { getConfig, getI18n, renderer, formats, interceptor, createEvent } = VxeUI
|
|
13
13
|
|
|
14
|
+
const supportMaxRow = 5e6
|
|
14
15
|
const customStorageKey = 'VXE_CUSTOM_STORE'
|
|
15
16
|
const maxYHeight = 5e6
|
|
16
17
|
const maxXWidth = 5e6
|
|
@@ -236,7 +237,7 @@ function cacheColumnMap ($xeTable: VxeTableConstructor) {
|
|
|
236
237
|
fullColumnFieldData[field] = rest
|
|
237
238
|
} else {
|
|
238
239
|
if ((storage && !type) || (columnOpts.drag && (isCrossDrag || isSelfToChildDrag))) {
|
|
239
|
-
errLog('vxe.error.reqProp', [`${column.getTitle() || type || ''} -> column.field
|
|
240
|
+
errLog('vxe.error.reqProp', [`${column.getTitle() || type || ''} -> column.field=?`])
|
|
240
241
|
}
|
|
241
242
|
}
|
|
242
243
|
if (!hasFixed && fixed) {
|
|
@@ -340,9 +341,10 @@ function updateAfterListIndex ($xeTable: VxeTableConstructor) {
|
|
|
340
341
|
|
|
341
342
|
const { treeConfig } = props
|
|
342
343
|
const { afterFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData
|
|
344
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
343
345
|
const fullMaps: Record<string, any> = {}
|
|
344
346
|
afterFullData.forEach((row, index) => {
|
|
345
|
-
const rowid =
|
|
347
|
+
const rowid = handleGetRowId(row)
|
|
346
348
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
347
349
|
const seq = index + 1
|
|
348
350
|
if (rowRest) {
|
|
@@ -375,8 +377,9 @@ function updateAfterDataIndex ($xeTable: VxeTableConstructor) {
|
|
|
375
377
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
376
378
|
const fullMaps: Record<string, any> = {}
|
|
377
379
|
if (treeConfig) {
|
|
380
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
378
381
|
XEUtils.eachTree(afterTreeFullData, (row, index, items, path) => {
|
|
379
|
-
const rowid =
|
|
382
|
+
const rowid = handleGetRowId(row)
|
|
380
383
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
381
384
|
const seq = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
|
|
382
385
|
if (rowRest) {
|
|
@@ -402,22 +405,21 @@ function updateAfterDataIndex ($xeTable: VxeTableConstructor) {
|
|
|
402
405
|
*/
|
|
403
406
|
function handleVirtualTreeToList ($xeTable: VxeTableConstructor) {
|
|
404
407
|
const props = $xeTable
|
|
405
|
-
const reactData = $xeTable as unknown as TableReactData
|
|
406
408
|
const internalData = $xeTable as unknown as TableInternalData
|
|
407
409
|
|
|
408
410
|
const { treeConfig } = props
|
|
409
|
-
const { treeExpandedMaps } =
|
|
410
|
-
const { fullAllDataRowIdData } = internalData
|
|
411
|
+
const { fullAllDataRowIdData, treeExpandedMaps } = internalData
|
|
411
412
|
const treeOpts = $xeTable.computeTreeOpts
|
|
412
413
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
413
414
|
if (treeConfig && treeOpts.transform) {
|
|
415
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
414
416
|
const fullData: any[] = []
|
|
415
417
|
const expandMaps: {
|
|
416
418
|
[key: string]: number
|
|
417
419
|
} = {}
|
|
418
420
|
XEUtils.eachTree(internalData.afterTreeFullData, (row, index, items, path, parentRow) => {
|
|
419
|
-
const rowid =
|
|
420
|
-
const parentRowid =
|
|
421
|
+
const rowid = handleGetRowId(row)
|
|
422
|
+
const parentRowid = handleGetRowId(parentRow)
|
|
421
423
|
if (!parentRow || (expandMaps[parentRowid] && treeExpandedMaps[parentRowid])) {
|
|
422
424
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
423
425
|
if (rowRest) {
|
|
@@ -791,6 +793,27 @@ function updateStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
|
791
793
|
return $xeTable.$nextTick()
|
|
792
794
|
}
|
|
793
795
|
|
|
796
|
+
function checkValidate ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, type: any) {
|
|
797
|
+
if ($xeTable.triggerValidate) {
|
|
798
|
+
return $xeTable.triggerValidate(type)
|
|
799
|
+
}
|
|
800
|
+
return $xeTable.$nextTick()
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/**
|
|
804
|
+
* 当单元格发生改变时
|
|
805
|
+
* 如果存在规则,则校验
|
|
806
|
+
*/
|
|
807
|
+
function handleChangeCell ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: Event, params: any) {
|
|
808
|
+
checkValidate($xeTable, 'blur')
|
|
809
|
+
.catch((e: any) => e)
|
|
810
|
+
.then(() => {
|
|
811
|
+
$xeTable.handleEdit(params, evnt)
|
|
812
|
+
.then(() => checkValidate($xeTable, 'change'))
|
|
813
|
+
.catch((e: any) => e)
|
|
814
|
+
})
|
|
815
|
+
}
|
|
816
|
+
|
|
794
817
|
function handleRadioReserveRow ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, row: any) {
|
|
795
818
|
const internalData = $xeTable as unknown as TableInternalData
|
|
796
819
|
|
|
@@ -842,12 +865,13 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
842
865
|
const internalData = $xeTable as unknown as TableInternalData
|
|
843
866
|
|
|
844
867
|
const { treeConfig } = props
|
|
845
|
-
const { selectCheckboxMaps } =
|
|
846
|
-
const { afterFullData, checkboxReserveRowMap } = internalData
|
|
868
|
+
const { afterFullData, checkboxReserveRowMap, selectCheckboxMaps } = internalData
|
|
847
869
|
const treeOpts = $xeTable.computeTreeOpts
|
|
848
870
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
849
871
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
850
872
|
const { checkField, reserve, checkMethod } = checkboxOpts
|
|
873
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
874
|
+
// indeterminateField 仅支持读取
|
|
851
875
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
852
876
|
const selectRowMaps: Record<string, any> = {}
|
|
853
877
|
/**
|
|
@@ -858,7 +882,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
858
882
|
const checkValFn = (row: any) => {
|
|
859
883
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
860
884
|
if (checked) {
|
|
861
|
-
selectRowMaps[
|
|
885
|
+
selectRowMaps[handleGetRowId(row)] = row
|
|
862
886
|
}
|
|
863
887
|
XEUtils.set(row, checkField, checked)
|
|
864
888
|
}
|
|
@@ -886,7 +910,8 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
886
910
|
*/
|
|
887
911
|
XEUtils.eachTree(afterFullData, (row) => {
|
|
888
912
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
889
|
-
|
|
913
|
+
const rowid = handleGetRowId(row)
|
|
914
|
+
selectRowMaps[rowid] = row
|
|
890
915
|
}
|
|
891
916
|
}, { children: childrenField })
|
|
892
917
|
} else {
|
|
@@ -896,7 +921,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
896
921
|
*/
|
|
897
922
|
if (!isForce && checkMethod) {
|
|
898
923
|
XEUtils.eachTree(afterFullData, (row) => {
|
|
899
|
-
const rowid =
|
|
924
|
+
const rowid = handleGetRowId(row)
|
|
900
925
|
if (checkMethod({ row }) ? 0 : selectCheckboxMaps[rowid]) {
|
|
901
926
|
selectRowMaps[rowid] = row
|
|
902
927
|
}
|
|
@@ -912,14 +937,15 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
912
937
|
*/
|
|
913
938
|
if (!isForce && checkMethod) {
|
|
914
939
|
afterFullData.forEach((row) => {
|
|
915
|
-
const rowid =
|
|
940
|
+
const rowid = handleGetRowId(row)
|
|
916
941
|
if (selectCheckboxMaps[rowid] || checkMethod({ row })) {
|
|
917
942
|
selectRowMaps[rowid] = row
|
|
918
943
|
}
|
|
919
944
|
})
|
|
920
945
|
} else {
|
|
921
946
|
afterFullData.forEach(row => {
|
|
922
|
-
|
|
947
|
+
const rowid = handleGetRowId(row)
|
|
948
|
+
selectRowMaps[rowid] = row
|
|
923
949
|
})
|
|
924
950
|
}
|
|
925
951
|
} else {
|
|
@@ -930,7 +956,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
930
956
|
*/
|
|
931
957
|
if (!isForce && checkMethod) {
|
|
932
958
|
afterFullData.forEach((row) => {
|
|
933
|
-
const rowid =
|
|
959
|
+
const rowid = handleGetRowId(row)
|
|
934
960
|
if (checkMethod({ row }) ? 0 : selectCheckboxMaps[rowid]) {
|
|
935
961
|
selectRowMaps[rowid] = row
|
|
936
962
|
}
|
|
@@ -948,11 +974,11 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
|
|
|
948
974
|
afterFullData.forEach((row) => handleCheckboxReserveRow($xeTable, row, false))
|
|
949
975
|
}
|
|
950
976
|
}
|
|
951
|
-
reactData.
|
|
977
|
+
reactData.updateCheckboxFlag++
|
|
978
|
+
internalData.selectCheckboxMaps = checkField ? {} : selectRowMaps
|
|
952
979
|
|
|
953
980
|
reactData.isAllSelected = checked
|
|
954
981
|
reactData.isIndeterminate = false
|
|
955
|
-
reactData.treeIndeterminateMaps = {}
|
|
956
982
|
internalData.treeIndeterminateRowMaps = {}
|
|
957
983
|
$xeTable.checkSelectionStatus()
|
|
958
984
|
return $xeTable.$nextTick()
|
|
@@ -965,8 +991,8 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
965
991
|
const internalData = $xeTable as unknown as TableInternalData
|
|
966
992
|
|
|
967
993
|
const { treeConfig } = props
|
|
968
|
-
const { expandColumn, currentRow,
|
|
969
|
-
const { fullDataRowIdData, fullAllDataRowIdData, radioReserveRow } = internalData
|
|
994
|
+
const { expandColumn, currentRow, selectRadioRow } = reactData
|
|
995
|
+
const { fullDataRowIdData, fullAllDataRowIdData, radioReserveRow, selectCheckboxMaps, treeExpandedMaps, rowExpandedMaps } = internalData
|
|
970
996
|
const expandOpts = $xeTable.computeExpandOpts
|
|
971
997
|
const treeOpts = $xeTable.computeTreeOpts
|
|
972
998
|
const radioOpts = $xeTable.computeRadioOpts
|
|
@@ -983,7 +1009,8 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
983
1009
|
}
|
|
984
1010
|
}
|
|
985
1011
|
// 复选框
|
|
986
|
-
|
|
1012
|
+
internalData.selectCheckboxMaps = getRecoverRowMaps($xeTable, selectCheckboxMaps) // 刷新多选行状态
|
|
1013
|
+
reactData.updateCheckboxFlag++
|
|
987
1014
|
// 还原保留选中状态
|
|
988
1015
|
if (checkboxOpts.reserve) {
|
|
989
1016
|
handleCheckedCheckboxRow($xeTable, handleReserveRow($xeTable, internalData.checkboxReserveRowMap), true, true)
|
|
@@ -992,18 +1019,168 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
|
|
|
992
1019
|
reactData.currentRow = null // 刷新当前行状态
|
|
993
1020
|
}
|
|
994
1021
|
// 行展开
|
|
995
|
-
|
|
1022
|
+
internalData.rowExpandedMaps = expandColumn ? getRecoverRowMaps($xeTable, rowExpandedMaps) : {} // 刷新行展开状态
|
|
1023
|
+
reactData.rowExpandedFlag++
|
|
996
1024
|
// 还原保留状态
|
|
997
1025
|
if (expandColumn && expandOpts.reserve) {
|
|
998
1026
|
$xeTable.setRowExpand(handleReserveRow($xeTable, internalData.rowExpandedReserveRowMap), true)
|
|
999
1027
|
}
|
|
1000
1028
|
// 树展开
|
|
1001
|
-
|
|
1029
|
+
internalData.treeExpandedMaps = treeConfig ? getRecoverRowMaps($xeTable, treeExpandedMaps) : {} // 刷新树展开状态
|
|
1030
|
+
reactData.treeExpandedFlag++
|
|
1002
1031
|
if (treeConfig && treeOpts.reserve) {
|
|
1003
1032
|
$xeTable.setTreeExpand(handleReserveRow($xeTable, internalData.treeExpandedReserveRowMap), true)
|
|
1004
1033
|
}
|
|
1005
1034
|
}
|
|
1006
1035
|
|
|
1036
|
+
/**
|
|
1037
|
+
* 处理默认展开树节点
|
|
1038
|
+
*/
|
|
1039
|
+
const handleDefaultTreeExpand = ($xeTable: VxeTableConstructor) => {
|
|
1040
|
+
const props = $xeTable
|
|
1041
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1042
|
+
|
|
1043
|
+
const { treeConfig } = props
|
|
1044
|
+
if (treeConfig) {
|
|
1045
|
+
const { tableFullData } = internalData
|
|
1046
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
1047
|
+
const { expandAll, expandRowKeys } = treeOpts
|
|
1048
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
1049
|
+
if (expandAll) {
|
|
1050
|
+
$xeTable.setAllTreeExpand(true)
|
|
1051
|
+
} else if (expandRowKeys) {
|
|
1052
|
+
const defExpandeds: any[] = []
|
|
1053
|
+
const rowkey = getRowkey($xeTable)
|
|
1054
|
+
expandRowKeys.forEach((rowid: any) => {
|
|
1055
|
+
const matchObj = XEUtils.findTree(tableFullData, item => rowid === XEUtils.get(item, rowkey), { children: childrenField })
|
|
1056
|
+
if (matchObj) {
|
|
1057
|
+
defExpandeds.push(matchObj.item)
|
|
1058
|
+
}
|
|
1059
|
+
})
|
|
1060
|
+
$xeTable.setTreeExpand(defExpandeds, true)
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
const handleAsyncTreeExpandChilds = ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, row: any): Promise<void> => {
|
|
1066
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
1067
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1068
|
+
|
|
1069
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
1070
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
1071
|
+
const { transform, loadMethod } = treeOpts
|
|
1072
|
+
const { checkStrictly } = checkboxOpts
|
|
1073
|
+
return new Promise<void>(resolve => {
|
|
1074
|
+
if (loadMethod) {
|
|
1075
|
+
const { fullAllDataRowIdData, treeExpandLazyLoadedMaps } = internalData
|
|
1076
|
+
const rowid = getRowid($xeTable, row)
|
|
1077
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
1078
|
+
treeExpandLazyLoadedMaps[rowid] = row
|
|
1079
|
+
Promise.resolve(
|
|
1080
|
+
loadMethod({ $table: $xeTable, row })
|
|
1081
|
+
).then((childRecords: any) => {
|
|
1082
|
+
if (rowRest) {
|
|
1083
|
+
rowRest.treeLoaded = true
|
|
1084
|
+
}
|
|
1085
|
+
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
1086
|
+
delete treeExpandLazyLoadedMaps[rowid]
|
|
1087
|
+
}
|
|
1088
|
+
if (!XEUtils.isArray(childRecords)) {
|
|
1089
|
+
childRecords = []
|
|
1090
|
+
}
|
|
1091
|
+
if (childRecords) {
|
|
1092
|
+
return $xeTable.loadTreeChildren(row, childRecords).then(childRows => {
|
|
1093
|
+
const { treeExpandedMaps } = internalData
|
|
1094
|
+
if (childRows.length && !treeExpandedMaps[rowid]) {
|
|
1095
|
+
treeExpandedMaps[rowid] = row
|
|
1096
|
+
}
|
|
1097
|
+
reactData.treeExpandedFlag++
|
|
1098
|
+
// 如果当前节点已选中,则展开后子节点也被选中
|
|
1099
|
+
if (!checkStrictly && $xeTable.isCheckedByCheckboxRow(row)) {
|
|
1100
|
+
handleCheckedCheckboxRow($xeTable, childRows, true)
|
|
1101
|
+
}
|
|
1102
|
+
return $xeTable.$nextTick().then(() => {
|
|
1103
|
+
if (transform) {
|
|
1104
|
+
$xeTable.handleTableData()
|
|
1105
|
+
updateAfterDataIndex($xeTable)
|
|
1106
|
+
return $xeTable.$nextTick()
|
|
1107
|
+
}
|
|
1108
|
+
})
|
|
1109
|
+
})
|
|
1110
|
+
}
|
|
1111
|
+
}).catch(() => {
|
|
1112
|
+
const { treeExpandLazyLoadedMaps } = internalData
|
|
1113
|
+
if (rowRest) {
|
|
1114
|
+
rowRest.treeLoaded = false
|
|
1115
|
+
}
|
|
1116
|
+
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
1117
|
+
delete treeExpandLazyLoadedMaps[rowid]
|
|
1118
|
+
}
|
|
1119
|
+
}).finally(() => {
|
|
1120
|
+
reactData.treeExpandedFlag++
|
|
1121
|
+
$xeTable.$nextTick().then(() => $xeTable.recalculate()).then(() => resolve())
|
|
1122
|
+
})
|
|
1123
|
+
} else {
|
|
1124
|
+
resolve()
|
|
1125
|
+
}
|
|
1126
|
+
})
|
|
1127
|
+
}
|
|
1128
|
+
|
|
1129
|
+
const handleTreeExpandReserve = ($xeTable: VxeTableConstructor, row: any, expanded: boolean) => {
|
|
1130
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1131
|
+
|
|
1132
|
+
const { treeExpandedReserveRowMap } = internalData
|
|
1133
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
1134
|
+
if (treeOpts.reserve) {
|
|
1135
|
+
const rowid = getRowid($xeTable, row)
|
|
1136
|
+
if (expanded) {
|
|
1137
|
+
treeExpandedReserveRowMap[rowid] = row
|
|
1138
|
+
} else if (treeExpandedReserveRowMap[rowid]) {
|
|
1139
|
+
delete treeExpandedReserveRowMap[rowid]
|
|
1140
|
+
}
|
|
1141
|
+
}
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
const handleAsyncRowExpand = ($xeTable: VxeTableConstructor, row: any): Promise<void> => {
|
|
1145
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
1146
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1147
|
+
|
|
1148
|
+
return new Promise<void>(resolve => {
|
|
1149
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
1150
|
+
const { loadMethod } = expandOpts
|
|
1151
|
+
if (loadMethod) {
|
|
1152
|
+
const { fullAllDataRowIdData, rowExpandLazyLoadedMaps } = internalData
|
|
1153
|
+
const rowid = getRowid($xeTable, row)
|
|
1154
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
1155
|
+
rowExpandLazyLoadedMaps[rowid] = row
|
|
1156
|
+
loadMethod({ $table: $xeTable, row, rowIndex: $xeTable.getRowIndex(row), $rowIndex: $xeTable.getVMRowIndex(row) }).then(() => {
|
|
1157
|
+
const { rowExpandedMaps } = internalData
|
|
1158
|
+
if (rowRest) {
|
|
1159
|
+
rowRest.expandLoaded = true
|
|
1160
|
+
}
|
|
1161
|
+
rowExpandedMaps[rowid] = row
|
|
1162
|
+
reactData.rowExpandedFlag++
|
|
1163
|
+
}).catch(() => {
|
|
1164
|
+
if (rowRest) {
|
|
1165
|
+
rowRest.expandLoaded = false
|
|
1166
|
+
}
|
|
1167
|
+
}).finally(() => {
|
|
1168
|
+
const { rowExpandLazyLoadedMaps } = internalData
|
|
1169
|
+
if (rowExpandLazyLoadedMaps[rowid]) {
|
|
1170
|
+
delete rowExpandLazyLoadedMaps[rowid]
|
|
1171
|
+
}
|
|
1172
|
+
reactData.rowExpandedFlag++
|
|
1173
|
+
$xeTable.$nextTick()
|
|
1174
|
+
.then(() => $xeTable.recalculate())
|
|
1175
|
+
.then(() => $xeTable.updateCellAreas())
|
|
1176
|
+
.then(() => resolve())
|
|
1177
|
+
})
|
|
1178
|
+
} else {
|
|
1179
|
+
resolve()
|
|
1180
|
+
}
|
|
1181
|
+
})
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1007
1184
|
function calcVarRowHeightConfig ($xeTable: VxeTableConstructor, sizeKey: 'default' | 'medium' | 'small' | 'mini', sizeEl: Element) {
|
|
1008
1185
|
const reactData = $xeTable as unknown as TableReactData
|
|
1009
1186
|
|
|
@@ -1069,12 +1246,13 @@ function handleVirtualYVisible ($xeTable: VxeTableConstructor) {
|
|
|
1069
1246
|
toVisibleIndex = Math.floor(startTop / defaultRowHeight) - 1
|
|
1070
1247
|
visibleSize = Math.ceil(clientHeight / defaultRowHeight) + 1
|
|
1071
1248
|
} else {
|
|
1249
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
1072
1250
|
let leftIndex = 0
|
|
1073
1251
|
let rightIndex = afterFullData.length
|
|
1074
1252
|
while (leftIndex < rightIndex) {
|
|
1075
1253
|
const rIndex = Math.floor((leftIndex + rightIndex) / 2)
|
|
1076
1254
|
const row = afterFullData[rIndex]
|
|
1077
|
-
const rowid =
|
|
1255
|
+
const rowid = handleGetRowId(row)
|
|
1078
1256
|
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
1079
1257
|
if (rowRest.oTop <= startTop) {
|
|
1080
1258
|
leftIndex = rIndex + 1
|
|
@@ -1085,7 +1263,7 @@ function handleVirtualYVisible ($xeTable: VxeTableConstructor) {
|
|
|
1085
1263
|
toVisibleIndex = Math.max(0, leftIndex < afterFullData.length ? leftIndex - 2 : 0)
|
|
1086
1264
|
for (let rIndex = toVisibleIndex, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
|
|
1087
1265
|
const row = afterFullData[rIndex]
|
|
1088
|
-
const rowid =
|
|
1266
|
+
const rowid = handleGetRowId(row)
|
|
1089
1267
|
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
1090
1268
|
visibleSize++
|
|
1091
1269
|
if (rowRest.oTop > endTop || visibleSize >= 100) {
|
|
@@ -1117,16 +1295,20 @@ function calculateMergerOffsetIndex (list: any, offsetItem: any, type: any) {
|
|
|
1117
1295
|
}
|
|
1118
1296
|
}
|
|
1119
1297
|
|
|
1120
|
-
function setMerges (
|
|
1298
|
+
function setMerges ($xeTable: VxeTableConstructor, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[], mList: VxeTableDefines.MergeItem[], rowList?: any[]) {
|
|
1299
|
+
const props = $xeTable
|
|
1300
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1301
|
+
|
|
1121
1302
|
if (merges) {
|
|
1122
|
-
const { treeConfig
|
|
1303
|
+
const { treeConfig } = props
|
|
1304
|
+
const { visibleColumn } = internalData
|
|
1123
1305
|
if (!XEUtils.isArray(merges)) {
|
|
1124
1306
|
merges = [merges]
|
|
1125
1307
|
}
|
|
1126
1308
|
if (treeConfig && merges.length) {
|
|
1127
1309
|
errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
|
|
1128
1310
|
}
|
|
1129
|
-
merges.forEach((item
|
|
1311
|
+
merges.forEach((item) => {
|
|
1130
1312
|
let { row, col, rowspan, colspan } = item
|
|
1131
1313
|
if (rowList && XEUtils.isNumber(row)) {
|
|
1132
1314
|
row = rowList[row]
|
|
@@ -1165,10 +1347,14 @@ function setMerges (_vm: any, merges: any, mList: any, rowList: any) {
|
|
|
1165
1347
|
}
|
|
1166
1348
|
}
|
|
1167
1349
|
|
|
1168
|
-
function removeMerges (
|
|
1350
|
+
function removeMerges ($xeTable: VxeTableConstructor, merges: VxeTableDefines.MergeOptions | VxeTableDefines.MergeOptions[], mList: VxeTableDefines.MergeItem[], rowList?: any) {
|
|
1351
|
+
const props = $xeTable
|
|
1352
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
1353
|
+
|
|
1169
1354
|
const rest: any[] = []
|
|
1170
1355
|
if (merges) {
|
|
1171
|
-
const { treeConfig
|
|
1356
|
+
const { treeConfig } = props
|
|
1357
|
+
const { visibleColumn } = internalData
|
|
1172
1358
|
if (!XEUtils.isArray(merges)) {
|
|
1173
1359
|
merges = [merges]
|
|
1174
1360
|
}
|
|
@@ -1381,8 +1567,9 @@ const calcCellHeight = ($xeTable: VxeTableConstructor) => {
|
|
|
1381
1567
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
1382
1568
|
const el = $xeTable.$refs.refElem as HTMLDivElement
|
|
1383
1569
|
if (!isAllOverflow && scrollYLoad && el) {
|
|
1570
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
1384
1571
|
tableData.forEach(row => {
|
|
1385
|
-
const rowid =
|
|
1572
|
+
const rowid = handleGetRowId(row)
|
|
1386
1573
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
1387
1574
|
if (rowRest) {
|
|
1388
1575
|
const height = calcCellAutoHeight(rowRest, el)
|
|
@@ -2054,6 +2241,39 @@ function loadScrollYData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods
|
|
|
2054
2241
|
}
|
|
2055
2242
|
}
|
|
2056
2243
|
|
|
2244
|
+
const createGetRowCacheProp = (prop: 'seq' | 'index' | '_index' | '$index') => {
|
|
2245
|
+
return function (this: VxeTableConstructor & VxeTablePrivateMethods, row: any) {
|
|
2246
|
+
const $xeTable = this
|
|
2247
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
2248
|
+
|
|
2249
|
+
const { fullAllDataRowIdData } = internalData
|
|
2250
|
+
if (row) {
|
|
2251
|
+
const rowid = getRowid($xeTable, row)
|
|
2252
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
2253
|
+
if (rowRest) {
|
|
2254
|
+
return rowRest[prop]
|
|
2255
|
+
}
|
|
2256
|
+
}
|
|
2257
|
+
return -1
|
|
2258
|
+
}
|
|
2259
|
+
}
|
|
2260
|
+
|
|
2261
|
+
const createGetColumnCacheProp = (prop: 'index' | '_index' | '$index') => {
|
|
2262
|
+
return function (this: VxeTableConstructor & VxeTablePrivateMethods, column: VxeTableDefines.ColumnInfo) {
|
|
2263
|
+
const $xeTable = this
|
|
2264
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
2265
|
+
|
|
2266
|
+
const { fullColumnIdData } = internalData
|
|
2267
|
+
if (column) {
|
|
2268
|
+
const colRest = fullColumnIdData[column.id]
|
|
2269
|
+
if (colRest) {
|
|
2270
|
+
return colRest[prop]
|
|
2271
|
+
}
|
|
2272
|
+
}
|
|
2273
|
+
return -1
|
|
2274
|
+
}
|
|
2275
|
+
}
|
|
2276
|
+
|
|
2057
2277
|
function lazyScrollXData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
|
|
2058
2278
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2059
2279
|
|
|
@@ -2220,7 +2440,7 @@ function calcCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
|
|
|
2220
2440
|
|
|
2221
2441
|
function handleUpdateColResize ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: MouseEvent, params: any) {
|
|
2222
2442
|
$xeTable.analyColumnWidth()
|
|
2223
|
-
$xeTable.recalculate(
|
|
2443
|
+
$xeTable.recalculate().then(() => {
|
|
2224
2444
|
$xeTable.saveCustomStore('update:width')
|
|
2225
2445
|
$xeTable.updateCellAreas()
|
|
2226
2446
|
$xeTable.dispatchEvent('column-resizable-change', params, evnt)
|
|
@@ -2234,7 +2454,7 @@ function handleUpdateRowResize ($xeTable: VxeTableConstructor & VxeTablePrivateM
|
|
|
2234
2454
|
const reactData = $xeTable as unknown as TableReactData
|
|
2235
2455
|
|
|
2236
2456
|
reactData.resizeHeightFlag++
|
|
2237
|
-
$xeTable.recalculate(
|
|
2457
|
+
$xeTable.recalculate().then(() => {
|
|
2238
2458
|
$xeTable.updateCellAreas()
|
|
2239
2459
|
$xeTable.dispatchEvent('row-resizable-change', params, evnt)
|
|
2240
2460
|
setTimeout(() => $xeTable.recalculate(true), 300)
|
|
@@ -2259,16 +2479,17 @@ function updateRowOffsetTop ($xeTable: VxeTableConstructor & VxeTablePrivateMeth
|
|
|
2259
2479
|
const reactData = $xeTable as unknown as TableReactData
|
|
2260
2480
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2261
2481
|
|
|
2262
|
-
const { expandColumn
|
|
2263
|
-
const { afterFullData, fullAllDataRowIdData } = internalData
|
|
2482
|
+
const { expandColumn } = reactData
|
|
2483
|
+
const { afterFullData, fullAllDataRowIdData, rowExpandedMaps } = internalData
|
|
2264
2484
|
const expandOpts = $xeTable.computeExpandOpts
|
|
2265
2485
|
const rowOpts = $xeTable.computeRowOpts
|
|
2266
2486
|
const cellOpts = $xeTable.computeCellOpts
|
|
2267
2487
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
2488
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
2268
2489
|
let offsetTop = 0
|
|
2269
2490
|
for (let rIndex = 0, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
|
|
2270
2491
|
const row = afterFullData[rIndex]
|
|
2271
|
-
const rowid =
|
|
2492
|
+
const rowid = handleGetRowId(row)
|
|
2272
2493
|
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
2273
2494
|
rowRest.oTop = offsetTop
|
|
2274
2495
|
offsetTop += rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight
|
|
@@ -2283,46 +2504,42 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
|
|
|
2283
2504
|
const reactData = $xeTable as unknown as TableReactData
|
|
2284
2505
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2285
2506
|
|
|
2286
|
-
const { expandColumn, scrollYLoad,
|
|
2507
|
+
const { expandColumn, scrollYLoad, scrollYTop, isScrollYBig } = reactData
|
|
2287
2508
|
const expandOpts = $xeTable.computeExpandOpts
|
|
2288
2509
|
const rowOpts = $xeTable.computeRowOpts
|
|
2289
2510
|
const cellOpts = $xeTable.computeCellOpts
|
|
2290
2511
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
2291
2512
|
const { mode } = expandOpts
|
|
2292
2513
|
if (expandColumn && mode === 'fixed') {
|
|
2293
|
-
const { elemStore,
|
|
2514
|
+
const { elemStore, fullAllDataRowIdData } = internalData
|
|
2294
2515
|
const rowExpandEl = $xeTable.$refs.refRowExpandElem as HTMLDivElement
|
|
2295
2516
|
const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
|
|
2296
2517
|
if (rowExpandEl && bodyScrollElem) {
|
|
2297
2518
|
let isUpdateHeight = false
|
|
2298
|
-
if (scrollYLoad) {
|
|
2299
|
-
let offsetTop = 0
|
|
2300
|
-
for (let rIndex = 0, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
|
|
2301
|
-
const row = afterFullData[rIndex]
|
|
2302
|
-
const rowid = getRowid($xeTable, row)
|
|
2303
|
-
const rowRest = fullAllDataRowIdData[rowid] || {}
|
|
2304
|
-
rowRest.oTop = offsetTop
|
|
2305
|
-
offsetTop += rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight
|
|
2306
|
-
// 是否展开行
|
|
2307
|
-
if (expandColumn && rowExpandedMaps[rowid]) {
|
|
2308
|
-
offsetTop += rowRest.expandHeight || expandOpts.height || 0
|
|
2309
|
-
}
|
|
2310
|
-
}
|
|
2311
|
-
}
|
|
2312
2519
|
XEUtils.arrayEach(rowExpandEl.children, reEl => {
|
|
2313
2520
|
const expandEl = reEl as HTMLDivElement
|
|
2314
2521
|
const rowid = expandEl.getAttribute('rowid') || ''
|
|
2315
2522
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
2316
2523
|
if (rowRest) {
|
|
2317
2524
|
const expandHeight = expandEl.offsetHeight + 1
|
|
2525
|
+
const trEl = bodyScrollElem.querySelector(`.vxe-body--row[rowid="${rowid}"]`) as HTMLTableCellElement
|
|
2526
|
+
let offsetTop = 0
|
|
2318
2527
|
if (scrollYLoad) {
|
|
2319
|
-
|
|
2528
|
+
if (isScrollYBig && trEl) {
|
|
2529
|
+
offsetTop = trEl.offsetTop + trEl.offsetHeight
|
|
2530
|
+
} else {
|
|
2531
|
+
offsetTop = rowRest.oTop + (rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight)
|
|
2532
|
+
}
|
|
2320
2533
|
} else {
|
|
2321
|
-
const trEl = bodyScrollElem.querySelector(`.vxe-body--row[rowid="${rowid}"]`) as HTMLTableCellElement
|
|
2322
2534
|
if (trEl) {
|
|
2323
|
-
|
|
2535
|
+
offsetTop = trEl.offsetTop + trEl.offsetHeight
|
|
2324
2536
|
}
|
|
2325
2537
|
}
|
|
2538
|
+
if (isScrollYBig) {
|
|
2539
|
+
offsetTop += scrollYTop
|
|
2540
|
+
}
|
|
2541
|
+
expandEl.style.top = toCssUnit(offsetTop)
|
|
2542
|
+
|
|
2326
2543
|
if (!isUpdateHeight) {
|
|
2327
2544
|
if (rowRest.expandHeight !== expandHeight) {
|
|
2328
2545
|
isUpdateHeight = true
|
|
@@ -2333,6 +2550,9 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
|
|
|
2333
2550
|
})
|
|
2334
2551
|
if (isUpdateHeight) {
|
|
2335
2552
|
reactData.rowExpandHeightFlag++
|
|
2553
|
+
$xeTable.$nextTick(() => {
|
|
2554
|
+
updateRowOffsetTop($xeTable)
|
|
2555
|
+
})
|
|
2336
2556
|
}
|
|
2337
2557
|
}
|
|
2338
2558
|
}
|
|
@@ -2362,6 +2582,11 @@ const Methods = {
|
|
|
2362
2582
|
}
|
|
2363
2583
|
return []
|
|
2364
2584
|
},
|
|
2585
|
+
getEl () {
|
|
2586
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2587
|
+
|
|
2588
|
+
return $xeTable.$refs.refElem as HTMLDivElement
|
|
2589
|
+
},
|
|
2365
2590
|
/**
|
|
2366
2591
|
* 获取父容器元素
|
|
2367
2592
|
*/
|
|
@@ -2373,10 +2598,26 @@ const Methods = {
|
|
|
2373
2598
|
* 获取父容器的高度
|
|
2374
2599
|
*/
|
|
2375
2600
|
getParentHeight () {
|
|
2376
|
-
const
|
|
2377
|
-
const
|
|
2378
|
-
const
|
|
2379
|
-
|
|
2601
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
2602
|
+
const $xeGrid = $xeTable.$xeGrid as VxeGridConstructor & GridPrivateMethods
|
|
2603
|
+
const props = $xeTable
|
|
2604
|
+
|
|
2605
|
+
const { height } = props
|
|
2606
|
+
const el = $xeTable.$refs.refElem as HTMLDivElement
|
|
2607
|
+
if (el) {
|
|
2608
|
+
const parentElem = el.parentNode as HTMLElement
|
|
2609
|
+
const parentPaddingSize = height === '100%' || height === 'auto' ? getPaddingTopBottomSize(parentElem) : 0
|
|
2610
|
+
let parentWrapperHeight = 0
|
|
2611
|
+
if (parentElem) {
|
|
2612
|
+
if ($xeGrid && hasClass(parentElem, 'vxe-grid--table-wrapper')) {
|
|
2613
|
+
parentWrapperHeight = $xeGrid.getParentHeight()
|
|
2614
|
+
} else {
|
|
2615
|
+
parentWrapperHeight = parentElem.clientHeight
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
return Math.floor(parentWrapperHeight - parentPaddingSize)
|
|
2619
|
+
}
|
|
2620
|
+
return 0
|
|
2380
2621
|
},
|
|
2381
2622
|
/**
|
|
2382
2623
|
* 获取需要排除的高度
|
|
@@ -2466,6 +2707,9 @@ const Methods = {
|
|
|
2466
2707
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
2467
2708
|
let treeData = []
|
|
2468
2709
|
let fullData = datas ? datas.slice(0) : []
|
|
2710
|
+
if (fullData.length > supportMaxRow) {
|
|
2711
|
+
errLog('vxe.error.errMaxRow', [supportMaxRow])
|
|
2712
|
+
}
|
|
2469
2713
|
if (treeConfig) {
|
|
2470
2714
|
// 树结构自动转换
|
|
2471
2715
|
if (treeOpts.transform) {
|
|
@@ -2561,7 +2805,7 @@ const Methods = {
|
|
|
2561
2805
|
// warnLog('vxe.error.reqProp', ['table.show-overflow'])
|
|
2562
2806
|
// }
|
|
2563
2807
|
if (this.spanMethod) {
|
|
2564
|
-
|
|
2808
|
+
errLog('vxe.error.scrollErrProp', ['table.span-method'])
|
|
2565
2809
|
}
|
|
2566
2810
|
}
|
|
2567
2811
|
|
|
@@ -2710,35 +2954,17 @@ const Methods = {
|
|
|
2710
2954
|
const internalData = $xeTable as unknown as TableInternalData
|
|
2711
2955
|
|
|
2712
2956
|
const { treeConfig } = props
|
|
2713
|
-
const { treeExpandedMaps } =
|
|
2714
|
-
const { fullAllDataRowIdData, tableFullData, tableFullTreeData } = internalData
|
|
2957
|
+
const { fullAllDataRowIdData, tableFullData, tableFullTreeData, treeExpandedMaps } = internalData
|
|
2715
2958
|
const treeOpts = $xeTable.computeTreeOpts
|
|
2716
2959
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
2717
2960
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
2718
|
-
const
|
|
2961
|
+
const { lazy } = treeOpts
|
|
2719
2962
|
const fullAllDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = { ...fullAllDataRowIdData } // 存在已删除数据
|
|
2720
2963
|
const fullDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = {}
|
|
2721
|
-
|
|
2722
|
-
const
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
const level = nodes ? nodes.length - 1 : 0
|
|
2726
|
-
if (eqEmptyValue(rowid)) {
|
|
2727
|
-
rowid = getRowUniqueId()
|
|
2728
|
-
XEUtils.set(row, rowkey, rowid)
|
|
2729
|
-
}
|
|
2730
|
-
if (treeConfig && treeOpts.lazy) {
|
|
2731
|
-
const treeExpRest = treeExpandedMaps[rowid]
|
|
2732
|
-
if (row[hasChildField] && XEUtils.isUndefined(row[childrenField])) {
|
|
2733
|
-
row[childrenField] = null
|
|
2734
|
-
}
|
|
2735
|
-
if (treeExpRest) {
|
|
2736
|
-
if (!row[childrenField] || !row[childrenField].length) {
|
|
2737
|
-
delete treeTempExpandedMaps[rowid]
|
|
2738
|
-
}
|
|
2739
|
-
}
|
|
2740
|
-
}
|
|
2741
|
-
let rowRest = fullAllDataRowIdData[rowid]
|
|
2964
|
+
|
|
2965
|
+
const { handleUpdateRowId } = createHandleUpdateRowId($xeTable)
|
|
2966
|
+
const handleRowCache = (row: any, index: number, items: any, currIndex: number, parentRow: any, rowid: string, level: number, seq: string | number) => {
|
|
2967
|
+
let rowRest = fullAllDataRowIdMaps[rowid]
|
|
2742
2968
|
if (!rowRest) {
|
|
2743
2969
|
rowRest = { row, rowid, seq, index: -1, _index: -1, $index: -1, treeIndex: index, items, parent: parentRow, level, height: 0, resizeHeight: 0, oTop: 0, expandHeight: 0 }
|
|
2744
2970
|
}
|
|
@@ -2749,34 +2975,51 @@ const Methods = {
|
|
|
2749
2975
|
rowRest.items = items
|
|
2750
2976
|
rowRest.parent = parentRow
|
|
2751
2977
|
rowRest.level = level
|
|
2752
|
-
rowRest.index =
|
|
2978
|
+
rowRest.index = currIndex
|
|
2979
|
+
rowRest.treeIndex = index
|
|
2980
|
+
|
|
2753
2981
|
fullDataRowIdMaps[rowid] = rowRest
|
|
2754
2982
|
fullAllDataRowIdMaps[rowid] = rowRest
|
|
2755
2983
|
}
|
|
2984
|
+
|
|
2756
2985
|
if (treeConfig) {
|
|
2757
|
-
XEUtils.eachTree(tableFullTreeData,
|
|
2986
|
+
XEUtils.eachTree(tableFullTreeData, (row, index, items, path, parentRow, nodes) => {
|
|
2987
|
+
const rowid = handleUpdateRowId(row)
|
|
2988
|
+
if (treeConfig && lazy) {
|
|
2989
|
+
if (row[hasChildField] && row[childrenField] === undefined) {
|
|
2990
|
+
row[childrenField] = null
|
|
2991
|
+
}
|
|
2992
|
+
if (treeExpandedMaps[rowid]) {
|
|
2993
|
+
if (!row[childrenField] || !row[childrenField].length) {
|
|
2994
|
+
delete treeExpandedMaps[rowid]
|
|
2995
|
+
}
|
|
2996
|
+
}
|
|
2997
|
+
}
|
|
2998
|
+
handleRowCache(row, index, items, parentRow ? -1 : index, parentRow, rowid, nodes.length - 1, toTreePathSeq(path))
|
|
2999
|
+
}, { children: childrenField })
|
|
2758
3000
|
} else {
|
|
2759
|
-
tableFullData.forEach(
|
|
3001
|
+
tableFullData.forEach((row, index, items) => {
|
|
3002
|
+
handleRowCache(row, index, items, index, null, handleUpdateRowId(row), 0, index + 1)
|
|
3003
|
+
})
|
|
2760
3004
|
}
|
|
3005
|
+
|
|
2761
3006
|
internalData.fullDataRowIdData = fullDataRowIdMaps
|
|
2762
3007
|
internalData.fullAllDataRowIdData = fullAllDataRowIdMaps
|
|
2763
|
-
reactData.
|
|
3008
|
+
reactData.treeExpandedFlag++
|
|
2764
3009
|
},
|
|
2765
3010
|
cacheSourceMap (fullData: any[]) {
|
|
2766
|
-
|
|
3011
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3012
|
+
const props = $xeTable
|
|
3013
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3014
|
+
|
|
3015
|
+
const { treeConfig } = props
|
|
3016
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
2767
3017
|
const sourceData = XEUtils.clone(fullData, true)
|
|
2768
|
-
const
|
|
2769
|
-
|
|
3018
|
+
const { handleUpdateRowId } = createHandleUpdateRowId($xeTable)
|
|
3019
|
+
const sourceRowIdData: Record<string, any> = {}
|
|
2770
3020
|
const handleSourceRow = (row: any) => {
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
rowid = getRowUniqueId()
|
|
2774
|
-
XEUtils.set(row, rowkey, rowid)
|
|
2775
|
-
}
|
|
2776
|
-
sourceDataRowIdData[rowid] = {
|
|
2777
|
-
row,
|
|
2778
|
-
rowid
|
|
2779
|
-
}
|
|
3021
|
+
const rowid = handleUpdateRowId(row)
|
|
3022
|
+
sourceRowIdData[rowid] = row
|
|
2780
3023
|
}
|
|
2781
3024
|
// 源数据缓存
|
|
2782
3025
|
if (treeConfig) {
|
|
@@ -2785,7 +3028,8 @@ const Methods = {
|
|
|
2785
3028
|
} else {
|
|
2786
3029
|
sourceData.forEach(handleSourceRow)
|
|
2787
3030
|
}
|
|
2788
|
-
|
|
3031
|
+
internalData.sourceDataRowIdData = sourceRowIdData
|
|
3032
|
+
internalData.tableSourceData = sourceData
|
|
2789
3033
|
},
|
|
2790
3034
|
getParams () {
|
|
2791
3035
|
return this.params
|
|
@@ -2873,47 +3117,22 @@ const Methods = {
|
|
|
2873
3117
|
* 根据 row 获取序号
|
|
2874
3118
|
* @param {Row} row 行对象
|
|
2875
3119
|
*/
|
|
2876
|
-
getRowSeq (
|
|
2877
|
-
const { fullAllDataRowIdData } = this
|
|
2878
|
-
if (row) {
|
|
2879
|
-
const rowid = getRowid(this, row)
|
|
2880
|
-
const rest = fullAllDataRowIdData[rowid]
|
|
2881
|
-
if (rest) {
|
|
2882
|
-
return rest.seq
|
|
2883
|
-
}
|
|
2884
|
-
}
|
|
2885
|
-
return -1
|
|
2886
|
-
},
|
|
3120
|
+
getRowSeq: createGetRowCacheProp('seq'),
|
|
2887
3121
|
/**
|
|
2888
3122
|
* 根据 row 获取相对于 data 中的索引
|
|
2889
3123
|
* @param {Row} row 行对象
|
|
2890
3124
|
*/
|
|
2891
|
-
getRowIndex (row: any)
|
|
2892
|
-
const { fullAllDataRowIdData } = this
|
|
2893
|
-
if (row) {
|
|
2894
|
-
const rowid = getRowid(this, row)
|
|
2895
|
-
const rest = fullAllDataRowIdData[rowid]
|
|
2896
|
-
if (rest) {
|
|
2897
|
-
return rest.index
|
|
2898
|
-
}
|
|
2899
|
-
}
|
|
2900
|
-
return -1
|
|
2901
|
-
},
|
|
3125
|
+
getRowIndex: createGetRowCacheProp('index') as ((row: any) => number),
|
|
2902
3126
|
/**
|
|
2903
3127
|
* 根据 row 获取相对于当前数据中的索引
|
|
2904
3128
|
* @param {Row} row 行对象
|
|
2905
3129
|
*/
|
|
2906
|
-
getVTRowIndex (row: any)
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
return rest._index
|
|
2913
|
-
}
|
|
2914
|
-
}
|
|
2915
|
-
return -1
|
|
2916
|
-
},
|
|
3130
|
+
getVTRowIndex: createGetRowCacheProp('_index') as ((row: any) => number),
|
|
3131
|
+
/**
|
|
3132
|
+
* 根据 row 获取渲染中的虚拟索引
|
|
3133
|
+
* @param {Row} row 行对象
|
|
3134
|
+
*/
|
|
3135
|
+
getVMRowIndex: createGetRowCacheProp('$index') as ((row: any) => number),
|
|
2917
3136
|
// 在 v3 中废弃
|
|
2918
3137
|
_getRowIndex (row: any) {
|
|
2919
3138
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -2921,21 +3140,6 @@ const Methods = {
|
|
|
2921
3140
|
}
|
|
2922
3141
|
return this.getVTRowIndex(row)
|
|
2923
3142
|
},
|
|
2924
|
-
/**
|
|
2925
|
-
* 根据 row 获取渲染中的虚拟索引
|
|
2926
|
-
* @param {Row} row 行对象
|
|
2927
|
-
*/
|
|
2928
|
-
getVMRowIndex (row: any) {
|
|
2929
|
-
const { fullAllDataRowIdData } = this
|
|
2930
|
-
if (row) {
|
|
2931
|
-
const rowid = getRowid(this, row)
|
|
2932
|
-
const rest = fullAllDataRowIdData[rowid]
|
|
2933
|
-
if (rest) {
|
|
2934
|
-
return rest.$index
|
|
2935
|
-
}
|
|
2936
|
-
}
|
|
2937
|
-
return -1
|
|
2938
|
-
},
|
|
2939
3143
|
// 在 v3 中废弃
|
|
2940
3144
|
$getRowIndex (row: any) {
|
|
2941
3145
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -2947,30 +3151,17 @@ const Methods = {
|
|
|
2947
3151
|
* 根据 column 获取相对于 columns 中的索引
|
|
2948
3152
|
* @param {ColumnInfo} column 列配置
|
|
2949
3153
|
*/
|
|
2950
|
-
getColumnIndex (
|
|
2951
|
-
const { fullColumnIdData } = this
|
|
2952
|
-
if (column) {
|
|
2953
|
-
const rest = fullColumnIdData[column.id]
|
|
2954
|
-
if (rest) {
|
|
2955
|
-
return rest.index
|
|
2956
|
-
}
|
|
2957
|
-
}
|
|
2958
|
-
return -1
|
|
2959
|
-
},
|
|
3154
|
+
getColumnIndex: createGetColumnCacheProp('index'),
|
|
2960
3155
|
/**
|
|
2961
3156
|
* 根据 column 获取相对于当前表格列中的索引
|
|
2962
3157
|
* @param {ColumnInfo} column 列配置
|
|
2963
3158
|
*/
|
|
2964
|
-
getVTColumnIndex (
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
|
|
2968
|
-
|
|
2969
|
-
|
|
2970
|
-
}
|
|
2971
|
-
}
|
|
2972
|
-
return -1
|
|
2973
|
-
},
|
|
3159
|
+
getVTColumnIndex: createGetColumnCacheProp('_index'),
|
|
3160
|
+
/**
|
|
3161
|
+
* 根据 column 获取渲染中的虚拟索引
|
|
3162
|
+
* @param {ColumnInfo} column 列配置
|
|
3163
|
+
*/
|
|
3164
|
+
getVMColumnIndex: createGetColumnCacheProp('$index'),
|
|
2974
3165
|
// 在 v3 中废弃
|
|
2975
3166
|
_getColumnIndex (column: any) {
|
|
2976
3167
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -2978,20 +3169,6 @@ const Methods = {
|
|
|
2978
3169
|
}
|
|
2979
3170
|
return this.getVTColumnIndex(column)
|
|
2980
3171
|
},
|
|
2981
|
-
/**
|
|
2982
|
-
* 根据 column 获取渲染中的虚拟索引
|
|
2983
|
-
* @param {ColumnInfo} column 列配置
|
|
2984
|
-
*/
|
|
2985
|
-
getVMColumnIndex (column: any) {
|
|
2986
|
-
const { fullColumnIdData } = this
|
|
2987
|
-
if (column) {
|
|
2988
|
-
const rest = fullColumnIdData[column.id]
|
|
2989
|
-
if (rest) {
|
|
2990
|
-
return rest.$index
|
|
2991
|
-
}
|
|
2992
|
-
}
|
|
2993
|
-
return -1
|
|
2994
|
-
},
|
|
2995
3172
|
// 在 v3 中废弃
|
|
2996
3173
|
$getColumnIndex (column: any) {
|
|
2997
3174
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -3085,12 +3262,15 @@ const Methods = {
|
|
|
3085
3262
|
const internalData = $xeTable as unknown as TableInternalData
|
|
3086
3263
|
|
|
3087
3264
|
const { keepSource, treeConfig } = props
|
|
3088
|
-
const {
|
|
3265
|
+
const { editStore } = reactData
|
|
3266
|
+
const { fullAllDataRowIdData, fullDataRowIdData, tableSourceData, sourceDataRowIdData, tableFullData, afterFullData } = internalData
|
|
3267
|
+
const removeTempMaps = { ...editStore.removeMaps }
|
|
3089
3268
|
const treeOpts = $xeTable.computeTreeOpts
|
|
3090
3269
|
const { transform } = treeOpts
|
|
3270
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
3091
3271
|
if (!keepSource) {
|
|
3092
3272
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
3093
|
-
|
|
3273
|
+
errLog('vxe.error.reqProp', ['keep-source'])
|
|
3094
3274
|
}
|
|
3095
3275
|
return $xeTable.$nextTick()
|
|
3096
3276
|
}
|
|
@@ -3104,22 +3284,23 @@ const Methods = {
|
|
|
3104
3284
|
}
|
|
3105
3285
|
let reDelFlag = false
|
|
3106
3286
|
if (targetRows.length) {
|
|
3107
|
-
targetRows.forEach((
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3287
|
+
targetRows.forEach((item: any) => {
|
|
3288
|
+
const rowid = handleGetRowId(item)
|
|
3289
|
+
const rowRest = fullAllDataRowIdData[rowid]
|
|
3290
|
+
if (rowRest) {
|
|
3291
|
+
const row = rowRest.row
|
|
3292
|
+
if (!$xeTable.isInsertByRow(row)) {
|
|
3293
|
+
const oRow = sourceDataRowIdData[rowid]
|
|
3294
|
+
if (oRow && row) {
|
|
3295
|
+
if (field) {
|
|
3296
|
+
XEUtils.set(row, field, XEUtils.clone(XEUtils.get(oRow, field), true))
|
|
3297
|
+
} else {
|
|
3298
|
+
XEUtils.destructuring(row, XEUtils.clone(oRow, true))
|
|
3299
|
+
}
|
|
3300
|
+
if (!fullDataRowIdData[rowid] && $xeTable.isRemoveByRow(row)) {
|
|
3301
|
+
delete removeTempMaps[rowid]
|
|
3302
|
+
tableFullData.unshift(row)
|
|
3303
|
+
afterFullData.unshift(row)
|
|
3123
3304
|
reDelFlag = true
|
|
3124
3305
|
}
|
|
3125
3306
|
}
|
|
@@ -3129,6 +3310,7 @@ const Methods = {
|
|
|
3129
3310
|
}
|
|
3130
3311
|
if (rows) {
|
|
3131
3312
|
if (reDelFlag) {
|
|
3313
|
+
editStore.removeMaps = removeTempMaps
|
|
3132
3314
|
$xeTable.updateFooter()
|
|
3133
3315
|
$xeTable.cacheRowMap(false)
|
|
3134
3316
|
$xeTable.handleTableData(treeConfig && transform)
|
|
@@ -3291,22 +3473,28 @@ const Methods = {
|
|
|
3291
3473
|
},
|
|
3292
3474
|
/**
|
|
3293
3475
|
* 检查行或列数据是否发生改变
|
|
3294
|
-
* @param {Row}
|
|
3476
|
+
* @param {Row} rowOrId 行对象
|
|
3295
3477
|
* @param {String} field 字段名
|
|
3296
3478
|
*/
|
|
3297
|
-
isUpdateByRow (
|
|
3298
|
-
const
|
|
3479
|
+
isUpdateByRow (rowOrId: any, field?: string | null) {
|
|
3480
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3481
|
+
const props = $xeTable
|
|
3482
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3483
|
+
|
|
3484
|
+
const { keepSource } = props
|
|
3485
|
+
const { tableFullColumn, fullDataRowIdData, sourceDataRowIdData } = internalData
|
|
3299
3486
|
if (keepSource) {
|
|
3300
|
-
const rowid = getRowid(
|
|
3487
|
+
const rowid = XEUtils.isString(rowOrId) || XEUtils.isNumber(rowOrId) ? rowOrId : getRowid($xeTable, rowOrId)
|
|
3488
|
+
const rowRest = fullDataRowIdData[rowid]
|
|
3301
3489
|
// 新增的数据不需要检测
|
|
3302
|
-
if (!
|
|
3490
|
+
if (!rowRest) {
|
|
3303
3491
|
return false
|
|
3304
3492
|
}
|
|
3305
|
-
const
|
|
3306
|
-
|
|
3307
|
-
|
|
3493
|
+
const row = rowRest.row
|
|
3494
|
+
const oRow = sourceDataRowIdData[rowid]
|
|
3495
|
+
if (oRow) {
|
|
3308
3496
|
if (arguments.length > 1) {
|
|
3309
|
-
return !eqCellValue(oRow, row, field)
|
|
3497
|
+
return !eqCellValue(oRow, row, field as string)
|
|
3310
3498
|
}
|
|
3311
3499
|
for (let index = 0, len = tableFullColumn.length; index < len; index++) {
|
|
3312
3500
|
const property = tableFullColumn[index].field
|
|
@@ -3367,7 +3555,108 @@ const Methods = {
|
|
|
3367
3555
|
}
|
|
3368
3556
|
},
|
|
3369
3557
|
/**
|
|
3370
|
-
*
|
|
3558
|
+
* 移动列到指定列的位置
|
|
3559
|
+
* @param fieldOrColumn
|
|
3560
|
+
* @param targetFieldOrColumn
|
|
3561
|
+
* @param options
|
|
3562
|
+
*/
|
|
3563
|
+
moveColumnTo (fieldOrColumn: VxeTableDefines.ColumnInfo, targetFieldOrColumn: VxeTableDefines.ColumnInfo, options?: {
|
|
3564
|
+
isCrossDrag?: boolean
|
|
3565
|
+
dragToChild?: boolean;
|
|
3566
|
+
dragPos?: 'left' | 'right' | '' | null;
|
|
3567
|
+
}) {
|
|
3568
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3569
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3570
|
+
|
|
3571
|
+
const { fullColumnIdData, visibleColumn } = internalData
|
|
3572
|
+
const { dragToChild, dragPos, isCrossDrag } = Object.assign({}, options)
|
|
3573
|
+
const dragCol = handleFieldOrColumn($xeTable, fieldOrColumn)
|
|
3574
|
+
let prevDragCol: VxeTableDefines.ColumnInfo | null = null
|
|
3575
|
+
const colRest = dragCol ? fullColumnIdData[dragCol.id] : null
|
|
3576
|
+
let defPos: 'left' | 'right' = 'left'
|
|
3577
|
+
if (XEUtils.isNumber(targetFieldOrColumn)) {
|
|
3578
|
+
if (colRest && targetFieldOrColumn) {
|
|
3579
|
+
let currList = colRest.items
|
|
3580
|
+
let offsetIndex = colRest._index + targetFieldOrColumn
|
|
3581
|
+
if (isCrossDrag) {
|
|
3582
|
+
currList = visibleColumn
|
|
3583
|
+
offsetIndex = colRest._index + targetFieldOrColumn
|
|
3584
|
+
}
|
|
3585
|
+
if (offsetIndex > 0 && offsetIndex < currList.length - 1) {
|
|
3586
|
+
prevDragCol = currList[offsetIndex]
|
|
3587
|
+
}
|
|
3588
|
+
if (targetFieldOrColumn > 0) {
|
|
3589
|
+
defPos = 'right'
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
} else {
|
|
3593
|
+
prevDragCol = handleFieldOrColumn($xeTable, targetFieldOrColumn)
|
|
3594
|
+
const targetColRest = prevDragCol ? fullColumnIdData[prevDragCol.id] : null
|
|
3595
|
+
if (colRest && targetColRest) {
|
|
3596
|
+
if (targetColRest._index > colRest._index) {
|
|
3597
|
+
defPos = 'right'
|
|
3598
|
+
}
|
|
3599
|
+
}
|
|
3600
|
+
}
|
|
3601
|
+
return $xeTable.handleColDragSwapEvent(null, true, dragCol, prevDragCol, dragPos || defPos, dragToChild === true)
|
|
3602
|
+
},
|
|
3603
|
+
/**
|
|
3604
|
+
* 移动行到指定行的位置
|
|
3605
|
+
* @param rowidOrRow
|
|
3606
|
+
* @param targetRowidOrRow
|
|
3607
|
+
* @param options
|
|
3608
|
+
*/
|
|
3609
|
+
moveRowTo (rowidOrRow: any, targetRowidOrRow: any, options?: {
|
|
3610
|
+
isCrossDrag?: boolean
|
|
3611
|
+
dragToChild?: boolean;
|
|
3612
|
+
dragPos?: 'top' | 'bottom' | '' | null;
|
|
3613
|
+
}) {
|
|
3614
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3615
|
+
const props = $xeTable
|
|
3616
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3617
|
+
|
|
3618
|
+
const { treeConfig } = props
|
|
3619
|
+
const { fullAllDataRowIdData, afterFullData } = internalData
|
|
3620
|
+
const { dragToChild, dragPos, isCrossDrag } = Object.assign({}, options)
|
|
3621
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
3622
|
+
const dragRow = handleRowidOrRow($xeTable, rowidOrRow)
|
|
3623
|
+
let prevDragRow: any = null
|
|
3624
|
+
let defPos: 'top' | 'bottom' = 'top'
|
|
3625
|
+
const rowRest = dragRow ? fullAllDataRowIdData[getRowid($xeTable, dragRow)] : null
|
|
3626
|
+
if (XEUtils.isNumber(targetRowidOrRow)) {
|
|
3627
|
+
if (rowRest && targetRowidOrRow) {
|
|
3628
|
+
let currList = afterFullData
|
|
3629
|
+
let offsetIndex = rowRest._index + targetRowidOrRow
|
|
3630
|
+
if (treeConfig) {
|
|
3631
|
+
currList = rowRest.items
|
|
3632
|
+
if (treeOpts.transform) {
|
|
3633
|
+
offsetIndex = rowRest.treeIndex + targetRowidOrRow
|
|
3634
|
+
if (isCrossDrag) {
|
|
3635
|
+
currList = afterFullData
|
|
3636
|
+
offsetIndex = rowRest._index + targetRowidOrRow
|
|
3637
|
+
}
|
|
3638
|
+
}
|
|
3639
|
+
}
|
|
3640
|
+
if (offsetIndex >= 0 && offsetIndex <= currList.length - 1) {
|
|
3641
|
+
prevDragRow = currList[offsetIndex]
|
|
3642
|
+
}
|
|
3643
|
+
if (targetRowidOrRow > 0) {
|
|
3644
|
+
defPos = 'bottom'
|
|
3645
|
+
}
|
|
3646
|
+
}
|
|
3647
|
+
} else {
|
|
3648
|
+
prevDragRow = handleRowidOrRow($xeTable, targetRowidOrRow)
|
|
3649
|
+
const targetRowRest = prevDragRow ? fullAllDataRowIdData[getRowid($xeTable, prevDragRow)] : null
|
|
3650
|
+
if (rowRest && targetRowRest) {
|
|
3651
|
+
if (targetRowRest._index > rowRest._index) {
|
|
3652
|
+
defPos = 'bottom'
|
|
3653
|
+
}
|
|
3654
|
+
}
|
|
3655
|
+
}
|
|
3656
|
+
return $xeTable.handleRowDragSwapEvent(null, true, dragRow, prevDragRow, dragPos || defPos, dragToChild === true)
|
|
3657
|
+
},
|
|
3658
|
+
/**
|
|
3659
|
+
* 获取表格的全量列
|
|
3371
3660
|
*/
|
|
3372
3661
|
getFullColumns () {
|
|
3373
3662
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
@@ -3386,21 +3675,28 @@ const Methods = {
|
|
|
3386
3675
|
/**
|
|
3387
3676
|
* 用于多选行,获取已选中的数据
|
|
3388
3677
|
*/
|
|
3389
|
-
getCheckboxRecords (isFull:
|
|
3390
|
-
const
|
|
3678
|
+
getCheckboxRecords (isFull: boolean) {
|
|
3679
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3680
|
+
const props = $xeTable
|
|
3681
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
3682
|
+
|
|
3683
|
+
const { treeConfig } = props
|
|
3684
|
+
const { tableFullData, afterFullData, afterTreeFullData, tableFullTreeData, fullDataRowIdData, afterFullRowMaps, selectCheckboxMaps } = internalData
|
|
3685
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
3686
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
3391
3687
|
const { transform, mapChildrenField } = treeOpts
|
|
3392
3688
|
const { checkField } = checkboxOpts
|
|
3393
3689
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
3394
|
-
|
|
3395
|
-
let rowList = []
|
|
3690
|
+
let rowList: any[] = []
|
|
3396
3691
|
if (checkField) {
|
|
3397
3692
|
if (treeConfig) {
|
|
3693
|
+
const currTableData = isFull ? (transform ? tableFullTreeData : tableFullData) : (transform ? afterTreeFullData : afterFullData)
|
|
3398
3694
|
rowList = XEUtils.filterTree(currTableData, row => XEUtils.get(row, checkField), { children: transform ? mapChildrenField : childrenField })
|
|
3399
3695
|
} else {
|
|
3400
|
-
|
|
3696
|
+
const currTableData = isFull ? tableFullData : afterFullData
|
|
3697
|
+
rowList = currTableData.filter((row) => XEUtils.get(row, checkField))
|
|
3401
3698
|
}
|
|
3402
3699
|
} else {
|
|
3403
|
-
const { selectCheckboxMaps, fullDataRowIdData } = this
|
|
3404
3700
|
XEUtils.each(selectCheckboxMaps, (row, rowid) => {
|
|
3405
3701
|
if (isFull) {
|
|
3406
3702
|
if (fullDataRowIdData[rowid]) {
|
|
@@ -3722,6 +4018,8 @@ const Methods = {
|
|
|
3722
4018
|
* 默认执行一次,除非被重置
|
|
3723
4019
|
*/
|
|
3724
4020
|
handleLoadDefaults () {
|
|
4021
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
4022
|
+
|
|
3725
4023
|
if (this.checkboxConfig) {
|
|
3726
4024
|
this.handleDefaultSelectionChecked()
|
|
3727
4025
|
}
|
|
@@ -3732,7 +4030,7 @@ const Methods = {
|
|
|
3732
4030
|
this.handleDefaultRowExpand()
|
|
3733
4031
|
}
|
|
3734
4032
|
if (this.treeConfig) {
|
|
3735
|
-
|
|
4033
|
+
handleDefaultTreeExpand($xeTable)
|
|
3736
4034
|
}
|
|
3737
4035
|
if (this.mergeCells) {
|
|
3738
4036
|
this.handleDefaultMergeCells()
|
|
@@ -3756,7 +4054,7 @@ const Methods = {
|
|
|
3756
4054
|
* 设置为固定列
|
|
3757
4055
|
*/
|
|
3758
4056
|
setColumnFixed (fieldOrColumn: any, fixed: any) {
|
|
3759
|
-
const $xeTable = this
|
|
4057
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
3760
4058
|
|
|
3761
4059
|
let status = false
|
|
3762
4060
|
const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
|
|
@@ -4002,13 +4300,25 @@ const Methods = {
|
|
|
4002
4300
|
}
|
|
4003
4301
|
},
|
|
4004
4302
|
getCustomStoreData () {
|
|
4005
|
-
const
|
|
4006
|
-
const
|
|
4007
|
-
const
|
|
4008
|
-
|
|
4009
|
-
const
|
|
4010
|
-
const
|
|
4011
|
-
const
|
|
4303
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
4304
|
+
const props = $xeTable
|
|
4305
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
4306
|
+
|
|
4307
|
+
const { id } = props
|
|
4308
|
+
const customOpts = $xeTable.computeCustomOpts
|
|
4309
|
+
const { collectColumn } = internalData
|
|
4310
|
+
const { storage, checkMethod } = customOpts
|
|
4311
|
+
const isAllCustom = storage === true
|
|
4312
|
+
const storageOpts: VxeTableDefines.VxeTableCustomStorageObj = isAllCustom ? {} : Object.assign({}, storage || {})
|
|
4313
|
+
const isCustomResizable = isAllCustom || storageOpts.resizable
|
|
4314
|
+
const isCustomVisible = isAllCustom || storageOpts.visible
|
|
4315
|
+
const isCustomFixed = isAllCustom || storageOpts.fixed
|
|
4316
|
+
const isCustomSort = isAllCustom || storageOpts.sort
|
|
4317
|
+
const resizableData: Record<string, number> = {}
|
|
4318
|
+
const sortData: Record<string, number> = {}
|
|
4319
|
+
const visibleData: Record<string, boolean> = {}
|
|
4320
|
+
const fixedData: Record<string, VxeColumnPropTypes.Fixed> = {}
|
|
4321
|
+
const storeData: VxeTableDefines.CustomStoreData = {
|
|
4012
4322
|
resizableData: undefined,
|
|
4013
4323
|
sortData: undefined,
|
|
4014
4324
|
visibleData: undefined,
|
|
@@ -4020,46 +4330,36 @@ const Methods = {
|
|
|
4020
4330
|
}
|
|
4021
4331
|
let hasResizable = 0
|
|
4022
4332
|
let hasSort = 0
|
|
4023
|
-
let
|
|
4333
|
+
let hasFixed = 0
|
|
4024
4334
|
let hasVisible = 0
|
|
4025
4335
|
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
4336
|
+
const colKey = column.getKey()
|
|
4337
|
+
if (!colKey) {
|
|
4338
|
+
errLog('vxe.error.reqProp', [`${column.getTitle() || column.type || ''} -> column.field=?`])
|
|
4339
|
+
return
|
|
4340
|
+
}
|
|
4026
4341
|
// 只支持一级
|
|
4027
4342
|
if (!parentColumn) {
|
|
4028
|
-
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
hasSort = 1
|
|
4032
|
-
sortData[colKey] = column.renderSortNumber
|
|
4033
|
-
}
|
|
4034
|
-
})
|
|
4035
|
-
if (column.fixed !== column.defaultFixed) {
|
|
4036
|
-
const colKey = column.getKey()
|
|
4037
|
-
if (colKey) {
|
|
4038
|
-
hasFixedt = 1
|
|
4039
|
-
fixedData[colKey] = column.fixed
|
|
4040
|
-
}
|
|
4343
|
+
if (isCustomSort) {
|
|
4344
|
+
hasSort = 1
|
|
4345
|
+
sortData[colKey] = column.renderSortNumber
|
|
4041
4346
|
}
|
|
4042
|
-
|
|
4043
|
-
|
|
4044
|
-
|
|
4045
|
-
if (colKey) {
|
|
4046
|
-
hasResizable = 1
|
|
4047
|
-
resizableData[colKey] = column.renderWidth
|
|
4347
|
+
if (isCustomFixed && column.fixed !== column.defaultFixed) {
|
|
4348
|
+
hasFixed = 1
|
|
4349
|
+
fixedData[colKey] = column.fixed
|
|
4048
4350
|
}
|
|
4049
4351
|
}
|
|
4050
|
-
if (
|
|
4352
|
+
if (isCustomResizable && column.resizeWidth) {
|
|
4353
|
+
hasResizable = 1
|
|
4354
|
+
resizableData[colKey] = column.renderWidth
|
|
4355
|
+
}
|
|
4356
|
+
if (isCustomVisible && (!checkMethod || checkMethod({ column }))) {
|
|
4051
4357
|
if (!column.visible && column.defaultVisible) {
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
hasVisible = 1
|
|
4055
|
-
visibleData[colKey] = false
|
|
4056
|
-
}
|
|
4358
|
+
hasVisible = 1
|
|
4359
|
+
visibleData[colKey] = false
|
|
4057
4360
|
} else if (column.visible && !column.defaultVisible) {
|
|
4058
|
-
|
|
4059
|
-
|
|
4060
|
-
hasVisible = 1
|
|
4061
|
-
visibleData[colKey] = true
|
|
4062
|
-
}
|
|
4361
|
+
hasVisible = 1
|
|
4362
|
+
visibleData[colKey] = true
|
|
4063
4363
|
}
|
|
4064
4364
|
}
|
|
4065
4365
|
})
|
|
@@ -4069,7 +4369,7 @@ const Methods = {
|
|
|
4069
4369
|
if (hasSort) {
|
|
4070
4370
|
storeData.sortData = sortData
|
|
4071
4371
|
}
|
|
4072
|
-
if (
|
|
4372
|
+
if (hasFixed) {
|
|
4073
4373
|
storeData.fixedData = fixedData
|
|
4074
4374
|
}
|
|
4075
4375
|
if (hasVisible) {
|
|
@@ -4078,9 +4378,9 @@ const Methods = {
|
|
|
4078
4378
|
return storeData
|
|
4079
4379
|
},
|
|
4080
4380
|
saveCustomStore (type: any) {
|
|
4081
|
-
const $xeTable = this
|
|
4381
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
4082
4382
|
const props = $xeTable
|
|
4083
|
-
const reactData = $xeTable as TableReactData
|
|
4383
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
4084
4384
|
|
|
4085
4385
|
const { customConfig } = props
|
|
4086
4386
|
const tableId = $xeTable.computeTableId
|
|
@@ -4558,12 +4858,13 @@ const Methods = {
|
|
|
4558
4858
|
const internalData = $xeTable as unknown as TableInternalData
|
|
4559
4859
|
|
|
4560
4860
|
const { fullAllDataRowIdData, afterFullData } = internalData
|
|
4861
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
4561
4862
|
const rowOpts = $xeTable.computeRowOpts
|
|
4562
4863
|
const cellOpts = $xeTable.computeCellOpts
|
|
4563
4864
|
const defaultRowHeight = $xeTable.computeDefaultRowHeight
|
|
4564
4865
|
const rest: Record<string, number> = {}
|
|
4565
4866
|
afterFullData.forEach(row => {
|
|
4566
|
-
const rowid =
|
|
4867
|
+
const rowid = handleGetRowId(row)
|
|
4567
4868
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
4568
4869
|
if (rowRest) {
|
|
4569
4870
|
const resizeHeight = rowRest.resizeHeight
|
|
@@ -4591,8 +4892,9 @@ const Methods = {
|
|
|
4591
4892
|
rHeight = Math.floor(rHeight * bodyHeight)
|
|
4592
4893
|
}
|
|
4593
4894
|
if (rHeight) {
|
|
4895
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
4594
4896
|
rows.forEach(row => {
|
|
4595
|
-
const rowid = XEUtils.isString(row) || XEUtils.isNumber(row) ? row :
|
|
4897
|
+
const rowid = XEUtils.isString(row) || XEUtils.isNumber(row) ? row : handleGetRowId(row)
|
|
4596
4898
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
4597
4899
|
if (rowRest) {
|
|
4598
4900
|
rowRest.resizeHeight = rHeight
|
|
@@ -4752,8 +5054,21 @@ const Methods = {
|
|
|
4752
5054
|
}
|
|
4753
5055
|
// 兼容老版本
|
|
4754
5056
|
|
|
4755
|
-
let rest
|
|
4756
|
-
|
|
5057
|
+
let rest = null
|
|
5058
|
+
let isStop = false
|
|
5059
|
+
for (let i = 0; i < evntList.length; i++) {
|
|
5060
|
+
const func = evntList[i]
|
|
5061
|
+
const fnRest = func(Object.assign({ $grid: this.$xegrid, $table: this, $event: evnt }, args))
|
|
5062
|
+
if (fnRest === false) {
|
|
5063
|
+
isStop = true
|
|
5064
|
+
break
|
|
5065
|
+
} else if (fnRest && fnRest.status === false) {
|
|
5066
|
+
rest = fnRest.result
|
|
5067
|
+
isStop = true
|
|
5068
|
+
break
|
|
5069
|
+
}
|
|
5070
|
+
}
|
|
5071
|
+
if (!isStop) {
|
|
4757
5072
|
if (next) {
|
|
4758
5073
|
rest = next()
|
|
4759
5074
|
}
|
|
@@ -4943,7 +5258,8 @@ const Methods = {
|
|
|
4943
5258
|
if (this.isActivated) {
|
|
4944
5259
|
this.preventEvent(evnt, 'event.keydown', null, () => {
|
|
4945
5260
|
const { afterFullData } = internalData
|
|
4946
|
-
const { filterStore, isCtxMenu, ctxMenuStore, editStore, editOpts, editConfig, mouseConfig, mouseOpts, keyboardConfig, keyboardOpts, treeConfig, treeOpts, highlightCurrentRow, currentRow, bodyCtxMenu, rowOpts } = this
|
|
5261
|
+
const { filterStore, isCtxMenu, ctxMenuStore, editStore, editOpts, editConfig, mouseConfig, mouseOpts, keyboardConfig, keyboardOpts, treeConfig, treeOpts, highlightCurrentRow, highlightCurrentColumn, currentRow, bodyCtxMenu, rowOpts } = this
|
|
5262
|
+
const columnOpts = $xeTable.computeColumnOpts
|
|
4947
5263
|
const { selected, actived } = editStore
|
|
4948
5264
|
const { keyCode } = evnt
|
|
4949
5265
|
const hasBackspaceKey = keyCode === 8
|
|
@@ -5084,10 +5400,15 @@ const Methods = {
|
|
|
5084
5400
|
if (!isEditStatus) {
|
|
5085
5401
|
// 如果按下了方向键
|
|
5086
5402
|
if (selected.row && selected.column) {
|
|
5087
|
-
|
|
5088
|
-
}
|
|
5089
|
-
|
|
5090
|
-
|
|
5403
|
+
$xeTable.moveSelected(selected.args, isLeftArrow, isUpArrow, isRightArrow, isDwArrow, evnt)
|
|
5404
|
+
}
|
|
5405
|
+
// 当前行按键上下移动
|
|
5406
|
+
if ((isUpArrow || isDwArrow) && (rowOpts.isCurrent || highlightCurrentRow)) {
|
|
5407
|
+
$xeTable.moveCurrentRow(isUpArrow, isDwArrow, evnt)
|
|
5408
|
+
}
|
|
5409
|
+
// 当前行按键左右移动
|
|
5410
|
+
if ((isLeftArrow || isRightArrow) && (columnOpts.isCurrent || highlightCurrentColumn)) {
|
|
5411
|
+
$xeTable.moveCurrentColumn(isLeftArrow, isRightArrow, evnt)
|
|
5091
5412
|
}
|
|
5092
5413
|
}
|
|
5093
5414
|
} else if (isTab && keyboardConfig && keyboardOpts.isTab) {
|
|
@@ -5406,11 +5727,16 @@ const Methods = {
|
|
|
5406
5727
|
* 获取复选框半选状态的行数据
|
|
5407
5728
|
*/
|
|
5408
5729
|
getCheckboxIndeterminateRecords (isFull: any) {
|
|
5409
|
-
const
|
|
5730
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5731
|
+
const props = $xeTable
|
|
5732
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5733
|
+
|
|
5734
|
+
const { treeConfig } = props
|
|
5735
|
+
const { fullDataRowIdData, treeIndeterminateRowMaps } = internalData
|
|
5410
5736
|
if (treeConfig) {
|
|
5411
5737
|
const fullRest: any[] = []
|
|
5412
5738
|
const defRest: any[] = []
|
|
5413
|
-
XEUtils.each(
|
|
5739
|
+
XEUtils.each(treeIndeterminateRowMaps, (item, rowid) => {
|
|
5414
5740
|
if (item) {
|
|
5415
5741
|
fullRest.push(item)
|
|
5416
5742
|
if (fullDataRowIdData[rowid]) {
|
|
@@ -5465,7 +5791,7 @@ const Methods = {
|
|
|
5465
5791
|
},
|
|
5466
5792
|
setCheckboxRowKey (keys: any, checked: boolean) {
|
|
5467
5793
|
const $xeTable = this
|
|
5468
|
-
const internalData = $xeTable
|
|
5794
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5469
5795
|
|
|
5470
5796
|
const { fullAllDataRowIdData } = internalData
|
|
5471
5797
|
if (keys && !XEUtils.isArray(keys)) {
|
|
@@ -5482,23 +5808,25 @@ const Methods = {
|
|
|
5482
5808
|
},
|
|
5483
5809
|
isCheckedByCheckboxRow (row: any) {
|
|
5484
5810
|
const $xeTable = this
|
|
5485
|
-
const reactData = $xeTable
|
|
5811
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
5812
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5486
5813
|
|
|
5487
|
-
const {
|
|
5814
|
+
const { updateCheckboxFlag } = reactData
|
|
5815
|
+
const { selectCheckboxMaps } = internalData
|
|
5488
5816
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5489
5817
|
const { checkField } = checkboxOpts
|
|
5490
5818
|
if (checkField) {
|
|
5491
5819
|
return XEUtils.get(row, checkField)
|
|
5492
5820
|
}
|
|
5493
|
-
return !!selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5821
|
+
return !!updateCheckboxFlag && !!selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5494
5822
|
},
|
|
5495
5823
|
isCheckedByCheckboxRowKey (rowid: string) {
|
|
5496
|
-
const $xeTable = this
|
|
5497
|
-
const reactData = $xeTable
|
|
5498
|
-
const internalData = $xeTable
|
|
5824
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5825
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
5826
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5499
5827
|
|
|
5500
|
-
const {
|
|
5501
|
-
const { fullAllDataRowIdData } = internalData
|
|
5828
|
+
const { updateCheckboxFlag } = reactData
|
|
5829
|
+
const { fullAllDataRowIdData, selectCheckboxMaps } = internalData
|
|
5502
5830
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5503
5831
|
const { checkField } = checkboxOpts
|
|
5504
5832
|
if (checkField) {
|
|
@@ -5508,21 +5836,21 @@ const Methods = {
|
|
|
5508
5836
|
}
|
|
5509
5837
|
return false
|
|
5510
5838
|
}
|
|
5511
|
-
return !!selectCheckboxMaps[rowid]
|
|
5839
|
+
return !!updateCheckboxFlag && !!selectCheckboxMaps[rowid]
|
|
5512
5840
|
},
|
|
5513
5841
|
isIndeterminateByCheckboxRow (row: any) {
|
|
5514
|
-
const $xeTable = this
|
|
5515
|
-
const
|
|
5842
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5843
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5516
5844
|
|
|
5517
|
-
const {
|
|
5518
|
-
return !!
|
|
5845
|
+
const { treeIndeterminateRowMaps } = internalData
|
|
5846
|
+
return !!treeIndeterminateRowMaps[getRowid($xeTable, row)] && !$xeTable.isCheckedByCheckboxRow(row)
|
|
5519
5847
|
},
|
|
5520
5848
|
isIndeterminateByCheckboxRowKey (rowid: string) {
|
|
5521
5849
|
const $xeTable = this
|
|
5522
|
-
const
|
|
5850
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5523
5851
|
|
|
5524
|
-
const {
|
|
5525
|
-
return !!
|
|
5852
|
+
const { treeIndeterminateRowMaps } = internalData
|
|
5853
|
+
return !!treeIndeterminateRowMaps[rowid] && !$xeTable.isCheckedByCheckboxRowKey(rowid)
|
|
5526
5854
|
},
|
|
5527
5855
|
/**
|
|
5528
5856
|
* 切换选中
|
|
@@ -5532,15 +5860,17 @@ const Methods = {
|
|
|
5532
5860
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5533
5861
|
const props = $xeTable
|
|
5534
5862
|
const reactData = $xeTable as unknown as TableReactData
|
|
5863
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5535
5864
|
|
|
5536
5865
|
const { treeConfig } = props
|
|
5537
|
-
const { selectCheckboxMaps } =
|
|
5538
|
-
const selectRowMaps = Object.assign({}, selectCheckboxMaps)
|
|
5866
|
+
const { selectCheckboxMaps } = internalData
|
|
5539
5867
|
const treeOpts = $xeTable.computeTreeOpts
|
|
5540
5868
|
const { transform, mapChildrenField } = treeOpts
|
|
5541
5869
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
5542
5870
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5543
5871
|
const { checkField, checkStrictly, checkMethod } = checkboxOpts
|
|
5872
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
5873
|
+
// indeterminateField 仅支持读取
|
|
5544
5874
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
5545
5875
|
if (checkField) {
|
|
5546
5876
|
// 树结构
|
|
@@ -5555,18 +5885,17 @@ const Methods = {
|
|
|
5555
5885
|
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5556
5886
|
}
|
|
5557
5887
|
}, { children: transform ? mapChildrenField : childrenField })
|
|
5558
|
-
reactData.
|
|
5888
|
+
reactData.updateCheckboxFlag++
|
|
5559
5889
|
return
|
|
5560
|
-
} else {
|
|
5561
|
-
// 列表
|
|
5562
|
-
rows.forEach(row => {
|
|
5563
|
-
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5564
|
-
XEUtils.set(row, checkField, checked)
|
|
5565
|
-
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5566
|
-
}
|
|
5567
|
-
})
|
|
5568
5890
|
}
|
|
5569
|
-
|
|
5891
|
+
// 列表
|
|
5892
|
+
rows.forEach(row => {
|
|
5893
|
+
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5894
|
+
XEUtils.set(row, checkField, checked)
|
|
5895
|
+
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5896
|
+
}
|
|
5897
|
+
})
|
|
5898
|
+
reactData.updateCheckboxFlag++
|
|
5570
5899
|
return
|
|
5571
5900
|
}
|
|
5572
5901
|
|
|
@@ -5574,51 +5903,55 @@ const Methods = {
|
|
|
5574
5903
|
if (treeConfig && !checkStrictly) {
|
|
5575
5904
|
// 更新子节点状态
|
|
5576
5905
|
XEUtils.eachTree(rows, (row) => {
|
|
5577
|
-
const rowid =
|
|
5906
|
+
const rowid = handleGetRowId(row)
|
|
5578
5907
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5579
5908
|
if (checked) {
|
|
5580
|
-
|
|
5909
|
+
selectCheckboxMaps[rowid] = row
|
|
5581
5910
|
} else {
|
|
5582
|
-
if (
|
|
5583
|
-
delete
|
|
5911
|
+
if (selectCheckboxMaps[rowid]) {
|
|
5912
|
+
delete selectCheckboxMaps[rowid]
|
|
5584
5913
|
}
|
|
5585
5914
|
}
|
|
5586
5915
|
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5587
5916
|
}
|
|
5588
5917
|
}, { children: transform ? mapChildrenField : childrenField })
|
|
5589
|
-
reactData.
|
|
5918
|
+
reactData.updateCheckboxFlag++
|
|
5590
5919
|
return
|
|
5591
5920
|
}
|
|
5592
5921
|
|
|
5593
5922
|
// 列表
|
|
5594
5923
|
rows.forEach(row => {
|
|
5595
|
-
const rowid =
|
|
5924
|
+
const rowid = handleGetRowId(row)
|
|
5596
5925
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
5597
5926
|
if (checked) {
|
|
5598
|
-
if (!
|
|
5599
|
-
|
|
5927
|
+
if (!selectCheckboxMaps[rowid]) {
|
|
5928
|
+
selectCheckboxMaps[rowid] = row
|
|
5600
5929
|
}
|
|
5601
5930
|
} else {
|
|
5602
|
-
if (
|
|
5603
|
-
delete
|
|
5931
|
+
if (selectCheckboxMaps[rowid]) {
|
|
5932
|
+
delete selectCheckboxMaps[rowid]
|
|
5604
5933
|
}
|
|
5605
5934
|
}
|
|
5606
5935
|
handleCheckboxReserveRow($xeTable, row, checked)
|
|
5936
|
+
reactData.updateCheckboxFlag++
|
|
5607
5937
|
}
|
|
5608
5938
|
})
|
|
5609
|
-
reactData.selectCheckboxMaps = selectRowMaps
|
|
5610
5939
|
},
|
|
5611
5940
|
/**
|
|
5612
5941
|
* 即将移除
|
|
5613
5942
|
* @deprecated
|
|
5614
5943
|
*/
|
|
5615
5944
|
handleSelectRow ({ row }: any, checked: boolean, isForce?: boolean) {
|
|
5616
|
-
const $xeTable = this
|
|
5945
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5617
5946
|
|
|
5618
5947
|
$xeTable.handleBatchSelectRows([row], checked, isForce)
|
|
5619
5948
|
},
|
|
5620
5949
|
handleToggleCheckRowEvent (evnt: any, params: any) {
|
|
5621
|
-
const
|
|
5950
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5951
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5952
|
+
|
|
5953
|
+
const { selectCheckboxMaps } = internalData
|
|
5954
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5622
5955
|
const { checkField, trigger } = checkboxOpts
|
|
5623
5956
|
const { row } = params
|
|
5624
5957
|
if (trigger === 'manual') {
|
|
@@ -5628,47 +5961,52 @@ const Methods = {
|
|
|
5628
5961
|
if (checkField) {
|
|
5629
5962
|
checked = !XEUtils.get(row, checkField)
|
|
5630
5963
|
} else {
|
|
5631
|
-
checked = !selectCheckboxMaps[getRowid(
|
|
5964
|
+
checked = !selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5632
5965
|
}
|
|
5633
5966
|
if (evnt) {
|
|
5634
|
-
|
|
5967
|
+
$xeTable.triggerCheckRowEvent(evnt, params, checked)
|
|
5635
5968
|
} else {
|
|
5636
|
-
|
|
5637
|
-
|
|
5969
|
+
$xeTable.handleBatchSelectRows([row], checked)
|
|
5970
|
+
$xeTable.checkSelectionStatus()
|
|
5638
5971
|
}
|
|
5639
5972
|
},
|
|
5640
5973
|
triggerCheckRowEvent (evnt: any, params: any, checked: any) {
|
|
5641
|
-
const $xeTable = this
|
|
5974
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
5975
|
+
const props = $xeTable
|
|
5976
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5642
5977
|
|
|
5643
|
-
const { checkboxOpts, afterFullData } = this
|
|
5644
|
-
const { checkMethod, trigger } = checkboxOpts
|
|
5645
5978
|
const { row } = params
|
|
5979
|
+
const { afterFullData } = internalData
|
|
5980
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5981
|
+
const { checkMethod, trigger } = checkboxOpts
|
|
5646
5982
|
if (trigger === 'manual') {
|
|
5647
5983
|
return
|
|
5648
5984
|
}
|
|
5649
5985
|
evnt.stopPropagation()
|
|
5650
|
-
if (checkboxOpts.isShiftKey && evnt.shiftKey && !
|
|
5651
|
-
const checkboxRecords =
|
|
5986
|
+
if (checkboxOpts.isShiftKey && evnt.shiftKey && !props.treeConfig) {
|
|
5987
|
+
const checkboxRecords = $xeTable.getCheckboxRecords()
|
|
5652
5988
|
if (checkboxRecords.length) {
|
|
5653
5989
|
const firstRow = checkboxRecords[0]
|
|
5654
|
-
const _rowIndex =
|
|
5655
|
-
const _firstRowIndex =
|
|
5990
|
+
const _rowIndex = $xeTable.getVTRowIndex(row)
|
|
5991
|
+
const _firstRowIndex = $xeTable.getVTRowIndex(firstRow)
|
|
5656
5992
|
if (_rowIndex !== _firstRowIndex) {
|
|
5657
|
-
|
|
5993
|
+
$xeTable.setAllCheckboxRow(false)
|
|
5658
5994
|
const rangeRows = _rowIndex < _firstRowIndex ? afterFullData.slice(_rowIndex, _firstRowIndex + 1) : afterFullData.slice(_firstRowIndex, _rowIndex + 1)
|
|
5659
|
-
|
|
5660
|
-
|
|
5995
|
+
$xeTable.$nextTick(() => {
|
|
5996
|
+
handleCheckedCheckboxRow($xeTable, rangeRows, true, false)
|
|
5997
|
+
})
|
|
5998
|
+
$xeTable.dispatchEvent('checkbox-range-select', Object.assign({ rangeRecords: rangeRows }, params), evnt)
|
|
5661
5999
|
return
|
|
5662
6000
|
}
|
|
5663
6001
|
}
|
|
5664
6002
|
}
|
|
5665
6003
|
if (!checkMethod || checkMethod({ row })) {
|
|
5666
|
-
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
records:
|
|
5670
|
-
reserves:
|
|
5671
|
-
indeterminates:
|
|
6004
|
+
$xeTable.handleBatchSelectRows([row], checked)
|
|
6005
|
+
$xeTable.checkSelectionStatus()
|
|
6006
|
+
$xeTable.dispatchEvent('checkbox-change', Object.assign({
|
|
6007
|
+
records: () => $xeTable.getCheckboxRecords(),
|
|
6008
|
+
reserves: () => $xeTable.getCheckboxReserveRecords(),
|
|
6009
|
+
indeterminates: () => $xeTable.getCheckboxIndeterminateRecords(),
|
|
5672
6010
|
checked
|
|
5673
6011
|
}, params), evnt)
|
|
5674
6012
|
}
|
|
@@ -5677,9 +6015,11 @@ const Methods = {
|
|
|
5677
6015
|
* 多选,切换某一行的选中状态
|
|
5678
6016
|
*/
|
|
5679
6017
|
toggleCheckboxRow (row: any) {
|
|
5680
|
-
const $xeTable = this
|
|
6018
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6019
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
5681
6020
|
|
|
5682
|
-
const { selectCheckboxMaps
|
|
6021
|
+
const { selectCheckboxMaps } = internalData
|
|
6022
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5683
6023
|
const { checkField } = checkboxOpts
|
|
5684
6024
|
const checked = checkField ? !XEUtils.get(row, checkField) : !selectCheckboxMaps[getRowid($xeTable, row)]
|
|
5685
6025
|
$xeTable.handleBatchSelectRows([row], checked, true)
|
|
@@ -5702,9 +6042,7 @@ const Methods = {
|
|
|
5702
6042
|
const internalData = $xeTable as unknown as TableInternalData
|
|
5703
6043
|
|
|
5704
6044
|
const { treeConfig } = props
|
|
5705
|
-
const { selectCheckboxMaps,
|
|
5706
|
-
const selectRowMaps = Object.assign({}, selectCheckboxMaps)
|
|
5707
|
-
const halfRowMaps = Object.assign({}, treeIndeterminateMaps)
|
|
6045
|
+
const { selectCheckboxMaps, treeIndeterminateRowMaps } = internalData
|
|
5708
6046
|
const treeOpts = $xeTable.computeTreeOpts
|
|
5709
6047
|
const { transform, mapChildrenField } = treeOpts
|
|
5710
6048
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
@@ -5716,10 +6054,11 @@ const Methods = {
|
|
|
5716
6054
|
}
|
|
5717
6055
|
// 树结构
|
|
5718
6056
|
if (treeConfig) {
|
|
6057
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
5719
6058
|
const childRowMaps: Record<string, number> = {}
|
|
5720
6059
|
const childRowList: any[][] = []
|
|
5721
6060
|
XEUtils.eachTree(afterTreeFullData, (row: any) => {
|
|
5722
|
-
const rowid =
|
|
6061
|
+
const rowid = handleGetRowId(row)
|
|
5723
6062
|
const childList = row[transform ? mapChildrenField : childrenField]
|
|
5724
6063
|
if (childList && childList.length && !childRowMaps[rowid]) {
|
|
5725
6064
|
childRowMaps[rowid] = 1
|
|
@@ -5736,29 +6075,29 @@ const Methods = {
|
|
|
5736
6075
|
childList.forEach(
|
|
5737
6076
|
checkMethod
|
|
5738
6077
|
? (item) => {
|
|
5739
|
-
const childRowid =
|
|
5740
|
-
const isSelect = checkField ? XEUtils.get(item, checkField) :
|
|
6078
|
+
const childRowid = handleGetRowId(item)
|
|
6079
|
+
const isSelect = checkField ? XEUtils.get(item, checkField) : selectCheckboxMaps[childRowid]
|
|
5741
6080
|
if (checkMethod({ row: item })) {
|
|
5742
6081
|
if (isSelect) {
|
|
5743
6082
|
sLen++
|
|
5744
|
-
} else if (
|
|
6083
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5745
6084
|
hLen++
|
|
5746
6085
|
}
|
|
5747
6086
|
vLen++
|
|
5748
6087
|
} else {
|
|
5749
6088
|
if (isSelect) {
|
|
5750
6089
|
sLen++
|
|
5751
|
-
} else if (
|
|
6090
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5752
6091
|
hLen++
|
|
5753
6092
|
}
|
|
5754
6093
|
}
|
|
5755
6094
|
}
|
|
5756
6095
|
: item => {
|
|
5757
|
-
const childRowid =
|
|
5758
|
-
const isSelect = checkField ? XEUtils.get(item, checkField) :
|
|
6096
|
+
const childRowid = handleGetRowId(item)
|
|
6097
|
+
const isSelect = checkField ? XEUtils.get(item, checkField) : selectCheckboxMaps[childRowid]
|
|
5759
6098
|
if (isSelect) {
|
|
5760
6099
|
sLen++
|
|
5761
|
-
} else if (
|
|
6100
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5762
6101
|
hLen++
|
|
5763
6102
|
}
|
|
5764
6103
|
vLen++
|
|
@@ -5771,29 +6110,28 @@ const Methods = {
|
|
|
5771
6110
|
}
|
|
5772
6111
|
if (isSelected) {
|
|
5773
6112
|
if (!checkField) {
|
|
5774
|
-
|
|
6113
|
+
selectCheckboxMaps[rowid] = row
|
|
5775
6114
|
}
|
|
5776
|
-
if (
|
|
5777
|
-
delete
|
|
6115
|
+
if (treeIndeterminateRowMaps[rowid]) {
|
|
6116
|
+
delete treeIndeterminateRowMaps[rowid]
|
|
5778
6117
|
}
|
|
5779
6118
|
} else {
|
|
5780
6119
|
if (!checkField) {
|
|
5781
|
-
if (
|
|
5782
|
-
delete
|
|
6120
|
+
if (selectCheckboxMaps[rowid]) {
|
|
6121
|
+
delete selectCheckboxMaps[rowid]
|
|
5783
6122
|
}
|
|
5784
6123
|
}
|
|
5785
6124
|
if (halfSelect) {
|
|
5786
|
-
|
|
6125
|
+
treeIndeterminateRowMaps[rowid] = row
|
|
5787
6126
|
} else {
|
|
5788
|
-
if (
|
|
5789
|
-
delete
|
|
6127
|
+
if (treeIndeterminateRowMaps[rowid]) {
|
|
6128
|
+
delete treeIndeterminateRowMaps[rowid]
|
|
5790
6129
|
}
|
|
5791
6130
|
}
|
|
5792
6131
|
}
|
|
5793
6132
|
})
|
|
5794
6133
|
}
|
|
5795
|
-
reactData.
|
|
5796
|
-
reactData.treeIndeterminateMaps = halfRowMaps
|
|
6134
|
+
reactData.updateCheckboxFlag++
|
|
5797
6135
|
},
|
|
5798
6136
|
updateAllCheckboxStatus () {
|
|
5799
6137
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
@@ -5802,10 +6140,10 @@ const Methods = {
|
|
|
5802
6140
|
const internalData = $xeTable as unknown as TableInternalData
|
|
5803
6141
|
|
|
5804
6142
|
const { treeConfig } = props
|
|
5805
|
-
const { selectCheckboxMaps,
|
|
6143
|
+
const { afterFullData, afterTreeFullData, checkboxReserveRowMap, selectCheckboxMaps, treeIndeterminateRowMaps } = internalData
|
|
5806
6144
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
5807
6145
|
const { checkField, checkMethod, showReserveStatus } = checkboxOpts
|
|
5808
|
-
const {
|
|
6146
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
5809
6147
|
|
|
5810
6148
|
let sLen = 0 // 已选
|
|
5811
6149
|
let hLen = 0 // 半选
|
|
@@ -5814,29 +6152,29 @@ const Methods = {
|
|
|
5814
6152
|
const rootList: any[] = (treeConfig ? afterTreeFullData : afterFullData)
|
|
5815
6153
|
rootList.forEach(checkMethod
|
|
5816
6154
|
? row => {
|
|
5817
|
-
const childRowid =
|
|
6155
|
+
const childRowid = handleGetRowId(row)
|
|
5818
6156
|
const selected = checkField ? XEUtils.get(row, checkField) : selectCheckboxMaps[childRowid]
|
|
5819
6157
|
if (checkMethod({ row })) {
|
|
5820
6158
|
if (selected) {
|
|
5821
6159
|
sLen++
|
|
5822
|
-
} else if (
|
|
6160
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5823
6161
|
hLen++
|
|
5824
6162
|
}
|
|
5825
6163
|
vLen++
|
|
5826
6164
|
} else {
|
|
5827
6165
|
if (selected) {
|
|
5828
6166
|
sLen++
|
|
5829
|
-
} else if (
|
|
6167
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5830
6168
|
hLen++
|
|
5831
6169
|
}
|
|
5832
6170
|
}
|
|
5833
6171
|
}
|
|
5834
6172
|
: row => {
|
|
5835
|
-
const childRowid =
|
|
6173
|
+
const childRowid = handleGetRowId(row)
|
|
5836
6174
|
const selected = checkField ? XEUtils.get(row, checkField) : selectCheckboxMaps[childRowid]
|
|
5837
6175
|
if (selected) {
|
|
5838
6176
|
sLen++
|
|
5839
|
-
} else if (
|
|
6177
|
+
} else if (treeIndeterminateRowMaps[childRowid]) {
|
|
5840
6178
|
hLen++
|
|
5841
6179
|
}
|
|
5842
6180
|
vLen++
|
|
@@ -5895,18 +6233,26 @@ const Methods = {
|
|
|
5895
6233
|
* 获取复选框保留选中的行
|
|
5896
6234
|
*/
|
|
5897
6235
|
getCheckboxReserveRecords (isFull: any) {
|
|
5898
|
-
const
|
|
6236
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6237
|
+
const props = $xeTable
|
|
6238
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
6239
|
+
|
|
6240
|
+
const { treeConfig } = props
|
|
6241
|
+
const { afterFullData, fullDataRowIdData, checkboxReserveRowMap } = internalData
|
|
6242
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
6243
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
5899
6244
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
5900
6245
|
const reserveSelection: any[] = []
|
|
5901
6246
|
if (checkboxOpts.reserve) {
|
|
5902
|
-
const
|
|
6247
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
6248
|
+
const afterFullIdMaps: { [key: string]: number } = {}
|
|
5903
6249
|
if (treeConfig) {
|
|
5904
6250
|
XEUtils.eachTree(afterFullData, row => {
|
|
5905
|
-
afterFullIdMaps[
|
|
6251
|
+
afterFullIdMaps[handleGetRowId(row)] = 1
|
|
5906
6252
|
}, { children: childrenField })
|
|
5907
6253
|
} else {
|
|
5908
6254
|
afterFullData.forEach((row: any) => {
|
|
5909
|
-
afterFullIdMaps[
|
|
6255
|
+
afterFullIdMaps[handleGetRowId(row)] = 1
|
|
5910
6256
|
})
|
|
5911
6257
|
}
|
|
5912
6258
|
XEUtils.each(checkboxReserveRowMap, (oldRow, oldRowid) => {
|
|
@@ -5946,9 +6292,9 @@ const Methods = {
|
|
|
5946
6292
|
handleCheckedAllCheckboxRow($xeTable, value)
|
|
5947
6293
|
if (evnt) {
|
|
5948
6294
|
$xeTable.dispatchEvent('checkbox-all', {
|
|
5949
|
-
records: $xeTable.getCheckboxRecords(),
|
|
5950
|
-
reserves: $xeTable.getCheckboxReserveRecords(),
|
|
5951
|
-
indeterminates: $xeTable.getCheckboxIndeterminateRecords(),
|
|
6295
|
+
records: () => $xeTable.getCheckboxRecords(),
|
|
6296
|
+
reserves: () => $xeTable.getCheckboxReserveRecords(),
|
|
6297
|
+
indeterminates: () => $xeTable.getCheckboxIndeterminateRecords(),
|
|
5952
6298
|
checked: value
|
|
5953
6299
|
}, evnt)
|
|
5954
6300
|
}
|
|
@@ -5981,9 +6327,18 @@ const Methods = {
|
|
|
5981
6327
|
* 清空行为不管是否被禁用还是保留记录,都将彻底清空选中状态
|
|
5982
6328
|
*/
|
|
5983
6329
|
clearCheckboxRow () {
|
|
5984
|
-
const
|
|
5985
|
-
const
|
|
6330
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6331
|
+
const props = $xeTable
|
|
6332
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
6333
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
6334
|
+
|
|
6335
|
+
const { treeConfig } = props
|
|
6336
|
+
const { tableFullData } = internalData
|
|
6337
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
5986
6338
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
6339
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
6340
|
+
const { checkField, reserve } = checkboxOpts
|
|
6341
|
+
// indeterminateField 仅支持读取
|
|
5987
6342
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
5988
6343
|
if (checkField) {
|
|
5989
6344
|
const handleClearChecked = (item: any) => {
|
|
@@ -5999,12 +6354,13 @@ const Methods = {
|
|
|
5999
6354
|
}
|
|
6000
6355
|
}
|
|
6001
6356
|
if (reserve) {
|
|
6002
|
-
tableFullData.forEach((row
|
|
6357
|
+
tableFullData.forEach((row) => this.handleCheckboxReserveRow(row, false))
|
|
6003
6358
|
}
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6359
|
+
reactData.isAllSelected = false
|
|
6360
|
+
reactData.isIndeterminate = false
|
|
6361
|
+
internalData.selectCheckboxMaps = {}
|
|
6362
|
+
internalData.treeIndeterminateRowMaps = {}
|
|
6363
|
+
reactData.updateCheckboxFlag++
|
|
6008
6364
|
return this.$nextTick()
|
|
6009
6365
|
},
|
|
6010
6366
|
/**
|
|
@@ -6211,11 +6567,13 @@ const Methods = {
|
|
|
6211
6567
|
},
|
|
6212
6568
|
triggerHeaderCellClickEvent (evnt: MouseEvent, params: VxeTableDefines.CellRenderHeaderParams) {
|
|
6213
6569
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6570
|
+
const props = $xeTable
|
|
6214
6571
|
const internalData = $xeTable as unknown as TableInternalData
|
|
6215
6572
|
|
|
6216
6573
|
const { _lastResizeTime } = internalData
|
|
6217
6574
|
const sortOpts = $xeTable.computeSortOpts
|
|
6218
6575
|
const columnOpts = $xeTable.computeColumnOpts
|
|
6576
|
+
const currentColumnOpts = $xeTable.computeCurrentColumnOpts
|
|
6219
6577
|
const { column } = params
|
|
6220
6578
|
const cell = evnt.currentTarget
|
|
6221
6579
|
const triggerResizable = _lastResizeTime && _lastResizeTime > Date.now() - 300
|
|
@@ -6225,7 +6583,7 @@ const Methods = {
|
|
|
6225
6583
|
$xeTable.triggerSortEvent(evnt, column, getNextSortOrder($xeTable, column))
|
|
6226
6584
|
}
|
|
6227
6585
|
$xeTable.dispatchEvent('header-cell-click', Object.assign({ triggerResizable, triggerSort, triggerFilter, cell }, params), evnt)
|
|
6228
|
-
if (columnOpts.isCurrent ||
|
|
6586
|
+
if ((columnOpts.isCurrent || props.highlightCurrentColumn) && (!currentColumnOpts.trigger || ['header', 'default'].includes(currentColumnOpts.trigger))) {
|
|
6229
6587
|
$xeTable.triggerCurrentColumnEvent(evnt, params)
|
|
6230
6588
|
}
|
|
6231
6589
|
return $xeTable.$nextTick()
|
|
@@ -6241,13 +6599,24 @@ const Methods = {
|
|
|
6241
6599
|
* @param {ColumnInfo} fieldOrColumn 列配置
|
|
6242
6600
|
*/
|
|
6243
6601
|
setCurrentColumn (fieldOrColumn: any) {
|
|
6244
|
-
const
|
|
6602
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6603
|
+
const props = $xeTable
|
|
6604
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
6605
|
+
|
|
6606
|
+
const { mouseConfig } = props
|
|
6607
|
+
const mouseOpts = $xeTable.computeMouseOpts
|
|
6608
|
+
const isMouseSelected = mouseConfig && mouseOpts.selected
|
|
6609
|
+
const column = handleFieldOrColumn($xeTable, fieldOrColumn)
|
|
6245
6610
|
if (column) {
|
|
6246
|
-
|
|
6247
|
-
|
|
6248
|
-
this.currentColumn = column
|
|
6611
|
+
$xeTable.clearCurrentColumn()
|
|
6612
|
+
reactData.currentColumn = column
|
|
6249
6613
|
}
|
|
6250
|
-
return
|
|
6614
|
+
return $xeTable.$nextTick().then(() => {
|
|
6615
|
+
// 更新状选中态
|
|
6616
|
+
if (isMouseSelected) {
|
|
6617
|
+
$xeTable.addCellSelectedClass()
|
|
6618
|
+
}
|
|
6619
|
+
})
|
|
6251
6620
|
},
|
|
6252
6621
|
/**
|
|
6253
6622
|
* 用于当前列,手动清空当前高亮的状态
|
|
@@ -6256,36 +6625,17 @@ const Methods = {
|
|
|
6256
6625
|
this.currentColumn = null
|
|
6257
6626
|
return this.$nextTick()
|
|
6258
6627
|
},
|
|
6259
|
-
checkValidate (type: any) {
|
|
6260
|
-
if (this.triggerValidate) {
|
|
6261
|
-
return this.triggerValidate(type)
|
|
6262
|
-
}
|
|
6263
|
-
return this.$nextTick()
|
|
6264
|
-
},
|
|
6265
|
-
/**
|
|
6266
|
-
* 当单元格发生改变时
|
|
6267
|
-
* 如果存在规则,则校验
|
|
6268
|
-
*/
|
|
6269
|
-
handleChangeCell (evnt: Event, params: any) {
|
|
6270
|
-
this.checkValidate('blur')
|
|
6271
|
-
.catch((e: any) => e)
|
|
6272
|
-
.then(() => {
|
|
6273
|
-
this.handleEdit(params, evnt)
|
|
6274
|
-
.then(() => this.checkValidate('change'))
|
|
6275
|
-
.catch((e: any) => e)
|
|
6276
|
-
})
|
|
6277
|
-
},
|
|
6278
6628
|
/**
|
|
6279
6629
|
* 列点击事件
|
|
6280
6630
|
* 如果是单击模式,则激活为编辑状态
|
|
6281
6631
|
* 如果是双击模式,则单击后选中状态
|
|
6282
6632
|
*/
|
|
6283
6633
|
triggerCellClickEvent (evnt: MouseEvent, params: VxeTableDefines.CellRenderBodyParams) {
|
|
6284
|
-
const $xeTable = this
|
|
6634
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6285
6635
|
const props = $xeTable
|
|
6286
|
-
const reactData = $xeTable
|
|
6636
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
6287
6637
|
|
|
6288
|
-
const { highlightCurrentRow, editConfig } = props
|
|
6638
|
+
const { highlightCurrentRow, highlightCurrentColumn, editConfig } = props
|
|
6289
6639
|
const { editStore, isDragResize } = reactData
|
|
6290
6640
|
if (isDragResize) {
|
|
6291
6641
|
return
|
|
@@ -6297,6 +6647,8 @@ const Methods = {
|
|
|
6297
6647
|
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
6298
6648
|
const keyboardOpts = $xeTable.computeKeyboardOpts
|
|
6299
6649
|
const rowOpts = $xeTable.computeRowOpts
|
|
6650
|
+
const columnOpts = $xeTable.computeColumnOpts
|
|
6651
|
+
const currentColumnOpts = $xeTable.computeCurrentColumnOpts
|
|
6300
6652
|
const { actived, focused } = editStore
|
|
6301
6653
|
const { row, column } = params
|
|
6302
6654
|
const { type, treeNode } = column
|
|
@@ -6312,11 +6664,11 @@ const Methods = {
|
|
|
6312
6664
|
if (!triggerCheckbox && !triggerRadio) {
|
|
6313
6665
|
// 如果是展开行
|
|
6314
6666
|
if (!triggerExpandNode && (expandOpts.trigger === 'row' || (isExpandType && expandOpts.trigger === 'cell'))) {
|
|
6315
|
-
|
|
6667
|
+
$xeTable.triggerRowExpandEvent(evnt, params)
|
|
6316
6668
|
}
|
|
6317
6669
|
// 如果是树形表格
|
|
6318
6670
|
if ((treeOpts.trigger === 'row' || (treeNode && treeOpts.trigger === 'cell'))) {
|
|
6319
|
-
|
|
6671
|
+
$xeTable.triggerTreeExpandEvent(evnt, params)
|
|
6320
6672
|
}
|
|
6321
6673
|
}
|
|
6322
6674
|
// 如果点击了树节点
|
|
@@ -6325,16 +6677,22 @@ const Methods = {
|
|
|
6325
6677
|
// 如果是高亮行
|
|
6326
6678
|
if (rowOpts.isCurrent || highlightCurrentRow) {
|
|
6327
6679
|
if (!triggerCheckbox && !triggerRadio) {
|
|
6328
|
-
|
|
6680
|
+
$xeTable.triggerCurrentRowEvent(evnt, params)
|
|
6681
|
+
}
|
|
6682
|
+
}
|
|
6683
|
+
// 如果是当前列
|
|
6684
|
+
if ((columnOpts.isCurrent || highlightCurrentColumn) && (!currentColumnOpts.trigger || ['cell', 'default'].includes(currentColumnOpts.trigger))) {
|
|
6685
|
+
if (!triggerCheckbox && !triggerRadio) {
|
|
6686
|
+
$xeTable.triggerCurrentColumnEvent(evnt, params)
|
|
6329
6687
|
}
|
|
6330
6688
|
}
|
|
6331
6689
|
// 如果是单选框
|
|
6332
6690
|
if (!triggerRadio && (radioOpts.trigger === 'row' || (isRadioType && radioOpts.trigger === 'cell'))) {
|
|
6333
|
-
|
|
6691
|
+
$xeTable.triggerRadioRowEvent(evnt, params)
|
|
6334
6692
|
}
|
|
6335
6693
|
// 如果是复选框
|
|
6336
6694
|
if (!triggerCheckbox && (checkboxOpts.trigger === 'row' || (isCheckboxType && checkboxOpts.trigger === 'cell'))) {
|
|
6337
|
-
|
|
6695
|
+
$xeTable.handleToggleCheckRowEvent(evnt, params)
|
|
6338
6696
|
}
|
|
6339
6697
|
}
|
|
6340
6698
|
// 如果设置了单元格选中功能,则不会使用点击事件去处理(只能支持双击模式)
|
|
@@ -6346,14 +6704,14 @@ const Methods = {
|
|
|
6346
6704
|
}
|
|
6347
6705
|
if (editOpts.trigger === 'manual') {
|
|
6348
6706
|
if (actived.args && actived.row === row && column !== actived.column) {
|
|
6349
|
-
|
|
6707
|
+
handleChangeCell($xeTable, evnt, params)
|
|
6350
6708
|
}
|
|
6351
6709
|
} else if (!actived.args || row !== actived.row || column !== actived.column) {
|
|
6352
6710
|
if (editOpts.trigger === 'click') {
|
|
6353
|
-
|
|
6711
|
+
handleChangeCell($xeTable, evnt, params)
|
|
6354
6712
|
} else if (editOpts.trigger === 'dblclick') {
|
|
6355
6713
|
if (editOpts.mode === 'row' && actived.row === row) {
|
|
6356
|
-
|
|
6714
|
+
handleChangeCell($xeTable, evnt, params)
|
|
6357
6715
|
}
|
|
6358
6716
|
}
|
|
6359
6717
|
}
|
|
@@ -6373,7 +6731,7 @@ const Methods = {
|
|
|
6373
6731
|
}
|
|
6374
6732
|
}
|
|
6375
6733
|
}
|
|
6376
|
-
|
|
6734
|
+
$xeTable.dispatchEvent('cell-click', params, evnt)
|
|
6377
6735
|
},
|
|
6378
6736
|
/**
|
|
6379
6737
|
* 列双击点击事件
|
|
@@ -6396,16 +6754,16 @@ const Methods = {
|
|
|
6396
6754
|
if (isEnableConf(editConfig) && editOpts.trigger === 'dblclick') {
|
|
6397
6755
|
if (!actived.args || evnt.currentTarget !== actived.args.cell) {
|
|
6398
6756
|
if (editOpts.mode === 'row') {
|
|
6399
|
-
|
|
6757
|
+
checkValidate($xeTable, 'blur')
|
|
6400
6758
|
.catch((e: any) => e)
|
|
6401
6759
|
.then(() => {
|
|
6402
6760
|
this.handleEdit(params, evnt)
|
|
6403
|
-
.then(() =>
|
|
6761
|
+
.then(() => checkValidate($xeTable, 'change'))
|
|
6404
6762
|
.catch((e: any) => e)
|
|
6405
6763
|
})
|
|
6406
6764
|
} else if (editOpts.mode === 'cell') {
|
|
6407
6765
|
this.handleEdit(params, evnt)
|
|
6408
|
-
.then(() =>
|
|
6766
|
+
.then(() => checkValidate($xeTable, 'change'))
|
|
6409
6767
|
.catch((e: any) => e)
|
|
6410
6768
|
}
|
|
6411
6769
|
}
|
|
@@ -6593,7 +6951,7 @@ const Methods = {
|
|
|
6593
6951
|
evnt.dataTransfer.setDragImage(getTpImg(), 0, 0)
|
|
6594
6952
|
}
|
|
6595
6953
|
},
|
|
6596
|
-
handleRowDragSwapEvent (evnt: DragEvent, isSyncRow: boolean | undefined, dragRow: any, prevDragRow: any, prevDragPos: '' | 'top' | 'bottom' | 'left' | 'right' | undefined, prevDragToChild: boolean | undefined) {
|
|
6954
|
+
handleRowDragSwapEvent (evnt: DragEvent | null, isSyncRow: boolean | undefined, dragRow: any, prevDragRow: any, prevDragPos: '' | 'top' | 'bottom' | 'left' | 'right' | undefined, prevDragToChild: boolean | undefined) {
|
|
6597
6955
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
6598
6956
|
const props = $xeTable
|
|
6599
6957
|
const reactData = $xeTable as unknown as TableReactData
|
|
@@ -6601,14 +6959,16 @@ const Methods = {
|
|
|
6601
6959
|
|
|
6602
6960
|
const { treeConfig, dragConfig } = props
|
|
6603
6961
|
const rowDragOpts = $xeTable.computeRowDragOpts
|
|
6604
|
-
const { fullAllDataRowIdData } = internalData
|
|
6962
|
+
const { afterFullData, tableFullData, fullAllDataRowIdData } = internalData
|
|
6605
6963
|
const { isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod, dragToChildMethod } = rowDragOpts
|
|
6606
6964
|
const treeOpts = $xeTable.computeTreeOpts
|
|
6607
6965
|
const { transform, rowField, mapChildrenField, parentField } = treeOpts
|
|
6608
6966
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
6609
|
-
const { afterFullData, tableFullData } = internalData
|
|
6610
6967
|
const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null)
|
|
6611
6968
|
const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
|
|
6969
|
+
const errRest = {
|
|
6970
|
+
status: false
|
|
6971
|
+
}
|
|
6612
6972
|
if (prevDragRow && dragRow) {
|
|
6613
6973
|
// 判断是否有拖动
|
|
6614
6974
|
if (prevDragRow !== dragRow) {
|
|
@@ -6623,7 +6983,7 @@ const Methods = {
|
|
|
6623
6983
|
const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
|
|
6624
6984
|
return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then((status) => {
|
|
6625
6985
|
if (!status) {
|
|
6626
|
-
return
|
|
6986
|
+
return errRest
|
|
6627
6987
|
}
|
|
6628
6988
|
|
|
6629
6989
|
let oafIndex = -1
|
|
@@ -6654,11 +7014,11 @@ const Methods = {
|
|
|
6654
7014
|
if (isPeerDrag && !isCrossDrag) {
|
|
6655
7015
|
if (oldRest.row[parentField] !== newRest.row[parentField]) {
|
|
6656
7016
|
// 非同级
|
|
6657
|
-
return
|
|
7017
|
+
return errRest
|
|
6658
7018
|
}
|
|
6659
7019
|
} else {
|
|
6660
7020
|
if (!isCrossDrag) {
|
|
6661
|
-
return
|
|
7021
|
+
return errRest
|
|
6662
7022
|
}
|
|
6663
7023
|
if (oldAllMaps[newRowid]) {
|
|
6664
7024
|
isSelfToChildStatus = true
|
|
@@ -6669,7 +7029,7 @@ const Methods = {
|
|
|
6669
7029
|
content: getI18n('vxe.error.treeDragChild')
|
|
6670
7030
|
})
|
|
6671
7031
|
}
|
|
6672
|
-
return
|
|
7032
|
+
return errRest
|
|
6673
7033
|
}
|
|
6674
7034
|
}
|
|
6675
7035
|
}
|
|
@@ -6677,13 +7037,13 @@ const Methods = {
|
|
|
6677
7037
|
// 子到根
|
|
6678
7038
|
|
|
6679
7039
|
if (!isCrossDrag) {
|
|
6680
|
-
return
|
|
7040
|
+
return errRest
|
|
6681
7041
|
}
|
|
6682
7042
|
} else if (newLevel) {
|
|
6683
7043
|
// 根到子
|
|
6684
7044
|
|
|
6685
7045
|
if (!isCrossDrag) {
|
|
6686
|
-
return
|
|
7046
|
+
return errRest
|
|
6687
7047
|
}
|
|
6688
7048
|
if (oldAllMaps[newRowid]) {
|
|
6689
7049
|
isSelfToChildStatus = true
|
|
@@ -6694,7 +7054,7 @@ const Methods = {
|
|
|
6694
7054
|
content: getI18n('vxe.error.treeDragChild')
|
|
6695
7055
|
})
|
|
6696
7056
|
}
|
|
6697
|
-
return
|
|
7057
|
+
return errRest
|
|
6698
7058
|
}
|
|
6699
7059
|
}
|
|
6700
7060
|
} else {
|
|
@@ -6758,28 +7118,36 @@ const Methods = {
|
|
|
6758
7118
|
if (reactData.scrollYLoad) {
|
|
6759
7119
|
$xeTable.updateScrollYSpace()
|
|
6760
7120
|
}
|
|
6761
|
-
|
|
7121
|
+
|
|
7122
|
+
if (evnt) {
|
|
7123
|
+
$xeTable.dispatchEvent('row-dragend', {
|
|
7124
|
+
oldRow: dragRow,
|
|
7125
|
+
newRow: prevDragRow,
|
|
7126
|
+
dragRow,
|
|
7127
|
+
dragPos: prevDragPos as any,
|
|
7128
|
+
dragToChild: isDragToChildFlag,
|
|
7129
|
+
offsetIndex: dragOffsetIndex,
|
|
7130
|
+
_index: {
|
|
7131
|
+
newIndex: nafIndex,
|
|
7132
|
+
oldIndex: oafIndex
|
|
7133
|
+
}
|
|
7134
|
+
}, evnt)
|
|
7135
|
+
}
|
|
7136
|
+
|
|
7137
|
+
return $xeTable.$nextTick().then(() => {
|
|
6762
7138
|
$xeTable.updateCellAreas()
|
|
6763
7139
|
$xeTable.recalculate()
|
|
6764
|
-
})
|
|
6765
|
-
|
|
6766
|
-
|
|
6767
|
-
oldRow: dragRow,
|
|
6768
|
-
newRow: prevDragRow,
|
|
6769
|
-
dragRow,
|
|
6770
|
-
dragPos: prevDragPos as any,
|
|
6771
|
-
dragToChild: isDragToChildFlag,
|
|
6772
|
-
offsetIndex: dragOffsetIndex,
|
|
6773
|
-
_index: {
|
|
6774
|
-
newIndex: nafIndex,
|
|
6775
|
-
oldIndex: oafIndex
|
|
7140
|
+
}).then(() => {
|
|
7141
|
+
return {
|
|
7142
|
+
status: true
|
|
6776
7143
|
}
|
|
6777
|
-
}
|
|
7144
|
+
})
|
|
6778
7145
|
}).catch(() => {
|
|
7146
|
+
return errRest
|
|
6779
7147
|
})
|
|
6780
7148
|
}
|
|
6781
7149
|
}
|
|
6782
|
-
return Promise.resolve()
|
|
7150
|
+
return Promise.resolve(errRest)
|
|
6783
7151
|
},
|
|
6784
7152
|
handleRowDragDragendEvent (evnt: DragEvent) {
|
|
6785
7153
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
@@ -6918,7 +7286,7 @@ const Methods = {
|
|
|
6918
7286
|
$xeTable.saveCustomStore('update:sort')
|
|
6919
7287
|
})
|
|
6920
7288
|
},
|
|
6921
|
-
handleColDragSwapEvent (evnt: DragEvent, isSyncColumn: boolean | undefined, dragCol: VxeTableDefines.ColumnInfo | null | undefined, prevDragCol: VxeTableDefines.ColumnInfo | undefined, prevDragPos: '' | 'top' | 'bottom' | 'left' | 'right' | undefined, prevDragToChild: boolean | undefined) {
|
|
7289
|
+
handleColDragSwapEvent (evnt: DragEvent | null, isSyncColumn: boolean | undefined, dragCol: VxeTableDefines.ColumnInfo | null | undefined, prevDragCol: VxeTableDefines.ColumnInfo | undefined, prevDragPos: '' | 'top' | 'bottom' | 'left' | 'right' | undefined, prevDragToChild: boolean | undefined) {
|
|
6922
7290
|
const $xeTable = this
|
|
6923
7291
|
const props = $xeTable
|
|
6924
7292
|
const reactData = $xeTable
|
|
@@ -6929,6 +7297,9 @@ const Methods = {
|
|
|
6929
7297
|
const { isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts
|
|
6930
7298
|
const { collectColumn } = internalData
|
|
6931
7299
|
const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0
|
|
7300
|
+
const errRest = {
|
|
7301
|
+
status: false
|
|
7302
|
+
}
|
|
6932
7303
|
if (prevDragCol && dragCol) {
|
|
6933
7304
|
// 判断是否有拖动
|
|
6934
7305
|
if (prevDragCol !== dragCol) {
|
|
@@ -6945,7 +7316,7 @@ const Methods = {
|
|
|
6945
7316
|
const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild
|
|
6946
7317
|
return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
|
|
6947
7318
|
if (!status) {
|
|
6948
|
-
return
|
|
7319
|
+
return errRest
|
|
6949
7320
|
}
|
|
6950
7321
|
|
|
6951
7322
|
let oafIndex = -1
|
|
@@ -6964,11 +7335,11 @@ const Methods = {
|
|
|
6964
7335
|
if (isPeerDrag && !isCrossDrag) {
|
|
6965
7336
|
if (dragColumn.parentId !== newColumn.parentId) {
|
|
6966
7337
|
// 非同级
|
|
6967
|
-
return
|
|
7338
|
+
return errRest
|
|
6968
7339
|
}
|
|
6969
7340
|
} else {
|
|
6970
7341
|
if (!isCrossDrag) {
|
|
6971
|
-
return
|
|
7342
|
+
return errRest
|
|
6972
7343
|
}
|
|
6973
7344
|
|
|
6974
7345
|
if (oldAllMaps[newColumn.id]) {
|
|
@@ -6980,7 +7351,7 @@ const Methods = {
|
|
|
6980
7351
|
content: getI18n('vxe.error.treeDragChild')
|
|
6981
7352
|
})
|
|
6982
7353
|
}
|
|
6983
|
-
return
|
|
7354
|
+
return errRest
|
|
6984
7355
|
}
|
|
6985
7356
|
}
|
|
6986
7357
|
}
|
|
@@ -6988,13 +7359,13 @@ const Methods = {
|
|
|
6988
7359
|
// 子到根
|
|
6989
7360
|
|
|
6990
7361
|
if (!isCrossDrag) {
|
|
6991
|
-
return
|
|
7362
|
+
return errRest
|
|
6992
7363
|
}
|
|
6993
7364
|
} else if (newColumn.parentId) {
|
|
6994
7365
|
// 根到子
|
|
6995
7366
|
|
|
6996
7367
|
if (!isCrossDrag) {
|
|
6997
|
-
return
|
|
7368
|
+
return errRest
|
|
6998
7369
|
}
|
|
6999
7370
|
if (oldAllMaps[newColumn.id]) {
|
|
7000
7371
|
isSelfToChildStatus = true
|
|
@@ -7005,7 +7376,7 @@ const Methods = {
|
|
|
7005
7376
|
content: getI18n('vxe.error.treeDragChild')
|
|
7006
7377
|
})
|
|
7007
7378
|
}
|
|
7008
|
-
return
|
|
7379
|
+
return errRest
|
|
7009
7380
|
}
|
|
7010
7381
|
}
|
|
7011
7382
|
} else {
|
|
@@ -7069,27 +7440,34 @@ const Methods = {
|
|
|
7069
7440
|
}
|
|
7070
7441
|
}
|
|
7071
7442
|
|
|
7072
|
-
|
|
7073
|
-
|
|
7074
|
-
|
|
7075
|
-
|
|
7076
|
-
|
|
7077
|
-
|
|
7078
|
-
|
|
7079
|
-
|
|
7080
|
-
|
|
7081
|
-
|
|
7082
|
-
|
|
7083
|
-
|
|
7443
|
+
if (evnt) {
|
|
7444
|
+
$xeTable.dispatchEvent('column-dragend', {
|
|
7445
|
+
oldColumn: dragColumn,
|
|
7446
|
+
newColumn,
|
|
7447
|
+
dragColumn,
|
|
7448
|
+
dragPos: prevDragPos,
|
|
7449
|
+
dragToChild: isDragToChildFlag,
|
|
7450
|
+
offsetIndex: dragOffsetIndex,
|
|
7451
|
+
_index: {
|
|
7452
|
+
newIndex: nafIndex,
|
|
7453
|
+
oldIndex: oafIndex
|
|
7454
|
+
}
|
|
7455
|
+
}, evnt)
|
|
7456
|
+
}
|
|
7084
7457
|
|
|
7085
7458
|
if (isSyncColumn) {
|
|
7086
7459
|
$xeTable.handleColDragSwapColumn()
|
|
7087
7460
|
}
|
|
7461
|
+
|
|
7462
|
+
return {
|
|
7463
|
+
status: true
|
|
7464
|
+
}
|
|
7088
7465
|
}).catch(() => {
|
|
7466
|
+
return errRest
|
|
7089
7467
|
})
|
|
7090
7468
|
}
|
|
7091
7469
|
}
|
|
7092
|
-
return Promise.resolve()
|
|
7470
|
+
return Promise.resolve(errRest)
|
|
7093
7471
|
},
|
|
7094
7472
|
handleHeaderCellDragDragendEvent (evnt: DragEvent) {
|
|
7095
7473
|
const $xeTable = this
|
|
@@ -7181,8 +7559,8 @@ const Methods = {
|
|
|
7181
7559
|
}
|
|
7182
7560
|
},
|
|
7183
7561
|
handleHeaderCellDragMousedownEvent (evnt: MouseEvent, params: any) {
|
|
7184
|
-
const $xeTable = this
|
|
7185
|
-
const reactData = $xeTable
|
|
7562
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7563
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7186
7564
|
|
|
7187
7565
|
evnt.stopPropagation()
|
|
7188
7566
|
const columnDragOpts = $xeTable.computeColumnDragOpts
|
|
@@ -7207,8 +7585,8 @@ const Methods = {
|
|
|
7207
7585
|
$xeTable.dispatchEvent('column-dragstart', params, evnt)
|
|
7208
7586
|
},
|
|
7209
7587
|
handleHeaderCellDragMouseupEvent () {
|
|
7210
|
-
const $xeTable = this
|
|
7211
|
-
const reactData = $xeTable
|
|
7588
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7589
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7212
7590
|
|
|
7213
7591
|
clearColDropOrigin($xeTable)
|
|
7214
7592
|
hideDropTip($xeTable)
|
|
@@ -7217,54 +7595,58 @@ const Methods = {
|
|
|
7217
7595
|
reactData.isDragColMove = false
|
|
7218
7596
|
},
|
|
7219
7597
|
setPendingRow (rows: any, status: any) {
|
|
7220
|
-
const $xeTable = this
|
|
7221
|
-
const reactData = $xeTable
|
|
7598
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7599
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7600
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7222
7601
|
|
|
7223
|
-
const
|
|
7602
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
7603
|
+
const { pendingRowMaps } = internalData
|
|
7224
7604
|
if (rows && !XEUtils.isArray(rows)) {
|
|
7225
7605
|
rows = [rows]
|
|
7226
7606
|
}
|
|
7227
7607
|
if (status) {
|
|
7228
7608
|
rows.forEach((row: any) => {
|
|
7229
|
-
const rowid =
|
|
7230
|
-
if (rowid && !
|
|
7231
|
-
|
|
7609
|
+
const rowid = handleGetRowId(row)
|
|
7610
|
+
if (rowid && !pendingRowMaps[rowid]) {
|
|
7611
|
+
pendingRowMaps[rowid] = row
|
|
7232
7612
|
}
|
|
7233
7613
|
})
|
|
7234
7614
|
} else {
|
|
7235
7615
|
rows.forEach((row: any) => {
|
|
7236
|
-
const rowid =
|
|
7237
|
-
if (rowid &&
|
|
7238
|
-
delete
|
|
7616
|
+
const rowid = handleGetRowId(row)
|
|
7617
|
+
if (rowid && pendingRowMaps[rowid]) {
|
|
7618
|
+
delete pendingRowMaps[rowid]
|
|
7239
7619
|
}
|
|
7240
7620
|
})
|
|
7241
7621
|
}
|
|
7242
|
-
reactData.
|
|
7622
|
+
reactData.pendingRowFlag++
|
|
7243
7623
|
return $xeTable.$nextTick()
|
|
7244
7624
|
},
|
|
7245
7625
|
togglePendingRow (rows: any) {
|
|
7246
|
-
const $xeTable = this
|
|
7247
|
-
const reactData = $xeTable
|
|
7626
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7627
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7628
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7248
7629
|
|
|
7249
|
-
const
|
|
7630
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
7631
|
+
const { pendingRowMaps } = internalData
|
|
7250
7632
|
if (rows && !XEUtils.isArray(rows)) {
|
|
7251
7633
|
rows = [rows]
|
|
7252
7634
|
}
|
|
7253
7635
|
rows.forEach((row: any) => {
|
|
7254
|
-
const rowid =
|
|
7636
|
+
const rowid = handleGetRowId(row)
|
|
7255
7637
|
if (rowid) {
|
|
7256
|
-
if (
|
|
7257
|
-
delete
|
|
7638
|
+
if (pendingRowMaps[rowid]) {
|
|
7639
|
+
delete pendingRowMaps[rowid]
|
|
7258
7640
|
} else {
|
|
7259
|
-
|
|
7641
|
+
pendingRowMaps[rowid] = row
|
|
7260
7642
|
}
|
|
7261
7643
|
}
|
|
7262
7644
|
})
|
|
7263
|
-
reactData.
|
|
7645
|
+
reactData.pendingRowFlag++
|
|
7264
7646
|
return $xeTable.$nextTick()
|
|
7265
7647
|
},
|
|
7266
7648
|
hasPendingByRow (row: any) {
|
|
7267
|
-
const $xeTable = this
|
|
7649
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7268
7650
|
|
|
7269
7651
|
return $xeTable.isPendingByRow(row)
|
|
7270
7652
|
},
|
|
@@ -7277,12 +7659,10 @@ const Methods = {
|
|
|
7277
7659
|
return !!pendingRowMaps[rowid]
|
|
7278
7660
|
},
|
|
7279
7661
|
getPendingRecords () {
|
|
7280
|
-
const $xeTable = this
|
|
7281
|
-
const
|
|
7282
|
-
const internalData = $xeTable
|
|
7662
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7663
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7283
7664
|
|
|
7284
|
-
const { pendingRowMaps } =
|
|
7285
|
-
const { fullAllDataRowIdData } = internalData
|
|
7665
|
+
const { fullAllDataRowIdData, pendingRowMaps } = internalData
|
|
7286
7666
|
const insertRecords: any[] = []
|
|
7287
7667
|
XEUtils.each(pendingRowMaps, (row, rowid) => {
|
|
7288
7668
|
if (fullAllDataRowIdData[rowid]) {
|
|
@@ -7292,11 +7672,16 @@ const Methods = {
|
|
|
7292
7672
|
return insertRecords
|
|
7293
7673
|
},
|
|
7294
7674
|
clearPendingRow () {
|
|
7295
|
-
|
|
7296
|
-
|
|
7675
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7676
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7677
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7678
|
+
|
|
7679
|
+
internalData.pendingRowMaps = {}
|
|
7680
|
+
reactData.pendingRowFlag++
|
|
7681
|
+
return $xeTable.$nextTick()
|
|
7297
7682
|
},
|
|
7298
7683
|
sort (sortConfs: any, sortOrder: any) {
|
|
7299
|
-
const $xeTable = this
|
|
7684
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7300
7685
|
|
|
7301
7686
|
const { sortOpts } = this
|
|
7302
7687
|
const { multiple, remote, orders } = sortOpts
|
|
@@ -7446,7 +7831,10 @@ const Methods = {
|
|
|
7446
7831
|
* @param {Event} evnt 事件
|
|
7447
7832
|
*/
|
|
7448
7833
|
closeFilter () {
|
|
7449
|
-
const
|
|
7834
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7835
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7836
|
+
|
|
7837
|
+
const { filterStore } = reactData
|
|
7450
7838
|
const { column, visible } = filterStore
|
|
7451
7839
|
Object.assign(filterStore, {
|
|
7452
7840
|
isAllSelected: false,
|
|
@@ -7455,9 +7843,15 @@ const Methods = {
|
|
|
7455
7843
|
visible: false
|
|
7456
7844
|
})
|
|
7457
7845
|
if (visible) {
|
|
7458
|
-
|
|
7846
|
+
$xeTable.dispatchEvent('filter-visible', {
|
|
7847
|
+
column,
|
|
7848
|
+
field: column.field,
|
|
7849
|
+
property: column.field,
|
|
7850
|
+
filterList: () => $xeTable.getCheckedFilters(),
|
|
7851
|
+
visible: false
|
|
7852
|
+
}, null)
|
|
7459
7853
|
}
|
|
7460
|
-
return
|
|
7854
|
+
return $xeTable.$nextTick()
|
|
7461
7855
|
},
|
|
7462
7856
|
/**
|
|
7463
7857
|
* 判断指定列是否为筛选状态,如果为空则判断所有列
|
|
@@ -7490,17 +7884,16 @@ const Methods = {
|
|
|
7490
7884
|
const reactData = $xeTable as unknown as TableReactData
|
|
7491
7885
|
const internalData = $xeTable as unknown as TableInternalData
|
|
7492
7886
|
|
|
7493
|
-
const
|
|
7494
|
-
const { fullAllDataRowIdData } = internalData
|
|
7887
|
+
const { fullAllDataRowIdData, rowExpandLazyLoadedMaps } = internalData
|
|
7495
7888
|
const expandOpts = $xeTable.computeExpandOpts
|
|
7496
7889
|
const { lazy } = expandOpts
|
|
7497
7890
|
const rowid = getRowid($xeTable, row)
|
|
7498
7891
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
7499
7892
|
if (lazy && rowRest) {
|
|
7500
7893
|
rowRest.expandLoaded = false
|
|
7501
|
-
delete
|
|
7894
|
+
delete rowExpandLazyLoadedMaps[rowid]
|
|
7502
7895
|
}
|
|
7503
|
-
reactData.
|
|
7896
|
+
reactData.rowExpandedFlag++
|
|
7504
7897
|
return $xeTable.$nextTick()
|
|
7505
7898
|
},
|
|
7506
7899
|
/**
|
|
@@ -7508,14 +7901,18 @@ const Methods = {
|
|
|
7508
7901
|
* @param {Row} row 行对象
|
|
7509
7902
|
*/
|
|
7510
7903
|
reloadRowExpand (row: any) {
|
|
7511
|
-
const
|
|
7904
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7905
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7906
|
+
|
|
7907
|
+
const { rowExpandLazyLoadedMaps } = internalData
|
|
7908
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
7512
7909
|
const { lazy } = expandOpts
|
|
7513
7910
|
const rowid = getRowid(this, row)
|
|
7514
7911
|
if (lazy && !rowExpandLazyLoadedMaps[rowid]) {
|
|
7515
|
-
|
|
7516
|
-
.then(() =>
|
|
7912
|
+
$xeTable.clearRowExpandLoaded(row)
|
|
7913
|
+
.then(() => handleAsyncRowExpand($xeTable, row))
|
|
7517
7914
|
}
|
|
7518
|
-
return
|
|
7915
|
+
return $xeTable.$nextTick()
|
|
7519
7916
|
},
|
|
7520
7917
|
reloadExpandContent (row: any) {
|
|
7521
7918
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -7528,20 +7925,34 @@ const Methods = {
|
|
|
7528
7925
|
* 展开行事件
|
|
7529
7926
|
*/
|
|
7530
7927
|
triggerRowExpandEvent (evnt: any, params: any) {
|
|
7531
|
-
const
|
|
7928
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
7929
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
7930
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7931
|
+
|
|
7932
|
+
const { expandColumn: column } = reactData
|
|
7933
|
+
const { rowExpandLazyLoadedMaps } = internalData
|
|
7934
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
7532
7935
|
const { row } = params
|
|
7533
7936
|
const { lazy, trigger } = expandOpts
|
|
7534
7937
|
if (trigger === 'manual') {
|
|
7535
7938
|
return
|
|
7536
7939
|
}
|
|
7537
7940
|
evnt.stopPropagation()
|
|
7538
|
-
const rowid = getRowid(
|
|
7941
|
+
const rowid = getRowid($xeTable, row)
|
|
7539
7942
|
if (!lazy || !rowExpandLazyLoadedMaps[rowid]) {
|
|
7540
|
-
const expanded =
|
|
7541
|
-
const columnIndex =
|
|
7542
|
-
const $columnIndex =
|
|
7543
|
-
|
|
7544
|
-
|
|
7943
|
+
const expanded = !$xeTable.isRowExpandByRow(row)
|
|
7944
|
+
const columnIndex = $xeTable.getColumnIndex(column)
|
|
7945
|
+
const $columnIndex = $xeTable.getVMColumnIndex(column)
|
|
7946
|
+
$xeTable.setRowExpand(row, expanded)
|
|
7947
|
+
$xeTable.dispatchEvent('toggle-row-expand', {
|
|
7948
|
+
expanded,
|
|
7949
|
+
column,
|
|
7950
|
+
columnIndex,
|
|
7951
|
+
$columnIndex,
|
|
7952
|
+
row,
|
|
7953
|
+
rowIndex: $xeTable.getRowIndex(row),
|
|
7954
|
+
$rowIndex: $xeTable.getVMRowIndex(row)
|
|
7955
|
+
}, evnt)
|
|
7545
7956
|
}
|
|
7546
7957
|
},
|
|
7547
7958
|
/**
|
|
@@ -7585,48 +7996,6 @@ const Methods = {
|
|
|
7585
7996
|
}
|
|
7586
7997
|
return this.setRowExpand(expandedRows, expanded)
|
|
7587
7998
|
},
|
|
7588
|
-
handleAsyncRowExpand (row: any) {
|
|
7589
|
-
const $xeTable = this
|
|
7590
|
-
const reactData = $xeTable as TableReactData
|
|
7591
|
-
const internalData = $xeTable as TableInternalData
|
|
7592
|
-
|
|
7593
|
-
return new Promise<void>(resolve => {
|
|
7594
|
-
const { expandOpts } = this
|
|
7595
|
-
const { loadMethod } = expandOpts
|
|
7596
|
-
if (loadMethod) {
|
|
7597
|
-
const { fullAllDataRowIdData } = internalData
|
|
7598
|
-
const rExpandLazyLoadedMaps = { ...reactData.rowExpandLazyLoadedMaps }
|
|
7599
|
-
const rowid = getRowid($xeTable, row)
|
|
7600
|
-
const rowRest = fullAllDataRowIdData[rowid]
|
|
7601
|
-
rExpandLazyLoadedMaps[rowid] = row
|
|
7602
|
-
reactData.rowExpandLazyLoadedMaps = rExpandLazyLoadedMaps
|
|
7603
|
-
loadMethod({ $table: $xeTable, row, rowIndex: $xeTable.getRowIndex(row), $rowIndex: $xeTable.getVMRowIndex(row) }).then(() => {
|
|
7604
|
-
const rExpandedMaps = { ...reactData.rowExpandedMaps }
|
|
7605
|
-
if (rowRest) {
|
|
7606
|
-
rowRest.expandLoaded = true
|
|
7607
|
-
}
|
|
7608
|
-
rExpandedMaps[rowid] = row
|
|
7609
|
-
reactData.rowExpandedMaps = rExpandedMaps
|
|
7610
|
-
}).catch(() => {
|
|
7611
|
-
if (rowRest) {
|
|
7612
|
-
rowRest.expandLoaded = false
|
|
7613
|
-
}
|
|
7614
|
-
}).finally(() => {
|
|
7615
|
-
const rExpandLazyLoadedMaps = { ...reactData.rowExpandLazyLoadedMaps }
|
|
7616
|
-
if (rExpandLazyLoadedMaps[rowid]) {
|
|
7617
|
-
delete rExpandLazyLoadedMaps[rowid]
|
|
7618
|
-
}
|
|
7619
|
-
reactData.rowExpandLazyLoadedMaps = rExpandLazyLoadedMaps
|
|
7620
|
-
$xeTable.$nextTick()
|
|
7621
|
-
.then(() => $xeTable.recalculate())
|
|
7622
|
-
.then(() => $xeTable.updateCellAreas())
|
|
7623
|
-
.then(() => resolve())
|
|
7624
|
-
})
|
|
7625
|
-
} else {
|
|
7626
|
-
resolve()
|
|
7627
|
-
}
|
|
7628
|
-
})
|
|
7629
|
-
},
|
|
7630
7999
|
/**
|
|
7631
8000
|
* 设置展开行,二个参数设置这一行展开与否
|
|
7632
8001
|
* 支持单行
|
|
@@ -7635,10 +8004,14 @@ const Methods = {
|
|
|
7635
8004
|
* @param {Boolean} expanded 是否展开
|
|
7636
8005
|
*/
|
|
7637
8006
|
setRowExpand (rows: any, expanded: any) {
|
|
7638
|
-
const $xeTable = this
|
|
8007
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8008
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
8009
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7639
8010
|
|
|
7640
|
-
const {
|
|
7641
|
-
let
|
|
8011
|
+
const { expandColumn } = reactData
|
|
8012
|
+
let { fullAllDataRowIdData, rowExpandedMaps, rowExpandLazyLoadedMaps } = internalData
|
|
8013
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
8014
|
+
const expandOpts = $xeTable.computeExpandOpts
|
|
7642
8015
|
const { reserve, lazy, accordion, toggleMethod } = expandOpts
|
|
7643
8016
|
const lazyRests: any[] = []
|
|
7644
8017
|
const columnIndex = $xeTable.getColumnIndex(expandColumn)
|
|
@@ -7649,28 +8022,29 @@ const Methods = {
|
|
|
7649
8022
|
}
|
|
7650
8023
|
if (accordion) {
|
|
7651
8024
|
// 只能同时展开一个
|
|
7652
|
-
|
|
8025
|
+
rowExpandedMaps = {}
|
|
8026
|
+
internalData.rowExpandedMaps = rowExpandedMaps
|
|
7653
8027
|
rows = rows.slice(rows.length - 1, rows.length)
|
|
7654
8028
|
}
|
|
7655
|
-
const validRows: any[] = toggleMethod ? rows.filter((row: any) => toggleMethod({ expanded, column: expandColumn, columnIndex, $columnIndex, row, rowIndex: this.getRowIndex(row), $rowIndex: this.getVMRowIndex(row) })) : rows
|
|
8029
|
+
const validRows: any[] = toggleMethod ? rows.filter((row: any) => toggleMethod({ $table: $xeTable, expanded, column: expandColumn, columnIndex, $columnIndex, row, rowIndex: this.getRowIndex(row), $rowIndex: this.getVMRowIndex(row) })) : rows
|
|
7656
8030
|
if (expanded) {
|
|
7657
8031
|
validRows.forEach((row: any) => {
|
|
7658
|
-
const rowid =
|
|
7659
|
-
if (!
|
|
8032
|
+
const rowid = handleGetRowId(row)
|
|
8033
|
+
if (!rowExpandedMaps[rowid]) {
|
|
7660
8034
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
7661
8035
|
const isLoad = lazy && !rowRest.expandLoaded && !rowExpandLazyLoadedMaps[rowid]
|
|
7662
8036
|
if (isLoad) {
|
|
7663
|
-
lazyRests.push(
|
|
8037
|
+
lazyRests.push(handleAsyncRowExpand($xeTable, row))
|
|
7664
8038
|
} else {
|
|
7665
|
-
|
|
8039
|
+
rowExpandedMaps[rowid] = row
|
|
7666
8040
|
}
|
|
7667
8041
|
}
|
|
7668
8042
|
})
|
|
7669
8043
|
} else {
|
|
7670
8044
|
validRows.forEach((item) => {
|
|
7671
|
-
const rowid =
|
|
7672
|
-
if (
|
|
7673
|
-
delete
|
|
8045
|
+
const rowid = handleGetRowId(item)
|
|
8046
|
+
if (rowExpandedMaps[rowid]) {
|
|
8047
|
+
delete rowExpandedMaps[rowid]
|
|
7674
8048
|
}
|
|
7675
8049
|
})
|
|
7676
8050
|
}
|
|
@@ -7678,7 +8052,7 @@ const Methods = {
|
|
|
7678
8052
|
validRows.forEach((row) => handleRowExpandReserve($xeTable, row, expanded))
|
|
7679
8053
|
}
|
|
7680
8054
|
}
|
|
7681
|
-
|
|
8055
|
+
reactData.rowExpandedFlag++
|
|
7682
8056
|
return Promise.all(lazyRests)
|
|
7683
8057
|
.then(() => $xeTable.$nextTick())
|
|
7684
8058
|
.then(() => $xeTable.recalculate(true))
|
|
@@ -7694,9 +8068,14 @@ const Methods = {
|
|
|
7694
8068
|
* @param {Row} row 行对象
|
|
7695
8069
|
*/
|
|
7696
8070
|
isRowExpandByRow (row: any) {
|
|
7697
|
-
const
|
|
8071
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8072
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
8073
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8074
|
+
|
|
8075
|
+
const { rowExpandedFlag } = reactData
|
|
8076
|
+
const { rowExpandedMaps } = internalData
|
|
7698
8077
|
const rowid = getRowid(this, row)
|
|
7699
|
-
return !!rowExpandedMaps[rowid]
|
|
8078
|
+
return !!rowExpandedFlag && !!rowExpandedMaps[rowid]
|
|
7700
8079
|
},
|
|
7701
8080
|
isExpandByRow (row: any) {
|
|
7702
8081
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
@@ -7717,7 +8096,8 @@ const Methods = {
|
|
|
7717
8096
|
const expandOpts = $xeTable.computeExpandOpts
|
|
7718
8097
|
const { reserve } = expandOpts
|
|
7719
8098
|
const expList = $xeTable.getRowExpandRecords()
|
|
7720
|
-
|
|
8099
|
+
internalData.rowExpandedMaps = {}
|
|
8100
|
+
reactData.rowExpandedFlag++
|
|
7721
8101
|
if (reserve) {
|
|
7722
8102
|
tableFullData.forEach((row) => handleRowExpandReserve($xeTable, row, false))
|
|
7723
8103
|
}
|
|
@@ -7737,8 +8117,11 @@ const Methods = {
|
|
|
7737
8117
|
return this.$nextTick()
|
|
7738
8118
|
},
|
|
7739
8119
|
getRowExpandRecords () {
|
|
8120
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8121
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8122
|
+
|
|
7740
8123
|
const rest: any[] = []
|
|
7741
|
-
XEUtils.each(
|
|
8124
|
+
XEUtils.each(internalData.rowExpandedMaps, item => {
|
|
7742
8125
|
if (item) {
|
|
7743
8126
|
rest.push(item)
|
|
7744
8127
|
}
|
|
@@ -7746,8 +8129,11 @@ const Methods = {
|
|
|
7746
8129
|
return rest
|
|
7747
8130
|
},
|
|
7748
8131
|
getTreeExpandRecords () {
|
|
8132
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8133
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8134
|
+
|
|
7749
8135
|
const rest: any[] = []
|
|
7750
|
-
XEUtils.each(
|
|
8136
|
+
XEUtils.each(internalData.treeExpandedMaps, item => {
|
|
7751
8137
|
if (item) {
|
|
7752
8138
|
rest.push(item)
|
|
7753
8139
|
}
|
|
@@ -7782,12 +8168,10 @@ const Methods = {
|
|
|
7782
8168
|
const reactData = $xeTable as unknown as TableReactData
|
|
7783
8169
|
const internalData = $xeTable as unknown as TableInternalData
|
|
7784
8170
|
|
|
7785
|
-
const { fullAllDataRowIdData } = internalData
|
|
8171
|
+
const { fullAllDataRowIdData, treeExpandedMaps } = internalData
|
|
7786
8172
|
const treeOpts = $xeTable.computeTreeOpts
|
|
7787
8173
|
const { transform } = treeOpts
|
|
7788
|
-
let tExpandedMaps: Record<string, any> = {}
|
|
7789
8174
|
if (rows) {
|
|
7790
|
-
tExpandedMaps = { ...reactData.treeExpandedMaps }
|
|
7791
8175
|
if (!XEUtils.isArray(rows)) {
|
|
7792
8176
|
rows = [rows]
|
|
7793
8177
|
}
|
|
@@ -7796,8 +8180,8 @@ const Methods = {
|
|
|
7796
8180
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
7797
8181
|
if (rowRest) {
|
|
7798
8182
|
rowRest.treeLoaded = false
|
|
7799
|
-
if (
|
|
7800
|
-
delete
|
|
8183
|
+
if (treeExpandedMaps[rowid]) {
|
|
8184
|
+
delete treeExpandedMaps[rowid]
|
|
7801
8185
|
}
|
|
7802
8186
|
}
|
|
7803
8187
|
})
|
|
@@ -7806,7 +8190,8 @@ const Methods = {
|
|
|
7806
8190
|
rowRest.treeLoaded = false
|
|
7807
8191
|
})
|
|
7808
8192
|
}
|
|
7809
|
-
|
|
8193
|
+
internalData.treeExpandedMaps = {}
|
|
8194
|
+
reactData.treeExpandedFlag++
|
|
7810
8195
|
if (transform) {
|
|
7811
8196
|
handleVirtualTreeToList($xeTable)
|
|
7812
8197
|
return $xeTable.handleTableData()
|
|
@@ -7819,37 +8204,45 @@ const Methods = {
|
|
|
7819
8204
|
*/
|
|
7820
8205
|
reloadTreeExpand (row: any) {
|
|
7821
8206
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8207
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
7822
8208
|
|
|
7823
|
-
const {
|
|
8209
|
+
const { treeExpandLazyLoadedMaps } = internalData
|
|
8210
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
7824
8211
|
const { transform, lazy } = treeOpts
|
|
7825
8212
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
7826
|
-
const rowid = getRowid(
|
|
8213
|
+
const rowid = getRowid($xeTable, row)
|
|
7827
8214
|
if (lazy && row[hasChildField] && !treeExpandLazyLoadedMaps[rowid]) {
|
|
7828
|
-
return
|
|
7829
|
-
return
|
|
8215
|
+
return $xeTable.clearTreeExpandLoaded(row).then(() => {
|
|
8216
|
+
return handleAsyncTreeExpandChilds($xeTable, row)
|
|
7830
8217
|
}).then(() => {
|
|
7831
8218
|
if (transform) {
|
|
7832
8219
|
handleVirtualTreeToList($xeTable)
|
|
7833
|
-
return
|
|
8220
|
+
return $xeTable.handleTableData()
|
|
7834
8221
|
}
|
|
7835
8222
|
}).then(() => {
|
|
7836
|
-
return
|
|
8223
|
+
return $xeTable.recalculate()
|
|
7837
8224
|
})
|
|
7838
8225
|
}
|
|
7839
|
-
return
|
|
8226
|
+
return $xeTable.$nextTick()
|
|
7840
8227
|
},
|
|
7841
8228
|
reloadTreeChilds (row: any) {
|
|
8229
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8230
|
+
|
|
7842
8231
|
if (process.env.VUE_APP_VXE_ENV === 'development') {
|
|
7843
8232
|
warnLog('vxe.error.delFunc', ['reloadTreeChilds', 'reloadTreeExpand'])
|
|
7844
8233
|
}
|
|
7845
8234
|
// 即将废弃
|
|
7846
|
-
return
|
|
8235
|
+
return $xeTable.reloadTreeExpand(row)
|
|
7847
8236
|
},
|
|
7848
8237
|
/**
|
|
7849
8238
|
* 展开树节点事件
|
|
7850
8239
|
*/
|
|
7851
8240
|
triggerTreeExpandEvent (evnt: any, params: any) {
|
|
7852
|
-
const
|
|
8241
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8242
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8243
|
+
|
|
8244
|
+
const { treeExpandLazyLoadedMaps } = internalData
|
|
8245
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
7853
8246
|
const { row, column } = params
|
|
7854
8247
|
const { lazy, trigger } = treeOpts
|
|
7855
8248
|
if (trigger === 'manual') {
|
|
@@ -7858,11 +8251,11 @@ const Methods = {
|
|
|
7858
8251
|
evnt.stopPropagation()
|
|
7859
8252
|
const rowid = getRowid(this, row)
|
|
7860
8253
|
if (!lazy || !treeExpandLazyLoadedMaps[rowid]) {
|
|
7861
|
-
const expanded =
|
|
7862
|
-
const columnIndex =
|
|
7863
|
-
const $columnIndex =
|
|
7864
|
-
|
|
7865
|
-
|
|
8254
|
+
const expanded = !$xeTable.isTreeExpandByRow(row)
|
|
8255
|
+
const columnIndex = $xeTable.getColumnIndex(column)
|
|
8256
|
+
const $columnIndex = $xeTable.getVMColumnIndex(column)
|
|
8257
|
+
$xeTable.setTreeExpand(row, expanded)
|
|
8258
|
+
$xeTable.dispatchEvent('toggle-tree-expand', { expanded, column, columnIndex, $columnIndex, row }, evnt)
|
|
7866
8259
|
}
|
|
7867
8260
|
},
|
|
7868
8261
|
/**
|
|
@@ -7871,88 +8264,6 @@ const Methods = {
|
|
|
7871
8264
|
toggleTreeExpand (row: any) {
|
|
7872
8265
|
return this.setTreeExpand(row, !this.isTreeExpandByRow(row))
|
|
7873
8266
|
},
|
|
7874
|
-
/**
|
|
7875
|
-
* 处理默认展开树节点
|
|
7876
|
-
*/
|
|
7877
|
-
handleDefaultTreeExpand () {
|
|
7878
|
-
const { treeConfig, treeOpts, tableFullData } = this
|
|
7879
|
-
if (treeConfig) {
|
|
7880
|
-
const { expandAll, expandRowKeys } = treeOpts
|
|
7881
|
-
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
7882
|
-
if (expandAll) {
|
|
7883
|
-
this.setAllTreeExpand(true)
|
|
7884
|
-
} else if (expandRowKeys) {
|
|
7885
|
-
const defExpandeds: any[] = []
|
|
7886
|
-
const rowkey = getRowkey(this)
|
|
7887
|
-
expandRowKeys.forEach((rowid: any) => {
|
|
7888
|
-
const matchObj = XEUtils.findTree(tableFullData, item => rowid === XEUtils.get(item, rowkey), { children: childrenField })
|
|
7889
|
-
if (matchObj) {
|
|
7890
|
-
defExpandeds.push(matchObj.item)
|
|
7891
|
-
}
|
|
7892
|
-
})
|
|
7893
|
-
this.setTreeExpand(defExpandeds, true)
|
|
7894
|
-
}
|
|
7895
|
-
}
|
|
7896
|
-
},
|
|
7897
|
-
handleAsyncTreeExpandChilds (row: any) {
|
|
7898
|
-
const $xeTable = this
|
|
7899
|
-
|
|
7900
|
-
const { treeOpts, checkboxOpts } = this
|
|
7901
|
-
const { transform, loadMethod } = treeOpts
|
|
7902
|
-
const { checkStrictly } = checkboxOpts
|
|
7903
|
-
return new Promise<void>(resolve => {
|
|
7904
|
-
if (loadMethod) {
|
|
7905
|
-
const { treeExpandLazyLoadedMaps, fullAllDataRowIdData } = this
|
|
7906
|
-
const rowid = getRowid($xeTable, row)
|
|
7907
|
-
const rowRest = fullAllDataRowIdData[rowid]
|
|
7908
|
-
treeExpandLazyLoadedMaps[rowid] = row
|
|
7909
|
-
Promise.resolve(
|
|
7910
|
-
loadMethod({ $table: $xeTable, row })
|
|
7911
|
-
).then((childRecords: any) => {
|
|
7912
|
-
if (rowRest) {
|
|
7913
|
-
rowRest.treeLoaded = true
|
|
7914
|
-
}
|
|
7915
|
-
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
7916
|
-
delete treeExpandLazyLoadedMaps[rowid]
|
|
7917
|
-
}
|
|
7918
|
-
if (!XEUtils.isArray(childRecords)) {
|
|
7919
|
-
childRecords = []
|
|
7920
|
-
}
|
|
7921
|
-
if (childRecords) {
|
|
7922
|
-
return this.loadTreeChildren(row, childRecords).then((childRows: any[]) => {
|
|
7923
|
-
const { treeExpandedMaps } = this
|
|
7924
|
-
if (childRows.length && !treeExpandedMaps[rowid]) {
|
|
7925
|
-
treeExpandedMaps[rowid] = row
|
|
7926
|
-
}
|
|
7927
|
-
// 如果当前节点已选中,则展开后子节点也被选中
|
|
7928
|
-
if (!checkStrictly && this.isCheckedByCheckboxRow(row)) {
|
|
7929
|
-
handleCheckedCheckboxRow($xeTable, childRows, true)
|
|
7930
|
-
}
|
|
7931
|
-
return this.$nextTick().then(() => {
|
|
7932
|
-
if (transform) {
|
|
7933
|
-
this.handleTableData()
|
|
7934
|
-
updateAfterDataIndex($xeTable)
|
|
7935
|
-
return this.$nextTick()
|
|
7936
|
-
}
|
|
7937
|
-
})
|
|
7938
|
-
})
|
|
7939
|
-
}
|
|
7940
|
-
}).catch(() => {
|
|
7941
|
-
const { treeExpandLazyLoadedMaps } = this
|
|
7942
|
-
if (rowRest) {
|
|
7943
|
-
rowRest.treeLoaded = false
|
|
7944
|
-
}
|
|
7945
|
-
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
7946
|
-
delete treeExpandLazyLoadedMaps[rowid]
|
|
7947
|
-
}
|
|
7948
|
-
}).finally(() => {
|
|
7949
|
-
this.$nextTick().then(() => this.recalculate()).then(() => resolve())
|
|
7950
|
-
})
|
|
7951
|
-
} else {
|
|
7952
|
-
resolve()
|
|
7953
|
-
}
|
|
7954
|
-
})
|
|
7955
|
-
},
|
|
7956
8267
|
/**
|
|
7957
8268
|
* 设置所有树节点的展开与否
|
|
7958
8269
|
* @param {Boolean} expanded 是否展开
|
|
@@ -7977,41 +8288,47 @@ const Methods = {
|
|
|
7977
8288
|
* @returns
|
|
7978
8289
|
*/
|
|
7979
8290
|
handleBaseTreeExpand (rows: any, expanded: any) {
|
|
7980
|
-
const
|
|
8291
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8292
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
8293
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8294
|
+
|
|
8295
|
+
const { treeNodeColumn } = reactData
|
|
8296
|
+
const { fullAllDataRowIdData, tableFullData, treeExpandedMaps, treeExpandLazyLoadedMaps } = internalData
|
|
8297
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
7981
8298
|
const { reserve, lazy, accordion, toggleMethod } = treeOpts
|
|
7982
|
-
const treeTempExpandedMaps = { ...treeExpandedMaps }
|
|
7983
8299
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
7984
8300
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
7985
8301
|
const result: any[] = []
|
|
7986
|
-
const columnIndex =
|
|
7987
|
-
const $columnIndex =
|
|
7988
|
-
|
|
8302
|
+
const columnIndex = $xeTable.getColumnIndex(treeNodeColumn)
|
|
8303
|
+
const $columnIndex = $xeTable.getVMColumnIndex(treeNodeColumn)
|
|
8304
|
+
const { handleGetRowId } = createHandleGetRowId($xeTable)
|
|
8305
|
+
let validRows = toggleMethod ? rows.filter((row: any) => toggleMethod({ $table: $xeTable, expanded, column: treeNodeColumn, columnIndex, $columnIndex, row })) : rows
|
|
7989
8306
|
if (accordion) {
|
|
7990
8307
|
validRows = validRows.length ? [validRows[validRows.length - 1]] : []
|
|
7991
8308
|
// 同一级只能展开一个
|
|
7992
8309
|
const matchObj = XEUtils.findTree(tableFullData, item => item === validRows[0], { children: childrenField })
|
|
7993
8310
|
if (matchObj) {
|
|
7994
8311
|
matchObj.items.forEach(item => {
|
|
7995
|
-
const rowid =
|
|
7996
|
-
if (
|
|
7997
|
-
delete
|
|
8312
|
+
const rowid = handleGetRowId(item)
|
|
8313
|
+
if (treeExpandedMaps[rowid]) {
|
|
8314
|
+
delete treeExpandedMaps[rowid]
|
|
7998
8315
|
}
|
|
7999
8316
|
})
|
|
8000
8317
|
}
|
|
8001
8318
|
}
|
|
8002
8319
|
if (expanded) {
|
|
8003
8320
|
validRows.forEach((row: any) => {
|
|
8004
|
-
const rowid =
|
|
8005
|
-
if (!
|
|
8321
|
+
const rowid = handleGetRowId(row)
|
|
8322
|
+
if (!treeExpandedMaps[rowid]) {
|
|
8006
8323
|
const rowRest = fullAllDataRowIdData[rowid]
|
|
8007
8324
|
if (rowRest) {
|
|
8008
8325
|
const isLoad = lazy && row[hasChildField] && !rowRest.treeLoaded && !treeExpandLazyLoadedMaps[rowid]
|
|
8009
8326
|
// 是否使用懒加载
|
|
8010
8327
|
if (isLoad) {
|
|
8011
|
-
result.push(
|
|
8328
|
+
result.push(handleAsyncTreeExpandChilds($xeTable, row))
|
|
8012
8329
|
} else {
|
|
8013
8330
|
if (row[childrenField] && row[childrenField].length) {
|
|
8014
|
-
|
|
8331
|
+
treeExpandedMaps[rowid] = row
|
|
8015
8332
|
}
|
|
8016
8333
|
}
|
|
8017
8334
|
}
|
|
@@ -8019,18 +8336,18 @@ const Methods = {
|
|
|
8019
8336
|
})
|
|
8020
8337
|
} else {
|
|
8021
8338
|
validRows.forEach((item: any) => {
|
|
8022
|
-
const rowid =
|
|
8023
|
-
if (
|
|
8024
|
-
delete
|
|
8339
|
+
const rowid = handleGetRowId(item)
|
|
8340
|
+
if (treeExpandedMaps[rowid]) {
|
|
8341
|
+
delete treeExpandedMaps[rowid]
|
|
8025
8342
|
}
|
|
8026
8343
|
})
|
|
8027
8344
|
}
|
|
8028
8345
|
if (reserve) {
|
|
8029
|
-
validRows.forEach((row: any) =>
|
|
8346
|
+
validRows.forEach((row: any) => handleTreeExpandReserve($xeTable, row, expanded))
|
|
8030
8347
|
}
|
|
8031
|
-
|
|
8348
|
+
reactData.treeExpandedFlag++
|
|
8032
8349
|
return Promise.all(result).then(() => {
|
|
8033
|
-
return
|
|
8350
|
+
return $xeTable.recalculate()
|
|
8034
8351
|
})
|
|
8035
8352
|
},
|
|
8036
8353
|
/**
|
|
@@ -8084,31 +8401,40 @@ const Methods = {
|
|
|
8084
8401
|
* @param {Row} row 行对象
|
|
8085
8402
|
*/
|
|
8086
8403
|
isTreeExpandByRow (row: any) {
|
|
8087
|
-
const
|
|
8088
|
-
|
|
8404
|
+
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8405
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
8406
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8407
|
+
|
|
8408
|
+
const { treeExpandedFlag } = reactData
|
|
8409
|
+
const { treeExpandedMaps } = internalData
|
|
8410
|
+
return !!treeExpandedFlag && !!treeExpandedMaps[getRowid($xeTable, row)]
|
|
8089
8411
|
},
|
|
8090
8412
|
/**
|
|
8091
8413
|
* 手动清空树形节点的展开状态,数据会恢复成未展开的状态
|
|
8092
8414
|
*/
|
|
8093
8415
|
clearTreeExpand () {
|
|
8094
8416
|
const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
|
|
8417
|
+
const reactData = $xeTable as unknown as TableReactData
|
|
8418
|
+
const internalData = $xeTable as unknown as TableInternalData
|
|
8095
8419
|
|
|
8096
|
-
const {
|
|
8097
|
-
const
|
|
8420
|
+
const { tableFullTreeData } = internalData
|
|
8421
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
8098
8422
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
8099
|
-
const
|
|
8100
|
-
|
|
8423
|
+
const { transform, reserve } = treeOpts
|
|
8424
|
+
const expList = $xeTable.getTreeExpandRecords()
|
|
8425
|
+
internalData.treeExpandedMaps = {}
|
|
8426
|
+
reactData.treeExpandedFlag++
|
|
8101
8427
|
if (reserve) {
|
|
8102
|
-
XEUtils.eachTree(
|
|
8428
|
+
XEUtils.eachTree(tableFullTreeData, row => handleTreeExpandReserve($xeTable, row, false), { children: childrenField })
|
|
8103
8429
|
}
|
|
8104
|
-
return
|
|
8430
|
+
return $xeTable.handleTableData().then(() => {
|
|
8105
8431
|
if (transform) {
|
|
8106
8432
|
handleVirtualTreeToList($xeTable)
|
|
8107
|
-
return
|
|
8433
|
+
return $xeTable.handleTableData()
|
|
8108
8434
|
}
|
|
8109
8435
|
}).then(() => {
|
|
8110
8436
|
if (expList.length) {
|
|
8111
|
-
|
|
8437
|
+
$xeTable.recalculate()
|
|
8112
8438
|
}
|
|
8113
8439
|
})
|
|
8114
8440
|
},
|
|
@@ -8116,17 +8442,6 @@ const Methods = {
|
|
|
8116
8442
|
this.treeExpandedReserveRowMap = {}
|
|
8117
8443
|
return this.$nextTick()
|
|
8118
8444
|
},
|
|
8119
|
-
handleTreeExpandReserve (row: any, expanded: any) {
|
|
8120
|
-
const { treeExpandedReserveRowMap, treeOpts } = this
|
|
8121
|
-
if (treeOpts.reserve) {
|
|
8122
|
-
const rowid = getRowid(this, row)
|
|
8123
|
-
if (expanded) {
|
|
8124
|
-
treeExpandedReserveRowMap[rowid] = row
|
|
8125
|
-
} else if (treeExpandedReserveRowMap[rowid]) {
|
|
8126
|
-
delete treeExpandedReserveRowMap[rowid]
|
|
8127
|
-
}
|
|
8128
|
-
}
|
|
8129
|
-
},
|
|
8130
8445
|
/**
|
|
8131
8446
|
* 获取表格的滚动状态
|
|
8132
8447
|
*/
|
|
@@ -8451,10 +8766,10 @@ const Methods = {
|
|
|
8451
8766
|
}
|
|
8452
8767
|
|
|
8453
8768
|
const { highlightHoverRow } = tableProps
|
|
8454
|
-
const { scrollXLoad, scrollYLoad } = reactData
|
|
8769
|
+
const { scrollXLoad, scrollYLoad, expandColumn } = reactData
|
|
8455
8770
|
const leftFixedWidth = $xeTable.computeLeftFixedWidth
|
|
8456
8771
|
const rightFixedWidth = $xeTable.computeRightFixedWidth
|
|
8457
|
-
if (!(scrollYLoad || leftFixedWidth || rightFixedWidth)) {
|
|
8772
|
+
if (!(scrollYLoad || leftFixedWidth || rightFixedWidth || expandColumn)) {
|
|
8458
8773
|
return
|
|
8459
8774
|
}
|
|
8460
8775
|
|
|
@@ -8723,8 +9038,8 @@ const Methods = {
|
|
|
8723
9038
|
const reactData = $xeTable as unknown as TableReactData
|
|
8724
9039
|
const internalData = $xeTable as unknown as TableInternalData
|
|
8725
9040
|
|
|
8726
|
-
const { isAllOverflow, scrollYLoad, expandColumn
|
|
8727
|
-
const { scrollYStore, elemStore, isResizeCellHeight, afterFullData, fullAllDataRowIdData } = internalData
|
|
9041
|
+
const { isAllOverflow, scrollYLoad, expandColumn } = reactData
|
|
9042
|
+
const { scrollYStore, elemStore, isResizeCellHeight, afterFullData, fullAllDataRowIdData, rowExpandedMaps } = internalData
|
|
8728
9043
|
const { startIndex } = scrollYStore
|
|
8729
9044
|
const expandOpts = $xeTable.computeExpandOpts
|
|
8730
9045
|
const rowOpts = $xeTable.computeRowOpts
|
|
@@ -9059,7 +9374,7 @@ const Methods = {
|
|
|
9059
9374
|
if (this.footerSpanMethod) {
|
|
9060
9375
|
errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method'])
|
|
9061
9376
|
}
|
|
9062
|
-
setMerges(this, merges, this.mergeFooterList
|
|
9377
|
+
setMerges(this, merges, this.mergeFooterList)
|
|
9063
9378
|
return this.$nextTick().then(() => {
|
|
9064
9379
|
this.updateCellAreas()
|
|
9065
9380
|
return updateStyle($xeTable)
|