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