vxe-table 3.14.0-beta.20 → 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.
Files changed (45) hide show
  1. package/es/style.css +1 -1
  2. package/es/table/module/edit/mixin.js +14 -9
  3. package/es/table/module/validator/mixin.js +2 -2
  4. package/es/table/src/body.js +10 -10
  5. package/es/table/src/cell.js +15 -11
  6. package/es/table/src/methods.js +509 -458
  7. package/es/table/src/table.js +46 -26
  8. package/es/table/src/util.js +2 -2
  9. package/es/ui/index.js +1 -1
  10. package/es/ui/src/log.js +1 -1
  11. package/lib/index.umd.js +761 -670
  12. package/lib/index.umd.min.js +1 -1
  13. package/lib/style.css +1 -1
  14. package/lib/table/module/edit/mixin.js +16 -11
  15. package/lib/table/module/edit/mixin.min.js +1 -1
  16. package/lib/table/module/validator/mixin.js +3 -3
  17. package/lib/table/module/validator/mixin.min.js +1 -1
  18. package/lib/table/src/body.js +16 -11
  19. package/lib/table/src/body.min.js +1 -1
  20. package/lib/table/src/cell.js +22 -13
  21. package/lib/table/src/cell.min.js +1 -1
  22. package/lib/table/src/methods.js +623 -559
  23. package/lib/table/src/methods.min.js +1 -1
  24. package/lib/table/src/table.js +51 -25
  25. package/lib/table/src/table.min.js +1 -1
  26. package/lib/table/src/util.js +2 -2
  27. package/lib/table/src/util.min.js +1 -1
  28. package/lib/ui/index.js +1 -1
  29. package/lib/ui/index.min.js +1 -1
  30. package/lib/ui/src/log.js +1 -1
  31. package/lib/ui/src/log.min.js +1 -1
  32. package/package.json +2 -2
  33. package/packages/table/module/edit/mixin.ts +17 -12
  34. package/packages/table/module/validator/mixin.ts +2 -2
  35. package/packages/table/src/body.ts +10 -10
  36. package/packages/table/src/cell.ts +15 -11
  37. package/packages/table/src/methods.ts +559 -481
  38. package/packages/table/src/table.ts +53 -31
  39. package/packages/table/src/util.ts +2 -2
  40. /package/es/{iconfont.1742353673989.ttf → iconfont.1742437924038.ttf} +0 -0
  41. /package/es/{iconfont.1742353673989.woff → iconfont.1742437924038.woff} +0 -0
  42. /package/es/{iconfont.1742353673989.woff2 → iconfont.1742437924038.woff2} +0 -0
  43. /package/lib/{iconfont.1742353673989.ttf → iconfont.1742437924038.ttf} +0 -0
  44. /package/lib/{iconfont.1742353673989.woff → iconfont.1742437924038.woff} +0 -0
  45. /package/lib/{iconfont.1742353673989.woff2 → iconfont.1742437924038.woff2} +0 -0
@@ -341,9 +341,10 @@ function updateAfterListIndex ($xeTable: VxeTableConstructor) {
341
341
 
342
342
  const { treeConfig } = props
343
343
  const { afterFullData, fullDataRowIdData, fullAllDataRowIdData } = internalData
344
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
344
345
  const fullMaps: Record<string, any> = {}
345
346
  afterFullData.forEach((row, index) => {
346
- const rowid = getRowid($xeTable, row)
347
+ const rowid = handleGetRowId(row)
347
348
  const rowRest = fullAllDataRowIdData[rowid]
348
349
  const seq = index + 1
349
350
  if (rowRest) {
@@ -376,8 +377,9 @@ function updateAfterDataIndex ($xeTable: VxeTableConstructor) {
376
377
  const childrenField = treeOpts.children || treeOpts.childrenField
377
378
  const fullMaps: Record<string, any> = {}
378
379
  if (treeConfig) {
380
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
379
381
  XEUtils.eachTree(afterTreeFullData, (row, index, items, path) => {
380
- const rowid = getRowid($xeTable, row)
382
+ const rowid = handleGetRowId(row)
381
383
  const rowRest = fullAllDataRowIdData[rowid]
382
384
  const seq = path.map((num, i) => i % 2 === 0 ? (Number(num) + 1) : '.').join('')
383
385
  if (rowRest) {
@@ -403,22 +405,21 @@ function updateAfterDataIndex ($xeTable: VxeTableConstructor) {
403
405
  */
404
406
  function handleVirtualTreeToList ($xeTable: VxeTableConstructor) {
405
407
  const props = $xeTable
406
- const reactData = $xeTable as unknown as TableReactData
407
408
  const internalData = $xeTable as unknown as TableInternalData
408
409
 
409
410
  const { treeConfig } = props
410
- const { treeExpandedMaps } = reactData
411
- const { fullAllDataRowIdData } = internalData
411
+ const { fullAllDataRowIdData, treeExpandedMaps } = internalData
412
412
  const treeOpts = $xeTable.computeTreeOpts
413
413
  const childrenField = treeOpts.children || treeOpts.childrenField
414
414
  if (treeConfig && treeOpts.transform) {
415
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
415
416
  const fullData: any[] = []
416
417
  const expandMaps: {
417
418
  [key: string]: number
418
419
  } = {}
419
420
  XEUtils.eachTree(internalData.afterTreeFullData, (row, index, items, path, parentRow) => {
420
- const rowid = getRowid($xeTable, row)
421
- const parentRowid = getRowid($xeTable, parentRow)
421
+ const rowid = handleGetRowId(row)
422
+ const parentRowid = handleGetRowId(parentRow)
422
423
  if (!parentRow || (expandMaps[parentRowid] && treeExpandedMaps[parentRowid])) {
423
424
  const rowRest = fullAllDataRowIdData[rowid]
424
425
  if (rowRest) {
@@ -864,8 +865,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
864
865
  const internalData = $xeTable as unknown as TableInternalData
865
866
 
866
867
  const { treeConfig } = props
867
- const { selectCheckboxMaps } = reactData
868
- const { afterFullData, checkboxReserveRowMap } = internalData
868
+ const { afterFullData, checkboxReserveRowMap, selectCheckboxMaps } = internalData
869
869
  const treeOpts = $xeTable.computeTreeOpts
870
870
  const childrenField = treeOpts.children || treeOpts.childrenField
871
871
  const checkboxOpts = $xeTable.computeCheckboxOpts
@@ -882,7 +882,7 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
882
882
  const checkValFn = (row: any) => {
883
883
  if (isForce || (!checkMethod || checkMethod({ row }))) {
884
884
  if (checked) {
885
- selectRowMaps[getRowid($xeTable, row)] = row
885
+ selectRowMaps[handleGetRowId(row)] = row
886
886
  }
887
887
  XEUtils.set(row, checkField, checked)
888
888
  }
@@ -974,11 +974,11 @@ function handleCheckedAllCheckboxRow ($xeTable: VxeTableConstructor & VxeTablePr
974
974
  afterFullData.forEach((row) => handleCheckboxReserveRow($xeTable, row, false))
975
975
  }
976
976
  }
977
- reactData.selectCheckboxMaps = checkField ? {} : selectRowMaps
977
+ reactData.updateCheckboxFlag++
978
+ internalData.selectCheckboxMaps = checkField ? {} : selectRowMaps
978
979
 
979
980
  reactData.isAllSelected = checked
980
981
  reactData.isIndeterminate = false
981
- reactData.treeIndeterminateMaps = {}
982
982
  internalData.treeIndeterminateRowMaps = {}
983
983
  $xeTable.checkSelectionStatus()
984
984
  return $xeTable.$nextTick()
@@ -991,8 +991,8 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
991
991
  const internalData = $xeTable as unknown as TableInternalData
992
992
 
993
993
  const { treeConfig } = props
994
- const { expandColumn, currentRow, selectCheckboxMaps, selectRadioRow, rowExpandedMaps, treeExpandedMaps } = reactData
995
- const { fullDataRowIdData, fullAllDataRowIdData, radioReserveRow } = internalData
994
+ const { expandColumn, currentRow, selectRadioRow } = reactData
995
+ const { fullDataRowIdData, fullAllDataRowIdData, radioReserveRow, selectCheckboxMaps, treeExpandedMaps, rowExpandedMaps } = internalData
996
996
  const expandOpts = $xeTable.computeExpandOpts
997
997
  const treeOpts = $xeTable.computeTreeOpts
998
998
  const radioOpts = $xeTable.computeRadioOpts
@@ -1009,7 +1009,8 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
1009
1009
  }
1010
1010
  }
1011
1011
  // 复选框
1012
- reactData.selectCheckboxMaps = getRecoverRowMaps($xeTable, selectCheckboxMaps) // 刷新多选行状态
1012
+ internalData.selectCheckboxMaps = getRecoverRowMaps($xeTable, selectCheckboxMaps) // 刷新多选行状态
1013
+ reactData.updateCheckboxFlag++
1013
1014
  // 还原保留选中状态
1014
1015
  if (checkboxOpts.reserve) {
1015
1016
  handleCheckedCheckboxRow($xeTable, handleReserveRow($xeTable, internalData.checkboxReserveRowMap), true, true)
@@ -1018,18 +1019,168 @@ function handleReserveStatus ($xeTable: VxeTableConstructor & VxeTablePrivateMet
1018
1019
  reactData.currentRow = null // 刷新当前行状态
1019
1020
  }
1020
1021
  // 行展开
1021
- reactData.rowExpandedMaps = expandColumn ? getRecoverRowMaps($xeTable, rowExpandedMaps) : {} // 刷新行展开状态
1022
+ internalData.rowExpandedMaps = expandColumn ? getRecoverRowMaps($xeTable, rowExpandedMaps) : {} // 刷新行展开状态
1023
+ reactData.rowExpandedFlag++
1022
1024
  // 还原保留状态
1023
1025
  if (expandColumn && expandOpts.reserve) {
1024
1026
  $xeTable.setRowExpand(handleReserveRow($xeTable, internalData.rowExpandedReserveRowMap), true)
1025
1027
  }
1026
1028
  // 树展开
1027
- reactData.treeExpandedMaps = treeConfig ? getRecoverRowMaps($xeTable, treeExpandedMaps) : {} // 刷新树展开状态
1029
+ internalData.treeExpandedMaps = treeConfig ? getRecoverRowMaps($xeTable, treeExpandedMaps) : {} // 刷新树展开状态
1030
+ reactData.treeExpandedFlag++
1028
1031
  if (treeConfig && treeOpts.reserve) {
1029
1032
  $xeTable.setTreeExpand(handleReserveRow($xeTable, internalData.treeExpandedReserveRowMap), true)
1030
1033
  }
1031
1034
  }
1032
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
+
1033
1184
  function calcVarRowHeightConfig ($xeTable: VxeTableConstructor, sizeKey: 'default' | 'medium' | 'small' | 'mini', sizeEl: Element) {
1034
1185
  const reactData = $xeTable as unknown as TableReactData
1035
1186
 
@@ -1095,12 +1246,13 @@ function handleVirtualYVisible ($xeTable: VxeTableConstructor) {
1095
1246
  toVisibleIndex = Math.floor(startTop / defaultRowHeight) - 1
1096
1247
  visibleSize = Math.ceil(clientHeight / defaultRowHeight) + 1
1097
1248
  } else {
1249
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
1098
1250
  let leftIndex = 0
1099
1251
  let rightIndex = afterFullData.length
1100
1252
  while (leftIndex < rightIndex) {
1101
1253
  const rIndex = Math.floor((leftIndex + rightIndex) / 2)
1102
1254
  const row = afterFullData[rIndex]
1103
- const rowid = getRowid($xeTable, row)
1255
+ const rowid = handleGetRowId(row)
1104
1256
  const rowRest = fullAllDataRowIdData[rowid] || {}
1105
1257
  if (rowRest.oTop <= startTop) {
1106
1258
  leftIndex = rIndex + 1
@@ -1111,7 +1263,7 @@ function handleVirtualYVisible ($xeTable: VxeTableConstructor) {
1111
1263
  toVisibleIndex = Math.max(0, leftIndex < afterFullData.length ? leftIndex - 2 : 0)
1112
1264
  for (let rIndex = toVisibleIndex, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
1113
1265
  const row = afterFullData[rIndex]
1114
- const rowid = getRowid($xeTable, row)
1266
+ const rowid = handleGetRowId(row)
1115
1267
  const rowRest = fullAllDataRowIdData[rowid] || {}
1116
1268
  visibleSize++
1117
1269
  if (rowRest.oTop > endTop || visibleSize >= 100) {
@@ -1143,16 +1295,20 @@ function calculateMergerOffsetIndex (list: any, offsetItem: any, type: any) {
1143
1295
  }
1144
1296
  }
1145
1297
 
1146
- function setMerges (_vm: any, merges: any, mList: any, rowList: any) {
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
+
1147
1302
  if (merges) {
1148
- const { treeConfig, visibleColumn } = _vm
1303
+ const { treeConfig } = props
1304
+ const { visibleColumn } = internalData
1149
1305
  if (!XEUtils.isArray(merges)) {
1150
1306
  merges = [merges]
1151
1307
  }
1152
1308
  if (treeConfig && merges.length) {
1153
1309
  errLog('vxe.error.noTree', ['merge-cells | merge-footer-items'])
1154
1310
  }
1155
- merges.forEach((item: any) => {
1311
+ merges.forEach((item) => {
1156
1312
  let { row, col, rowspan, colspan } = item
1157
1313
  if (rowList && XEUtils.isNumber(row)) {
1158
1314
  row = rowList[row]
@@ -1191,10 +1347,14 @@ function setMerges (_vm: any, merges: any, mList: any, rowList: any) {
1191
1347
  }
1192
1348
  }
1193
1349
 
1194
- function removeMerges (_vm: any, merges: any, mList: any, rowList: any) {
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
+
1195
1354
  const rest: any[] = []
1196
1355
  if (merges) {
1197
- const { treeConfig, visibleColumn } = _vm
1356
+ const { treeConfig } = props
1357
+ const { visibleColumn } = internalData
1198
1358
  if (!XEUtils.isArray(merges)) {
1199
1359
  merges = [merges]
1200
1360
  }
@@ -1407,8 +1567,9 @@ const calcCellHeight = ($xeTable: VxeTableConstructor) => {
1407
1567
  const defaultRowHeight = $xeTable.computeDefaultRowHeight
1408
1568
  const el = $xeTable.$refs.refElem as HTMLDivElement
1409
1569
  if (!isAllOverflow && scrollYLoad && el) {
1570
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
1410
1571
  tableData.forEach(row => {
1411
- const rowid = getRowid($xeTable, row)
1572
+ const rowid = handleGetRowId(row)
1412
1573
  const rowRest = fullAllDataRowIdData[rowid]
1413
1574
  if (rowRest) {
1414
1575
  const height = calcCellAutoHeight(rowRest, el)
@@ -2080,6 +2241,39 @@ function loadScrollYData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods
2080
2241
  }
2081
2242
  }
2082
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
+
2083
2277
  function lazyScrollXData ($xeTable: VxeTableConstructor & VxeTablePrivateMethods) {
2084
2278
  const internalData = $xeTable as unknown as TableInternalData
2085
2279
 
@@ -2246,7 +2440,7 @@ function calcCellWidth ($xeTable: VxeTableConstructor & VxeTablePrivateMethods)
2246
2440
 
2247
2441
  function handleUpdateColResize ($xeTable: VxeTableConstructor & VxeTablePrivateMethods, evnt: MouseEvent, params: any) {
2248
2442
  $xeTable.analyColumnWidth()
2249
- $xeTable.recalculate(true).then(() => {
2443
+ $xeTable.recalculate().then(() => {
2250
2444
  $xeTable.saveCustomStore('update:width')
2251
2445
  $xeTable.updateCellAreas()
2252
2446
  $xeTable.dispatchEvent('column-resizable-change', params, evnt)
@@ -2260,7 +2454,7 @@ function handleUpdateRowResize ($xeTable: VxeTableConstructor & VxeTablePrivateM
2260
2454
  const reactData = $xeTable as unknown as TableReactData
2261
2455
 
2262
2456
  reactData.resizeHeightFlag++
2263
- $xeTable.recalculate(true).then(() => {
2457
+ $xeTable.recalculate().then(() => {
2264
2458
  $xeTable.updateCellAreas()
2265
2459
  $xeTable.dispatchEvent('row-resizable-change', params, evnt)
2266
2460
  setTimeout(() => $xeTable.recalculate(true), 300)
@@ -2285,16 +2479,17 @@ function updateRowOffsetTop ($xeTable: VxeTableConstructor & VxeTablePrivateMeth
2285
2479
  const reactData = $xeTable as unknown as TableReactData
2286
2480
  const internalData = $xeTable as unknown as TableInternalData
2287
2481
 
2288
- const { expandColumn, rowExpandedMaps } = reactData
2289
- const { afterFullData, fullAllDataRowIdData } = internalData
2482
+ const { expandColumn } = reactData
2483
+ const { afterFullData, fullAllDataRowIdData, rowExpandedMaps } = internalData
2290
2484
  const expandOpts = $xeTable.computeExpandOpts
2291
2485
  const rowOpts = $xeTable.computeRowOpts
2292
2486
  const cellOpts = $xeTable.computeCellOpts
2293
2487
  const defaultRowHeight = $xeTable.computeDefaultRowHeight
2488
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
2294
2489
  let offsetTop = 0
2295
2490
  for (let rIndex = 0, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
2296
2491
  const row = afterFullData[rIndex]
2297
- const rowid = getRowid($xeTable, row)
2492
+ const rowid = handleGetRowId(row)
2298
2493
  const rowRest = fullAllDataRowIdData[rowid] || {}
2299
2494
  rowRest.oTop = offsetTop
2300
2495
  offsetTop += rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight
@@ -2309,46 +2504,42 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
2309
2504
  const reactData = $xeTable as unknown as TableReactData
2310
2505
  const internalData = $xeTable as unknown as TableInternalData
2311
2506
 
2312
- const { expandColumn, scrollYLoad, rowExpandedMaps } = reactData
2507
+ const { expandColumn, scrollYLoad, scrollYTop, isScrollYBig } = reactData
2313
2508
  const expandOpts = $xeTable.computeExpandOpts
2314
2509
  const rowOpts = $xeTable.computeRowOpts
2315
2510
  const cellOpts = $xeTable.computeCellOpts
2316
2511
  const defaultRowHeight = $xeTable.computeDefaultRowHeight
2317
2512
  const { mode } = expandOpts
2318
2513
  if (expandColumn && mode === 'fixed') {
2319
- const { elemStore, afterFullData, fullAllDataRowIdData } = internalData
2514
+ const { elemStore, fullAllDataRowIdData } = internalData
2320
2515
  const rowExpandEl = $xeTable.$refs.refRowExpandElem as HTMLDivElement
2321
2516
  const bodyScrollElem = getRefElem(elemStore['main-body-scroll'])
2322
2517
  if (rowExpandEl && bodyScrollElem) {
2323
2518
  let isUpdateHeight = false
2324
- if (scrollYLoad) {
2325
- let offsetTop = 0
2326
- for (let rIndex = 0, rLen = afterFullData.length; rIndex < rLen; rIndex++) {
2327
- const row = afterFullData[rIndex]
2328
- const rowid = getRowid($xeTable, row)
2329
- const rowRest = fullAllDataRowIdData[rowid] || {}
2330
- rowRest.oTop = offsetTop
2331
- offsetTop += rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight
2332
- // 是否展开行
2333
- if (expandColumn && rowExpandedMaps[rowid]) {
2334
- offsetTop += rowRest.expandHeight || expandOpts.height || 0
2335
- }
2336
- }
2337
- }
2338
2519
  XEUtils.arrayEach(rowExpandEl.children, reEl => {
2339
2520
  const expandEl = reEl as HTMLDivElement
2340
2521
  const rowid = expandEl.getAttribute('rowid') || ''
2341
2522
  const rowRest = fullAllDataRowIdData[rowid]
2342
2523
  if (rowRest) {
2343
2524
  const expandHeight = expandEl.offsetHeight + 1
2525
+ const trEl = bodyScrollElem.querySelector(`.vxe-body--row[rowid="${rowid}"]`) as HTMLTableCellElement
2526
+ let offsetTop = 0
2344
2527
  if (scrollYLoad) {
2345
- expandEl.style.top = toCssUnit(rowRest.oTop + (rowRest.resizeHeight || cellOpts.height || rowOpts.height || rowRest.height || defaultRowHeight))
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
+ }
2346
2533
  } else {
2347
- const trEl = bodyScrollElem.querySelector(`.vxe-body--row[rowid="${rowid}"]`) as HTMLTableCellElement
2348
2534
  if (trEl) {
2349
- expandEl.style.top = toCssUnit(trEl.offsetTop + trEl.offsetHeight)
2535
+ offsetTop = trEl.offsetTop + trEl.offsetHeight
2350
2536
  }
2351
2537
  }
2538
+ if (isScrollYBig) {
2539
+ offsetTop += scrollYTop
2540
+ }
2541
+ expandEl.style.top = toCssUnit(offsetTop)
2542
+
2352
2543
  if (!isUpdateHeight) {
2353
2544
  if (rowRest.expandHeight !== expandHeight) {
2354
2545
  isUpdateHeight = true
@@ -2359,6 +2550,9 @@ function updateRowExpandStyle ($xeTable: VxeTableConstructor & VxeTablePrivateMe
2359
2550
  })
2360
2551
  if (isUpdateHeight) {
2361
2552
  reactData.rowExpandHeightFlag++
2553
+ $xeTable.$nextTick(() => {
2554
+ updateRowOffsetTop($xeTable)
2555
+ })
2362
2556
  }
2363
2557
  }
2364
2558
  }
@@ -2760,15 +2954,13 @@ const Methods = {
2760
2954
  const internalData = $xeTable as unknown as TableInternalData
2761
2955
 
2762
2956
  const { treeConfig } = props
2763
- const { treeExpandedMaps } = reactData
2764
- const { fullAllDataRowIdData, tableFullData, tableFullTreeData } = internalData
2957
+ const { fullAllDataRowIdData, tableFullData, tableFullTreeData, treeExpandedMaps } = internalData
2765
2958
  const treeOpts = $xeTable.computeTreeOpts
2766
2959
  const childrenField = treeOpts.children || treeOpts.childrenField
2767
2960
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
2768
2961
  const { lazy } = treeOpts
2769
2962
  const fullAllDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = { ...fullAllDataRowIdData } // 存在已删除数据
2770
2963
  const fullDataRowIdMaps: Record<string, VxeTableDefines.RowCacheItem> = {}
2771
- const treeTempExpandedMaps = { ...treeExpandedMaps }
2772
2964
 
2773
2965
  const { handleUpdateRowId } = createHandleUpdateRowId($xeTable)
2774
2966
  const handleRowCache = (row: any, index: number, items: any, currIndex: number, parentRow: any, rowid: string, level: number, seq: string | number) => {
@@ -2794,13 +2986,12 @@ const Methods = {
2794
2986
  XEUtils.eachTree(tableFullTreeData, (row, index, items, path, parentRow, nodes) => {
2795
2987
  const rowid = handleUpdateRowId(row)
2796
2988
  if (treeConfig && lazy) {
2797
- const treeExpRest = treeTempExpandedMaps[rowid]
2798
2989
  if (row[hasChildField] && row[childrenField] === undefined) {
2799
2990
  row[childrenField] = null
2800
2991
  }
2801
- if (treeExpRest) {
2992
+ if (treeExpandedMaps[rowid]) {
2802
2993
  if (!row[childrenField] || !row[childrenField].length) {
2803
- delete treeTempExpandedMaps[rowid]
2994
+ delete treeExpandedMaps[rowid]
2804
2995
  }
2805
2996
  }
2806
2997
  }
@@ -2814,7 +3005,7 @@ const Methods = {
2814
3005
 
2815
3006
  internalData.fullDataRowIdData = fullDataRowIdMaps
2816
3007
  internalData.fullAllDataRowIdData = fullAllDataRowIdMaps
2817
- reactData.treeExpandedMaps = treeTempExpandedMaps
3008
+ reactData.treeExpandedFlag++
2818
3009
  },
2819
3010
  cacheSourceMap (fullData: any[]) {
2820
3011
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
@@ -2926,47 +3117,22 @@ const Methods = {
2926
3117
  * 根据 row 获取序号
2927
3118
  * @param {Row} row 行对象
2928
3119
  */
2929
- getRowSeq (row: any) {
2930
- const { fullAllDataRowIdData } = this
2931
- if (row) {
2932
- const rowid = getRowid(this, row)
2933
- const rest = fullAllDataRowIdData[rowid]
2934
- if (rest) {
2935
- return rest.seq
2936
- }
2937
- }
2938
- return -1
2939
- },
3120
+ getRowSeq: createGetRowCacheProp('seq'),
2940
3121
  /**
2941
3122
  * 根据 row 获取相对于 data 中的索引
2942
3123
  * @param {Row} row 行对象
2943
3124
  */
2944
- getRowIndex (row: any) {
2945
- const { fullAllDataRowIdData } = this
2946
- if (row) {
2947
- const rowid = getRowid(this, row)
2948
- const rest = fullAllDataRowIdData[rowid]
2949
- if (rest) {
2950
- return rest.index
2951
- }
2952
- }
2953
- return -1
2954
- },
3125
+ getRowIndex: createGetRowCacheProp('index') as ((row: any) => number),
2955
3126
  /**
2956
3127
  * 根据 row 获取相对于当前数据中的索引
2957
3128
  * @param {Row} row 行对象
2958
3129
  */
2959
- getVTRowIndex (row: any) {
2960
- const { fullAllDataRowIdData } = this
2961
- if (row) {
2962
- const rowid = getRowid(this, row)
2963
- const rest = fullAllDataRowIdData[rowid]
2964
- if (rest) {
2965
- return rest._index
2966
- }
2967
- }
2968
- return -1
2969
- },
3130
+ getVTRowIndex: createGetRowCacheProp('_index') as ((row: any) => number),
3131
+ /**
3132
+ * 根据 row 获取渲染中的虚拟索引
3133
+ * @param {Row} row 行对象
3134
+ */
3135
+ getVMRowIndex: createGetRowCacheProp('$index') as ((row: any) => number),
2970
3136
  // 在 v3 中废弃
2971
3137
  _getRowIndex (row: any) {
2972
3138
  if (process.env.VUE_APP_VXE_ENV === 'development') {
@@ -2974,21 +3140,6 @@ const Methods = {
2974
3140
  }
2975
3141
  return this.getVTRowIndex(row)
2976
3142
  },
2977
- /**
2978
- * 根据 row 获取渲染中的虚拟索引
2979
- * @param {Row} row 行对象
2980
- */
2981
- getVMRowIndex (row: any) {
2982
- const { fullAllDataRowIdData } = this
2983
- if (row) {
2984
- const rowid = getRowid(this, row)
2985
- const rest = fullAllDataRowIdData[rowid]
2986
- if (rest) {
2987
- return rest.$index
2988
- }
2989
- }
2990
- return -1
2991
- },
2992
3143
  // 在 v3 中废弃
2993
3144
  $getRowIndex (row: any) {
2994
3145
  if (process.env.VUE_APP_VXE_ENV === 'development') {
@@ -3000,30 +3151,17 @@ const Methods = {
3000
3151
  * 根据 column 获取相对于 columns 中的索引
3001
3152
  * @param {ColumnInfo} column 列配置
3002
3153
  */
3003
- getColumnIndex (column: any) {
3004
- const { fullColumnIdData } = this
3005
- if (column) {
3006
- const rest = fullColumnIdData[column.id]
3007
- if (rest) {
3008
- return rest.index
3009
- }
3010
- }
3011
- return -1
3012
- },
3154
+ getColumnIndex: createGetColumnCacheProp('index'),
3013
3155
  /**
3014
3156
  * 根据 column 获取相对于当前表格列中的索引
3015
3157
  * @param {ColumnInfo} column 列配置
3016
3158
  */
3017
- getVTColumnIndex (column: any) {
3018
- const { fullColumnIdData } = this
3019
- if (column) {
3020
- const rest = fullColumnIdData[column.id]
3021
- if (rest) {
3022
- return rest._index
3023
- }
3024
- }
3025
- return -1
3026
- },
3159
+ getVTColumnIndex: createGetColumnCacheProp('_index'),
3160
+ /**
3161
+ * 根据 column 获取渲染中的虚拟索引
3162
+ * @param {ColumnInfo} column 列配置
3163
+ */
3164
+ getVMColumnIndex: createGetColumnCacheProp('$index'),
3027
3165
  // 在 v3 中废弃
3028
3166
  _getColumnIndex (column: any) {
3029
3167
  if (process.env.VUE_APP_VXE_ENV === 'development') {
@@ -3031,20 +3169,6 @@ const Methods = {
3031
3169
  }
3032
3170
  return this.getVTColumnIndex(column)
3033
3171
  },
3034
- /**
3035
- * 根据 column 获取渲染中的虚拟索引
3036
- * @param {ColumnInfo} column 列配置
3037
- */
3038
- getVMColumnIndex (column: any) {
3039
- const { fullColumnIdData } = this
3040
- if (column) {
3041
- const rest = fullColumnIdData[column.id]
3042
- if (rest) {
3043
- return rest.$index
3044
- }
3045
- }
3046
- return -1
3047
- },
3048
3172
  // 在 v3 中废弃
3049
3173
  $getColumnIndex (column: any) {
3050
3174
  if (process.env.VUE_APP_VXE_ENV === 'development') {
@@ -3143,6 +3267,7 @@ const Methods = {
3143
3267
  const removeTempMaps = { ...editStore.removeMaps }
3144
3268
  const treeOpts = $xeTable.computeTreeOpts
3145
3269
  const { transform } = treeOpts
3270
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
3146
3271
  if (!keepSource) {
3147
3272
  if (process.env.VUE_APP_VXE_ENV === 'development') {
3148
3273
  errLog('vxe.error.reqProp', ['keep-source'])
@@ -3160,7 +3285,7 @@ const Methods = {
3160
3285
  let reDelFlag = false
3161
3286
  if (targetRows.length) {
3162
3287
  targetRows.forEach((item: any) => {
3163
- const rowid = getRowid($xeTable, item)
3288
+ const rowid = handleGetRowId(item)
3164
3289
  const rowRest = fullAllDataRowIdData[rowid]
3165
3290
  if (rowRest) {
3166
3291
  const row = rowRest.row
@@ -3553,12 +3678,10 @@ const Methods = {
3553
3678
  getCheckboxRecords (isFull: boolean) {
3554
3679
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3555
3680
  const props = $xeTable
3556
- const reactData = $xeTable as unknown as TableReactData
3557
3681
  const internalData = $xeTable as unknown as TableInternalData
3558
3682
 
3559
3683
  const { treeConfig } = props
3560
- const { selectCheckboxMaps } = reactData
3561
- const { tableFullData, afterFullData, afterTreeFullData, tableFullTreeData, fullDataRowIdData, afterFullRowMaps } = internalData
3684
+ const { tableFullData, afterFullData, afterTreeFullData, tableFullTreeData, fullDataRowIdData, afterFullRowMaps, selectCheckboxMaps } = internalData
3562
3685
  const treeOpts = $xeTable.computeTreeOpts
3563
3686
  const checkboxOpts = $xeTable.computeCheckboxOpts
3564
3687
  const { transform, mapChildrenField } = treeOpts
@@ -3895,6 +4018,8 @@ const Methods = {
3895
4018
  * 默认执行一次,除非被重置
3896
4019
  */
3897
4020
  handleLoadDefaults () {
4021
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
4022
+
3898
4023
  if (this.checkboxConfig) {
3899
4024
  this.handleDefaultSelectionChecked()
3900
4025
  }
@@ -3905,7 +4030,7 @@ const Methods = {
3905
4030
  this.handleDefaultRowExpand()
3906
4031
  }
3907
4032
  if (this.treeConfig) {
3908
- this.handleDefaultTreeExpand()
4033
+ handleDefaultTreeExpand($xeTable)
3909
4034
  }
3910
4035
  if (this.mergeCells) {
3911
4036
  this.handleDefaultMergeCells()
@@ -3929,7 +4054,7 @@ const Methods = {
3929
4054
  * 设置为固定列
3930
4055
  */
3931
4056
  setColumnFixed (fieldOrColumn: any, fixed: any) {
3932
- const $xeTable = this
4057
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
3933
4058
 
3934
4059
  let status = false
3935
4060
  const cols = XEUtils.isArray(fieldOrColumn) ? fieldOrColumn : [fieldOrColumn]
@@ -4733,12 +4858,13 @@ const Methods = {
4733
4858
  const internalData = $xeTable as unknown as TableInternalData
4734
4859
 
4735
4860
  const { fullAllDataRowIdData, afterFullData } = internalData
4861
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
4736
4862
  const rowOpts = $xeTable.computeRowOpts
4737
4863
  const cellOpts = $xeTable.computeCellOpts
4738
4864
  const defaultRowHeight = $xeTable.computeDefaultRowHeight
4739
4865
  const rest: Record<string, number> = {}
4740
4866
  afterFullData.forEach(row => {
4741
- const rowid = getRowid($xeTable, row)
4867
+ const rowid = handleGetRowId(row)
4742
4868
  const rowRest = fullAllDataRowIdData[rowid]
4743
4869
  if (rowRest) {
4744
4870
  const resizeHeight = rowRest.resizeHeight
@@ -4766,8 +4892,9 @@ const Methods = {
4766
4892
  rHeight = Math.floor(rHeight * bodyHeight)
4767
4893
  }
4768
4894
  if (rHeight) {
4895
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
4769
4896
  rows.forEach(row => {
4770
- const rowid = XEUtils.isString(row) || XEUtils.isNumber(row) ? row : getRowid($xeTable, row)
4897
+ const rowid = XEUtils.isString(row) || XEUtils.isNumber(row) ? row : handleGetRowId(row)
4771
4898
  const rowRest = fullAllDataRowIdData[rowid]
4772
4899
  if (rowRest) {
4773
4900
  rowRest.resizeHeight = rHeight
@@ -5600,11 +5727,16 @@ const Methods = {
5600
5727
  * 获取复选框半选状态的行数据
5601
5728
  */
5602
5729
  getCheckboxIndeterminateRecords (isFull: any) {
5603
- const { treeConfig, treeIndeterminateMaps, fullDataRowIdData } = this
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
5604
5736
  if (treeConfig) {
5605
5737
  const fullRest: any[] = []
5606
5738
  const defRest: any[] = []
5607
- XEUtils.each(treeIndeterminateMaps, (item, rowid) => {
5739
+ XEUtils.each(treeIndeterminateRowMaps, (item, rowid) => {
5608
5740
  if (item) {
5609
5741
  fullRest.push(item)
5610
5742
  if (fullDataRowIdData[rowid]) {
@@ -5659,7 +5791,7 @@ const Methods = {
5659
5791
  },
5660
5792
  setCheckboxRowKey (keys: any, checked: boolean) {
5661
5793
  const $xeTable = this
5662
- const internalData = $xeTable
5794
+ const internalData = $xeTable as unknown as TableInternalData
5663
5795
 
5664
5796
  const { fullAllDataRowIdData } = internalData
5665
5797
  if (keys && !XEUtils.isArray(keys)) {
@@ -5676,23 +5808,25 @@ const Methods = {
5676
5808
  },
5677
5809
  isCheckedByCheckboxRow (row: any) {
5678
5810
  const $xeTable = this
5679
- const reactData = $xeTable
5811
+ const reactData = $xeTable as unknown as TableReactData
5812
+ const internalData = $xeTable as unknown as TableInternalData
5680
5813
 
5681
- const { selectCheckboxMaps } = reactData
5814
+ const { updateCheckboxFlag } = reactData
5815
+ const { selectCheckboxMaps } = internalData
5682
5816
  const checkboxOpts = $xeTable.computeCheckboxOpts
5683
5817
  const { checkField } = checkboxOpts
5684
5818
  if (checkField) {
5685
5819
  return XEUtils.get(row, checkField)
5686
5820
  }
5687
- return !!selectCheckboxMaps[getRowid($xeTable, row)]
5821
+ return !!updateCheckboxFlag && !!selectCheckboxMaps[getRowid($xeTable, row)]
5688
5822
  },
5689
5823
  isCheckedByCheckboxRowKey (rowid: string) {
5690
- const $xeTable = this
5691
- const reactData = $xeTable
5692
- 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
5693
5827
 
5694
- const { selectCheckboxMaps } = reactData
5695
- const { fullAllDataRowIdData } = internalData
5828
+ const { updateCheckboxFlag } = reactData
5829
+ const { fullAllDataRowIdData, selectCheckboxMaps } = internalData
5696
5830
  const checkboxOpts = $xeTable.computeCheckboxOpts
5697
5831
  const { checkField } = checkboxOpts
5698
5832
  if (checkField) {
@@ -5702,21 +5836,21 @@ const Methods = {
5702
5836
  }
5703
5837
  return false
5704
5838
  }
5705
- return !!selectCheckboxMaps[rowid]
5839
+ return !!updateCheckboxFlag && !!selectCheckboxMaps[rowid]
5706
5840
  },
5707
5841
  isIndeterminateByCheckboxRow (row: any) {
5708
- const $xeTable = this
5709
- const reactData = $xeTable
5842
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
5843
+ const internalData = $xeTable as unknown as TableInternalData
5710
5844
 
5711
- const { treeIndeterminateMaps } = reactData
5712
- return !!treeIndeterminateMaps[getRowid($xeTable, row)] && !$xeTable.isCheckedByCheckboxRow(row)
5845
+ const { treeIndeterminateRowMaps } = internalData
5846
+ return !!treeIndeterminateRowMaps[getRowid($xeTable, row)] && !$xeTable.isCheckedByCheckboxRow(row)
5713
5847
  },
5714
5848
  isIndeterminateByCheckboxRowKey (rowid: string) {
5715
5849
  const $xeTable = this
5716
- const reactData = $xeTable
5850
+ const internalData = $xeTable as unknown as TableInternalData
5717
5851
 
5718
- const { treeIndeterminateMaps } = reactData
5719
- return !!treeIndeterminateMaps[rowid] && !$xeTable.isCheckedByCheckboxRowKey(rowid)
5852
+ const { treeIndeterminateRowMaps } = internalData
5853
+ return !!treeIndeterminateRowMaps[rowid] && !$xeTable.isCheckedByCheckboxRowKey(rowid)
5720
5854
  },
5721
5855
  /**
5722
5856
  * 切换选中
@@ -5726,10 +5860,10 @@ const Methods = {
5726
5860
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
5727
5861
  const props = $xeTable
5728
5862
  const reactData = $xeTable as unknown as TableReactData
5863
+ const internalData = $xeTable as unknown as TableInternalData
5729
5864
 
5730
5865
  const { treeConfig } = props
5731
- const { selectCheckboxMaps } = reactData
5732
- const selectRowMaps = Object.assign({}, selectCheckboxMaps)
5866
+ const { selectCheckboxMaps } = internalData
5733
5867
  const treeOpts = $xeTable.computeTreeOpts
5734
5868
  const { transform, mapChildrenField } = treeOpts
5735
5869
  const childrenField = treeOpts.children || treeOpts.childrenField
@@ -5751,18 +5885,17 @@ const Methods = {
5751
5885
  handleCheckboxReserveRow($xeTable, row, checked)
5752
5886
  }
5753
5887
  }, { children: transform ? mapChildrenField : childrenField })
5754
- reactData.selectCheckboxMaps = selectRowMaps
5888
+ reactData.updateCheckboxFlag++
5755
5889
  return
5756
- } else {
5757
- // 列表
5758
- rows.forEach(row => {
5759
- if (isForce || (!checkMethod || checkMethod({ row }))) {
5760
- XEUtils.set(row, checkField, checked)
5761
- handleCheckboxReserveRow($xeTable, row, checked)
5762
- }
5763
- })
5764
5890
  }
5765
- reactData.selectCheckboxMaps = selectRowMaps
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++
5766
5899
  return
5767
5900
  }
5768
5901
 
@@ -5773,16 +5906,16 @@ const Methods = {
5773
5906
  const rowid = handleGetRowId(row)
5774
5907
  if (isForce || (!checkMethod || checkMethod({ row }))) {
5775
5908
  if (checked) {
5776
- selectRowMaps[rowid] = row
5909
+ selectCheckboxMaps[rowid] = row
5777
5910
  } else {
5778
- if (selectRowMaps[rowid]) {
5779
- delete selectRowMaps[rowid]
5911
+ if (selectCheckboxMaps[rowid]) {
5912
+ delete selectCheckboxMaps[rowid]
5780
5913
  }
5781
5914
  }
5782
5915
  handleCheckboxReserveRow($xeTable, row, checked)
5783
5916
  }
5784
5917
  }, { children: transform ? mapChildrenField : childrenField })
5785
- reactData.selectCheckboxMaps = selectRowMaps
5918
+ reactData.updateCheckboxFlag++
5786
5919
  return
5787
5920
  }
5788
5921
 
@@ -5791,18 +5924,18 @@ const Methods = {
5791
5924
  const rowid = handleGetRowId(row)
5792
5925
  if (isForce || (!checkMethod || checkMethod({ row }))) {
5793
5926
  if (checked) {
5794
- if (!selectRowMaps[rowid]) {
5795
- selectRowMaps[rowid] = row
5927
+ if (!selectCheckboxMaps[rowid]) {
5928
+ selectCheckboxMaps[rowid] = row
5796
5929
  }
5797
5930
  } else {
5798
- if (selectRowMaps[rowid]) {
5799
- delete selectRowMaps[rowid]
5931
+ if (selectCheckboxMaps[rowid]) {
5932
+ delete selectCheckboxMaps[rowid]
5800
5933
  }
5801
5934
  }
5802
5935
  handleCheckboxReserveRow($xeTable, row, checked)
5936
+ reactData.updateCheckboxFlag++
5803
5937
  }
5804
5938
  })
5805
- reactData.selectCheckboxMaps = selectRowMaps
5806
5939
  },
5807
5940
  /**
5808
5941
  * 即将移除
@@ -5815,9 +5948,9 @@ const Methods = {
5815
5948
  },
5816
5949
  handleToggleCheckRowEvent (evnt: any, params: any) {
5817
5950
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
5818
- const reactData = $xeTable as unknown as TableReactData
5951
+ const internalData = $xeTable as unknown as TableInternalData
5819
5952
 
5820
- const { selectCheckboxMaps } = reactData
5953
+ const { selectCheckboxMaps } = internalData
5821
5954
  const checkboxOpts = $xeTable.computeCheckboxOpts
5822
5955
  const { checkField, trigger } = checkboxOpts
5823
5956
  const { row } = params
@@ -5828,17 +5961,18 @@ const Methods = {
5828
5961
  if (checkField) {
5829
5962
  checked = !XEUtils.get(row, checkField)
5830
5963
  } else {
5831
- checked = !selectCheckboxMaps[getRowid(this, row)]
5964
+ checked = !selectCheckboxMaps[getRowid($xeTable, row)]
5832
5965
  }
5833
5966
  if (evnt) {
5834
5967
  $xeTable.triggerCheckRowEvent(evnt, params, checked)
5835
5968
  } else {
5836
- $xeTable.handleBatchSelectRows(params, checked)
5969
+ $xeTable.handleBatchSelectRows([row], checked)
5837
5970
  $xeTable.checkSelectionStatus()
5838
5971
  }
5839
5972
  },
5840
5973
  triggerCheckRowEvent (evnt: any, params: any, checked: any) {
5841
5974
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
5975
+ const props = $xeTable
5842
5976
  const internalData = $xeTable as unknown as TableInternalData
5843
5977
 
5844
5978
  const { row } = params
@@ -5849,7 +5983,7 @@ const Methods = {
5849
5983
  return
5850
5984
  }
5851
5985
  evnt.stopPropagation()
5852
- if (checkboxOpts.isShiftKey && evnt.shiftKey && !this.treeConfig) {
5986
+ if (checkboxOpts.isShiftKey && evnt.shiftKey && !props.treeConfig) {
5853
5987
  const checkboxRecords = $xeTable.getCheckboxRecords()
5854
5988
  if (checkboxRecords.length) {
5855
5989
  const firstRow = checkboxRecords[0]
@@ -5858,14 +5992,16 @@ const Methods = {
5858
5992
  if (_rowIndex !== _firstRowIndex) {
5859
5993
  $xeTable.setAllCheckboxRow(false)
5860
5994
  const rangeRows = _rowIndex < _firstRowIndex ? afterFullData.slice(_rowIndex, _firstRowIndex + 1) : afterFullData.slice(_firstRowIndex, _rowIndex + 1)
5861
- handleCheckedCheckboxRow($xeTable, rangeRows, true, false)
5995
+ $xeTable.$nextTick(() => {
5996
+ handleCheckedCheckboxRow($xeTable, rangeRows, true, false)
5997
+ })
5862
5998
  $xeTable.dispatchEvent('checkbox-range-select', Object.assign({ rangeRecords: rangeRows }, params), evnt)
5863
5999
  return
5864
6000
  }
5865
6001
  }
5866
6002
  }
5867
6003
  if (!checkMethod || checkMethod({ row })) {
5868
- $xeTable.handleBatchSelectRows(params, checked)
6004
+ $xeTable.handleBatchSelectRows([row], checked)
5869
6005
  $xeTable.checkSelectionStatus()
5870
6006
  $xeTable.dispatchEvent('checkbox-change', Object.assign({
5871
6007
  records: () => $xeTable.getCheckboxRecords(),
@@ -5879,9 +6015,11 @@ const Methods = {
5879
6015
  * 多选,切换某一行的选中状态
5880
6016
  */
5881
6017
  toggleCheckboxRow (row: any) {
5882
- const $xeTable = this
6018
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
6019
+ const internalData = $xeTable as unknown as TableInternalData
5883
6020
 
5884
- const { selectCheckboxMaps, checkboxOpts } = this
6021
+ const { selectCheckboxMaps } = internalData
6022
+ const checkboxOpts = $xeTable.computeCheckboxOpts
5885
6023
  const { checkField } = checkboxOpts
5886
6024
  const checked = checkField ? !XEUtils.get(row, checkField) : !selectCheckboxMaps[getRowid($xeTable, row)]
5887
6025
  $xeTable.handleBatchSelectRows([row], checked, true)
@@ -5904,9 +6042,7 @@ const Methods = {
5904
6042
  const internalData = $xeTable as unknown as TableInternalData
5905
6043
 
5906
6044
  const { treeConfig } = props
5907
- const { selectCheckboxMaps, treeIndeterminateMaps } = reactData
5908
- const selectRowMaps = Object.assign({}, selectCheckboxMaps)
5909
- const halfRowMaps = Object.assign({}, treeIndeterminateMaps)
6045
+ const { selectCheckboxMaps, treeIndeterminateRowMaps } = internalData
5910
6046
  const treeOpts = $xeTable.computeTreeOpts
5911
6047
  const { transform, mapChildrenField } = treeOpts
5912
6048
  const childrenField = treeOpts.children || treeOpts.childrenField
@@ -5940,28 +6076,28 @@ const Methods = {
5940
6076
  checkMethod
5941
6077
  ? (item) => {
5942
6078
  const childRowid = handleGetRowId(item)
5943
- const isSelect = checkField ? XEUtils.get(item, checkField) : selectRowMaps[childRowid]
6079
+ const isSelect = checkField ? XEUtils.get(item, checkField) : selectCheckboxMaps[childRowid]
5944
6080
  if (checkMethod({ row: item })) {
5945
6081
  if (isSelect) {
5946
6082
  sLen++
5947
- } else if (halfRowMaps[childRowid]) {
6083
+ } else if (treeIndeterminateRowMaps[childRowid]) {
5948
6084
  hLen++
5949
6085
  }
5950
6086
  vLen++
5951
6087
  } else {
5952
6088
  if (isSelect) {
5953
6089
  sLen++
5954
- } else if (halfRowMaps[childRowid]) {
6090
+ } else if (treeIndeterminateRowMaps[childRowid]) {
5955
6091
  hLen++
5956
6092
  }
5957
6093
  }
5958
6094
  }
5959
6095
  : item => {
5960
6096
  const childRowid = handleGetRowId(item)
5961
- const isSelect = checkField ? XEUtils.get(item, checkField) : selectRowMaps[childRowid]
6097
+ const isSelect = checkField ? XEUtils.get(item, checkField) : selectCheckboxMaps[childRowid]
5962
6098
  if (isSelect) {
5963
6099
  sLen++
5964
- } else if (halfRowMaps[childRowid]) {
6100
+ } else if (treeIndeterminateRowMaps[childRowid]) {
5965
6101
  hLen++
5966
6102
  }
5967
6103
  vLen++
@@ -5974,29 +6110,28 @@ const Methods = {
5974
6110
  }
5975
6111
  if (isSelected) {
5976
6112
  if (!checkField) {
5977
- selectRowMaps[rowid] = row
6113
+ selectCheckboxMaps[rowid] = row
5978
6114
  }
5979
- if (halfRowMaps[rowid]) {
5980
- delete halfRowMaps[rowid]
6115
+ if (treeIndeterminateRowMaps[rowid]) {
6116
+ delete treeIndeterminateRowMaps[rowid]
5981
6117
  }
5982
6118
  } else {
5983
6119
  if (!checkField) {
5984
- if (selectRowMaps[rowid]) {
5985
- delete selectRowMaps[rowid]
6120
+ if (selectCheckboxMaps[rowid]) {
6121
+ delete selectCheckboxMaps[rowid]
5986
6122
  }
5987
6123
  }
5988
6124
  if (halfSelect) {
5989
- halfRowMaps[rowid] = row
6125
+ treeIndeterminateRowMaps[rowid] = row
5990
6126
  } else {
5991
- if (halfRowMaps[rowid]) {
5992
- delete halfRowMaps[rowid]
6127
+ if (treeIndeterminateRowMaps[rowid]) {
6128
+ delete treeIndeterminateRowMaps[rowid]
5993
6129
  }
5994
6130
  }
5995
6131
  }
5996
6132
  })
5997
6133
  }
5998
- reactData.selectCheckboxMaps = selectRowMaps
5999
- reactData.treeIndeterminateMaps = halfRowMaps
6134
+ reactData.updateCheckboxFlag++
6000
6135
  },
6001
6136
  updateAllCheckboxStatus () {
6002
6137
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
@@ -6005,10 +6140,9 @@ const Methods = {
6005
6140
  const internalData = $xeTable as unknown as TableInternalData
6006
6141
 
6007
6142
  const { treeConfig } = props
6008
- const { selectCheckboxMaps, treeIndeterminateMaps } = reactData
6143
+ const { afterFullData, afterTreeFullData, checkboxReserveRowMap, selectCheckboxMaps, treeIndeterminateRowMaps } = internalData
6009
6144
  const checkboxOpts = $xeTable.computeCheckboxOpts
6010
6145
  const { checkField, checkMethod, showReserveStatus } = checkboxOpts
6011
- const { afterFullData, afterTreeFullData, checkboxReserveRowMap } = internalData
6012
6146
  const { handleGetRowId } = createHandleGetRowId($xeTable)
6013
6147
 
6014
6148
  let sLen = 0 // 已选
@@ -6023,14 +6157,14 @@ const Methods = {
6023
6157
  if (checkMethod({ row })) {
6024
6158
  if (selected) {
6025
6159
  sLen++
6026
- } else if (treeIndeterminateMaps[childRowid]) {
6160
+ } else if (treeIndeterminateRowMaps[childRowid]) {
6027
6161
  hLen++
6028
6162
  }
6029
6163
  vLen++
6030
6164
  } else {
6031
6165
  if (selected) {
6032
6166
  sLen++
6033
- } else if (treeIndeterminateMaps[childRowid]) {
6167
+ } else if (treeIndeterminateRowMaps[childRowid]) {
6034
6168
  hLen++
6035
6169
  }
6036
6170
  }
@@ -6040,7 +6174,7 @@ const Methods = {
6040
6174
  const selected = checkField ? XEUtils.get(row, checkField) : selectCheckboxMaps[childRowid]
6041
6175
  if (selected) {
6042
6176
  sLen++
6043
- } else if (treeIndeterminateMaps[childRowid]) {
6177
+ } else if (treeIndeterminateRowMaps[childRowid]) {
6044
6178
  hLen++
6045
6179
  }
6046
6180
  vLen++
@@ -6099,18 +6233,26 @@ const Methods = {
6099
6233
  * 获取复选框保留选中的行
6100
6234
  */
6101
6235
  getCheckboxReserveRecords (isFull: any) {
6102
- const { fullDataRowIdData, afterFullData, checkboxReserveRowMap, checkboxOpts, treeConfig, treeOpts } = this
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
6103
6244
  const childrenField = treeOpts.children || treeOpts.childrenField
6104
6245
  const reserveSelection: any[] = []
6105
6246
  if (checkboxOpts.reserve) {
6106
- const afterFullIdMaps: any = {}
6247
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
6248
+ const afterFullIdMaps: { [key: string]: number } = {}
6107
6249
  if (treeConfig) {
6108
6250
  XEUtils.eachTree(afterFullData, row => {
6109
- afterFullIdMaps[getRowid(this, row)] = 1
6251
+ afterFullIdMaps[handleGetRowId(row)] = 1
6110
6252
  }, { children: childrenField })
6111
6253
  } else {
6112
6254
  afterFullData.forEach((row: any) => {
6113
- afterFullIdMaps[getRowid(this, row)] = 1
6255
+ afterFullIdMaps[handleGetRowId(row)] = 1
6114
6256
  })
6115
6257
  }
6116
6258
  XEUtils.each(checkboxReserveRowMap, (oldRow, oldRowid) => {
@@ -6185,9 +6327,17 @@ const Methods = {
6185
6327
  * 清空行为不管是否被禁用还是保留记录,都将彻底清空选中状态
6186
6328
  */
6187
6329
  clearCheckboxRow () {
6188
- const { tableFullData, treeConfig, treeOpts, checkboxOpts } = this
6189
- const { checkField, reserve } = checkboxOpts
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
6190
6338
  const childrenField = treeOpts.children || treeOpts.childrenField
6339
+ const checkboxOpts = $xeTable.computeCheckboxOpts
6340
+ const { checkField, reserve } = checkboxOpts
6191
6341
  // indeterminateField 仅支持读取
6192
6342
  const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
6193
6343
  if (checkField) {
@@ -6204,12 +6354,13 @@ const Methods = {
6204
6354
  }
6205
6355
  }
6206
6356
  if (reserve) {
6207
- tableFullData.forEach((row: any) => this.handleCheckboxReserveRow(row, false))
6357
+ tableFullData.forEach((row) => this.handleCheckboxReserveRow(row, false))
6208
6358
  }
6209
- this.isAllSelected = false
6210
- this.isIndeterminate = false
6211
- this.selectCheckboxMaps = {}
6212
- this.treeIndeterminateMaps = {}
6359
+ reactData.isAllSelected = false
6360
+ reactData.isIndeterminate = false
6361
+ internalData.selectCheckboxMaps = {}
6362
+ internalData.treeIndeterminateRowMaps = {}
6363
+ reactData.updateCheckboxFlag++
6213
6364
  return this.$nextTick()
6214
6365
  },
6215
6366
  /**
@@ -6808,12 +6959,11 @@ const Methods = {
6808
6959
 
6809
6960
  const { treeConfig, dragConfig } = props
6810
6961
  const rowDragOpts = $xeTable.computeRowDragOpts
6811
- const { fullAllDataRowIdData } = internalData
6962
+ const { afterFullData, tableFullData, fullAllDataRowIdData } = internalData
6812
6963
  const { isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod, dragToChildMethod } = rowDragOpts
6813
6964
  const treeOpts = $xeTable.computeTreeOpts
6814
6965
  const { transform, rowField, mapChildrenField, parentField } = treeOpts
6815
6966
  const childrenField = treeOpts.children || treeOpts.childrenField
6816
- const { afterFullData, tableFullData } = internalData
6817
6967
  const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null)
6818
6968
  const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0
6819
6969
  const errRest = {
@@ -7409,8 +7559,8 @@ const Methods = {
7409
7559
  }
7410
7560
  },
7411
7561
  handleHeaderCellDragMousedownEvent (evnt: MouseEvent, params: any) {
7412
- const $xeTable = this
7413
- const reactData = $xeTable
7562
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7563
+ const reactData = $xeTable as unknown as TableReactData
7414
7564
 
7415
7565
  evnt.stopPropagation()
7416
7566
  const columnDragOpts = $xeTable.computeColumnDragOpts
@@ -7435,8 +7585,8 @@ const Methods = {
7435
7585
  $xeTable.dispatchEvent('column-dragstart', params, evnt)
7436
7586
  },
7437
7587
  handleHeaderCellDragMouseupEvent () {
7438
- const $xeTable = this
7439
- const reactData = $xeTable
7588
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7589
+ const reactData = $xeTable as unknown as TableReactData
7440
7590
 
7441
7591
  clearColDropOrigin($xeTable)
7442
7592
  hideDropTip($xeTable)
@@ -7445,54 +7595,58 @@ const Methods = {
7445
7595
  reactData.isDragColMove = false
7446
7596
  },
7447
7597
  setPendingRow (rows: any, status: any) {
7448
- const $xeTable = this
7449
- 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
7450
7601
 
7451
- const pendingMaps = Object.assign({}, reactData.pendingRowMaps)
7602
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
7603
+ const { pendingRowMaps } = internalData
7452
7604
  if (rows && !XEUtils.isArray(rows)) {
7453
7605
  rows = [rows]
7454
7606
  }
7455
7607
  if (status) {
7456
7608
  rows.forEach((row: any) => {
7457
- const rowid = getRowid($xeTable, row)
7458
- if (rowid && !pendingMaps[rowid]) {
7459
- pendingMaps[rowid] = row
7609
+ const rowid = handleGetRowId(row)
7610
+ if (rowid && !pendingRowMaps[rowid]) {
7611
+ pendingRowMaps[rowid] = row
7460
7612
  }
7461
7613
  })
7462
7614
  } else {
7463
7615
  rows.forEach((row: any) => {
7464
- const rowid = getRowid($xeTable, row)
7465
- if (rowid && pendingMaps[rowid]) {
7466
- delete pendingMaps[rowid]
7616
+ const rowid = handleGetRowId(row)
7617
+ if (rowid && pendingRowMaps[rowid]) {
7618
+ delete pendingRowMaps[rowid]
7467
7619
  }
7468
7620
  })
7469
7621
  }
7470
- reactData.pendingRowMaps = pendingMaps
7622
+ reactData.pendingRowFlag++
7471
7623
  return $xeTable.$nextTick()
7472
7624
  },
7473
7625
  togglePendingRow (rows: any) {
7474
- const $xeTable = this
7475
- 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
7476
7629
 
7477
- const pendingMaps = Object.assign({}, reactData.pendingRowMaps)
7630
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
7631
+ const { pendingRowMaps } = internalData
7478
7632
  if (rows && !XEUtils.isArray(rows)) {
7479
7633
  rows = [rows]
7480
7634
  }
7481
7635
  rows.forEach((row: any) => {
7482
- const rowid = getRowid($xeTable, row)
7636
+ const rowid = handleGetRowId(row)
7483
7637
  if (rowid) {
7484
- if (pendingMaps[rowid]) {
7485
- delete pendingMaps[rowid]
7638
+ if (pendingRowMaps[rowid]) {
7639
+ delete pendingRowMaps[rowid]
7486
7640
  } else {
7487
- pendingMaps[rowid] = row
7641
+ pendingRowMaps[rowid] = row
7488
7642
  }
7489
7643
  }
7490
7644
  })
7491
- reactData.pendingRowMaps = pendingMaps
7645
+ reactData.pendingRowFlag++
7492
7646
  return $xeTable.$nextTick()
7493
7647
  },
7494
7648
  hasPendingByRow (row: any) {
7495
- const $xeTable = this
7649
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7496
7650
 
7497
7651
  return $xeTable.isPendingByRow(row)
7498
7652
  },
@@ -7505,12 +7659,10 @@ const Methods = {
7505
7659
  return !!pendingRowMaps[rowid]
7506
7660
  },
7507
7661
  getPendingRecords () {
7508
- const $xeTable = this
7509
- const reactData = $xeTable
7510
- const internalData = $xeTable
7662
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7663
+ const internalData = $xeTable as unknown as TableInternalData
7511
7664
 
7512
- const { pendingRowMaps } = reactData
7513
- const { fullAllDataRowIdData } = internalData
7665
+ const { fullAllDataRowIdData, pendingRowMaps } = internalData
7514
7666
  const insertRecords: any[] = []
7515
7667
  XEUtils.each(pendingRowMaps, (row, rowid) => {
7516
7668
  if (fullAllDataRowIdData[rowid]) {
@@ -7520,11 +7672,16 @@ const Methods = {
7520
7672
  return insertRecords
7521
7673
  },
7522
7674
  clearPendingRow () {
7523
- this.pendingRowMaps = {}
7524
- return this.$nextTick()
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()
7525
7682
  },
7526
7683
  sort (sortConfs: any, sortOrder: any) {
7527
- const $xeTable = this
7684
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
7528
7685
 
7529
7686
  const { sortOpts } = this
7530
7687
  const { multiple, remote, orders } = sortOpts
@@ -7727,17 +7884,16 @@ const Methods = {
7727
7884
  const reactData = $xeTable as unknown as TableReactData
7728
7885
  const internalData = $xeTable as unknown as TableInternalData
7729
7886
 
7730
- const rExpandLazyLoadedMaps = { ...reactData.rowExpandLazyLoadedMaps }
7731
- const { fullAllDataRowIdData } = internalData
7887
+ const { fullAllDataRowIdData, rowExpandLazyLoadedMaps } = internalData
7732
7888
  const expandOpts = $xeTable.computeExpandOpts
7733
7889
  const { lazy } = expandOpts
7734
7890
  const rowid = getRowid($xeTable, row)
7735
7891
  const rowRest = fullAllDataRowIdData[rowid]
7736
7892
  if (lazy && rowRest) {
7737
7893
  rowRest.expandLoaded = false
7738
- delete rExpandLazyLoadedMaps[rowid]
7894
+ delete rowExpandLazyLoadedMaps[rowid]
7739
7895
  }
7740
- reactData.rowExpandLazyLoadedMaps = rExpandLazyLoadedMaps
7896
+ reactData.rowExpandedFlag++
7741
7897
  return $xeTable.$nextTick()
7742
7898
  },
7743
7899
  /**
@@ -7745,14 +7901,18 @@ const Methods = {
7745
7901
  * @param {Row} row 行对象
7746
7902
  */
7747
7903
  reloadRowExpand (row: any) {
7748
- const { expandOpts, rowExpandLazyLoadedMaps } = this
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
7749
7909
  const { lazy } = expandOpts
7750
7910
  const rowid = getRowid(this, row)
7751
7911
  if (lazy && !rowExpandLazyLoadedMaps[rowid]) {
7752
- this.clearRowExpandLoaded(row)
7753
- .then(() => this.handleAsyncRowExpand(row))
7912
+ $xeTable.clearRowExpandLoaded(row)
7913
+ .then(() => handleAsyncRowExpand($xeTable, row))
7754
7914
  }
7755
- return this.$nextTick()
7915
+ return $xeTable.$nextTick()
7756
7916
  },
7757
7917
  reloadExpandContent (row: any) {
7758
7918
  if (process.env.VUE_APP_VXE_ENV === 'development') {
@@ -7765,20 +7925,34 @@ const Methods = {
7765
7925
  * 展开行事件
7766
7926
  */
7767
7927
  triggerRowExpandEvent (evnt: any, params: any) {
7768
- const { expandOpts, rowExpandLazyLoadedMaps, expandColumn: column } = this
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
7769
7935
  const { row } = params
7770
7936
  const { lazy, trigger } = expandOpts
7771
7937
  if (trigger === 'manual') {
7772
7938
  return
7773
7939
  }
7774
7940
  evnt.stopPropagation()
7775
- const rowid = getRowid(this, row)
7941
+ const rowid = getRowid($xeTable, row)
7776
7942
  if (!lazy || !rowExpandLazyLoadedMaps[rowid]) {
7777
- const expanded = !this.isRowExpandByRow(row)
7778
- const columnIndex = this.getColumnIndex(column)
7779
- const $columnIndex = this.getVMColumnIndex(column)
7780
- this.setRowExpand(row, expanded)
7781
- this.emitEvent('toggle-row-expand', { expanded, column, columnIndex, $columnIndex, row, rowIndex: this.getRowIndex(row), $rowIndex: this.getVMRowIndex(row) }, evnt)
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)
7782
7956
  }
7783
7957
  },
7784
7958
  /**
@@ -7822,48 +7996,6 @@ const Methods = {
7822
7996
  }
7823
7997
  return this.setRowExpand(expandedRows, expanded)
7824
7998
  },
7825
- handleAsyncRowExpand (row: any) {
7826
- const $xeTable = this
7827
- const reactData = $xeTable as TableReactData
7828
- const internalData = $xeTable as TableInternalData
7829
-
7830
- return new Promise<void>(resolve => {
7831
- const { expandOpts } = this
7832
- const { loadMethod } = expandOpts
7833
- if (loadMethod) {
7834
- const { fullAllDataRowIdData } = internalData
7835
- const rExpandLazyLoadedMaps = { ...reactData.rowExpandLazyLoadedMaps }
7836
- const rowid = getRowid($xeTable, row)
7837
- const rowRest = fullAllDataRowIdData[rowid]
7838
- rExpandLazyLoadedMaps[rowid] = row
7839
- reactData.rowExpandLazyLoadedMaps = rExpandLazyLoadedMaps
7840
- loadMethod({ $table: $xeTable, row, rowIndex: $xeTable.getRowIndex(row), $rowIndex: $xeTable.getVMRowIndex(row) }).then(() => {
7841
- const rExpandedMaps = { ...reactData.rowExpandedMaps }
7842
- if (rowRest) {
7843
- rowRest.expandLoaded = true
7844
- }
7845
- rExpandedMaps[rowid] = row
7846
- reactData.rowExpandedMaps = rExpandedMaps
7847
- }).catch(() => {
7848
- if (rowRest) {
7849
- rowRest.expandLoaded = false
7850
- }
7851
- }).finally(() => {
7852
- const rExpandLazyLoadedMaps = { ...reactData.rowExpandLazyLoadedMaps }
7853
- if (rExpandLazyLoadedMaps[rowid]) {
7854
- delete rExpandLazyLoadedMaps[rowid]
7855
- }
7856
- reactData.rowExpandLazyLoadedMaps = rExpandLazyLoadedMaps
7857
- $xeTable.$nextTick()
7858
- .then(() => $xeTable.recalculate())
7859
- .then(() => $xeTable.updateCellAreas())
7860
- .then(() => resolve())
7861
- })
7862
- } else {
7863
- resolve()
7864
- }
7865
- })
7866
- },
7867
7999
  /**
7868
8000
  * 设置展开行,二个参数设置这一行展开与否
7869
8001
  * 支持单行
@@ -7872,10 +8004,14 @@ const Methods = {
7872
8004
  * @param {Boolean} expanded 是否展开
7873
8005
  */
7874
8006
  setRowExpand (rows: any, expanded: any) {
7875
- 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
7876
8010
 
7877
- const { rowExpandedMaps, fullAllDataRowIdData, rowExpandLazyLoadedMaps, expandOpts, expandColumn } = this
7878
- let rExpandedMaps = { ...rowExpandedMaps }
8011
+ const { expandColumn } = reactData
8012
+ let { fullAllDataRowIdData, rowExpandedMaps, rowExpandLazyLoadedMaps } = internalData
8013
+ const { handleGetRowId } = createHandleGetRowId($xeTable)
8014
+ const expandOpts = $xeTable.computeExpandOpts
7879
8015
  const { reserve, lazy, accordion, toggleMethod } = expandOpts
7880
8016
  const lazyRests: any[] = []
7881
8017
  const columnIndex = $xeTable.getColumnIndex(expandColumn)
@@ -7886,28 +8022,29 @@ const Methods = {
7886
8022
  }
7887
8023
  if (accordion) {
7888
8024
  // 只能同时展开一个
7889
- rExpandedMaps = {}
8025
+ rowExpandedMaps = {}
8026
+ internalData.rowExpandedMaps = rowExpandedMaps
7890
8027
  rows = rows.slice(rows.length - 1, rows.length)
7891
8028
  }
7892
- 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
7893
8030
  if (expanded) {
7894
8031
  validRows.forEach((row: any) => {
7895
- const rowid = getRowid(this, row)
7896
- if (!rExpandedMaps[rowid]) {
8032
+ const rowid = handleGetRowId(row)
8033
+ if (!rowExpandedMaps[rowid]) {
7897
8034
  const rowRest = fullAllDataRowIdData[rowid]
7898
8035
  const isLoad = lazy && !rowRest.expandLoaded && !rowExpandLazyLoadedMaps[rowid]
7899
8036
  if (isLoad) {
7900
- lazyRests.push(this.handleAsyncRowExpand(row))
8037
+ lazyRests.push(handleAsyncRowExpand($xeTable, row))
7901
8038
  } else {
7902
- rExpandedMaps[rowid] = row
8039
+ rowExpandedMaps[rowid] = row
7903
8040
  }
7904
8041
  }
7905
8042
  })
7906
8043
  } else {
7907
8044
  validRows.forEach((item) => {
7908
- const rowid = getRowid(this, item)
7909
- if (rExpandedMaps[rowid]) {
7910
- delete rExpandedMaps[rowid]
8045
+ const rowid = handleGetRowId(item)
8046
+ if (rowExpandedMaps[rowid]) {
8047
+ delete rowExpandedMaps[rowid]
7911
8048
  }
7912
8049
  })
7913
8050
  }
@@ -7915,7 +8052,7 @@ const Methods = {
7915
8052
  validRows.forEach((row) => handleRowExpandReserve($xeTable, row, expanded))
7916
8053
  }
7917
8054
  }
7918
- this.rowExpandedMaps = rExpandedMaps
8055
+ reactData.rowExpandedFlag++
7919
8056
  return Promise.all(lazyRests)
7920
8057
  .then(() => $xeTable.$nextTick())
7921
8058
  .then(() => $xeTable.recalculate(true))
@@ -7931,9 +8068,14 @@ const Methods = {
7931
8068
  * @param {Row} row 行对象
7932
8069
  */
7933
8070
  isRowExpandByRow (row: any) {
7934
- const { rowExpandedMaps } = this
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
7935
8077
  const rowid = getRowid(this, row)
7936
- return !!rowExpandedMaps[rowid]
8078
+ return !!rowExpandedFlag && !!rowExpandedMaps[rowid]
7937
8079
  },
7938
8080
  isExpandByRow (row: any) {
7939
8081
  if (process.env.VUE_APP_VXE_ENV === 'development') {
@@ -7954,7 +8096,8 @@ const Methods = {
7954
8096
  const expandOpts = $xeTable.computeExpandOpts
7955
8097
  const { reserve } = expandOpts
7956
8098
  const expList = $xeTable.getRowExpandRecords()
7957
- reactData.rowExpandedMaps = {}
8099
+ internalData.rowExpandedMaps = {}
8100
+ reactData.rowExpandedFlag++
7958
8101
  if (reserve) {
7959
8102
  tableFullData.forEach((row) => handleRowExpandReserve($xeTable, row, false))
7960
8103
  }
@@ -7974,8 +8117,11 @@ const Methods = {
7974
8117
  return this.$nextTick()
7975
8118
  },
7976
8119
  getRowExpandRecords () {
8120
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8121
+ const internalData = $xeTable as unknown as TableInternalData
8122
+
7977
8123
  const rest: any[] = []
7978
- XEUtils.each(this.rowExpandedMaps, item => {
8124
+ XEUtils.each(internalData.rowExpandedMaps, item => {
7979
8125
  if (item) {
7980
8126
  rest.push(item)
7981
8127
  }
@@ -7983,8 +8129,11 @@ const Methods = {
7983
8129
  return rest
7984
8130
  },
7985
8131
  getTreeExpandRecords () {
8132
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8133
+ const internalData = $xeTable as unknown as TableInternalData
8134
+
7986
8135
  const rest: any[] = []
7987
- XEUtils.each(this.treeExpandedMaps, item => {
8136
+ XEUtils.each(internalData.treeExpandedMaps, item => {
7988
8137
  if (item) {
7989
8138
  rest.push(item)
7990
8139
  }
@@ -8019,12 +8168,10 @@ const Methods = {
8019
8168
  const reactData = $xeTable as unknown as TableReactData
8020
8169
  const internalData = $xeTable as unknown as TableInternalData
8021
8170
 
8022
- const { fullAllDataRowIdData } = internalData
8171
+ const { fullAllDataRowIdData, treeExpandedMaps } = internalData
8023
8172
  const treeOpts = $xeTable.computeTreeOpts
8024
8173
  const { transform } = treeOpts
8025
- let tExpandedMaps: Record<string, any> = {}
8026
8174
  if (rows) {
8027
- tExpandedMaps = { ...reactData.treeExpandedMaps }
8028
8175
  if (!XEUtils.isArray(rows)) {
8029
8176
  rows = [rows]
8030
8177
  }
@@ -8033,8 +8180,8 @@ const Methods = {
8033
8180
  const rowRest = fullAllDataRowIdData[rowid]
8034
8181
  if (rowRest) {
8035
8182
  rowRest.treeLoaded = false
8036
- if (tExpandedMaps[rowid]) {
8037
- delete tExpandedMaps[rowid]
8183
+ if (treeExpandedMaps[rowid]) {
8184
+ delete treeExpandedMaps[rowid]
8038
8185
  }
8039
8186
  }
8040
8187
  })
@@ -8043,7 +8190,8 @@ const Methods = {
8043
8190
  rowRest.treeLoaded = false
8044
8191
  })
8045
8192
  }
8046
- reactData.treeExpandedMaps = {}
8193
+ internalData.treeExpandedMaps = {}
8194
+ reactData.treeExpandedFlag++
8047
8195
  if (transform) {
8048
8196
  handleVirtualTreeToList($xeTable)
8049
8197
  return $xeTable.handleTableData()
@@ -8056,37 +8204,45 @@ const Methods = {
8056
8204
  */
8057
8205
  reloadTreeExpand (row: any) {
8058
8206
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8207
+ const internalData = $xeTable as unknown as TableInternalData
8059
8208
 
8060
- const { treeOpts, treeExpandLazyLoadedMaps } = this
8209
+ const { treeExpandLazyLoadedMaps } = internalData
8210
+ const treeOpts = $xeTable.computeTreeOpts
8061
8211
  const { transform, lazy } = treeOpts
8062
8212
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
8063
- const rowid = getRowid(this, row)
8213
+ const rowid = getRowid($xeTable, row)
8064
8214
  if (lazy && row[hasChildField] && !treeExpandLazyLoadedMaps[rowid]) {
8065
- return this.clearTreeExpandLoaded(row).then(() => {
8066
- return this.handleAsyncTreeExpandChilds(row)
8215
+ return $xeTable.clearTreeExpandLoaded(row).then(() => {
8216
+ return handleAsyncTreeExpandChilds($xeTable, row)
8067
8217
  }).then(() => {
8068
8218
  if (transform) {
8069
8219
  handleVirtualTreeToList($xeTable)
8070
- return this.handleTableData()
8220
+ return $xeTable.handleTableData()
8071
8221
  }
8072
8222
  }).then(() => {
8073
- return this.recalculate()
8223
+ return $xeTable.recalculate()
8074
8224
  })
8075
8225
  }
8076
- return this.$nextTick()
8226
+ return $xeTable.$nextTick()
8077
8227
  },
8078
8228
  reloadTreeChilds (row: any) {
8229
+ const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8230
+
8079
8231
  if (process.env.VUE_APP_VXE_ENV === 'development') {
8080
8232
  warnLog('vxe.error.delFunc', ['reloadTreeChilds', 'reloadTreeExpand'])
8081
8233
  }
8082
8234
  // 即将废弃
8083
- return this.reloadTreeExpand(row)
8235
+ return $xeTable.reloadTreeExpand(row)
8084
8236
  },
8085
8237
  /**
8086
8238
  * 展开树节点事件
8087
8239
  */
8088
8240
  triggerTreeExpandEvent (evnt: any, params: any) {
8089
- const { treeOpts, treeExpandLazyLoadedMaps } = this
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
8090
8246
  const { row, column } = params
8091
8247
  const { lazy, trigger } = treeOpts
8092
8248
  if (trigger === 'manual') {
@@ -8095,11 +8251,11 @@ const Methods = {
8095
8251
  evnt.stopPropagation()
8096
8252
  const rowid = getRowid(this, row)
8097
8253
  if (!lazy || !treeExpandLazyLoadedMaps[rowid]) {
8098
- const expanded = !this.isTreeExpandByRow(row)
8099
- const columnIndex = this.getColumnIndex(column)
8100
- const $columnIndex = this.getVMColumnIndex(column)
8101
- this.setTreeExpand(row, expanded)
8102
- this.emitEvent('toggle-tree-expand', { expanded, column, columnIndex, $columnIndex, row }, evnt)
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)
8103
8259
  }
8104
8260
  },
8105
8261
  /**
@@ -8108,88 +8264,6 @@ const Methods = {
8108
8264
  toggleTreeExpand (row: any) {
8109
8265
  return this.setTreeExpand(row, !this.isTreeExpandByRow(row))
8110
8266
  },
8111
- /**
8112
- * 处理默认展开树节点
8113
- */
8114
- handleDefaultTreeExpand () {
8115
- const { treeConfig, treeOpts, tableFullData } = this
8116
- if (treeConfig) {
8117
- const { expandAll, expandRowKeys } = treeOpts
8118
- const childrenField = treeOpts.children || treeOpts.childrenField
8119
- if (expandAll) {
8120
- this.setAllTreeExpand(true)
8121
- } else if (expandRowKeys) {
8122
- const defExpandeds: any[] = []
8123
- const rowkey = getRowkey(this)
8124
- expandRowKeys.forEach((rowid: any) => {
8125
- const matchObj = XEUtils.findTree(tableFullData, item => rowid === XEUtils.get(item, rowkey), { children: childrenField })
8126
- if (matchObj) {
8127
- defExpandeds.push(matchObj.item)
8128
- }
8129
- })
8130
- this.setTreeExpand(defExpandeds, true)
8131
- }
8132
- }
8133
- },
8134
- handleAsyncTreeExpandChilds (row: any) {
8135
- const $xeTable = this
8136
-
8137
- const { treeOpts, checkboxOpts } = this
8138
- const { transform, loadMethod } = treeOpts
8139
- const { checkStrictly } = checkboxOpts
8140
- return new Promise<void>(resolve => {
8141
- if (loadMethod) {
8142
- const { treeExpandLazyLoadedMaps, fullAllDataRowIdData } = this
8143
- const rowid = getRowid($xeTable, row)
8144
- const rowRest = fullAllDataRowIdData[rowid]
8145
- treeExpandLazyLoadedMaps[rowid] = row
8146
- Promise.resolve(
8147
- loadMethod({ $table: $xeTable, row })
8148
- ).then((childRecords: any) => {
8149
- if (rowRest) {
8150
- rowRest.treeLoaded = true
8151
- }
8152
- if (treeExpandLazyLoadedMaps[rowid]) {
8153
- delete treeExpandLazyLoadedMaps[rowid]
8154
- }
8155
- if (!XEUtils.isArray(childRecords)) {
8156
- childRecords = []
8157
- }
8158
- if (childRecords) {
8159
- return this.loadTreeChildren(row, childRecords).then((childRows: any[]) => {
8160
- const { treeExpandedMaps } = this
8161
- if (childRows.length && !treeExpandedMaps[rowid]) {
8162
- treeExpandedMaps[rowid] = row
8163
- }
8164
- // 如果当前节点已选中,则展开后子节点也被选中
8165
- if (!checkStrictly && this.isCheckedByCheckboxRow(row)) {
8166
- handleCheckedCheckboxRow($xeTable, childRows, true)
8167
- }
8168
- return this.$nextTick().then(() => {
8169
- if (transform) {
8170
- this.handleTableData()
8171
- updateAfterDataIndex($xeTable)
8172
- return this.$nextTick()
8173
- }
8174
- })
8175
- })
8176
- }
8177
- }).catch(() => {
8178
- const { treeExpandLazyLoadedMaps } = this
8179
- if (rowRest) {
8180
- rowRest.treeLoaded = false
8181
- }
8182
- if (treeExpandLazyLoadedMaps[rowid]) {
8183
- delete treeExpandLazyLoadedMaps[rowid]
8184
- }
8185
- }).finally(() => {
8186
- this.$nextTick().then(() => this.recalculate()).then(() => resolve())
8187
- })
8188
- } else {
8189
- resolve()
8190
- }
8191
- })
8192
- },
8193
8267
  /**
8194
8268
  * 设置所有树节点的展开与否
8195
8269
  * @param {Boolean} expanded 是否展开
@@ -8214,41 +8288,47 @@ const Methods = {
8214
8288
  * @returns
8215
8289
  */
8216
8290
  handleBaseTreeExpand (rows: any, expanded: any) {
8217
- const { fullAllDataRowIdData, tableFullData, treeExpandedMaps, treeOpts, treeExpandLazyLoadedMaps, treeNodeColumn } = this
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
8218
8298
  const { reserve, lazy, accordion, toggleMethod } = treeOpts
8219
- const treeTempExpandedMaps = { ...treeExpandedMaps }
8220
8299
  const childrenField = treeOpts.children || treeOpts.childrenField
8221
8300
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
8222
8301
  const result: any[] = []
8223
- const columnIndex = this.getColumnIndex(treeNodeColumn)
8224
- const $columnIndex = this.getVMColumnIndex(treeNodeColumn)
8225
- let validRows = toggleMethod ? rows.filter((row: any) => toggleMethod({ expanded, column: treeNodeColumn, columnIndex, $columnIndex, row })) : rows
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
8226
8306
  if (accordion) {
8227
8307
  validRows = validRows.length ? [validRows[validRows.length - 1]] : []
8228
8308
  // 同一级只能展开一个
8229
8309
  const matchObj = XEUtils.findTree(tableFullData, item => item === validRows[0], { children: childrenField })
8230
8310
  if (matchObj) {
8231
8311
  matchObj.items.forEach(item => {
8232
- const rowid = getRowid(this, item)
8233
- if (treeTempExpandedMaps[rowid]) {
8234
- delete treeTempExpandedMaps[rowid]
8312
+ const rowid = handleGetRowId(item)
8313
+ if (treeExpandedMaps[rowid]) {
8314
+ delete treeExpandedMaps[rowid]
8235
8315
  }
8236
8316
  })
8237
8317
  }
8238
8318
  }
8239
8319
  if (expanded) {
8240
8320
  validRows.forEach((row: any) => {
8241
- const rowid = getRowid(this, row)
8242
- if (!treeTempExpandedMaps[rowid]) {
8321
+ const rowid = handleGetRowId(row)
8322
+ if (!treeExpandedMaps[rowid]) {
8243
8323
  const rowRest = fullAllDataRowIdData[rowid]
8244
8324
  if (rowRest) {
8245
8325
  const isLoad = lazy && row[hasChildField] && !rowRest.treeLoaded && !treeExpandLazyLoadedMaps[rowid]
8246
8326
  // 是否使用懒加载
8247
8327
  if (isLoad) {
8248
- result.push(this.handleAsyncTreeExpandChilds(row))
8328
+ result.push(handleAsyncTreeExpandChilds($xeTable, row))
8249
8329
  } else {
8250
8330
  if (row[childrenField] && row[childrenField].length) {
8251
- treeTempExpandedMaps[rowid] = row
8331
+ treeExpandedMaps[rowid] = row
8252
8332
  }
8253
8333
  }
8254
8334
  }
@@ -8256,18 +8336,18 @@ const Methods = {
8256
8336
  })
8257
8337
  } else {
8258
8338
  validRows.forEach((item: any) => {
8259
- const rowid = getRowid(this, item)
8260
- if (treeTempExpandedMaps[rowid]) {
8261
- delete treeTempExpandedMaps[rowid]
8339
+ const rowid = handleGetRowId(item)
8340
+ if (treeExpandedMaps[rowid]) {
8341
+ delete treeExpandedMaps[rowid]
8262
8342
  }
8263
8343
  })
8264
8344
  }
8265
8345
  if (reserve) {
8266
- validRows.forEach((row: any) => this.handleTreeExpandReserve(row, expanded))
8346
+ validRows.forEach((row: any) => handleTreeExpandReserve($xeTable, row, expanded))
8267
8347
  }
8268
- this.treeExpandedMaps = treeTempExpandedMaps
8348
+ reactData.treeExpandedFlag++
8269
8349
  return Promise.all(result).then(() => {
8270
- return this.recalculate()
8350
+ return $xeTable.recalculate()
8271
8351
  })
8272
8352
  },
8273
8353
  /**
@@ -8321,31 +8401,40 @@ const Methods = {
8321
8401
  * @param {Row} row 行对象
8322
8402
  */
8323
8403
  isTreeExpandByRow (row: any) {
8324
- const { treeExpandedMaps } = this
8325
- return !!treeExpandedMaps[getRowid(this, row)]
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)]
8326
8411
  },
8327
8412
  /**
8328
8413
  * 手动清空树形节点的展开状态,数据会恢复成未展开的状态
8329
8414
  */
8330
8415
  clearTreeExpand () {
8331
8416
  const $xeTable = this as VxeTableConstructor & VxeTablePrivateMethods
8417
+ const reactData = $xeTable as unknown as TableReactData
8418
+ const internalData = $xeTable as unknown as TableInternalData
8332
8419
 
8333
- const { treeOpts, tableFullData } = this
8334
- const { transform, reserve } = treeOpts
8420
+ const { tableFullTreeData } = internalData
8421
+ const treeOpts = $xeTable.computeTreeOpts
8335
8422
  const childrenField = treeOpts.children || treeOpts.childrenField
8336
- const expList = this.getTreeExpandRecords()
8337
- this.treeExpandedMaps = {}
8423
+ const { transform, reserve } = treeOpts
8424
+ const expList = $xeTable.getTreeExpandRecords()
8425
+ internalData.treeExpandedMaps = {}
8426
+ reactData.treeExpandedFlag++
8338
8427
  if (reserve) {
8339
- XEUtils.eachTree(tableFullData, row => this.handleTreeExpandReserve(row, false), { children: childrenField })
8428
+ XEUtils.eachTree(tableFullTreeData, row => handleTreeExpandReserve($xeTable, row, false), { children: childrenField })
8340
8429
  }
8341
- return this.handleTableData().then(() => {
8430
+ return $xeTable.handleTableData().then(() => {
8342
8431
  if (transform) {
8343
8432
  handleVirtualTreeToList($xeTable)
8344
- return this.handleTableData()
8433
+ return $xeTable.handleTableData()
8345
8434
  }
8346
8435
  }).then(() => {
8347
8436
  if (expList.length) {
8348
- this.recalculate()
8437
+ $xeTable.recalculate()
8349
8438
  }
8350
8439
  })
8351
8440
  },
@@ -8353,17 +8442,6 @@ const Methods = {
8353
8442
  this.treeExpandedReserveRowMap = {}
8354
8443
  return this.$nextTick()
8355
8444
  },
8356
- handleTreeExpandReserve (row: any, expanded: any) {
8357
- const { treeExpandedReserveRowMap, treeOpts } = this
8358
- if (treeOpts.reserve) {
8359
- const rowid = getRowid(this, row)
8360
- if (expanded) {
8361
- treeExpandedReserveRowMap[rowid] = row
8362
- } else if (treeExpandedReserveRowMap[rowid]) {
8363
- delete treeExpandedReserveRowMap[rowid]
8364
- }
8365
- }
8366
- },
8367
8445
  /**
8368
8446
  * 获取表格的滚动状态
8369
8447
  */
@@ -8960,8 +9038,8 @@ const Methods = {
8960
9038
  const reactData = $xeTable as unknown as TableReactData
8961
9039
  const internalData = $xeTable as unknown as TableInternalData
8962
9040
 
8963
- const { isAllOverflow, scrollYLoad, expandColumn, rowExpandedMaps } = reactData
8964
- const { scrollYStore, elemStore, isResizeCellHeight, afterFullData, fullAllDataRowIdData } = internalData
9041
+ const { isAllOverflow, scrollYLoad, expandColumn } = reactData
9042
+ const { scrollYStore, elemStore, isResizeCellHeight, afterFullData, fullAllDataRowIdData, rowExpandedMaps } = internalData
8965
9043
  const { startIndex } = scrollYStore
8966
9044
  const expandOpts = $xeTable.computeExpandOpts
8967
9045
  const rowOpts = $xeTable.computeRowOpts
@@ -9296,7 +9374,7 @@ const Methods = {
9296
9374
  if (this.footerSpanMethod) {
9297
9375
  errLog('vxe.error.errConflicts', ['merge-footer-items', 'footer-span-method'])
9298
9376
  }
9299
- setMerges(this, merges, this.mergeFooterList, null)
9377
+ setMerges(this, merges, this.mergeFooterList)
9300
9378
  return this.$nextTick().then(() => {
9301
9379
  this.updateCellAreas()
9302
9380
  return updateStyle($xeTable)