vxe-table 3.14.0-beta.7 → 3.14.0-beta.8

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.
@@ -965,6 +965,7 @@ function handleCheckedAllCheckboxRow($xeTable, checked, isForce) {
965
965
  reserve,
966
966
  checkMethod
967
967
  } = checkboxOpts;
968
+ // indeterminateField 仅支持读取
968
969
  const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
969
970
  const selectRowMaps = {};
970
971
  /**
@@ -2631,6 +2632,10 @@ const Methods = {
2631
2632
  }
2632
2633
  return [];
2633
2634
  },
2635
+ getEl() {
2636
+ const $xeTable = this;
2637
+ return $xeTable.$refs.refElem;
2638
+ },
2634
2639
  /**
2635
2640
  * 获取父容器元素
2636
2641
  */
@@ -3717,25 +3722,31 @@ const Methods = {
3717
3722
  },
3718
3723
  /**
3719
3724
  * 检查行或列数据是否发生改变
3720
- * @param {Row} row 行对象
3725
+ * @param {Row} rowOrId 行对象
3721
3726
  * @param {String} field 字段名
3722
3727
  */
3723
- isUpdateByRow(row, field) {
3728
+ isUpdateByRow(rowOrId, field) {
3729
+ const $xeTable = this;
3730
+ const props = $xeTable;
3731
+ const internalData = $xeTable;
3732
+ const {
3733
+ keepSource
3734
+ } = props;
3724
3735
  const {
3725
3736
  tableFullColumn,
3726
- keepSource,
3727
- sourceDataRowIdData,
3728
- fullDataRowIdData
3729
- } = this;
3737
+ fullDataRowIdData,
3738
+ sourceDataRowIdData
3739
+ } = internalData;
3730
3740
  if (keepSource) {
3731
- const rowid = (0, _util.getRowid)(this, row);
3741
+ const rowid = _xeUtils.default.isString(rowOrId) || _xeUtils.default.isNumber(rowOrId) ? rowOrId : (0, _util.getRowid)($xeTable, rowOrId);
3742
+ const rowRest = fullDataRowIdData[rowid];
3732
3743
  // 新增的数据不需要检测
3733
- if (!fullDataRowIdData[rowid]) {
3744
+ if (!rowRest) {
3734
3745
  return false;
3735
3746
  }
3736
- const oldRest = sourceDataRowIdData[rowid];
3737
- if (oldRest) {
3738
- const oRow = oldRest.row;
3747
+ const row = rowRest.row;
3748
+ const oRow = sourceDataRowIdData[rowid];
3749
+ if (oRow) {
3739
3750
  if (arguments.length > 1) {
3740
3751
  return !eqCellValue(oRow, row, field);
3741
3752
  }
@@ -3797,6 +3808,113 @@ const Methods = {
3797
3808
  tableColumn: this.tableColumn.slice(0)
3798
3809
  };
3799
3810
  },
3811
+ /**
3812
+ * 移动列到指定列的位置
3813
+ * @param fieldOrColumn
3814
+ * @param targetFieldOrColumn
3815
+ * @param options
3816
+ */
3817
+ moveColumnTo(fieldOrColumn, targetFieldOrColumn, options) {
3818
+ const $xeTable = this;
3819
+ const internalData = $xeTable;
3820
+ const {
3821
+ fullColumnIdData,
3822
+ visibleColumn
3823
+ } = internalData;
3824
+ const {
3825
+ dragToChild,
3826
+ dragPos,
3827
+ isCrossDrag
3828
+ } = Object.assign({}, options);
3829
+ const dragCol = (0, _util.handleFieldOrColumn)($xeTable, fieldOrColumn);
3830
+ let prevDragCol = null;
3831
+ const colRest = dragCol ? fullColumnIdData[dragCol.id] : null;
3832
+ let defPos = 'left';
3833
+ if (_xeUtils.default.isNumber(targetFieldOrColumn)) {
3834
+ if (colRest && targetFieldOrColumn) {
3835
+ let currList = colRest.items;
3836
+ let offsetIndex = colRest._index + targetFieldOrColumn;
3837
+ if (isCrossDrag) {
3838
+ currList = visibleColumn;
3839
+ offsetIndex = colRest._index + targetFieldOrColumn;
3840
+ }
3841
+ if (offsetIndex > 0 && offsetIndex < currList.length - 1) {
3842
+ prevDragCol = currList[offsetIndex];
3843
+ }
3844
+ if (targetFieldOrColumn > 0) {
3845
+ defPos = 'right';
3846
+ }
3847
+ }
3848
+ } else {
3849
+ prevDragCol = (0, _util.handleFieldOrColumn)($xeTable, targetFieldOrColumn);
3850
+ const targetColRest = prevDragCol ? fullColumnIdData[prevDragCol.id] : null;
3851
+ if (colRest && targetColRest) {
3852
+ if (targetColRest._index > colRest._index) {
3853
+ defPos = 'right';
3854
+ }
3855
+ }
3856
+ }
3857
+ return $xeTable.handleColDragSwapEvent(null, true, dragCol, prevDragCol, dragPos || defPos, dragToChild === true);
3858
+ },
3859
+ /**
3860
+ * 移动行到指定行的位置
3861
+ * @param rowidOrRow
3862
+ * @param targetRowidOrRow
3863
+ * @param options
3864
+ */
3865
+ moveRowTo(rowidOrRow, targetRowidOrRow, options) {
3866
+ const $xeTable = this;
3867
+ const props = $xeTable;
3868
+ const internalData = $xeTable;
3869
+ const {
3870
+ treeConfig
3871
+ } = props;
3872
+ const {
3873
+ fullAllDataRowIdData,
3874
+ afterFullData
3875
+ } = internalData;
3876
+ const {
3877
+ dragToChild,
3878
+ dragPos,
3879
+ isCrossDrag
3880
+ } = Object.assign({}, options);
3881
+ const treeOpts = $xeTable.computeTreeOpts;
3882
+ const dragRow = (0, _util.handleRowidOrRow)($xeTable, rowidOrRow);
3883
+ let prevDragRow = null;
3884
+ let defPos = 'top';
3885
+ const rowRest = dragRow ? fullAllDataRowIdData[(0, _util.getRowid)($xeTable, dragRow)] : null;
3886
+ if (_xeUtils.default.isNumber(targetRowidOrRow)) {
3887
+ if (rowRest && targetRowidOrRow) {
3888
+ let currList = afterFullData;
3889
+ let offsetIndex = rowRest._index + targetRowidOrRow;
3890
+ if (treeConfig) {
3891
+ currList = rowRest.items;
3892
+ if (treeOpts.transform) {
3893
+ offsetIndex = rowRest.treeIndex + targetRowidOrRow;
3894
+ if (isCrossDrag) {
3895
+ currList = afterFullData;
3896
+ offsetIndex = rowRest._index + targetRowidOrRow;
3897
+ }
3898
+ }
3899
+ }
3900
+ if (offsetIndex >= 0 && offsetIndex <= currList.length - 1) {
3901
+ prevDragRow = currList[offsetIndex];
3902
+ }
3903
+ if (targetRowidOrRow > 0) {
3904
+ defPos = 'bottom';
3905
+ }
3906
+ }
3907
+ } else {
3908
+ prevDragRow = (0, _util.handleRowidOrRow)($xeTable, targetRowidOrRow);
3909
+ const targetRowRest = prevDragRow ? fullAllDataRowIdData[(0, _util.getRowid)($xeTable, prevDragRow)] : null;
3910
+ if (rowRest && targetRowRest) {
3911
+ if (targetRowRest._index > rowRest._index) {
3912
+ defPos = 'bottom';
3913
+ }
3914
+ }
3915
+ }
3916
+ return $xeTable.handleRowDragSwapEvent(null, true, dragRow, prevDragRow, dragPos || defPos, dragToChild === true);
3917
+ },
3800
3918
  /**
3801
3919
  * 获取表格的全量列
3802
3920
  */
@@ -3819,16 +3937,26 @@ const Methods = {
3819
3937
  * 用于多选行,获取已选中的数据
3820
3938
  */
3821
3939
  getCheckboxRecords(isFull) {
3940
+ const $xeTable = this;
3941
+ const props = $xeTable;
3942
+ const reactData = $xeTable;
3943
+ const internalData = $xeTable;
3944
+ const {
3945
+ treeConfig
3946
+ } = props;
3947
+ const {
3948
+ selectCheckboxMaps
3949
+ } = reactData;
3822
3950
  const {
3823
3951
  tableFullData,
3824
3952
  afterFullData,
3825
- treeConfig,
3826
- treeOpts,
3827
- checkboxOpts,
3828
- tableFullTreeData,
3829
3953
  afterTreeFullData,
3954
+ tableFullTreeData,
3955
+ fullDataRowIdData,
3830
3956
  afterFullRowMaps
3831
- } = this;
3957
+ } = internalData;
3958
+ const treeOpts = $xeTable.computeTreeOpts;
3959
+ const checkboxOpts = $xeTable.computeCheckboxOpts;
3832
3960
  const {
3833
3961
  transform,
3834
3962
  mapChildrenField
@@ -3837,21 +3965,18 @@ const Methods = {
3837
3965
  checkField
3838
3966
  } = checkboxOpts;
3839
3967
  const childrenField = treeOpts.children || treeOpts.childrenField;
3840
- const currTableData = isFull ? transform ? tableFullTreeData : tableFullData : transform ? afterTreeFullData : afterFullData;
3841
3968
  let rowList = [];
3842
3969
  if (checkField) {
3843
3970
  if (treeConfig) {
3971
+ const currTableData = isFull ? transform ? tableFullTreeData : tableFullData : transform ? afterTreeFullData : afterFullData;
3844
3972
  rowList = _xeUtils.default.filterTree(currTableData, row => _xeUtils.default.get(row, checkField), {
3845
3973
  children: transform ? mapChildrenField : childrenField
3846
3974
  });
3847
3975
  } else {
3976
+ const currTableData = isFull ? tableFullData : afterFullData;
3848
3977
  rowList = currTableData.filter(row => _xeUtils.default.get(row, checkField));
3849
3978
  }
3850
3979
  } else {
3851
- const {
3852
- selectCheckboxMaps,
3853
- fullDataRowIdData
3854
- } = this;
3855
3980
  _xeUtils.default.each(selectCheckboxMaps, (row, rowid) => {
3856
3981
  if (isFull) {
3857
3982
  if (fullDataRowIdData[rowid]) {
@@ -6326,6 +6451,7 @@ const Methods = {
6326
6451
  checkStrictly,
6327
6452
  checkMethod
6328
6453
  } = checkboxOpts;
6454
+ // indeterminateField 仅支持读取
6329
6455
  const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
6330
6456
  if (checkField) {
6331
6457
  // 树结构
@@ -6852,6 +6978,7 @@ const Methods = {
6852
6978
  reserve
6853
6979
  } = checkboxOpts;
6854
6980
  const childrenField = treeOpts.children || treeOpts.childrenField;
6981
+ // indeterminateField 仅支持读取
6855
6982
  const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
6856
6983
  if (checkField) {
6857
6984
  const handleClearChecked = item => {
@@ -7623,6 +7750,9 @@ const Methods = {
7623
7750
  } = internalData;
7624
7751
  const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null);
7625
7752
  const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0;
7753
+ const errRest = {
7754
+ status: false
7755
+ };
7626
7756
  if (prevDragRow && dragRow) {
7627
7757
  // 判断是否有拖动
7628
7758
  if (prevDragRow !== dragRow) {
@@ -7637,7 +7767,7 @@ const Methods = {
7637
7767
  const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
7638
7768
  return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then(status => {
7639
7769
  if (!status) {
7640
- return;
7770
+ return errRest;
7641
7771
  }
7642
7772
  let oafIndex = -1;
7643
7773
  let nafIndex = -1;
@@ -7668,11 +7798,11 @@ const Methods = {
7668
7798
  if (isPeerDrag && !isCrossDrag) {
7669
7799
  if (oldRest.row[parentField] !== newRest.row[parentField]) {
7670
7800
  // 非同级
7671
- return;
7801
+ return errRest;
7672
7802
  }
7673
7803
  } else {
7674
7804
  if (!isCrossDrag) {
7675
- return;
7805
+ return errRest;
7676
7806
  }
7677
7807
  if (oldAllMaps[newRowid]) {
7678
7808
  isSelfToChildStatus = true;
@@ -7683,19 +7813,19 @@ const Methods = {
7683
7813
  content: getI18n('vxe.error.treeDragChild')
7684
7814
  });
7685
7815
  }
7686
- return;
7816
+ return errRest;
7687
7817
  }
7688
7818
  }
7689
7819
  }
7690
7820
  } else if (oldLevel) {
7691
7821
  // 子到根
7692
7822
  if (!isCrossDrag) {
7693
- return;
7823
+ return errRest;
7694
7824
  }
7695
7825
  } else if (newLevel) {
7696
7826
  // 根到子
7697
7827
  if (!isCrossDrag) {
7698
- return;
7828
+ return errRest;
7699
7829
  }
7700
7830
  if (oldAllMaps[newRowid]) {
7701
7831
  isSelfToChildStatus = true;
@@ -7706,7 +7836,7 @@ const Methods = {
7706
7836
  content: getI18n('vxe.error.treeDragChild')
7707
7837
  });
7708
7838
  }
7709
- return;
7839
+ return errRest;
7710
7840
  }
7711
7841
  }
7712
7842
  } else {
@@ -7764,26 +7894,34 @@ const Methods = {
7764
7894
  if (reactData.scrollYLoad) {
7765
7895
  $xeTable.updateScrollYSpace();
7766
7896
  }
7767
- $xeTable.$nextTick().then(() => {
7897
+ if (evnt) {
7898
+ $xeTable.dispatchEvent('row-dragend', {
7899
+ oldRow: dragRow,
7900
+ newRow: prevDragRow,
7901
+ dragRow,
7902
+ dragPos: prevDragPos,
7903
+ dragToChild: isDragToChildFlag,
7904
+ offsetIndex: dragOffsetIndex,
7905
+ _index: {
7906
+ newIndex: nafIndex,
7907
+ oldIndex: oafIndex
7908
+ }
7909
+ }, evnt);
7910
+ }
7911
+ return $xeTable.$nextTick().then(() => {
7768
7912
  $xeTable.updateCellAreas();
7769
7913
  $xeTable.recalculate();
7914
+ }).then(() => {
7915
+ return {
7916
+ status: true
7917
+ };
7770
7918
  });
7771
- $xeTable.dispatchEvent('row-dragend', {
7772
- oldRow: dragRow,
7773
- newRow: prevDragRow,
7774
- dragRow,
7775
- dragPos: prevDragPos,
7776
- dragToChild: isDragToChildFlag,
7777
- offsetIndex: dragOffsetIndex,
7778
- _index: {
7779
- newIndex: nafIndex,
7780
- oldIndex: oafIndex
7781
- }
7782
- }, evnt);
7783
- }).catch(() => {});
7919
+ }).catch(() => {
7920
+ return errRest;
7921
+ });
7784
7922
  }
7785
7923
  }
7786
- return Promise.resolve();
7924
+ return Promise.resolve(errRest);
7787
7925
  },
7788
7926
  handleRowDragDragendEvent(evnt) {
7789
7927
  const $xeTable = this;
@@ -7970,6 +8108,9 @@ const Methods = {
7970
8108
  collectColumn
7971
8109
  } = internalData;
7972
8110
  const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0;
8111
+ const errRest = {
8112
+ status: false
8113
+ };
7973
8114
  if (prevDragCol && dragCol) {
7974
8115
  // 判断是否有拖动
7975
8116
  if (prevDragCol !== dragCol) {
@@ -7986,7 +8127,7 @@ const Methods = {
7986
8127
  const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
7987
8128
  return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then(status => {
7988
8129
  if (!status) {
7989
- return;
8130
+ return errRest;
7990
8131
  }
7991
8132
  let oafIndex = -1;
7992
8133
  let nafIndex = -1;
@@ -8000,11 +8141,11 @@ const Methods = {
8000
8141
  if (isPeerDrag && !isCrossDrag) {
8001
8142
  if (dragColumn.parentId !== newColumn.parentId) {
8002
8143
  // 非同级
8003
- return;
8144
+ return errRest;
8004
8145
  }
8005
8146
  } else {
8006
8147
  if (!isCrossDrag) {
8007
- return;
8148
+ return errRest;
8008
8149
  }
8009
8150
  if (oldAllMaps[newColumn.id]) {
8010
8151
  isSelfToChildStatus = true;
@@ -8015,19 +8156,19 @@ const Methods = {
8015
8156
  content: getI18n('vxe.error.treeDragChild')
8016
8157
  });
8017
8158
  }
8018
- return;
8159
+ return errRest;
8019
8160
  }
8020
8161
  }
8021
8162
  }
8022
8163
  } else if (dragColumn.parentId) {
8023
8164
  // 子到根
8024
8165
  if (!isCrossDrag) {
8025
- return;
8166
+ return errRest;
8026
8167
  }
8027
8168
  } else if (newColumn.parentId) {
8028
8169
  // 根到子
8029
8170
  if (!isCrossDrag) {
8030
- return;
8171
+ return errRest;
8031
8172
  }
8032
8173
  if (oldAllMaps[newColumn.id]) {
8033
8174
  isSelfToChildStatus = true;
@@ -8038,7 +8179,7 @@ const Methods = {
8038
8179
  content: getI18n('vxe.error.treeDragChild')
8039
8180
  });
8040
8181
  }
8041
- return;
8182
+ return errRest;
8042
8183
  }
8043
8184
  }
8044
8185
  } else {
@@ -8107,25 +8248,32 @@ const Methods = {
8107
8248
  $xeTable.clearCopyCellArea();
8108
8249
  }
8109
8250
  }
8110
- $xeTable.dispatchEvent('column-dragend', {
8111
- oldColumn: dragColumn,
8112
- newColumn,
8113
- dragColumn,
8114
- dragPos: prevDragPos,
8115
- dragToChild: isDragToChildFlag,
8116
- offsetIndex: dragOffsetIndex,
8117
- _index: {
8118
- newIndex: nafIndex,
8119
- oldIndex: oafIndex
8120
- }
8121
- }, evnt);
8251
+ if (evnt) {
8252
+ $xeTable.dispatchEvent('column-dragend', {
8253
+ oldColumn: dragColumn,
8254
+ newColumn,
8255
+ dragColumn,
8256
+ dragPos: prevDragPos,
8257
+ dragToChild: isDragToChildFlag,
8258
+ offsetIndex: dragOffsetIndex,
8259
+ _index: {
8260
+ newIndex: nafIndex,
8261
+ oldIndex: oafIndex
8262
+ }
8263
+ }, evnt);
8264
+ }
8122
8265
  if (isSyncColumn) {
8123
8266
  $xeTable.handleColDragSwapColumn();
8124
8267
  }
8125
- }).catch(() => {});
8268
+ return {
8269
+ status: true
8270
+ };
8271
+ }).catch(() => {
8272
+ return errRest;
8273
+ });
8126
8274
  }
8127
8275
  }
8128
- return Promise.resolve();
8276
+ return Promise.resolve(errRest);
8129
8277
  },
8130
8278
  handleHeaderCellDragDragendEvent(evnt) {
8131
8279
  const $xeTable = this;