vxe-table 3.18.0 → 3.18.1
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/es/style.css +1 -1
- package/es/table/module/edit/mixin.js +58 -20
- package/es/table/module/filter/mixin.js +12 -10
- package/es/table/module/menu/mixin.js +16 -9
- package/es/table/module/validator/mixin.js +4 -2
- package/es/table/src/methods.js +344 -46
- package/es/table/src/store.js +8 -0
- package/es/table/src/table.js +26 -9
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/lib/index.umd.js +518 -104
- package/lib/index.umd.min.js +1 -1
- package/lib/style.css +1 -1
- package/lib/table/module/edit/mixin.js +55 -16
- package/lib/table/module/edit/mixin.min.js +1 -1
- package/lib/table/module/filter/mixin.js +12 -10
- package/lib/table/module/filter/mixin.min.js +1 -1
- package/lib/table/module/menu/mixin.js +20 -13
- package/lib/table/module/menu/mixin.min.js +1 -1
- package/lib/table/module/validator/mixin.js +4 -2
- package/lib/table/module/validator/mixin.min.js +1 -1
- package/lib/table/src/methods.js +388 -52
- package/lib/table/src/methods.min.js +1 -1
- package/lib/table/src/store.js +15 -0
- package/lib/table/src/store.min.js +1 -0
- package/lib/table/src/table.js +28 -9
- package/lib/table/src/table.min.js +1 -1
- package/lib/ui/index.js +1 -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/package.json +1 -1
- package/packages/table/module/edit/mixin.ts +59 -23
- package/packages/table/module/filter/mixin.ts +17 -13
- package/packages/table/module/menu/mixin.ts +16 -9
- package/packages/table/module/validator/mixin.ts +8 -4
- package/packages/table/src/methods.ts +362 -50
- package/packages/table/src/store.ts +15 -0
- package/packages/table/src/table.ts +27 -9
- /package/es/{iconfont.1756083626568.ttf → iconfont.1756272539382.ttf} +0 -0
- /package/es/{iconfont.1756083626568.woff → iconfont.1756272539382.woff} +0 -0
- /package/es/{iconfont.1756083626568.woff2 → iconfont.1756272539382.woff2} +0 -0
- /package/lib/{iconfont.1756083626568.ttf → iconfont.1756272539382.ttf} +0 -0
- /package/lib/{iconfont.1756083626568.woff → iconfont.1756272539382.woff} +0 -0
- /package/lib/{iconfont.1756083626568.woff2 → iconfont.1756272539382.woff2} +0 -0
package/es/table/src/methods.js
CHANGED
|
@@ -7,12 +7,14 @@ import { getRowUniqueId, clearTableAllStatus, getColumnList, toFilters, getRowke
|
|
|
7
7
|
import { getSlotVNs } from '../../ui/src/vn';
|
|
8
8
|
import { moveRowAnimateToTb, clearRowAnimate, moveColAnimateToLr, clearColAnimate } from './anime';
|
|
9
9
|
import { warnLog, errLog } from '../../ui/src/log';
|
|
10
|
+
import { getCrossTableDragRowInfo } from './store';
|
|
10
11
|
const { getConfig, getI18n, renderer, formats, interceptor, createEvent } = VxeUI;
|
|
11
12
|
const browseObj = XEUtils.browse();
|
|
12
13
|
const supportMaxRow = 5e6;
|
|
13
14
|
const customStorageKey = 'VXE_CUSTOM_STORE';
|
|
14
15
|
const maxYHeight = 5e6;
|
|
15
16
|
const maxXWidth = 5e6;
|
|
17
|
+
let crossTableDragRowObj = null;
|
|
16
18
|
function eqCellValue(row1, row2, field) {
|
|
17
19
|
const val1 = XEUtils.get(row1, field);
|
|
18
20
|
const val2 = XEUtils.get(row2, field);
|
|
@@ -960,22 +962,28 @@ function updateStyle($xeTable) {
|
|
|
960
962
|
emptyPlaceholderElem.style.top = `${tHeaderHeight}px`;
|
|
961
963
|
emptyPlaceholderElem.style.height = bodyWrapperElem ? `${bodyWrapperElem.offsetHeight - osbHeight}px` : '';
|
|
962
964
|
}
|
|
965
|
+
const scrollbarXConf = scrollbarOpts.x || {};
|
|
963
966
|
const scrollbarXToTop = $xeTable.computeScrollbarXToTop;
|
|
967
|
+
const scrollbarYConf = scrollbarOpts.y || {};
|
|
964
968
|
const scrollbarYToLeft = $xeTable.computeScrollbarYToLeft;
|
|
965
969
|
let xScrollbarVisible = overflowX ? 'visible' : 'hidden';
|
|
966
|
-
if ($xeGanttView) {
|
|
970
|
+
if (scrollbarXConf.visible === 'visible' || $xeGanttView) {
|
|
967
971
|
osbHeight = scrollbarHeight;
|
|
968
972
|
xScrollbarVisible = 'visible';
|
|
969
973
|
}
|
|
970
|
-
else if (
|
|
974
|
+
else if (scrollbarXConf.visible === 'hidden' || scrollbarXConf.visible === false) {
|
|
971
975
|
osbHeight = 0;
|
|
972
976
|
xScrollbarVisible = 'hidden';
|
|
973
977
|
}
|
|
974
978
|
let yScrollbarVisible = overflowY ? 'visible' : 'hidden';
|
|
975
|
-
if ((
|
|
979
|
+
if ((scrollbarYConf.visible === 'hidden' || scrollbarYConf.visible === false) || ($xeGanttView && !scrollbarYToLeft)) {
|
|
976
980
|
osbWidth = 0;
|
|
977
981
|
yScrollbarVisible = 'hidden';
|
|
978
982
|
}
|
|
983
|
+
else if (scrollbarYConf.visible === 'visible') {
|
|
984
|
+
osbWidth = scrollbarWidth;
|
|
985
|
+
yScrollbarVisible = 'visible';
|
|
986
|
+
}
|
|
979
987
|
let tbHeight = 0;
|
|
980
988
|
let bodyMaxHeight = 0;
|
|
981
989
|
const bodyMinHeight = customMinHeight - tHeaderHeight - tFooterHeight - osbHeight;
|
|
@@ -2348,6 +2356,11 @@ function handleTargetEnterEvent($xeTable, isClear) {
|
|
|
2348
2356
|
}
|
|
2349
2357
|
}
|
|
2350
2358
|
}
|
|
2359
|
+
function clearCrossTableDragStatus($xeTable) {
|
|
2360
|
+
const crossTableDragRowInfo = getCrossTableDragRowInfo($xeTable);
|
|
2361
|
+
crossTableDragRowObj = null;
|
|
2362
|
+
crossTableDragRowInfo.row = null;
|
|
2363
|
+
}
|
|
2351
2364
|
function clearDragStatus($xeTable) {
|
|
2352
2365
|
const reactData = $xeTable;
|
|
2353
2366
|
const { dragRow, dragCol } = reactData;
|
|
@@ -2355,6 +2368,7 @@ function clearDragStatus($xeTable) {
|
|
|
2355
2368
|
clearColDropOrigin($xeTable);
|
|
2356
2369
|
clearRowDropOrigin($xeTable);
|
|
2357
2370
|
hideDropTip($xeTable);
|
|
2371
|
+
clearCrossTableDragStatus($xeTable);
|
|
2358
2372
|
reactData.dragRow = null;
|
|
2359
2373
|
reactData.dragCol = null;
|
|
2360
2374
|
}
|
|
@@ -2548,6 +2562,26 @@ function hideDropTip($xeTable) {
|
|
|
2548
2562
|
cdLineEl.style.display = '';
|
|
2549
2563
|
}
|
|
2550
2564
|
}
|
|
2565
|
+
function clearRowDragData($xeTable) {
|
|
2566
|
+
const $xeGantt = $xeTable.$xeGantt;
|
|
2567
|
+
const reactData = $xeTable;
|
|
2568
|
+
const internalData = $xeTable;
|
|
2569
|
+
let wrapperEl = $xeTable.$refs.refElem;
|
|
2570
|
+
const dtClss = ['.vxe-body--row'];
|
|
2571
|
+
if ($xeGantt) {
|
|
2572
|
+
const ganttContainerElem = $xeGantt.$refs.refGanttContainerElem;
|
|
2573
|
+
if (ganttContainerElem) {
|
|
2574
|
+
wrapperEl = ganttContainerElem;
|
|
2575
|
+
}
|
|
2576
|
+
dtClss.push('.vxe-gantt-view--body-row', '.vxe-gantt-view--chart-row');
|
|
2577
|
+
}
|
|
2578
|
+
hideDropTip($xeTable);
|
|
2579
|
+
clearRowDropOrigin($xeTable);
|
|
2580
|
+
clearRowAnimate(wrapperEl, dtClss);
|
|
2581
|
+
internalData.prevDragToChild = false;
|
|
2582
|
+
reactData.dragRow = null;
|
|
2583
|
+
reactData.dragCol = null;
|
|
2584
|
+
}
|
|
2551
2585
|
/**
|
|
2552
2586
|
* 处理显示 tooltip
|
|
2553
2587
|
* @param {Event} evnt 事件
|
|
@@ -4778,7 +4812,9 @@ const Methods = {
|
|
|
4778
4812
|
}
|
|
4779
4813
|
}
|
|
4780
4814
|
}
|
|
4781
|
-
|
|
4815
|
+
const rest = $xeTable.handleRowDragSwapEvent(null, true, dragRow, prevDragRow, dragPos || defPos, dragToChild === true);
|
|
4816
|
+
clearRowDragData($xeTable);
|
|
4817
|
+
return rest;
|
|
4782
4818
|
},
|
|
4783
4819
|
/**
|
|
4784
4820
|
* 获取表格的全量列
|
|
@@ -6162,7 +6198,7 @@ const Methods = {
|
|
|
6162
6198
|
// 如果点击了当前表格之外
|
|
6163
6199
|
!getEventTargetNode(evnt, $el).flag) {
|
|
6164
6200
|
setTimeout(() => {
|
|
6165
|
-
|
|
6201
|
+
$xeTable.handleClearEdit(evnt).then(() => {
|
|
6166
6202
|
// 如果存在校验,点击了表格之外则清除
|
|
6167
6203
|
if (!this.isActivated && editRules && validOpts.autoClear) {
|
|
6168
6204
|
this.validErrorMaps = {};
|
|
@@ -6178,17 +6214,17 @@ const Methods = {
|
|
|
6178
6214
|
}
|
|
6179
6215
|
else if (mouseConfig) {
|
|
6180
6216
|
if (!getEventTargetNode(evnt, $el).flag && !($xeGGWrapper && getEventTargetNode(evnt, $xeGGWrapper.$el).flag) && !(tableMenu && getEventTargetNode(evnt, tableMenu.$el).flag) && !($toolbar && getEventTargetNode(evnt, $toolbar.$el).flag)) {
|
|
6181
|
-
if (
|
|
6182
|
-
|
|
6217
|
+
if ($xeTable.clearSelected) {
|
|
6218
|
+
$xeTable.clearSelected();
|
|
6183
6219
|
}
|
|
6184
6220
|
if (areaOpts.autoClear) {
|
|
6185
|
-
if (
|
|
6186
|
-
const cellAreas =
|
|
6221
|
+
if ($xeTable.getCellAreas) {
|
|
6222
|
+
const cellAreas = $xeTable.getCellAreas();
|
|
6187
6223
|
if (cellAreas && cellAreas.length && !getEventTargetNode(evnt, document.body, 'vxe-table--ignore-areas-clear').flag) {
|
|
6188
|
-
|
|
6189
|
-
|
|
6190
|
-
|
|
6191
|
-
|
|
6224
|
+
$xeTable.preventEvent(evnt, 'event.clearAreas', {}, () => {
|
|
6225
|
+
$xeTable.clearCellAreas();
|
|
6226
|
+
$xeTable.clearCopyCellArea();
|
|
6227
|
+
$xeTable.dispatchEvent('clear-cell-area-selection', { cellAreas }, evnt);
|
|
6192
6228
|
});
|
|
6193
6229
|
}
|
|
6194
6230
|
}
|
|
@@ -6225,13 +6261,14 @@ const Methods = {
|
|
|
6225
6261
|
* 表格键盘事件
|
|
6226
6262
|
*/
|
|
6227
6263
|
keydownEvent(evnt) {
|
|
6264
|
+
const $xeTable = this;
|
|
6228
6265
|
const { filterStore, ctxMenuStore, editStore, keyboardConfig, mouseConfig, mouseOpts, keyboardOpts } = this;
|
|
6229
6266
|
const { actived } = editStore;
|
|
6230
6267
|
const { keyCode } = evnt;
|
|
6231
6268
|
const isEsc = keyCode === 27;
|
|
6232
6269
|
if (isEsc) {
|
|
6233
6270
|
this.preventEvent(evnt, 'event.keydown', null, () => {
|
|
6234
|
-
|
|
6271
|
+
$xeTable.dispatchEvent('keydown-start', {}, evnt);
|
|
6235
6272
|
if (keyboardConfig && mouseConfig && mouseOpts.area && this.handleKeyboardCellAreaEvent) {
|
|
6236
6273
|
this.handleKeyboardCellAreaEvent(evnt);
|
|
6237
6274
|
}
|
|
@@ -6252,8 +6289,8 @@ const Methods = {
|
|
|
6252
6289
|
}
|
|
6253
6290
|
}
|
|
6254
6291
|
}
|
|
6255
|
-
|
|
6256
|
-
|
|
6292
|
+
$xeTable.dispatchEvent('keydown', {}, evnt);
|
|
6293
|
+
$xeTable.dispatchEvent('keydown-end', {}, evnt);
|
|
6257
6294
|
});
|
|
6258
6295
|
}
|
|
6259
6296
|
},
|
|
@@ -6584,6 +6621,7 @@ const Methods = {
|
|
|
6584
6621
|
}
|
|
6585
6622
|
},
|
|
6586
6623
|
handleGlobalPasteEvent(evnt) {
|
|
6624
|
+
const $xeTable = this;
|
|
6587
6625
|
const { isActivated, keyboardConfig, keyboardOpts, mouseConfig, mouseOpts, editStore, filterStore } = this;
|
|
6588
6626
|
const { actived } = editStore;
|
|
6589
6627
|
if (isActivated && !filterStore.visible) {
|
|
@@ -6592,10 +6630,11 @@ const Methods = {
|
|
|
6592
6630
|
this.handlePasteCellAreaEvent(evnt);
|
|
6593
6631
|
}
|
|
6594
6632
|
}
|
|
6595
|
-
|
|
6633
|
+
$xeTable.dispatchEvent('paste', {}, evnt);
|
|
6596
6634
|
}
|
|
6597
6635
|
},
|
|
6598
6636
|
handleGlobalCopyEvent(evnt) {
|
|
6637
|
+
const $xeTable = this;
|
|
6599
6638
|
const { isActivated, keyboardConfig, keyboardOpts, mouseConfig, mouseOpts, editStore, filterStore } = this;
|
|
6600
6639
|
const { actived } = editStore;
|
|
6601
6640
|
if (isActivated && !filterStore.visible) {
|
|
@@ -6604,10 +6643,11 @@ const Methods = {
|
|
|
6604
6643
|
this.handleCopyCellAreaEvent(evnt);
|
|
6605
6644
|
}
|
|
6606
6645
|
}
|
|
6607
|
-
|
|
6646
|
+
$xeTable.dispatchEvent('copy', {}, evnt);
|
|
6608
6647
|
}
|
|
6609
6648
|
},
|
|
6610
6649
|
handleGlobalCutEvent(evnt) {
|
|
6650
|
+
const $xeTable = this;
|
|
6611
6651
|
const { isActivated, keyboardConfig, keyboardOpts, mouseConfig, mouseOpts, editStore, filterStore } = this;
|
|
6612
6652
|
const { actived } = editStore;
|
|
6613
6653
|
if (isActivated && !filterStore.visible) {
|
|
@@ -6616,7 +6656,7 @@ const Methods = {
|
|
|
6616
6656
|
this.handleCutCellAreaEvent(evnt);
|
|
6617
6657
|
}
|
|
6618
6658
|
}
|
|
6619
|
-
|
|
6659
|
+
$xeTable.dispatchEvent('cut', {}, evnt);
|
|
6620
6660
|
}
|
|
6621
6661
|
},
|
|
6622
6662
|
handleGlobalResizeEvent() {
|
|
@@ -7789,7 +7829,8 @@ const Methods = {
|
|
|
7789
7829
|
return $xeTable.$nextTick();
|
|
7790
7830
|
},
|
|
7791
7831
|
triggerHeaderCellDblclickEvent(evnt, params) {
|
|
7792
|
-
|
|
7832
|
+
const $xeTable = this;
|
|
7833
|
+
$xeTable.dispatchEvent('header-cell-dblclick', Object.assign({ cell: evnt.currentTarget }, params), evnt);
|
|
7793
7834
|
},
|
|
7794
7835
|
getCurrentColumn() {
|
|
7795
7836
|
return this.columnOpts.isCurrent || this.highlightCurrentColumn ? this.currentColumn : null;
|
|
@@ -7975,7 +8016,7 @@ const Methods = {
|
|
|
7975
8016
|
}
|
|
7976
8017
|
}
|
|
7977
8018
|
}
|
|
7978
|
-
|
|
8019
|
+
$xeTable.dispatchEvent('cell-dblclick', params, evnt);
|
|
7979
8020
|
},
|
|
7980
8021
|
handleColumnSortEvent(evnt, column) {
|
|
7981
8022
|
const $xeTable = this;
|
|
@@ -8399,12 +8440,239 @@ const Methods = {
|
|
|
8399
8440
|
}
|
|
8400
8441
|
return Promise.resolve(errRest);
|
|
8401
8442
|
},
|
|
8402
|
-
|
|
8443
|
+
/**
|
|
8444
|
+
* 处理跨表拖拽完成
|
|
8445
|
+
*/
|
|
8446
|
+
handleCrossTableRowDragFinishEvent(evnt) {
|
|
8447
|
+
const $xeTable = this;
|
|
8448
|
+
const $xeGantt = $xeTable.$xeGantt;
|
|
8449
|
+
const reactData = $xeTable;
|
|
8450
|
+
const internalData = $xeTable;
|
|
8451
|
+
const crossTableDragRowInfo = getCrossTableDragRowInfo($xeTable);
|
|
8452
|
+
const { tableData } = reactData;
|
|
8453
|
+
const { fullAllDataRowIdData } = internalData;
|
|
8454
|
+
const rowOpts = $xeTable.computeRowOpts;
|
|
8455
|
+
const cellOpts = $xeTable.computeCellOpts;
|
|
8456
|
+
const defaultRowHeight = $xeTable.computeDefaultRowHeight;
|
|
8457
|
+
const rowDragOpts = $xeTable.computeRowDragOpts;
|
|
8458
|
+
const { animation, isCrossTableDrag } = rowDragOpts;
|
|
8459
|
+
const treeOpts = $xeTable.computeTreeOpts;
|
|
8460
|
+
const { mapChildrenField } = treeOpts;
|
|
8461
|
+
const el = $xeTable.$refs.refElem;
|
|
8462
|
+
if (isCrossTableDrag && crossTableDragRowObj && crossTableDragRowInfo) {
|
|
8463
|
+
const { row: dragRow } = crossTableDragRowInfo;
|
|
8464
|
+
if (dragRow) {
|
|
8465
|
+
const dragRowid = getRowid($xeTable, dragRow);
|
|
8466
|
+
const dragRowRest = fullAllDataRowIdData[dragRowid];
|
|
8467
|
+
let dragRowHeight = 0;
|
|
8468
|
+
let rsIndex = -1;
|
|
8469
|
+
if (dragRowRest) {
|
|
8470
|
+
if (animation) {
|
|
8471
|
+
dragRowHeight = getCellRestHeight(dragRowRest, cellOpts, rowOpts, defaultRowHeight);
|
|
8472
|
+
}
|
|
8473
|
+
rsIndex = dragRowRest.$index;
|
|
8474
|
+
}
|
|
8475
|
+
const dragRangeList = rsIndex > -1 && rsIndex < tableData.length - 1 ? tableData.slice(rsIndex + 1) : [];
|
|
8476
|
+
const dragList = XEUtils.toTreeArray([dragRow], {
|
|
8477
|
+
updated: true,
|
|
8478
|
+
children: mapChildrenField
|
|
8479
|
+
});
|
|
8480
|
+
$xeTable.remove(dragList).then(() => {
|
|
8481
|
+
if (animation && dragRowHeight && dragRangeList.length) {
|
|
8482
|
+
const $xeGanttView = internalData.xeGanttView;
|
|
8483
|
+
let wrapperEl = el;
|
|
8484
|
+
if ($xeGantt && $xeGanttView) {
|
|
8485
|
+
const ganttContainerElem = $xeGantt.$refs.refGanttContainerElem;
|
|
8486
|
+
if (ganttContainerElem) {
|
|
8487
|
+
wrapperEl = ganttContainerElem;
|
|
8488
|
+
}
|
|
8489
|
+
}
|
|
8490
|
+
const dtClss = [];
|
|
8491
|
+
dragRangeList.forEach(row => {
|
|
8492
|
+
const rowid = getRowid($xeTable, row);
|
|
8493
|
+
dtClss.push(`.vxe-body--row[rowid="${rowid}"]`);
|
|
8494
|
+
if ($xeGantt) {
|
|
8495
|
+
dtClss.push(`.vxe-gantt-view--body-row[rowid="${rowid}"]`, `.vxe-gantt-view--chart-row[rowid="${rowid}"]`);
|
|
8496
|
+
}
|
|
8497
|
+
});
|
|
8498
|
+
const dtTrList = wrapperEl.querySelectorAll(dtClss.join(','));
|
|
8499
|
+
moveRowAnimateToTb(dtTrList, dragRowHeight);
|
|
8500
|
+
}
|
|
8501
|
+
});
|
|
8502
|
+
$xeTable.dispatchEvent('row-remove-dragend', {
|
|
8503
|
+
row: dragRow
|
|
8504
|
+
}, evnt);
|
|
8505
|
+
clearRowDragData($xeTable);
|
|
8506
|
+
clearCrossTableDragStatus($xeTable);
|
|
8507
|
+
}
|
|
8508
|
+
}
|
|
8509
|
+
},
|
|
8510
|
+
/**
|
|
8511
|
+
* 处理跨表拖至新的空表
|
|
8512
|
+
*/
|
|
8513
|
+
handleCrossTableRowDragoverEmptyEvent(evnt) {
|
|
8514
|
+
const $xeTable = this;
|
|
8515
|
+
const reactData = $xeTable;
|
|
8516
|
+
const internalData = $xeTable;
|
|
8517
|
+
const { tableData } = reactData;
|
|
8518
|
+
const rowDragOpts = $xeTable.computeRowDragOpts;
|
|
8519
|
+
const { isCrossTableDrag } = rowDragOpts;
|
|
8520
|
+
if (isCrossTableDrag && crossTableDragRowObj && !tableData.length) {
|
|
8521
|
+
const { $oldTable } = crossTableDragRowObj;
|
|
8522
|
+
if ($oldTable && $oldTable.xID !== $xeTable.xID) {
|
|
8523
|
+
evnt.preventDefault();
|
|
8524
|
+
crossTableDragRowObj.$newTable = $xeTable;
|
|
8525
|
+
internalData.prevDragRow = null;
|
|
8526
|
+
}
|
|
8527
|
+
}
|
|
8528
|
+
},
|
|
8529
|
+
/**
|
|
8530
|
+
* 处理跨表拖插入
|
|
8531
|
+
*/
|
|
8532
|
+
handleCrossTableRowDragInsertEvent(evnt) {
|
|
8403
8533
|
const $xeTable = this;
|
|
8404
8534
|
const $xeGantt = $xeTable.$xeGantt;
|
|
8405
8535
|
const props = $xeTable;
|
|
8406
8536
|
const reactData = $xeTable;
|
|
8407
8537
|
const internalData = $xeTable;
|
|
8538
|
+
const crossTableDragRowInfo = getCrossTableDragRowInfo($xeTable);
|
|
8539
|
+
const { treeConfig } = props;
|
|
8540
|
+
const { prevDragRow, prevDragPos, prevDragToChild } = internalData;
|
|
8541
|
+
const rowDragOpts = $xeTable.computeRowDragOpts;
|
|
8542
|
+
const { animation, isSelfToChildDrag, isCrossTableDrag, dragEndMethod, dragToChildMethod } = rowDragOpts;
|
|
8543
|
+
const rowOpts = $xeTable.computeRowOpts;
|
|
8544
|
+
const cellOpts = $xeTable.computeCellOpts;
|
|
8545
|
+
const defaultRowHeight = $xeTable.computeDefaultRowHeight;
|
|
8546
|
+
const treeOpts = $xeTable.computeTreeOpts;
|
|
8547
|
+
const { parentField, mapChildrenField } = treeOpts;
|
|
8548
|
+
const childrenField = treeOpts.children || treeOpts.childrenField;
|
|
8549
|
+
// 跨表拖拽
|
|
8550
|
+
if (isCrossTableDrag && crossTableDragRowObj && crossTableDragRowInfo) {
|
|
8551
|
+
const { row: oldRow } = crossTableDragRowInfo;
|
|
8552
|
+
const { $oldTable } = crossTableDragRowObj;
|
|
8553
|
+
const el = $xeTable.$refs.refElem;
|
|
8554
|
+
if ($oldTable && oldRow) {
|
|
8555
|
+
const dragRow = oldRow;
|
|
8556
|
+
let dragOffsetIndex = -1;
|
|
8557
|
+
if (prevDragRow) {
|
|
8558
|
+
dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0;
|
|
8559
|
+
}
|
|
8560
|
+
const dragParams = {
|
|
8561
|
+
oldRow: dragRow,
|
|
8562
|
+
newRow: prevDragRow,
|
|
8563
|
+
dragRow,
|
|
8564
|
+
dragPos: prevDragPos,
|
|
8565
|
+
dragToChild: !!prevDragToChild,
|
|
8566
|
+
offsetIndex: dragOffsetIndex
|
|
8567
|
+
};
|
|
8568
|
+
const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
|
|
8569
|
+
const errRest = {
|
|
8570
|
+
status: false
|
|
8571
|
+
};
|
|
8572
|
+
Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
|
|
8573
|
+
if (!status) {
|
|
8574
|
+
return errRest;
|
|
8575
|
+
}
|
|
8576
|
+
let insertRest = Promise.resolve();
|
|
8577
|
+
if (treeConfig) {
|
|
8578
|
+
const dragList = XEUtils.toTreeArray([dragRow], {
|
|
8579
|
+
updated: true,
|
|
8580
|
+
children: mapChildrenField
|
|
8581
|
+
});
|
|
8582
|
+
$oldTable.handleCrossTableRowDragFinishEvent(evnt);
|
|
8583
|
+
if (prevDragRow) {
|
|
8584
|
+
dragRow[parentField] = prevDragRow[parentField];
|
|
8585
|
+
}
|
|
8586
|
+
else {
|
|
8587
|
+
dragRow[parentField] = null;
|
|
8588
|
+
}
|
|
8589
|
+
dragList.forEach(row => {
|
|
8590
|
+
row[childrenField] = undefined;
|
|
8591
|
+
row[mapChildrenField] = undefined;
|
|
8592
|
+
});
|
|
8593
|
+
if (prevDragRow) {
|
|
8594
|
+
if (prevDragPos === 'bottom') {
|
|
8595
|
+
insertRest = $xeTable.insertNextAt(dragList, prevDragRow);
|
|
8596
|
+
}
|
|
8597
|
+
else {
|
|
8598
|
+
insertRest = $xeTable.insertAt(dragList, prevDragRow);
|
|
8599
|
+
}
|
|
8600
|
+
}
|
|
8601
|
+
else {
|
|
8602
|
+
insertRest = $xeTable.insert(dragList);
|
|
8603
|
+
}
|
|
8604
|
+
}
|
|
8605
|
+
else {
|
|
8606
|
+
$oldTable.handleCrossTableRowDragFinishEvent(evnt);
|
|
8607
|
+
if (prevDragRow) {
|
|
8608
|
+
if (prevDragPos === 'bottom') {
|
|
8609
|
+
insertRest = $xeTable.insertNextAt(dragRow, prevDragRow);
|
|
8610
|
+
}
|
|
8611
|
+
else {
|
|
8612
|
+
insertRest = $xeTable.insertAt(dragRow, prevDragRow);
|
|
8613
|
+
}
|
|
8614
|
+
}
|
|
8615
|
+
else {
|
|
8616
|
+
insertRest = $xeTable.insert(dragRow);
|
|
8617
|
+
}
|
|
8618
|
+
}
|
|
8619
|
+
$xeTable.dispatchEvent('row-insert-dragend', {
|
|
8620
|
+
oldRow,
|
|
8621
|
+
newRow: prevDragRow,
|
|
8622
|
+
dragRow,
|
|
8623
|
+
dragPos: prevDragPos,
|
|
8624
|
+
dragToChild: isDragToChildFlag,
|
|
8625
|
+
offsetIndex: dragOffsetIndex
|
|
8626
|
+
}, evnt);
|
|
8627
|
+
clearRowDragData($xeTable);
|
|
8628
|
+
insertRest.then(() => {
|
|
8629
|
+
const { tableData } = reactData;
|
|
8630
|
+
const { fullAllDataRowIdData } = internalData;
|
|
8631
|
+
const oldRowid = getRowid($xeTable, dragRow);
|
|
8632
|
+
const oldRowRest = fullAllDataRowIdData[oldRowid];
|
|
8633
|
+
let dragRowHeight = 0;
|
|
8634
|
+
let rsIndex = -1;
|
|
8635
|
+
if (oldRowRest) {
|
|
8636
|
+
if (animation) {
|
|
8637
|
+
dragRowHeight = getCellRestHeight(oldRowRest, cellOpts, rowOpts, defaultRowHeight);
|
|
8638
|
+
}
|
|
8639
|
+
rsIndex = oldRowRest.$index;
|
|
8640
|
+
}
|
|
8641
|
+
const dragRangeList = rsIndex > -1 ? tableData.slice(rsIndex) : [];
|
|
8642
|
+
if (animation && dragRowHeight && dragRangeList.length) {
|
|
8643
|
+
const $xeGanttView = internalData.xeGanttView;
|
|
8644
|
+
let wrapperEl = el;
|
|
8645
|
+
if ($xeGantt && $xeGanttView) {
|
|
8646
|
+
const ganttContainerElem = $xeGantt.$refs.refGanttContainerElem;
|
|
8647
|
+
if (ganttContainerElem) {
|
|
8648
|
+
wrapperEl = ganttContainerElem;
|
|
8649
|
+
}
|
|
8650
|
+
}
|
|
8651
|
+
const dtClss = [];
|
|
8652
|
+
dragRangeList.forEach(row => {
|
|
8653
|
+
const rowid = getRowid($xeTable, row);
|
|
8654
|
+
dtClss.push(`.vxe-body--row[rowid="${rowid}"]`);
|
|
8655
|
+
if ($xeGantt) {
|
|
8656
|
+
dtClss.push(`.vxe-gantt-view--body-row[rowid="${rowid}"]`, `.vxe-gantt-view--chart-row[rowid="${rowid}"]`);
|
|
8657
|
+
}
|
|
8658
|
+
});
|
|
8659
|
+
const dtTrList = wrapperEl.querySelectorAll(dtClss.join(','));
|
|
8660
|
+
moveRowAnimateToTb(dtTrList, -dragRowHeight);
|
|
8661
|
+
}
|
|
8662
|
+
});
|
|
8663
|
+
});
|
|
8664
|
+
}
|
|
8665
|
+
}
|
|
8666
|
+
},
|
|
8667
|
+
hideCrossTableRowDropClearStatus() {
|
|
8668
|
+
const $xeTable = this;
|
|
8669
|
+
hideDropTip($xeTable);
|
|
8670
|
+
},
|
|
8671
|
+
handleRowDragDragendEvent(evnt) {
|
|
8672
|
+
const $xeTable = this;
|
|
8673
|
+
const props = $xeTable;
|
|
8674
|
+
const reactData = $xeTable;
|
|
8675
|
+
const internalData = $xeTable;
|
|
8408
8676
|
const { treeConfig } = props;
|
|
8409
8677
|
const { fullAllDataRowIdData, prevDragToChild } = internalData;
|
|
8410
8678
|
const { dragRow } = reactData;
|
|
@@ -8412,7 +8680,18 @@ const Methods = {
|
|
|
8412
8680
|
const { lazy } = treeOpts;
|
|
8413
8681
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField;
|
|
8414
8682
|
const { prevDragRow, prevDragPos } = internalData;
|
|
8415
|
-
|
|
8683
|
+
const rowDragOpts = $xeTable.computeRowDragOpts;
|
|
8684
|
+
const { isCrossTableDrag, isCrossDrag } = rowDragOpts;
|
|
8685
|
+
// 跨表拖拽
|
|
8686
|
+
if (isCrossTableDrag && crossTableDragRowObj) {
|
|
8687
|
+
const { $newTable } = crossTableDragRowObj;
|
|
8688
|
+
if ($newTable && $newTable.xID !== $xeTable.xID) {
|
|
8689
|
+
if (!treeConfig || isCrossDrag) {
|
|
8690
|
+
$newTable.handleCrossTableRowDragInsertEvent(evnt);
|
|
8691
|
+
}
|
|
8692
|
+
return;
|
|
8693
|
+
}
|
|
8694
|
+
}
|
|
8416
8695
|
if (treeConfig && lazy && prevDragToChild) {
|
|
8417
8696
|
// 懒加载
|
|
8418
8697
|
const newRowid = getRowid($xeTable, prevDragRow);
|
|
@@ -8429,20 +8708,8 @@ const Methods = {
|
|
|
8429
8708
|
else {
|
|
8430
8709
|
$xeTable.handleRowDragSwapEvent(evnt, true, dragRow, prevDragRow, prevDragPos, prevDragToChild);
|
|
8431
8710
|
}
|
|
8432
|
-
|
|
8433
|
-
|
|
8434
|
-
const ganttContainerElem = $xeGantt.$refs.refGanttContainerElem;
|
|
8435
|
-
if (ganttContainerElem) {
|
|
8436
|
-
wrapperEl = ganttContainerElem;
|
|
8437
|
-
}
|
|
8438
|
-
dtClss.push('.vxe-gantt-view--body-row', '.vxe-gantt-view--chart-row');
|
|
8439
|
-
}
|
|
8440
|
-
hideDropTip($xeTable);
|
|
8441
|
-
clearRowDropOrigin($xeTable);
|
|
8442
|
-
clearRowAnimate(wrapperEl, dtClss);
|
|
8443
|
-
internalData.prevDragToChild = false;
|
|
8444
|
-
reactData.dragRow = null;
|
|
8445
|
-
reactData.dragCol = null;
|
|
8711
|
+
clearRowDragData($xeTable);
|
|
8712
|
+
clearCrossTableDragStatus($xeTable);
|
|
8446
8713
|
},
|
|
8447
8714
|
handleRowDragDragoverEvent(evnt) {
|
|
8448
8715
|
const $xeTable = this;
|
|
@@ -8456,8 +8723,8 @@ const Methods = {
|
|
|
8456
8723
|
const { lazy, transform, parentField } = treeOpts;
|
|
8457
8724
|
const hasChildField = treeOpts.hasChild || treeOpts.hasChildField;
|
|
8458
8725
|
const rowDragOpts = $xeTable.computeRowDragOpts;
|
|
8459
|
-
const { isPeerDrag, isCrossDrag, isToChildDrag } = rowDragOpts;
|
|
8460
|
-
if (!dragRow) {
|
|
8726
|
+
const { isPeerDrag, isCrossDrag, isToChildDrag, isCrossTableDrag } = rowDragOpts;
|
|
8727
|
+
if (!dragRow && !(isCrossTableDrag && (!treeConfig || isCrossDrag) && crossTableDragRowObj)) {
|
|
8461
8728
|
evnt.preventDefault();
|
|
8462
8729
|
return;
|
|
8463
8730
|
}
|
|
@@ -8466,16 +8733,38 @@ const Methods = {
|
|
|
8466
8733
|
const rowid = trEl.getAttribute('rowid') || '';
|
|
8467
8734
|
const rest = fullAllDataRowIdData[rowid];
|
|
8468
8735
|
if (rest) {
|
|
8736
|
+
evnt.preventDefault();
|
|
8469
8737
|
const row = rest.row;
|
|
8470
8738
|
const rowid = getRowid($xeTable, row);
|
|
8471
8739
|
const rowRest = fullAllDataRowIdData[rowid];
|
|
8472
|
-
evnt.preventDefault();
|
|
8473
|
-
const { dragRow } = reactData;
|
|
8474
8740
|
const offsetY = evnt.clientY - trEl.getBoundingClientRect().y;
|
|
8475
8741
|
const dragPos = offsetY < trEl.clientHeight / 2 ? 'top' : 'bottom';
|
|
8476
|
-
internalData.prevDragToChild = !!(treeConfig && transform && isToChildDrag && isControlKey);
|
|
8742
|
+
internalData.prevDragToChild = !!(treeConfig && transform && (isCrossDrag && isToChildDrag) && isControlKey);
|
|
8477
8743
|
internalData.prevDragRow = row;
|
|
8478
8744
|
internalData.prevDragPos = dragPos;
|
|
8745
|
+
// 跨表拖拽
|
|
8746
|
+
if (isCrossTableDrag && (!treeConfig || isCrossDrag) && crossTableDragRowObj) {
|
|
8747
|
+
const { $oldTable, $newTable } = crossTableDragRowObj;
|
|
8748
|
+
if ($oldTable) {
|
|
8749
|
+
const oldTableReactData = $oldTable;
|
|
8750
|
+
if ($oldTable.xID === $xeTable.xID) {
|
|
8751
|
+
if ($newTable) {
|
|
8752
|
+
$newTable.hideCrossTableRowDropClearStatus();
|
|
8753
|
+
}
|
|
8754
|
+
reactData.isCrossDragRow = false;
|
|
8755
|
+
oldTableReactData.isCrossDragRow = false;
|
|
8756
|
+
crossTableDragRowObj.$newTable = null;
|
|
8757
|
+
}
|
|
8758
|
+
else if (!treeConfig || isCrossDrag) {
|
|
8759
|
+
$oldTable.hideCrossTableRowDropClearStatus();
|
|
8760
|
+
oldTableReactData.isCrossDragRow = true;
|
|
8761
|
+
reactData.dragTipText = oldTableReactData.dragTipText;
|
|
8762
|
+
crossTableDragRowObj.$newTable = $xeTable;
|
|
8763
|
+
showDropTip($xeTable, evnt, trEl, null, true, dragPos);
|
|
8764
|
+
return;
|
|
8765
|
+
}
|
|
8766
|
+
}
|
|
8767
|
+
}
|
|
8479
8768
|
if ($xeTable.eqRow(dragRow, row) ||
|
|
8480
8769
|
(isControlKey && treeConfig && lazy && row[hasChildField] && rowRest && !rowRest.treeLoaded) ||
|
|
8481
8770
|
(!isCrossDrag && treeConfig && transform && (isPeerDrag ? dragRow[parentField] !== row[parentField] : rest.level))) {
|
|
@@ -8495,10 +8784,11 @@ const Methods = {
|
|
|
8495
8784
|
const $xeTable = this;
|
|
8496
8785
|
const props = $xeTable;
|
|
8497
8786
|
const reactData = $xeTable;
|
|
8787
|
+
const crossTableDragRowInfo = getCrossTableDragRowInfo($xeTable);
|
|
8498
8788
|
evnt.stopPropagation();
|
|
8499
8789
|
const { dragConfig } = props;
|
|
8500
8790
|
const rowDragOpts = $xeTable.computeRowDragOpts;
|
|
8501
|
-
const { trigger, dragStartMethod } = rowDragOpts;
|
|
8791
|
+
const { isCrossTableDrag, trigger, dragStartMethod } = rowDragOpts;
|
|
8502
8792
|
const { row } = params;
|
|
8503
8793
|
const dragEl = evnt.currentTarget;
|
|
8504
8794
|
const tdEl = trigger === 'cell' || trigger === 'row' ? dragEl : (_a = dragEl.parentElement) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
@@ -8509,10 +8799,16 @@ const Methods = {
|
|
|
8509
8799
|
trEl.draggable = false;
|
|
8510
8800
|
reactData.dragRow = null;
|
|
8511
8801
|
reactData.dragCol = null;
|
|
8802
|
+
clearCrossTableDragStatus($xeTable);
|
|
8512
8803
|
hideDropTip($xeTable);
|
|
8513
8804
|
return;
|
|
8514
8805
|
}
|
|
8806
|
+
if (isCrossTableDrag) {
|
|
8807
|
+
crossTableDragRowInfo.row = row;
|
|
8808
|
+
crossTableDragRowObj = { $oldTable: $xeTable, $newTable: null };
|
|
8809
|
+
}
|
|
8515
8810
|
reactData.dragRow = row;
|
|
8811
|
+
reactData.isCrossDragRow = false;
|
|
8516
8812
|
reactData.dragCol = null;
|
|
8517
8813
|
trEl.draggable = true;
|
|
8518
8814
|
updateRowDropOrigin($xeTable, row);
|
|
@@ -8832,6 +9128,7 @@ const Methods = {
|
|
|
8832
9128
|
internalData.prevDragToChild = false;
|
|
8833
9129
|
reactData.dragRow = null;
|
|
8834
9130
|
reactData.dragCol = null;
|
|
9131
|
+
clearCrossTableDragStatus($xeTable);
|
|
8835
9132
|
},
|
|
8836
9133
|
handleHeaderCellDragDragoverEvent(evnt) {
|
|
8837
9134
|
const $xeTable = this;
|
|
@@ -8916,11 +9213,13 @@ const Methods = {
|
|
|
8916
9213
|
reactData.dragRow = null;
|
|
8917
9214
|
reactData.dragCol = null;
|
|
8918
9215
|
hideDropTip($xeTable);
|
|
9216
|
+
clearCrossTableDragStatus($xeTable);
|
|
8919
9217
|
return;
|
|
8920
9218
|
}
|
|
8921
9219
|
reactData.dragCol = column;
|
|
8922
9220
|
reactData.dragRow = null;
|
|
8923
9221
|
thEl.draggable = true;
|
|
9222
|
+
clearCrossTableDragStatus($xeTable);
|
|
8924
9223
|
updateColDropOrigin($xeTable, column);
|
|
8925
9224
|
updateColDropTipContent($xeTable, thEl);
|
|
8926
9225
|
$xeTable.dispatchEvent('column-dragstart', params, evnt);
|
|
@@ -8930,6 +9229,7 @@ const Methods = {
|
|
|
8930
9229
|
const reactData = $xeTable;
|
|
8931
9230
|
clearColDropOrigin($xeTable);
|
|
8932
9231
|
hideDropTip($xeTable);
|
|
9232
|
+
clearCrossTableDragStatus($xeTable);
|
|
8933
9233
|
reactData.dragRow = null;
|
|
8934
9234
|
reactData.dragCol = null;
|
|
8935
9235
|
},
|
|
@@ -11001,9 +11301,7 @@ const Methods = {
|
|
|
11001
11301
|
// 已废弃,使用 dispatchEvent
|
|
11002
11302
|
emitEvent(type, params, evnt) {
|
|
11003
11303
|
const $xeTable = this;
|
|
11004
|
-
|
|
11005
|
-
const $xeGantt = $xeTable.$xeGantt;
|
|
11006
|
-
$xeTable.$emit(type, createEvent(evnt, { $table: $xeTable, $grid: $xeGrid, $gantt: $xeGantt, $event: evnt }));
|
|
11304
|
+
$xeTable.dispatchEvent(type, params, evnt);
|
|
11007
11305
|
},
|
|
11008
11306
|
focus() {
|
|
11009
11307
|
this.isActivated = true;
|