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.
@@ -4658,11 +4658,12 @@ const Methods = {
4658
4658
  }
4659
4659
  },
4660
4660
  handleCheckedCheckboxRow(rows, value, isForce) {
4661
+ const $xeTable = this;
4661
4662
  if (rows && !_xeUtils.default.isArray(rows)) {
4662
4663
  rows = [rows];
4663
4664
  }
4664
- this.handleBatchSelectRows(rows, !!value, isForce);
4665
- this.checkSelectionStatus();
4665
+ $xeTable.handleBatchSelectRows(rows, !!value, isForce);
4666
+ $xeTable.checkSelectionStatus();
4666
4667
  return this.$nextTick();
4667
4668
  },
4668
4669
  /**
@@ -4695,269 +4696,118 @@ const Methods = {
4695
4696
  return !!treeIndeterminateMaps[(0, _util.getRowid)(this, row)] && !this.isCheckedByCheckboxRow(row);
4696
4697
  },
4697
4698
  /**
4698
- * 多行
4699
+ * 切换选中
4699
4700
  * 多选,行选中事件
4700
- * value 选中true 不选false 半选-1
4701
4701
  */
4702
- handleBatchSelectRows(rows, value, isForce) {
4702
+ handleBatchSelectRows(rows, checked, isForce) {
4703
4703
  const $xeTable = this;
4704
+ const props = $xeTable;
4705
+ const reactData = $xeTable;
4704
4706
  const {
4705
4707
  treeConfig
4706
- } = $xeTable;
4708
+ } = props;
4707
4709
  const {
4708
- selectCheckboxMaps,
4709
- checkboxOpts
4710
- } = this;
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;
4711
4720
  const {
4712
4721
  checkField,
4713
4722
  checkStrictly,
4714
4723
  checkMethod
4715
4724
  } = checkboxOpts;
4725
+ const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
4716
4726
  if (checkField) {
4727
+ // 树结构
4717
4728
  if (treeConfig && !checkStrictly) {
4718
- rows.forEach(row => {
4719
- this.handleSelectRow({
4720
- row
4721
- }, value, isForce);
4722
- });
4723
- } else {
4724
- rows.forEach(row => {
4729
+ // 更新子节点状态
4730
+ _xeUtils.default.eachTree(rows, row => {
4725
4731
  if (isForce || !checkMethod || checkMethod({
4726
4732
  row
4727
4733
  })) {
4728
- _xeUtils.default.set(row, checkField, value);
4729
- this.handleCheckboxReserveRow(row, value);
4734
+ _xeUtils.default.set(row, checkField, checked);
4735
+ if (indeterminateField) {
4736
+ _xeUtils.default.set(row, indeterminateField, false);
4737
+ }
4738
+ $xeTable.handleCheckboxReserveRow(row, checked);
4730
4739
  }
4740
+ }, {
4741
+ children: transform ? mapChildrenField : childrenField
4731
4742
  });
4732
- }
4733
- } else {
4734
- if (treeConfig && !checkStrictly) {
4735
- rows.forEach(row => {
4736
- this.handleSelectRow({
4737
- row
4738
- }, value, isForce);
4739
- });
4743
+ reactData.selectCheckboxMaps = selectRowMaps;
4744
+ return;
4740
4745
  } else {
4741
- const selectRowMaps = Object.assign({}, selectCheckboxMaps);
4746
+ // 列表
4742
4747
  rows.forEach(row => {
4743
- const rowid = (0, _util.getRowid)($xeTable, row);
4744
4748
  if (isForce || !checkMethod || checkMethod({
4745
4749
  row
4746
4750
  })) {
4747
- if (value) {
4748
- if (!selectRowMaps[rowid]) {
4749
- selectRowMaps[rowid] = row;
4750
- }
4751
- } else {
4752
- if (selectRowMaps[rowid]) {
4753
- delete selectRowMaps[rowid];
4754
- }
4755
- }
4756
- this.handleCheckboxReserveRow(row, value);
4751
+ _xeUtils.default.set(row, checkField, checked);
4752
+ $xeTable.handleCheckboxReserveRow(row, checked);
4757
4753
  }
4758
4754
  });
4759
- this.selectCheckboxMaps = selectRowMaps;
4760
4755
  }
4756
+ reactData.selectCheckboxMaps = selectRowMaps;
4757
+ return;
4761
4758
  }
4762
- },
4763
- /**
4764
- * 多选,行选中事件
4765
- * value 选中true 不选false 半选-1
4766
- */
4767
- handleSelectRow({
4768
- row
4769
- }, value, isForce) {
4770
- const {
4771
- selectCheckboxMaps,
4772
- afterFullData,
4773
- treeConfig,
4774
- treeOpts,
4775
- treeIndeterminateMaps,
4776
- checkboxOpts
4777
- } = this;
4778
- const {
4779
- checkField,
4780
- checkStrictly,
4781
- checkMethod
4782
- } = checkboxOpts;
4783
- const selectRowMaps = Object.assign({}, selectCheckboxMaps);
4784
- const childrenField = treeOpts.children || treeOpts.childrenField;
4785
- const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
4786
- const rowid = (0, _util.getRowid)(this, row);
4787
- if (checkField) {
4788
- if (treeConfig && !checkStrictly) {
4789
- if (value === -1) {
4790
- if (!treeIndeterminateMaps[rowid]) {
4791
- if (indeterminateField) {
4792
- _xeUtils.default.set(row, indeterminateField, true);
4793
- }
4794
- treeIndeterminateMaps[rowid] = row;
4795
- }
4796
- _xeUtils.default.set(row, checkField, false);
4797
- } else {
4798
- // 更新子节点状态
4799
- _xeUtils.default.eachTree([row], item => {
4800
- if (this.eqRow(item, row) || isForce || !checkMethod || checkMethod({
4801
- row: item
4802
- })) {
4803
- _xeUtils.default.set(item, checkField, value);
4804
- if (indeterminateField) {
4805
- _xeUtils.default.set(row, indeterminateField, false);
4806
- }
4807
- delete treeIndeterminateMaps[(0, _util.getRowid)(this, item)];
4808
- this.handleCheckboxReserveRow(row, value);
4809
- }
4810
- }, {
4811
- children: childrenField
4812
- });
4813
- }
4814
- // 如果存在父节点,更新父节点状态
4815
- const matchObj = _xeUtils.default.findTree(afterFullData, item => this.eqRow(item, row), {
4816
- children: childrenField
4817
- });
4818
- if (matchObj && matchObj.parent) {
4819
- let parentStatus;
4820
- const vItems = [];
4821
- const vItemMaps = {};
4822
- if (!isForce && checkMethod) {
4823
- matchObj.items.forEach(item => {
4824
- if (checkMethod({
4825
- row: item
4826
- })) {
4827
- const itemRid = (0, _util.getRowid)(this, item);
4828
- vItemMaps[itemRid] = item;
4829
- vItems.push(item);
4830
- }
4831
- });
4832
- } else {
4833
- matchObj.items.forEach(item => {
4834
- const itemRid = (0, _util.getRowid)(this, item);
4835
- vItemMaps[itemRid] = item;
4836
- vItems.push(item);
4837
- });
4838
- }
4839
- const indeterminatesItem = _xeUtils.default.find(matchObj.items, item => !!treeIndeterminateMaps[(0, _util.getRowid)(this, item)]);
4840
- if (indeterminatesItem) {
4841
- parentStatus = -1;
4842
- } else {
4843
- const selectItems = [];
4844
- matchObj.items.forEach(item => {
4845
- if (_xeUtils.default.get(item, checkField)) {
4846
- selectItems.push(item);
4847
- }
4848
- });
4849
- parentStatus = selectItems.filter(item => vItemMaps[(0, _util.getRowid)(this, item)]).length === vItems.length ? true : selectItems.length || value === -1 ? -1 : false;
4850
- }
4851
- this.selectCheckboxMaps = selectRowMaps;
4852
- return this.handleSelectRow({
4853
- row: matchObj.parent
4854
- }, parentStatus, isForce);
4855
- }
4856
- } else {
4857
- if (isForce || !checkMethod || checkMethod({
4858
- row
4859
- })) {
4860
- _xeUtils.default.set(row, checkField, value);
4861
- this.handleCheckboxReserveRow(row, value);
4862
- }
4863
- }
4864
- } else {
4865
- if (treeConfig && !checkStrictly) {
4866
- if (value === -1) {
4867
- if (!treeIndeterminateMaps[rowid]) {
4868
- if (indeterminateField) {
4869
- _xeUtils.default.set(row, indeterminateField, true);
4870
- }
4871
- treeIndeterminateMaps[rowid] = row;
4872
- }
4873
- if (selectRowMaps[rowid]) {
4874
- delete selectRowMaps[rowid];
4875
- }
4876
- } else {
4877
- // 更新子节点状态
4878
- _xeUtils.default.eachTree([row], item => {
4879
- const itemRid = (0, _util.getRowid)(this, item);
4880
- if (this.eqRow(item, row) || isForce || !checkMethod || checkMethod({
4881
- row: item
4882
- })) {
4883
- if (value) {
4884
- selectRowMaps[itemRid] = item;
4885
- } else {
4886
- if (selectRowMaps[itemRid]) {
4887
- delete selectRowMaps[itemRid];
4888
- }
4889
- }
4890
- if (indeterminateField) {
4891
- _xeUtils.default.set(row, indeterminateField, false);
4892
- }
4893
- delete treeIndeterminateMaps[(0, _util.getRowid)(this, item)];
4894
- this.handleCheckboxReserveRow(row, value);
4895
- }
4896
- }, {
4897
- children: childrenField
4898
- });
4899
- }
4900
- // 如果存在父节点,更新父节点状态
4901
- const matchObj = _xeUtils.default.findTree(afterFullData, item => this.eqRow(item, row), {
4902
- children: childrenField
4903
- });
4904
- if (matchObj && matchObj.parent) {
4905
- let parentStatus;
4906
- const vItems = [];
4907
- const vItemMaps = {};
4908
- if (!isForce && checkMethod) {
4909
- matchObj.items.forEach(item => {
4910
- if (checkMethod({
4911
- row: item
4912
- })) {
4913
- const itemRid = (0, _util.getRowid)(this, item);
4914
- vItemMaps[itemRid] = item;
4915
- vItems.push(item);
4916
- }
4917
- });
4918
- } else {
4919
- matchObj.items.forEach(item => {
4920
- const itemRid = (0, _util.getRowid)(this, item);
4921
- vItemMaps[itemRid] = item;
4922
- vItems.push(item);
4923
- });
4924
- }
4925
- const indeterminatesItem = _xeUtils.default.find(matchObj.items, item => !!treeIndeterminateMaps[(0, _util.getRowid)(this, item)]);
4926
- if (indeterminatesItem) {
4927
- parentStatus = -1;
4928
- } else {
4929
- const selectItems = [];
4930
- matchObj.items.forEach(item => {
4931
- const itemRid = (0, _util.getRowid)(this, item);
4932
- if (selectRowMaps[itemRid]) {
4933
- selectItems.push(item);
4934
- }
4935
- });
4936
- parentStatus = selectItems.filter(item => vItemMaps[(0, _util.getRowid)(this, item)]).length === vItems.length ? true : selectItems.length || value === -1 ? -1 : false;
4937
- }
4938
- this.selectCheckboxMaps = selectRowMaps;
4939
- return this.handleSelectRow({
4940
- row: matchObj.parent
4941
- }, parentStatus, isForce);
4942
- }
4943
- } else {
4759
+ // 树结构
4760
+ if (treeConfig && !checkStrictly) {
4761
+ // 更新子节点状态
4762
+ _xeUtils.default.eachTree(rows, row => {
4763
+ const rowid = (0, _util.getRowid)($xeTable, row);
4944
4764
  if (isForce || !checkMethod || checkMethod({
4945
4765
  row
4946
4766
  })) {
4947
- if (value) {
4948
- if (!selectRowMaps[rowid]) {
4949
- selectRowMaps[rowid] = row;
4950
- }
4767
+ if (checked) {
4768
+ selectRowMaps[rowid] = row;
4951
4769
  } else {
4952
4770
  if (selectRowMaps[rowid]) {
4953
4771
  delete selectRowMaps[rowid];
4954
4772
  }
4955
4773
  }
4956
- this.handleCheckboxReserveRow(row, value);
4774
+ $xeTable.handleCheckboxReserveRow(row, checked);
4957
4775
  }
4958
- }
4776
+ }, {
4777
+ children: transform ? mapChildrenField : childrenField
4778
+ });
4779
+ reactData.selectCheckboxMaps = selectRowMaps;
4780
+ return;
4959
4781
  }
4960
- this.selectCheckboxMaps = selectRowMaps;
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);
4961
4811
  },
4962
4812
  handleToggleCheckRowEvent(evnt, params) {
4963
4813
  const {
@@ -4974,20 +4824,20 @@ const Methods = {
4974
4824
  if (trigger === 'manual') {
4975
4825
  return;
4976
4826
  }
4977
- let value = false;
4827
+ let checked = false;
4978
4828
  if (checkField) {
4979
- value = !_xeUtils.default.get(row, checkField);
4829
+ checked = !_xeUtils.default.get(row, checkField);
4980
4830
  } else {
4981
- value = !selectCheckboxMaps[(0, _util.getRowid)(this, row)];
4831
+ checked = !selectCheckboxMaps[(0, _util.getRowid)(this, row)];
4982
4832
  }
4983
4833
  if (evnt) {
4984
- this.triggerCheckRowEvent(evnt, params, value);
4834
+ this.triggerCheckRowEvent(evnt, params, checked);
4985
4835
  } else {
4986
- this.handleSelectRow(params, value);
4836
+ this.handleSelectRow(params, checked);
4987
4837
  this.checkSelectionStatus();
4988
4838
  }
4989
4839
  },
4990
- triggerCheckRowEvent(evnt, params, value) {
4840
+ triggerCheckRowEvent(evnt, params, checked) {
4991
4841
  const {
4992
4842
  checkboxOpts,
4993
4843
  afterFullData
@@ -5023,13 +4873,13 @@ const Methods = {
5023
4873
  if (!checkMethod || checkMethod({
5024
4874
  row
5025
4875
  })) {
5026
- this.handleSelectRow(params, value);
4876
+ this.handleSelectRow(params, checked);
5027
4877
  this.checkSelectionStatus();
5028
4878
  this.emitEvent('checkbox-change', Object.assign({
5029
4879
  records: this.getCheckboxRecords(),
5030
4880
  reserves: this.getCheckboxReserveRecords(),
5031
4881
  indeterminates: this.getCheckboxIndeterminateRecords(),
5032
- checked: value
4882
+ checked
5033
4883
  }, params), evnt);
5034
4884
  }
5035
4885
  },
@@ -5037,6 +4887,7 @@ const Methods = {
5037
4887
  * 多选,切换某一行的选中状态
5038
4888
  */
5039
4889
  toggleCheckboxRow(row) {
4890
+ const $xeTable = this;
5040
4891
  const {
5041
4892
  selectCheckboxMaps,
5042
4893
  checkboxOpts
@@ -5044,14 +4895,14 @@ const Methods = {
5044
4895
  const {
5045
4896
  checkField
5046
4897
  } = checkboxOpts;
5047
- const value = checkField ? !_xeUtils.default.get(row, checkField) : !selectCheckboxMaps[(0, _util.getRowid)(this, row)];
5048
- this.handleSelectRow({
5049
- row
5050
- }, value, true);
5051
- this.checkSelectionStatus();
5052
- 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();
5053
4902
  },
5054
- handleCheckedAllCheckboxRow(value, isForce) {
4903
+ handleCheckedAllCheckboxRow(checked, isForce) {
4904
+ const $xeTable = this;
4905
+ const reactData = $xeTable;
5055
4906
  const {
5056
4907
  afterFullData,
5057
4908
  treeConfig,
@@ -5080,7 +4931,7 @@ const Methods = {
5080
4931
  }
5081
4932
  // 疑惑!
5082
4933
  if (checkStrictly) {
5083
- this.isAllSelected = value;
4934
+ this.isAllSelected = checked;
5084
4935
  } else {
5085
4936
  /**
5086
4937
  * 绑定属性方式(高性能,有污染)
@@ -5091,10 +4942,10 @@ const Methods = {
5091
4942
  if (isForce || !checkMethod || checkMethod({
5092
4943
  row
5093
4944
  })) {
5094
- if (value) {
4945
+ if (checked) {
5095
4946
  selectRowMaps[(0, _util.getRowid)(this, row)] = row;
5096
4947
  }
5097
- _xeUtils.default.set(row, checkField, value);
4948
+ _xeUtils.default.set(row, checkField, checked);
5098
4949
  }
5099
4950
  if (treeConfig && indeterminateField) {
5100
4951
  _xeUtils.default.set(row, indeterminateField, false);
@@ -5115,7 +4966,7 @@ const Methods = {
5115
4966
  * 无需任何属性,直接绑定
5116
4967
  */
5117
4968
  if (treeConfig) {
5118
- if (value) {
4969
+ if (checked) {
5119
4970
  /**
5120
4971
  * 如果是树勾选
5121
4972
  * 如果方法成立,则添加到临时集合中
@@ -5148,7 +4999,7 @@ const Methods = {
5148
4999
  }
5149
5000
  }
5150
5001
  } else {
5151
- if (value) {
5002
+ if (checked) {
5152
5003
  /**
5153
5004
  * 如果是行勾选
5154
5005
  * 如果存在选中方法且成立或者本身已勾选,则添加到临时集合中
@@ -5188,7 +5039,7 @@ const Methods = {
5188
5039
  }
5189
5040
  }
5190
5041
  if (reserve) {
5191
- if (value) {
5042
+ if (checked) {
5192
5043
  _xeUtils.default.each(selectRowMaps, (row, rowid) => {
5193
5044
  checkboxReserveRowMap[rowid] = row;
5194
5045
  });
@@ -5198,6 +5049,8 @@ const Methods = {
5198
5049
  }
5199
5050
  this.selectCheckboxMaps = checkField ? {} : selectRowMaps;
5200
5051
  }
5052
+ reactData.isAllSelected = checked;
5053
+ reactData.isIndeterminate = false;
5201
5054
  this.treeIndeterminateMaps = {};
5202
5055
  this.treeIndeterminateRowMaps = {};
5203
5056
  this.checkSelectionStatus();
@@ -5210,81 +5063,182 @@ const Methods = {
5210
5063
  setAllCheckboxRow(value) {
5211
5064
  return this.handleCheckedAllCheckboxRow(value, true);
5212
5065
  },
5213
- checkSelectionStatus() {
5066
+ updateCheckboxStatus() {
5067
+ const $xeTable = this;
5068
+ const props = $xeTable;
5069
+ const reactData = $xeTable;
5070
+ const internalData = $xeTable;
5214
5071
  const {
5215
- afterFullData,
5216
- selectCheckboxMaps,
5217
- treeIndeterminateMaps,
5218
- checkboxOpts,
5219
5072
  treeConfig
5220
- } = this;
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;
5221
5087
  const {
5222
5088
  checkField,
5223
5089
  checkStrictly,
5224
5090
  checkMethod
5225
5091
  } = checkboxOpts;
5226
- const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
5227
- if (!checkStrictly) {
5228
- const disableRows = [];
5229
- const checkRows = [];
5230
- let isAllResolve = false;
5231
- let isAllSelected = false;
5232
- let isIndeterminate = false;
5233
- if (checkField) {
5234
- isAllResolve = afterFullData.every(checkMethod ? row => {
5235
- if (!checkMethod({
5236
- row
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
5237
5124
  })) {
5238
- disableRows.push(row);
5239
- return true;
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
+ }
5240
5137
  }
5241
- if (_xeUtils.default.get(row, checkField)) {
5242
- checkRows.push(row);
5243
- return true;
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++;
5244
5145
  }
5245
- return false;
5246
- } : row => _xeUtils.default.get(row, checkField));
5247
- isAllSelected = isAllResolve && afterFullData.length !== disableRows.length;
5248
- if (treeConfig) {
5249
- if (indeterminateField) {
5250
- isIndeterminate = !isAllSelected && afterFullData.some(row => _xeUtils.default.get(row, checkField) || _xeUtils.default.get(row, indeterminateField) || !!treeIndeterminateMaps[(0, _util.getRowid)(this, row)]);
5251
- } else {
5252
- isIndeterminate = !isAllSelected && afterFullData.some(row => _xeUtils.default.get(row, checkField) || !!treeIndeterminateMaps[(0, _util.getRowid)(this, row)]);
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];
5253
5159
  }
5254
5160
  } else {
5255
- if (indeterminateField) {
5256
- isIndeterminate = !isAllSelected && afterFullData.some(row => _xeUtils.default.get(row, checkField) || _xeUtils.default.get(row, indeterminateField));
5161
+ if (!checkField) {
5162
+ if (selectRowMaps[rowid]) {
5163
+ delete selectRowMaps[rowid];
5164
+ }
5165
+ }
5166
+ if (halfSelect) {
5167
+ halfRowMaps[rowid] = row;
5257
5168
  } else {
5258
- isIndeterminate = !isAllSelected && afterFullData.some(row => _xeUtils.default.get(row, checkField));
5169
+ if (halfRowMaps[rowid]) {
5170
+ delete halfRowMaps[rowid];
5171
+ }
5259
5172
  }
5260
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++;
5261
5216
  } else {
5262
- isAllResolve = afterFullData.every(checkMethod ? row => {
5263
- if (!checkMethod({
5264
- row
5265
- })) {
5266
- disableRows.push(row);
5267
- return true;
5268
- }
5269
- if (selectCheckboxMaps[(0, _util.getRowid)(this, row)]) {
5270
- checkRows.push(row);
5271
- return true;
5272
- }
5273
- return false;
5274
- } : row => selectCheckboxMaps[(0, _util.getRowid)(this, row)]);
5275
- isAllSelected = isAllResolve && afterFullData.length !== disableRows.length;
5276
- if (treeConfig) {
5277
- isIndeterminate = !isAllSelected && afterFullData.some(row => {
5278
- const itemRid = (0, _util.getRowid)(this, row);
5279
- return treeIndeterminateMaps[itemRid] || selectCheckboxMaps[itemRid];
5280
- });
5281
- } else {
5282
- isIndeterminate = !isAllSelected && afterFullData.some(row => selectCheckboxMaps[(0, _util.getRowid)(this, row)]);
5217
+ if (selected) {
5218
+ sLen++;
5219
+ } else if (treeIndeterminateMaps[childRowid]) {
5220
+ hLen++;
5283
5221
  }
5284
5222
  }
5285
- this.isAllSelected = isAllSelected;
5286
- this.isIndeterminate = isIndeterminate;
5287
- }
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();
5288
5242
  },
5289
5243
  // 还原展开、选中等相关状态
5290
5244
  handleReserveStatus() {