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.
package/lib/index.umd.js CHANGED
@@ -2220,7 +2220,7 @@ function getClass(property, params) {
2220
2220
  ;// CONCATENATED MODULE: ./packages/ui/index.ts
2221
2221
 
2222
2222
 
2223
- const version = "3.14.0-beta.7";
2223
+ const version = "3.14.0-beta.8";
2224
2224
  core_.VxeUI.version = version;
2225
2225
  core_.VxeUI.tableVersion = version;
2226
2226
  core_.VxeUI.setConfig({
@@ -2843,7 +2843,7 @@ function isNodeElement(elem) {
2843
2843
  const {
2844
2844
  log: log_log
2845
2845
  } = core_.VxeUI;
2846
- const log_version = `table v${"3.14.0-beta.7"}`;
2846
+ const log_version = `table v${"3.14.0-beta.8"}`;
2847
2847
  const warnLog = log_log.create('warn', log_version);
2848
2848
  const errLog = log_log.create('error', log_version);
2849
2849
  ;// CONCATENATED MODULE: ./packages/table/src/columnInfo.ts
@@ -3166,12 +3166,19 @@ function getCellHeight(height) {
3166
3166
  }
3167
3167
  return height || 0;
3168
3168
  }
3169
- function handleFieldOrColumn(_vm, fieldOrColumn) {
3169
+ function handleFieldOrColumn($xeTable, fieldOrColumn) {
3170
3170
  if (fieldOrColumn) {
3171
- return external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isString(fieldOrColumn) || external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isNumber(fieldOrColumn) ? _vm.getColumnByField(`${fieldOrColumn}`) : fieldOrColumn;
3171
+ return external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isString(fieldOrColumn) || external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isNumber(fieldOrColumn) ? $xeTable.getColumnByField(`${fieldOrColumn}`) : fieldOrColumn;
3172
3172
  }
3173
3173
  return null;
3174
3174
  }
3175
+ const handleRowidOrRow = ($xeTable, rowidOrRow) => {
3176
+ if (rowidOrRow) {
3177
+ const rowid = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isString(rowidOrRow) || external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isNumber(rowidOrRow) ? rowidOrRow : getRowid($xeTable, rowidOrRow);
3178
+ return $xeTable.getRowById(rowid);
3179
+ }
3180
+ return null;
3181
+ };
3175
3182
  // 组装列配置
3176
3183
  function assembleColumn(_vm) {
3177
3184
  const {
@@ -6052,6 +6059,7 @@ function handleCheckedAllCheckboxRow($xeTable, checked, isForce) {
6052
6059
  reserve,
6053
6060
  checkMethod
6054
6061
  } = checkboxOpts;
6062
+ // indeterminateField 仅支持读取
6055
6063
  const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
6056
6064
  const selectRowMaps = {};
6057
6065
  /**
@@ -7718,6 +7726,10 @@ const Methods = {
7718
7726
  }
7719
7727
  return [];
7720
7728
  },
7729
+ getEl() {
7730
+ const $xeTable = this;
7731
+ return $xeTable.$refs.refElem;
7732
+ },
7721
7733
  /**
7722
7734
  * 获取父容器元素
7723
7735
  */
@@ -8810,25 +8822,31 @@ const Methods = {
8810
8822
  },
8811
8823
  /**
8812
8824
  * 检查行或列数据是否发生改变
8813
- * @param {Row} row 行对象
8825
+ * @param {Row} rowOrId 行对象
8814
8826
  * @param {String} field 字段名
8815
8827
  */
8816
- isUpdateByRow(row, field) {
8828
+ isUpdateByRow(rowOrId, field) {
8829
+ const $xeTable = this;
8830
+ const props = $xeTable;
8831
+ const internalData = $xeTable;
8832
+ const {
8833
+ keepSource
8834
+ } = props;
8817
8835
  const {
8818
8836
  tableFullColumn,
8819
- keepSource,
8820
- sourceDataRowIdData,
8821
- fullDataRowIdData
8822
- } = this;
8837
+ fullDataRowIdData,
8838
+ sourceDataRowIdData
8839
+ } = internalData;
8823
8840
  if (keepSource) {
8824
- const rowid = getRowid(this, row);
8841
+ const rowid = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isString(rowOrId) || external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isNumber(rowOrId) ? rowOrId : getRowid($xeTable, rowOrId);
8842
+ const rowRest = fullDataRowIdData[rowid];
8825
8843
  // 新增的数据不需要检测
8826
- if (!fullDataRowIdData[rowid]) {
8844
+ if (!rowRest) {
8827
8845
  return false;
8828
8846
  }
8829
- const oldRest = sourceDataRowIdData[rowid];
8830
- if (oldRest) {
8831
- const oRow = oldRest.row;
8847
+ const row = rowRest.row;
8848
+ const oRow = sourceDataRowIdData[rowid];
8849
+ if (oRow) {
8832
8850
  if (arguments.length > 1) {
8833
8851
  return !eqCellValue(oRow, row, field);
8834
8852
  }
@@ -8890,6 +8908,113 @@ const Methods = {
8890
8908
  tableColumn: this.tableColumn.slice(0)
8891
8909
  };
8892
8910
  },
8911
+ /**
8912
+ * 移动列到指定列的位置
8913
+ * @param fieldOrColumn
8914
+ * @param targetFieldOrColumn
8915
+ * @param options
8916
+ */
8917
+ moveColumnTo(fieldOrColumn, targetFieldOrColumn, options) {
8918
+ const $xeTable = this;
8919
+ const internalData = $xeTable;
8920
+ const {
8921
+ fullColumnIdData,
8922
+ visibleColumn
8923
+ } = internalData;
8924
+ const {
8925
+ dragToChild,
8926
+ dragPos,
8927
+ isCrossDrag
8928
+ } = Object.assign({}, options);
8929
+ const dragCol = handleFieldOrColumn($xeTable, fieldOrColumn);
8930
+ let prevDragCol = null;
8931
+ const colRest = dragCol ? fullColumnIdData[dragCol.id] : null;
8932
+ let defPos = 'left';
8933
+ if (external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isNumber(targetFieldOrColumn)) {
8934
+ if (colRest && targetFieldOrColumn) {
8935
+ let currList = colRest.items;
8936
+ let offsetIndex = colRest._index + targetFieldOrColumn;
8937
+ if (isCrossDrag) {
8938
+ currList = visibleColumn;
8939
+ offsetIndex = colRest._index + targetFieldOrColumn;
8940
+ }
8941
+ if (offsetIndex > 0 && offsetIndex < currList.length - 1) {
8942
+ prevDragCol = currList[offsetIndex];
8943
+ }
8944
+ if (targetFieldOrColumn > 0) {
8945
+ defPos = 'right';
8946
+ }
8947
+ }
8948
+ } else {
8949
+ prevDragCol = handleFieldOrColumn($xeTable, targetFieldOrColumn);
8950
+ const targetColRest = prevDragCol ? fullColumnIdData[prevDragCol.id] : null;
8951
+ if (colRest && targetColRest) {
8952
+ if (targetColRest._index > colRest._index) {
8953
+ defPos = 'right';
8954
+ }
8955
+ }
8956
+ }
8957
+ return $xeTable.handleColDragSwapEvent(null, true, dragCol, prevDragCol, dragPos || defPos, dragToChild === true);
8958
+ },
8959
+ /**
8960
+ * 移动行到指定行的位置
8961
+ * @param rowidOrRow
8962
+ * @param targetRowidOrRow
8963
+ * @param options
8964
+ */
8965
+ moveRowTo(rowidOrRow, targetRowidOrRow, options) {
8966
+ const $xeTable = this;
8967
+ const props = $xeTable;
8968
+ const internalData = $xeTable;
8969
+ const {
8970
+ treeConfig
8971
+ } = props;
8972
+ const {
8973
+ fullAllDataRowIdData,
8974
+ afterFullData
8975
+ } = internalData;
8976
+ const {
8977
+ dragToChild,
8978
+ dragPos,
8979
+ isCrossDrag
8980
+ } = Object.assign({}, options);
8981
+ const treeOpts = $xeTable.computeTreeOpts;
8982
+ const dragRow = handleRowidOrRow($xeTable, rowidOrRow);
8983
+ let prevDragRow = null;
8984
+ let defPos = 'top';
8985
+ const rowRest = dragRow ? fullAllDataRowIdData[getRowid($xeTable, dragRow)] : null;
8986
+ if (external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().isNumber(targetRowidOrRow)) {
8987
+ if (rowRest && targetRowidOrRow) {
8988
+ let currList = afterFullData;
8989
+ let offsetIndex = rowRest._index + targetRowidOrRow;
8990
+ if (treeConfig) {
8991
+ currList = rowRest.items;
8992
+ if (treeOpts.transform) {
8993
+ offsetIndex = rowRest.treeIndex + targetRowidOrRow;
8994
+ if (isCrossDrag) {
8995
+ currList = afterFullData;
8996
+ offsetIndex = rowRest._index + targetRowidOrRow;
8997
+ }
8998
+ }
8999
+ }
9000
+ if (offsetIndex >= 0 && offsetIndex <= currList.length - 1) {
9001
+ prevDragRow = currList[offsetIndex];
9002
+ }
9003
+ if (targetRowidOrRow > 0) {
9004
+ defPos = 'bottom';
9005
+ }
9006
+ }
9007
+ } else {
9008
+ prevDragRow = handleRowidOrRow($xeTable, targetRowidOrRow);
9009
+ const targetRowRest = prevDragRow ? fullAllDataRowIdData[getRowid($xeTable, prevDragRow)] : null;
9010
+ if (rowRest && targetRowRest) {
9011
+ if (targetRowRest._index > rowRest._index) {
9012
+ defPos = 'bottom';
9013
+ }
9014
+ }
9015
+ }
9016
+ return $xeTable.handleRowDragSwapEvent(null, true, dragRow, prevDragRow, dragPos || defPos, dragToChild === true);
9017
+ },
8893
9018
  /**
8894
9019
  * 获取表格的全量列
8895
9020
  */
@@ -8912,16 +9037,26 @@ const Methods = {
8912
9037
  * 用于多选行,获取已选中的数据
8913
9038
  */
8914
9039
  getCheckboxRecords(isFull) {
9040
+ const $xeTable = this;
9041
+ const props = $xeTable;
9042
+ const reactData = $xeTable;
9043
+ const internalData = $xeTable;
9044
+ const {
9045
+ treeConfig
9046
+ } = props;
9047
+ const {
9048
+ selectCheckboxMaps
9049
+ } = reactData;
8915
9050
  const {
8916
9051
  tableFullData,
8917
9052
  afterFullData,
8918
- treeConfig,
8919
- treeOpts,
8920
- checkboxOpts,
8921
- tableFullTreeData,
8922
9053
  afterTreeFullData,
9054
+ tableFullTreeData,
9055
+ fullDataRowIdData,
8923
9056
  afterFullRowMaps
8924
- } = this;
9057
+ } = internalData;
9058
+ const treeOpts = $xeTable.computeTreeOpts;
9059
+ const checkboxOpts = $xeTable.computeCheckboxOpts;
8925
9060
  const {
8926
9061
  transform,
8927
9062
  mapChildrenField
@@ -8930,21 +9065,18 @@ const Methods = {
8930
9065
  checkField
8931
9066
  } = checkboxOpts;
8932
9067
  const childrenField = treeOpts.children || treeOpts.childrenField;
8933
- const currTableData = isFull ? transform ? tableFullTreeData : tableFullData : transform ? afterTreeFullData : afterFullData;
8934
9068
  let rowList = [];
8935
9069
  if (checkField) {
8936
9070
  if (treeConfig) {
9071
+ const currTableData = isFull ? transform ? tableFullTreeData : tableFullData : transform ? afterTreeFullData : afterFullData;
8937
9072
  rowList = external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().filterTree(currTableData, row => external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().get(row, checkField), {
8938
9073
  children: transform ? mapChildrenField : childrenField
8939
9074
  });
8940
9075
  } else {
9076
+ const currTableData = isFull ? tableFullData : afterFullData;
8941
9077
  rowList = currTableData.filter(row => external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().get(row, checkField));
8942
9078
  }
8943
9079
  } else {
8944
- const {
8945
- selectCheckboxMaps,
8946
- fullDataRowIdData
8947
- } = this;
8948
9080
  external_root_XEUtils_commonjs_xe_utils_commonjs2_xe_utils_amd_xe_utils_default().each(selectCheckboxMaps, (row, rowid) => {
8949
9081
  if (isFull) {
8950
9082
  if (fullDataRowIdData[rowid]) {
@@ -11424,6 +11556,7 @@ const Methods = {
11424
11556
  checkStrictly,
11425
11557
  checkMethod
11426
11558
  } = checkboxOpts;
11559
+ // indeterminateField 仅支持读取
11427
11560
  const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
11428
11561
  if (checkField) {
11429
11562
  // 树结构
@@ -11950,6 +12083,7 @@ const Methods = {
11950
12083
  reserve
11951
12084
  } = checkboxOpts;
11952
12085
  const childrenField = treeOpts.children || treeOpts.childrenField;
12086
+ // indeterminateField 仅支持读取
11953
12087
  const indeterminateField = checkboxOpts.indeterminateField || checkboxOpts.halfField;
11954
12088
  if (checkField) {
11955
12089
  const handleClearChecked = item => {
@@ -12723,6 +12857,9 @@ const Methods = {
12723
12857
  } = internalData;
12724
12858
  const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null);
12725
12859
  const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0;
12860
+ const errRest = {
12861
+ status: false
12862
+ };
12726
12863
  if (prevDragRow && dragRow) {
12727
12864
  // 判断是否有拖动
12728
12865
  if (prevDragRow !== dragRow) {
@@ -12737,7 +12874,7 @@ const Methods = {
12737
12874
  const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
12738
12875
  return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then(status => {
12739
12876
  if (!status) {
12740
- return;
12877
+ return errRest;
12741
12878
  }
12742
12879
  let oafIndex = -1;
12743
12880
  let nafIndex = -1;
@@ -12768,11 +12905,11 @@ const Methods = {
12768
12905
  if (isPeerDrag && !isCrossDrag) {
12769
12906
  if (oldRest.row[parentField] !== newRest.row[parentField]) {
12770
12907
  // 非同级
12771
- return;
12908
+ return errRest;
12772
12909
  }
12773
12910
  } else {
12774
12911
  if (!isCrossDrag) {
12775
- return;
12912
+ return errRest;
12776
12913
  }
12777
12914
  if (oldAllMaps[newRowid]) {
12778
12915
  isSelfToChildStatus = true;
@@ -12783,19 +12920,19 @@ const Methods = {
12783
12920
  content: methods_getI18n('vxe.error.treeDragChild')
12784
12921
  });
12785
12922
  }
12786
- return;
12923
+ return errRest;
12787
12924
  }
12788
12925
  }
12789
12926
  }
12790
12927
  } else if (oldLevel) {
12791
12928
  // 子到根
12792
12929
  if (!isCrossDrag) {
12793
- return;
12930
+ return errRest;
12794
12931
  }
12795
12932
  } else if (newLevel) {
12796
12933
  // 根到子
12797
12934
  if (!isCrossDrag) {
12798
- return;
12935
+ return errRest;
12799
12936
  }
12800
12937
  if (oldAllMaps[newRowid]) {
12801
12938
  isSelfToChildStatus = true;
@@ -12806,7 +12943,7 @@ const Methods = {
12806
12943
  content: methods_getI18n('vxe.error.treeDragChild')
12807
12944
  });
12808
12945
  }
12809
- return;
12946
+ return errRest;
12810
12947
  }
12811
12948
  }
12812
12949
  } else {
@@ -12864,26 +13001,34 @@ const Methods = {
12864
13001
  if (reactData.scrollYLoad) {
12865
13002
  $xeTable.updateScrollYSpace();
12866
13003
  }
12867
- $xeTable.$nextTick().then(() => {
13004
+ if (evnt) {
13005
+ $xeTable.dispatchEvent('row-dragend', {
13006
+ oldRow: dragRow,
13007
+ newRow: prevDragRow,
13008
+ dragRow,
13009
+ dragPos: prevDragPos,
13010
+ dragToChild: isDragToChildFlag,
13011
+ offsetIndex: dragOffsetIndex,
13012
+ _index: {
13013
+ newIndex: nafIndex,
13014
+ oldIndex: oafIndex
13015
+ }
13016
+ }, evnt);
13017
+ }
13018
+ return $xeTable.$nextTick().then(() => {
12868
13019
  $xeTable.updateCellAreas();
12869
13020
  $xeTable.recalculate();
13021
+ }).then(() => {
13022
+ return {
13023
+ status: true
13024
+ };
12870
13025
  });
12871
- $xeTable.dispatchEvent('row-dragend', {
12872
- oldRow: dragRow,
12873
- newRow: prevDragRow,
12874
- dragRow,
12875
- dragPos: prevDragPos,
12876
- dragToChild: isDragToChildFlag,
12877
- offsetIndex: dragOffsetIndex,
12878
- _index: {
12879
- newIndex: nafIndex,
12880
- oldIndex: oafIndex
12881
- }
12882
- }, evnt);
12883
- }).catch(() => {});
13026
+ }).catch(() => {
13027
+ return errRest;
13028
+ });
12884
13029
  }
12885
13030
  }
12886
- return Promise.resolve();
13031
+ return Promise.resolve(errRest);
12887
13032
  },
12888
13033
  handleRowDragDragendEvent(evnt) {
12889
13034
  const $xeTable = this;
@@ -13069,6 +13214,9 @@ const Methods = {
13069
13214
  collectColumn
13070
13215
  } = internalData;
13071
13216
  const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0;
13217
+ const errRest = {
13218
+ status: false
13219
+ };
13072
13220
  if (prevDragCol && dragCol) {
13073
13221
  // 判断是否有拖动
13074
13222
  if (prevDragCol !== dragCol) {
@@ -13085,7 +13233,7 @@ const Methods = {
13085
13233
  const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
13086
13234
  return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then(status => {
13087
13235
  if (!status) {
13088
- return;
13236
+ return errRest;
13089
13237
  }
13090
13238
  let oafIndex = -1;
13091
13239
  let nafIndex = -1;
@@ -13099,11 +13247,11 @@ const Methods = {
13099
13247
  if (isPeerDrag && !isCrossDrag) {
13100
13248
  if (dragColumn.parentId !== newColumn.parentId) {
13101
13249
  // 非同级
13102
- return;
13250
+ return errRest;
13103
13251
  }
13104
13252
  } else {
13105
13253
  if (!isCrossDrag) {
13106
- return;
13254
+ return errRest;
13107
13255
  }
13108
13256
  if (oldAllMaps[newColumn.id]) {
13109
13257
  isSelfToChildStatus = true;
@@ -13114,19 +13262,19 @@ const Methods = {
13114
13262
  content: methods_getI18n('vxe.error.treeDragChild')
13115
13263
  });
13116
13264
  }
13117
- return;
13265
+ return errRest;
13118
13266
  }
13119
13267
  }
13120
13268
  }
13121
13269
  } else if (dragColumn.parentId) {
13122
13270
  // 子到根
13123
13271
  if (!isCrossDrag) {
13124
- return;
13272
+ return errRest;
13125
13273
  }
13126
13274
  } else if (newColumn.parentId) {
13127
13275
  // 根到子
13128
13276
  if (!isCrossDrag) {
13129
- return;
13277
+ return errRest;
13130
13278
  }
13131
13279
  if (oldAllMaps[newColumn.id]) {
13132
13280
  isSelfToChildStatus = true;
@@ -13137,7 +13285,7 @@ const Methods = {
13137
13285
  content: methods_getI18n('vxe.error.treeDragChild')
13138
13286
  });
13139
13287
  }
13140
- return;
13288
+ return errRest;
13141
13289
  }
13142
13290
  }
13143
13291
  } else {
@@ -13206,25 +13354,32 @@ const Methods = {
13206
13354
  $xeTable.clearCopyCellArea();
13207
13355
  }
13208
13356
  }
13209
- $xeTable.dispatchEvent('column-dragend', {
13210
- oldColumn: dragColumn,
13211
- newColumn,
13212
- dragColumn,
13213
- dragPos: prevDragPos,
13214
- dragToChild: isDragToChildFlag,
13215
- offsetIndex: dragOffsetIndex,
13216
- _index: {
13217
- newIndex: nafIndex,
13218
- oldIndex: oafIndex
13219
- }
13220
- }, evnt);
13357
+ if (evnt) {
13358
+ $xeTable.dispatchEvent('column-dragend', {
13359
+ oldColumn: dragColumn,
13360
+ newColumn,
13361
+ dragColumn,
13362
+ dragPos: prevDragPos,
13363
+ dragToChild: isDragToChildFlag,
13364
+ offsetIndex: dragOffsetIndex,
13365
+ _index: {
13366
+ newIndex: nafIndex,
13367
+ oldIndex: oafIndex
13368
+ }
13369
+ }, evnt);
13370
+ }
13221
13371
  if (isSyncColumn) {
13222
13372
  $xeTable.handleColDragSwapColumn();
13223
13373
  }
13224
- }).catch(() => {});
13374
+ return {
13375
+ status: true
13376
+ };
13377
+ }).catch(() => {
13378
+ return errRest;
13379
+ });
13225
13380
  }
13226
13381
  }
13227
- return Promise.resolve();
13382
+ return Promise.resolve(errRest);
13228
13383
  },
13229
13384
  handleHeaderCellDragDragendEvent(evnt) {
13230
13385
  const $xeTable = this;
@@ -28759,6 +28914,10 @@ Object.keys(table.methods).forEach(name => {
28759
28914
  }
28760
28915
  return [];
28761
28916
  },
28917
+ getEl() {
28918
+ const $xeGrid = this;
28919
+ return $xeGrid.$refs.refElem;
28920
+ },
28762
28921
  /**
28763
28922
  * 获取需要排除的高度
28764
28923
  */