vxe-table 3.7.0-beta.16 → 3.7.0-beta.17
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/lib/edit/src/mixin.js +6 -4
- package/lib/edit/src/mixin.min.js +1 -1
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/index.css +1 -1
- package/lib/index.umd.js +571 -404
- package/lib/index.umd.min.js +1 -1
- package/lib/input/src/input.js +24 -1
- package/lib/input/src/input.min.js +1 -1
- package/lib/input/style/style.css +21 -0
- package/lib/input/style/style.min.css +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/src/body.js +6 -6
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/cell.js +20 -16
- package/lib/table/src/cell.min.js +1 -1
- package/lib/table/src/methods.js +498 -360
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/table.js +15 -13
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/style/style.css +2 -2
- package/lib/table/style/style.min.css +1 -1
- package/lib/tools/log.js +1 -1
- package/lib/tools/log.min.js +1 -1
- package/lib/v-x-e-table/index.js +1 -1
- package/lib/v-x-e-table/index.min.js +1 -1
- package/package.json +3 -8
- package/packages/edit/src/mixin.js +7 -5
- package/packages/input/src/input.js +24 -1
- package/packages/table/src/body.js +6 -6
- package/packages/table/src/cell.js +18 -14
- package/packages/table/src/methods.js +375 -181
- package/packages/table/src/table.js +15 -13
- package/styles/css-variable.scss +3 -3
- package/styles/input.scss +25 -0
- package/styles/table.scss +6 -2
- package/styles/textarea.scss +3 -3
- package/styles/variable.scss +3 -3
- /package/lib/icon/style/{iconfont.1693009490086.ttf → iconfont.1693628087676.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1693009490086.woff → iconfont.1693628087676.woff} +0 -0
- /package/lib/icon/style/{iconfont.1693009490086.woff2 → iconfont.1693628087676.woff2} +0 -0
- /package/lib/{iconfont.1693009490086.ttf → iconfont.1693628087676.ttf} +0 -0
- /package/lib/{iconfont.1693009490086.woff → iconfont.1693628087676.woff} +0 -0
- /package/lib/{iconfont.1693009490086.woff2 → iconfont.1693628087676.woff2} +0 -0
|
@@ -52,9 +52,15 @@ function getCustomStorageMap (key) {
|
|
|
52
52
|
return rest && rest._v === version ? rest : { _v: version }
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
const {
|
|
57
|
-
|
|
55
|
+
const getRecoverRowMaps = (_vm, keyMaps) => {
|
|
56
|
+
const { fullAllDataRowIdData } = _vm
|
|
57
|
+
const restKeys = {}
|
|
58
|
+
XEUtils.each(keyMaps, (row, rowid) => {
|
|
59
|
+
if (fullAllDataRowIdData[rowid]) {
|
|
60
|
+
restKeys[rowid] = row
|
|
61
|
+
}
|
|
62
|
+
})
|
|
63
|
+
return restKeys
|
|
58
64
|
}
|
|
59
65
|
|
|
60
66
|
function handleReserveRow (_vm, reserveRowMap) {
|
|
@@ -654,7 +660,7 @@ const Methods = {
|
|
|
654
660
|
this.tableSourceData = sourceData
|
|
655
661
|
},
|
|
656
662
|
loadTreeChildren (row, childRecords) {
|
|
657
|
-
const { keepSource, tableSourceData, treeOpts, fullDataRowIdData, fullDataRowMap, fullAllDataRowMap, fullAllDataRowIdData } = this
|
|
663
|
+
const { keepSource, tableSourceData, treeOpts, fullDataRowIdData, fullDataRowMap, fullAllDataRowMap, fullAllDataRowIdData, sourceDataRowIdData } = this
|
|
658
664
|
const { transform, mapChildrenField } = treeOpts
|
|
659
665
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
660
666
|
const rest = fullAllDataRowIdData[getRowid(this, row)]
|
|
@@ -666,6 +672,10 @@ const Methods = {
|
|
|
666
672
|
if (matchObj) {
|
|
667
673
|
matchObj.item[childrenField] = XEUtils.clone(rows, true)
|
|
668
674
|
}
|
|
675
|
+
rows.forEach(childRow => {
|
|
676
|
+
const rowid = getRowid(this, childRow)
|
|
677
|
+
sourceDataRowIdData[rowid] = XEUtils.clone(childRow, true)
|
|
678
|
+
})
|
|
669
679
|
}
|
|
670
680
|
XEUtils.eachTree(rows, (childRow, index, items, path, parent, nodes) => {
|
|
671
681
|
const rowid = getRowid(this, childRow)
|
|
@@ -1161,7 +1171,7 @@ const Methods = {
|
|
|
1161
1171
|
* 用于多选行,获取已选中的数据
|
|
1162
1172
|
*/
|
|
1163
1173
|
getCheckboxRecords (isFull) {
|
|
1164
|
-
const { tableFullData, afterFullData, treeConfig, treeOpts, checkboxOpts, tableFullTreeData, afterTreeFullData } = this
|
|
1174
|
+
const { tableFullData, afterFullData, treeConfig, treeOpts, checkboxOpts, tableFullTreeData, afterTreeFullData, afterFullRowMaps } = this
|
|
1165
1175
|
const { transform, mapChildrenField } = treeOpts
|
|
1166
1176
|
const { checkField } = checkboxOpts
|
|
1167
1177
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
@@ -1174,12 +1184,12 @@ const Methods = {
|
|
|
1174
1184
|
rowList = currTableData.filter(row => XEUtils.get(row, checkField))
|
|
1175
1185
|
}
|
|
1176
1186
|
} else {
|
|
1177
|
-
const {
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
}
|
|
1187
|
+
const { selectCheckboxMaps, fullDataRowIdData } = this
|
|
1188
|
+
XEUtils.each(selectCheckboxMaps, (row, rowid) => {
|
|
1189
|
+
if (isFull ? fullDataRowIdData[rowid] : afterFullRowMaps[rowid]) {
|
|
1190
|
+
rowList.push(row)
|
|
1191
|
+
}
|
|
1192
|
+
})
|
|
1183
1193
|
}
|
|
1184
1194
|
return rowList
|
|
1185
1195
|
},
|
|
@@ -1188,13 +1198,15 @@ const Methods = {
|
|
|
1188
1198
|
* @returns
|
|
1189
1199
|
*/
|
|
1190
1200
|
handleVirtualTreeToList () {
|
|
1191
|
-
const { treeOpts, treeConfig,
|
|
1201
|
+
const { treeOpts, treeConfig, treeExpandedMaps, afterTreeFullData, afterFullData } = this
|
|
1192
1202
|
if (treeConfig && treeOpts.transform) {
|
|
1193
1203
|
const fullData = []
|
|
1194
|
-
const expandMaps =
|
|
1204
|
+
const expandMaps = {}
|
|
1195
1205
|
XEUtils.eachTree(afterTreeFullData, (row, index, items, path, parent) => {
|
|
1196
|
-
|
|
1197
|
-
|
|
1206
|
+
const rowid = getRowid(this, row)
|
|
1207
|
+
const parentRowid = getRowid(this, parent)
|
|
1208
|
+
if (!parent || (expandMaps[parentRowid] && treeExpandedMaps[parentRowid])) {
|
|
1209
|
+
expandMaps[rowid] = 1
|
|
1198
1210
|
fullData.push(row)
|
|
1199
1211
|
}
|
|
1200
1212
|
}, { children: treeOpts.mapChildrenField })
|
|
@@ -1322,6 +1334,7 @@ const Methods = {
|
|
|
1322
1334
|
updateAfterDataIndex () {
|
|
1323
1335
|
const { treeConfig, afterFullData, fullDataRowIdData, fullAllDataRowIdData, afterTreeFullData, treeOpts } = this
|
|
1324
1336
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
1337
|
+
const fullMaps = {}
|
|
1325
1338
|
if (treeConfig) {
|
|
1326
1339
|
XEUtils.eachTree(afterTreeFullData, (row, index, items, path) => {
|
|
1327
1340
|
const rowid = getRowid(this, row)
|
|
@@ -1335,6 +1348,7 @@ const Methods = {
|
|
|
1335
1348
|
fullAllDataRowIdData[rowid] = rest
|
|
1336
1349
|
fullDataRowIdData[rowid] = rest
|
|
1337
1350
|
}
|
|
1351
|
+
fullMaps[rowid] = row
|
|
1338
1352
|
}, { children: treeOpts.transform ? treeOpts.mapChildrenField : childrenField })
|
|
1339
1353
|
} else {
|
|
1340
1354
|
afterFullData.forEach((row, index) => {
|
|
@@ -1349,8 +1363,10 @@ const Methods = {
|
|
|
1349
1363
|
fullAllDataRowIdData[rowid] = rest
|
|
1350
1364
|
fullDataRowIdData[rowid] = rest
|
|
1351
1365
|
}
|
|
1366
|
+
fullMaps[rowid] = row
|
|
1352
1367
|
})
|
|
1353
1368
|
}
|
|
1369
|
+
this.afterFullRowMaps = fullMaps
|
|
1354
1370
|
},
|
|
1355
1371
|
/**
|
|
1356
1372
|
* 只对 tree-config 有效,获取行的父级
|
|
@@ -2922,12 +2938,22 @@ const Methods = {
|
|
|
2922
2938
|
* 获取复选框半选状态的行数据
|
|
2923
2939
|
*/
|
|
2924
2940
|
getCheckboxIndeterminateRecords (isFull) {
|
|
2925
|
-
const { treeConfig,
|
|
2941
|
+
const { treeConfig, treeIndeterminateMaps, fullDataRowIdData } = this
|
|
2926
2942
|
if (treeConfig) {
|
|
2927
|
-
|
|
2928
|
-
|
|
2929
|
-
|
|
2943
|
+
const fullRest = []
|
|
2944
|
+
const defRest = []
|
|
2945
|
+
XEUtils.each(treeIndeterminateMaps, (item, rowid) => {
|
|
2946
|
+
if (item) {
|
|
2947
|
+
fullRest.push(item)
|
|
2948
|
+
if (fullDataRowIdData[rowid]) {
|
|
2949
|
+
defRest.push(item)
|
|
2950
|
+
}
|
|
2951
|
+
}
|
|
2930
2952
|
})
|
|
2953
|
+
if (isFull) {
|
|
2954
|
+
return fullRest
|
|
2955
|
+
}
|
|
2956
|
+
return defRest
|
|
2931
2957
|
}
|
|
2932
2958
|
return []
|
|
2933
2959
|
},
|
|
@@ -2965,30 +2991,36 @@ const Methods = {
|
|
|
2965
2991
|
return this.handleCheckedCheckboxRow(rows, value, true)
|
|
2966
2992
|
},
|
|
2967
2993
|
isCheckedByCheckboxRow (row) {
|
|
2968
|
-
const {
|
|
2994
|
+
const { selectCheckboxMaps } = this
|
|
2969
2995
|
const { checkField } = this.checkboxOpts
|
|
2970
2996
|
if (checkField) {
|
|
2971
2997
|
return XEUtils.get(row, checkField)
|
|
2972
2998
|
}
|
|
2973
|
-
return this
|
|
2999
|
+
return !!selectCheckboxMaps[getRowid(this, row)]
|
|
2974
3000
|
},
|
|
2975
3001
|
isIndeterminateByCheckboxRow (row) {
|
|
2976
|
-
const {
|
|
2977
|
-
return this
|
|
3002
|
+
const { treeIndeterminateMaps } = this
|
|
3003
|
+
return !!treeIndeterminateMaps[getRowid(this, row)] && !this.isCheckedByCheckboxRow(row)
|
|
2978
3004
|
},
|
|
2979
3005
|
/**
|
|
2980
3006
|
* 多选,行选中事件
|
|
2981
3007
|
* value 选中true 不选false 半选-1
|
|
2982
3008
|
*/
|
|
2983
3009
|
handleSelectRow ({ row }, value, isForce) {
|
|
2984
|
-
const {
|
|
3010
|
+
const { selectCheckboxMaps, afterFullData, treeConfig, treeOpts, treeIndeterminateMaps, checkboxOpts } = this
|
|
2985
3011
|
const { checkField, checkStrictly, checkMethod } = checkboxOpts
|
|
3012
|
+
const selectRowMaps = { ...selectCheckboxMaps }
|
|
2986
3013
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
3014
|
+
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
3015
|
+
const rowid = getRowid(this, row)
|
|
2987
3016
|
if (checkField) {
|
|
2988
3017
|
if (treeConfig && !checkStrictly) {
|
|
2989
3018
|
if (value === -1) {
|
|
2990
|
-
if (
|
|
2991
|
-
|
|
3019
|
+
if (!treeIndeterminateMaps[rowid]) {
|
|
3020
|
+
if (indeterminateField) {
|
|
3021
|
+
XEUtils.set(row, indeterminateField, true)
|
|
3022
|
+
}
|
|
3023
|
+
treeIndeterminateMaps[rowid] = row
|
|
2992
3024
|
}
|
|
2993
3025
|
XEUtils.set(row, checkField, false)
|
|
2994
3026
|
} else {
|
|
@@ -2996,7 +3028,10 @@ const Methods = {
|
|
|
2996
3028
|
XEUtils.eachTree([row], (item) => {
|
|
2997
3029
|
if (this.eqRow(item, row) || (isForce || (!checkMethod || checkMethod({ row: item })))) {
|
|
2998
3030
|
XEUtils.set(item, checkField, value)
|
|
2999
|
-
|
|
3031
|
+
if (indeterminateField) {
|
|
3032
|
+
XEUtils.set(row, indeterminateField, false)
|
|
3033
|
+
}
|
|
3034
|
+
delete treeIndeterminateMaps[getRowid(this, item)]
|
|
3000
3035
|
this.handleCheckboxReserveRow(row, value)
|
|
3001
3036
|
}
|
|
3002
3037
|
}, { children: childrenField })
|
|
@@ -3005,14 +3040,36 @@ const Methods = {
|
|
|
3005
3040
|
const matchObj = XEUtils.findTree(afterFullData, item => this.eqRow(item, row), { children: childrenField })
|
|
3006
3041
|
if (matchObj && matchObj.parent) {
|
|
3007
3042
|
let parentStatus
|
|
3008
|
-
const vItems =
|
|
3009
|
-
const
|
|
3043
|
+
const vItems = []
|
|
3044
|
+
const vItemMaps = {}
|
|
3045
|
+
if (!isForce && checkMethod) {
|
|
3046
|
+
matchObj.items.forEach((item) => {
|
|
3047
|
+
if (checkMethod({ row: item })) {
|
|
3048
|
+
const itemRid = getRowid(this, item)
|
|
3049
|
+
vItemMaps[itemRid] = item
|
|
3050
|
+
vItems.push(item)
|
|
3051
|
+
}
|
|
3052
|
+
})
|
|
3053
|
+
} else {
|
|
3054
|
+
matchObj.items.forEach(item => {
|
|
3055
|
+
const itemRid = getRowid(this, item)
|
|
3056
|
+
vItemMaps[itemRid] = item
|
|
3057
|
+
vItems.push(item)
|
|
3058
|
+
})
|
|
3059
|
+
}
|
|
3060
|
+
const indeterminatesItem = XEUtils.find(matchObj.items, item => !!treeIndeterminateMaps[getRowid(this, item)])
|
|
3010
3061
|
if (indeterminatesItem) {
|
|
3011
3062
|
parentStatus = -1
|
|
3012
3063
|
} else {
|
|
3013
|
-
const selectItems =
|
|
3014
|
-
|
|
3064
|
+
const selectItems = []
|
|
3065
|
+
matchObj.items.forEach(item => {
|
|
3066
|
+
if (XEUtils.get(item, checkField)) {
|
|
3067
|
+
selectItems.push(item)
|
|
3068
|
+
}
|
|
3069
|
+
})
|
|
3070
|
+
parentStatus = selectItems.filter(item => vItemMaps[getRowid(this, item)]).length === vItems.length ? true : (selectItems.length || value === -1 ? -1 : false)
|
|
3015
3071
|
}
|
|
3072
|
+
this.selectCheckboxMaps = selectRowMaps
|
|
3016
3073
|
return this.handleSelectRow({ row: matchObj.parent }, parentStatus, isForce)
|
|
3017
3074
|
}
|
|
3018
3075
|
} else {
|
|
@@ -3024,20 +3081,31 @@ const Methods = {
|
|
|
3024
3081
|
} else {
|
|
3025
3082
|
if (treeConfig && !checkStrictly) {
|
|
3026
3083
|
if (value === -1) {
|
|
3027
|
-
if (
|
|
3028
|
-
|
|
3084
|
+
if (!treeIndeterminateMaps[rowid]) {
|
|
3085
|
+
if (indeterminateField) {
|
|
3086
|
+
XEUtils.set(row, indeterminateField, true)
|
|
3087
|
+
}
|
|
3088
|
+
treeIndeterminateMaps[rowid] = row
|
|
3089
|
+
}
|
|
3090
|
+
if (selectRowMaps[rowid]) {
|
|
3091
|
+
delete selectRowMaps[rowid]
|
|
3029
3092
|
}
|
|
3030
|
-
XEUtils.remove(selectCheckboxRows, item => this.eqRow(item, row))
|
|
3031
3093
|
} else {
|
|
3032
3094
|
// 更新子节点状态
|
|
3033
3095
|
XEUtils.eachTree([row], (item) => {
|
|
3096
|
+
const itemRid = getRowid(this, item)
|
|
3034
3097
|
if (this.eqRow(item, row) || (isForce || (!checkMethod || checkMethod({ row: item })))) {
|
|
3035
3098
|
if (value) {
|
|
3036
|
-
|
|
3099
|
+
selectRowMaps[itemRid] = item
|
|
3037
3100
|
} else {
|
|
3038
|
-
|
|
3101
|
+
if (selectRowMaps[itemRid]) {
|
|
3102
|
+
delete selectRowMaps[itemRid]
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
if (indeterminateField) {
|
|
3106
|
+
XEUtils.set(row, indeterminateField, false)
|
|
3039
3107
|
}
|
|
3040
|
-
|
|
3108
|
+
delete treeIndeterminateMaps[getRowid(this, item)]
|
|
3041
3109
|
this.handleCheckboxReserveRow(row, value)
|
|
3042
3110
|
}
|
|
3043
3111
|
}, { children: childrenField })
|
|
@@ -3046,36 +3114,67 @@ const Methods = {
|
|
|
3046
3114
|
const matchObj = XEUtils.findTree(afterFullData, item => this.eqRow(item, row), { children: childrenField })
|
|
3047
3115
|
if (matchObj && matchObj.parent) {
|
|
3048
3116
|
let parentStatus
|
|
3049
|
-
const vItems =
|
|
3050
|
-
const
|
|
3117
|
+
const vItems = []
|
|
3118
|
+
const vItemMaps = {}
|
|
3119
|
+
if (!isForce && checkMethod) {
|
|
3120
|
+
matchObj.items.forEach((item) => {
|
|
3121
|
+
if (checkMethod({ row: item })) {
|
|
3122
|
+
const itemRid = getRowid(this, item)
|
|
3123
|
+
vItemMaps[itemRid] = item
|
|
3124
|
+
vItems.push(item)
|
|
3125
|
+
}
|
|
3126
|
+
})
|
|
3127
|
+
} else {
|
|
3128
|
+
matchObj.items.forEach(item => {
|
|
3129
|
+
const itemRid = getRowid(this, item)
|
|
3130
|
+
vItemMaps[itemRid] = item
|
|
3131
|
+
vItems.push(item)
|
|
3132
|
+
})
|
|
3133
|
+
}
|
|
3134
|
+
const indeterminatesItem = XEUtils.find(matchObj.items, item => !!treeIndeterminateMaps[getRowid(this, item)])
|
|
3051
3135
|
if (indeterminatesItem) {
|
|
3052
3136
|
parentStatus = -1
|
|
3053
3137
|
} else {
|
|
3054
|
-
const selectItems =
|
|
3055
|
-
|
|
3138
|
+
const selectItems = []
|
|
3139
|
+
matchObj.items.forEach(item => {
|
|
3140
|
+
const itemRid = getRowid(this, item)
|
|
3141
|
+
if (selectRowMaps[itemRid]) {
|
|
3142
|
+
selectItems.push(item)
|
|
3143
|
+
}
|
|
3144
|
+
})
|
|
3145
|
+
parentStatus = selectItems.filter(item => vItemMaps[getRowid(this, item)]).length === vItems.length ? true : (selectItems.length || value === -1 ? -1 : false)
|
|
3056
3146
|
}
|
|
3147
|
+
this.selectCheckboxMaps = selectRowMaps
|
|
3057
3148
|
return this.handleSelectRow({ row: matchObj.parent }, parentStatus, isForce)
|
|
3058
3149
|
}
|
|
3059
3150
|
} else {
|
|
3060
3151
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
3061
3152
|
if (value) {
|
|
3062
|
-
if (
|
|
3063
|
-
|
|
3153
|
+
if (!selectRowMaps[rowid]) {
|
|
3154
|
+
selectRowMaps[rowid] = row
|
|
3064
3155
|
}
|
|
3065
3156
|
} else {
|
|
3066
|
-
|
|
3157
|
+
if (selectRowMaps[rowid]) {
|
|
3158
|
+
delete selectRowMaps[rowid]
|
|
3159
|
+
}
|
|
3067
3160
|
}
|
|
3068
3161
|
this.handleCheckboxReserveRow(row, value)
|
|
3069
3162
|
}
|
|
3070
3163
|
}
|
|
3071
3164
|
}
|
|
3165
|
+
this.selectCheckboxMaps = selectRowMaps
|
|
3072
3166
|
this.checkSelectionStatus()
|
|
3073
3167
|
},
|
|
3074
3168
|
handleToggleCheckRowEvent (evnt, params) {
|
|
3075
|
-
const {
|
|
3169
|
+
const { selectCheckboxMaps, checkboxOpts } = this
|
|
3076
3170
|
const { checkField } = checkboxOpts
|
|
3077
3171
|
const { row } = params
|
|
3078
|
-
|
|
3172
|
+
let value = false
|
|
3173
|
+
if (checkField) {
|
|
3174
|
+
value = !XEUtils.get(row, checkField)
|
|
3175
|
+
} else {
|
|
3176
|
+
value = !selectCheckboxMaps[getRowid(this, row)]
|
|
3177
|
+
}
|
|
3079
3178
|
if (evnt) {
|
|
3080
3179
|
this.triggerCheckRowEvent(evnt, params, value)
|
|
3081
3180
|
} else {
|
|
@@ -3115,19 +3214,29 @@ const Methods = {
|
|
|
3115
3214
|
* 多选,切换某一行的选中状态
|
|
3116
3215
|
*/
|
|
3117
3216
|
toggleCheckboxRow (row) {
|
|
3118
|
-
const {
|
|
3217
|
+
const { selectCheckboxMaps, checkboxOpts } = this
|
|
3119
3218
|
const { checkField } = checkboxOpts
|
|
3120
|
-
const value = checkField ? !XEUtils.get(row, checkField) : this
|
|
3219
|
+
const value = checkField ? !XEUtils.get(row, checkField) : !selectCheckboxMaps[getRowid(this, row)]
|
|
3121
3220
|
this.handleSelectRow({ row }, value, true)
|
|
3122
3221
|
return this.$nextTick()
|
|
3123
3222
|
},
|
|
3124
3223
|
handleCheckedAllCheckboxRow (value, isForce) {
|
|
3125
|
-
const { afterFullData, treeConfig, treeOpts,
|
|
3224
|
+
const { afterFullData, treeConfig, treeOpts, selectCheckboxMaps, checkboxReserveRowMap, checkboxOpts, afterFullRowMaps } = this
|
|
3126
3225
|
const { checkField, reserve, checkStrictly, checkMethod } = checkboxOpts
|
|
3127
3226
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
3128
3227
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
3129
|
-
|
|
3130
|
-
|
|
3228
|
+
const selectRowMaps = {}
|
|
3229
|
+
|
|
3230
|
+
// 疑惑!
|
|
3231
|
+
if (!treeConfig) {
|
|
3232
|
+
XEUtils.each(selectCheckboxMaps, (row, rowid) => {
|
|
3233
|
+
if (!afterFullRowMaps[rowid]) {
|
|
3234
|
+
selectRowMaps[rowid] = row
|
|
3235
|
+
}
|
|
3236
|
+
})
|
|
3237
|
+
}
|
|
3238
|
+
// 疑惑!
|
|
3239
|
+
|
|
3131
3240
|
if (checkStrictly) {
|
|
3132
3241
|
this.isAllSelected = value
|
|
3133
3242
|
} else {
|
|
@@ -3139,7 +3248,7 @@ const Methods = {
|
|
|
3139
3248
|
const checkValFn = (row) => {
|
|
3140
3249
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
3141
3250
|
if (value) {
|
|
3142
|
-
|
|
3251
|
+
selectRowMaps[getRowid(this, row)] = row
|
|
3143
3252
|
}
|
|
3144
3253
|
XEUtils.set(row, checkField, value)
|
|
3145
3254
|
}
|
|
@@ -3167,7 +3276,7 @@ const Methods = {
|
|
|
3167
3276
|
*/
|
|
3168
3277
|
XEUtils.eachTree(afterFullData, (row) => {
|
|
3169
3278
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
3170
|
-
|
|
3279
|
+
selectRowMaps[getRowid(this, row)] = row
|
|
3171
3280
|
}
|
|
3172
3281
|
}, { children: childrenField })
|
|
3173
3282
|
} else {
|
|
@@ -3177,8 +3286,9 @@ const Methods = {
|
|
|
3177
3286
|
*/
|
|
3178
3287
|
if (!isForce && checkMethod) {
|
|
3179
3288
|
XEUtils.eachTree(afterFullData, (row) => {
|
|
3180
|
-
|
|
3181
|
-
|
|
3289
|
+
const rowid = getRowid(this, row)
|
|
3290
|
+
if (checkMethod({ row }) ? 0 : selectCheckboxMaps[rowid]) {
|
|
3291
|
+
selectRowMaps[rowid] = row
|
|
3182
3292
|
}
|
|
3183
3293
|
}, { children: childrenField })
|
|
3184
3294
|
}
|
|
@@ -3191,9 +3301,16 @@ const Methods = {
|
|
|
3191
3301
|
* 如果不存在选中方法,则添加所有数据到临时集合中
|
|
3192
3302
|
*/
|
|
3193
3303
|
if (!isForce && checkMethod) {
|
|
3194
|
-
|
|
3304
|
+
afterFullData.forEach((row) => {
|
|
3305
|
+
const rowid = getRowid(this, row)
|
|
3306
|
+
if (selectCheckboxMaps[rowid] || checkMethod({ row })) {
|
|
3307
|
+
selectRowMaps[rowid] = row
|
|
3308
|
+
}
|
|
3309
|
+
})
|
|
3195
3310
|
} else {
|
|
3196
|
-
|
|
3311
|
+
afterFullData.forEach(row => {
|
|
3312
|
+
selectRowMaps[getRowid(this, row)] = row
|
|
3313
|
+
})
|
|
3197
3314
|
}
|
|
3198
3315
|
} else {
|
|
3199
3316
|
/**
|
|
@@ -3202,23 +3319,29 @@ const Methods = {
|
|
|
3202
3319
|
* 如果不存在选中方法,无需处理,临时集合默认为空
|
|
3203
3320
|
*/
|
|
3204
3321
|
if (!isForce && checkMethod) {
|
|
3205
|
-
|
|
3322
|
+
afterFullData.forEach((row) => {
|
|
3323
|
+
const rowid = getRowid(this, row)
|
|
3324
|
+
if (checkMethod({ row }) ? 0 : selectCheckboxMaps[rowid]) {
|
|
3325
|
+
selectRowMaps[rowid] = row
|
|
3326
|
+
}
|
|
3327
|
+
})
|
|
3206
3328
|
}
|
|
3207
3329
|
}
|
|
3208
3330
|
}
|
|
3209
3331
|
}
|
|
3210
3332
|
if (reserve) {
|
|
3211
3333
|
if (value) {
|
|
3212
|
-
|
|
3213
|
-
checkboxReserveRowMap[
|
|
3334
|
+
XEUtils.each(selectRowMaps, (row, rowid) => {
|
|
3335
|
+
checkboxReserveRowMap[rowid] = row
|
|
3214
3336
|
})
|
|
3215
3337
|
} else {
|
|
3216
|
-
afterFullData.forEach(row => this.handleCheckboxReserveRow(row, false))
|
|
3338
|
+
afterFullData.forEach((row) => this.handleCheckboxReserveRow(row, false))
|
|
3217
3339
|
}
|
|
3218
3340
|
}
|
|
3219
|
-
this.
|
|
3341
|
+
this.selectCheckboxMaps = checkField ? {} : selectRowMaps
|
|
3220
3342
|
}
|
|
3221
|
-
this.
|
|
3343
|
+
this.treeIndeterminateMaps = {}
|
|
3344
|
+
this.treeIndeterminateRowMaps = {}
|
|
3222
3345
|
this.checkSelectionStatus()
|
|
3223
3346
|
return this.$nextTick()
|
|
3224
3347
|
},
|
|
@@ -3230,7 +3353,7 @@ const Methods = {
|
|
|
3230
3353
|
return this.handleCheckedAllCheckboxRow(value, true)
|
|
3231
3354
|
},
|
|
3232
3355
|
checkSelectionStatus () {
|
|
3233
|
-
const { afterFullData,
|
|
3356
|
+
const { afterFullData, selectCheckboxMaps, treeIndeterminateMaps, checkboxOpts, treeConfig } = this
|
|
3234
3357
|
const { checkField, checkStrictly, checkMethod } = checkboxOpts
|
|
3235
3358
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
3236
3359
|
if (!checkStrictly) {
|
|
@@ -3258,15 +3381,15 @@ const Methods = {
|
|
|
3258
3381
|
isAllSelected = isAllResolve && afterFullData.length !== disableRows.length
|
|
3259
3382
|
if (treeConfig) {
|
|
3260
3383
|
if (indeterminateField) {
|
|
3261
|
-
isIndeterminate = !isAllSelected && afterFullData.some(row => XEUtils.get(row, checkField) || XEUtils.get(row, indeterminateField) || this
|
|
3384
|
+
isIndeterminate = !isAllSelected && afterFullData.some((row) => XEUtils.get(row, checkField) || XEUtils.get(row, indeterminateField) || !!treeIndeterminateMaps[getRowid(this, row)])
|
|
3262
3385
|
} else {
|
|
3263
|
-
isIndeterminate = !isAllSelected && afterFullData.some(row => XEUtils.get(row, checkField) || this
|
|
3386
|
+
isIndeterminate = !isAllSelected && afterFullData.some((row) => XEUtils.get(row, checkField) || !!treeIndeterminateMaps[getRowid(this, row)])
|
|
3264
3387
|
}
|
|
3265
3388
|
} else {
|
|
3266
3389
|
if (indeterminateField) {
|
|
3267
|
-
isIndeterminate = !isAllSelected && afterFullData.some(row => XEUtils.get(row, checkField) || XEUtils.get(row, indeterminateField))
|
|
3390
|
+
isIndeterminate = !isAllSelected && afterFullData.some((row) => XEUtils.get(row, checkField) || XEUtils.get(row, indeterminateField))
|
|
3268
3391
|
} else {
|
|
3269
|
-
isIndeterminate = !isAllSelected && afterFullData.some(row => XEUtils.get(row, checkField))
|
|
3392
|
+
isIndeterminate = !isAllSelected && afterFullData.some((row) => XEUtils.get(row, checkField))
|
|
3270
3393
|
}
|
|
3271
3394
|
}
|
|
3272
3395
|
} else {
|
|
@@ -3277,19 +3400,22 @@ const Methods = {
|
|
|
3277
3400
|
disableRows.push(row)
|
|
3278
3401
|
return true
|
|
3279
3402
|
}
|
|
3280
|
-
if (this
|
|
3403
|
+
if (selectCheckboxMaps[getRowid(this, row)]) {
|
|
3281
3404
|
checkRows.push(row)
|
|
3282
3405
|
return true
|
|
3283
3406
|
}
|
|
3284
3407
|
return false
|
|
3285
3408
|
}
|
|
3286
|
-
: row => this
|
|
3409
|
+
: row => selectCheckboxMaps[getRowid(this, row)]
|
|
3287
3410
|
)
|
|
3288
3411
|
isAllSelected = isAllResolve && afterFullData.length !== disableRows.length
|
|
3289
3412
|
if (treeConfig) {
|
|
3290
|
-
isIndeterminate = !isAllSelected && afterFullData.some(
|
|
3413
|
+
isIndeterminate = !isAllSelected && afterFullData.some((row) => {
|
|
3414
|
+
const itemRid = getRowid(this, row)
|
|
3415
|
+
return treeIndeterminateMaps[itemRid] || selectCheckboxMaps[itemRid]
|
|
3416
|
+
})
|
|
3291
3417
|
} else {
|
|
3292
|
-
isIndeterminate = !isAllSelected && afterFullData.some(row => this
|
|
3418
|
+
isIndeterminate = !isAllSelected && afterFullData.some((row) => selectCheckboxMaps[getRowid(this, row)])
|
|
3293
3419
|
}
|
|
3294
3420
|
}
|
|
3295
3421
|
this.isAllSelected = isAllSelected
|
|
@@ -3298,10 +3424,10 @@ const Methods = {
|
|
|
3298
3424
|
},
|
|
3299
3425
|
// 还原展开、选中等相关状态
|
|
3300
3426
|
handleReserveStatus () {
|
|
3301
|
-
const { expandColumn, treeOpts, treeConfig, fullDataRowIdData, fullAllDataRowMap, currentRow,
|
|
3427
|
+
const { expandColumn, treeOpts, treeConfig, fullDataRowIdData, fullAllDataRowMap, currentRow, selectRadioRow, radioReserveRow, radioOpts, checkboxOpts, selectCheckboxMaps, rowExpandedMaps, treeExpandedMaps, expandOpts } = this
|
|
3302
3428
|
// 单选框
|
|
3303
|
-
if (
|
|
3304
|
-
this.
|
|
3429
|
+
if (selectRadioRow && !fullAllDataRowMap.has(selectRadioRow)) {
|
|
3430
|
+
this.selectRadioRow = null // 刷新单选行状态
|
|
3305
3431
|
}
|
|
3306
3432
|
// 还原保留选中状态
|
|
3307
3433
|
if (radioOpts.reserve && radioReserveRow) {
|
|
@@ -3311,7 +3437,7 @@ const Methods = {
|
|
|
3311
3437
|
}
|
|
3312
3438
|
}
|
|
3313
3439
|
// 复选框
|
|
3314
|
-
this.
|
|
3440
|
+
this.selectCheckboxMaps = getRecoverRowMaps(this, selectCheckboxMaps) // 刷新多选行状态
|
|
3315
3441
|
// 还原保留选中状态
|
|
3316
3442
|
if (checkboxOpts.reserve) {
|
|
3317
3443
|
this.handleCheckedCheckboxRow(handleReserveRow(this, this.checkboxReserveRowMap), true, true)
|
|
@@ -3320,13 +3446,13 @@ const Methods = {
|
|
|
3320
3446
|
this.currentRow = null // 刷新当前行状态
|
|
3321
3447
|
}
|
|
3322
3448
|
// 行展开
|
|
3323
|
-
this.
|
|
3449
|
+
this.rowExpandedMaps = expandColumn ? getRecoverRowMaps(this, rowExpandedMaps) : [] // 刷新行展开状态
|
|
3324
3450
|
// 还原保留状态
|
|
3325
3451
|
if (expandColumn && expandOpts.reserve) {
|
|
3326
3452
|
this.setRowExpand(handleReserveRow(this, this.rowExpandedReserveRowMap), true)
|
|
3327
3453
|
}
|
|
3328
3454
|
// 树展开
|
|
3329
|
-
this.
|
|
3455
|
+
this.treeExpandedMaps = treeConfig ? getRecoverRowMaps(this, treeExpandedMaps) : [] // 刷新树展开状态
|
|
3330
3456
|
if (treeConfig && treeOpts.reserve) {
|
|
3331
3457
|
this.setTreeExpand(handleReserveRow(this, this.treeExpandedReserveRowMap), true)
|
|
3332
3458
|
}
|
|
@@ -3459,8 +3585,8 @@ const Methods = {
|
|
|
3459
3585
|
}
|
|
3460
3586
|
this.isAllSelected = false
|
|
3461
3587
|
this.isIndeterminate = false
|
|
3462
|
-
this.
|
|
3463
|
-
this.
|
|
3588
|
+
this.selectCheckboxMaps = {}
|
|
3589
|
+
this.treeIndeterminateMaps = {}
|
|
3464
3590
|
return this.$nextTick()
|
|
3465
3591
|
},
|
|
3466
3592
|
/**
|
|
@@ -3483,7 +3609,7 @@ const Methods = {
|
|
|
3483
3609
|
* 单选,行选中事件
|
|
3484
3610
|
*/
|
|
3485
3611
|
triggerRadioRowEvent (evnt, params) {
|
|
3486
|
-
const {
|
|
3612
|
+
const { selectRadioRow: oldValue, radioOpts } = this
|
|
3487
3613
|
const { row } = params
|
|
3488
3614
|
let newValue = row
|
|
3489
3615
|
let isChange = oldValue !== newValue
|
|
@@ -3526,13 +3652,13 @@ const Methods = {
|
|
|
3526
3652
|
return this.$nextTick()
|
|
3527
3653
|
},
|
|
3528
3654
|
isCheckedByRadioRow (row) {
|
|
3529
|
-
return this.
|
|
3655
|
+
return this.selectRadioRow === row
|
|
3530
3656
|
},
|
|
3531
3657
|
handleCheckedRadioRow (row, isForce) {
|
|
3532
3658
|
const { radioOpts } = this
|
|
3533
3659
|
const { checkMethod } = radioOpts
|
|
3534
3660
|
if (row && (isForce || (!checkMethod || checkMethod({ row })))) {
|
|
3535
|
-
this.
|
|
3661
|
+
this.selectRadioRow = row
|
|
3536
3662
|
this.handleRadioReserveRow(row)
|
|
3537
3663
|
}
|
|
3538
3664
|
return this.$nextTick()
|
|
@@ -3560,7 +3686,7 @@ const Methods = {
|
|
|
3560
3686
|
* 用于单选行,手动清空用户的选择
|
|
3561
3687
|
*/
|
|
3562
3688
|
clearRadioRow () {
|
|
3563
|
-
this.
|
|
3689
|
+
this.selectRadioRow = null
|
|
3564
3690
|
return this.$nextTick()
|
|
3565
3691
|
},
|
|
3566
3692
|
/**
|
|
@@ -3573,25 +3699,16 @@ const Methods = {
|
|
|
3573
3699
|
* 用于单选行,获取当已选中的数据
|
|
3574
3700
|
*/
|
|
3575
3701
|
getRadioRecord (isFull) {
|
|
3576
|
-
const {
|
|
3577
|
-
|
|
3578
|
-
|
|
3579
|
-
const rowid = getRowid(this, selectRow)
|
|
3702
|
+
const { selectRadioRow, fullDataRowIdData, afterFullRowMaps } = this
|
|
3703
|
+
if (selectRadioRow) {
|
|
3704
|
+
const rowid = getRowid(this, selectRadioRow)
|
|
3580
3705
|
if (isFull) {
|
|
3581
3706
|
if (!fullDataRowIdData[rowid]) {
|
|
3582
|
-
return
|
|
3707
|
+
return selectRadioRow
|
|
3583
3708
|
}
|
|
3584
3709
|
} else {
|
|
3585
|
-
if (
|
|
3586
|
-
|
|
3587
|
-
const matchObj = XEUtils.findTree(afterFullData, row => rowid === XEUtils.get(row, rowkey), { children: childrenField })
|
|
3588
|
-
if (matchObj) {
|
|
3589
|
-
return selectRow
|
|
3590
|
-
}
|
|
3591
|
-
} else {
|
|
3592
|
-
if (afterFullData.indexOf(selectRow) > -1) {
|
|
3593
|
-
return selectRow
|
|
3594
|
-
}
|
|
3710
|
+
if (afterFullRowMaps[rowid]) {
|
|
3711
|
+
return selectRadioRow
|
|
3595
3712
|
}
|
|
3596
3713
|
}
|
|
3597
3714
|
}
|
|
@@ -3955,12 +4072,17 @@ const Methods = {
|
|
|
3955
4072
|
return rest && rest.expandLoaded
|
|
3956
4073
|
},
|
|
3957
4074
|
clearRowExpandLoaded (row) {
|
|
3958
|
-
const { expandOpts,
|
|
4075
|
+
const { expandOpts, rowExpandLazyLoadedMaps, fullAllDataRowMap } = this
|
|
3959
4076
|
const { lazy } = expandOpts
|
|
4077
|
+
const rowid = getRowid(this, row)
|
|
3960
4078
|
const rest = fullAllDataRowMap.get(row)
|
|
3961
4079
|
if (lazy && rest) {
|
|
3962
4080
|
rest.expandLoaded = false
|
|
3963
|
-
|
|
4081
|
+
const rowTempExpandLazyLoadedMaps = { ...rowExpandLazyLoadedMaps }
|
|
4082
|
+
if (rowTempExpandLazyLoadedMaps[rowid]) {
|
|
4083
|
+
delete rowTempExpandLazyLoadedMaps[rowid]
|
|
4084
|
+
}
|
|
4085
|
+
this.rowExpandLazyLoadedMaps = rowTempExpandLazyLoadedMaps
|
|
3964
4086
|
}
|
|
3965
4087
|
return this.$nextTick()
|
|
3966
4088
|
},
|
|
@@ -3969,9 +4091,10 @@ const Methods = {
|
|
|
3969
4091
|
* @param {Row} row 行对象
|
|
3970
4092
|
*/
|
|
3971
4093
|
reloadRowExpand (row) {
|
|
3972
|
-
const { expandOpts,
|
|
4094
|
+
const { expandOpts, rowExpandLazyLoadedMaps } = this
|
|
3973
4095
|
const { lazy } = expandOpts
|
|
3974
|
-
|
|
4096
|
+
const rowid = getRowid(this, row)
|
|
4097
|
+
if (lazy && !rowExpandLazyLoadedMaps[rowid]) {
|
|
3975
4098
|
this.clearRowExpandLoaded(row)
|
|
3976
4099
|
.then(() => this.handleAsyncRowExpand(row))
|
|
3977
4100
|
}
|
|
@@ -3988,10 +4111,11 @@ const Methods = {
|
|
|
3988
4111
|
* 展开行事件
|
|
3989
4112
|
*/
|
|
3990
4113
|
triggerRowExpandEvent (evnt, params) {
|
|
3991
|
-
const { expandOpts,
|
|
4114
|
+
const { expandOpts, rowExpandLazyLoadedMaps, expandColumn: column } = this
|
|
3992
4115
|
const { row } = params
|
|
3993
4116
|
const { lazy } = expandOpts
|
|
3994
|
-
|
|
4117
|
+
const rowid = getRowid(this, row)
|
|
4118
|
+
if (!lazy || !rowExpandLazyLoadedMaps[rowid]) {
|
|
3995
4119
|
const expanded = !this.isExpandByRow(row)
|
|
3996
4120
|
const columnIndex = this.getColumnIndex(column)
|
|
3997
4121
|
const $columnIndex = this.getVMColumnIndex(column)
|
|
@@ -4041,18 +4165,36 @@ const Methods = {
|
|
|
4041
4165
|
return this.setRowExpand(expandedRows, expanded)
|
|
4042
4166
|
},
|
|
4043
4167
|
handleAsyncRowExpand (row) {
|
|
4044
|
-
const
|
|
4168
|
+
const { fullAllDataRowMap, expandOpts } = this
|
|
4169
|
+
const rest = fullAllDataRowMap.get(row)
|
|
4045
4170
|
return new Promise(resolve => {
|
|
4046
|
-
|
|
4047
|
-
|
|
4048
|
-
|
|
4049
|
-
|
|
4050
|
-
|
|
4051
|
-
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
|
|
4055
|
-
|
|
4171
|
+
const { loadMethod } = expandOpts
|
|
4172
|
+
if (loadMethod) {
|
|
4173
|
+
const { rowExpandLazyLoadedMaps } = this
|
|
4174
|
+
const rowTempExpandLazyLoadedMaps = { ...rowExpandLazyLoadedMaps }
|
|
4175
|
+
const rowid = getRowid(this, row)
|
|
4176
|
+
rowTempExpandLazyLoadedMaps[rowid] = row
|
|
4177
|
+
this.rowExpandLazyLoadedMaps = rowTempExpandLazyLoadedMaps
|
|
4178
|
+
loadMethod({ $table: this, row, rowIndex: this.getRowIndex(row), $rowIndex: this.getVMRowIndex(row) }).then(() => {
|
|
4179
|
+
rest.expandLoaded = true
|
|
4180
|
+
const { rowExpandedMaps } = this
|
|
4181
|
+
const rowTempExpandedMaps = { ...rowExpandedMaps }
|
|
4182
|
+
rowTempExpandedMaps[rowid] = row
|
|
4183
|
+
this.rowExpandedMaps = rowTempExpandedMaps
|
|
4184
|
+
}).catch(() => {
|
|
4185
|
+
rest.expandLoaded = false
|
|
4186
|
+
}).finally(() => {
|
|
4187
|
+
const { rowExpandLazyLoadedMaps } = this
|
|
4188
|
+
const rowTempExpandLazyLoadedMaps = { ...rowExpandLazyLoadedMaps }
|
|
4189
|
+
if (rowTempExpandLazyLoadedMaps[rowid]) {
|
|
4190
|
+
delete rowTempExpandLazyLoadedMaps[rowid]
|
|
4191
|
+
}
|
|
4192
|
+
this.rowExpandLazyLoadedMaps = rowTempExpandLazyLoadedMaps
|
|
4193
|
+
resolve(this.$nextTick().then(this.recalculate))
|
|
4194
|
+
})
|
|
4195
|
+
} else {
|
|
4196
|
+
resolve()
|
|
4197
|
+
}
|
|
4056
4198
|
})
|
|
4057
4199
|
},
|
|
4058
4200
|
/**
|
|
@@ -4063,8 +4205,8 @@ const Methods = {
|
|
|
4063
4205
|
* @param {Boolean} expanded 是否展开
|
|
4064
4206
|
*/
|
|
4065
4207
|
setRowExpand (rows, expanded) {
|
|
4066
|
-
const {
|
|
4067
|
-
let {
|
|
4208
|
+
const { rowExpandedMaps, fullAllDataRowIdData, rowExpandLazyLoadedMaps, expandOpts, expandColumn: column } = this
|
|
4209
|
+
let rExpandedMaps = { ...rowExpandedMaps }
|
|
4068
4210
|
const { reserve, lazy, accordion, toggleMethod } = expandOpts
|
|
4069
4211
|
const lazyRests = []
|
|
4070
4212
|
const columnIndex = this.getColumnIndex(column)
|
|
@@ -4075,30 +4217,36 @@ const Methods = {
|
|
|
4075
4217
|
}
|
|
4076
4218
|
if (accordion) {
|
|
4077
4219
|
// 只能同时展开一个
|
|
4078
|
-
|
|
4220
|
+
rExpandedMaps = {}
|
|
4079
4221
|
rows = rows.slice(rows.length - 1, rows.length)
|
|
4080
4222
|
}
|
|
4081
4223
|
const validRows = toggleMethod ? rows.filter(row => toggleMethod({ expanded, column, columnIndex, $columnIndex, row, rowIndex: this.getRowIndex(row), $rowIndex: this.getVMRowIndex(row) })) : rows
|
|
4082
4224
|
if (expanded) {
|
|
4083
4225
|
validRows.forEach(row => {
|
|
4084
|
-
|
|
4085
|
-
|
|
4086
|
-
const
|
|
4226
|
+
const rowid = getRowid(this, row)
|
|
4227
|
+
if (!rExpandedMaps[rowid]) {
|
|
4228
|
+
const rest = fullAllDataRowIdData[rowid]
|
|
4229
|
+
const isLoad = lazy && !rest.expandLoaded && !rowExpandLazyLoadedMaps[rowid]
|
|
4087
4230
|
if (isLoad) {
|
|
4088
4231
|
lazyRests.push(this.handleAsyncRowExpand(row))
|
|
4089
4232
|
} else {
|
|
4090
|
-
|
|
4233
|
+
rExpandedMaps[rowid] = row
|
|
4091
4234
|
}
|
|
4092
4235
|
}
|
|
4093
4236
|
})
|
|
4094
4237
|
} else {
|
|
4095
|
-
|
|
4238
|
+
validRows.forEach(item => {
|
|
4239
|
+
const rowid = getRowid(this, item)
|
|
4240
|
+
if (rExpandedMaps[rowid]) {
|
|
4241
|
+
delete rExpandedMaps[rowid]
|
|
4242
|
+
}
|
|
4243
|
+
})
|
|
4096
4244
|
}
|
|
4097
4245
|
if (reserve) {
|
|
4098
4246
|
validRows.forEach(row => this.handleRowExpandReserve(row, expanded))
|
|
4099
4247
|
}
|
|
4100
4248
|
}
|
|
4101
|
-
this.
|
|
4249
|
+
this.rowExpandedMaps = rExpandedMaps
|
|
4102
4250
|
return Promise.all(lazyRests).then(this.recalculate)
|
|
4103
4251
|
},
|
|
4104
4252
|
/**
|
|
@@ -4106,22 +4254,23 @@ const Methods = {
|
|
|
4106
4254
|
* @param {Row} row 行对象
|
|
4107
4255
|
*/
|
|
4108
4256
|
isExpandByRow (row) {
|
|
4109
|
-
const {
|
|
4110
|
-
|
|
4257
|
+
const { rowExpandedMaps } = this
|
|
4258
|
+
const rowid = getRowid(this, row)
|
|
4259
|
+
return !!rowExpandedMaps[rowid]
|
|
4111
4260
|
},
|
|
4112
4261
|
/**
|
|
4113
4262
|
* 手动清空展开行状态,数据会恢复成未展开的状态
|
|
4114
4263
|
*/
|
|
4115
4264
|
clearRowExpand () {
|
|
4116
|
-
const { expandOpts,
|
|
4265
|
+
const { expandOpts, tableFullData } = this
|
|
4117
4266
|
const { reserve } = expandOpts
|
|
4118
|
-
const
|
|
4119
|
-
this.
|
|
4267
|
+
const expList = this.getRowExpandRecords()
|
|
4268
|
+
this.rowExpandedMaps = {}
|
|
4120
4269
|
if (reserve) {
|
|
4121
4270
|
tableFullData.forEach(row => this.handleRowExpandReserve(row, false))
|
|
4122
4271
|
}
|
|
4123
4272
|
return this.$nextTick().then(() => {
|
|
4124
|
-
if (
|
|
4273
|
+
if (expList.length) {
|
|
4125
4274
|
this.recalculate()
|
|
4126
4275
|
}
|
|
4127
4276
|
})
|
|
@@ -4142,13 +4291,25 @@ const Methods = {
|
|
|
4142
4291
|
}
|
|
4143
4292
|
},
|
|
4144
4293
|
getRowExpandRecords () {
|
|
4145
|
-
|
|
4294
|
+
const rest = []
|
|
4295
|
+
XEUtils.each(this.rowExpandedMaps, item => {
|
|
4296
|
+
if (item) {
|
|
4297
|
+
rest.push(item)
|
|
4298
|
+
}
|
|
4299
|
+
})
|
|
4300
|
+
return rest
|
|
4146
4301
|
},
|
|
4147
4302
|
getTreeExpandRecords () {
|
|
4148
|
-
|
|
4303
|
+
const rest = []
|
|
4304
|
+
XEUtils.each(this.treeExpandedMaps, item => {
|
|
4305
|
+
if (item) {
|
|
4306
|
+
rest.push(item)
|
|
4307
|
+
}
|
|
4308
|
+
})
|
|
4309
|
+
return rest
|
|
4149
4310
|
},
|
|
4150
4311
|
/**
|
|
4151
|
-
*
|
|
4312
|
+
* 获取树表格状态
|
|
4152
4313
|
*/
|
|
4153
4314
|
getTreeStatus () {
|
|
4154
4315
|
if (this.treeConfig) {
|
|
@@ -4168,12 +4329,15 @@ const Methods = {
|
|
|
4168
4329
|
return rest && rest.treeLoaded
|
|
4169
4330
|
},
|
|
4170
4331
|
clearTreeExpandLoaded (row) {
|
|
4171
|
-
const { treeOpts,
|
|
4332
|
+
const { treeOpts, treeExpandedMaps, fullAllDataRowMap } = this
|
|
4172
4333
|
const { transform, lazy } = treeOpts
|
|
4334
|
+
const rowid = getRowid(this, row)
|
|
4173
4335
|
const rest = fullAllDataRowMap.get(row)
|
|
4174
4336
|
if (lazy && rest) {
|
|
4175
4337
|
rest.treeLoaded = false
|
|
4176
|
-
|
|
4338
|
+
if (treeExpandedMaps[rowid]) {
|
|
4339
|
+
delete treeExpandedMaps[rowid]
|
|
4340
|
+
}
|
|
4177
4341
|
}
|
|
4178
4342
|
if (transform) {
|
|
4179
4343
|
this.handleVirtualTreeToList()
|
|
@@ -4186,10 +4350,11 @@ const Methods = {
|
|
|
4186
4350
|
* @param {Row} row 行对象
|
|
4187
4351
|
*/
|
|
4188
4352
|
reloadTreeExpand (row) {
|
|
4189
|
-
const { treeOpts,
|
|
4353
|
+
const { treeOpts, treeExpandLazyLoadedMaps } = this
|
|
4190
4354
|
const { transform, lazy } = treeOpts
|
|
4191
4355
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
4192
|
-
|
|
4356
|
+
const rowid = getRowid(this, row)
|
|
4357
|
+
if (lazy && row[hasChildField] && !treeExpandLazyLoadedMaps[rowid]) {
|
|
4193
4358
|
this.clearTreeExpandLoaded(row).then(() => {
|
|
4194
4359
|
return this.handleAsyncTreeExpandChilds(row)
|
|
4195
4360
|
}).then(() => {
|
|
@@ -4214,10 +4379,11 @@ const Methods = {
|
|
|
4214
4379
|
* 展开树节点事件
|
|
4215
4380
|
*/
|
|
4216
4381
|
triggerTreeExpandEvent (evnt, params) {
|
|
4217
|
-
const { treeOpts,
|
|
4382
|
+
const { treeOpts, treeExpandLazyLoadedMaps } = this
|
|
4218
4383
|
const { row, column } = params
|
|
4219
4384
|
const { lazy } = treeOpts
|
|
4220
|
-
|
|
4385
|
+
const rowid = getRowid(this, row)
|
|
4386
|
+
if (!lazy || !treeExpandLazyLoadedMaps[rowid]) {
|
|
4221
4387
|
const expanded = !this.isTreeExpandByRow(row)
|
|
4222
4388
|
const columnIndex = this.getColumnIndex(column)
|
|
4223
4389
|
const $columnIndex = this.getVMColumnIndex(column)
|
|
@@ -4255,42 +4421,56 @@ const Methods = {
|
|
|
4255
4421
|
}
|
|
4256
4422
|
},
|
|
4257
4423
|
handleAsyncTreeExpandChilds (row) {
|
|
4258
|
-
const {
|
|
4424
|
+
const { treeOpts, checkboxOpts } = this
|
|
4259
4425
|
const { transform, loadMethod } = treeOpts
|
|
4260
4426
|
const { checkStrictly } = checkboxOpts
|
|
4261
|
-
const rest = fullAllDataRowMap.get(row)
|
|
4262
4427
|
return new Promise(resolve => {
|
|
4263
|
-
|
|
4264
|
-
|
|
4265
|
-
|
|
4266
|
-
rest
|
|
4267
|
-
|
|
4268
|
-
|
|
4269
|
-
|
|
4270
|
-
|
|
4271
|
-
|
|
4272
|
-
|
|
4273
|
-
|
|
4274
|
-
|
|
4275
|
-
|
|
4276
|
-
|
|
4277
|
-
|
|
4278
|
-
|
|
4279
|
-
|
|
4280
|
-
|
|
4281
|
-
if (
|
|
4282
|
-
|
|
4428
|
+
if (loadMethod) {
|
|
4429
|
+
const { fullAllDataRowMap, treeExpandLazyLoadedMaps } = this
|
|
4430
|
+
const rowid = getRowid(this, row)
|
|
4431
|
+
const rest = fullAllDataRowMap.get(row)
|
|
4432
|
+
treeExpandLazyLoadedMaps[rowid] = row
|
|
4433
|
+
loadMethod({ $table: this, row }).then(childRecords => {
|
|
4434
|
+
// 响应成功后则展开行,并将子节点挂载到该节点下
|
|
4435
|
+
rest.treeLoaded = true
|
|
4436
|
+
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
4437
|
+
treeExpandLazyLoadedMaps[rowid] = null
|
|
4438
|
+
}
|
|
4439
|
+
if (!XEUtils.isArray(childRecords)) {
|
|
4440
|
+
childRecords = []
|
|
4441
|
+
}
|
|
4442
|
+
if (childRecords) {
|
|
4443
|
+
return this.loadTreeChildren(row, childRecords).then(childRows => {
|
|
4444
|
+
const { treeExpandedMaps } = this
|
|
4445
|
+
const treeTempExpandedMaps = { ...treeExpandedMaps }
|
|
4446
|
+
if (childRows.length && !treeTempExpandedMaps[rowid]) {
|
|
4447
|
+
treeTempExpandedMaps[rowid] = row
|
|
4448
|
+
this.treeExpandedMaps = treeTempExpandedMaps
|
|
4283
4449
|
}
|
|
4450
|
+
// 如果当前节点已选中,则展开后子节点也被选中
|
|
4451
|
+
if (!checkStrictly && this.isCheckedByCheckboxRow(row)) {
|
|
4452
|
+
this.handleCheckedCheckboxRow(childRows, true, true)
|
|
4453
|
+
}
|
|
4454
|
+
return this.$nextTick().then(() => {
|
|
4455
|
+
if (transform) {
|
|
4456
|
+
return this.handleTableData()
|
|
4457
|
+
}
|
|
4458
|
+
})
|
|
4284
4459
|
})
|
|
4285
|
-
}
|
|
4286
|
-
}
|
|
4287
|
-
}).catch(() => {
|
|
4460
|
+
}
|
|
4461
|
+
}).catch(() => {
|
|
4288
4462
|
// 如果响应异常,则不展开,再次点击后将重新触发懒加载
|
|
4289
|
-
|
|
4290
|
-
|
|
4291
|
-
|
|
4292
|
-
|
|
4293
|
-
|
|
4463
|
+
rest.treeLoaded = false
|
|
4464
|
+
const { treeExpandLazyLoadedMaps } = this
|
|
4465
|
+
if (treeExpandLazyLoadedMaps[rowid]) {
|
|
4466
|
+
treeExpandLazyLoadedMaps[rowid] = null
|
|
4467
|
+
}
|
|
4468
|
+
}).finally(() => {
|
|
4469
|
+
this.$nextTick().then(() => this.recalculate()).then(() => resolve())
|
|
4470
|
+
})
|
|
4471
|
+
} else {
|
|
4472
|
+
resolve()
|
|
4473
|
+
}
|
|
4294
4474
|
})
|
|
4295
4475
|
},
|
|
4296
4476
|
/**
|
|
@@ -4317,8 +4497,9 @@ const Methods = {
|
|
|
4317
4497
|
* @returns
|
|
4318
4498
|
*/
|
|
4319
4499
|
handleBaseTreeExpand (rows, expanded) {
|
|
4320
|
-
const { fullAllDataRowMap, tableFullData,
|
|
4500
|
+
const { fullAllDataRowMap, tableFullData, treeExpandedMaps, treeOpts, treeExpandLazyLoadedMaps, treeNodeColumn } = this
|
|
4321
4501
|
const { reserve, lazy, accordion, toggleMethod } = treeOpts
|
|
4502
|
+
const treeTempExpandedMaps = { ...treeExpandedMaps }
|
|
4322
4503
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
4323
4504
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField
|
|
4324
4505
|
const result = []
|
|
@@ -4330,30 +4511,42 @@ const Methods = {
|
|
|
4330
4511
|
// 同一级只能展开一个
|
|
4331
4512
|
const matchObj = XEUtils.findTree(tableFullData, item => item === validRows[0], { children: childrenField })
|
|
4332
4513
|
if (matchObj) {
|
|
4333
|
-
|
|
4514
|
+
matchObj.items.forEach(item => {
|
|
4515
|
+
const rowid = getRowid(this, item)
|
|
4516
|
+
if (treeTempExpandedMaps[rowid]) {
|
|
4517
|
+
delete treeTempExpandedMaps[rowid]
|
|
4518
|
+
}
|
|
4519
|
+
})
|
|
4334
4520
|
}
|
|
4335
4521
|
}
|
|
4336
4522
|
if (expanded) {
|
|
4337
4523
|
validRows.forEach(row => {
|
|
4338
|
-
|
|
4524
|
+
const rowid = getRowid(this, row)
|
|
4525
|
+
if (!treeTempExpandedMaps[rowid]) {
|
|
4339
4526
|
const rest = fullAllDataRowMap.get(row)
|
|
4340
|
-
const isLoad = lazy && row[
|
|
4527
|
+
const isLoad = lazy && row[hasChildField] && !rest.treeLoaded && !treeExpandLazyLoadedMaps[rowid]
|
|
4341
4528
|
// 是否使用懒加载
|
|
4342
4529
|
if (isLoad) {
|
|
4343
4530
|
result.push(this.handleAsyncTreeExpandChilds(row))
|
|
4344
4531
|
} else {
|
|
4345
4532
|
if (row[childrenField] && row[childrenField].length) {
|
|
4346
|
-
|
|
4533
|
+
treeTempExpandedMaps[rowid] = row
|
|
4347
4534
|
}
|
|
4348
4535
|
}
|
|
4349
4536
|
}
|
|
4350
4537
|
})
|
|
4351
4538
|
} else {
|
|
4352
|
-
|
|
4539
|
+
validRows.forEach(item => {
|
|
4540
|
+
const rowid = getRowid(this, item)
|
|
4541
|
+
if (treeTempExpandedMaps[rowid]) {
|
|
4542
|
+
delete treeTempExpandedMaps[rowid]
|
|
4543
|
+
}
|
|
4544
|
+
})
|
|
4353
4545
|
}
|
|
4354
4546
|
if (reserve) {
|
|
4355
4547
|
validRows.forEach(row => this.handleTreeExpandReserve(row, expanded))
|
|
4356
4548
|
}
|
|
4549
|
+
this.treeExpandedMaps = treeTempExpandedMaps
|
|
4357
4550
|
return Promise.all(result).then(this.recalculate)
|
|
4358
4551
|
},
|
|
4359
4552
|
/**
|
|
@@ -4400,17 +4593,18 @@ const Methods = {
|
|
|
4400
4593
|
* @param {Row} row 行对象
|
|
4401
4594
|
*/
|
|
4402
4595
|
isTreeExpandByRow (row) {
|
|
4403
|
-
|
|
4596
|
+
const { treeExpandedMaps } = this
|
|
4597
|
+
return !!treeExpandedMaps[getRowid(this, row)]
|
|
4404
4598
|
},
|
|
4405
4599
|
/**
|
|
4406
4600
|
* 手动清空树形节点的展开状态,数据会恢复成未展开的状态
|
|
4407
4601
|
*/
|
|
4408
4602
|
clearTreeExpand () {
|
|
4409
|
-
const { treeOpts,
|
|
4603
|
+
const { treeOpts, tableFullData } = this
|
|
4410
4604
|
const { transform, reserve } = treeOpts
|
|
4411
4605
|
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
4412
|
-
const
|
|
4413
|
-
this.
|
|
4606
|
+
const expList = this.getTreeExpandRecords()
|
|
4607
|
+
this.treeExpandedMaps = {}
|
|
4414
4608
|
if (reserve) {
|
|
4415
4609
|
XEUtils.eachTree(tableFullData, row => this.handleTreeExpandReserve(row, false), { children: childrenField })
|
|
4416
4610
|
}
|
|
@@ -4420,7 +4614,7 @@ const Methods = {
|
|
|
4420
4614
|
return this.handleTableData()
|
|
4421
4615
|
}
|
|
4422
4616
|
}).then(() => {
|
|
4423
|
-
if (
|
|
4617
|
+
if (expList.length) {
|
|
4424
4618
|
this.recalculate()
|
|
4425
4619
|
}
|
|
4426
4620
|
})
|