vxe-table 3.16.0-beta.1 → 3.16.0-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/es/grid/src/grid.js +17 -5
- package/es/index.css +1 -1
- package/es/index.min.css +1 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/table/module/custom/mixin.js +0 -4
- package/es/table/module/custom/panel.js +0 -1
- package/es/table/src/anime.js +46 -0
- package/es/table/src/body.js +15 -40
- package/es/table/src/columnInfo.js +5 -0
- package/es/table/src/footer.js +1 -19
- package/es/table/src/header.js +1 -19
- package/es/table/src/methods.js +536 -346
- package/es/table/src/table.js +21 -2
- package/es/table/style.css +8 -8
- package/es/table/style.min.css +1 -1
- package/es/ui/index.js +2 -1
- package/es/ui/src/log.js +1 -1
- package/es/vxe-table/style.css +8 -8
- package/es/vxe-table/style.min.css +1 -1
- package/lib/grid/src/grid.js +22 -7
- package/lib/grid/src/grid.min.js +1 -1
- package/lib/index.css +1 -1
- package/lib/index.min.css +1 -1
- package/lib/index.umd.js +646 -436
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/table/module/custom/mixin.js +0 -4
- package/lib/table/module/custom/mixin.min.js +1 -1
- package/lib/table/module/custom/panel.js +0 -1
- package/lib/table/module/custom/panel.min.js +1 -1
- package/lib/table/src/anime.js +56 -0
- package/lib/table/src/anime.min.js +1 -0
- package/lib/table/src/body.js +3 -28
- package/lib/table/src/body.min.js +1 -1
- package/lib/table/src/columnInfo.js +5 -0
- package/lib/table/src/columnInfo.min.js +1 -1
- package/lib/table/src/footer.js +1 -19
- package/lib/table/src/footer.min.js +1 -1
- package/lib/table/src/header.js +1 -19
- package/lib/table/src/header.min.js +1 -1
- package/lib/table/src/methods.js +543 -355
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/table.js +21 -1
- package/lib/table/src/table.min.js +1 -1
- package/lib/table/style/style.css +8 -8
- package/lib/table/style/style.min.css +1 -1
- package/lib/ui/index.js +2 -1
- package/lib/ui/index.min.js +1 -1
- package/lib/ui/src/log.js +1 -1
- package/lib/ui/src/log.min.js +1 -1
- package/lib/vxe-table/style/style.css +8 -8
- package/lib/vxe-table/style/style.min.css +1 -1
- package/package.json +1 -1
- package/packages/grid/src/grid.ts +19 -6
- package/packages/table/module/custom/mixin.ts +0 -4
- package/packages/table/module/custom/panel.ts +0 -1
- package/packages/table/src/anime.ts +52 -0
- package/packages/table/src/body.ts +15 -40
- package/packages/table/src/columnInfo.ts +5 -0
- package/packages/table/src/footer.ts +1 -19
- package/packages/table/src/header.ts +1 -20
- package/packages/table/src/methods.ts +558 -360
- package/packages/table/src/table.ts +21 -2
- package/packages/ui/index.ts +1 -0
- package/styles/components/table.scss +9 -9
- /package/es/{iconfont.1750910486943.ttf → iconfont.1751247393221.ttf} +0 -0
- /package/es/{iconfont.1750910486943.woff → iconfont.1751247393221.woff} +0 -0
- /package/es/{iconfont.1750910486943.woff2 → iconfont.1751247393221.woff2} +0 -0
- /package/lib/{iconfont.1750910486943.ttf → iconfont.1751247393221.ttf} +0 -0
- /package/lib/{iconfont.1750910486943.woff → iconfont.1751247393221.woff} +0 -0
- /package/lib/{iconfont.1750910486943.woff2 → iconfont.1751247393221.woff2} +0 -0
package/es/table/src/methods.js
CHANGED
|
@@ -3,8 +3,9 @@ import { getTpImg, isPx, isScale, hasClass, addClass, removeClass, getEventTarge
|
|
|
3
3
|
import { getLastZIndex, nextZIndex, hasChildrenList, getFuncText, isEnableConf, formatText, eqEmptyValue } from '../../ui/src/utils';
|
|
4
4
|
import { VxeUI } from '../../ui';
|
|
5
5
|
import Cell from './cell';
|
|
6
|
-
import { getRowUniqueId, clearTableAllStatus, toFilters, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getRefElem } from './util';
|
|
6
|
+
import { getRowUniqueId, clearTableAllStatus, toFilters, getRowkey, getRowid, rowToVisible, colToVisible, getCellValue, setCellValue, handleRowidOrRow, handleFieldOrColumn, toTreePathSeq, restoreScrollLocation, getRootColumn, getColReMinWidth, createHandleUpdateRowId, createHandleGetRowId, getRefElem, getCellRestHeight } from './util';
|
|
7
7
|
import { getSlotVNs } from '../../ui/src/vn';
|
|
8
|
+
import { moveRowAnimateToTb, clearRowAnimate, moveColAnimateToLr, clearColAnimate } from './anime';
|
|
8
9
|
import { warnLog, errLog } from '../../ui/src/log';
|
|
9
10
|
const { getConfig, getI18n, renderer, formats, interceptor, createEvent } = VxeUI;
|
|
10
11
|
const browseObj = XEUtils.browse();
|
|
@@ -417,7 +418,7 @@ function handleVirtualTreeExpand($xeTable, rows, expanded) {
|
|
|
417
418
|
updateAfterDataIndex($xeTable);
|
|
418
419
|
return $xeTable.$nextTick();
|
|
419
420
|
}).then(() => {
|
|
420
|
-
return $xeTable
|
|
421
|
+
return handleLazyRecalculate($xeTable, true, true, true);
|
|
421
422
|
}).then(() => {
|
|
422
423
|
setTimeout(() => {
|
|
423
424
|
$xeTable.updateCellAreas();
|
|
@@ -492,7 +493,7 @@ function handleRowGroupVirtualExpand($xeTable, rows, expanded) {
|
|
|
492
493
|
updateAfterDataIndex($xeTable);
|
|
493
494
|
return $xeTable.$nextTick();
|
|
494
495
|
}).then(() => {
|
|
495
|
-
return $xeTable
|
|
496
|
+
return handleLazyRecalculate($xeTable, true, true, true);
|
|
496
497
|
}).then(() => {
|
|
497
498
|
setTimeout(() => {
|
|
498
499
|
$xeTable.updateCellAreas();
|
|
@@ -2233,8 +2234,6 @@ function clearDragStatus($xeTable) {
|
|
|
2233
2234
|
hideDropTip($xeTable);
|
|
2234
2235
|
reactData.dragRow = null;
|
|
2235
2236
|
reactData.dragCol = null;
|
|
2236
|
-
reactData.isDragColMove = false;
|
|
2237
|
-
reactData.isDragRowMove = false;
|
|
2238
2237
|
}
|
|
2239
2238
|
}
|
|
2240
2239
|
function clearRowDropOrigin($xeTable) {
|
|
@@ -2575,7 +2574,7 @@ function calcScrollbar($xeTable) {
|
|
|
2575
2574
|
$xeTable.checkScrolling();
|
|
2576
2575
|
}
|
|
2577
2576
|
}
|
|
2578
|
-
function
|
|
2577
|
+
function handleRecalculateStyle($xeTable, reFull, reWidth, reHeight) {
|
|
2579
2578
|
const internalData = $xeTable;
|
|
2580
2579
|
const el = $xeTable.$refs.refElem;
|
|
2581
2580
|
internalData.rceRunTime = Date.now();
|
|
@@ -2590,19 +2589,28 @@ function handleRecalculateLayout($xeTable, reFull) {
|
|
|
2590
2589
|
calcVarRowHeightConfig($xeTable, 'small', smallEl);
|
|
2591
2590
|
calcVarRowHeightConfig($xeTable, 'mini', miniEl);
|
|
2592
2591
|
}
|
|
2593
|
-
|
|
2594
|
-
|
|
2592
|
+
if (reWidth) {
|
|
2593
|
+
calcCellWidth($xeTable);
|
|
2594
|
+
}
|
|
2595
|
+
if (reFull) {
|
|
2596
|
+
autoCellWidth($xeTable);
|
|
2597
|
+
}
|
|
2595
2598
|
calcScrollbar($xeTable);
|
|
2596
2599
|
updateStyle($xeTable);
|
|
2597
2600
|
updateRowExpandStyle($xeTable);
|
|
2598
2601
|
return computeScrollLoad($xeTable).then(() => {
|
|
2599
2602
|
// 初始化时需要在列计算之后再执行优化运算,达到最优显示效果
|
|
2600
|
-
|
|
2603
|
+
if (reWidth) {
|
|
2604
|
+
calcCellWidth($xeTable);
|
|
2605
|
+
}
|
|
2601
2606
|
if (reFull) {
|
|
2602
2607
|
autoCellWidth($xeTable);
|
|
2603
2608
|
}
|
|
2604
|
-
|
|
2609
|
+
if (reHeight) {
|
|
2610
|
+
calcCellHeight($xeTable);
|
|
2611
|
+
}
|
|
2605
2612
|
updateStyle($xeTable);
|
|
2613
|
+
calcScrollbar($xeTable);
|
|
2606
2614
|
if (reFull) {
|
|
2607
2615
|
updateRowOffsetTop($xeTable);
|
|
2608
2616
|
}
|
|
@@ -2612,6 +2620,37 @@ function handleRecalculateLayout($xeTable, reFull) {
|
|
|
2612
2620
|
}
|
|
2613
2621
|
});
|
|
2614
2622
|
}
|
|
2623
|
+
function handleLazyRecalculate($xeTable, reFull, reWidth, reHeight) {
|
|
2624
|
+
const internalData = $xeTable;
|
|
2625
|
+
return new Promise(resolve => {
|
|
2626
|
+
const { rceTimeout, rceRunTime } = internalData;
|
|
2627
|
+
const resizeOpts = $xeTable.computeResizeOpts;
|
|
2628
|
+
const refreshDelay = resizeOpts.refreshDelay || 20;
|
|
2629
|
+
const el = $xeTable.$refs.refElem;
|
|
2630
|
+
if (el && el.clientWidth) {
|
|
2631
|
+
autoCellWidth($xeTable);
|
|
2632
|
+
updateRowExpandStyle($xeTable);
|
|
2633
|
+
}
|
|
2634
|
+
if (rceTimeout) {
|
|
2635
|
+
clearTimeout(rceTimeout);
|
|
2636
|
+
if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
|
|
2637
|
+
resolve(handleRecalculateStyle($xeTable, !!reFull, reWidth, reHeight));
|
|
2638
|
+
}
|
|
2639
|
+
else {
|
|
2640
|
+
$xeTable.$nextTick(() => {
|
|
2641
|
+
resolve();
|
|
2642
|
+
});
|
|
2643
|
+
}
|
|
2644
|
+
}
|
|
2645
|
+
else {
|
|
2646
|
+
resolve(handleRecalculateStyle($xeTable, !!reFull, reWidth, reHeight));
|
|
2647
|
+
}
|
|
2648
|
+
internalData.rceTimeout = setTimeout(() => {
|
|
2649
|
+
internalData.rceTimeout = undefined;
|
|
2650
|
+
handleRecalculateStyle($xeTable, !!reFull, reWidth, reHeight);
|
|
2651
|
+
}, refreshDelay);
|
|
2652
|
+
});
|
|
2653
|
+
}
|
|
2615
2654
|
function handleUpdateAggValues($xeTable) {
|
|
2616
2655
|
const reactData = $xeTable;
|
|
2617
2656
|
const internalData = $xeTable;
|
|
@@ -2834,8 +2873,6 @@ function loadTableData($xeTable, datas, isReset) {
|
|
|
2834
2873
|
internalData.removeRowMaps = {};
|
|
2835
2874
|
reactData.removeRowFlag++;
|
|
2836
2875
|
const sYLoad = updateScrollYStatus($xeTable, fullData);
|
|
2837
|
-
reactData.isDragColMove = false;
|
|
2838
|
-
reactData.isDragRowMove = false;
|
|
2839
2876
|
// 全量数据
|
|
2840
2877
|
internalData.tableFullData = fullData;
|
|
2841
2878
|
internalData.tableFullTreeData = isRGroup ? [] : treeData;
|
|
@@ -2896,11 +2933,11 @@ function loadTableData($xeTable, datas, isReset) {
|
|
|
2896
2933
|
$xeTable.checkSelectionStatus();
|
|
2897
2934
|
return new Promise(resolve => {
|
|
2898
2935
|
$xeTable.$nextTick()
|
|
2899
|
-
.then(() =>
|
|
2936
|
+
.then(() => handleRecalculateStyle($xeTable, false, false, false))
|
|
2900
2937
|
.then(() => {
|
|
2901
2938
|
calcCellHeight($xeTable);
|
|
2902
2939
|
updateRowOffsetTop($xeTable);
|
|
2903
|
-
return
|
|
2940
|
+
return handleRecalculateStyle($xeTable, false, false, false);
|
|
2904
2941
|
})
|
|
2905
2942
|
.then(() => {
|
|
2906
2943
|
let targetScrollLeft = lastScrollLeft;
|
|
@@ -2915,7 +2952,7 @@ function loadTableData($xeTable, datas, isReset) {
|
|
|
2915
2952
|
targetScrollTop = 0;
|
|
2916
2953
|
}
|
|
2917
2954
|
reactData.isRowLoading = false;
|
|
2918
|
-
|
|
2955
|
+
handleRecalculateStyle($xeTable, false, false, false);
|
|
2919
2956
|
// 是否变更虚拟滚动
|
|
2920
2957
|
if (oldScrollYLoad === sYLoad) {
|
|
2921
2958
|
restoreScrollLocation($xeTable, targetScrollLeft, targetScrollTop)
|
|
@@ -3164,7 +3201,6 @@ function handleColumn($xeTable, collectColumn) {
|
|
|
3164
3201
|
const tableFullColumn = getColumnList(collectColumn);
|
|
3165
3202
|
internalData.tableFullColumn = tableFullColumn;
|
|
3166
3203
|
reactData.isColLoading = true;
|
|
3167
|
-
reactData.isDragColMove = false;
|
|
3168
3204
|
initColumnSort($xeTable);
|
|
3169
3205
|
return Promise.resolve(restoreCustomStorage($xeTable)).then(() => {
|
|
3170
3206
|
const { scrollXLoad, scrollYLoad, expandColumn } = reactData;
|
|
@@ -3653,10 +3689,10 @@ const Methods = {
|
|
|
3653
3689
|
}
|
|
3654
3690
|
}).then(() => {
|
|
3655
3691
|
$xeTable.updateCellAreas();
|
|
3656
|
-
return $xeTable
|
|
3692
|
+
return handleLazyRecalculate($xeTable, true, true, true);
|
|
3657
3693
|
}).then(() => {
|
|
3658
3694
|
// 存在滚动行为未结束情况
|
|
3659
|
-
setTimeout(() => $xeTable
|
|
3695
|
+
setTimeout(() => handleLazyRecalculate($xeTable, false, true, true), 50);
|
|
3660
3696
|
});
|
|
3661
3697
|
},
|
|
3662
3698
|
handleTableData(force) {
|
|
@@ -3708,7 +3744,7 @@ const Methods = {
|
|
|
3708
3744
|
if (!initStatus) {
|
|
3709
3745
|
handleLoadDefaults($xeTable);
|
|
3710
3746
|
}
|
|
3711
|
-
return
|
|
3747
|
+
return handleLazyRecalculate($xeTable, false, true, true);
|
|
3712
3748
|
});
|
|
3713
3749
|
},
|
|
3714
3750
|
/**
|
|
@@ -3725,7 +3761,7 @@ const Methods = {
|
|
|
3725
3761
|
})
|
|
3726
3762
|
.then(() => {
|
|
3727
3763
|
handleLoadDefaults($xeTable);
|
|
3728
|
-
return
|
|
3764
|
+
return handleLazyRecalculate($xeTable, false, true, true);
|
|
3729
3765
|
});
|
|
3730
3766
|
},
|
|
3731
3767
|
/**
|
|
@@ -4217,7 +4253,7 @@ const Methods = {
|
|
|
4217
4253
|
}
|
|
4218
4254
|
return $xeTable.$nextTick().then(() => {
|
|
4219
4255
|
$xeTable.updateCellAreas();
|
|
4220
|
-
return $xeTable
|
|
4256
|
+
return handleLazyRecalculate($xeTable, false, true, true);
|
|
4221
4257
|
});
|
|
4222
4258
|
}
|
|
4223
4259
|
return $xeTable.reloadData(tableSourceData);
|
|
@@ -5108,7 +5144,7 @@ const Methods = {
|
|
|
5108
5144
|
return parseColumns($xeTable, true).then(() => {
|
|
5109
5145
|
return this.refreshScroll();
|
|
5110
5146
|
}).then(() => {
|
|
5111
|
-
return
|
|
5147
|
+
return handleLazyRecalculate($xeTable, false, true, true);
|
|
5112
5148
|
});
|
|
5113
5149
|
},
|
|
5114
5150
|
/**
|
|
@@ -5639,35 +5675,8 @@ const Methods = {
|
|
|
5639
5675
|
*/
|
|
5640
5676
|
recalculate(reFull) {
|
|
5641
5677
|
const $xeTable = this;
|
|
5642
|
-
const
|
|
5643
|
-
return
|
|
5644
|
-
const { rceTimeout, rceRunTime } = internalData;
|
|
5645
|
-
const resizeOpts = $xeTable.computeResizeOpts;
|
|
5646
|
-
const refreshDelay = resizeOpts.refreshDelay || 20;
|
|
5647
|
-
const el = $xeTable.$refs.refElem;
|
|
5648
|
-
if (el && el.clientWidth) {
|
|
5649
|
-
autoCellWidth($xeTable);
|
|
5650
|
-
updateRowExpandStyle($xeTable);
|
|
5651
|
-
}
|
|
5652
|
-
if (rceTimeout) {
|
|
5653
|
-
clearTimeout(rceTimeout);
|
|
5654
|
-
if (rceRunTime && rceRunTime + (refreshDelay - 5) < Date.now()) {
|
|
5655
|
-
resolve(handleRecalculateLayout($xeTable, !!reFull));
|
|
5656
|
-
}
|
|
5657
|
-
else {
|
|
5658
|
-
$xeTable.$nextTick(() => {
|
|
5659
|
-
resolve();
|
|
5660
|
-
});
|
|
5661
|
-
}
|
|
5662
|
-
}
|
|
5663
|
-
else {
|
|
5664
|
-
resolve(handleRecalculateLayout($xeTable, !!reFull));
|
|
5665
|
-
}
|
|
5666
|
-
internalData.rceTimeout = setTimeout(() => {
|
|
5667
|
-
internalData.rceTimeout = undefined;
|
|
5668
|
-
handleRecalculateLayout($xeTable, !!reFull);
|
|
5669
|
-
}, refreshDelay);
|
|
5670
|
-
});
|
|
5678
|
+
const isForce = !!reFull;
|
|
5679
|
+
return handleLazyRecalculate($xeTable, isForce, isForce, isForce);
|
|
5671
5680
|
},
|
|
5672
5681
|
updateStyle() {
|
|
5673
5682
|
const $xeTable = this;
|
|
@@ -6276,9 +6285,11 @@ const Methods = {
|
|
|
6276
6285
|
}
|
|
6277
6286
|
},
|
|
6278
6287
|
handleGlobalResizeEvent() {
|
|
6279
|
-
this
|
|
6280
|
-
|
|
6281
|
-
|
|
6288
|
+
const $xeTable = this;
|
|
6289
|
+
$xeTable.closeMenu();
|
|
6290
|
+
$xeTable.updateCellAreas();
|
|
6291
|
+
handleLazyRecalculate($xeTable, true, true, true);
|
|
6292
|
+
$xeTable.updateCellAreas();
|
|
6282
6293
|
},
|
|
6283
6294
|
/**
|
|
6284
6295
|
* 处理合并
|
|
@@ -6844,7 +6855,8 @@ const Methods = {
|
|
|
6844
6855
|
const childList = vals[2];
|
|
6845
6856
|
let sLen = 0; // 已选
|
|
6846
6857
|
let hLen = 0; // 半选
|
|
6847
|
-
let vLen = 0; //
|
|
6858
|
+
let vLen = 0; // 有效子行
|
|
6859
|
+
const cLen = childList.length; // 有效子行
|
|
6848
6860
|
childList.forEach(checkMethod
|
|
6849
6861
|
? (item) => {
|
|
6850
6862
|
const childRowid = handleGetRowId(item);
|
|
@@ -6878,16 +6890,29 @@ const Methods = {
|
|
|
6878
6890
|
}
|
|
6879
6891
|
vLen++;
|
|
6880
6892
|
});
|
|
6881
|
-
let isSelected =
|
|
6882
|
-
if (
|
|
6883
|
-
if (
|
|
6884
|
-
isSelected = sLen >= vLen;
|
|
6893
|
+
let isSelected = false;
|
|
6894
|
+
if (cLen > 0) {
|
|
6895
|
+
if (vLen > 0) {
|
|
6896
|
+
isSelected = (sLen > 0 || hLen > 0) && sLen >= vLen;
|
|
6885
6897
|
}
|
|
6886
6898
|
else {
|
|
6887
|
-
|
|
6899
|
+
// 如果存在子项禁用
|
|
6900
|
+
if ((sLen > 0 && sLen >= vLen)) {
|
|
6901
|
+
isSelected = true;
|
|
6902
|
+
}
|
|
6903
|
+
else if (selectCheckboxMaps[rowid]) {
|
|
6904
|
+
isSelected = true;
|
|
6905
|
+
}
|
|
6906
|
+
else {
|
|
6907
|
+
isSelected = false;
|
|
6908
|
+
}
|
|
6888
6909
|
}
|
|
6889
6910
|
}
|
|
6890
|
-
|
|
6911
|
+
else {
|
|
6912
|
+
// 如果无子项
|
|
6913
|
+
isSelected = selectCheckboxMaps[rowid];
|
|
6914
|
+
}
|
|
6915
|
+
const halfSelect = !isSelected && (sLen > 0 || hLen > 0);
|
|
6891
6916
|
if (checkField) {
|
|
6892
6917
|
XEUtils.set(row, checkField, isSelected);
|
|
6893
6918
|
}
|
|
@@ -6930,7 +6955,9 @@ const Methods = {
|
|
|
6930
6955
|
const { checkField, checkMethod, showReserveStatus } = checkboxOpts;
|
|
6931
6956
|
const { handleGetRowId } = createHandleGetRowId($xeTable);
|
|
6932
6957
|
let sLen = 0; // 已选
|
|
6958
|
+
let dsLen = 0; // 禁用的已选
|
|
6933
6959
|
let hLen = 0; // 半选
|
|
6960
|
+
let dhLen = 0; // 禁用的半选
|
|
6934
6961
|
let vLen = 0; // 有效行
|
|
6935
6962
|
const rootList = (treeConfig ? afterTreeFullData : (isRowGroupStatus ? afterGroupFullData : afterFullData));
|
|
6936
6963
|
rootList.forEach(checkMethod
|
|
@@ -6948,10 +6975,10 @@ const Methods = {
|
|
|
6948
6975
|
}
|
|
6949
6976
|
else {
|
|
6950
6977
|
if (selected) {
|
|
6951
|
-
|
|
6978
|
+
dsLen++;
|
|
6952
6979
|
}
|
|
6953
6980
|
else if (treeIndeterminateRowMaps[childRowid]) {
|
|
6954
|
-
|
|
6981
|
+
dhLen++;
|
|
6955
6982
|
}
|
|
6956
6983
|
}
|
|
6957
6984
|
}
|
|
@@ -6967,7 +6994,7 @@ const Methods = {
|
|
|
6967
6994
|
vLen++;
|
|
6968
6995
|
});
|
|
6969
6996
|
const isSelected = rootList.length > 0 ? (vLen > 0 ? (sLen >= vLen) : (sLen >= rootList.length)) : false;
|
|
6970
|
-
let halfSelect = !isSelected && (sLen
|
|
6997
|
+
let halfSelect = !isSelected && (sLen > 0 || hLen > 0 || dsLen > 0 || dhLen > 0);
|
|
6971
6998
|
// 如果复选框启用保留记录,当保留数据存在时显示半选
|
|
6972
6999
|
if (!isSelected && !halfSelect && showReserveStatus) {
|
|
6973
7000
|
halfSelect = !XEUtils.isEmpty(checkboxReserveRowMap);
|
|
@@ -7720,83 +7747,75 @@ const Methods = {
|
|
|
7720
7747
|
const { treeConfig, dragConfig } = props;
|
|
7721
7748
|
const rowDragOpts = $xeTable.computeRowDragOpts;
|
|
7722
7749
|
const { afterFullData, tableFullData, fullAllDataRowIdData } = internalData;
|
|
7723
|
-
const { isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod, dragToChildMethod } = rowDragOpts;
|
|
7750
|
+
const { animation, isPeerDrag, isCrossDrag, isSelfToChildDrag, dragEndMethod, dragToChildMethod } = rowDragOpts;
|
|
7724
7751
|
const treeOpts = $xeTable.computeTreeOpts;
|
|
7752
|
+
const cellOpts = $xeTable.computeCellOpts;
|
|
7753
|
+
const rowOpts = $xeTable.computeRowOpts;
|
|
7754
|
+
const defaultRowHeight = $xeTable.computeDefaultRowHeight;
|
|
7725
7755
|
const { transform, rowField, mapChildrenField, parentField } = treeOpts;
|
|
7726
7756
|
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
7727
7757
|
const dEndMethod = dragEndMethod || (dragConfig ? dragConfig.dragEndMethod : null);
|
|
7728
7758
|
const dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0;
|
|
7759
|
+
const el = $xeTable.$refs.refElem;
|
|
7729
7760
|
const errRest = {
|
|
7730
7761
|
status: false
|
|
7731
7762
|
};
|
|
7732
|
-
if (prevDragRow && dragRow) {
|
|
7733
|
-
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7748
|
-
|
|
7749
|
-
|
|
7750
|
-
|
|
7751
|
-
|
|
7752
|
-
|
|
7753
|
-
|
|
7754
|
-
|
|
7755
|
-
|
|
7756
|
-
|
|
7757
|
-
|
|
7758
|
-
|
|
7759
|
-
|
|
7760
|
-
|
|
7761
|
-
|
|
7762
|
-
|
|
7763
|
-
|
|
7764
|
-
|
|
7765
|
-
|
|
7766
|
-
|
|
7767
|
-
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7782
|
-
|
|
7783
|
-
|
|
7784
|
-
content: getI18n('vxe.error.treeDragChild')
|
|
7785
|
-
});
|
|
7786
|
-
}
|
|
7787
|
-
return errRest;
|
|
7788
|
-
}
|
|
7789
|
-
}
|
|
7790
|
-
}
|
|
7791
|
-
}
|
|
7792
|
-
else if (oldLevel) {
|
|
7793
|
-
// 子到根
|
|
7794
|
-
if (!isCrossDrag) {
|
|
7763
|
+
if (!(el && prevDragRow && dragRow)) {
|
|
7764
|
+
return Promise.resolve(errRest);
|
|
7765
|
+
}
|
|
7766
|
+
// 判断是否有拖动
|
|
7767
|
+
if (prevDragRow !== dragRow) {
|
|
7768
|
+
const dragParams = {
|
|
7769
|
+
oldRow: dragRow,
|
|
7770
|
+
newRow: prevDragRow,
|
|
7771
|
+
dragRow,
|
|
7772
|
+
dragPos: prevDragPos,
|
|
7773
|
+
dragToChild: !!prevDragToChild,
|
|
7774
|
+
offsetIndex: dragOffsetIndex
|
|
7775
|
+
};
|
|
7776
|
+
const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
|
|
7777
|
+
return Promise.resolve(dEndMethod ? dEndMethod(dragParams) : true).then((status) => {
|
|
7778
|
+
if (!status) {
|
|
7779
|
+
return errRest;
|
|
7780
|
+
}
|
|
7781
|
+
const dragRowid = getRowid($xeTable, dragRow);
|
|
7782
|
+
const dragRowRest = fullAllDataRowIdData[dragRowid] || {};
|
|
7783
|
+
const _dragRowIndex = dragRowRest._index;
|
|
7784
|
+
let dragRowHeight = 0;
|
|
7785
|
+
let dragOffsetTop = -1;
|
|
7786
|
+
if (animation) {
|
|
7787
|
+
dragRowHeight = getCellRestHeight(dragRowRest, cellOpts, rowOpts, defaultRowHeight);
|
|
7788
|
+
const oldTrEl = el.querySelector(`.vxe-body--row[rowid="${dragRowid}"]`);
|
|
7789
|
+
if (oldTrEl) {
|
|
7790
|
+
dragOffsetTop = oldTrEl.offsetTop;
|
|
7791
|
+
}
|
|
7792
|
+
}
|
|
7793
|
+
let oafIndex = -1;
|
|
7794
|
+
let nafIndex = -1;
|
|
7795
|
+
// 如果为树结构
|
|
7796
|
+
if (treeConfig) {
|
|
7797
|
+
if (transform) {
|
|
7798
|
+
// 移出源位置
|
|
7799
|
+
const oldRest = dragRowRest;
|
|
7800
|
+
const newRowid = getRowid($xeTable, prevDragRow);
|
|
7801
|
+
const newRest = fullAllDataRowIdData[newRowid];
|
|
7802
|
+
if (oldRest && newRest) {
|
|
7803
|
+
const { level: oldLevel } = oldRest;
|
|
7804
|
+
const { level: newLevel } = newRest;
|
|
7805
|
+
const oldAllMaps = {};
|
|
7806
|
+
XEUtils.eachTree([dragRow], item => {
|
|
7807
|
+
oldAllMaps[getRowid($xeTable, item)] = item;
|
|
7808
|
+
}, { children: mapChildrenField });
|
|
7809
|
+
let isSelfToChildStatus = false;
|
|
7810
|
+
if (oldLevel && newLevel) {
|
|
7811
|
+
// 子到子
|
|
7812
|
+
if (isPeerDrag && !isCrossDrag) {
|
|
7813
|
+
if (oldRest.row[parentField] !== newRest.row[parentField]) {
|
|
7814
|
+
// 非同级
|
|
7795
7815
|
return errRest;
|
|
7796
7816
|
}
|
|
7797
7817
|
}
|
|
7798
|
-
else
|
|
7799
|
-
// 根到子
|
|
7818
|
+
else {
|
|
7800
7819
|
if (!isCrossDrag) {
|
|
7801
7820
|
return errRest;
|
|
7802
7821
|
}
|
|
@@ -7813,88 +7832,162 @@ const Methods = {
|
|
|
7813
7832
|
}
|
|
7814
7833
|
}
|
|
7815
7834
|
}
|
|
7816
|
-
|
|
7817
|
-
|
|
7835
|
+
}
|
|
7836
|
+
else if (oldLevel) {
|
|
7837
|
+
// 子到根
|
|
7838
|
+
if (!isCrossDrag) {
|
|
7839
|
+
return errRest;
|
|
7818
7840
|
}
|
|
7819
|
-
|
|
7820
|
-
|
|
7821
|
-
|
|
7822
|
-
|
|
7823
|
-
|
|
7824
|
-
|
|
7825
|
-
|
|
7826
|
-
|
|
7827
|
-
|
|
7828
|
-
|
|
7829
|
-
|
|
7830
|
-
|
|
7831
|
-
|
|
7832
|
-
|
|
7833
|
-
|
|
7834
|
-
|
|
7835
|
-
}
|
|
7841
|
+
}
|
|
7842
|
+
else if (newLevel) {
|
|
7843
|
+
// 根到子
|
|
7844
|
+
if (!isCrossDrag) {
|
|
7845
|
+
return errRest;
|
|
7846
|
+
}
|
|
7847
|
+
if (oldAllMaps[newRowid]) {
|
|
7848
|
+
isSelfToChildStatus = true;
|
|
7849
|
+
if (!(isCrossDrag && isSelfToChildDrag)) {
|
|
7850
|
+
if (VxeUI.modal) {
|
|
7851
|
+
VxeUI.modal.message({
|
|
7852
|
+
status: 'error',
|
|
7853
|
+
content: getI18n('vxe.error.treeDragChild')
|
|
7854
|
+
});
|
|
7855
|
+
}
|
|
7856
|
+
return errRest;
|
|
7857
|
+
}
|
|
7836
7858
|
}
|
|
7837
|
-
|
|
7838
|
-
|
|
7839
|
-
|
|
7840
|
-
|
|
7841
|
-
|
|
7842
|
-
|
|
7859
|
+
}
|
|
7860
|
+
else {
|
|
7861
|
+
// 根到根
|
|
7862
|
+
}
|
|
7863
|
+
const fullList = XEUtils.toTreeArray(internalData.afterTreeFullData, {
|
|
7864
|
+
key: rowField,
|
|
7865
|
+
parentKey: parentField,
|
|
7866
|
+
children: mapChildrenField
|
|
7867
|
+
});
|
|
7868
|
+
// 移出
|
|
7869
|
+
const otfIndex = $xeTable.findRowIndexOf(fullList, dragRow);
|
|
7870
|
+
fullList.splice(otfIndex, 1);
|
|
7871
|
+
// 插入
|
|
7872
|
+
const ptfIndex = $xeTable.findRowIndexOf(fullList, prevDragRow);
|
|
7873
|
+
const ntfIndex = ptfIndex + dragOffsetIndex;
|
|
7874
|
+
fullList.splice(ntfIndex, 0, dragRow);
|
|
7875
|
+
// 改变层级
|
|
7876
|
+
if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
|
|
7877
|
+
XEUtils.each(dragRow[childrenField], childRow => {
|
|
7878
|
+
childRow[parentField] = dragRow[parentField];
|
|
7843
7879
|
});
|
|
7844
7880
|
}
|
|
7881
|
+
dragRow[parentField] = isDragToChildFlag ? prevDragRow[rowField] : prevDragRow[parentField];
|
|
7882
|
+
internalData.tableFullTreeData = XEUtils.toArrayTree(fullList, {
|
|
7883
|
+
key: rowField,
|
|
7884
|
+
parentKey: parentField,
|
|
7885
|
+
children: childrenField,
|
|
7886
|
+
mapChildren: mapChildrenField
|
|
7887
|
+
});
|
|
7845
7888
|
}
|
|
7846
7889
|
}
|
|
7847
|
-
|
|
7848
|
-
|
|
7849
|
-
|
|
7850
|
-
|
|
7851
|
-
|
|
7852
|
-
|
|
7853
|
-
|
|
7854
|
-
|
|
7855
|
-
|
|
7856
|
-
|
|
7857
|
-
|
|
7858
|
-
|
|
7859
|
-
|
|
7860
|
-
|
|
7861
|
-
|
|
7862
|
-
|
|
7863
|
-
|
|
7864
|
-
|
|
7865
|
-
|
|
7866
|
-
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7890
|
+
}
|
|
7891
|
+
else {
|
|
7892
|
+
// 移出
|
|
7893
|
+
oafIndex = $xeTable.findRowIndexOf(afterFullData, dragRow);
|
|
7894
|
+
const otfIndex = $xeTable.findRowIndexOf(tableFullData, dragRow);
|
|
7895
|
+
afterFullData.splice(oafIndex, 1);
|
|
7896
|
+
tableFullData.splice(otfIndex, 1);
|
|
7897
|
+
// 插入
|
|
7898
|
+
const pafIndex = $xeTable.findRowIndexOf(afterFullData, prevDragRow);
|
|
7899
|
+
const ptfIndex = $xeTable.findRowIndexOf(tableFullData, prevDragRow);
|
|
7900
|
+
nafIndex = pafIndex + dragOffsetIndex;
|
|
7901
|
+
const ntfIndex = ptfIndex + dragOffsetIndex;
|
|
7902
|
+
afterFullData.splice(nafIndex, 0, dragRow);
|
|
7903
|
+
tableFullData.splice(ntfIndex, 0, dragRow);
|
|
7904
|
+
}
|
|
7905
|
+
$xeTable.handleTableData(treeConfig && transform);
|
|
7906
|
+
$xeTable.cacheRowMap(false);
|
|
7907
|
+
updateScrollYStatus($xeTable);
|
|
7908
|
+
if (!(treeConfig && transform)) {
|
|
7909
|
+
updateAfterDataIndex($xeTable);
|
|
7910
|
+
}
|
|
7911
|
+
$xeTable.checkSelectionStatus();
|
|
7912
|
+
if (reactData.scrollYLoad) {
|
|
7913
|
+
$xeTable.updateScrollYSpace();
|
|
7914
|
+
}
|
|
7915
|
+
if (evnt) {
|
|
7916
|
+
$xeTable.dispatchEvent('row-dragend', {
|
|
7917
|
+
oldRow: dragRow,
|
|
7918
|
+
newRow: prevDragRow,
|
|
7919
|
+
dragRow,
|
|
7920
|
+
dragPos: prevDragPos,
|
|
7921
|
+
dragToChild: isDragToChildFlag,
|
|
7922
|
+
offsetIndex: dragOffsetIndex,
|
|
7923
|
+
_index: {
|
|
7924
|
+
newIndex: nafIndex,
|
|
7925
|
+
oldIndex: oafIndex
|
|
7926
|
+
}
|
|
7927
|
+
}, evnt);
|
|
7928
|
+
}
|
|
7929
|
+
return $xeTable.$nextTick().then(() => {
|
|
7930
|
+
if (animation) {
|
|
7931
|
+
const { tableData } = reactData;
|
|
7932
|
+
const dragRowRest = fullAllDataRowIdData[dragRowid];
|
|
7933
|
+
const _newRowIndex = dragRowRest._index;
|
|
7934
|
+
const firstRow = tableData[0];
|
|
7935
|
+
const firstRowRest = fullAllDataRowIdData[getRowid($xeTable, firstRow)];
|
|
7936
|
+
if (firstRowRest) {
|
|
7937
|
+
const _firstRowIndex = firstRowRest._index;
|
|
7938
|
+
const _lastRowIndex = _firstRowIndex + tableData.length;
|
|
7939
|
+
let rsIndex = -1;
|
|
7940
|
+
let reIndex = -1;
|
|
7941
|
+
let offsetRate = 1;
|
|
7942
|
+
if (_dragRowIndex < _firstRowIndex) {
|
|
7943
|
+
// 从上往下虚拟拖拽
|
|
7944
|
+
rsIndex = 0;
|
|
7945
|
+
reIndex = _newRowIndex - _firstRowIndex;
|
|
7883
7946
|
}
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
|
|
7890
|
-
|
|
7891
|
-
|
|
7892
|
-
|
|
7893
|
-
|
|
7894
|
-
|
|
7895
|
-
|
|
7947
|
+
else if (_dragRowIndex > _lastRowIndex) {
|
|
7948
|
+
// 从下往上虚拟拖拽
|
|
7949
|
+
const $newRowIndex = dragRowRest.$index;
|
|
7950
|
+
rsIndex = $newRowIndex + 1;
|
|
7951
|
+
reIndex = tableData.length;
|
|
7952
|
+
offsetRate = -1;
|
|
7953
|
+
}
|
|
7954
|
+
else {
|
|
7955
|
+
if (_newRowIndex > _dragRowIndex) {
|
|
7956
|
+
// 从上往下拖拽
|
|
7957
|
+
rsIndex = _dragRowIndex - _firstRowIndex;
|
|
7958
|
+
reIndex = rsIndex + _newRowIndex - _dragRowIndex;
|
|
7959
|
+
}
|
|
7960
|
+
else {
|
|
7961
|
+
// 从下往上拖拽
|
|
7962
|
+
rsIndex = _newRowIndex - _firstRowIndex;
|
|
7963
|
+
reIndex = rsIndex + _dragRowIndex - _newRowIndex + 1;
|
|
7964
|
+
offsetRate = -1;
|
|
7965
|
+
}
|
|
7966
|
+
}
|
|
7967
|
+
const dragRangeList = tableData.slice(rsIndex, reIndex);
|
|
7968
|
+
if (dragRangeList.length) {
|
|
7969
|
+
const dtTrList = el.querySelectorAll(dragRangeList.map(row => `.vxe-body--row[rowid="${getRowid($xeTable, row)}"]`).join(','));
|
|
7970
|
+
moveRowAnimateToTb(dtTrList, offsetRate * dragRowHeight);
|
|
7971
|
+
}
|
|
7972
|
+
}
|
|
7973
|
+
const newTrList = el.querySelectorAll(`.vxe-body--row[rowid="${dragRowid}"]`);
|
|
7974
|
+
const newTrEl = newTrList[0];
|
|
7975
|
+
if (dragOffsetTop > -1 && newTrEl) {
|
|
7976
|
+
moveRowAnimateToTb(newTrList, dragOffsetTop - newTrEl.offsetTop);
|
|
7977
|
+
}
|
|
7978
|
+
}
|
|
7979
|
+
updateRowOffsetTop($xeTable);
|
|
7980
|
+
updateRowExpandStyle($xeTable);
|
|
7981
|
+
$xeTable.updateCellAreas();
|
|
7982
|
+
$xeTable.recalculate();
|
|
7983
|
+
}).then(() => {
|
|
7984
|
+
return {
|
|
7985
|
+
status: true
|
|
7986
|
+
};
|
|
7896
7987
|
});
|
|
7897
|
-
}
|
|
7988
|
+
}).catch(() => {
|
|
7989
|
+
return errRest;
|
|
7990
|
+
});
|
|
7898
7991
|
}
|
|
7899
7992
|
return Promise.resolve(errRest);
|
|
7900
7993
|
},
|
|
@@ -7910,6 +8003,7 @@ const Methods = {
|
|
|
7910
8003
|
const { lazy } = treeOpts;
|
|
7911
8004
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField;
|
|
7912
8005
|
const { prevDragRow, prevDragPos } = internalData;
|
|
8006
|
+
const el = $xeTable.$refs.refElem;
|
|
7913
8007
|
if (treeConfig && lazy && prevDragToChild) {
|
|
7914
8008
|
// 懒加载
|
|
7915
8009
|
const newRowid = getRowid($xeTable, prevDragRow);
|
|
@@ -7928,18 +8022,16 @@ const Methods = {
|
|
|
7928
8022
|
}
|
|
7929
8023
|
hideDropTip($xeTable);
|
|
7930
8024
|
clearRowDropOrigin($xeTable);
|
|
8025
|
+
clearRowAnimate(el);
|
|
7931
8026
|
internalData.prevDragToChild = false;
|
|
7932
8027
|
reactData.dragRow = null;
|
|
7933
8028
|
reactData.dragCol = null;
|
|
7934
|
-
setTimeout(() => {
|
|
7935
|
-
reactData.isDragRowMove = false;
|
|
7936
|
-
}, 500);
|
|
7937
8029
|
},
|
|
7938
8030
|
handleRowDragDragoverEvent(evnt) {
|
|
7939
8031
|
const $xeTable = this;
|
|
7940
8032
|
const props = $xeTable;
|
|
7941
|
-
const internalData = $xeTable;
|
|
7942
8033
|
const reactData = $xeTable;
|
|
8034
|
+
const internalData = $xeTable;
|
|
7943
8035
|
const { treeConfig } = props;
|
|
7944
8036
|
const { fullAllDataRowIdData } = internalData;
|
|
7945
8037
|
const { dragRow } = reactData;
|
|
@@ -7995,7 +8087,6 @@ const Methods = {
|
|
|
7995
8087
|
const tdEl = trigger === 'cell' || trigger === 'row' ? dragEl : (_a = dragEl.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
7996
8088
|
const trEl = tdEl.parentElement;
|
|
7997
8089
|
const dStartMethod = dragStartMethod || (dragConfig ? dragConfig.dragStartMethod : null);
|
|
7998
|
-
reactData.isDragRowMove = false;
|
|
7999
8090
|
clearRowDropOrigin($xeTable);
|
|
8000
8091
|
if (dStartMethod && !dStartMethod(params)) {
|
|
8001
8092
|
trEl.draggable = false;
|
|
@@ -8026,7 +8117,7 @@ const Methods = {
|
|
|
8026
8117
|
handleColDragSwapColumn() {
|
|
8027
8118
|
const $xeTable = this;
|
|
8028
8119
|
handleUpdateColumn($xeTable);
|
|
8029
|
-
parseColumns($xeTable, false).then(() => {
|
|
8120
|
+
return parseColumns($xeTable, false).then(() => {
|
|
8030
8121
|
$xeTable.updateCellAreas();
|
|
8031
8122
|
$xeTable.saveCustomStore('update:sort');
|
|
8032
8123
|
});
|
|
@@ -8038,71 +8129,73 @@ const Methods = {
|
|
|
8038
8129
|
const internalData = $xeTable;
|
|
8039
8130
|
const { mouseConfig } = props;
|
|
8040
8131
|
const columnDragOpts = $xeTable.computeColumnDragOpts;
|
|
8041
|
-
const { isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts;
|
|
8042
|
-
const { collectColumn } = internalData;
|
|
8132
|
+
const { animation, isPeerDrag, isCrossDrag, isSelfToChildDrag, isToChildDrag, dragEndMethod, dragToChildMethod } = columnDragOpts;
|
|
8133
|
+
const { collectColumn, fullColumnIdData } = internalData;
|
|
8134
|
+
const el = $xeTable.$refs.refElem;
|
|
8043
8135
|
const dragOffsetIndex = prevDragPos === 'right' ? 1 : 0;
|
|
8044
8136
|
const errRest = {
|
|
8045
8137
|
status: false
|
|
8046
8138
|
};
|
|
8047
|
-
if (prevDragCol && dragCol) {
|
|
8048
|
-
|
|
8049
|
-
|
|
8050
|
-
|
|
8051
|
-
|
|
8052
|
-
|
|
8053
|
-
|
|
8054
|
-
|
|
8055
|
-
|
|
8056
|
-
|
|
8057
|
-
|
|
8058
|
-
|
|
8059
|
-
|
|
8060
|
-
|
|
8061
|
-
|
|
8062
|
-
|
|
8063
|
-
|
|
8064
|
-
|
|
8065
|
-
|
|
8066
|
-
|
|
8067
|
-
|
|
8139
|
+
if (!(el && prevDragCol && dragCol)) {
|
|
8140
|
+
return Promise.resolve(errRest);
|
|
8141
|
+
}
|
|
8142
|
+
// 判断是否有拖动
|
|
8143
|
+
if (prevDragCol !== dragCol) {
|
|
8144
|
+
const dragColumn = dragCol;
|
|
8145
|
+
const newColumn = prevDragCol;
|
|
8146
|
+
const dragParams = {
|
|
8147
|
+
oldColumn: dragColumn,
|
|
8148
|
+
newColumn,
|
|
8149
|
+
dragColumn,
|
|
8150
|
+
dragPos: prevDragPos,
|
|
8151
|
+
dragToChild: !!prevDragToChild,
|
|
8152
|
+
offsetIndex: dragOffsetIndex
|
|
8153
|
+
};
|
|
8154
|
+
const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
|
|
8155
|
+
return Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
|
|
8156
|
+
if (!status) {
|
|
8157
|
+
return errRest;
|
|
8158
|
+
}
|
|
8159
|
+
let dragTargetColumn = null;
|
|
8160
|
+
const dragAllTargetCols = [];
|
|
8161
|
+
let dragColWidth = 0;
|
|
8162
|
+
if (animation) {
|
|
8068
8163
|
XEUtils.eachTree([dragColumn], column => {
|
|
8069
|
-
|
|
8070
|
-
|
|
8071
|
-
|
|
8072
|
-
if (dragColumn.parentId && newColumn.parentId) {
|
|
8073
|
-
// 子到子
|
|
8074
|
-
if (isPeerDrag && !isCrossDrag) {
|
|
8075
|
-
if (dragColumn.parentId !== newColumn.parentId) {
|
|
8076
|
-
// 非同级
|
|
8077
|
-
return errRest;
|
|
8078
|
-
}
|
|
8079
|
-
}
|
|
8080
|
-
else {
|
|
8081
|
-
if (!isCrossDrag) {
|
|
8082
|
-
return errRest;
|
|
8083
|
-
}
|
|
8084
|
-
if (oldAllMaps[newColumn.id]) {
|
|
8085
|
-
isSelfToChildStatus = true;
|
|
8086
|
-
if (!(isCrossDrag && isSelfToChildDrag)) {
|
|
8087
|
-
if (VxeUI.modal) {
|
|
8088
|
-
VxeUI.modal.message({
|
|
8089
|
-
status: 'error',
|
|
8090
|
-
content: getI18n('vxe.error.treeDragChild')
|
|
8091
|
-
});
|
|
8092
|
-
}
|
|
8093
|
-
return errRest;
|
|
8094
|
-
}
|
|
8095
|
-
}
|
|
8164
|
+
if (!dragTargetColumn && (!column.children || !column.children.length)) {
|
|
8165
|
+
dragTargetColumn = column;
|
|
8166
|
+
dragColWidth += column.renderWidth;
|
|
8096
8167
|
}
|
|
8168
|
+
dragAllTargetCols.push(column);
|
|
8169
|
+
});
|
|
8170
|
+
}
|
|
8171
|
+
if (!dragTargetColumn) {
|
|
8172
|
+
dragTargetColumn = dragColumn;
|
|
8173
|
+
}
|
|
8174
|
+
const dragColRest = fullColumnIdData[dragTargetColumn.id] || {};
|
|
8175
|
+
const _dragColIndex = dragColRest._index;
|
|
8176
|
+
let dragOffsetLeft = -1;
|
|
8177
|
+
if (animation) {
|
|
8178
|
+
const oldTrEl = el.querySelector(`.vxe-table--column[colid="${dragTargetColumn.id}"]`);
|
|
8179
|
+
if (oldTrEl) {
|
|
8180
|
+
dragOffsetLeft = oldTrEl.offsetLeft;
|
|
8097
8181
|
}
|
|
8098
|
-
|
|
8099
|
-
|
|
8100
|
-
|
|
8182
|
+
}
|
|
8183
|
+
let oafIndex = -1;
|
|
8184
|
+
let nafIndex = -1;
|
|
8185
|
+
const oldAllMaps = {};
|
|
8186
|
+
XEUtils.eachTree([dragColumn], column => {
|
|
8187
|
+
oldAllMaps[column.id] = column;
|
|
8188
|
+
});
|
|
8189
|
+
let isSelfToChildStatus = false;
|
|
8190
|
+
if (dragColumn.parentId && newColumn.parentId) {
|
|
8191
|
+
// 子到子
|
|
8192
|
+
if (isPeerDrag && !isCrossDrag) {
|
|
8193
|
+
if (dragColumn.parentId !== newColumn.parentId) {
|
|
8194
|
+
// 非同级
|
|
8101
8195
|
return errRest;
|
|
8102
8196
|
}
|
|
8103
8197
|
}
|
|
8104
|
-
else
|
|
8105
|
-
// 根到子
|
|
8198
|
+
else {
|
|
8106
8199
|
if (!isCrossDrag) {
|
|
8107
8200
|
return errRest;
|
|
8108
8201
|
}
|
|
@@ -8119,87 +8212,192 @@ const Methods = {
|
|
|
8119
8212
|
}
|
|
8120
8213
|
}
|
|
8121
8214
|
}
|
|
8122
|
-
|
|
8123
|
-
|
|
8124
|
-
|
|
8125
|
-
|
|
8126
|
-
|
|
8127
|
-
if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
|
|
8128
|
-
if (oldewMatchRest) {
|
|
8129
|
-
const { items: oCols, index: oIndex } = oldewMatchRest;
|
|
8130
|
-
const childList = dragColumn.children || [];
|
|
8131
|
-
childList.forEach(column => {
|
|
8132
|
-
column.parentId = dragColumn.parentId;
|
|
8133
|
-
});
|
|
8134
|
-
oCols.splice(oIndex, 1, ...childList);
|
|
8135
|
-
dragColumn.children = [];
|
|
8136
|
-
}
|
|
8215
|
+
}
|
|
8216
|
+
else if (dragColumn.parentId) {
|
|
8217
|
+
// 子到根
|
|
8218
|
+
if (!isCrossDrag) {
|
|
8219
|
+
return errRest;
|
|
8137
8220
|
}
|
|
8138
|
-
|
|
8139
|
-
|
|
8140
|
-
|
|
8141
|
-
|
|
8142
|
-
|
|
8143
|
-
|
|
8221
|
+
}
|
|
8222
|
+
else if (newColumn.parentId) {
|
|
8223
|
+
// 根到子
|
|
8224
|
+
if (!isCrossDrag) {
|
|
8225
|
+
return errRest;
|
|
8226
|
+
}
|
|
8227
|
+
if (oldAllMaps[newColumn.id]) {
|
|
8228
|
+
isSelfToChildStatus = true;
|
|
8229
|
+
if (!(isCrossDrag && isSelfToChildDrag)) {
|
|
8230
|
+
if (VxeUI.modal) {
|
|
8231
|
+
VxeUI.modal.message({
|
|
8232
|
+
status: 'error',
|
|
8233
|
+
content: getI18n('vxe.error.treeDragChild')
|
|
8234
|
+
});
|
|
8144
8235
|
}
|
|
8236
|
+
return errRest;
|
|
8145
8237
|
}
|
|
8146
8238
|
}
|
|
8147
|
-
|
|
8148
|
-
|
|
8149
|
-
|
|
8150
|
-
|
|
8151
|
-
|
|
8152
|
-
|
|
8153
|
-
|
|
8154
|
-
|
|
8155
|
-
|
|
8156
|
-
|
|
8157
|
-
|
|
8158
|
-
|
|
8159
|
-
|
|
8160
|
-
|
|
8161
|
-
|
|
8239
|
+
}
|
|
8240
|
+
else {
|
|
8241
|
+
// 根到根
|
|
8242
|
+
}
|
|
8243
|
+
const oldewMatchRest = XEUtils.findTree(collectColumn, item => item.id === dragColumn.id);
|
|
8244
|
+
// 改变层级
|
|
8245
|
+
if (isSelfToChildStatus && (isCrossDrag && isSelfToChildDrag)) {
|
|
8246
|
+
if (oldewMatchRest) {
|
|
8247
|
+
const { items: oCols, index: oIndex } = oldewMatchRest;
|
|
8248
|
+
const childList = dragColumn.children || [];
|
|
8249
|
+
childList.forEach(column => {
|
|
8250
|
+
column.parentId = dragColumn.parentId;
|
|
8251
|
+
});
|
|
8252
|
+
oCols.splice(oIndex, 1, ...childList);
|
|
8253
|
+
dragColumn.children = [];
|
|
8162
8254
|
}
|
|
8163
|
-
|
|
8164
|
-
|
|
8165
|
-
|
|
8166
|
-
|
|
8167
|
-
|
|
8168
|
-
|
|
8169
|
-
|
|
8170
|
-
if (mouseConfig) {
|
|
8171
|
-
if ($xeTable.clearSelected) {
|
|
8172
|
-
$xeTable.clearSelected();
|
|
8173
|
-
}
|
|
8174
|
-
if ($xeTable.clearCellAreas) {
|
|
8175
|
-
$xeTable.clearCellAreas();
|
|
8176
|
-
$xeTable.clearCopyCellArea();
|
|
8255
|
+
}
|
|
8256
|
+
else {
|
|
8257
|
+
if (oldewMatchRest) {
|
|
8258
|
+
const { items: oCols, index: oIndex, parent: oParent } = oldewMatchRest;
|
|
8259
|
+
oCols.splice(oIndex, 1);
|
|
8260
|
+
if (!oParent) {
|
|
8261
|
+
oafIndex = oIndex;
|
|
8177
8262
|
}
|
|
8178
8263
|
}
|
|
8179
|
-
|
|
8180
|
-
|
|
8181
|
-
|
|
8182
|
-
|
|
8183
|
-
|
|
8184
|
-
|
|
8185
|
-
|
|
8186
|
-
|
|
8187
|
-
_index: {
|
|
8188
|
-
newIndex: nafIndex,
|
|
8189
|
-
oldIndex: oafIndex
|
|
8190
|
-
}
|
|
8191
|
-
}, evnt);
|
|
8264
|
+
}
|
|
8265
|
+
const newMatchRest = XEUtils.findTree(collectColumn, item => item.id === newColumn.id);
|
|
8266
|
+
if (newMatchRest) {
|
|
8267
|
+
const { items: nCols, index: nIndex, parent: nParent } = newMatchRest;
|
|
8268
|
+
// 转子级
|
|
8269
|
+
if ((isCrossDrag && isToChildDrag) && isDragToChildFlag) {
|
|
8270
|
+
dragColumn.parentId = newColumn.id;
|
|
8271
|
+
newColumn.children = (newColumn.children || []).concat([dragColumn]);
|
|
8192
8272
|
}
|
|
8273
|
+
else {
|
|
8274
|
+
dragColumn.parentId = newColumn.parentId;
|
|
8275
|
+
nCols.splice(nIndex + dragOffsetIndex, 0, dragColumn);
|
|
8276
|
+
}
|
|
8277
|
+
if (!nParent) {
|
|
8278
|
+
nafIndex = nIndex;
|
|
8279
|
+
}
|
|
8280
|
+
}
|
|
8281
|
+
XEUtils.eachTree(collectColumn, (column, index, items, path, parentColumn) => {
|
|
8282
|
+
if (!parentColumn) {
|
|
8283
|
+
const sortIndex = index + 1;
|
|
8284
|
+
column.renderSortNumber = sortIndex;
|
|
8285
|
+
}
|
|
8286
|
+
});
|
|
8287
|
+
if (mouseConfig) {
|
|
8288
|
+
if ($xeTable.clearSelected) {
|
|
8289
|
+
$xeTable.clearSelected();
|
|
8290
|
+
}
|
|
8291
|
+
if ($xeTable.clearCellAreas) {
|
|
8292
|
+
$xeTable.clearCellAreas();
|
|
8293
|
+
$xeTable.clearCopyCellArea();
|
|
8294
|
+
}
|
|
8295
|
+
}
|
|
8296
|
+
if (evnt) {
|
|
8297
|
+
$xeTable.dispatchEvent('column-dragend', {
|
|
8298
|
+
oldColumn: dragColumn,
|
|
8299
|
+
newColumn,
|
|
8300
|
+
dragColumn,
|
|
8301
|
+
dragPos: prevDragPos,
|
|
8302
|
+
dragToChild: isDragToChildFlag,
|
|
8303
|
+
offsetIndex: dragOffsetIndex,
|
|
8304
|
+
_index: {
|
|
8305
|
+
newIndex: nafIndex,
|
|
8306
|
+
oldIndex: oafIndex
|
|
8307
|
+
}
|
|
8308
|
+
}, evnt);
|
|
8309
|
+
}
|
|
8310
|
+
return $xeTable.$nextTick().then(() => {
|
|
8193
8311
|
if (isSyncColumn) {
|
|
8194
|
-
$xeTable.handleColDragSwapColumn();
|
|
8312
|
+
return $xeTable.handleColDragSwapColumn();
|
|
8313
|
+
}
|
|
8314
|
+
}).then(() => {
|
|
8315
|
+
if (animation) {
|
|
8316
|
+
const { tableColumn } = reactData;
|
|
8317
|
+
const { visibleColumn, fullColumnIdData } = internalData;
|
|
8318
|
+
let dragNewColumn = null;
|
|
8319
|
+
const dragNewColMaps = {};
|
|
8320
|
+
XEUtils.eachTree([dragColumn], column => {
|
|
8321
|
+
if (!dragNewColumn && (!column.children || !column.children.length)) {
|
|
8322
|
+
dragNewColumn = column;
|
|
8323
|
+
}
|
|
8324
|
+
dragNewColMaps[column.id] = column;
|
|
8325
|
+
});
|
|
8326
|
+
if (!dragNewColumn) {
|
|
8327
|
+
dragNewColumn = dragColumn;
|
|
8328
|
+
}
|
|
8329
|
+
if (dragColWidth && dragAllTargetCols.length) {
|
|
8330
|
+
const _newColIndex = XEUtils.findIndexOf(visibleColumn, column => !!dragNewColumn && column.id === dragNewColumn.id);
|
|
8331
|
+
const firstCol = tableColumn[0];
|
|
8332
|
+
const firstColRest = fullColumnIdData[firstCol.id];
|
|
8333
|
+
if (firstColRest) {
|
|
8334
|
+
const _firstColIndex = firstColRest._index;
|
|
8335
|
+
const _lastColIndex = _firstColIndex + tableColumn.length;
|
|
8336
|
+
let csIndex = -1;
|
|
8337
|
+
let ceIndex = -1;
|
|
8338
|
+
let offsetRate = 1;
|
|
8339
|
+
if (_dragColIndex < _firstColIndex) {
|
|
8340
|
+
// 从左往右虚拟拖拽
|
|
8341
|
+
csIndex = 0;
|
|
8342
|
+
ceIndex = _newColIndex - _firstColIndex;
|
|
8343
|
+
}
|
|
8344
|
+
else if (_dragColIndex > _lastColIndex) {
|
|
8345
|
+
// 从右往左虚拟拖拽
|
|
8346
|
+
const $newRowIndex = dragColRest.$index;
|
|
8347
|
+
csIndex = $newRowIndex + 1;
|
|
8348
|
+
ceIndex = tableColumn.length;
|
|
8349
|
+
offsetRate = -1;
|
|
8350
|
+
}
|
|
8351
|
+
else {
|
|
8352
|
+
if (_newColIndex > _dragColIndex) {
|
|
8353
|
+
// 从左往右拖拽
|
|
8354
|
+
csIndex = _dragColIndex - _firstColIndex;
|
|
8355
|
+
ceIndex = csIndex + _newColIndex - _dragColIndex;
|
|
8356
|
+
}
|
|
8357
|
+
else {
|
|
8358
|
+
// 从右往左拖拽
|
|
8359
|
+
csIndex = _newColIndex - _firstColIndex + 1;
|
|
8360
|
+
ceIndex = csIndex + _dragColIndex - _newColIndex;
|
|
8361
|
+
offsetRate = -1;
|
|
8362
|
+
}
|
|
8363
|
+
}
|
|
8364
|
+
const dragRangeList = [];
|
|
8365
|
+
const dragRangeMaps = {};
|
|
8366
|
+
for (let i = csIndex; i < ceIndex; i++) {
|
|
8367
|
+
const column = tableColumn[i];
|
|
8368
|
+
if (!dragRangeMaps[column.id] && !dragNewColMaps[column.id]) {
|
|
8369
|
+
dragRangeMaps[column.id] = column;
|
|
8370
|
+
dragRangeList.push(column);
|
|
8371
|
+
}
|
|
8372
|
+
}
|
|
8373
|
+
XEUtils.eachTree([newColumn], column => {
|
|
8374
|
+
if (!dragRangeMaps[column.id]) {
|
|
8375
|
+
dragRangeMaps[column.id] = column;
|
|
8376
|
+
dragRangeList.push(column);
|
|
8377
|
+
}
|
|
8378
|
+
});
|
|
8379
|
+
if (dragRangeList.length) {
|
|
8380
|
+
const dtTrList = el.querySelectorAll(dragRangeList.map(column => `.vxe-table--column[colid="${column.id}"]`).join(','));
|
|
8381
|
+
moveColAnimateToLr(dtTrList, offsetRate * dragColWidth);
|
|
8382
|
+
}
|
|
8383
|
+
}
|
|
8384
|
+
const newTrList = el.querySelectorAll(dragAllTargetCols.map(column => `.vxe-table--column[colid="${column.id}"]`).join(','));
|
|
8385
|
+
const newTdEl = newTrList[0];
|
|
8386
|
+
if (dragOffsetLeft > -1 && newTdEl) {
|
|
8387
|
+
moveColAnimateToLr(newTrList, dragOffsetLeft - newTdEl.offsetLeft);
|
|
8388
|
+
}
|
|
8389
|
+
}
|
|
8195
8390
|
}
|
|
8391
|
+
updateColumnOffsetLeft($xeTable);
|
|
8392
|
+
loadScrollXData($xeTable);
|
|
8393
|
+
$xeTable.updateCellAreas();
|
|
8196
8394
|
return {
|
|
8197
8395
|
status: true
|
|
8198
8396
|
};
|
|
8199
|
-
}).catch(() => {
|
|
8200
|
-
return errRest;
|
|
8201
8397
|
});
|
|
8202
|
-
}
|
|
8398
|
+
}).catch(() => {
|
|
8399
|
+
return errRest;
|
|
8400
|
+
});
|
|
8203
8401
|
}
|
|
8204
8402
|
return Promise.resolve(errRest);
|
|
8205
8403
|
},
|
|
@@ -8209,18 +8407,14 @@ const Methods = {
|
|
|
8209
8407
|
const internalData = $xeTable;
|
|
8210
8408
|
const { dragCol } = reactData;
|
|
8211
8409
|
const { prevDragCol, prevDragPos, prevDragToChild } = internalData;
|
|
8410
|
+
const el = $xeTable.$refs.refElem;
|
|
8212
8411
|
$xeTable.handleColDragSwapEvent(evnt, true, dragCol, prevDragCol, prevDragPos, prevDragToChild);
|
|
8213
8412
|
hideDropTip($xeTable);
|
|
8214
8413
|
clearColDropOrigin($xeTable);
|
|
8414
|
+
clearColAnimate(el);
|
|
8215
8415
|
internalData.prevDragToChild = false;
|
|
8216
8416
|
reactData.dragRow = null;
|
|
8217
8417
|
reactData.dragCol = null;
|
|
8218
|
-
setTimeout(() => {
|
|
8219
|
-
reactData.isDragColMove = false;
|
|
8220
|
-
$xeTable.recalculate().then(() => {
|
|
8221
|
-
loadScrollXData($xeTable);
|
|
8222
|
-
});
|
|
8223
|
-
}, 500);
|
|
8224
8418
|
},
|
|
8225
8419
|
handleHeaderCellDragDragoverEvent(evnt) {
|
|
8226
8420
|
const $xeTable = this;
|
|
@@ -8299,7 +8493,6 @@ const Methods = {
|
|
|
8299
8493
|
const { column } = params;
|
|
8300
8494
|
const dragEl = evnt.currentTarget;
|
|
8301
8495
|
const thEl = trigger === 'cell' ? dragEl : (_a = dragEl.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
8302
|
-
reactData.isDragColMove = false;
|
|
8303
8496
|
clearColDropOrigin($xeTable);
|
|
8304
8497
|
if (dragStartMethod && !dragStartMethod(params)) {
|
|
8305
8498
|
thEl.draggable = false;
|
|
@@ -8322,7 +8515,6 @@ const Methods = {
|
|
|
8322
8515
|
hideDropTip($xeTable);
|
|
8323
8516
|
reactData.dragRow = null;
|
|
8324
8517
|
reactData.dragCol = null;
|
|
8325
|
-
reactData.isDragColMove = false;
|
|
8326
8518
|
},
|
|
8327
8519
|
setPendingRow(rows, status) {
|
|
8328
8520
|
const $xeTable = this;
|
|
@@ -8815,7 +9007,7 @@ const Methods = {
|
|
|
8815
9007
|
reactData.rowExpandedFlag++;
|
|
8816
9008
|
return Promise.all(lazyRests)
|
|
8817
9009
|
.then(() => $xeTable.$nextTick())
|
|
8818
|
-
.then(() => $xeTable
|
|
9010
|
+
.then(() => handleLazyRecalculate($xeTable, true, true, true))
|
|
8819
9011
|
.then(() => {
|
|
8820
9012
|
updateRowOffsetTop($xeTable);
|
|
8821
9013
|
updateRowExpandStyle($xeTable);
|
|
@@ -8859,7 +9051,7 @@ const Methods = {
|
|
|
8859
9051
|
}
|
|
8860
9052
|
return $xeTable.$nextTick().then(() => {
|
|
8861
9053
|
if (expList.length) {
|
|
8862
|
-
return $xeTable
|
|
9054
|
+
return handleLazyRecalculate($xeTable, true, true, true);
|
|
8863
9055
|
}
|
|
8864
9056
|
}).then(() => {
|
|
8865
9057
|
updateRowOffsetTop($xeTable);
|
|
@@ -8992,7 +9184,7 @@ const Methods = {
|
|
|
8992
9184
|
$xeTable.handleTableData();
|
|
8993
9185
|
updateAfterDataIndex($xeTable);
|
|
8994
9186
|
reactData.rowGroupExpandedFlag++;
|
|
8995
|
-
return $xeTable
|
|
9187
|
+
return handleLazyRecalculate($xeTable, true, true, true);
|
|
8996
9188
|
},
|
|
8997
9189
|
clearRowGroupExpand() {
|
|
8998
9190
|
const $xeTable = this;
|
|
@@ -9003,7 +9195,7 @@ const Methods = {
|
|
|
9003
9195
|
$xeTable.handleTableData();
|
|
9004
9196
|
updateAfterDataIndex($xeTable);
|
|
9005
9197
|
reactData.rowGroupExpandedFlag++;
|
|
9006
|
-
return $xeTable
|
|
9198
|
+
return handleLazyRecalculate($xeTable, true, true, true);
|
|
9007
9199
|
},
|
|
9008
9200
|
getTreeExpandRecords() {
|
|
9009
9201
|
const $xeTable = this;
|
|
@@ -9353,8 +9545,6 @@ const Methods = {
|
|
|
9353
9545
|
}
|
|
9354
9546
|
internalData.lastScrollTop = scrollTop;
|
|
9355
9547
|
}
|
|
9356
|
-
reactData.isDragColMove = false;
|
|
9357
|
-
reactData.isDragRowMove = false;
|
|
9358
9548
|
reactData.lastScrollTime = Date.now();
|
|
9359
9549
|
const evntParams = Object.assign({ scrollTop,
|
|
9360
9550
|
scrollLeft,
|