vxe-table 4.14.0-beta.0 → 4.14.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 (81) hide show
  1. package/README.en.md +2 -1
  2. package/README.ja-JP.md +2 -1
  3. package/README.md +4 -2
  4. package/README.zh-TW.md +2 -1
  5. package/es/grid/src/grid.js +127 -94
  6. package/es/index.css +1 -1
  7. package/es/index.min.css +1 -1
  8. package/es/style.css +1 -1
  9. package/es/style.min.css +1 -1
  10. package/es/table/module/custom/hook.js +0 -4
  11. package/es/table/module/custom/panel.js +0 -1
  12. package/es/table/module/keyboard/hook.js +2 -2
  13. package/es/table/src/anime.js +46 -0
  14. package/es/table/src/body.js +9 -24
  15. package/es/table/src/columnInfo.js +5 -0
  16. package/es/table/src/footer.js +5 -22
  17. package/es/table/src/header.js +4 -21
  18. package/es/table/src/table.js +562 -358
  19. package/es/table/src/util.js +1 -1
  20. package/es/table/style.css +8 -8
  21. package/es/table/style.min.css +1 -1
  22. package/es/ui/index.js +3 -2
  23. package/es/ui/src/log.js +1 -1
  24. package/es/vxe-table/style.css +8 -8
  25. package/es/vxe-table/style.min.css +1 -1
  26. package/lib/grid/src/grid.js +143 -98
  27. package/lib/grid/src/grid.min.js +1 -1
  28. package/lib/index.css +1 -1
  29. package/lib/index.min.css +1 -1
  30. package/lib/index.umd.js +255 -208
  31. package/lib/index.umd.min.js +1 -1
  32. package/lib/style.css +1 -1
  33. package/lib/style.min.css +1 -1
  34. package/lib/table/module/custom/hook.js +0 -4
  35. package/lib/table/module/custom/hook.min.js +1 -1
  36. package/lib/table/module/custom/panel.js +0 -1
  37. package/lib/table/module/custom/panel.min.js +1 -1
  38. package/lib/table/module/keyboard/hook.js +2 -2
  39. package/lib/table/module/keyboard/hook.min.js +1 -1
  40. package/lib/table/src/anime.js +56 -0
  41. package/lib/table/src/anime.min.js +1 -0
  42. package/lib/table/src/body.js +3 -26
  43. package/lib/table/src/body.min.js +1 -1
  44. package/lib/table/src/columnInfo.js +5 -0
  45. package/lib/table/src/columnInfo.min.js +1 -1
  46. package/lib/table/src/footer.js +2 -20
  47. package/lib/table/src/footer.min.js +1 -1
  48. package/lib/table/src/header.js +2 -19
  49. package/lib/table/src/header.min.js +1 -1
  50. package/lib/table/src/table.js +47 -34
  51. package/lib/table/src/table.min.js +1 -1
  52. package/lib/table/src/util.js +2 -2
  53. package/lib/table/src/util.min.js +1 -1
  54. package/lib/table/style/style.css +8 -8
  55. package/lib/table/style/style.min.css +1 -1
  56. package/lib/ui/index.js +3 -2
  57. package/lib/ui/index.min.js +1 -1
  58. package/lib/ui/src/log.js +1 -1
  59. package/lib/ui/src/log.min.js +1 -1
  60. package/lib/vxe-table/style/style.css +8 -8
  61. package/lib/vxe-table/style/style.min.css +1 -1
  62. package/package.json +1 -1
  63. package/packages/grid/src/grid.ts +136 -101
  64. package/packages/table/module/custom/hook.ts +0 -4
  65. package/packages/table/module/custom/panel.ts +0 -1
  66. package/packages/table/module/keyboard/hook.ts +2 -2
  67. package/packages/table/src/anime.ts +52 -0
  68. package/packages/table/src/body.ts +15 -38
  69. package/packages/table/src/columnInfo.ts +5 -0
  70. package/packages/table/src/footer.ts +5 -22
  71. package/packages/table/src/header.ts +4 -21
  72. package/packages/table/src/table.ts +570 -361
  73. package/packages/table/src/util.ts +1 -1
  74. package/packages/ui/index.ts +2 -1
  75. package/styles/components/table.scss +9 -9
  76. /package/es/{iconfont.1750770364548.ttf → iconfont.1751195167653.ttf} +0 -0
  77. /package/es/{iconfont.1750770364548.woff → iconfont.1751195167653.woff} +0 -0
  78. /package/es/{iconfont.1750770364548.woff2 → iconfont.1751195167653.woff2} +0 -0
  79. /package/lib/{iconfont.1750770364548.ttf → iconfont.1751195167653.ttf} +0 -0
  80. /package/lib/{iconfont.1750770364548.woff → iconfont.1751195167653.woff} +0 -0
  81. /package/lib/{iconfont.1750770364548.woff2 → iconfont.1751195167653.woff2} +0 -0
@@ -4,15 +4,16 @@ import XEUtils from 'xe-utils';
4
4
  import { initTpImg, getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTargetNode, getPaddingTopBottomSize, setScrollTop, setScrollLeft, toCssUnit, hasControlKey } from '../../ui/src/dom';
5
5
  import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils';
6
6
  import { VxeUI } from '../../ui';
7
+ import { getRowUniqueId, clearTableAllStatus, toFilters, hasDeepKey, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getRefElem, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getCalcHeight, getCellRestHeight } from './util';
8
+ import { getSlotVNs } from '../../ui/src/vn';
9
+ import { moveRowAnimateToTb, clearRowAnimate, moveColAnimateToLr, clearColAnimate } from './anime';
10
+ import { warnLog, errLog } from '../../ui/src/log';
7
11
  import Cell from './cell';
8
12
  import TableBodyComponent from './body';
9
13
  import TableHeaderComponent from './header';
10
14
  import TableFooterComponent from './footer';
11
15
  import tableProps from './props';
12
16
  import tableEmits from './emits';
13
- import { getRowUniqueId, clearTableAllStatus, toFilters, hasDeepKey, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getRefElem, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getCellHeight } from './util';
14
- import { getSlotVNs } from '../../ui/src/vn';
15
- import { warnLog, errLog } from '../../ui/src/log';
16
17
  import TableCustomPanelComponent from '../module/custom/panel';
17
18
  import TableFilterPanelComponent from '../module/filter/panel';
18
19
  import TableImportPanelComponent from '../module/export/import-panel';
@@ -519,13 +520,13 @@ export default defineVxeComponent({
519
520
  const computeHeaderCellOpts = computed(() => {
520
521
  const headerCellOpts = Object.assign({}, getConfig().table.headerCellConfig, props.headerCellConfig);
521
522
  const cellOpts = computeCellOpts.value;
522
- headerCellOpts.height = XEUtils.toNumber(getCellHeight(headerCellOpts.height || cellOpts.height));
523
+ headerCellOpts.height = XEUtils.toNumber(getCalcHeight(headerCellOpts.height || cellOpts.height));
523
524
  return headerCellOpts;
524
525
  });
525
526
  const computeFooterCellOpts = computed(() => {
526
527
  const footerCellOpts = Object.assign({}, getConfig().table.footerCellConfig, props.footerCellConfig);
527
528
  const cellOpts = computeCellOpts.value;
528
- footerCellOpts.height = XEUtils.toNumber(getCellHeight(footerCellOpts.height || cellOpts.height));
529
+ footerCellOpts.height = XEUtils.toNumber(getCalcHeight(footerCellOpts.height || cellOpts.height));
529
530
  return footerCellOpts;
530
531
  });
531
532
  const computeRowOpts = computed(() => {
@@ -680,10 +681,10 @@ export default defineVxeComponent({
680
681
  return Object.assign({}, getConfig().table.customConfig, props.customConfig);
681
682
  });
682
683
  const computeTableRowExpandedList = computed(() => {
683
- const { rowExpandedFlag, expandColumn, rowGroupExpandedFlag, treeExpandedFlag } = reactData;
684
+ const { tableData, rowExpandedFlag, expandColumn, rowGroupExpandedFlag, treeExpandedFlag } = reactData;
684
685
  const { visibleDataRowIdData, rowExpandedMaps } = internalData;
685
686
  const expandList = [];
686
- if (expandColumn && rowExpandedFlag && rowGroupExpandedFlag && treeExpandedFlag) {
687
+ if (tableData.length && expandColumn && rowExpandedFlag && rowGroupExpandedFlag && treeExpandedFlag) {
687
688
  XEUtils.each(rowExpandedMaps, (row, rowid) => {
688
689
  if (visibleDataRowIdData[rowid]) {
689
690
  expandList.push(row);
@@ -2968,7 +2969,7 @@ export default defineVxeComponent({
2968
2969
  $xeTable.checkScrolling();
2969
2970
  }
2970
2971
  };
2971
- const handleRecalculateLayout = (reFull) => {
2972
+ const handleRecalculateStyle = (reFull, reWidth, reHeight) => {
2972
2973
  const el = refElem.value;
2973
2974
  internalData.rceRunTime = Date.now();
2974
2975
  if (!el || !el.clientWidth) {
@@ -2982,19 +2983,28 @@ export default defineVxeComponent({
2982
2983
  calcVarRowHeightConfig('small', smallEl);
2983
2984
  calcVarRowHeightConfig('mini', miniEl);
2984
2985
  }
2985
- calcCellWidth();
2986
- autoCellWidth();
2986
+ if (reWidth) {
2987
+ calcCellWidth();
2988
+ }
2989
+ if (reFull) {
2990
+ autoCellWidth();
2991
+ }
2987
2992
  calcScrollbar();
2988
2993
  updateStyle();
2989
2994
  updateRowExpandStyle();
2990
2995
  return computeScrollLoad().then(() => {
2991
2996
  // 初始化时需要在列计算之后再执行优化运算,达到最优显示效果
2992
- calcCellWidth();
2997
+ if (reWidth) {
2998
+ calcCellWidth();
2999
+ }
2993
3000
  if (reFull) {
2994
3001
  autoCellWidth();
2995
3002
  }
2996
- calcScrollbar();
3003
+ if (reHeight) {
3004
+ calcCellHeight();
3005
+ }
2997
3006
  updateStyle();
3007
+ calcScrollbar();
2998
3008
  if (reFull) {
2999
3009
  updateRowOffsetTop();
3000
3010
  }
@@ -3004,6 +3014,36 @@ export default defineVxeComponent({
3004
3014
  }
3005
3015
  });
3006
3016
  };
3017
+ const handleLazyRecalculate = (reFull, reWidth, reHeight) => {
3018
+ return new Promise(resolve => {
3019
+ const { rceTimeout, rceRunTime } = internalData;
3020
+ const resizeOpts = computeResizeOpts.value;
3021
+ const refreshDelay = resizeOpts.refreshDelay || 20;
3022
+ const el = refElem.value;
3023
+ if (el && el.clientWidth) {
3024
+ autoCellWidth();
3025
+ updateRowExpandStyle();
3026
+ }
3027
+ if (rceTimeout) {
3028
+ clearTimeout(rceTimeout);
3029
+ if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
3030
+ resolve(handleRecalculateStyle(!!reFull, reWidth, reHeight));
3031
+ }
3032
+ else {
3033
+ nextTick(() => {
3034
+ resolve();
3035
+ });
3036
+ }
3037
+ }
3038
+ else {
3039
+ resolve(handleRecalculateStyle(!!reFull, reWidth, reHeight));
3040
+ }
3041
+ internalData.rceTimeout = setTimeout(() => {
3042
+ internalData.rceTimeout = undefined;
3043
+ handleRecalculateStyle(!!reFull, reWidth, reHeight);
3044
+ }, refreshDelay);
3045
+ });
3046
+ };
3007
3047
  const handleUpdateAggValues = () => {
3008
3048
  const { visibleColumn } = internalData;
3009
3049
  const aggCols = [];
@@ -3217,8 +3257,6 @@ export default defineVxeComponent({
3217
3257
  internalData.removeRowMaps = {};
3218
3258
  reactData.removeRowFlag++;
3219
3259
  const sYLoad = updateScrollYStatus(fullData);
3220
- reactData.isDragColMove = false;
3221
- reactData.isDragRowMove = false;
3222
3260
  // 全量数据
3223
3261
  internalData.tableFullData = fullData;
3224
3262
  internalData.tableFullTreeData = isRGroup ? [] : treeData;
@@ -3279,11 +3317,11 @@ export default defineVxeComponent({
3279
3317
  $xeTable.checkSelectionStatus();
3280
3318
  return new Promise(resolve => {
3281
3319
  nextTick()
3282
- .then(() => handleRecalculateLayout(false))
3320
+ .then(() => handleRecalculateStyle(false, false, false))
3283
3321
  .then(() => {
3284
3322
  calcCellHeight();
3285
3323
  updateRowOffsetTop();
3286
- return handleRecalculateLayout(false);
3324
+ return handleRecalculateStyle(false, false, false);
3287
3325
  })
3288
3326
  .then(() => {
3289
3327
  let targetScrollLeft = lastScrollLeft;
@@ -3298,7 +3336,7 @@ export default defineVxeComponent({
3298
3336
  targetScrollTop = 0;
3299
3337
  }
3300
3338
  reactData.isRowLoading = false;
3301
- handleRecalculateLayout(false);
3339
+ handleRecalculateStyle(false, false, false);
3302
3340
  // 是否变更虚拟滚动
3303
3341
  if (oldScrollYLoad === sYLoad) {
3304
3342
  restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
@@ -3536,7 +3574,6 @@ export default defineVxeComponent({
3536
3574
  const tableFullColumn = getColumnList(collectColumn);
3537
3575
  internalData.tableFullColumn = tableFullColumn;
3538
3576
  reactData.isColLoading = true;
3539
- reactData.isDragColMove = false;
3540
3577
  initColumnSort();
3541
3578
  return Promise.resolve(restoreCustomStorage()).then(() => {
3542
3579
  const { scrollXLoad, scrollYLoad, expandColumn } = reactData;
@@ -3668,7 +3705,7 @@ export default defineVxeComponent({
3668
3705
  updateAfterDataIndex();
3669
3706
  return nextTick();
3670
3707
  }).then(() => {
3671
- return $xeTable.recalculate(true);
3708
+ return handleLazyRecalculate(true, true, true);
3672
3709
  }).then(() => {
3673
3710
  setTimeout(() => {
3674
3711
  $xeTable.updateCellAreas();
@@ -3740,7 +3777,7 @@ export default defineVxeComponent({
3740
3777
  updateAfterDataIndex();
3741
3778
  return nextTick();
3742
3779
  }).then(() => {
3743
- return $xeTable.recalculate(true);
3780
+ return handleLazyRecalculate(true, true, true);
3744
3781
  }).then(() => {
3745
3782
  setTimeout(() => {
3746
3783
  $xeTable.updateCellAreas();
@@ -4088,23 +4125,23 @@ export default defineVxeComponent({
4088
4125
  */
4089
4126
  updateData() {
4090
4127
  const { scrollXLoad, scrollYLoad } = reactData;
4091
- return tablePrivateMethods.handleTableData(true).then(() => {
4092
- tableMethods.updateFooter();
4128
+ return $xeTable.handleTableData(true).then(() => {
4129
+ $xeTable.updateFooter();
4093
4130
  if (scrollXLoad || scrollYLoad) {
4094
4131
  if (scrollXLoad) {
4095
- tablePrivateMethods.updateScrollXSpace();
4132
+ $xeTable.updateScrollXSpace();
4096
4133
  }
4097
4134
  if (scrollYLoad) {
4098
- tablePrivateMethods.updateScrollYSpace();
4135
+ $xeTable.updateScrollYSpace();
4099
4136
  }
4100
- return tableMethods.refreshScroll();
4137
+ return $xeTable.refreshScroll();
4101
4138
  }
4102
4139
  }).then(() => {
4103
- tableMethods.updateCellAreas();
4104
- return tableMethods.recalculate(true);
4140
+ $xeTable.updateCellAreas();
4141
+ return handleLazyRecalculate(true, true, true);
4105
4142
  }).then(() => {
4106
4143
  // 存在滚动行为未结束情况
4107
- setTimeout(() => $xeTable.recalculate(), 50);
4144
+ setTimeout(() => handleLazyRecalculate(false, true, true), 50);
4108
4145
  });
4109
4146
  },
4110
4147
  /**
@@ -4119,7 +4156,7 @@ export default defineVxeComponent({
4119
4156
  if (!initStatus) {
4120
4157
  handleLoadDefaults();
4121
4158
  }
4122
- return tableMethods.recalculate();
4159
+ return handleLazyRecalculate(false, true, true);
4123
4160
  });
4124
4161
  },
4125
4162
  /**
@@ -4127,14 +4164,14 @@ export default defineVxeComponent({
4127
4164
  * @param {Array} datas 数据
4128
4165
  */
4129
4166
  reloadData(datas) {
4130
- return tableMethods.clearAll()
4167
+ return $xeTable.clearAll()
4131
4168
  .then(() => {
4132
4169
  internalData.inited = true;
4133
4170
  internalData.initStatus = true;
4134
4171
  return loadTableData(datas, true);
4135
4172
  }).then(() => {
4136
4173
  handleLoadDefaults();
4137
- return tableMethods.recalculate();
4174
+ return handleLazyRecalculate(false, true, true);
4138
4175
  });
4139
4176
  },
4140
4177
  /**
@@ -4441,7 +4478,7 @@ export default defineVxeComponent({
4441
4478
  }
4442
4479
  return nextTick().then(() => {
4443
4480
  $xeTable.updateCellAreas();
4444
- return $xeTable.recalculate();
4481
+ return handleLazyRecalculate(false, true, true);
4445
4482
  });
4446
4483
  }
4447
4484
  return $xeTable.reloadData(tableSourceData);
@@ -5054,9 +5091,9 @@ export default defineVxeComponent({
5054
5091
  handleUpdateColumn();
5055
5092
  }
5056
5093
  return parseColumns(true).then(() => {
5057
- return tableMethods.refreshScroll();
5094
+ return $xeTable.refreshScroll();
5058
5095
  }).then(() => {
5059
- return tableMethods.recalculate();
5096
+ return handleLazyRecalculate(false, true, true);
5060
5097
  });
5061
5098
  },
5062
5099
  setRowHeightConf(heightConf) {
@@ -5191,34 +5228,8 @@ export default defineVxeComponent({
5191
5228
  * 刷新布局
5192
5229
  */
5193
5230
  recalculate(reFull) {
5194
- return new Promise(resolve => {
5195
- const { rceTimeout, rceRunTime } = internalData;
5196
- const resizeOpts = computeResizeOpts.value;
5197
- const refreshDelay = resizeOpts.refreshDelay || 20;
5198
- const el = refElem.value;
5199
- if (el && el.clientWidth) {
5200
- autoCellWidth();
5201
- updateRowExpandStyle();
5202
- }
5203
- if (rceTimeout) {
5204
- clearTimeout(rceTimeout);
5205
- if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
5206
- resolve(handleRecalculateLayout(!!reFull));
5207
- }
5208
- else {
5209
- nextTick(() => {
5210
- resolve();
5211
- });
5212
- }
5213
- }
5214
- else {
5215
- resolve(handleRecalculateLayout(!!reFull));
5216
- }
5217
- internalData.rceTimeout = setTimeout(() => {
5218
- internalData.rceTimeout = undefined;
5219
- handleRecalculateLayout(!!reFull);
5220
- }, refreshDelay);
5221
- });
5231
+ const isForce = !!reFull;
5232
+ return handleLazyRecalculate(isForce, isForce, isForce);
5222
5233
  },
5223
5234
  openTooltip(target, content) {
5224
5235
  const $commTip = refCommTooltip.value;
@@ -6031,7 +6042,7 @@ export default defineVxeComponent({
6031
6042
  reactData.rowExpandedFlag++;
6032
6043
  return Promise.all(lazyRests)
6033
6044
  .then(() => nextTick())
6034
- .then(() => $xeTable.recalculate(true))
6045
+ .then(() => handleLazyRecalculate(true, true, true))
6035
6046
  .then(() => {
6036
6047
  updateRowOffsetTop();
6037
6048
  updateRowExpandStyle();
@@ -6069,7 +6080,7 @@ export default defineVxeComponent({
6069
6080
  }
6070
6081
  return nextTick().then(() => {
6071
6082
  if (expList.length) {
6072
- return $xeTable.recalculate(true);
6083
+ return handleLazyRecalculate(true, true, true);
6073
6084
  }
6074
6085
  }).then(() => {
6075
6086
  updateRowOffsetTop();
@@ -6179,7 +6190,7 @@ export default defineVxeComponent({
6179
6190
  $xeTable.handleTableData();
6180
6191
  updateAfterDataIndex();
6181
6192
  reactData.rowGroupExpandedFlag++;
6182
- return $xeTable.recalculate(true);
6193
+ return handleLazyRecalculate(true, true, true);
6183
6194
  },
6184
6195
  clearRowGroupExpand() {
6185
6196
  internalData.rowGroupExpandedMaps = {};
@@ -6187,7 +6198,7 @@ export default defineVxeComponent({
6187
6198
  $xeTable.handleTableData();
6188
6199
  updateAfterDataIndex();
6189
6200
  reactData.rowGroupExpandedFlag++;
6190
- return $xeTable.recalculate(true);
6201
+ return handleLazyRecalculate(true, true, true);
6191
6202
  },
6192
6203
  getTreeExpandRecords() {
6193
6204
  const rest = [];
@@ -7299,10 +7310,10 @@ export default defineVxeComponent({
7299
7310
  }
7300
7311
  const el = refElem.value;
7301
7312
  if (!el || !el.clientWidth) {
7302
- return nextTick();
7313
+ return;
7303
7314
  }
7304
- tableMethods.recalculate(true);
7305
- tableMethods.updateCellAreas();
7315
+ handleLazyRecalculate(true, true, true);
7316
+ $xeTable.updateCellAreas();
7306
7317
  };
7307
7318
  const handleTargetEnterEvent = (isClear) => {
7308
7319
  const $tooltip = refTooltip.value;
@@ -7324,8 +7335,6 @@ export default defineVxeComponent({
7324
7335
  hideDropTip();
7325
7336
  reactData.dragRow = null;
7326
7337
  reactData.dragCol = null;
7327
- reactData.isDragColMove = false;
7328
- reactData.isDragRowMove = false;
7329
7338
  }
7330
7339
  };
7331
7340
  const clearRowDropOrigin = () => {
@@ -8285,7 +8294,8 @@ export default defineVxeComponent({
8285
8294
  const childList = vals[2];
8286
8295
  let sLen = 0; // 已选
8287
8296
  let hLen = 0; // 半选
8288
- let vLen = 0; // 有效行
8297
+ let vLen = 0; // 有效子行
8298
+ const cLen = childList.length; // 有效子行
8289
8299
  childList.forEach(checkMethod
8290
8300
  ? (item) => {
8291
8301
  const childRowid = handleGetRowId(item);
@@ -8319,16 +8329,29 @@ export default defineVxeComponent({
8319
8329
  }
8320
8330
  vLen++;
8321
8331
  });
8322
- let isSelected = (sLen >= vLen && (vLen >= 1 || hLen >= 1));
8323
- if (checkMethod) {
8324
- if (checkMethod({ $table: $xeTable, row })) {
8325
- isSelected = sLen >= vLen;
8332
+ let isSelected = false;
8333
+ if (cLen > 0) {
8334
+ if (vLen > 0) {
8335
+ isSelected = (sLen > 0 || hLen > 0) && sLen >= vLen;
8326
8336
  }
8327
8337
  else {
8328
- isSelected = selectCheckboxMaps[rowid];
8338
+ // 如果存在子项禁用
8339
+ if ((sLen > 0 && sLen >= vLen)) {
8340
+ isSelected = true;
8341
+ }
8342
+ else if (selectCheckboxMaps[rowid]) {
8343
+ isSelected = true;
8344
+ }
8345
+ else {
8346
+ isSelected = false;
8347
+ }
8329
8348
  }
8330
8349
  }
8331
- const halfSelect = !isSelected && (sLen >= 1 || hLen >= 1);
8350
+ else {
8351
+ // 如果无子项
8352
+ isSelected = selectCheckboxMaps[rowid];
8353
+ }
8354
+ const halfSelect = !isSelected && (sLen > 0 || hLen > 0);
8332
8355
  if (checkField) {
8333
8356
  XEUtils.set(row, checkField, isSelected);
8334
8357
  }
@@ -8367,7 +8390,9 @@ export default defineVxeComponent({
8367
8390
  const { checkField, checkMethod, showReserveStatus } = checkboxOpts;
8368
8391
  const { handleGetRowId } = createHandleGetRowId($xeTable);
8369
8392
  let sLen = 0; // 已选
8393
+ let dsLen = 0; // 禁用的已选
8370
8394
  let hLen = 0; // 半选
8395
+ let dhLen = 0; // 禁用的半选
8371
8396
  let vLen = 0; // 有效行
8372
8397
  const rootList = (treeConfig ? afterTreeFullData : (isRowGroupStatus ? afterGroupFullData : afterFullData));
8373
8398
  rootList.forEach(checkMethod
@@ -8385,10 +8410,10 @@ export default defineVxeComponent({
8385
8410
  }
8386
8411
  else {
8387
8412
  if (selected) {
8388
- sLen++;
8413
+ dsLen++;
8389
8414
  }
8390
8415
  else if (treeIndeterminateRowMaps[childRowid]) {
8391
- hLen++;
8416
+ dhLen++;
8392
8417
  }
8393
8418
  }
8394
8419
  }
@@ -8404,7 +8429,7 @@ export default defineVxeComponent({
8404
8429
  vLen++;
8405
8430
  });
8406
8431
  const isSelected = rootList.length > 0 ? (vLen > 0 ? (sLen >= vLen) : (sLen >= rootList.length)) : false;
8407
- let halfSelect = !isSelected && (sLen >= 1 || hLen >= 1);
8432
+ let halfSelect = !isSelected && (sLen > 0 || hLen > 0 || dsLen > 0 || dhLen > 0);
8408
8433
  // 如果复选框启用保留记录,当保留数据存在时显示半选
8409
8434
  if (!isSelected && !halfSelect && showReserveStatus) {
8410
8435
  halfSelect = !XEUtils.isEmpty(checkboxReserveRowMap);
@@ -9207,83 +9232,75 @@ export default defineVxeComponent({
9207
9232
  const { treeConfig, dragConfig } = props;
9208
9233
  const rowDragOpts = computeRowDragOpts.value;
9209
9234
  const { afterFullData, tableFullData, fullAllDataRowIdData } = internalData;
9210
- const { isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod, dragToChildMethod } = rowDragOpts;
9235
+ const { animation, isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod, dragToChildMethod } = rowDragOpts;
9211
9236
  const treeOpts = computeTreeOpts.value;
9237
+ const cellOpts = computeCellOpts.value;
9238
+ const rowOpts = computeRowOpts.value;
9239
+ const defaultRowHeight = computeDefaultRowHeight.value;
9212
9240
  const { transform, rowField, mapChildrenField, parentField } = treeOpts;
9213
9241
  const childrenField = treeOpts.children || treeOpts.childrenField;
9214
9242
  const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null);
9215
9243
  const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0;
9244
+ const el = refElem.value;
9216
9245
  const errRest = {
9217
9246
  status: false
9218
9247
  };
9219
- if (prevDragRow && dragRow) {
9220
- // 判断是否有拖动
9221
- if (prevDragRow !== dragRow) {
9222
- const dragParams = {
9223
- oldRow: dragRow,
9224
- newRow: prevDragRow,
9225
- dragRow,
9226
- dragPos: prevDragPos,
9227
- dragToChild: !!prevDragToChild,
9228
- offsetIndex: dragOffsetIndex
9229
- };
9230
- const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
9231
- return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then((status) => {
9232
- if (!status) {
9233
- return errRest;
9234
- }
9235
- let oafIndex = -1;
9236
- let nafIndex = -1;
9237
- // 如果为树结构
9238
- if (treeConfig) {
9239
- if (transform) {
9240
- // 移出源位置
9241
- const oldRowid = getRowid($xeTable, dragRow);
9242
- const oldRest = fullAllDataRowIdData[oldRowid];
9243
- const newRowid = getRowid($xeTable, prevDragRow);
9244
- const newRest = fullAllDataRowIdData[newRowid];
9245
- if (oldRest && newRest) {
9246
- const { level: oldLevel } = oldRest;
9247
- const { level: newLevel } = newRest;
9248
- const oldAllMaps = {};
9249
- XEUtils.eachTree([dragRow], item => {
9250
- oldAllMaps[getRowid($xeTable, item)] = item;
9251
- }, { children: mapChildrenField });
9252
- let isSelfToChildStatus = false;
9253
- if (oldLevel && newLevel) {
9254
- // 子到子
9255
- if (isPeerDrag && !isCrossDrag) {
9256
- if (oldRest.row[parentField] !== newRest.row[parentField]) {
9257
- // 非同级
9258
- return errRest;
9259
- }
9260
- }
9261
- else {
9262
- if (!isCrossDrag) {
9263
- return errRest;
9264
- }
9265
- if (oldAllMaps[newRowid]) {
9266
- isSelfToChildStatus = true;
9267
- if (!(isCrossDrag && isSelfToChildDrag)) {
9268
- if (VxeUI.modal) {
9269
- VxeUI.modal.message({
9270
- status: 'error',
9271
- content: getI18n('vxe.error.treeDragChild')
9272
- });
9273
- }
9274
- return errRest;
9275
- }
9276
- }
9277
- }
9278
- }
9279
- else if (oldLevel) {
9280
- // 子到根
9281
- if (!isCrossDrag) {
9248
+ if (!(el && prevDragRow && dragRow)) {
9249
+ return Promise.resolve(errRest);
9250
+ }
9251
+ // 判断是否有拖动
9252
+ if (prevDragRow !== dragRow) {
9253
+ const dragParams = {
9254
+ oldRow: dragRow,
9255
+ newRow: prevDragRow,
9256
+ dragRow,
9257
+ dragPos: prevDragPos,
9258
+ dragToChild: !!prevDragToChild,
9259
+ offsetIndex: dragOffsetIndex
9260
+ };
9261
+ const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
9262
+ return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then((status) => {
9263
+ if (!status) {
9264
+ return errRest;
9265
+ }
9266
+ const dragRowid = getRowid($xeTable, dragRow);
9267
+ const dragRowRest = fullAllDataRowIdData[dragRowid] || {};
9268
+ const _dragRowIndex = dragRowRest._index;
9269
+ let dragRowHeight = 0;
9270
+ let dragOffsetTop = -1;
9271
+ if (animation) {
9272
+ dragRowHeight = getCellRestHeight(dragRowRest, cellOpts, rowOpts, defaultRowHeight);
9273
+ const oldTrEl = el.querySelector(`.vxe-body--row[rowid="${dragRowid}"]`);
9274
+ if (oldTrEl) {
9275
+ dragOffsetTop = oldTrEl.offsetTop;
9276
+ }
9277
+ }
9278
+ let oafIndex = -1;
9279
+ let nafIndex = -1;
9280
+ // 如果为树结构
9281
+ if (treeConfig) {
9282
+ if (transform) {
9283
+ // 移出源位置
9284
+ const oldRest = dragRowRest;
9285
+ const newRowid = getRowid($xeTable, prevDragRow);
9286
+ const newRest = fullAllDataRowIdData[newRowid];
9287
+ if (oldRest && newRest) {
9288
+ const { level: oldLevel } = oldRest;
9289
+ const { level: newLevel } = newRest;
9290
+ const oldAllMaps = {};
9291
+ XEUtils.eachTree([dragRow], item => {
9292
+ oldAllMaps[getRowid($xeTable, item)] = item;
9293
+ }, { children: mapChildrenField });
9294
+ let isSelfToChildStatus = false;
9295
+ if (oldLevel && newLevel) {
9296
+ // 子到子
9297
+ if (isPeerDrag && !isCrossDrag) {
9298
+ if (oldRest.row[parentField] !== newRest.row[parentField]) {
9299
+ // 非同级
9282
9300
  return errRest;
9283
9301
  }
9284
9302
  }
9285
- else if (newLevel) {
9286
- // 根到子
9303
+ else {
9287
9304
  if (!isCrossDrag) {
9288
9305
  return errRest;
9289
9306
  }
@@ -9300,88 +9317,160 @@ export default defineVxeComponent({
9300
9317
  }
9301
9318
  }
9302
9319
  }
9303
- else {
9304
- // 根到根
9320
+ }
9321
+ else if (oldLevel) {
9322
+ // 子到根
9323
+ if (!isCrossDrag) {
9324
+ return errRest;
9305
9325
  }
9306
- const fullList = XEUtils.toTreeArray(internalData.afterTreeFullData, {
9307
- key: rowField,
9308
- parentKey: parentField,
9309
- children: mapChildrenField
9310
- });
9311
- // 移出
9312
- const otfIndex = $xeTable.findRowIndexOf(fullList, dragRow);
9313
- fullList.splice(otfIndex, 1);
9314
- // 插入
9315
- const ptfIndex = $xeTable.findRowIndexOf(fullList, prevDragRow);
9316
- const ntfIndex = ptfIndex + dragOffsetIndex;
9317
- fullList.splice(ntfIndex, 0, dragRow);
9318
- // 改变层级
9319
- if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
9320
- XEUtils.each(dragRow[childrenField], childRow => {
9321
- childRow[parentField] = dragRow[parentField];
9322
- });
9326
+ }
9327
+ else if (newLevel) {
9328
+ // 根到子
9329
+ if (!isCrossDrag) {
9330
+ return errRest;
9331
+ }
9332
+ if (oldAllMaps[newRowid]) {
9333
+ isSelfToChildStatus = true;
9334
+ if (!(isCrossDrag && isSelfToChildDrag)) {
9335
+ if (VxeUI.modal) {
9336
+ VxeUI.modal.message({
9337
+ status: 'error',
9338
+ content: getI18n('vxe.error.treeDragChild')
9339
+ });
9340
+ }
9341
+ return errRest;
9342
+ }
9323
9343
  }
9324
- dragRow[parentField] = isDragToChildFlag ? prevDragRow[rowField] : prevDragRow[parentField];
9325
- internalData.tableFullTreeData = XEUtils.toArrayTree(fullList, {
9326
- key: rowField,
9327
- parentKey: parentField,
9328
- children: childrenField,
9329
- mapChildren: mapChildrenField
9344
+ }
9345
+ else {
9346
+ // 根到根
9347
+ }
9348
+ const fullList = XEUtils.toTreeArray(internalData.afterTreeFullData, {
9349
+ key: rowField,
9350
+ parentKey: parentField,
9351
+ children: mapChildrenField
9352
+ });
9353
+ // 移出
9354
+ const otfIndex = $xeTable.findRowIndexOf(fullList, dragRow);
9355
+ fullList.splice(otfIndex, 1);
9356
+ // 插入
9357
+ const ptfIndex = $xeTable.findRowIndexOf(fullList, prevDragRow);
9358
+ const ntfIndex = ptfIndex + dragOffsetIndex;
9359
+ fullList.splice(ntfIndex, 0, dragRow);
9360
+ // 改变层级
9361
+ if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
9362
+ XEUtils.each(dragRow[childrenField], childRow => {
9363
+ childRow[parentField] = dragRow[parentField];
9330
9364
  });
9331
9365
  }
9366
+ dragRow[parentField] = isDragToChildFlag ? prevDragRow[rowField] : prevDragRow[parentField];
9367
+ internalData.tableFullTreeData = XEUtils.toArrayTree(fullList, {
9368
+ key: rowField,
9369
+ parentKey: parentField,
9370
+ children: childrenField,
9371
+ mapChildren: mapChildrenField
9372
+ });
9332
9373
  }
9333
9374
  }
9334
- else {
9335
- // 移出
9336
- oafIndex = $xeTable.findRowIndexOf(afterFullData, dragRow);
9337
- const otfIndex = $xeTable.findRowIndexOf(tableFullData, dragRow);
9338
- afterFullData.splice(oafIndex, 1);
9339
- tableFullData.splice(otfIndex, 1);
9340
- // 插入
9341
- const pafIndex = $xeTable.findRowIndexOf(afterFullData, prevDragRow);
9342
- const ptfIndex = $xeTable.findRowIndexOf(tableFullData, prevDragRow);
9343
- nafIndex = pafIndex + dragOffsetIndex;
9344
- const ntfIndex = ptfIndex + dragOffsetIndex;
9345
- afterFullData.splice(nafIndex, 0, dragRow);
9346
- tableFullData.splice(ntfIndex, 0, dragRow);
9347
- }
9348
- reactData.isDragRowMove = true;
9349
- $xeTable.handleTableData(treeConfig && transform);
9350
- $xeTable.cacheRowMap(false);
9351
- updateScrollYStatus();
9352
- if (!(treeConfig && transform)) {
9353
- $xeTable.updateAfterDataIndex();
9354
- }
9355
- $xeTable.checkSelectionStatus();
9356
- if (reactData.scrollYLoad) {
9357
- $xeTable.updateScrollYSpace();
9358
- }
9359
- if (evnt) {
9360
- dispatchEvent('row-dragend', {
9361
- oldRow: dragRow,
9362
- newRow: prevDragRow,
9363
- dragRow,
9364
- dragPos: prevDragPos,
9365
- dragToChild: isDragToChildFlag,
9366
- offsetIndex: dragOffsetIndex,
9367
- _index: {
9368
- newIndex: nafIndex,
9369
- oldIndex: oafIndex
9375
+ }
9376
+ else {
9377
+ // 移出
9378
+ oafIndex = $xeTable.findRowIndexOf(afterFullData, dragRow);
9379
+ const otfIndex = $xeTable.findRowIndexOf(tableFullData, dragRow);
9380
+ afterFullData.splice(oafIndex, 1);
9381
+ tableFullData.splice(otfIndex, 1);
9382
+ // 插入
9383
+ const pafIndex = $xeTable.findRowIndexOf(afterFullData, prevDragRow);
9384
+ const ptfIndex = $xeTable.findRowIndexOf(tableFullData, prevDragRow);
9385
+ nafIndex = pafIndex + dragOffsetIndex;
9386
+ const ntfIndex = ptfIndex + dragOffsetIndex;
9387
+ afterFullData.splice(nafIndex, 0, dragRow);
9388
+ tableFullData.splice(ntfIndex, 0, dragRow);
9389
+ }
9390
+ $xeTable.handleTableData(treeConfig && transform);
9391
+ $xeTable.cacheRowMap(false);
9392
+ updateScrollYStatus();
9393
+ if (!(treeConfig && transform)) {
9394
+ $xeTable.updateAfterDataIndex();
9395
+ }
9396
+ $xeTable.checkSelectionStatus();
9397
+ if (reactData.scrollYLoad) {
9398
+ $xeTable.updateScrollYSpace();
9399
+ }
9400
+ if (evnt) {
9401
+ dispatchEvent('row-dragend', {
9402
+ oldRow: dragRow,
9403
+ newRow: prevDragRow,
9404
+ dragRow,
9405
+ dragPos: prevDragPos,
9406
+ dragToChild: isDragToChildFlag,
9407
+ offsetIndex: dragOffsetIndex,
9408
+ _index: {
9409
+ newIndex: nafIndex,
9410
+ oldIndex: oafIndex
9411
+ }
9412
+ }, evnt);
9413
+ }
9414
+ return nextTick().then(() => {
9415
+ if (animation) {
9416
+ const { tableData } = reactData;
9417
+ const dragRowRest = fullAllDataRowIdData[dragRowid];
9418
+ const _newRowIndex = dragRowRest._index;
9419
+ const firstRow = tableData[0];
9420
+ const firstRowRest = fullAllDataRowIdData[getRowid($xeTable, firstRow)];
9421
+ if (firstRowRest) {
9422
+ const _firstRowIndex = firstRowRest._index;
9423
+ const _lastRowIndex = _firstRowIndex + tableData.length;
9424
+ let rsIndex = -1;
9425
+ let reIndex = -1;
9426
+ let offsetRate = 1;
9427
+ if (_dragRowIndex < _firstRowIndex) {
9428
+ // 从上往下虚拟拖拽
9429
+ rsIndex = 0;
9430
+ reIndex = _newRowIndex - _firstRowIndex;
9370
9431
  }
9371
- }, evnt);
9372
- }
9373
- return nextTick().then(() => {
9374
- $xeTable.updateCellAreas();
9375
- $xeTable.recalculate();
9376
- }).then(() => {
9377
- return {
9378
- status: true
9379
- };
9380
- });
9381
- }).catch(() => {
9382
- return errRest;
9432
+ else if (_dragRowIndex > _lastRowIndex) {
9433
+ // 从下往上虚拟拖拽
9434
+ const $newRowIndex = dragRowRest.$index;
9435
+ rsIndex = $newRowIndex + 1;
9436
+ reIndex = tableData.length;
9437
+ offsetRate = -1;
9438
+ }
9439
+ else {
9440
+ if (_newRowIndex > _dragRowIndex) {
9441
+ // 从上往下拖拽
9442
+ rsIndex = _dragRowIndex - _firstRowIndex;
9443
+ reIndex = rsIndex + _newRowIndex - _dragRowIndex;
9444
+ }
9445
+ else {
9446
+ // 从下往上拖拽
9447
+ rsIndex = _newRowIndex - _firstRowIndex;
9448
+ reIndex = rsIndex + _dragRowIndex - _newRowIndex + 1;
9449
+ offsetRate = -1;
9450
+ }
9451
+ }
9452
+ const dragRangeList = tableData.slice(rsIndex, reIndex);
9453
+ if (dragRangeList.length) {
9454
+ const dtTrList = el.querySelectorAll(dragRangeList.map(row => `.vxe-body--row[rowid="${getRowid($xeTable, row)}"]`).join(','));
9455
+ moveRowAnimateToTb(dtTrList, offsetRate * dragRowHeight);
9456
+ }
9457
+ }
9458
+ const newTrList = el.querySelectorAll(`.vxe-body--row[rowid="${dragRowid}"]`);
9459
+ const newTrEl = newTrList[0];
9460
+ if (dragOffsetTop > -1 && newTrEl) {
9461
+ moveRowAnimateToTb(newTrList, dragOffsetTop - newTrEl.offsetTop);
9462
+ }
9463
+ }
9464
+ $xeTable.updateCellAreas();
9465
+ $xeTable.recalculate();
9466
+ }).then(() => {
9467
+ return {
9468
+ status: true
9469
+ };
9383
9470
  });
9384
- }
9471
+ }).catch(() => {
9472
+ return errRest;
9473
+ });
9385
9474
  }
9386
9475
  return Promise.resolve(errRest);
9387
9476
  },
@@ -9393,6 +9482,7 @@ export default defineVxeComponent({
9393
9482
  const { lazy } = treeOpts;
9394
9483
  const hasChildField = treeOpts.hasChild || treeOpts.hasChildField;
9395
9484
  const { prevDragRow, prevDragPos } = internalData;
9485
+ const el = refElem.value;
9396
9486
  if (treeConfig && lazy && prevDragToChild) {
9397
9487
  // 懒加载
9398
9488
  const newRowid = getRowid($xeTable, prevDragRow);
@@ -9411,12 +9501,10 @@ export default defineVxeComponent({
9411
9501
  }
9412
9502
  hideDropTip();
9413
9503
  clearRowDropOrigin();
9504
+ clearRowAnimate(el);
9414
9505
  internalData.prevDragToChild = false;
9415
9506
  reactData.dragRow = null;
9416
9507
  reactData.dragCol = null;
9417
- setTimeout(() => {
9418
- reactData.isDragRowMove = false;
9419
- }, 500);
9420
9508
  },
9421
9509
  handleRowDragDragoverEvent(evnt) {
9422
9510
  const { treeConfig } = props;
@@ -9499,7 +9587,7 @@ export default defineVxeComponent({
9499
9587
  },
9500
9588
  handleColDragSwapColumn() {
9501
9589
  handleUpdateColumn();
9502
- parseColumns(false).then(() => {
9590
+ return parseColumns(false).then(() => {
9503
9591
  $xeTable.updateCellAreas();
9504
9592
  $xeTable.saveCustomStore('update:sort');
9505
9593
  });
@@ -9507,71 +9595,73 @@ export default defineVxeComponent({
9507
9595
  handleColDragSwapEvent(evnt, isSyncColumn, dragCol, prevDragCol, prevDragPos, prevDragToChild) {
9508
9596
  const { mouseConfig } = props;
9509
9597
  const columnDragOpts = computeColumnDragOpts.value;
9510
- const { isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts;
9511
- const { collectColumn } = internalData;
9598
+ const { animation, isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts;
9599
+ const { collectColumn, fullColumnIdData } = internalData;
9600
+ const el = refElem.value;
9512
9601
  const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0;
9513
9602
  const errRest = {
9514
9603
  status: false
9515
9604
  };
9516
- if (prevDragCol && dragCol) {
9517
- // 判断是否有拖动
9518
- if (prevDragCol !== dragCol) {
9519
- const dragColumn = dragCol;
9520
- const newColumn = prevDragCol;
9521
- const dragParams = {
9522
- oldColumn: dragColumn,
9523
- newColumn,
9524
- dragColumn,
9525
- dragPos: prevDragPos,
9526
- dragToChild: !!prevDragToChild,
9527
- offsetIndex: dragOffsetIndex
9528
- };
9529
- const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
9530
- return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
9531
- if (!status) {
9532
- return errRest;
9533
- }
9534
- let oafIndex = -1;
9535
- let nafIndex = -1;
9536
- const oldAllMaps = {};
9605
+ if (!(el && prevDragCol && dragCol)) {
9606
+ return Promise.resolve(errRest);
9607
+ }
9608
+ // 判断是否有拖动
9609
+ if (prevDragCol !== dragCol) {
9610
+ const dragColumn = dragCol;
9611
+ const newColumn = prevDragCol;
9612
+ const dragParams = {
9613
+ oldColumn: dragColumn,
9614
+ newColumn,
9615
+ dragColumn,
9616
+ dragPos: prevDragPos,
9617
+ dragToChild: !!prevDragToChild,
9618
+ offsetIndex: dragOffsetIndex
9619
+ };
9620
+ const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
9621
+ return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
9622
+ if (!status) {
9623
+ return errRest;
9624
+ }
9625
+ let dragTargetColumn = null;
9626
+ const dragAllTargetCols = [];
9627
+ let dragColWidth = 0;
9628
+ if (animation) {
9537
9629
  XEUtils.eachTree([dragColumn], column => {
9538
- oldAllMaps[column.id] = column;
9539
- });
9540
- let isSelfToChildStatus = false;
9541
- if (dragColumn.parentId && newColumn.parentId) {
9542
- // 子到子
9543
- if (isPeerDrag && !isCrossDrag) {
9544
- if (dragColumn.parentId !== newColumn.parentId) {
9545
- // 非同级
9546
- return errRest;
9547
- }
9548
- }
9549
- else {
9550
- if (!isCrossDrag) {
9551
- return errRest;
9552
- }
9553
- if (oldAllMaps[newColumn.id]) {
9554
- isSelfToChildStatus = true;
9555
- if (!(isCrossDrag && isSelfToChildDrag)) {
9556
- if (VxeUI.modal) {
9557
- VxeUI.modal.message({
9558
- status: 'error',
9559
- content: getI18n('vxe.error.treeDragChild')
9560
- });
9561
- }
9562
- return errRest;
9563
- }
9564
- }
9630
+ if (!dragTargetColumn && (!column.children || !column.children.length)) {
9631
+ dragTargetColumn = column;
9632
+ dragColWidth += column.renderWidth;
9565
9633
  }
9634
+ dragAllTargetCols.push(column);
9635
+ });
9636
+ }
9637
+ if (!dragTargetColumn) {
9638
+ dragTargetColumn = dragColumn;
9639
+ }
9640
+ const dragColRest = fullColumnIdData[dragTargetColumn.id] || {};
9641
+ const _dragColIndex = dragColRest._index;
9642
+ let dragOffsetLeft = -1;
9643
+ if (animation) {
9644
+ const oldTrEl = el.querySelector(`.vxe-table--column[colid="${dragTargetColumn.id}"]`);
9645
+ if (oldTrEl) {
9646
+ dragOffsetLeft = oldTrEl.offsetLeft;
9566
9647
  }
9567
- else if (dragColumn.parentId) {
9568
- // 子到根
9569
- if (!isCrossDrag) {
9648
+ }
9649
+ let oafIndex = -1;
9650
+ let nafIndex = -1;
9651
+ const oldAllMaps = {};
9652
+ XEUtils.eachTree([dragColumn], column => {
9653
+ oldAllMaps[column.id] = column;
9654
+ });
9655
+ let isSelfToChildStatus = false;
9656
+ if (dragColumn.parentId && newColumn.parentId) {
9657
+ // 子到子
9658
+ if (isPeerDrag && !isCrossDrag) {
9659
+ if (dragColumn.parentId !== newColumn.parentId) {
9660
+ // 非同级
9570
9661
  return errRest;
9571
9662
  }
9572
9663
  }
9573
- else if (newColumn.parentId) {
9574
- // 根到子
9664
+ else {
9575
9665
  if (!isCrossDrag) {
9576
9666
  return errRest;
9577
9667
  }
@@ -9588,105 +9678,204 @@ export default defineVxeComponent({
9588
9678
  }
9589
9679
  }
9590
9680
  }
9591
- else {
9592
- // 根到根
9593
- }
9594
- const oldewMatchRest = XEUtils.findTree(collectColumn, item => item.id === dragColumn.id);
9595
- // 改变层级
9596
- if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
9597
- if (oldewMatchRest) {
9598
- const { items: oCols, index: oIndex } = oldewMatchRest;
9599
- const childList = dragColumn.children || [];
9600
- childList.forEach(column => {
9601
- column.parentId = dragColumn.parentId;
9602
- });
9603
- oCols.splice(oIndex, 1, ...childList);
9604
- dragColumn.children = [];
9605
- }
9681
+ }
9682
+ else if (dragColumn.parentId) {
9683
+ // 子到根
9684
+ if (!isCrossDrag) {
9685
+ return errRest;
9606
9686
  }
9607
- else {
9608
- if (oldewMatchRest) {
9609
- const { items: oCols, index: oIndex, parent: oParent } = oldewMatchRest;
9610
- oCols.splice(oIndex, 1);
9611
- if (!oParent) {
9612
- oafIndex = oIndex;
9687
+ }
9688
+ else if (newColumn.parentId) {
9689
+ // 根到子
9690
+ if (!isCrossDrag) {
9691
+ return errRest;
9692
+ }
9693
+ if (oldAllMaps[newColumn.id]) {
9694
+ isSelfToChildStatus = true;
9695
+ if (!(isCrossDrag && isSelfToChildDrag)) {
9696
+ if (VxeUI.modal) {
9697
+ VxeUI.modal.message({
9698
+ status: 'error',
9699
+ content: getI18n('vxe.error.treeDragChild')
9700
+ });
9613
9701
  }
9702
+ return errRest;
9614
9703
  }
9615
9704
  }
9616
- const newMatchRest = XEUtils.findTree(collectColumn, item => item.id === newColumn.id);
9617
- if (newMatchRest) {
9618
- const { items: nCols, index: nIndex, parent: nParent } = newMatchRest;
9619
- // 转子级
9620
- if ((isCrossDrag && isToChildDrag) && isDragToChildFlag) {
9621
- dragColumn.parentId = newColumn.id;
9622
- newColumn.children = (newColumn.children || []).concat([dragColumn]);
9623
- }
9624
- else {
9625
- dragColumn.parentId = newColumn.parentId;
9626
- nCols.splice(nIndex + dragOffsetIndex, 0, dragColumn);
9627
- }
9628
- if (!nParent) {
9629
- nafIndex = nIndex;
9630
- }
9705
+ }
9706
+ else {
9707
+ // 根到根
9708
+ }
9709
+ const oldewMatchRest = XEUtils.findTree(collectColumn, item => item.id === dragColumn.id);
9710
+ // 改变层级
9711
+ if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
9712
+ if (oldewMatchRest) {
9713
+ const { items: oCols, index: oIndex } = oldewMatchRest;
9714
+ const childList = dragColumn.children || [];
9715
+ childList.forEach(column => {
9716
+ column.parentId = dragColumn.parentId;
9717
+ });
9718
+ oCols.splice(oIndex, 1, ...childList);
9719
+ dragColumn.children = [];
9631
9720
  }
9632
- XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
9633
- if (!parentColumn) {
9634
- const sortIndex = index + 1;
9635
- column.renderSortNumber = sortIndex;
9636
- }
9637
- });
9638
- reactData.isDragColMove = true;
9639
- if (mouseConfig) {
9640
- if ($xeTable.clearSelected) {
9641
- $xeTable.clearSelected();
9642
- }
9643
- if ($xeTable.clearCellAreas) {
9644
- $xeTable.clearCellAreas();
9645
- $xeTable.clearCopyCellArea();
9721
+ }
9722
+ else {
9723
+ if (oldewMatchRest) {
9724
+ const { items: oCols, index: oIndex, parent: oParent } = oldewMatchRest;
9725
+ oCols.splice(oIndex, 1);
9726
+ if (!oParent) {
9727
+ oafIndex = oIndex;
9646
9728
  }
9647
9729
  }
9648
- if (evnt) {
9649
- dispatchEvent('column-dragend', {
9650
- oldColumn: dragColumn,
9651
- newColumn,
9652
- dragColumn,
9653
- dragPos: prevDragPos,
9654
- dragToChild: isDragToChildFlag,
9655
- offsetIndex: dragOffsetIndex,
9656
- _index: {
9657
- newIndex: nafIndex,
9658
- oldIndex: oafIndex
9659
- }
9660
- }, evnt);
9730
+ }
9731
+ const newMatchRest = XEUtils.findTree(collectColumn, item => item.id === newColumn.id);
9732
+ if (newMatchRest) {
9733
+ const { items: nCols, index: nIndex, parent: nParent } = newMatchRest;
9734
+ // 转子级
9735
+ if ((isCrossDrag && isToChildDrag) && isDragToChildFlag) {
9736
+ dragColumn.parentId = newColumn.id;
9737
+ newColumn.children = (newColumn.children || []).concat([dragColumn]);
9738
+ }
9739
+ else {
9740
+ dragColumn.parentId = newColumn.parentId;
9741
+ nCols.splice(nIndex + dragOffsetIndex, 0, dragColumn);
9742
+ }
9743
+ if (!nParent) {
9744
+ nafIndex = nIndex;
9745
+ }
9746
+ }
9747
+ XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
9748
+ if (!parentColumn) {
9749
+ const sortIndex = index + 1;
9750
+ column.renderSortNumber = sortIndex;
9661
9751
  }
9752
+ });
9753
+ if (mouseConfig) {
9754
+ if ($xeTable.clearSelected) {
9755
+ $xeTable.clearSelected();
9756
+ }
9757
+ if ($xeTable.clearCellAreas) {
9758
+ $xeTable.clearCellAreas();
9759
+ $xeTable.clearCopyCellArea();
9760
+ }
9761
+ }
9762
+ if (evnt) {
9763
+ dispatchEvent('column-dragend', {
9764
+ oldColumn: dragColumn,
9765
+ newColumn,
9766
+ dragColumn,
9767
+ dragPos: prevDragPos,
9768
+ dragToChild: isDragToChildFlag,
9769
+ offsetIndex: dragOffsetIndex,
9770
+ _index: {
9771
+ newIndex: nafIndex,
9772
+ oldIndex: oafIndex
9773
+ }
9774
+ }, evnt);
9775
+ }
9776
+ return nextTick().then(() => {
9662
9777
  if (isSyncColumn) {
9663
- $xeTable.handleColDragSwapColumn();
9778
+ return $xeTable.handleColDragSwapColumn();
9779
+ }
9780
+ }).then(() => {
9781
+ if (animation) {
9782
+ const { tableColumn } = reactData;
9783
+ const { visibleColumn, fullColumnIdData } = internalData;
9784
+ let dragNewColumn = null;
9785
+ const dragNewColMaps = {};
9786
+ XEUtils.eachTree([dragColumn], column => {
9787
+ if (!dragNewColumn && (!column.children || !column.children.length)) {
9788
+ dragNewColumn = column;
9789
+ }
9790
+ dragNewColMaps[column.id] = column;
9791
+ });
9792
+ if (!dragNewColumn) {
9793
+ dragNewColumn = dragColumn;
9794
+ }
9795
+ if (dragColWidth && dragAllTargetCols.length) {
9796
+ const _newColIndex = XEUtils.findIndexOf(visibleColumn, column => !!dragNewColumn && column.id === dragNewColumn.id);
9797
+ const firstCol = tableColumn[0];
9798
+ const firstColRest = fullColumnIdData[firstCol.id];
9799
+ if (firstColRest) {
9800
+ const _firstColIndex = firstColRest._index;
9801
+ const _lastColIndex = _firstColIndex + tableColumn.length;
9802
+ let csIndex = -1;
9803
+ let ceIndex = -1;
9804
+ let offsetRate = 1;
9805
+ if (_dragColIndex < _firstColIndex) {
9806
+ // 从左往右虚拟拖拽
9807
+ csIndex = 0;
9808
+ ceIndex = _newColIndex - _firstColIndex;
9809
+ }
9810
+ else if (_dragColIndex > _lastColIndex) {
9811
+ // 从右往左虚拟拖拽
9812
+ const $newRowIndex = dragColRest.$index;
9813
+ csIndex = $newRowIndex + 1;
9814
+ ceIndex = tableColumn.length;
9815
+ offsetRate = -1;
9816
+ }
9817
+ else {
9818
+ if (_newColIndex > _dragColIndex) {
9819
+ // 从左往右拖拽
9820
+ csIndex = _dragColIndex - _firstColIndex;
9821
+ ceIndex = csIndex + _newColIndex - _dragColIndex;
9822
+ }
9823
+ else {
9824
+ // 从右往左拖拽
9825
+ csIndex = _newColIndex - _firstColIndex + 1;
9826
+ ceIndex = csIndex + _dragColIndex - _newColIndex;
9827
+ offsetRate = -1;
9828
+ }
9829
+ }
9830
+ const dragRangeList = [];
9831
+ const dragRangeMaps = {};
9832
+ for (let i = csIndex; i < ceIndex; i++) {
9833
+ const column = tableColumn[i];
9834
+ if (!dragRangeMaps[column.id] && !dragNewColMaps[column.id]) {
9835
+ dragRangeMaps[column.id] = column;
9836
+ dragRangeList.push(column);
9837
+ }
9838
+ }
9839
+ XEUtils.eachTree([newColumn], column => {
9840
+ if (!dragRangeMaps[column.id]) {
9841
+ dragRangeMaps[column.id] = column;
9842
+ dragRangeList.push(column);
9843
+ }
9844
+ });
9845
+ if (dragRangeList.length) {
9846
+ const dtTrList = el.querySelectorAll(dragRangeList.map(column => `.vxe-table--column[colid="${column.id}"]`).join(','));
9847
+ moveColAnimateToLr(dtTrList, offsetRate * dragColWidth);
9848
+ }
9849
+ }
9850
+ const newTrList = el.querySelectorAll(dragAllTargetCols.map(column => `.vxe-table--column[colid="${column.id}"]`).join(','));
9851
+ const newTdEl = newTrList[0];
9852
+ if (dragOffsetLeft > -1 && newTdEl) {
9853
+ moveColAnimateToLr(newTrList, dragOffsetLeft - newTdEl.offsetLeft);
9854
+ }
9855
+ }
9664
9856
  }
9857
+ loadScrollXData();
9665
9858
  return {
9666
9859
  status: true
9667
9860
  };
9668
- }).catch(() => {
9669
- return errRest;
9670
9861
  });
9671
- }
9862
+ }).catch(() => {
9863
+ return errRest;
9864
+ });
9672
9865
  }
9673
9866
  return Promise.resolve(errRest);
9674
9867
  },
9675
9868
  handleHeaderCellDragDragendEvent(evnt) {
9676
9869
  const { dragCol } = reactData;
9677
9870
  const { prevDragCol, prevDragPos, prevDragToChild } = internalData;
9871
+ const el = refElem.value;
9678
9872
  $xeTable.handleColDragSwapEvent(evnt, true, dragCol, prevDragCol, prevDragPos, prevDragToChild);
9679
9873
  hideDropTip();
9680
9874
  clearColDropOrigin();
9875
+ clearColAnimate(el);
9681
9876
  internalData.prevDragToChild = false;
9682
9877
  reactData.dragRow = null;
9683
9878
  reactData.dragCol = null;
9684
- setTimeout(() => {
9685
- reactData.isDragColMove = false;
9686
- $xeTable.recalculate().then(() => {
9687
- loadScrollXData();
9688
- });
9689
- }, 500);
9690
9879
  },
9691
9880
  handleHeaderCellDragDragoverEvent(evnt) {
9692
9881
  const { dragCol } = reactData;
@@ -9760,7 +9949,6 @@ export default defineVxeComponent({
9760
9949
  const { column } = params;
9761
9950
  const dragEl = evnt.currentTarget;
9762
9951
  const thEl = trigger === 'cell' ? dragEl : (_a = dragEl.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement;
9763
- reactData.isDragColMove = false;
9764
9952
  clearColDropOrigin();
9765
9953
  if (dragStartMethod && !dragStartMethod(params)) {
9766
9954
  thEl.draggable = false;
@@ -9781,7 +9969,6 @@ export default defineVxeComponent({
9781
9969
  hideDropTip();
9782
9970
  reactData.dragRow = null;
9783
9971
  reactData.dragCol = null;
9784
- reactData.isDragColMove = false;
9785
9972
  },
9786
9973
  handleScrollEvent(evnt, isRollY, isRollX, scrollTop, scrollLeft, params) {
9787
9974
  const { highlightHoverRow } = props;
@@ -9848,8 +10035,6 @@ export default defineVxeComponent({
9848
10035
  }
9849
10036
  internalData.lastScrollTop = scrollTop;
9850
10037
  }
9851
- reactData.isDragColMove = false;
9852
- reactData.isDragRowMove = false;
9853
10038
  reactData.lastScrollTime = Date.now();
9854
10039
  const evntParams = Object.assign({ scrollTop,
9855
10040
  scrollLeft,
@@ -11473,7 +11658,7 @@ export default defineVxeComponent({
11473
11658
  if (rowOpts.height && !props.showOverflow) {
11474
11659
  warnLog('vxe.error.notProp', ['table.show-overflow']);
11475
11660
  }
11476
- if (!$xeTable.triggerCellAreaMousedownEvent) {
11661
+ if (!$xeTable.triggerCellAreaMousednEvent) {
11477
11662
  if (props.areaConfig) {
11478
11663
  warnLog('vxe.error.notProp', ['area-config']);
11479
11664
  }
@@ -11657,6 +11842,7 @@ export default defineVxeComponent({
11657
11842
  nextTick(() => {
11658
11843
  if (props.loading) {
11659
11844
  if (!VxeUILoadingComponent && !slots.loading) {
11845
+ errLog('vxe.error.errProp', ['loading=true', 'loading=false | <template #loading>...</template>']);
11660
11846
  errLog('vxe.error.reqComp', ['vxe-loading']);
11661
11847
  }
11662
11848
  }
@@ -11665,6 +11851,24 @@ export default defineVxeComponent({
11665
11851
  (props.showFooterOverflow === true || props.showFooterOverflow === 'tooltip') ||
11666
11852
  props.tooltipConfig || props.editRules) {
11667
11853
  if (!VxeUITooltipComponent) {
11854
+ if (props.showOverflow === true) {
11855
+ errLog('vxe.error.errProp', ['show-overflow=true', 'show-overflow=title']);
11856
+ }
11857
+ if (props.showOverflow === 'tooltip') {
11858
+ errLog('vxe.error.errProp', ['show-overflow=tooltip', 'show-overflow=title']);
11859
+ }
11860
+ if (props.showHeaderOverflow === true) {
11861
+ errLog('vxe.error.errProp', ['show-header-overflow=true', 'show-header-overflow=title']);
11862
+ }
11863
+ if (props.showHeaderOverflow === 'tooltip') {
11864
+ errLog('vxe.error.errProp', ['show-header-overflow=tooltip', 'show-header-overflow=title']);
11865
+ }
11866
+ if (props.showFooterOverflow === true) {
11867
+ errLog('vxe.error.errProp', ['show-footer-overflow=true', 'show-footer-overflow=title']);
11868
+ }
11869
+ if (props.showFooterOverflow === 'tooltip') {
11870
+ errLog('vxe.error.errProp', ['show-footer-overflow=tooltip', 'show-footer-overflow=title']);
11871
+ }
11668
11872
  errLog('vxe.error.reqComp', ['vxe-tooltip']);
11669
11873
  }
11670
11874
  }