vxe-table 3.11.29 → 3.11.30-beta.1
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/custom/mixin.js +31 -19
- package/es/table/module/keyboard/mixin.js +2 -1
- package/es/table/src/methods.js +237 -272
- package/es/table/src/table.js +23 -9
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/index.umd.js +329 -345
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/module/custom/mixin.js +36 -23
- package/lib/table/module/custom/mixin.min.js +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 +264 -306
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/table.js +25 -9
- package/lib/table/src/table.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/custom/mixin.ts +35 -19
- package/packages/table/module/keyboard/mixin.ts +3 -1
- package/packages/table/src/methods.ts +247 -262
- package/packages/table/src/table.ts +26 -9
- /package/es/{iconfont.1734067799153.ttf → iconfont.1734093222885.ttf} +0 -0
- /package/es/{iconfont.1734067799153.woff → iconfont.1734093222885.woff} +0 -0
- /package/es/{iconfont.1734067799153.woff2 → iconfont.1734093222885.woff2} +0 -0
- /package/lib/{iconfont.1734067799153.ttf → iconfont.1734093222885.ttf} +0 -0
- /package/lib/{iconfont.1734067799153.woff → iconfont.1734093222885.woff} +0 -0
- /package/lib/{iconfont.1734067799153.woff2 → iconfont.1734093222885.woff2} +0 -0
package/lib/table/src/methods.js
CHANGED
|
@@ -1030,6 +1030,7 @@ const Methods = {
|
|
|
1030
1030
|
});
|
|
1031
1031
|
},
|
|
1032
1032
|
handleColumn(collectColumn) {
|
|
1033
|
+
const $xeTable = this;
|
|
1033
1034
|
this.collectColumn = collectColumn;
|
|
1034
1035
|
const tableFullColumn = getColumnList(collectColumn);
|
|
1035
1036
|
this.tableFullColumn = tableFullColumn;
|
|
@@ -1059,6 +1060,9 @@ const Methods = {
|
|
|
1059
1060
|
$table: this
|
|
1060
1061
|
});
|
|
1061
1062
|
}
|
|
1063
|
+
if ($xeTable.handleUpdateCustomColumn) {
|
|
1064
|
+
$xeTable.handleUpdateCustomColumn();
|
|
1065
|
+
}
|
|
1062
1066
|
return this.recalculate();
|
|
1063
1067
|
});
|
|
1064
1068
|
});
|
|
@@ -4654,11 +4658,12 @@ const Methods = {
|
|
|
4654
4658
|
}
|
|
4655
4659
|
},
|
|
4656
4660
|
handleCheckedCheckboxRow(rows, value, isForce) {
|
|
4661
|
+
const $xeTable = this;
|
|
4657
4662
|
if (rows && !_xeUtils.default.isArray(rows)) {
|
|
4658
4663
|
rows = [rows];
|
|
4659
4664
|
}
|
|
4660
|
-
|
|
4661
|
-
|
|
4665
|
+
$xeTable.handleBatchSelectRows(rows, !!value, isForce);
|
|
4666
|
+
$xeTable.checkSelectionStatus();
|
|
4662
4667
|
return this.$nextTick();
|
|
4663
4668
|
},
|
|
4664
4669
|
/**
|
|
@@ -4691,269 +4696,118 @@ const Methods = {
|
|
|
4691
4696
|
return !!treeIndeterminateMaps[(0, _util.getRowid)(this, row)] && !this.isCheckedByCheckboxRow(row);
|
|
4692
4697
|
},
|
|
4693
4698
|
/**
|
|
4694
|
-
*
|
|
4699
|
+
* 切换选中
|
|
4695
4700
|
* 多选,行选中事件
|
|
4696
|
-
* value 选中true 不选false 半选-1
|
|
4697
4701
|
*/
|
|
4698
|
-
handleBatchSelectRows(rows,
|
|
4702
|
+
handleBatchSelectRows(rows, checked, isForce) {
|
|
4699
4703
|
const $xeTable = this;
|
|
4704
|
+
const props = $xeTable;
|
|
4705
|
+
const reactData = $xeTable;
|
|
4700
4706
|
const {
|
|
4701
4707
|
treeConfig
|
|
4702
|
-
} =
|
|
4708
|
+
} = props;
|
|
4703
4709
|
const {
|
|
4704
|
-
selectCheckboxMaps
|
|
4705
|
-
|
|
4706
|
-
|
|
4710
|
+
selectCheckboxMaps
|
|
4711
|
+
} = reactData;
|
|
4712
|
+
const selectRowMaps = Object.assign({}, selectCheckboxMaps);
|
|
4713
|
+
const treeOpts = $xeTable.computeTreeOpts;
|
|
4714
|
+
const {
|
|
4715
|
+
transform,
|
|
4716
|
+
mapChildrenField
|
|
4717
|
+
} = treeOpts;
|
|
4718
|
+
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
4719
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts;
|
|
4707
4720
|
const {
|
|
4708
4721
|
checkField,
|
|
4709
4722
|
checkStrictly,
|
|
4710
4723
|
checkMethod
|
|
4711
4724
|
} = checkboxOpts;
|
|
4725
|
+
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
|
|
4712
4726
|
if (checkField) {
|
|
4727
|
+
// 树结构
|
|
4713
4728
|
if (treeConfig && !checkStrictly) {
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
row
|
|
4717
|
-
}, value, isForce);
|
|
4718
|
-
});
|
|
4719
|
-
} else {
|
|
4720
|
-
rows.forEach(row => {
|
|
4729
|
+
// 更新子节点状态
|
|
4730
|
+
_xeUtils.default.eachTree(rows, row => {
|
|
4721
4731
|
if (isForce || !checkMethod || checkMethod({
|
|
4722
4732
|
row
|
|
4723
4733
|
})) {
|
|
4724
|
-
_xeUtils.default.set(row, checkField,
|
|
4725
|
-
|
|
4734
|
+
_xeUtils.default.set(row, checkField, checked);
|
|
4735
|
+
if (indeterminateField) {
|
|
4736
|
+
_xeUtils.default.set(row, indeterminateField, false);
|
|
4737
|
+
}
|
|
4738
|
+
$xeTable.handleCheckboxReserveRow(row, checked);
|
|
4726
4739
|
}
|
|
4740
|
+
}, {
|
|
4741
|
+
children: transform ? mapChildrenField : childrenField
|
|
4727
4742
|
});
|
|
4728
|
-
|
|
4729
|
-
|
|
4730
|
-
if (treeConfig && !checkStrictly) {
|
|
4731
|
-
rows.forEach(row => {
|
|
4732
|
-
this.handleSelectRow({
|
|
4733
|
-
row
|
|
4734
|
-
}, value, isForce);
|
|
4735
|
-
});
|
|
4743
|
+
reactData.selectCheckboxMaps = selectRowMaps;
|
|
4744
|
+
return;
|
|
4736
4745
|
} else {
|
|
4737
|
-
|
|
4746
|
+
// 列表
|
|
4738
4747
|
rows.forEach(row => {
|
|
4739
|
-
const rowid = (0, _util.getRowid)($xeTable, row);
|
|
4740
4748
|
if (isForce || !checkMethod || checkMethod({
|
|
4741
4749
|
row
|
|
4742
4750
|
})) {
|
|
4743
|
-
|
|
4744
|
-
|
|
4745
|
-
selectRowMaps[rowid] = row;
|
|
4746
|
-
}
|
|
4747
|
-
} else {
|
|
4748
|
-
if (selectRowMaps[rowid]) {
|
|
4749
|
-
delete selectRowMaps[rowid];
|
|
4750
|
-
}
|
|
4751
|
-
}
|
|
4752
|
-
this.handleCheckboxReserveRow(row, value);
|
|
4751
|
+
_xeUtils.default.set(row, checkField, checked);
|
|
4752
|
+
$xeTable.handleCheckboxReserveRow(row, checked);
|
|
4753
4753
|
}
|
|
4754
4754
|
});
|
|
4755
|
-
this.selectCheckboxMaps = selectRowMaps;
|
|
4756
4755
|
}
|
|
4756
|
+
reactData.selectCheckboxMaps = selectRowMaps;
|
|
4757
|
+
return;
|
|
4757
4758
|
}
|
|
4758
|
-
|
|
4759
|
-
|
|
4760
|
-
|
|
4761
|
-
|
|
4762
|
-
|
|
4763
|
-
handleSelectRow({
|
|
4764
|
-
row
|
|
4765
|
-
}, value, isForce) {
|
|
4766
|
-
const {
|
|
4767
|
-
selectCheckboxMaps,
|
|
4768
|
-
afterFullData,
|
|
4769
|
-
treeConfig,
|
|
4770
|
-
treeOpts,
|
|
4771
|
-
treeIndeterminateMaps,
|
|
4772
|
-
checkboxOpts
|
|
4773
|
-
} = this;
|
|
4774
|
-
const {
|
|
4775
|
-
checkField,
|
|
4776
|
-
checkStrictly,
|
|
4777
|
-
checkMethod
|
|
4778
|
-
} = checkboxOpts;
|
|
4779
|
-
const selectRowMaps = Object.assign({}, selectCheckboxMaps);
|
|
4780
|
-
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
4781
|
-
const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
|
|
4782
|
-
const rowid = (0, _util.getRowid)(this, row);
|
|
4783
|
-
if (checkField) {
|
|
4784
|
-
if (treeConfig && !checkStrictly) {
|
|
4785
|
-
if (value === -1) {
|
|
4786
|
-
if (!treeIndeterminateMaps[rowid]) {
|
|
4787
|
-
if (indeterminateField) {
|
|
4788
|
-
_xeUtils.default.set(row, indeterminateField, true);
|
|
4789
|
-
}
|
|
4790
|
-
treeIndeterminateMaps[rowid] = row;
|
|
4791
|
-
}
|
|
4792
|
-
_xeUtils.default.set(row, checkField, false);
|
|
4793
|
-
} else {
|
|
4794
|
-
// 更新子节点状态
|
|
4795
|
-
_xeUtils.default.eachTree([row], item => {
|
|
4796
|
-
if (this.eqRow(item, row) || isForce || !checkMethod || checkMethod({
|
|
4797
|
-
row: item
|
|
4798
|
-
})) {
|
|
4799
|
-
_xeUtils.default.set(item, checkField, value);
|
|
4800
|
-
if (indeterminateField) {
|
|
4801
|
-
_xeUtils.default.set(row, indeterminateField, false);
|
|
4802
|
-
}
|
|
4803
|
-
delete treeIndeterminateMaps[(0, _util.getRowid)(this, item)];
|
|
4804
|
-
this.handleCheckboxReserveRow(row, value);
|
|
4805
|
-
}
|
|
4806
|
-
}, {
|
|
4807
|
-
children: childrenField
|
|
4808
|
-
});
|
|
4809
|
-
}
|
|
4810
|
-
// 如果存在父节点,更新父节点状态
|
|
4811
|
-
const matchObj = _xeUtils.default.findTree(afterFullData, item => this.eqRow(item, row), {
|
|
4812
|
-
children: childrenField
|
|
4813
|
-
});
|
|
4814
|
-
if (matchObj && matchObj.parent) {
|
|
4815
|
-
let parentStatus;
|
|
4816
|
-
const vItems = [];
|
|
4817
|
-
const vItemMaps = {};
|
|
4818
|
-
if (!isForce && checkMethod) {
|
|
4819
|
-
matchObj.items.forEach(item => {
|
|
4820
|
-
if (checkMethod({
|
|
4821
|
-
row: item
|
|
4822
|
-
})) {
|
|
4823
|
-
const itemRid = (0, _util.getRowid)(this, item);
|
|
4824
|
-
vItemMaps[itemRid] = item;
|
|
4825
|
-
vItems.push(item);
|
|
4826
|
-
}
|
|
4827
|
-
});
|
|
4828
|
-
} else {
|
|
4829
|
-
matchObj.items.forEach(item => {
|
|
4830
|
-
const itemRid = (0, _util.getRowid)(this, item);
|
|
4831
|
-
vItemMaps[itemRid] = item;
|
|
4832
|
-
vItems.push(item);
|
|
4833
|
-
});
|
|
4834
|
-
}
|
|
4835
|
-
const indeterminatesItem = _xeUtils.default.find(matchObj.items, item => !!treeIndeterminateMaps[(0, _util.getRowid)(this, item)]);
|
|
4836
|
-
if (indeterminatesItem) {
|
|
4837
|
-
parentStatus = -1;
|
|
4838
|
-
} else {
|
|
4839
|
-
const selectItems = [];
|
|
4840
|
-
matchObj.items.forEach(item => {
|
|
4841
|
-
if (_xeUtils.default.get(item, checkField)) {
|
|
4842
|
-
selectItems.push(item);
|
|
4843
|
-
}
|
|
4844
|
-
});
|
|
4845
|
-
parentStatus = selectItems.filter(item => vItemMaps[(0, _util.getRowid)(this, item)]).length === vItems.length ? true : selectItems.length || value === -1 ? -1 : false;
|
|
4846
|
-
}
|
|
4847
|
-
this.selectCheckboxMaps = selectRowMaps;
|
|
4848
|
-
return this.handleSelectRow({
|
|
4849
|
-
row: matchObj.parent
|
|
4850
|
-
}, parentStatus, isForce);
|
|
4851
|
-
}
|
|
4852
|
-
} else {
|
|
4853
|
-
if (isForce || !checkMethod || checkMethod({
|
|
4854
|
-
row
|
|
4855
|
-
})) {
|
|
4856
|
-
_xeUtils.default.set(row, checkField, value);
|
|
4857
|
-
this.handleCheckboxReserveRow(row, value);
|
|
4858
|
-
}
|
|
4859
|
-
}
|
|
4860
|
-
} else {
|
|
4861
|
-
if (treeConfig && !checkStrictly) {
|
|
4862
|
-
if (value === -1) {
|
|
4863
|
-
if (!treeIndeterminateMaps[rowid]) {
|
|
4864
|
-
if (indeterminateField) {
|
|
4865
|
-
_xeUtils.default.set(row, indeterminateField, true);
|
|
4866
|
-
}
|
|
4867
|
-
treeIndeterminateMaps[rowid] = row;
|
|
4868
|
-
}
|
|
4869
|
-
if (selectRowMaps[rowid]) {
|
|
4870
|
-
delete selectRowMaps[rowid];
|
|
4871
|
-
}
|
|
4872
|
-
} else {
|
|
4873
|
-
// 更新子节点状态
|
|
4874
|
-
_xeUtils.default.eachTree([row], item => {
|
|
4875
|
-
const itemRid = (0, _util.getRowid)(this, item);
|
|
4876
|
-
if (this.eqRow(item, row) || isForce || !checkMethod || checkMethod({
|
|
4877
|
-
row: item
|
|
4878
|
-
})) {
|
|
4879
|
-
if (value) {
|
|
4880
|
-
selectRowMaps[itemRid] = item;
|
|
4881
|
-
} else {
|
|
4882
|
-
if (selectRowMaps[itemRid]) {
|
|
4883
|
-
delete selectRowMaps[itemRid];
|
|
4884
|
-
}
|
|
4885
|
-
}
|
|
4886
|
-
if (indeterminateField) {
|
|
4887
|
-
_xeUtils.default.set(row, indeterminateField, false);
|
|
4888
|
-
}
|
|
4889
|
-
delete treeIndeterminateMaps[(0, _util.getRowid)(this, item)];
|
|
4890
|
-
this.handleCheckboxReserveRow(row, value);
|
|
4891
|
-
}
|
|
4892
|
-
}, {
|
|
4893
|
-
children: childrenField
|
|
4894
|
-
});
|
|
4895
|
-
}
|
|
4896
|
-
// 如果存在父节点,更新父节点状态
|
|
4897
|
-
const matchObj = _xeUtils.default.findTree(afterFullData, item => this.eqRow(item, row), {
|
|
4898
|
-
children: childrenField
|
|
4899
|
-
});
|
|
4900
|
-
if (matchObj && matchObj.parent) {
|
|
4901
|
-
let parentStatus;
|
|
4902
|
-
const vItems = [];
|
|
4903
|
-
const vItemMaps = {};
|
|
4904
|
-
if (!isForce && checkMethod) {
|
|
4905
|
-
matchObj.items.forEach(item => {
|
|
4906
|
-
if (checkMethod({
|
|
4907
|
-
row: item
|
|
4908
|
-
})) {
|
|
4909
|
-
const itemRid = (0, _util.getRowid)(this, item);
|
|
4910
|
-
vItemMaps[itemRid] = item;
|
|
4911
|
-
vItems.push(item);
|
|
4912
|
-
}
|
|
4913
|
-
});
|
|
4914
|
-
} else {
|
|
4915
|
-
matchObj.items.forEach(item => {
|
|
4916
|
-
const itemRid = (0, _util.getRowid)(this, item);
|
|
4917
|
-
vItemMaps[itemRid] = item;
|
|
4918
|
-
vItems.push(item);
|
|
4919
|
-
});
|
|
4920
|
-
}
|
|
4921
|
-
const indeterminatesItem = _xeUtils.default.find(matchObj.items, item => !!treeIndeterminateMaps[(0, _util.getRowid)(this, item)]);
|
|
4922
|
-
if (indeterminatesItem) {
|
|
4923
|
-
parentStatus = -1;
|
|
4924
|
-
} else {
|
|
4925
|
-
const selectItems = [];
|
|
4926
|
-
matchObj.items.forEach(item => {
|
|
4927
|
-
const itemRid = (0, _util.getRowid)(this, item);
|
|
4928
|
-
if (selectRowMaps[itemRid]) {
|
|
4929
|
-
selectItems.push(item);
|
|
4930
|
-
}
|
|
4931
|
-
});
|
|
4932
|
-
parentStatus = selectItems.filter(item => vItemMaps[(0, _util.getRowid)(this, item)]).length === vItems.length ? true : selectItems.length || value === -1 ? -1 : false;
|
|
4933
|
-
}
|
|
4934
|
-
this.selectCheckboxMaps = selectRowMaps;
|
|
4935
|
-
return this.handleSelectRow({
|
|
4936
|
-
row: matchObj.parent
|
|
4937
|
-
}, parentStatus, isForce);
|
|
4938
|
-
}
|
|
4939
|
-
} else {
|
|
4759
|
+
// 树结构
|
|
4760
|
+
if (treeConfig && !checkStrictly) {
|
|
4761
|
+
// 更新子节点状态
|
|
4762
|
+
_xeUtils.default.eachTree(rows, row => {
|
|
4763
|
+
const rowid = (0, _util.getRowid)($xeTable, row);
|
|
4940
4764
|
if (isForce || !checkMethod || checkMethod({
|
|
4941
4765
|
row
|
|
4942
4766
|
})) {
|
|
4943
|
-
if (
|
|
4944
|
-
|
|
4945
|
-
selectRowMaps[rowid] = row;
|
|
4946
|
-
}
|
|
4767
|
+
if (checked) {
|
|
4768
|
+
selectRowMaps[rowid] = row;
|
|
4947
4769
|
} else {
|
|
4948
4770
|
if (selectRowMaps[rowid]) {
|
|
4949
4771
|
delete selectRowMaps[rowid];
|
|
4950
4772
|
}
|
|
4951
4773
|
}
|
|
4952
|
-
|
|
4774
|
+
$xeTable.handleCheckboxReserveRow(row, checked);
|
|
4953
4775
|
}
|
|
4954
|
-
}
|
|
4776
|
+
}, {
|
|
4777
|
+
children: transform ? mapChildrenField : childrenField
|
|
4778
|
+
});
|
|
4779
|
+
reactData.selectCheckboxMaps = selectRowMaps;
|
|
4780
|
+
return;
|
|
4955
4781
|
}
|
|
4956
|
-
|
|
4782
|
+
// 列表
|
|
4783
|
+
rows.forEach(row => {
|
|
4784
|
+
const rowid = (0, _util.getRowid)($xeTable, row);
|
|
4785
|
+
if (isForce || !checkMethod || checkMethod({
|
|
4786
|
+
row
|
|
4787
|
+
})) {
|
|
4788
|
+
if (checked) {
|
|
4789
|
+
if (!selectRowMaps[rowid]) {
|
|
4790
|
+
selectRowMaps[rowid] = row;
|
|
4791
|
+
}
|
|
4792
|
+
} else {
|
|
4793
|
+
if (selectRowMaps[rowid]) {
|
|
4794
|
+
delete selectRowMaps[rowid];
|
|
4795
|
+
}
|
|
4796
|
+
}
|
|
4797
|
+
$xeTable.handleCheckboxReserveRow(row, checked);
|
|
4798
|
+
}
|
|
4799
|
+
});
|
|
4800
|
+
reactData.selectCheckboxMaps = selectRowMaps;
|
|
4801
|
+
},
|
|
4802
|
+
/**
|
|
4803
|
+
* 即将移除
|
|
4804
|
+
* @deprecated
|
|
4805
|
+
*/
|
|
4806
|
+
handleSelectRow({
|
|
4807
|
+
row
|
|
4808
|
+
}, checked, isForce) {
|
|
4809
|
+
const $xeTable = this;
|
|
4810
|
+
$xeTable.handleBatchSelectRows([row], checked, isForce);
|
|
4957
4811
|
},
|
|
4958
4812
|
handleToggleCheckRowEvent(evnt, params) {
|
|
4959
4813
|
const {
|
|
@@ -4970,20 +4824,20 @@ const Methods = {
|
|
|
4970
4824
|
if (trigger === 'manual') {
|
|
4971
4825
|
return;
|
|
4972
4826
|
}
|
|
4973
|
-
let
|
|
4827
|
+
let checked = false;
|
|
4974
4828
|
if (checkField) {
|
|
4975
|
-
|
|
4829
|
+
checked = !_xeUtils.default.get(row, checkField);
|
|
4976
4830
|
} else {
|
|
4977
|
-
|
|
4831
|
+
checked = !selectCheckboxMaps[(0, _util.getRowid)(this, row)];
|
|
4978
4832
|
}
|
|
4979
4833
|
if (evnt) {
|
|
4980
|
-
this.triggerCheckRowEvent(evnt, params,
|
|
4834
|
+
this.triggerCheckRowEvent(evnt, params, checked);
|
|
4981
4835
|
} else {
|
|
4982
|
-
this.handleSelectRow(params,
|
|
4836
|
+
this.handleSelectRow(params, checked);
|
|
4983
4837
|
this.checkSelectionStatus();
|
|
4984
4838
|
}
|
|
4985
4839
|
},
|
|
4986
|
-
triggerCheckRowEvent(evnt, params,
|
|
4840
|
+
triggerCheckRowEvent(evnt, params, checked) {
|
|
4987
4841
|
const {
|
|
4988
4842
|
checkboxOpts,
|
|
4989
4843
|
afterFullData
|
|
@@ -5019,13 +4873,13 @@ const Methods = {
|
|
|
5019
4873
|
if (!checkMethod || checkMethod({
|
|
5020
4874
|
row
|
|
5021
4875
|
})) {
|
|
5022
|
-
this.handleSelectRow(params,
|
|
4876
|
+
this.handleSelectRow(params, checked);
|
|
5023
4877
|
this.checkSelectionStatus();
|
|
5024
4878
|
this.emitEvent('checkbox-change', Object.assign({
|
|
5025
4879
|
records: this.getCheckboxRecords(),
|
|
5026
4880
|
reserves: this.getCheckboxReserveRecords(),
|
|
5027
4881
|
indeterminates: this.getCheckboxIndeterminateRecords(),
|
|
5028
|
-
checked
|
|
4882
|
+
checked
|
|
5029
4883
|
}, params), evnt);
|
|
5030
4884
|
}
|
|
5031
4885
|
},
|
|
@@ -5033,6 +4887,7 @@ const Methods = {
|
|
|
5033
4887
|
* 多选,切换某一行的选中状态
|
|
5034
4888
|
*/
|
|
5035
4889
|
toggleCheckboxRow(row) {
|
|
4890
|
+
const $xeTable = this;
|
|
5036
4891
|
const {
|
|
5037
4892
|
selectCheckboxMaps,
|
|
5038
4893
|
checkboxOpts
|
|
@@ -5040,14 +4895,14 @@ const Methods = {
|
|
|
5040
4895
|
const {
|
|
5041
4896
|
checkField
|
|
5042
4897
|
} = checkboxOpts;
|
|
5043
|
-
const
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
this.checkSelectionStatus();
|
|
5048
|
-
return this.$nextTick();
|
|
4898
|
+
const checked = checkField ? !_xeUtils.default.get(row, checkField) : !selectCheckboxMaps[(0, _util.getRowid)($xeTable, row)];
|
|
4899
|
+
$xeTable.handleBatchSelectRows([row], checked, true);
|
|
4900
|
+
$xeTable.checkSelectionStatus();
|
|
4901
|
+
return $xeTable.$nextTick();
|
|
5049
4902
|
},
|
|
5050
|
-
handleCheckedAllCheckboxRow(
|
|
4903
|
+
handleCheckedAllCheckboxRow(checked, isForce) {
|
|
4904
|
+
const $xeTable = this;
|
|
4905
|
+
const reactData = $xeTable;
|
|
5051
4906
|
const {
|
|
5052
4907
|
afterFullData,
|
|
5053
4908
|
treeConfig,
|
|
@@ -5076,7 +4931,7 @@ const Methods = {
|
|
|
5076
4931
|
}
|
|
5077
4932
|
// 疑惑!
|
|
5078
4933
|
if (checkStrictly) {
|
|
5079
|
-
this.isAllSelected =
|
|
4934
|
+
this.isAllSelected = checked;
|
|
5080
4935
|
} else {
|
|
5081
4936
|
/**
|
|
5082
4937
|
* 绑定属性方式(高性能,有污染)
|
|
@@ -5087,10 +4942,10 @@ const Methods = {
|
|
|
5087
4942
|
if (isForce || !checkMethod || checkMethod({
|
|
5088
4943
|
row
|
|
5089
4944
|
})) {
|
|
5090
|
-
if (
|
|
4945
|
+
if (checked) {
|
|
5091
4946
|
selectRowMaps[(0, _util.getRowid)(this, row)] = row;
|
|
5092
4947
|
}
|
|
5093
|
-
_xeUtils.default.set(row, checkField,
|
|
4948
|
+
_xeUtils.default.set(row, checkField, checked);
|
|
5094
4949
|
}
|
|
5095
4950
|
if (treeConfig && indeterminateField) {
|
|
5096
4951
|
_xeUtils.default.set(row, indeterminateField, false);
|
|
@@ -5111,7 +4966,7 @@ const Methods = {
|
|
|
5111
4966
|
* 无需任何属性,直接绑定
|
|
5112
4967
|
*/
|
|
5113
4968
|
if (treeConfig) {
|
|
5114
|
-
if (
|
|
4969
|
+
if (checked) {
|
|
5115
4970
|
/**
|
|
5116
4971
|
* 如果是树勾选
|
|
5117
4972
|
* 如果方法成立,则添加到临时集合中
|
|
@@ -5144,7 +4999,7 @@ const Methods = {
|
|
|
5144
4999
|
}
|
|
5145
5000
|
}
|
|
5146
5001
|
} else {
|
|
5147
|
-
if (
|
|
5002
|
+
if (checked) {
|
|
5148
5003
|
/**
|
|
5149
5004
|
* 如果是行勾选
|
|
5150
5005
|
* 如果存在选中方法且成立或者本身已勾选,则添加到临时集合中
|
|
@@ -5184,7 +5039,7 @@ const Methods = {
|
|
|
5184
5039
|
}
|
|
5185
5040
|
}
|
|
5186
5041
|
if (reserve) {
|
|
5187
|
-
if (
|
|
5042
|
+
if (checked) {
|
|
5188
5043
|
_xeUtils.default.each(selectRowMaps, (row, rowid) => {
|
|
5189
5044
|
checkboxReserveRowMap[rowid] = row;
|
|
5190
5045
|
});
|
|
@@ -5194,6 +5049,8 @@ const Methods = {
|
|
|
5194
5049
|
}
|
|
5195
5050
|
this.selectCheckboxMaps = checkField ? {} : selectRowMaps;
|
|
5196
5051
|
}
|
|
5052
|
+
reactData.isAllSelected = checked;
|
|
5053
|
+
reactData.isIndeterminate = false;
|
|
5197
5054
|
this.treeIndeterminateMaps = {};
|
|
5198
5055
|
this.treeIndeterminateRowMaps = {};
|
|
5199
5056
|
this.checkSelectionStatus();
|
|
@@ -5206,81 +5063,182 @@ const Methods = {
|
|
|
5206
5063
|
setAllCheckboxRow(value) {
|
|
5207
5064
|
return this.handleCheckedAllCheckboxRow(value, true);
|
|
5208
5065
|
},
|
|
5209
|
-
|
|
5066
|
+
updateCheckboxStatus() {
|
|
5067
|
+
const $xeTable = this;
|
|
5068
|
+
const props = $xeTable;
|
|
5069
|
+
const reactData = $xeTable;
|
|
5070
|
+
const internalData = $xeTable;
|
|
5210
5071
|
const {
|
|
5211
|
-
afterFullData,
|
|
5212
|
-
selectCheckboxMaps,
|
|
5213
|
-
treeIndeterminateMaps,
|
|
5214
|
-
checkboxOpts,
|
|
5215
5072
|
treeConfig
|
|
5216
|
-
} =
|
|
5073
|
+
} = props;
|
|
5074
|
+
const {
|
|
5075
|
+
selectCheckboxMaps,
|
|
5076
|
+
treeIndeterminateMaps
|
|
5077
|
+
} = reactData;
|
|
5078
|
+
const selectRowMaps = Object.assign({}, selectCheckboxMaps);
|
|
5079
|
+
const halfRowMaps = Object.assign({}, treeIndeterminateMaps);
|
|
5080
|
+
const treeOpts = $xeTable.computeTreeOpts;
|
|
5081
|
+
const {
|
|
5082
|
+
transform,
|
|
5083
|
+
mapChildrenField
|
|
5084
|
+
} = treeOpts;
|
|
5085
|
+
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
5086
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts;
|
|
5217
5087
|
const {
|
|
5218
5088
|
checkField,
|
|
5219
5089
|
checkStrictly,
|
|
5220
5090
|
checkMethod
|
|
5221
5091
|
} = checkboxOpts;
|
|
5222
|
-
const
|
|
5223
|
-
|
|
5224
|
-
|
|
5225
|
-
|
|
5226
|
-
|
|
5227
|
-
|
|
5228
|
-
|
|
5229
|
-
|
|
5230
|
-
|
|
5231
|
-
|
|
5232
|
-
|
|
5092
|
+
const {
|
|
5093
|
+
afterTreeFullData
|
|
5094
|
+
} = internalData;
|
|
5095
|
+
if (checkStrictly) {
|
|
5096
|
+
return;
|
|
5097
|
+
}
|
|
5098
|
+
// 树结构
|
|
5099
|
+
if (treeConfig) {
|
|
5100
|
+
const childRowMaps = {};
|
|
5101
|
+
const childRowList = [];
|
|
5102
|
+
_xeUtils.default.eachTree(afterTreeFullData, row => {
|
|
5103
|
+
const rowid = (0, _util.getRowid)($xeTable, row);
|
|
5104
|
+
const childList = row[transform ? mapChildrenField : childrenField];
|
|
5105
|
+
if (childList && childList.length && !childRowMaps[rowid]) {
|
|
5106
|
+
childRowMaps[rowid] = 1;
|
|
5107
|
+
childRowList.unshift([row, rowid, childList]);
|
|
5108
|
+
}
|
|
5109
|
+
}, {
|
|
5110
|
+
children: transform ? mapChildrenField : childrenField
|
|
5111
|
+
});
|
|
5112
|
+
childRowList.forEach(vals => {
|
|
5113
|
+
const row = vals[0];
|
|
5114
|
+
const rowid = vals[1];
|
|
5115
|
+
const childList = vals[2];
|
|
5116
|
+
let sLen = 0; // 已选
|
|
5117
|
+
let hLen = 0; // 半选
|
|
5118
|
+
let vLen = 0; // 有效行
|
|
5119
|
+
childList.forEach(checkMethod ? item => {
|
|
5120
|
+
const childRowid = (0, _util.getRowid)($xeTable, item);
|
|
5121
|
+
const isSelect = checkField ? _xeUtils.default.get(item, checkField) : selectRowMaps[childRowid];
|
|
5122
|
+
if (checkMethod({
|
|
5123
|
+
row: item
|
|
5233
5124
|
})) {
|
|
5234
|
-
|
|
5235
|
-
|
|
5125
|
+
if (isSelect) {
|
|
5126
|
+
sLen++;
|
|
5127
|
+
} else if (halfRowMaps[childRowid]) {
|
|
5128
|
+
hLen++;
|
|
5129
|
+
}
|
|
5130
|
+
vLen++;
|
|
5131
|
+
} else {
|
|
5132
|
+
if (isSelect) {
|
|
5133
|
+
sLen++;
|
|
5134
|
+
} else if (halfRowMaps[childRowid]) {
|
|
5135
|
+
hLen++;
|
|
5136
|
+
}
|
|
5236
5137
|
}
|
|
5237
|
-
|
|
5238
|
-
|
|
5239
|
-
|
|
5138
|
+
} : item => {
|
|
5139
|
+
const childRowid = (0, _util.getRowid)($xeTable, item);
|
|
5140
|
+
const isSelect = checkField ? _xeUtils.default.get(item, checkField) : selectRowMaps[childRowid];
|
|
5141
|
+
if (isSelect) {
|
|
5142
|
+
sLen++;
|
|
5143
|
+
} else if (halfRowMaps[childRowid]) {
|
|
5144
|
+
hLen++;
|
|
5240
5145
|
}
|
|
5241
|
-
|
|
5242
|
-
}
|
|
5243
|
-
|
|
5244
|
-
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5146
|
+
vLen++;
|
|
5147
|
+
});
|
|
5148
|
+
const isSelected = sLen >= vLen;
|
|
5149
|
+
const halfSelect = !isSelected && (sLen >= 1 || hLen >= 1);
|
|
5150
|
+
if (checkField) {
|
|
5151
|
+
_xeUtils.default.get(row, checkField, isSelected);
|
|
5152
|
+
}
|
|
5153
|
+
if (isSelected) {
|
|
5154
|
+
if (!checkField) {
|
|
5155
|
+
selectRowMaps[rowid] = row;
|
|
5156
|
+
}
|
|
5157
|
+
if (halfRowMaps[rowid]) {
|
|
5158
|
+
delete halfRowMaps[rowid];
|
|
5249
5159
|
}
|
|
5250
5160
|
} else {
|
|
5251
|
-
if (
|
|
5252
|
-
|
|
5161
|
+
if (!checkField) {
|
|
5162
|
+
if (selectRowMaps[rowid]) {
|
|
5163
|
+
delete selectRowMaps[rowid];
|
|
5164
|
+
}
|
|
5165
|
+
}
|
|
5166
|
+
if (halfSelect) {
|
|
5167
|
+
halfRowMaps[rowid] = row;
|
|
5253
5168
|
} else {
|
|
5254
|
-
|
|
5169
|
+
if (halfRowMaps[rowid]) {
|
|
5170
|
+
delete halfRowMaps[rowid];
|
|
5171
|
+
}
|
|
5255
5172
|
}
|
|
5256
5173
|
}
|
|
5174
|
+
});
|
|
5175
|
+
}
|
|
5176
|
+
reactData.selectCheckboxMaps = selectRowMaps;
|
|
5177
|
+
reactData.treeIndeterminateMaps = halfRowMaps;
|
|
5178
|
+
},
|
|
5179
|
+
updateAllCheckboxStatus() {
|
|
5180
|
+
const $xeTable = this;
|
|
5181
|
+
const props = $xeTable;
|
|
5182
|
+
const reactData = $xeTable;
|
|
5183
|
+
const internalData = $xeTable;
|
|
5184
|
+
const {
|
|
5185
|
+
treeConfig
|
|
5186
|
+
} = props;
|
|
5187
|
+
const {
|
|
5188
|
+
selectCheckboxMaps,
|
|
5189
|
+
treeIndeterminateMaps
|
|
5190
|
+
} = reactData;
|
|
5191
|
+
const checkboxOpts = $xeTable.computeCheckboxOpts;
|
|
5192
|
+
const {
|
|
5193
|
+
checkField,
|
|
5194
|
+
checkMethod
|
|
5195
|
+
} = checkboxOpts;
|
|
5196
|
+
const {
|
|
5197
|
+
afterFullData,
|
|
5198
|
+
afterTreeFullData
|
|
5199
|
+
} = internalData;
|
|
5200
|
+
let sLen = 0; // 已选
|
|
5201
|
+
let hLen = 0; // 半选
|
|
5202
|
+
let vLen = 0; // 有效行
|
|
5203
|
+
const rootList = treeConfig ? afterTreeFullData : afterFullData;
|
|
5204
|
+
rootList.forEach(checkMethod ? row => {
|
|
5205
|
+
const childRowid = (0, _util.getRowid)($xeTable, row);
|
|
5206
|
+
const selected = checkField ? _xeUtils.default.get(row, checkField) : selectCheckboxMaps[childRowid];
|
|
5207
|
+
if (checkMethod({
|
|
5208
|
+
row
|
|
5209
|
+
})) {
|
|
5210
|
+
if (selected) {
|
|
5211
|
+
sLen++;
|
|
5212
|
+
} else if (treeIndeterminateMaps[childRowid]) {
|
|
5213
|
+
hLen++;
|
|
5214
|
+
}
|
|
5215
|
+
vLen++;
|
|
5257
5216
|
} else {
|
|
5258
|
-
|
|
5259
|
-
|
|
5260
|
-
|
|
5261
|
-
|
|
5262
|
-
disableRows.push(row);
|
|
5263
|
-
return true;
|
|
5264
|
-
}
|
|
5265
|
-
if (selectCheckboxMaps[(0, _util.getRowid)(this, row)]) {
|
|
5266
|
-
checkRows.push(row);
|
|
5267
|
-
return true;
|
|
5268
|
-
}
|
|
5269
|
-
return false;
|
|
5270
|
-
} : row => selectCheckboxMaps[(0, _util.getRowid)(this, row)]);
|
|
5271
|
-
isAllSelected = isAllResolve && afterFullData.length !== disableRows.length;
|
|
5272
|
-
if (treeConfig) {
|
|
5273
|
-
isIndeterminate = !isAllSelected && afterFullData.some(row => {
|
|
5274
|
-
const itemRid = (0, _util.getRowid)(this, row);
|
|
5275
|
-
return treeIndeterminateMaps[itemRid] || selectCheckboxMaps[itemRid];
|
|
5276
|
-
});
|
|
5277
|
-
} else {
|
|
5278
|
-
isIndeterminate = !isAllSelected && afterFullData.some(row => selectCheckboxMaps[(0, _util.getRowid)(this, row)]);
|
|
5217
|
+
if (selected) {
|
|
5218
|
+
sLen++;
|
|
5219
|
+
} else if (treeIndeterminateMaps[childRowid]) {
|
|
5220
|
+
hLen++;
|
|
5279
5221
|
}
|
|
5280
5222
|
}
|
|
5281
|
-
|
|
5282
|
-
|
|
5283
|
-
|
|
5223
|
+
} : row => {
|
|
5224
|
+
const childRowid = (0, _util.getRowid)($xeTable, row);
|
|
5225
|
+
const selected = checkField ? _xeUtils.default.get(row, checkField) : selectCheckboxMaps[childRowid];
|
|
5226
|
+
if (selected) {
|
|
5227
|
+
sLen++;
|
|
5228
|
+
} else if (treeIndeterminateMaps[childRowid]) {
|
|
5229
|
+
hLen++;
|
|
5230
|
+
}
|
|
5231
|
+
vLen++;
|
|
5232
|
+
});
|
|
5233
|
+
const isSelected = sLen >= vLen;
|
|
5234
|
+
const halfSelect = !isSelected && (sLen >= 1 || hLen >= 1);
|
|
5235
|
+
reactData.isAllSelected = isSelected;
|
|
5236
|
+
reactData.isIndeterminate = halfSelect;
|
|
5237
|
+
},
|
|
5238
|
+
checkSelectionStatus() {
|
|
5239
|
+
const $xeTable = this;
|
|
5240
|
+
$xeTable.updateCheckboxStatus();
|
|
5241
|
+
$xeTable.updateAllCheckboxStatus();
|
|
5284
5242
|
},
|
|
5285
5243
|
// 还原展开、选中等相关状态
|
|
5286
5244
|
handleReserveStatus() {
|