vxe-table 3.16.0-beta.1 → 3.16.0-beta.2

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.
Files changed (73) hide show
  1. package/es/grid/src/grid.js +17 -5
  2. package/es/index.css +1 -1
  3. package/es/index.min.css +1 -1
  4. package/es/style.css +1 -1
  5. package/es/style.min.css +1 -1
  6. package/es/table/module/custom/mixin.js +0 -4
  7. package/es/table/module/custom/panel.js +0 -1
  8. package/es/table/src/anime.js +46 -0
  9. package/es/table/src/body.js +15 -40
  10. package/es/table/src/columnInfo.js +5 -0
  11. package/es/table/src/footer.js +1 -19
  12. package/es/table/src/header.js +1 -19
  13. package/es/table/src/methods.js +532 -346
  14. package/es/table/src/table.js +21 -2
  15. package/es/table/style.css +8 -8
  16. package/es/table/style.min.css +1 -1
  17. package/es/ui/index.js +2 -1
  18. package/es/ui/src/log.js +1 -1
  19. package/es/vxe-table/style.css +8 -8
  20. package/es/vxe-table/style.min.css +1 -1
  21. package/lib/grid/src/grid.js +22 -7
  22. package/lib/grid/src/grid.min.js +1 -1
  23. package/lib/index.css +1 -1
  24. package/lib/index.min.css +1 -1
  25. package/lib/index.umd.js +642 -436
  26. package/lib/index.umd.min.js +1 -1
  27. package/lib/style.css +1 -1
  28. package/lib/style.min.css +1 -1
  29. package/lib/table/module/custom/mixin.js +0 -4
  30. package/lib/table/module/custom/mixin.min.js +1 -1
  31. package/lib/table/module/custom/panel.js +0 -1
  32. package/lib/table/module/custom/panel.min.js +1 -1
  33. package/lib/table/src/anime.js +56 -0
  34. package/lib/table/src/anime.min.js +1 -0
  35. package/lib/table/src/body.js +3 -28
  36. package/lib/table/src/body.min.js +1 -1
  37. package/lib/table/src/columnInfo.js +5 -0
  38. package/lib/table/src/columnInfo.min.js +1 -1
  39. package/lib/table/src/footer.js +1 -19
  40. package/lib/table/src/footer.min.js +1 -1
  41. package/lib/table/src/header.js +1 -19
  42. package/lib/table/src/header.min.js +1 -1
  43. package/lib/table/src/methods.js +539 -355
  44. package/lib/table/src/methods.min.js +1 -1
  45. package/lib/table/src/table.js +21 -1
  46. package/lib/table/src/table.min.js +1 -1
  47. package/lib/table/style/style.css +8 -8
  48. package/lib/table/style/style.min.css +1 -1
  49. package/lib/ui/index.js +2 -1
  50. package/lib/ui/index.min.js +1 -1
  51. package/lib/ui/src/log.js +1 -1
  52. package/lib/ui/src/log.min.js +1 -1
  53. package/lib/vxe-table/style/style.css +8 -8
  54. package/lib/vxe-table/style/style.min.css +1 -1
  55. package/package.json +1 -1
  56. package/packages/grid/src/grid.ts +19 -6
  57. package/packages/table/module/custom/mixin.ts +0 -4
  58. package/packages/table/module/custom/panel.ts +0 -1
  59. package/packages/table/src/anime.ts +52 -0
  60. package/packages/table/src/body.ts +15 -40
  61. package/packages/table/src/columnInfo.ts +5 -0
  62. package/packages/table/src/footer.ts +1 -19
  63. package/packages/table/src/header.ts +1 -20
  64. package/packages/table/src/methods.ts +554 -360
  65. package/packages/table/src/table.ts +21 -2
  66. package/packages/ui/index.ts +1 -0
  67. package/styles/components/table.scss +9 -9
  68. /package/es/{iconfont.1750910486943.ttf → iconfont.1751194972120.ttf} +0 -0
  69. /package/es/{iconfont.1750910486943.woff → iconfont.1751194972120.woff} +0 -0
  70. /package/es/{iconfont.1750910486943.woff2 → iconfont.1751194972120.woff2} +0 -0
  71. /package/lib/{iconfont.1750910486943.ttf → iconfont.1751194972120.ttf} +0 -0
  72. /package/lib/{iconfont.1750910486943.woff → iconfont.1751194972120.woff} +0 -0
  73. /package/lib/{iconfont.1750910486943.woff2 → iconfont.1751194972120.woff2} +0 -0
@@ -11,6 +11,7 @@ var _ui = require("../../ui");
11
11
  var _cell = _interopRequireDefault(require("./cell"));
12
12
  var _util = require("./util");
13
13
  var _vn = require("../../ui/src/vn");
14
+ var _anime = require("./anime");
14
15
  var _log = require("../../ui/src/log");
15
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
17
  const {
@@ -514,7 +515,7 @@ function handleVirtualTreeExpand($xeTable, rows, expanded) {
514
515
  updateAfterDataIndex($xeTable);
515
516
  return $xeTable.$nextTick();
516
517
  }).then(() => {
517
- return $xeTable.recalculate(true);
518
+ return handleLazyRecalculate($xeTable, true, true, true);
518
519
  }).then(() => {
519
520
  setTimeout(() => {
520
521
  $xeTable.updateCellAreas();
@@ -599,7 +600,7 @@ function handleRowGroupVirtualExpand($xeTable, rows, expanded) {
599
600
  updateAfterDataIndex($xeTable);
600
601
  return $xeTable.$nextTick();
601
602
  }).then(() => {
602
- return $xeTable.recalculate(true);
603
+ return handleLazyRecalculate($xeTable, true, true, true);
603
604
  }).then(() => {
604
605
  setTimeout(() => {
605
606
  $xeTable.updateCellAreas();
@@ -2719,8 +2720,6 @@ function clearDragStatus($xeTable) {
2719
2720
  hideDropTip($xeTable);
2720
2721
  reactData.dragRow = null;
2721
2722
  reactData.dragCol = null;
2722
- reactData.isDragColMove = false;
2723
- reactData.isDragRowMove = false;
2724
2723
  }
2725
2724
  }
2726
2725
  function clearRowDropOrigin($xeTable) {
@@ -3102,7 +3101,7 @@ function calcScrollbar($xeTable) {
3102
3101
  $xeTable.checkScrolling();
3103
3102
  }
3104
3103
  }
3105
- function handleRecalculateLayout($xeTable, reFull) {
3104
+ function handleRecalculateStyle($xeTable, reFull, reWidth, reHeight) {
3106
3105
  const internalData = $xeTable;
3107
3106
  const el = $xeTable.$refs.refElem;
3108
3107
  internalData.rceRunTime = Date.now();
@@ -3117,19 +3116,28 @@ function handleRecalculateLayout($xeTable, reFull) {
3117
3116
  calcVarRowHeightConfig($xeTable, 'small', smallEl);
3118
3117
  calcVarRowHeightConfig($xeTable, 'mini', miniEl);
3119
3118
  }
3120
- calcCellWidth($xeTable);
3121
- autoCellWidth($xeTable);
3119
+ if (reWidth) {
3120
+ calcCellWidth($xeTable);
3121
+ }
3122
+ if (reFull) {
3123
+ autoCellWidth($xeTable);
3124
+ }
3122
3125
  calcScrollbar($xeTable);
3123
3126
  updateStyle($xeTable);
3124
3127
  updateRowExpandStyle($xeTable);
3125
3128
  return computeScrollLoad($xeTable).then(() => {
3126
3129
  // 初始化时需要在列计算之后再执行优化运算,达到最优显示效果
3127
- calcCellWidth($xeTable);
3130
+ if (reWidth) {
3131
+ calcCellWidth($xeTable);
3132
+ }
3128
3133
  if (reFull) {
3129
3134
  autoCellWidth($xeTable);
3130
3135
  }
3131
- calcScrollbar($xeTable);
3136
+ if (reHeight) {
3137
+ calcCellHeight($xeTable);
3138
+ }
3132
3139
  updateStyle($xeTable);
3140
+ calcScrollbar($xeTable);
3133
3141
  if (reFull) {
3134
3142
  updateRowOffsetTop($xeTable);
3135
3143
  }
@@ -3139,6 +3147,38 @@ function handleRecalculateLayout($xeTable, reFull) {
3139
3147
  }
3140
3148
  });
3141
3149
  }
3150
+ function handleLazyRecalculate($xeTable, reFull, reWidth, reHeight) {
3151
+ const internalData = $xeTable;
3152
+ return new Promise(resolve => {
3153
+ const {
3154
+ rceTimeout,
3155
+ rceRunTime
3156
+ } = internalData;
3157
+ const resizeOpts = $xeTable.computeResizeOpts;
3158
+ const refreshDelay = resizeOpts.refreshDelay || 20;
3159
+ const el = $xeTable.$refs.refElem;
3160
+ if (el && el.clientWidth) {
3161
+ autoCellWidth($xeTable);
3162
+ updateRowExpandStyle($xeTable);
3163
+ }
3164
+ if (rceTimeout) {
3165
+ clearTimeout(rceTimeout);
3166
+ if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
3167
+ resolve(handleRecalculateStyle($xeTable, !!reFull, reWidth, reHeight));
3168
+ } else {
3169
+ $xeTable.$nextTick(() => {
3170
+ resolve();
3171
+ });
3172
+ }
3173
+ } else {
3174
+ resolve(handleRecalculateStyle($xeTable, !!reFull, reWidth, reHeight));
3175
+ }
3176
+ internalData.rceTimeout = setTimeout(() => {
3177
+ internalData.rceTimeout = undefined;
3178
+ handleRecalculateStyle($xeTable, !!reFull, reWidth, reHeight);
3179
+ }, refreshDelay);
3180
+ });
3181
+ }
3142
3182
  function handleUpdateAggValues($xeTable) {
3143
3183
  const reactData = $xeTable;
3144
3184
  const internalData = $xeTable;
@@ -3398,8 +3438,6 @@ function loadTableData($xeTable, datas, isReset) {
3398
3438
  internalData.removeRowMaps = {};
3399
3439
  reactData.removeRowFlag++;
3400
3440
  const sYLoad = updateScrollYStatus($xeTable, fullData);
3401
- reactData.isDragColMove = false;
3402
- reactData.isDragRowMove = false;
3403
3441
  // 全量数据
3404
3442
  internalData.tableFullData = fullData;
3405
3443
  internalData.tableFullTreeData = isRGroup ? [] : treeData;
@@ -3459,10 +3497,10 @@ function loadTableData($xeTable, datas, isReset) {
3459
3497
  handleReserveStatus($xeTable);
3460
3498
  $xeTable.checkSelectionStatus();
3461
3499
  return new Promise(resolve => {
3462
- $xeTable.$nextTick().then(() => handleRecalculateLayout($xeTable, false)).then(() => {
3500
+ $xeTable.$nextTick().then(() => handleRecalculateStyle($xeTable, false, false, false)).then(() => {
3463
3501
  calcCellHeight($xeTable);
3464
3502
  updateRowOffsetTop($xeTable);
3465
- return handleRecalculateLayout($xeTable, false);
3503
+ return handleRecalculateStyle($xeTable, false, false, false);
3466
3504
  }).then(() => {
3467
3505
  let targetScrollLeft = lastScrollLeft;
3468
3506
  let targetScrollTop = lastScrollTop;
@@ -3476,7 +3514,7 @@ function loadTableData($xeTable, datas, isReset) {
3476
3514
  targetScrollTop = 0;
3477
3515
  }
3478
3516
  reactData.isRowLoading = false;
3479
- handleRecalculateLayout($xeTable, false);
3517
+ handleRecalculateStyle($xeTable, false, false, false);
3480
3518
  // 是否变更虚拟滚动
3481
3519
  if (oldScrollYLoad === sYLoad) {
3482
3520
  (0, _util.restoreScrollLocation)($xeTable, targetScrollLeft, targetScrollTop).then(() => {
@@ -3753,7 +3791,6 @@ function handleColumn($xeTable, collectColumn) {
3753
3791
  const tableFullColumn = getColumnList(collectColumn);
3754
3792
  internalData.tableFullColumn = tableFullColumn;
3755
3793
  reactData.isColLoading = true;
3756
- reactData.isDragColMove = false;
3757
3794
  initColumnSort($xeTable);
3758
3795
  return Promise.resolve(restoreCustomStorage($xeTable)).then(() => {
3759
3796
  const {
@@ -4309,10 +4346,10 @@ const Methods = {
4309
4346
  }
4310
4347
  }).then(() => {
4311
4348
  $xeTable.updateCellAreas();
4312
- return $xeTable.recalculate(true);
4349
+ return handleLazyRecalculate($xeTable, true, true, true);
4313
4350
  }).then(() => {
4314
4351
  // 存在滚动行为未结束情况
4315
- setTimeout(() => $xeTable.recalculate(), 50);
4352
+ setTimeout(() => handleLazyRecalculate($xeTable, false, true, true), 50);
4316
4353
  });
4317
4354
  },
4318
4355
  handleTableData(force) {
@@ -4371,7 +4408,7 @@ const Methods = {
4371
4408
  if (!initStatus) {
4372
4409
  handleLoadDefaults($xeTable);
4373
4410
  }
4374
- return this.recalculate();
4411
+ return handleLazyRecalculate($xeTable, false, true, true);
4375
4412
  });
4376
4413
  },
4377
4414
  /**
@@ -4386,7 +4423,7 @@ const Methods = {
4386
4423
  return loadTableData($xeTable, datas, true);
4387
4424
  }).then(() => {
4388
4425
  handleLoadDefaults($xeTable);
4389
- return this.recalculate();
4426
+ return handleLazyRecalculate($xeTable, false, true, true);
4390
4427
  });
4391
4428
  },
4392
4429
  /**
@@ -4979,7 +5016,7 @@ const Methods = {
4979
5016
  }
4980
5017
  return $xeTable.$nextTick().then(() => {
4981
5018
  $xeTable.updateCellAreas();
4982
- return $xeTable.recalculate();
5019
+ return handleLazyRecalculate($xeTable, false, true, true);
4983
5020
  });
4984
5021
  }
4985
5022
  return $xeTable.reloadData(tableSourceData);
@@ -5986,7 +6023,7 @@ const Methods = {
5986
6023
  return parseColumns($xeTable, true).then(() => {
5987
6024
  return this.refreshScroll();
5988
6025
  }).then(() => {
5989
- return this.recalculate();
6026
+ return handleLazyRecalculate($xeTable, false, true, true);
5990
6027
  });
5991
6028
  },
5992
6029
  /**
@@ -6592,36 +6629,8 @@ const Methods = {
6592
6629
  */
6593
6630
  recalculate(reFull) {
6594
6631
  const $xeTable = this;
6595
- const internalData = $xeTable;
6596
- return new Promise(resolve => {
6597
- const {
6598
- rceTimeout,
6599
- rceRunTime
6600
- } = internalData;
6601
- const resizeOpts = $xeTable.computeResizeOpts;
6602
- const refreshDelay = resizeOpts.refreshDelay || 20;
6603
- const el = $xeTable.$refs.refElem;
6604
- if (el && el.clientWidth) {
6605
- autoCellWidth($xeTable);
6606
- updateRowExpandStyle($xeTable);
6607
- }
6608
- if (rceTimeout) {
6609
- clearTimeout(rceTimeout);
6610
- if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
6611
- resolve(handleRecalculateLayout($xeTable, !!reFull));
6612
- } else {
6613
- $xeTable.$nextTick(() => {
6614
- resolve();
6615
- });
6616
- }
6617
- } else {
6618
- resolve(handleRecalculateLayout($xeTable, !!reFull));
6619
- }
6620
- internalData.rceTimeout = setTimeout(() => {
6621
- internalData.rceTimeout = undefined;
6622
- handleRecalculateLayout($xeTable, !!reFull);
6623
- }, refreshDelay);
6624
- });
6632
+ const isForce = !!reFull;
6633
+ return handleLazyRecalculate($xeTable, isForce, isForce, isForce);
6625
6634
  },
6626
6635
  updateStyle() {
6627
6636
  const $xeTable = this;
@@ -7294,9 +7303,11 @@ const Methods = {
7294
7303
  }
7295
7304
  },
7296
7305
  handleGlobalResizeEvent() {
7297
- this.closeMenu();
7298
- this.updateCellAreas();
7299
- this.recalculate(true);
7306
+ const $xeTable = this;
7307
+ $xeTable.closeMenu();
7308
+ $xeTable.updateCellAreas();
7309
+ handleLazyRecalculate($xeTable, true, true, true);
7310
+ $xeTable.updateCellAreas();
7300
7311
  },
7301
7312
  /**
7302
7313
  * 处理合并
@@ -7996,7 +8007,8 @@ const Methods = {
7996
8007
  const childList = vals[2];
7997
8008
  let sLen = 0; // 已选
7998
8009
  let hLen = 0; // 半选
7999
- let vLen = 0; // 有效行
8010
+ let vLen = 0; // 有效子行
8011
+ const cLen = childList.length; // 有效子行
8000
8012
  childList.forEach(checkMethod ? item => {
8001
8013
  const childRowid = handleGetRowId(item);
8002
8014
  const isSelect = checkField ? _xeUtils.default.get(item, checkField) : selectCheckboxMaps[childRowid];
@@ -8027,18 +8039,25 @@ const Methods = {
8027
8039
  }
8028
8040
  vLen++;
8029
8041
  });
8030
- let isSelected = sLen >= vLen && (vLen >= 1 || hLen >= 1);
8031
- if (checkMethod) {
8032
- if (checkMethod({
8033
- $table: $xeTable,
8034
- row
8035
- })) {
8036
- isSelected = sLen >= vLen;
8042
+ let isSelected = false;
8043
+ if (cLen > 0) {
8044
+ if (vLen > 0) {
8045
+ isSelected = (sLen > 0 || hLen > 0) && sLen >= vLen;
8037
8046
  } else {
8038
- isSelected = selectCheckboxMaps[rowid];
8047
+ // 如果存在子项禁用
8048
+ if (sLen > 0 && sLen >= vLen) {
8049
+ isSelected = true;
8050
+ } else if (selectCheckboxMaps[rowid]) {
8051
+ isSelected = true;
8052
+ } else {
8053
+ isSelected = false;
8054
+ }
8039
8055
  }
8056
+ } else {
8057
+ // 如果无子项
8058
+ isSelected = selectCheckboxMaps[rowid];
8040
8059
  }
8041
- const halfSelect = !isSelected && (sLen >= 1 || hLen >= 1);
8060
+ const halfSelect = !isSelected && (sLen > 0 || hLen > 0);
8042
8061
  if (checkField) {
8043
8062
  _xeUtils.default.set(row, checkField, isSelected);
8044
8063
  }
@@ -8096,7 +8115,9 @@ const Methods = {
8096
8115
  handleGetRowId
8097
8116
  } = (0, _util.createHandleGetRowId)($xeTable);
8098
8117
  let sLen = 0; // 已选
8118
+ let dsLen = 0; // 禁用的已选
8099
8119
  let hLen = 0; // 半选
8120
+ let dhLen = 0; // 禁用的半选
8100
8121
  let vLen = 0; // 有效行
8101
8122
  const rootList = treeConfig ? afterTreeFullData : isRowGroupStatus ? afterGroupFullData : afterFullData;
8102
8123
  rootList.forEach(checkMethod ? row => {
@@ -8114,9 +8135,9 @@ const Methods = {
8114
8135
  vLen++;
8115
8136
  } else {
8116
8137
  if (selected) {
8117
- sLen++;
8138
+ dsLen++;
8118
8139
  } else if (treeIndeterminateRowMaps[childRowid]) {
8119
- hLen++;
8140
+ dhLen++;
8120
8141
  }
8121
8142
  }
8122
8143
  } : row => {
@@ -8130,7 +8151,7 @@ const Methods = {
8130
8151
  vLen++;
8131
8152
  });
8132
8153
  const isSelected = rootList.length > 0 ? vLen > 0 ? sLen >= vLen : sLen >= rootList.length : false;
8133
- let halfSelect = !isSelected && (sLen >= 1 || hLen >= 1);
8154
+ let halfSelect = !isSelected && (sLen > 0 || hLen > 0 || dsLen > 0 || dhLen > 0);
8134
8155
  // 如果复选框启用保留记录,当保留数据存在时显示半选
8135
8156
  if (!isSelected && !halfSelect && showReserveStatus) {
8136
8157
  halfSelect = !_xeUtils.default.isEmpty(checkboxReserveRowMap);
@@ -9068,6 +9089,7 @@ const Methods = {
9068
9089
  fullAllDataRowIdData
9069
9090
  } = internalData;
9070
9091
  const {
9092
+ animation,
9071
9093
  isPeerDrag,
9072
9094
  isCrossDrag,
9073
9095
  isSelfToChildDrag,
@@ -9075,6 +9097,9 @@ const Methods = {
9075
9097
  dragToChildMethod
9076
9098
  } = rowDragOpts;
9077
9099
  const treeOpts = $xeTable.computeTreeOpts;
9100
+ const cellOpts = $xeTable.computeCellOpts;
9101
+ const rowOpts = $xeTable.computeRowOpts;
9102
+ const defaultRowHeight = $xeTable.computeDefaultRowHeight;
9078
9103
  const {
9079
9104
  transform,
9080
9105
  rowField,
@@ -9084,80 +9109,71 @@ const Methods = {
9084
9109
  const childrenField = treeOpts.children || treeOpts.childrenField;
9085
9110
  const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null);
9086
9111
  const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0;
9112
+ const el = $xeTable.$refs.refElem;
9087
9113
  const errRest = {
9088
9114
  status: false
9089
9115
  };
9090
- if (prevDragRow && dragRow) {
9091
- // 判断是否有拖动
9092
- if (prevDragRow !== dragRow) {
9093
- const dragParams = {
9094
- oldRow: dragRow,
9095
- newRow: prevDragRow,
9096
- dragRow,
9097
- dragPos: prevDragPos,
9098
- dragToChild: !!prevDragToChild,
9099
- offsetIndex: dragOffsetIndex
9100
- };
9101
- const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
9102
- return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then(status => {
9103
- if (!status) {
9104
- return errRest;
9116
+ if (!(el && prevDragRow && dragRow)) {
9117
+ return Promise.resolve(errRest);
9118
+ }
9119
+ // 判断是否有拖动
9120
+ if (prevDragRow !== dragRow) {
9121
+ const dragParams = {
9122
+ oldRow: dragRow,
9123
+ newRow: prevDragRow,
9124
+ dragRow,
9125
+ dragPos: prevDragPos,
9126
+ dragToChild: !!prevDragToChild,
9127
+ offsetIndex: dragOffsetIndex
9128
+ };
9129
+ const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
9130
+ return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then(status => {
9131
+ if (!status) {
9132
+ return errRest;
9133
+ }
9134
+ const dragRowid = (0, _util.getRowid)($xeTable, dragRow);
9135
+ const dragRowRest = fullAllDataRowIdData[dragRowid] || {};
9136
+ const _dragRowIndex = dragRowRest._index;
9137
+ let dragRowHeight = 0;
9138
+ let dragOffsetTop = -1;
9139
+ if (animation) {
9140
+ dragRowHeight = (0, _util.getCellRestHeight)(dragRowRest, cellOpts, rowOpts, defaultRowHeight);
9141
+ const oldTrEl = el.querySelector(`.vxe-body--row[rowid="${dragRowid}"]`);
9142
+ if (oldTrEl) {
9143
+ dragOffsetTop = oldTrEl.offsetTop;
9105
9144
  }
9106
- let oafIndex = -1;
9107
- let nafIndex = -1;
9108
- // 如果为树结构
9109
- if (treeConfig) {
9110
- if (transform) {
9111
- // 移出源位置
9112
- const oldRowid = (0, _util.getRowid)($xeTable, dragRow);
9113
- const oldRest = fullAllDataRowIdData[oldRowid];
9114
- const newRowid = (0, _util.getRowid)($xeTable, prevDragRow);
9115
- const newRest = fullAllDataRowIdData[newRowid];
9116
- if (oldRest && newRest) {
9117
- const {
9118
- level: oldLevel
9119
- } = oldRest;
9120
- const {
9121
- level: newLevel
9122
- } = newRest;
9123
- const oldAllMaps = {};
9124
- _xeUtils.default.eachTree([dragRow], item => {
9125
- oldAllMaps[(0, _util.getRowid)($xeTable, item)] = item;
9126
- }, {
9127
- children: mapChildrenField
9128
- });
9129
- let isSelfToChildStatus = false;
9130
- if (oldLevel && newLevel) {
9131
- // 子到子
9132
- if (isPeerDrag && !isCrossDrag) {
9133
- if (oldRest.row[parentField] !== newRest.row[parentField]) {
9134
- // 非同级
9135
- return errRest;
9136
- }
9137
- } else {
9138
- if (!isCrossDrag) {
9139
- return errRest;
9140
- }
9141
- if (oldAllMaps[newRowid]) {
9142
- isSelfToChildStatus = true;
9143
- if (!(isCrossDrag && isSelfToChildDrag)) {
9144
- if (_ui.VxeUI.modal) {
9145
- _ui.VxeUI.modal.message({
9146
- status: 'error',
9147
- content: getI18n('vxe.error.treeDragChild')
9148
- });
9149
- }
9150
- return errRest;
9151
- }
9152
- }
9153
- }
9154
- } else if (oldLevel) {
9155
- // 子到根
9156
- if (!isCrossDrag) {
9145
+ }
9146
+ let oafIndex = -1;
9147
+ let nafIndex = -1;
9148
+ // 如果为树结构
9149
+ if (treeConfig) {
9150
+ if (transform) {
9151
+ // 移出源位置
9152
+ const oldRest = dragRowRest;
9153
+ const newRowid = (0, _util.getRowid)($xeTable, prevDragRow);
9154
+ const newRest = fullAllDataRowIdData[newRowid];
9155
+ if (oldRest && newRest) {
9156
+ const {
9157
+ level: oldLevel
9158
+ } = oldRest;
9159
+ const {
9160
+ level: newLevel
9161
+ } = newRest;
9162
+ const oldAllMaps = {};
9163
+ _xeUtils.default.eachTree([dragRow], item => {
9164
+ oldAllMaps[(0, _util.getRowid)($xeTable, item)] = item;
9165
+ }, {
9166
+ children: mapChildrenField
9167
+ });
9168
+ let isSelfToChildStatus = false;
9169
+ if (oldLevel && newLevel) {
9170
+ // 子到子
9171
+ if (isPeerDrag && !isCrossDrag) {
9172
+ if (oldRest.row[parentField] !== newRest.row[parentField]) {
9173
+ // 非同级
9157
9174
  return errRest;
9158
9175
  }
9159
- } else if (newLevel) {
9160
- // 根到子
9176
+ } else {
9161
9177
  if (!isCrossDrag) {
9162
9178
  return errRest;
9163
9179
  }
@@ -9173,87 +9189,156 @@ const Methods = {
9173
9189
  return errRest;
9174
9190
  }
9175
9191
  }
9176
- } else {
9177
- // 根到根
9178
9192
  }
9179
- const fullList = _xeUtils.default.toTreeArray(internalData.afterTreeFullData, {
9180
- key: rowField,
9181
- parentKey: parentField,
9182
- children: mapChildrenField
9183
- });
9184
- // 移出
9185
- const otfIndex = $xeTable.findRowIndexOf(fullList, dragRow);
9186
- fullList.splice(otfIndex, 1);
9187
- // 插入
9188
- const ptfIndex = $xeTable.findRowIndexOf(fullList, prevDragRow);
9189
- const ntfIndex = ptfIndex + dragOffsetIndex;
9190
- fullList.splice(ntfIndex, 0, dragRow);
9191
- // 改变层级
9192
- if (isSelfToChildStatus && isCrossDrag && isSelfToChildDrag) {
9193
- _xeUtils.default.each(dragRow[childrenField], childRow => {
9194
- childRow[parentField] = dragRow[parentField];
9195
- });
9193
+ } else if (oldLevel) {
9194
+ // 子到根
9195
+ if (!isCrossDrag) {
9196
+ return errRest;
9197
+ }
9198
+ } else if (newLevel) {
9199
+ // 根到子
9200
+ if (!isCrossDrag) {
9201
+ return errRest;
9202
+ }
9203
+ if (oldAllMaps[newRowid]) {
9204
+ isSelfToChildStatus = true;
9205
+ if (!(isCrossDrag && isSelfToChildDrag)) {
9206
+ if (_ui.VxeUI.modal) {
9207
+ _ui.VxeUI.modal.message({
9208
+ status: 'error',
9209
+ content: getI18n('vxe.error.treeDragChild')
9210
+ });
9211
+ }
9212
+ return errRest;
9213
+ }
9196
9214
  }
9197
- dragRow[parentField] = isDragToChildFlag ? prevDragRow[rowField] : prevDragRow[parentField];
9198
- internalData.tableFullTreeData = _xeUtils.default.toArrayTree(fullList, {
9199
- key: rowField,
9200
- parentKey: parentField,
9201
- children: childrenField,
9202
- mapChildren: mapChildrenField
9215
+ } else {
9216
+ // 根到根
9217
+ }
9218
+ const fullList = _xeUtils.default.toTreeArray(internalData.afterTreeFullData, {
9219
+ key: rowField,
9220
+ parentKey: parentField,
9221
+ children: mapChildrenField
9222
+ });
9223
+ // 移出
9224
+ const otfIndex = $xeTable.findRowIndexOf(fullList, dragRow);
9225
+ fullList.splice(otfIndex, 1);
9226
+ // 插入
9227
+ const ptfIndex = $xeTable.findRowIndexOf(fullList, prevDragRow);
9228
+ const ntfIndex = ptfIndex + dragOffsetIndex;
9229
+ fullList.splice(ntfIndex, 0, dragRow);
9230
+ // 改变层级
9231
+ if (isSelfToChildStatus && isCrossDrag && isSelfToChildDrag) {
9232
+ _xeUtils.default.each(dragRow[childrenField], childRow => {
9233
+ childRow[parentField] = dragRow[parentField];
9203
9234
  });
9204
9235
  }
9236
+ dragRow[parentField] = isDragToChildFlag ? prevDragRow[rowField] : prevDragRow[parentField];
9237
+ internalData.tableFullTreeData = _xeUtils.default.toArrayTree(fullList, {
9238
+ key: rowField,
9239
+ parentKey: parentField,
9240
+ children: childrenField,
9241
+ mapChildren: mapChildrenField
9242
+ });
9205
9243
  }
9206
- } else {
9207
- // 移出
9208
- oafIndex = $xeTable.findRowIndexOf(afterFullData, dragRow);
9209
- const otfIndex = $xeTable.findRowIndexOf(tableFullData, dragRow);
9210
- afterFullData.splice(oafIndex, 1);
9211
- tableFullData.splice(otfIndex, 1);
9212
- // 插入
9213
- const pafIndex = $xeTable.findRowIndexOf(afterFullData, prevDragRow);
9214
- const ptfIndex = $xeTable.findRowIndexOf(tableFullData, prevDragRow);
9215
- nafIndex = pafIndex + dragOffsetIndex;
9216
- const ntfIndex = ptfIndex + dragOffsetIndex;
9217
- afterFullData.splice(nafIndex, 0, dragRow);
9218
- tableFullData.splice(ntfIndex, 0, dragRow);
9219
- }
9220
- reactData.isDragRowMove = true;
9221
- $xeTable.handleTableData(treeConfig && transform);
9222
- $xeTable.cacheRowMap(false);
9223
- updateScrollYStatus($xeTable);
9224
- if (!(treeConfig && transform)) {
9225
- updateAfterDataIndex($xeTable);
9226
- }
9227
- $xeTable.checkSelectionStatus();
9228
- if (reactData.scrollYLoad) {
9229
- $xeTable.updateScrollYSpace();
9230
9244
  }
9231
- if (evnt) {
9232
- $xeTable.dispatchEvent('row-dragend', {
9233
- oldRow: dragRow,
9234
- newRow: prevDragRow,
9235
- dragRow,
9236
- dragPos: prevDragPos,
9237
- dragToChild: isDragToChildFlag,
9238
- offsetIndex: dragOffsetIndex,
9239
- _index: {
9240
- newIndex: nafIndex,
9241
- oldIndex: oafIndex
9245
+ } else {
9246
+ // 移出
9247
+ oafIndex = $xeTable.findRowIndexOf(afterFullData, dragRow);
9248
+ const otfIndex = $xeTable.findRowIndexOf(tableFullData, dragRow);
9249
+ afterFullData.splice(oafIndex, 1);
9250
+ tableFullData.splice(otfIndex, 1);
9251
+ // 插入
9252
+ const pafIndex = $xeTable.findRowIndexOf(afterFullData, prevDragRow);
9253
+ const ptfIndex = $xeTable.findRowIndexOf(tableFullData, prevDragRow);
9254
+ nafIndex = pafIndex + dragOffsetIndex;
9255
+ const ntfIndex = ptfIndex + dragOffsetIndex;
9256
+ afterFullData.splice(nafIndex, 0, dragRow);
9257
+ tableFullData.splice(ntfIndex, 0, dragRow);
9258
+ }
9259
+ $xeTable.handleTableData(treeConfig && transform);
9260
+ $xeTable.cacheRowMap(false);
9261
+ updateScrollYStatus($xeTable);
9262
+ if (!(treeConfig && transform)) {
9263
+ updateAfterDataIndex($xeTable);
9264
+ }
9265
+ $xeTable.checkSelectionStatus();
9266
+ if (reactData.scrollYLoad) {
9267
+ $xeTable.updateScrollYSpace();
9268
+ }
9269
+ if (evnt) {
9270
+ $xeTable.dispatchEvent('row-dragend', {
9271
+ oldRow: dragRow,
9272
+ newRow: prevDragRow,
9273
+ dragRow,
9274
+ dragPos: prevDragPos,
9275
+ dragToChild: isDragToChildFlag,
9276
+ offsetIndex: dragOffsetIndex,
9277
+ _index: {
9278
+ newIndex: nafIndex,
9279
+ oldIndex: oafIndex
9280
+ }
9281
+ }, evnt);
9282
+ }
9283
+ return $xeTable.$nextTick().then(() => {
9284
+ if (animation) {
9285
+ const {
9286
+ tableData
9287
+ } = reactData;
9288
+ const dragRowRest = fullAllDataRowIdData[dragRowid];
9289
+ const _newRowIndex = dragRowRest._index;
9290
+ const firstRow = tableData[0];
9291
+ const firstRowRest = fullAllDataRowIdData[(0, _util.getRowid)($xeTable, firstRow)];
9292
+ if (firstRowRest) {
9293
+ const _firstRowIndex = firstRowRest._index;
9294
+ const _lastRowIndex = _firstRowIndex + tableData.length;
9295
+ let rsIndex = -1;
9296
+ let reIndex = -1;
9297
+ let offsetRate = 1;
9298
+ if (_dragRowIndex < _firstRowIndex) {
9299
+ // 从上往下虚拟拖拽
9300
+ rsIndex = 0;
9301
+ reIndex = _newRowIndex - _firstRowIndex;
9302
+ } else if (_dragRowIndex > _lastRowIndex) {
9303
+ // 从下往上虚拟拖拽
9304
+ const $newRowIndex = dragRowRest.$index;
9305
+ rsIndex = $newRowIndex + 1;
9306
+ reIndex = tableData.length;
9307
+ offsetRate = -1;
9308
+ } else {
9309
+ if (_newRowIndex > _dragRowIndex) {
9310
+ // 从上往下拖拽
9311
+ rsIndex = _dragRowIndex - _firstRowIndex;
9312
+ reIndex = rsIndex + _newRowIndex - _dragRowIndex;
9313
+ } else {
9314
+ // 从下往上拖拽
9315
+ rsIndex = _newRowIndex - _firstRowIndex;
9316
+ reIndex = rsIndex + _dragRowIndex - _newRowIndex + 1;
9317
+ offsetRate = -1;
9318
+ }
9242
9319
  }
9243
- }, evnt);
9320
+ const dragRangeList = tableData.slice(rsIndex, reIndex);
9321
+ if (dragRangeList.length) {
9322
+ const dtTrList = el.querySelectorAll(dragRangeList.map(row => `.vxe-body--row[rowid="${(0, _util.getRowid)($xeTable, row)}"]`).join(','));
9323
+ (0, _anime.moveRowAnimateToTb)(dtTrList, offsetRate * dragRowHeight);
9324
+ }
9325
+ }
9326
+ const newTrList = el.querySelectorAll(`.vxe-body--row[rowid="${dragRowid}"]`);
9327
+ const newTrEl = newTrList[0];
9328
+ if (dragOffsetTop > -1 && newTrEl) {
9329
+ (0, _anime.moveRowAnimateToTb)(newTrList, dragOffsetTop - newTrEl.offsetTop);
9330
+ }
9244
9331
  }
9245
- return $xeTable.$nextTick().then(() => {
9246
- $xeTable.updateCellAreas();
9247
- $xeTable.recalculate();
9248
- }).then(() => {
9249
- return {
9250
- status: true
9251
- };
9252
- });
9253
- }).catch(() => {
9254
- return errRest;
9332
+ $xeTable.updateCellAreas();
9333
+ $xeTable.recalculate();
9334
+ }).then(() => {
9335
+ return {
9336
+ status: true
9337
+ };
9255
9338
  });
9256
- }
9339
+ }).catch(() => {
9340
+ return errRest;
9341
+ });
9257
9342
  }
9258
9343
  return Promise.resolve(errRest);
9259
9344
  },
@@ -9281,6 +9366,7 @@ const Methods = {
9281
9366
  prevDragRow,
9282
9367
  prevDragPos
9283
9368
  } = internalData;
9369
+ const el = $xeTable.$refs.refElem;
9284
9370
  if (treeConfig && lazy && prevDragToChild) {
9285
9371
  // 懒加载
9286
9372
  const newRowid = (0, _util.getRowid)($xeTable, prevDragRow);
@@ -9297,18 +9383,16 @@ const Methods = {
9297
9383
  }
9298
9384
  hideDropTip($xeTable);
9299
9385
  clearRowDropOrigin($xeTable);
9386
+ (0, _anime.clearRowAnimate)(el);
9300
9387
  internalData.prevDragToChild = false;
9301
9388
  reactData.dragRow = null;
9302
9389
  reactData.dragCol = null;
9303
- setTimeout(() => {
9304
- reactData.isDragRowMove = false;
9305
- }, 500);
9306
9390
  },
9307
9391
  handleRowDragDragoverEvent(evnt) {
9308
9392
  const $xeTable = this;
9309
9393
  const props = $xeTable;
9310
- const internalData = $xeTable;
9311
9394
  const reactData = $xeTable;
9395
+ const internalData = $xeTable;
9312
9396
  const {
9313
9397
  treeConfig
9314
9398
  } = props;
@@ -9385,7 +9469,6 @@ const Methods = {
9385
9469
  const tdEl = trigger === 'cell' || trigger === 'row' ? dragEl : (_a = dragEl.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement;
9386
9470
  const trEl = tdEl.parentElement;
9387
9471
  const dStartMethod = dragStartMethod || (dragConfig ? dragConfig.dragStartMethod : null);
9388
- reactData.isDragRowMove = false;
9389
9472
  clearRowDropOrigin($xeTable);
9390
9473
  if (dStartMethod && !dStartMethod(params)) {
9391
9474
  trEl.draggable = false;
@@ -9416,7 +9499,7 @@ const Methods = {
9416
9499
  handleColDragSwapColumn() {
9417
9500
  const $xeTable = this;
9418
9501
  handleUpdateColumn($xeTable);
9419
- parseColumns($xeTable, false).then(() => {
9502
+ return parseColumns($xeTable, false).then(() => {
9420
9503
  $xeTable.updateCellAreas();
9421
9504
  $xeTable.saveCustomStore('update:sort');
9422
9505
  });
@@ -9431,6 +9514,7 @@ const Methods = {
9431
9514
  } = props;
9432
9515
  const columnDragOpts = $xeTable.computeColumnDragOpts;
9433
9516
  const {
9517
+ animation,
9434
9518
  isPeerDrag,
9435
9519
  isCrossDrag,
9436
9520
  isSelfToChildDrag,
@@ -9439,68 +9523,73 @@ const Methods = {
9439
9523
  dragToChildMethod
9440
9524
  } = columnDragOpts;
9441
9525
  const {
9442
- collectColumn
9526
+ collectColumn,
9527
+ fullColumnIdData
9443
9528
  } = internalData;
9529
+ const el = $xeTable.$refs.refElem;
9444
9530
  const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0;
9445
9531
  const errRest = {
9446
9532
  status: false
9447
9533
  };
9448
- if (prevDragCol && dragCol) {
9449
- // 判断是否有拖动
9450
- if (prevDragCol !== dragCol) {
9451
- const dragColumn = dragCol;
9452
- const newColumn = prevDragCol;
9453
- const dragParams = {
9454
- oldColumn: dragColumn,
9455
- newColumn,
9456
- dragColumn,
9457
- dragPos: prevDragPos,
9458
- dragToChild: !!prevDragToChild,
9459
- offsetIndex: dragOffsetIndex
9460
- };
9461
- const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
9462
- return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then(status => {
9463
- if (!status) {
9464
- return errRest;
9465
- }
9466
- let oafIndex = -1;
9467
- let nafIndex = -1;
9468
- const oldAllMaps = {};
9534
+ if (!(el && prevDragCol && dragCol)) {
9535
+ return Promise.resolve(errRest);
9536
+ }
9537
+ // 判断是否有拖动
9538
+ if (prevDragCol !== dragCol) {
9539
+ const dragColumn = dragCol;
9540
+ const newColumn = prevDragCol;
9541
+ const dragParams = {
9542
+ oldColumn: dragColumn,
9543
+ newColumn,
9544
+ dragColumn,
9545
+ dragPos: prevDragPos,
9546
+ dragToChild: !!prevDragToChild,
9547
+ offsetIndex: dragOffsetIndex
9548
+ };
9549
+ const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
9550
+ return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then(status => {
9551
+ if (!status) {
9552
+ return errRest;
9553
+ }
9554
+ let dragTargetColumn = null;
9555
+ const dragAllTargetCols = [];
9556
+ let dragColWidth = 0;
9557
+ if (animation) {
9469
9558
  _xeUtils.default.eachTree([dragColumn], column => {
9470
- oldAllMaps[column.id] = column;
9471
- });
9472
- let isSelfToChildStatus = false;
9473
- if (dragColumn.parentId && newColumn.parentId) {
9474
- // 子到子
9475
- if (isPeerDrag && !isCrossDrag) {
9476
- if (dragColumn.parentId !== newColumn.parentId) {
9477
- // 非同级
9478
- return errRest;
9479
- }
9480
- } else {
9481
- if (!isCrossDrag) {
9482
- return errRest;
9483
- }
9484
- if (oldAllMaps[newColumn.id]) {
9485
- isSelfToChildStatus = true;
9486
- if (!(isCrossDrag && isSelfToChildDrag)) {
9487
- if (_ui.VxeUI.modal) {
9488
- _ui.VxeUI.modal.message({
9489
- status: 'error',
9490
- content: getI18n('vxe.error.treeDragChild')
9491
- });
9492
- }
9493
- return errRest;
9494
- }
9495
- }
9559
+ if (!dragTargetColumn && (!column.children || !column.children.length)) {
9560
+ dragTargetColumn = column;
9561
+ dragColWidth += column.renderWidth;
9496
9562
  }
9497
- } else if (dragColumn.parentId) {
9498
- // 子到根
9499
- if (!isCrossDrag) {
9563
+ dragAllTargetCols.push(column);
9564
+ });
9565
+ }
9566
+ if (!dragTargetColumn) {
9567
+ dragTargetColumn = dragColumn;
9568
+ }
9569
+ const dragColRest = fullColumnIdData[dragTargetColumn.id] || {};
9570
+ const _dragColIndex = dragColRest._index;
9571
+ let dragOffsetLeft = -1;
9572
+ if (animation) {
9573
+ const oldTrEl = el.querySelector(`.vxe-table--column[colid="${dragTargetColumn.id}"]`);
9574
+ if (oldTrEl) {
9575
+ dragOffsetLeft = oldTrEl.offsetLeft;
9576
+ }
9577
+ }
9578
+ let oafIndex = -1;
9579
+ let nafIndex = -1;
9580
+ const oldAllMaps = {};
9581
+ _xeUtils.default.eachTree([dragColumn], column => {
9582
+ oldAllMaps[column.id] = column;
9583
+ });
9584
+ let isSelfToChildStatus = false;
9585
+ if (dragColumn.parentId && newColumn.parentId) {
9586
+ // 子到子
9587
+ if (isPeerDrag && !isCrossDrag) {
9588
+ if (dragColumn.parentId !== newColumn.parentId) {
9589
+ // 非同级
9500
9590
  return errRest;
9501
9591
  }
9502
- } else if (newColumn.parentId) {
9503
- // 根到子
9592
+ } else {
9504
9593
  if (!isCrossDrag) {
9505
9594
  return errRest;
9506
9595
  }
@@ -9516,96 +9605,199 @@ const Methods = {
9516
9605
  return errRest;
9517
9606
  }
9518
9607
  }
9519
- } else {
9520
- // 根到根
9521
9608
  }
9522
- const oldewMatchRest = _xeUtils.default.findTree(collectColumn, item => item.id === dragColumn.id);
9523
- // 改变层级
9524
- if (isSelfToChildStatus && isCrossDrag && isSelfToChildDrag) {
9525
- if (oldewMatchRest) {
9526
- const {
9527
- items: oCols,
9528
- index: oIndex
9529
- } = oldewMatchRest;
9530
- const childList = dragColumn.children || [];
9531
- childList.forEach(column => {
9532
- column.parentId = dragColumn.parentId;
9533
- });
9534
- oCols.splice(oIndex, 1, ...childList);
9535
- dragColumn.children = [];
9536
- }
9537
- } else {
9538
- if (oldewMatchRest) {
9539
- const {
9540
- items: oCols,
9541
- index: oIndex,
9542
- parent: oParent
9543
- } = oldewMatchRest;
9544
- oCols.splice(oIndex, 1);
9545
- if (!oParent) {
9546
- oafIndex = oIndex;
9609
+ } else if (dragColumn.parentId) {
9610
+ // 子到根
9611
+ if (!isCrossDrag) {
9612
+ return errRest;
9613
+ }
9614
+ } else if (newColumn.parentId) {
9615
+ // 根到子
9616
+ if (!isCrossDrag) {
9617
+ return errRest;
9618
+ }
9619
+ if (oldAllMaps[newColumn.id]) {
9620
+ isSelfToChildStatus = true;
9621
+ if (!(isCrossDrag && isSelfToChildDrag)) {
9622
+ if (_ui.VxeUI.modal) {
9623
+ _ui.VxeUI.modal.message({
9624
+ status: 'error',
9625
+ content: getI18n('vxe.error.treeDragChild')
9626
+ });
9547
9627
  }
9628
+ return errRest;
9548
9629
  }
9549
9630
  }
9550
- const newMatchRest = _xeUtils.default.findTree(collectColumn, item => item.id === newColumn.id);
9551
- if (newMatchRest) {
9631
+ } else {
9632
+ // 根到根
9633
+ }
9634
+ const oldewMatchRest = _xeUtils.default.findTree(collectColumn, item => item.id === dragColumn.id);
9635
+ // 改变层级
9636
+ if (isSelfToChildStatus && isCrossDrag && isSelfToChildDrag) {
9637
+ if (oldewMatchRest) {
9552
9638
  const {
9553
- items: nCols,
9554
- index: nIndex,
9555
- parent: nParent
9556
- } = newMatchRest;
9557
- // 转子级
9558
- if (isCrossDrag && isToChildDrag && isDragToChildFlag) {
9559
- dragColumn.parentId = newColumn.id;
9560
- newColumn.children = (newColumn.children || []).concat([dragColumn]);
9561
- } else {
9562
- dragColumn.parentId = newColumn.parentId;
9563
- nCols.splice(nIndex + dragOffsetIndex, 0, dragColumn);
9564
- }
9565
- if (!nParent) {
9566
- nafIndex = nIndex;
9567
- }
9639
+ items: oCols,
9640
+ index: oIndex
9641
+ } = oldewMatchRest;
9642
+ const childList = dragColumn.children || [];
9643
+ childList.forEach(column => {
9644
+ column.parentId = dragColumn.parentId;
9645
+ });
9646
+ oCols.splice(oIndex, 1, ...childList);
9647
+ dragColumn.children = [];
9568
9648
  }
9569
- _xeUtils.default.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
9570
- if (!parentColumn) {
9571
- const sortIndex = index + 1;
9572
- column.renderSortNumber = sortIndex;
9573
- }
9574
- });
9575
- reactData.isDragColMove = true;
9576
- if (mouseConfig) {
9577
- if ($xeTable.clearSelected) {
9578
- $xeTable.clearSelected();
9579
- }
9580
- if ($xeTable.clearCellAreas) {
9581
- $xeTable.clearCellAreas();
9582
- $xeTable.clearCopyCellArea();
9649
+ } else {
9650
+ if (oldewMatchRest) {
9651
+ const {
9652
+ items: oCols,
9653
+ index: oIndex,
9654
+ parent: oParent
9655
+ } = oldewMatchRest;
9656
+ oCols.splice(oIndex, 1);
9657
+ if (!oParent) {
9658
+ oafIndex = oIndex;
9583
9659
  }
9584
9660
  }
9585
- if (evnt) {
9586
- $xeTable.dispatchEvent('column-dragend', {
9587
- oldColumn: dragColumn,
9588
- newColumn,
9589
- dragColumn,
9590
- dragPos: prevDragPos,
9591
- dragToChild: isDragToChildFlag,
9592
- offsetIndex: dragOffsetIndex,
9593
- _index: {
9594
- newIndex: nafIndex,
9595
- oldIndex: oafIndex
9596
- }
9597
- }, evnt);
9661
+ }
9662
+ const newMatchRest = _xeUtils.default.findTree(collectColumn, item => item.id === newColumn.id);
9663
+ if (newMatchRest) {
9664
+ const {
9665
+ items: nCols,
9666
+ index: nIndex,
9667
+ parent: nParent
9668
+ } = newMatchRest;
9669
+ // 转子级
9670
+ if (isCrossDrag && isToChildDrag && isDragToChildFlag) {
9671
+ dragColumn.parentId = newColumn.id;
9672
+ newColumn.children = (newColumn.children || []).concat([dragColumn]);
9673
+ } else {
9674
+ dragColumn.parentId = newColumn.parentId;
9675
+ nCols.splice(nIndex + dragOffsetIndex, 0, dragColumn);
9676
+ }
9677
+ if (!nParent) {
9678
+ nafIndex = nIndex;
9679
+ }
9680
+ }
9681
+ _xeUtils.default.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
9682
+ if (!parentColumn) {
9683
+ const sortIndex = index + 1;
9684
+ column.renderSortNumber = sortIndex;
9685
+ }
9686
+ });
9687
+ if (mouseConfig) {
9688
+ if ($xeTable.clearSelected) {
9689
+ $xeTable.clearSelected();
9690
+ }
9691
+ if ($xeTable.clearCellAreas) {
9692
+ $xeTable.clearCellAreas();
9693
+ $xeTable.clearCopyCellArea();
9598
9694
  }
9695
+ }
9696
+ if (evnt) {
9697
+ $xeTable.dispatchEvent('column-dragend', {
9698
+ oldColumn: dragColumn,
9699
+ newColumn,
9700
+ dragColumn,
9701
+ dragPos: prevDragPos,
9702
+ dragToChild: isDragToChildFlag,
9703
+ offsetIndex: dragOffsetIndex,
9704
+ _index: {
9705
+ newIndex: nafIndex,
9706
+ oldIndex: oafIndex
9707
+ }
9708
+ }, evnt);
9709
+ }
9710
+ return $xeTable.$nextTick().then(() => {
9599
9711
  if (isSyncColumn) {
9600
- $xeTable.handleColDragSwapColumn();
9712
+ return $xeTable.handleColDragSwapColumn();
9601
9713
  }
9714
+ }).then(() => {
9715
+ if (animation) {
9716
+ const {
9717
+ tableColumn
9718
+ } = reactData;
9719
+ const {
9720
+ visibleColumn,
9721
+ fullColumnIdData
9722
+ } = internalData;
9723
+ let dragNewColumn = null;
9724
+ const dragNewColMaps = {};
9725
+ _xeUtils.default.eachTree([dragColumn], column => {
9726
+ if (!dragNewColumn && (!column.children || !column.children.length)) {
9727
+ dragNewColumn = column;
9728
+ }
9729
+ dragNewColMaps[column.id] = column;
9730
+ });
9731
+ if (!dragNewColumn) {
9732
+ dragNewColumn = dragColumn;
9733
+ }
9734
+ if (dragColWidth && dragAllTargetCols.length) {
9735
+ const _newColIndex = _xeUtils.default.findIndexOf(visibleColumn, column => !!dragNewColumn && column.id === dragNewColumn.id);
9736
+ const firstCol = tableColumn[0];
9737
+ const firstColRest = fullColumnIdData[firstCol.id];
9738
+ if (firstColRest) {
9739
+ const _firstColIndex = firstColRest._index;
9740
+ const _lastColIndex = _firstColIndex + tableColumn.length;
9741
+ let csIndex = -1;
9742
+ let ceIndex = -1;
9743
+ let offsetRate = 1;
9744
+ if (_dragColIndex < _firstColIndex) {
9745
+ // 从左往右虚拟拖拽
9746
+ csIndex = 0;
9747
+ ceIndex = _newColIndex - _firstColIndex;
9748
+ } else if (_dragColIndex > _lastColIndex) {
9749
+ // 从右往左虚拟拖拽
9750
+ const $newRowIndex = dragColRest.$index;
9751
+ csIndex = $newRowIndex + 1;
9752
+ ceIndex = tableColumn.length;
9753
+ offsetRate = -1;
9754
+ } else {
9755
+ if (_newColIndex > _dragColIndex) {
9756
+ // 从左往右拖拽
9757
+ csIndex = _dragColIndex - _firstColIndex;
9758
+ ceIndex = csIndex + _newColIndex - _dragColIndex;
9759
+ } else {
9760
+ // 从右往左拖拽
9761
+ csIndex = _newColIndex - _firstColIndex + 1;
9762
+ ceIndex = csIndex + _dragColIndex - _newColIndex;
9763
+ offsetRate = -1;
9764
+ }
9765
+ }
9766
+ const dragRangeList = [];
9767
+ const dragRangeMaps = {};
9768
+ for (let i = csIndex; i < ceIndex; i++) {
9769
+ const column = tableColumn[i];
9770
+ if (!dragRangeMaps[column.id] && !dragNewColMaps[column.id]) {
9771
+ dragRangeMaps[column.id] = column;
9772
+ dragRangeList.push(column);
9773
+ }
9774
+ }
9775
+ _xeUtils.default.eachTree([newColumn], column => {
9776
+ if (!dragRangeMaps[column.id]) {
9777
+ dragRangeMaps[column.id] = column;
9778
+ dragRangeList.push(column);
9779
+ }
9780
+ });
9781
+ if (dragRangeList.length) {
9782
+ const dtTrList = el.querySelectorAll(dragRangeList.map(column => `.vxe-table--column[colid="${column.id}"]`).join(','));
9783
+ (0, _anime.moveColAnimateToLr)(dtTrList, offsetRate * dragColWidth);
9784
+ }
9785
+ }
9786
+ const newTrList = el.querySelectorAll(dragAllTargetCols.map(column => `.vxe-table--column[colid="${column.id}"]`).join(','));
9787
+ const newTdEl = newTrList[0];
9788
+ if (dragOffsetLeft > -1 && newTdEl) {
9789
+ (0, _anime.moveColAnimateToLr)(newTrList, dragOffsetLeft - newTdEl.offsetLeft);
9790
+ }
9791
+ }
9792
+ }
9793
+ loadScrollXData($xeTable);
9602
9794
  return {
9603
9795
  status: true
9604
9796
  };
9605
- }).catch(() => {
9606
- return errRest;
9607
9797
  });
9608
- }
9798
+ }).catch(() => {
9799
+ return errRest;
9800
+ });
9609
9801
  }
9610
9802
  return Promise.resolve(errRest);
9611
9803
  },
@@ -9621,18 +9813,14 @@ const Methods = {
9621
9813
  prevDragPos,
9622
9814
  prevDragToChild
9623
9815
  } = internalData;
9816
+ const el = $xeTable.$refs.refElem;
9624
9817
  $xeTable.handleColDragSwapEvent(evnt, true, dragCol, prevDragCol, prevDragPos, prevDragToChild);
9625
9818
  hideDropTip($xeTable);
9626
9819
  clearColDropOrigin($xeTable);
9820
+ (0, _anime.clearColAnimate)(el);
9627
9821
  internalData.prevDragToChild = false;
9628
9822
  reactData.dragRow = null;
9629
9823
  reactData.dragCol = null;
9630
- setTimeout(() => {
9631
- reactData.isDragColMove = false;
9632
- $xeTable.recalculate().then(() => {
9633
- loadScrollXData($xeTable);
9634
- });
9635
- }, 500);
9636
9824
  },
9637
9825
  handleHeaderCellDragDragoverEvent(evnt) {
9638
9826
  const $xeTable = this;
@@ -9721,7 +9909,6 @@ const Methods = {
9721
9909
  } = params;
9722
9910
  const dragEl = evnt.currentTarget;
9723
9911
  const thEl = trigger === 'cell' ? dragEl : (_a = dragEl.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement;
9724
- reactData.isDragColMove = false;
9725
9912
  clearColDropOrigin($xeTable);
9726
9913
  if (dragStartMethod && !dragStartMethod(params)) {
9727
9914
  thEl.draggable = false;
@@ -9744,7 +9931,6 @@ const Methods = {
9744
9931
  hideDropTip($xeTable);
9745
9932
  reactData.dragRow = null;
9746
9933
  reactData.dragCol = null;
9747
- reactData.isDragColMove = false;
9748
9934
  },
9749
9935
  setPendingRow(rows, status) {
9750
9936
  const $xeTable = this;
@@ -10329,7 +10515,7 @@ const Methods = {
10329
10515
  }
10330
10516
  }
10331
10517
  reactData.rowExpandedFlag++;
10332
- return Promise.all(lazyRests).then(() => $xeTable.$nextTick()).then(() => $xeTable.recalculate(true)).then(() => {
10518
+ return Promise.all(lazyRests).then(() => $xeTable.$nextTick()).then(() => handleLazyRecalculate($xeTable, true, true, true)).then(() => {
10333
10519
  updateRowOffsetTop($xeTable);
10334
10520
  updateRowExpandStyle($xeTable);
10335
10521
  handleRowExpandScroll($xeTable);
@@ -10380,7 +10566,7 @@ const Methods = {
10380
10566
  }
10381
10567
  return $xeTable.$nextTick().then(() => {
10382
10568
  if (expList.length) {
10383
- return $xeTable.recalculate(true);
10569
+ return handleLazyRecalculate($xeTable, true, true, true);
10384
10570
  }
10385
10571
  }).then(() => {
10386
10572
  updateRowOffsetTop($xeTable);
@@ -10540,7 +10726,7 @@ const Methods = {
10540
10726
  $xeTable.handleTableData();
10541
10727
  updateAfterDataIndex($xeTable);
10542
10728
  reactData.rowGroupExpandedFlag++;
10543
- return $xeTable.recalculate(true);
10729
+ return handleLazyRecalculate($xeTable, true, true, true);
10544
10730
  },
10545
10731
  clearRowGroupExpand() {
10546
10732
  const $xeTable = this;
@@ -10551,7 +10737,7 @@ const Methods = {
10551
10737
  $xeTable.handleTableData();
10552
10738
  updateAfterDataIndex($xeTable);
10553
10739
  reactData.rowGroupExpandedFlag++;
10554
- return $xeTable.recalculate(true);
10740
+ return handleLazyRecalculate($xeTable, true, true, true);
10555
10741
  },
10556
10742
  getTreeExpandRecords() {
10557
10743
  const $xeTable = this;
@@ -10970,8 +11156,6 @@ const Methods = {
10970
11156
  }
10971
11157
  internalData.lastScrollTop = scrollTop;
10972
11158
  }
10973
- reactData.isDragColMove = false;
10974
- reactData.isDragRowMove = false;
10975
11159
  reactData.lastScrollTime = Date.now();
10976
11160
  const evntParams = Object.assign({
10977
11161
  scrollTop,