vxe-table 3.11.30-beta.0 → 3.11.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/style.css +1 -1
- package/es/table/module/keyboard/mixin.js +2 -1
- package/es/table/src/methods.js +233 -272
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/index.umd.js +264 -313
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/module/keyboard/mixin.js +2 -3
- package/lib/table/module/keyboard/mixin.min.js +1 -1
- package/lib/table/src/methods.js +260 -306
- package/lib/table/src/methods.min.js +1 -1
- package/lib/ui/index.js +1 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/package.json +2 -2
- package/packages/table/module/keyboard/mixin.ts +3 -1
- package/packages/table/src/methods.ts +242 -262
- /package/es/{iconfont.1734070646835.ttf → iconfont.1734099731402.ttf} +0 -0
- /package/es/{iconfont.1734070646835.woff → iconfont.1734099731402.woff} +0 -0
- /package/es/{iconfont.1734070646835.woff2 → iconfont.1734099731402.woff2} +0 -0
- /package/lib/{iconfont.1734070646835.ttf → iconfont.1734099731402.ttf} +0 -0
- /package/lib/{iconfont.1734070646835.woff → iconfont.1734099731402.woff} +0 -0
- /package/lib/{iconfont.1734070646835.woff2 → iconfont.1734099731402.woff2} +0 -0
|
@@ -4006,11 +4006,13 @@ const Methods = {
|
|
|
4006
4006
|
}
|
|
4007
4007
|
},
|
|
4008
4008
|
handleCheckedCheckboxRow (rows: any, value: any, isForce: any) {
|
|
4009
|
+
const $xeTable = this
|
|
4010
|
+
|
|
4009
4011
|
if (rows && !XEUtils.isArray(rows)) {
|
|
4010
4012
|
rows = [rows]
|
|
4011
4013
|
}
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
+
$xeTable.handleBatchSelectRows(rows, !!value, isForce)
|
|
4015
|
+
$xeTable.checkSelectionStatus()
|
|
4014
4016
|
return this.$nextTick()
|
|
4015
4017
|
},
|
|
4016
4018
|
/**
|
|
@@ -4037,216 +4039,97 @@ const Methods = {
|
|
|
4037
4039
|
return !!treeIndeterminateMaps[getRowid(this, row)] && !this.isCheckedByCheckboxRow(row)
|
|
4038
4040
|
},
|
|
4039
4041
|
/**
|
|
4040
|
-
*
|
|
4042
|
+
* 切换选中
|
|
4041
4043
|
* 多选,行选中事件
|
|
4042
|
-
* value 选中true 不选false 半选-1
|
|
4043
4044
|
*/
|
|
4044
|
-
handleBatchSelectRows (rows: any[],
|
|
4045
|
+
handleBatchSelectRows (rows: any[], checked: boolean, isForce?: boolean) {
|
|
4045
4046
|
const $xeTable = this
|
|
4046
|
-
const
|
|
4047
|
+
const props = $xeTable
|
|
4048
|
+
const reactData = $xeTable
|
|
4047
4049
|
|
|
4048
|
-
const {
|
|
4050
|
+
const { treeConfig } = props
|
|
4051
|
+
const { selectCheckboxMaps } = reactData
|
|
4052
|
+
const selectRowMaps = Object.assign({}, selectCheckboxMaps)
|
|
4053
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
4054
|
+
const { transform, mapChildrenField } = treeOpts
|
|
4055
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
4056
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
4049
4057
|
const { checkField, checkStrictly, checkMethod } = checkboxOpts
|
|
4058
|
+
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
4050
4059
|
if (checkField) {
|
|
4060
|
+
// 树结构
|
|
4051
4061
|
if (treeConfig && !checkStrictly) {
|
|
4052
|
-
|
|
4053
|
-
|
|
4054
|
-
})
|
|
4055
|
-
} else {
|
|
4056
|
-
rows.forEach(row => {
|
|
4062
|
+
// 更新子节点状态
|
|
4063
|
+
XEUtils.eachTree(rows, (row) => {
|
|
4057
4064
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
4058
|
-
XEUtils.set(row, checkField,
|
|
4059
|
-
|
|
4065
|
+
XEUtils.set(row, checkField, checked)
|
|
4066
|
+
if (indeterminateField) {
|
|
4067
|
+
XEUtils.set(row, indeterminateField, false)
|
|
4068
|
+
}
|
|
4069
|
+
$xeTable.handleCheckboxReserveRow(row, checked)
|
|
4060
4070
|
}
|
|
4061
|
-
})
|
|
4062
|
-
|
|
4063
|
-
|
|
4064
|
-
if (treeConfig && !checkStrictly) {
|
|
4065
|
-
rows.forEach(row => {
|
|
4066
|
-
this.handleSelectRow({ row }, value, isForce)
|
|
4067
|
-
})
|
|
4071
|
+
}, { children: transform ? mapChildrenField : childrenField })
|
|
4072
|
+
reactData.selectCheckboxMaps = selectRowMaps
|
|
4073
|
+
return
|
|
4068
4074
|
} else {
|
|
4069
|
-
|
|
4075
|
+
// 列表
|
|
4070
4076
|
rows.forEach(row => {
|
|
4071
|
-
const rowid = getRowid($xeTable, row)
|
|
4072
4077
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
4073
|
-
|
|
4074
|
-
|
|
4075
|
-
selectRowMaps[rowid] = row
|
|
4076
|
-
}
|
|
4077
|
-
} else {
|
|
4078
|
-
if (selectRowMaps[rowid]) {
|
|
4079
|
-
delete selectRowMaps[rowid]
|
|
4080
|
-
}
|
|
4081
|
-
}
|
|
4082
|
-
this.handleCheckboxReserveRow(row, value)
|
|
4078
|
+
XEUtils.set(row, checkField, checked)
|
|
4079
|
+
$xeTable.handleCheckboxReserveRow(row, checked)
|
|
4083
4080
|
}
|
|
4084
4081
|
})
|
|
4085
|
-
this.selectCheckboxMaps = selectRowMaps
|
|
4086
4082
|
}
|
|
4083
|
+
reactData.selectCheckboxMaps = selectRowMaps
|
|
4084
|
+
return
|
|
4087
4085
|
}
|
|
4088
|
-
|
|
4089
|
-
|
|
4090
|
-
|
|
4091
|
-
|
|
4092
|
-
|
|
4093
|
-
|
|
4094
|
-
|
|
4095
|
-
|
|
4096
|
-
|
|
4097
|
-
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
4098
|
-
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
4099
|
-
const rowid = getRowid(this, row)
|
|
4100
|
-
if (checkField) {
|
|
4101
|
-
if (treeConfig && !checkStrictly) {
|
|
4102
|
-
if (value === -1) {
|
|
4103
|
-
if (!treeIndeterminateMaps[rowid]) {
|
|
4104
|
-
if (indeterminateField) {
|
|
4105
|
-
XEUtils.set(row, indeterminateField, true)
|
|
4106
|
-
}
|
|
4107
|
-
treeIndeterminateMaps[rowid] = row
|
|
4108
|
-
}
|
|
4109
|
-
XEUtils.set(row, checkField, false)
|
|
4110
|
-
} else {
|
|
4111
|
-
// 更新子节点状态
|
|
4112
|
-
XEUtils.eachTree([row], (item) => {
|
|
4113
|
-
if (this.eqRow(item, row) || (isForce || (!checkMethod || checkMethod({ row: item })))) {
|
|
4114
|
-
XEUtils.set(item, checkField, value)
|
|
4115
|
-
if (indeterminateField) {
|
|
4116
|
-
XEUtils.set(row, indeterminateField, false)
|
|
4117
|
-
}
|
|
4118
|
-
delete treeIndeterminateMaps[getRowid(this, item)]
|
|
4119
|
-
this.handleCheckboxReserveRow(row, value)
|
|
4120
|
-
}
|
|
4121
|
-
}, { children: childrenField })
|
|
4122
|
-
}
|
|
4123
|
-
// 如果存在父节点,更新父节点状态
|
|
4124
|
-
const matchObj = XEUtils.findTree(afterFullData, item => this.eqRow(item, row), { children: childrenField })
|
|
4125
|
-
if (matchObj && matchObj.parent) {
|
|
4126
|
-
let parentStatus
|
|
4127
|
-
const vItems: any[] = []
|
|
4128
|
-
const vItemMaps: any = {}
|
|
4129
|
-
if (!isForce && checkMethod) {
|
|
4130
|
-
matchObj.items.forEach((item) => {
|
|
4131
|
-
if (checkMethod({ row: item })) {
|
|
4132
|
-
const itemRid = getRowid(this, item)
|
|
4133
|
-
vItemMaps[itemRid] = item
|
|
4134
|
-
vItems.push(item)
|
|
4135
|
-
}
|
|
4136
|
-
})
|
|
4137
|
-
} else {
|
|
4138
|
-
matchObj.items.forEach(item => {
|
|
4139
|
-
const itemRid = getRowid(this, item)
|
|
4140
|
-
vItemMaps[itemRid] = item
|
|
4141
|
-
vItems.push(item)
|
|
4142
|
-
})
|
|
4143
|
-
}
|
|
4144
|
-
const indeterminatesItem = XEUtils.find(matchObj.items, item => !!treeIndeterminateMaps[getRowid(this, item)])
|
|
4145
|
-
if (indeterminatesItem) {
|
|
4146
|
-
parentStatus = -1
|
|
4086
|
+
|
|
4087
|
+
// 树结构
|
|
4088
|
+
if (treeConfig && !checkStrictly) {
|
|
4089
|
+
// 更新子节点状态
|
|
4090
|
+
XEUtils.eachTree(rows, (row) => {
|
|
4091
|
+
const rowid = getRowid($xeTable, row)
|
|
4092
|
+
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
4093
|
+
if (checked) {
|
|
4094
|
+
selectRowMaps[rowid] = row
|
|
4147
4095
|
} else {
|
|
4148
|
-
|
|
4149
|
-
|
|
4150
|
-
|
|
4151
|
-
selectItems.push(item)
|
|
4152
|
-
}
|
|
4153
|
-
})
|
|
4154
|
-
parentStatus = selectItems.filter(item => vItemMaps[getRowid(this, item)]).length === vItems.length ? true : (selectItems.length || value === -1 ? -1 : false)
|
|
4096
|
+
if (selectRowMaps[rowid]) {
|
|
4097
|
+
delete selectRowMaps[rowid]
|
|
4098
|
+
}
|
|
4155
4099
|
}
|
|
4156
|
-
|
|
4157
|
-
return this.handleSelectRow({ row: matchObj.parent }, parentStatus, isForce)
|
|
4100
|
+
$xeTable.handleCheckboxReserveRow(row, checked)
|
|
4158
4101
|
}
|
|
4159
|
-
}
|
|
4160
|
-
|
|
4161
|
-
|
|
4162
|
-
|
|
4163
|
-
|
|
4164
|
-
|
|
4165
|
-
|
|
4166
|
-
|
|
4167
|
-
|
|
4168
|
-
|
|
4169
|
-
|
|
4170
|
-
|
|
4171
|
-
}
|
|
4172
|
-
treeIndeterminateMaps[rowid] = row
|
|
4102
|
+
}, { children: transform ? mapChildrenField : childrenField })
|
|
4103
|
+
reactData.selectCheckboxMaps = selectRowMaps
|
|
4104
|
+
return
|
|
4105
|
+
}
|
|
4106
|
+
|
|
4107
|
+
// 列表
|
|
4108
|
+
rows.forEach(row => {
|
|
4109
|
+
const rowid = getRowid($xeTable, row)
|
|
4110
|
+
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
4111
|
+
if (checked) {
|
|
4112
|
+
if (!selectRowMaps[rowid]) {
|
|
4113
|
+
selectRowMaps[rowid] = row
|
|
4173
4114
|
}
|
|
4115
|
+
} else {
|
|
4174
4116
|
if (selectRowMaps[rowid]) {
|
|
4175
4117
|
delete selectRowMaps[rowid]
|
|
4176
4118
|
}
|
|
4177
|
-
} else {
|
|
4178
|
-
// 更新子节点状态
|
|
4179
|
-
XEUtils.eachTree([row], (item) => {
|
|
4180
|
-
const itemRid = getRowid(this, item)
|
|
4181
|
-
if (this.eqRow(item, row) || (isForce || (!checkMethod || checkMethod({ row: item })))) {
|
|
4182
|
-
if (value) {
|
|
4183
|
-
selectRowMaps[itemRid] = item
|
|
4184
|
-
} else {
|
|
4185
|
-
if (selectRowMaps[itemRid]) {
|
|
4186
|
-
delete selectRowMaps[itemRid]
|
|
4187
|
-
}
|
|
4188
|
-
}
|
|
4189
|
-
if (indeterminateField) {
|
|
4190
|
-
XEUtils.set(row, indeterminateField, false)
|
|
4191
|
-
}
|
|
4192
|
-
delete treeIndeterminateMaps[getRowid(this, item)]
|
|
4193
|
-
this.handleCheckboxReserveRow(row, value)
|
|
4194
|
-
}
|
|
4195
|
-
}, { children: childrenField })
|
|
4196
|
-
}
|
|
4197
|
-
// 如果存在父节点,更新父节点状态
|
|
4198
|
-
const matchObj = XEUtils.findTree(afterFullData, item => this.eqRow(item, row), { children: childrenField })
|
|
4199
|
-
if (matchObj && matchObj.parent) {
|
|
4200
|
-
let parentStatus
|
|
4201
|
-
const vItems: any[] = []
|
|
4202
|
-
const vItemMaps: any = {}
|
|
4203
|
-
if (!isForce && checkMethod) {
|
|
4204
|
-
matchObj.items.forEach((item) => {
|
|
4205
|
-
if (checkMethod({ row: item })) {
|
|
4206
|
-
const itemRid = getRowid(this, item)
|
|
4207
|
-
vItemMaps[itemRid] = item
|
|
4208
|
-
vItems.push(item)
|
|
4209
|
-
}
|
|
4210
|
-
})
|
|
4211
|
-
} else {
|
|
4212
|
-
matchObj.items.forEach(item => {
|
|
4213
|
-
const itemRid = getRowid(this, item)
|
|
4214
|
-
vItemMaps[itemRid] = item
|
|
4215
|
-
vItems.push(item)
|
|
4216
|
-
})
|
|
4217
|
-
}
|
|
4218
|
-
const indeterminatesItem = XEUtils.find(matchObj.items, item => !!treeIndeterminateMaps[getRowid(this, item)])
|
|
4219
|
-
if (indeterminatesItem) {
|
|
4220
|
-
parentStatus = -1
|
|
4221
|
-
} else {
|
|
4222
|
-
const selectItems: any[] = []
|
|
4223
|
-
matchObj.items.forEach(item => {
|
|
4224
|
-
const itemRid = getRowid(this, item)
|
|
4225
|
-
if (selectRowMaps[itemRid]) {
|
|
4226
|
-
selectItems.push(item)
|
|
4227
|
-
}
|
|
4228
|
-
})
|
|
4229
|
-
parentStatus = selectItems.filter(item => vItemMaps[getRowid(this, item)]).length === vItems.length ? true : (selectItems.length || value === -1 ? -1 : false)
|
|
4230
|
-
}
|
|
4231
|
-
this.selectCheckboxMaps = selectRowMaps
|
|
4232
|
-
return this.handleSelectRow({ row: matchObj.parent }, parentStatus, isForce)
|
|
4233
|
-
}
|
|
4234
|
-
} else {
|
|
4235
|
-
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
4236
|
-
if (value) {
|
|
4237
|
-
if (!selectRowMaps[rowid]) {
|
|
4238
|
-
selectRowMaps[rowid] = row
|
|
4239
|
-
}
|
|
4240
|
-
} else {
|
|
4241
|
-
if (selectRowMaps[rowid]) {
|
|
4242
|
-
delete selectRowMaps[rowid]
|
|
4243
|
-
}
|
|
4244
|
-
}
|
|
4245
|
-
this.handleCheckboxReserveRow(row, value)
|
|
4246
4119
|
}
|
|
4120
|
+
$xeTable.handleCheckboxReserveRow(row, checked)
|
|
4247
4121
|
}
|
|
4248
|
-
}
|
|
4249
|
-
|
|
4122
|
+
})
|
|
4123
|
+
reactData.selectCheckboxMaps = selectRowMaps
|
|
4124
|
+
},
|
|
4125
|
+
/**
|
|
4126
|
+
* 即将移除
|
|
4127
|
+
* @deprecated
|
|
4128
|
+
*/
|
|
4129
|
+
handleSelectRow ({ row }: any, checked: boolean, isForce?: boolean) {
|
|
4130
|
+
const $xeTable = this
|
|
4131
|
+
|
|
4132
|
+
$xeTable.handleBatchSelectRows([row], checked, isForce)
|
|
4250
4133
|
},
|
|
4251
4134
|
handleToggleCheckRowEvent (evnt: any, params: any) {
|
|
4252
4135
|
const { selectCheckboxMaps, checkboxOpts } = this
|
|
@@ -4255,20 +4138,20 @@ const Methods = {
|
|
|
4255
4138
|
if (trigger === 'manual') {
|
|
4256
4139
|
return
|
|
4257
4140
|
}
|
|
4258
|
-
let
|
|
4141
|
+
let checked = false
|
|
4259
4142
|
if (checkField) {
|
|
4260
|
-
|
|
4143
|
+
checked = !XEUtils.get(row, checkField)
|
|
4261
4144
|
} else {
|
|
4262
|
-
|
|
4145
|
+
checked = !selectCheckboxMaps[getRowid(this, row)]
|
|
4263
4146
|
}
|
|
4264
4147
|
if (evnt) {
|
|
4265
|
-
this.triggerCheckRowEvent(evnt, params,
|
|
4148
|
+
this.triggerCheckRowEvent(evnt, params, checked)
|
|
4266
4149
|
} else {
|
|
4267
|
-
this.handleSelectRow(params,
|
|
4150
|
+
this.handleSelectRow(params, checked)
|
|
4268
4151
|
this.checkSelectionStatus()
|
|
4269
4152
|
}
|
|
4270
4153
|
},
|
|
4271
|
-
triggerCheckRowEvent (evnt: any, params: any,
|
|
4154
|
+
triggerCheckRowEvent (evnt: any, params: any, checked: any) {
|
|
4272
4155
|
const { checkboxOpts, afterFullData } = this
|
|
4273
4156
|
const { checkMethod, trigger } = checkboxOpts
|
|
4274
4157
|
const { row } = params
|
|
@@ -4292,13 +4175,13 @@ const Methods = {
|
|
|
4292
4175
|
}
|
|
4293
4176
|
}
|
|
4294
4177
|
if (!checkMethod || checkMethod({ row })) {
|
|
4295
|
-
this.handleSelectRow(params,
|
|
4178
|
+
this.handleSelectRow(params, checked)
|
|
4296
4179
|
this.checkSelectionStatus()
|
|
4297
4180
|
this.emitEvent('checkbox-change', Object.assign({
|
|
4298
4181
|
records: this.getCheckboxRecords(),
|
|
4299
4182
|
reserves: this.getCheckboxReserveRecords(),
|
|
4300
4183
|
indeterminates: this.getCheckboxIndeterminateRecords(),
|
|
4301
|
-
checked
|
|
4184
|
+
checked
|
|
4302
4185
|
}, params), evnt)
|
|
4303
4186
|
}
|
|
4304
4187
|
},
|
|
@@ -4306,14 +4189,19 @@ const Methods = {
|
|
|
4306
4189
|
* 多选,切换某一行的选中状态
|
|
4307
4190
|
*/
|
|
4308
4191
|
toggleCheckboxRow (row: any) {
|
|
4192
|
+
const $xeTable = this
|
|
4193
|
+
|
|
4309
4194
|
const { selectCheckboxMaps, checkboxOpts } = this
|
|
4310
4195
|
const { checkField } = checkboxOpts
|
|
4311
|
-
const
|
|
4312
|
-
|
|
4313
|
-
|
|
4314
|
-
return
|
|
4196
|
+
const checked = checkField ? !XEUtils.get(row, checkField) : !selectCheckboxMaps[getRowid($xeTable, row)]
|
|
4197
|
+
$xeTable.handleBatchSelectRows([row], checked, true)
|
|
4198
|
+
$xeTable.checkSelectionStatus()
|
|
4199
|
+
return $xeTable.$nextTick()
|
|
4315
4200
|
},
|
|
4316
|
-
handleCheckedAllCheckboxRow (
|
|
4201
|
+
handleCheckedAllCheckboxRow (checked: any, isForce: any) {
|
|
4202
|
+
const $xeTable = this
|
|
4203
|
+
const reactData = $xeTable
|
|
4204
|
+
|
|
4317
4205
|
const { afterFullData, treeConfig, treeOpts, selectCheckboxMaps, checkboxReserveRowMap, checkboxOpts, afterFullRowMaps } = this
|
|
4318
4206
|
const { checkField, reserve, checkStrictly, checkMethod } = checkboxOpts
|
|
4319
4207
|
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField
|
|
@@ -4331,7 +4219,7 @@ const Methods = {
|
|
|
4331
4219
|
// 疑惑!
|
|
4332
4220
|
|
|
4333
4221
|
if (checkStrictly) {
|
|
4334
|
-
this.isAllSelected =
|
|
4222
|
+
this.isAllSelected = checked
|
|
4335
4223
|
} else {
|
|
4336
4224
|
/**
|
|
4337
4225
|
* 绑定属性方式(高性能,有污染)
|
|
@@ -4340,10 +4228,10 @@ const Methods = {
|
|
|
4340
4228
|
if (checkField) {
|
|
4341
4229
|
const checkValFn = (row: any) => {
|
|
4342
4230
|
if (isForce || (!checkMethod || checkMethod({ row }))) {
|
|
4343
|
-
if (
|
|
4231
|
+
if (checked) {
|
|
4344
4232
|
selectRowMaps[getRowid(this, row)] = row
|
|
4345
4233
|
}
|
|
4346
|
-
XEUtils.set(row, checkField,
|
|
4234
|
+
XEUtils.set(row, checkField, checked)
|
|
4347
4235
|
}
|
|
4348
4236
|
if (treeConfig && indeterminateField) {
|
|
4349
4237
|
XEUtils.set(row, indeterminateField, false)
|
|
@@ -4362,7 +4250,7 @@ const Methods = {
|
|
|
4362
4250
|
* 无需任何属性,直接绑定
|
|
4363
4251
|
*/
|
|
4364
4252
|
if (treeConfig) {
|
|
4365
|
-
if (
|
|
4253
|
+
if (checked) {
|
|
4366
4254
|
/**
|
|
4367
4255
|
* 如果是树勾选
|
|
4368
4256
|
* 如果方法成立,则添加到临时集合中
|
|
@@ -4387,7 +4275,7 @@ const Methods = {
|
|
|
4387
4275
|
}
|
|
4388
4276
|
}
|
|
4389
4277
|
} else {
|
|
4390
|
-
if (
|
|
4278
|
+
if (checked) {
|
|
4391
4279
|
/**
|
|
4392
4280
|
* 如果是行勾选
|
|
4393
4281
|
* 如果存在选中方法且成立或者本身已勾选,则添加到临时集合中
|
|
@@ -4423,7 +4311,7 @@ const Methods = {
|
|
|
4423
4311
|
}
|
|
4424
4312
|
}
|
|
4425
4313
|
if (reserve) {
|
|
4426
|
-
if (
|
|
4314
|
+
if (checked) {
|
|
4427
4315
|
XEUtils.each(selectRowMaps, (row, rowid) => {
|
|
4428
4316
|
checkboxReserveRowMap[rowid] = row
|
|
4429
4317
|
})
|
|
@@ -4433,6 +4321,9 @@ const Methods = {
|
|
|
4433
4321
|
}
|
|
4434
4322
|
this.selectCheckboxMaps = checkField ? {} : selectRowMaps
|
|
4435
4323
|
}
|
|
4324
|
+
|
|
4325
|
+
reactData.isAllSelected = checked
|
|
4326
|
+
reactData.isIndeterminate = false
|
|
4436
4327
|
this.treeIndeterminateMaps = {}
|
|
4437
4328
|
this.treeIndeterminateRowMaps = {}
|
|
4438
4329
|
this.checkSelectionStatus()
|
|
@@ -4445,75 +4336,164 @@ const Methods = {
|
|
|
4445
4336
|
setAllCheckboxRow (value: any) {
|
|
4446
4337
|
return this.handleCheckedAllCheckboxRow(value, true)
|
|
4447
4338
|
},
|
|
4448
|
-
|
|
4449
|
-
const
|
|
4339
|
+
updateCheckboxStatus () {
|
|
4340
|
+
const $xeTable = this
|
|
4341
|
+
const props = $xeTable
|
|
4342
|
+
const reactData = $xeTable
|
|
4343
|
+
const internalData = $xeTable
|
|
4344
|
+
|
|
4345
|
+
const { treeConfig } = props
|
|
4346
|
+
const { selectCheckboxMaps, treeIndeterminateMaps } = reactData
|
|
4347
|
+
const selectRowMaps = Object.assign({}, selectCheckboxMaps)
|
|
4348
|
+
const halfRowMaps = Object.assign({}, treeIndeterminateMaps)
|
|
4349
|
+
const treeOpts = $xeTable.computeTreeOpts
|
|
4350
|
+
const { transform, mapChildrenField } = treeOpts
|
|
4351
|
+
const childrenField = treeOpts.children || treeOpts.childrenField
|
|
4352
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
4450
4353
|
const { checkField, checkStrictly, checkMethod } = checkboxOpts
|
|
4451
|
-
const
|
|
4452
|
-
if (
|
|
4453
|
-
|
|
4454
|
-
|
|
4455
|
-
|
|
4456
|
-
|
|
4457
|
-
|
|
4458
|
-
|
|
4459
|
-
|
|
4354
|
+
const { afterTreeFullData } = internalData
|
|
4355
|
+
if (checkStrictly) {
|
|
4356
|
+
return
|
|
4357
|
+
}
|
|
4358
|
+
// 树结构
|
|
4359
|
+
if (treeConfig) {
|
|
4360
|
+
const childRowMaps: Record<string, number> = {}
|
|
4361
|
+
const childRowList: any[][] = []
|
|
4362
|
+
XEUtils.eachTree(afterTreeFullData, (row: any) => {
|
|
4363
|
+
const rowid = getRowid($xeTable, row)
|
|
4364
|
+
const childList = row[transform ? mapChildrenField : childrenField]
|
|
4365
|
+
if (childList && childList.length && !childRowMaps[rowid]) {
|
|
4366
|
+
childRowMaps[rowid] = 1
|
|
4367
|
+
childRowList.unshift([row, rowid, childList])
|
|
4368
|
+
}
|
|
4369
|
+
}, { children: transform ? mapChildrenField : childrenField })
|
|
4370
|
+
childRowList.forEach(vals => {
|
|
4371
|
+
const row: string = vals[0]
|
|
4372
|
+
const rowid: string = vals[1]
|
|
4373
|
+
const childList: any[] = vals[2]
|
|
4374
|
+
let sLen = 0 // 已选
|
|
4375
|
+
let hLen = 0 // 半选
|
|
4376
|
+
let vLen = 0 // 有效行
|
|
4377
|
+
childList.forEach(
|
|
4460
4378
|
checkMethod
|
|
4461
|
-
? (
|
|
4462
|
-
|
|
4463
|
-
|
|
4464
|
-
|
|
4465
|
-
|
|
4466
|
-
|
|
4467
|
-
|
|
4468
|
-
|
|
4379
|
+
? (item) => {
|
|
4380
|
+
const childRowid = getRowid($xeTable, item)
|
|
4381
|
+
const isSelect = checkField ? XEUtils.get(item, checkField) : selectRowMaps[childRowid]
|
|
4382
|
+
if (checkMethod({ row: item })) {
|
|
4383
|
+
if (isSelect) {
|
|
4384
|
+
sLen++
|
|
4385
|
+
} else if (halfRowMaps[childRowid]) {
|
|
4386
|
+
hLen++
|
|
4387
|
+
}
|
|
4388
|
+
vLen++
|
|
4389
|
+
} else {
|
|
4390
|
+
if (isSelect) {
|
|
4391
|
+
sLen++
|
|
4392
|
+
} else if (halfRowMaps[childRowid]) {
|
|
4393
|
+
hLen++
|
|
4394
|
+
}
|
|
4469
4395
|
}
|
|
4470
|
-
return false
|
|
4471
4396
|
}
|
|
4472
|
-
:
|
|
4397
|
+
: item => {
|
|
4398
|
+
const childRowid = getRowid($xeTable, item)
|
|
4399
|
+
const isSelect = checkField ? XEUtils.get(item, checkField) : selectRowMaps[childRowid]
|
|
4400
|
+
if (isSelect) {
|
|
4401
|
+
sLen++
|
|
4402
|
+
} else if (halfRowMaps[childRowid]) {
|
|
4403
|
+
hLen++
|
|
4404
|
+
}
|
|
4405
|
+
vLen++
|
|
4406
|
+
}
|
|
4473
4407
|
)
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4408
|
+
const isSelected = sLen >= vLen
|
|
4409
|
+
const halfSelect = !isSelected && (sLen >= 1 || hLen >= 1)
|
|
4410
|
+
if (checkField) {
|
|
4411
|
+
XEUtils.get(row, checkField, isSelected)
|
|
4412
|
+
}
|
|
4413
|
+
if (isSelected) {
|
|
4414
|
+
if (!checkField) {
|
|
4415
|
+
selectRowMaps[rowid] = row
|
|
4416
|
+
}
|
|
4417
|
+
if (halfRowMaps[rowid]) {
|
|
4418
|
+
delete halfRowMaps[rowid]
|
|
4480
4419
|
}
|
|
4481
4420
|
} else {
|
|
4482
|
-
if (
|
|
4483
|
-
|
|
4421
|
+
if (!checkField) {
|
|
4422
|
+
if (selectRowMaps[rowid]) {
|
|
4423
|
+
delete selectRowMaps[rowid]
|
|
4424
|
+
}
|
|
4425
|
+
}
|
|
4426
|
+
if (halfSelect) {
|
|
4427
|
+
halfRowMaps[rowid] = row
|
|
4484
4428
|
} else {
|
|
4485
|
-
|
|
4429
|
+
if (halfRowMaps[rowid]) {
|
|
4430
|
+
delete halfRowMaps[rowid]
|
|
4431
|
+
}
|
|
4486
4432
|
}
|
|
4487
4433
|
}
|
|
4488
|
-
}
|
|
4489
|
-
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4499
|
-
|
|
4500
|
-
|
|
4501
|
-
|
|
4502
|
-
|
|
4503
|
-
|
|
4504
|
-
|
|
4505
|
-
|
|
4506
|
-
|
|
4507
|
-
|
|
4508
|
-
|
|
4509
|
-
|
|
4434
|
+
})
|
|
4435
|
+
}
|
|
4436
|
+
reactData.selectCheckboxMaps = selectRowMaps
|
|
4437
|
+
reactData.treeIndeterminateMaps = halfRowMaps
|
|
4438
|
+
},
|
|
4439
|
+
updateAllCheckboxStatus () {
|
|
4440
|
+
const $xeTable = this
|
|
4441
|
+
const props = $xeTable
|
|
4442
|
+
const reactData = $xeTable
|
|
4443
|
+
const internalData = $xeTable
|
|
4444
|
+
|
|
4445
|
+
const { treeConfig } = props
|
|
4446
|
+
const { selectCheckboxMaps, treeIndeterminateMaps } = reactData
|
|
4447
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts
|
|
4448
|
+
const { checkField, checkMethod } = checkboxOpts
|
|
4449
|
+
const { afterFullData, afterTreeFullData } = internalData
|
|
4450
|
+
|
|
4451
|
+
let sLen = 0 // 已选
|
|
4452
|
+
let hLen = 0 // 半选
|
|
4453
|
+
let vLen = 0 // 有效行
|
|
4454
|
+
|
|
4455
|
+
const rootList: any[] = (treeConfig ? afterTreeFullData : afterFullData)
|
|
4456
|
+
rootList.forEach(checkMethod
|
|
4457
|
+
? row => {
|
|
4458
|
+
const childRowid = getRowid($xeTable, row)
|
|
4459
|
+
const selected = checkField ? XEUtils.get(row, checkField) : selectCheckboxMaps[childRowid]
|
|
4460
|
+
if (checkMethod({ row })) {
|
|
4461
|
+
if (selected) {
|
|
4462
|
+
sLen++
|
|
4463
|
+
} else if (treeIndeterminateMaps[childRowid]) {
|
|
4464
|
+
hLen++
|
|
4465
|
+
}
|
|
4466
|
+
vLen++
|
|
4510
4467
|
} else {
|
|
4511
|
-
|
|
4468
|
+
if (selected) {
|
|
4469
|
+
sLen++
|
|
4470
|
+
} else if (treeIndeterminateMaps[childRowid]) {
|
|
4471
|
+
hLen++
|
|
4472
|
+
}
|
|
4512
4473
|
}
|
|
4513
4474
|
}
|
|
4514
|
-
|
|
4515
|
-
|
|
4516
|
-
|
|
4475
|
+
: row => {
|
|
4476
|
+
const childRowid = getRowid($xeTable, row)
|
|
4477
|
+
const selected = checkField ? XEUtils.get(row, checkField) : selectCheckboxMaps[childRowid]
|
|
4478
|
+
if (selected) {
|
|
4479
|
+
sLen++
|
|
4480
|
+
} else if (treeIndeterminateMaps[childRowid]) {
|
|
4481
|
+
hLen++
|
|
4482
|
+
}
|
|
4483
|
+
vLen++
|
|
4484
|
+
})
|
|
4485
|
+
|
|
4486
|
+
const isSelected = sLen >= vLen
|
|
4487
|
+
const halfSelect = !isSelected && (sLen >= 1 || hLen >= 1)
|
|
4488
|
+
|
|
4489
|
+
reactData.isAllSelected = isSelected
|
|
4490
|
+
reactData.isIndeterminate = halfSelect
|
|
4491
|
+
},
|
|
4492
|
+
checkSelectionStatus () {
|
|
4493
|
+
const $xeTable = this
|
|
4494
|
+
|
|
4495
|
+
$xeTable.updateCheckboxStatus()
|
|
4496
|
+
$xeTable.updateAllCheckboxStatus()
|
|
4517
4497
|
},
|
|
4518
4498
|
// 还原展开、选中等相关状态
|
|
4519
4499
|
handleReserveStatus () {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|