vxe-table 3.11.30 → 3.11.31

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.
@@ -916,7 +916,6 @@ const Methods = {
916
916
  */
917
917
  loadData(datas) {
918
918
  const {
919
- inited,
920
919
  initStatus
921
920
  } = this;
922
921
  return this.loadTableData(datas).then(() => {
@@ -925,9 +924,6 @@ const Methods = {
925
924
  if (!initStatus) {
926
925
  this.handleLoadDefaults();
927
926
  }
928
- if (!inited) {
929
- this.handleInitDefaults();
930
- }
931
927
  return this.recalculate();
932
928
  });
933
929
  },
@@ -936,18 +932,12 @@ const Methods = {
936
932
  * @param {Array} datas 数据
937
933
  */
938
934
  reloadData(datas) {
939
- const {
940
- inited
941
- } = this;
942
935
  return this.clearAll().then(() => {
943
936
  this.inited = true;
944
937
  this.initStatus = true;
945
938
  return this.loadTableData(datas);
946
939
  }).then(() => {
947
940
  this.handleLoadDefaults();
948
- if (!inited) {
949
- this.handleInitDefaults();
950
- }
951
941
  return this.recalculate();
952
942
  });
953
943
  },
@@ -4671,29 +4661,84 @@ const Methods = {
4671
4661
  * @param {Array/Row} rows 行数据
4672
4662
  * @param {Boolean} value 是否选中
4673
4663
  */
4674
- setCheckboxRow(rows, value) {
4664
+ setCheckboxRow(rows, checked) {
4665
+ const $xeTable = this;
4675
4666
  if (rows && !_xeUtils.default.isArray(rows)) {
4676
4667
  rows = [rows];
4677
4668
  }
4678
- return this.handleCheckedCheckboxRow(rows, value, true);
4669
+ return $xeTable.handleCheckedCheckboxRow(rows, checked, true);
4670
+ },
4671
+ setCheckboxRowKey(keys, checked) {
4672
+ const $xeTable = this;
4673
+ const internalData = $xeTable;
4674
+ const {
4675
+ fullAllDataRowIdData
4676
+ } = internalData;
4677
+ if (keys && !_xeUtils.default.isArray(keys)) {
4678
+ keys = [keys];
4679
+ }
4680
+ const rows = [];
4681
+ keys.forEach(rowid => {
4682
+ const rowRest = fullAllDataRowIdData[rowid];
4683
+ if (rowRest) {
4684
+ rows.push(rowRest.row);
4685
+ }
4686
+ });
4687
+ return $xeTable.handleCheckedCheckboxRow(rows, checked, true);
4679
4688
  },
4680
4689
  isCheckedByCheckboxRow(row) {
4690
+ const $xeTable = this;
4691
+ const reactData = $xeTable;
4681
4692
  const {
4682
4693
  selectCheckboxMaps
4683
- } = this;
4694
+ } = reactData;
4695
+ const checkboxOpts = $xeTable.computeCheckboxOpts;
4684
4696
  const {
4685
4697
  checkField
4686
- } = this.checkboxOpts;
4698
+ } = checkboxOpts;
4687
4699
  if (checkField) {
4688
4700
  return _xeUtils.default.get(row, checkField);
4689
4701
  }
4690
- return !!selectCheckboxMaps[(0, _util.getRowid)(this, row)];
4702
+ return !!selectCheckboxMaps[(0, _util.getRowid)($xeTable, row)];
4703
+ },
4704
+ isCheckedByCheckboxRowKey(rowid) {
4705
+ const $xeTable = this;
4706
+ const reactData = $xeTable;
4707
+ const internalData = $xeTable;
4708
+ const {
4709
+ selectCheckboxMaps
4710
+ } = reactData;
4711
+ const {
4712
+ fullAllDataRowIdData
4713
+ } = internalData;
4714
+ const checkboxOpts = $xeTable.computeCheckboxOpts;
4715
+ const {
4716
+ checkField
4717
+ } = checkboxOpts;
4718
+ if (checkField) {
4719
+ const rowRest = fullAllDataRowIdData[rowid];
4720
+ if (rowRest) {
4721
+ return _xeUtils.default.get(rowRest.row, checkField);
4722
+ }
4723
+ return false;
4724
+ }
4725
+ return !!selectCheckboxMaps[rowid];
4691
4726
  },
4692
4727
  isIndeterminateByCheckboxRow(row) {
4728
+ const $xeTable = this;
4729
+ const reactData = $xeTable;
4693
4730
  const {
4694
4731
  treeIndeterminateMaps
4695
- } = this;
4696
- return !!treeIndeterminateMaps[(0, _util.getRowid)(this, row)] && !this.isCheckedByCheckboxRow(row);
4732
+ } = reactData;
4733
+ return !!treeIndeterminateMaps[(0, _util.getRowid)($xeTable, row)] && !$xeTable.isCheckedByCheckboxRow(row);
4734
+ },
4735
+ isIndeterminateByCheckboxRowKey(rowid) {
4736
+ const $xeTable = this;
4737
+ const reactData = $xeTable;
4738
+ const {
4739
+ treeIndeterminateMaps
4740
+ } = reactData;
4741
+ return !!treeIndeterminateMaps[rowid] && !$xeTable.isCheckedByCheckboxRowKey(rowid);
4697
4742
  },
4698
4743
  /**
4699
4744
  * 切换选中
@@ -5599,7 +5644,26 @@ const Methods = {
5599
5644
  return this.$nextTick();
5600
5645
  },
5601
5646
  isCheckedByRadioRow(row) {
5602
- return this.selectRadioRow === row;
5647
+ const $xeTable = this;
5648
+ const reactData = $xeTable;
5649
+ const {
5650
+ selectRadioRow
5651
+ } = reactData;
5652
+ if (row && selectRadioRow) {
5653
+ return $xeTable.eqRow(selectRadioRow, row);
5654
+ }
5655
+ return false;
5656
+ },
5657
+ isCheckedByRadioRowKey(key) {
5658
+ const $xeTable = this;
5659
+ const reactData = $xeTable;
5660
+ const {
5661
+ selectRadioRow
5662
+ } = reactData;
5663
+ if (selectRadioRow) {
5664
+ return key === (0, _util.getRowid)($xeTable, selectRadioRow);
5665
+ }
5666
+ return false;
5603
5667
  },
5604
5668
  handleCheckedRadioRow(row, isForce) {
5605
5669
  const {
@@ -5621,7 +5685,24 @@ const Methods = {
5621
5685
  * @param {Row} row 行对象
5622
5686
  */
5623
5687
  setRadioRow(row) {
5624
- return this.handleCheckedRadioRow(row, true);
5688
+ const $xeTable = this;
5689
+ return $xeTable.handleCheckedRadioRow(row, true);
5690
+ },
5691
+ /**
5692
+ * 用于单选行,设置某一行为选中状态
5693
+ * @param key 行主键
5694
+ */
5695
+ setRadioRowKey(rowid) {
5696
+ const $xeTable = this;
5697
+ const internalData = $xeTable;
5698
+ const {
5699
+ fullAllDataRowIdData
5700
+ } = internalData;
5701
+ const rowRest = fullAllDataRowIdData[rowid];
5702
+ if (rowRest) {
5703
+ return $xeTable.handleCheckedRadioRow(rowRest.row, true);
5704
+ }
5705
+ return $xeTable.$nextTick();
5625
5706
  },
5626
5707
  /**
5627
5708
  * 用于当前行,手动清空当前高亮的状态
@@ -5776,6 +5857,7 @@ const Methods = {
5776
5857
  * 如果是双击模式,则单击后选中状态
5777
5858
  */
5778
5859
  triggerCellClickEvent(evnt, params) {
5860
+ const $xeTable = this;
5779
5861
  const {
5780
5862
  highlightCurrentRow,
5781
5863
  editStore,
@@ -5865,6 +5947,20 @@ const Methods = {
5865
5947
  }
5866
5948
  }
5867
5949
  }
5950
+ // 如果是双击编辑模式
5951
+ if ((0, _utils.isEnableConf)(editConfig) && editOpts.trigger === 'dblclick') {
5952
+ if (actived.row && actived.column) {
5953
+ if (editOpts.mode === 'row') {
5954
+ if (!$xeTable.eqRow(actived.row, row)) {
5955
+ $xeTable.handleClearEdit(evnt);
5956
+ }
5957
+ } else if (editOpts.mode === 'cell') {
5958
+ if (!$xeTable.eqRow(actived.row, row) || actived.column.id !== column.id) {
5959
+ $xeTable.handleClearEdit(evnt);
5960
+ }
5961
+ }
5962
+ }
5963
+ }
5868
5964
  this.emitEvent('cell-click', params, evnt);
5869
5965
  },
5870
5966
  /**
@@ -6546,62 +6642,67 @@ const Methods = {
6546
6642
  reactData.isDragColMove = false;
6547
6643
  },
6548
6644
  setPendingRow(rows, status) {
6549
- const pendingMaps = Object.assign({}, this.pendingRowMaps);
6550
- const pendingList = [...this.pendingRowList];
6645
+ const $xeTable = this;
6646
+ const reactData = $xeTable;
6647
+ const pendingMaps = Object.assign({}, reactData.pendingRowMaps);
6551
6648
  if (rows && !_xeUtils.default.isArray(rows)) {
6552
6649
  rows = [rows];
6553
6650
  }
6554
6651
  if (status) {
6555
6652
  rows.forEach(row => {
6556
- const rowid = (0, _util.getRowid)(this, row);
6653
+ const rowid = (0, _util.getRowid)($xeTable, row);
6557
6654
  if (rowid && !pendingMaps[rowid]) {
6558
- pendingList.push(row);
6559
6655
  pendingMaps[rowid] = row;
6560
6656
  }
6561
6657
  });
6562
6658
  } else {
6563
6659
  rows.forEach(row => {
6564
- const rowid = (0, _util.getRowid)(this, row);
6660
+ const rowid = (0, _util.getRowid)($xeTable, row);
6565
6661
  if (rowid && pendingMaps[rowid]) {
6566
- const pendingIndex = this.findRowIndexOf(pendingList, row);
6567
- if (pendingIndex > -1) {
6568
- pendingList.splice(pendingIndex, 1);
6569
- }
6570
6662
  delete pendingMaps[rowid];
6571
6663
  }
6572
6664
  });
6573
6665
  }
6574
- this.pendingRowMaps = pendingMaps;
6575
- this.pendingRowList = pendingList;
6576
- return this.$nextTick();
6666
+ reactData.pendingRowMaps = pendingMaps;
6667
+ return $xeTable.$nextTick();
6577
6668
  },
6578
6669
  togglePendingRow(rows) {
6579
- const pendingMaps = Object.assign({}, this.pendingRowMaps);
6580
- const pendingList = [...this.pendingRowList];
6670
+ const $xeTable = this;
6671
+ const reactData = $xeTable;
6672
+ const pendingMaps = Object.assign({}, reactData.pendingRowMaps);
6581
6673
  if (rows && !_xeUtils.default.isArray(rows)) {
6582
6674
  rows = [rows];
6583
6675
  }
6584
6676
  rows.forEach(row => {
6585
- const rowid = (0, _util.getRowid)(this, row);
6677
+ const rowid = (0, _util.getRowid)($xeTable, row);
6586
6678
  if (rowid) {
6587
6679
  if (pendingMaps[rowid]) {
6588
- const pendingIndex = this.findRowIndexOf(pendingList, row);
6589
- if (pendingIndex > -1) {
6590
- pendingList.splice(pendingIndex, 1);
6591
- }
6592
6680
  delete pendingMaps[rowid];
6593
6681
  } else {
6594
- pendingList.push(row);
6595
6682
  pendingMaps[rowid] = row;
6596
6683
  }
6597
6684
  }
6598
6685
  });
6599
- this.pendingRowMaps = pendingMaps;
6600
- this.pendingRowList = pendingList;
6601
- return this.$nextTick();
6686
+ reactData.pendingRowMaps = pendingMaps;
6687
+ return $xeTable.$nextTick();
6602
6688
  },
6603
6689
  getPendingRecords() {
6604
- return this.pendingRowList.slice(0);
6690
+ const $xeTable = this;
6691
+ const reactData = $xeTable;
6692
+ const internalData = $xeTable;
6693
+ const {
6694
+ pendingRowMaps
6695
+ } = reactData;
6696
+ const {
6697
+ fullAllDataRowIdData
6698
+ } = internalData;
6699
+ const insertRecords = [];
6700
+ _xeUtils.default.each(pendingRowMaps, (row, rowid) => {
6701
+ if (fullAllDataRowIdData[rowid]) {
6702
+ insertRecords.push(row);
6703
+ }
6704
+ });
6705
+ return insertRecords;
6605
6706
  },
6606
6707
  hasPendingByRow(row) {
6607
6708
  const {
@@ -6612,7 +6713,6 @@ const Methods = {
6612
6713
  },
6613
6714
  clearPendingRow() {
6614
6715
  this.pendingRowMaps = {};
6615
- this.pendingRowList = [];
6616
6716
  return this.$nextTick();
6617
6717
  },
6618
6718
  sort(sortConfs, sortOrder) {
@@ -7746,6 +7846,8 @@ const Methods = {
7746
7846
  }
7747
7847
  internalData.lastScrollTop = scrollTop;
7748
7848
  }
7849
+ reactData.isDragColMove = false;
7850
+ reactData.isDragRowMove = false;
7749
7851
  reactData.lastScrollTime = Date.now();
7750
7852
  const evntParams = Object.assign({
7751
7853
  scrollTop,