vxe-pc-ui 3.15.15 → 3.15.16
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/icon/style.css +1 -1
- package/es/layout-container/style.css +14 -0
- package/es/layout-container/style.min.css +1 -1
- package/es/menu/style.css +0 -7
- package/es/menu/style.min.css +1 -1
- package/es/style.css +1 -1
- package/es/style.min.css +1 -1
- package/es/tree/src/tree.js +427 -107
- package/es/ui/index.js +1 -1
- package/es/ui/src/log.js +1 -1
- package/es/vxe-layout-container/style.css +14 -0
- package/es/vxe-layout-container/style.min.css +1 -1
- package/es/vxe-menu/style.css +0 -7
- package/es/vxe-menu/style.min.css +1 -1
- package/lib/icon/style/style.css +1 -1
- package/lib/icon/style/style.min.css +1 -1
- package/lib/index.umd.js +457 -109
- package/lib/index.umd.min.js +1 -1
- package/lib/layout-container/style/style.css +14 -0
- package/lib/layout-container/style/style.min.css +1 -1
- package/lib/menu/style/style.css +0 -7
- package/lib/menu/style/style.min.css +1 -1
- package/lib/style.css +1 -1
- package/lib/style.min.css +1 -1
- package/lib/tree/src/tree.js +455 -107
- package/lib/tree/src/tree.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/lib/vxe-layout-container/style/style.css +14 -0
- package/lib/vxe-layout-container/style/style.min.css +1 -1
- package/lib/vxe-menu/style/style.css +0 -7
- package/lib/vxe-menu/style/style.min.css +1 -1
- package/package.json +1 -1
- package/packages/tree/src/tree.ts +444 -107
- package/styles/components/layout-container.scss +15 -0
- package/styles/components/menu.scss +0 -12
- package/styles/theme/base.scss +1 -1
- package/types/components/tree.d.ts +33 -5
- /package/es/icon/{iconfont.1782810544397.ttf → iconfont.1782833699010.ttf} +0 -0
- /package/es/icon/{iconfont.1782810544397.woff → iconfont.1782833699010.woff} +0 -0
- /package/es/icon/{iconfont.1782810544397.woff2 → iconfont.1782833699010.woff2} +0 -0
- /package/es/{iconfont.1782810544397.ttf → iconfont.1782833699010.ttf} +0 -0
- /package/es/{iconfont.1782810544397.woff → iconfont.1782833699010.woff} +0 -0
- /package/es/{iconfont.1782810544397.woff2 → iconfont.1782833699010.woff2} +0 -0
- /package/lib/icon/style/{iconfont.1782810544397.ttf → iconfont.1782833699010.ttf} +0 -0
- /package/lib/icon/style/{iconfont.1782810544397.woff → iconfont.1782833699010.woff} +0 -0
- /package/lib/icon/style/{iconfont.1782810544397.woff2 → iconfont.1782833699010.woff2} +0 -0
- /package/lib/{iconfont.1782810544397.ttf → iconfont.1782833699010.ttf} +0 -0
- /package/lib/{iconfont.1782810544397.woff → iconfont.1782833699010.woff} +0 -0
- /package/lib/{iconfont.1782810544397.woff2 → iconfont.1782833699010.woff2} +0 -0
package/es/tree/src/tree.js
CHANGED
|
@@ -11,10 +11,7 @@ import { moveRowAnimateToTb, clearRowAnimate } from '../../ui/src/anime';
|
|
|
11
11
|
import VxeLoadingComponent from '../../loading';
|
|
12
12
|
const { warnLog, errLog } = createComponentLog('tree');
|
|
13
13
|
const { menus, getConfig, getI18n, getIcon } = VxeUI;
|
|
14
|
-
|
|
15
|
-
// $oldTree: VxeTreeConstructor & VxeTreePrivateMethods
|
|
16
|
-
// $newTree: (VxeTreeConstructor & VxeTreePrivateMethods) | null
|
|
17
|
-
// } | null = null
|
|
14
|
+
let crossTreeDragNodeObj = null;
|
|
18
15
|
/**
|
|
19
16
|
* 生成节点的唯一主键
|
|
20
17
|
*/
|
|
@@ -61,6 +58,11 @@ function handleScrollTo($xeTree, scrollLeft, scrollTop) {
|
|
|
61
58
|
}
|
|
62
59
|
return $xeTree.$nextTick();
|
|
63
60
|
}
|
|
61
|
+
function handleNodeDragEndClearStatus($xeTree) {
|
|
62
|
+
clearNodeDragData($xeTree);
|
|
63
|
+
clearCrossTreeDragStatus($xeTree);
|
|
64
|
+
$xeTree.recalculate();
|
|
65
|
+
}
|
|
64
66
|
function clearNodeDropOrigin($xeTree) {
|
|
65
67
|
const el = $xeTree.$refs.refElem;
|
|
66
68
|
if (el) {
|
|
@@ -81,7 +83,7 @@ function updateNodeDropOrigin($xeTree, node) {
|
|
|
81
83
|
});
|
|
82
84
|
}
|
|
83
85
|
}
|
|
84
|
-
function
|
|
86
|
+
function updateNodeDropTipContent($xeTree, itemEl) {
|
|
85
87
|
const reactData = $xeTree.reactData;
|
|
86
88
|
const { dragNode } = reactData;
|
|
87
89
|
const dragOpts = $xeTree.computeDragOpts;
|
|
@@ -112,7 +114,7 @@ function hideDropTip($xeTree) {
|
|
|
112
114
|
}
|
|
113
115
|
function clearCrossTreeDragStatus($xeTree) {
|
|
114
116
|
const crossTreeDragNodeInfo = getCrossTreeDragNodeInfo($xeTree);
|
|
115
|
-
|
|
117
|
+
crossTreeDragNodeObj = null;
|
|
116
118
|
crossTreeDragNodeInfo.node = null;
|
|
117
119
|
}
|
|
118
120
|
function clearDragStatus($xeTree) {
|
|
@@ -193,6 +195,7 @@ function handleNodeDragSwapEvent($xeTree, evnt, dragNode, prevDragNode, prevDrag
|
|
|
193
195
|
status: false
|
|
194
196
|
};
|
|
195
197
|
if (!(el && prevDragNode && dragNode)) {
|
|
198
|
+
handleNodeDragEndClearStatus($xeTree);
|
|
196
199
|
return Promise.resolve(errRest);
|
|
197
200
|
}
|
|
198
201
|
// 判断是否有拖动
|
|
@@ -240,15 +243,13 @@ function handleNodeDragSwapEvent($xeTree, evnt, dragNode, prevDragNode, prevDrag
|
|
|
240
243
|
if (isPeerDrag && !isCrossDrag) {
|
|
241
244
|
if (oldRest.item[parentField] !== newRest.item[parentField]) {
|
|
242
245
|
// 非同级
|
|
243
|
-
|
|
244
|
-
clearCrossTreeDragStatus($xeTree);
|
|
246
|
+
handleNodeDragEndClearStatus($xeTree);
|
|
245
247
|
return errRest;
|
|
246
248
|
}
|
|
247
249
|
}
|
|
248
250
|
else {
|
|
249
251
|
if (!isCrossDrag) {
|
|
250
|
-
|
|
251
|
-
clearCrossTreeDragStatus($xeTree);
|
|
252
|
+
handleNodeDragEndClearStatus($xeTree);
|
|
252
253
|
return errRest;
|
|
253
254
|
}
|
|
254
255
|
if (oldAllMaps[newNodeid]) {
|
|
@@ -260,8 +261,7 @@ function handleNodeDragSwapEvent($xeTree, evnt, dragNode, prevDragNode, prevDrag
|
|
|
260
261
|
content: getI18n('vxe.error.treeDragChild')
|
|
261
262
|
});
|
|
262
263
|
}
|
|
263
|
-
|
|
264
|
-
clearCrossTreeDragStatus($xeTree);
|
|
264
|
+
handleNodeDragEndClearStatus($xeTree);
|
|
265
265
|
return errRest;
|
|
266
266
|
}
|
|
267
267
|
}
|
|
@@ -270,16 +270,14 @@ function handleNodeDragSwapEvent($xeTree, evnt, dragNode, prevDragNode, prevDrag
|
|
|
270
270
|
else if (oldLevel) {
|
|
271
271
|
// 子到根
|
|
272
272
|
if (!isCrossDrag) {
|
|
273
|
-
|
|
274
|
-
clearCrossTreeDragStatus($xeTree);
|
|
273
|
+
handleNodeDragEndClearStatus($xeTree);
|
|
275
274
|
return errRest;
|
|
276
275
|
}
|
|
277
276
|
}
|
|
278
277
|
else if (newLevel) {
|
|
279
278
|
// 根到子
|
|
280
279
|
if (!isCrossDrag) {
|
|
281
|
-
|
|
282
|
-
clearCrossTreeDragStatus($xeTree);
|
|
280
|
+
handleNodeDragEndClearStatus($xeTree);
|
|
283
281
|
return errRest;
|
|
284
282
|
}
|
|
285
283
|
if (oldAllMaps[newNodeid]) {
|
|
@@ -291,8 +289,7 @@ function handleNodeDragSwapEvent($xeTree, evnt, dragNode, prevDragNode, prevDrag
|
|
|
291
289
|
content: getI18n('vxe.error.treeDragChild')
|
|
292
290
|
});
|
|
293
291
|
}
|
|
294
|
-
|
|
295
|
-
clearCrossTreeDragStatus($xeTree);
|
|
292
|
+
handleNodeDragEndClearStatus($xeTree);
|
|
296
293
|
return errRest;
|
|
297
294
|
}
|
|
298
295
|
}
|
|
@@ -442,13 +439,11 @@ function handleNodeDragSwapEvent($xeTree, evnt, dragNode, prevDragNode, prevDrag
|
|
|
442
439
|
}).catch(() => {
|
|
443
440
|
return errRest;
|
|
444
441
|
}).then((rest) => {
|
|
445
|
-
|
|
446
|
-
clearCrossTreeDragStatus($xeTree);
|
|
442
|
+
handleNodeDragEndClearStatus($xeTree);
|
|
447
443
|
return rest;
|
|
448
444
|
});
|
|
449
445
|
}
|
|
450
|
-
|
|
451
|
-
clearCrossTreeDragStatus($xeTree);
|
|
446
|
+
handleNodeDragEndClearStatus($xeTree);
|
|
452
447
|
return Promise.resolve(errRest);
|
|
453
448
|
}
|
|
454
449
|
function handleVisibleOrCheckMode(mode, isExistChild, nLevel) {
|
|
@@ -471,9 +466,9 @@ function insertTreeNode($xeTree, newRecords, isAppend) {
|
|
|
471
466
|
const mapChildrenField = $xeTree.computeMapChildrenField;
|
|
472
467
|
const funcName = isAppend ? 'push' : 'unshift';
|
|
473
468
|
newRecords.forEach((item) => {
|
|
474
|
-
const
|
|
469
|
+
const parentNodeId = item[parentField];
|
|
475
470
|
const nodeid = $xeTree.getNodeId(item);
|
|
476
|
-
const matchObj =
|
|
471
|
+
const matchObj = parentNodeId ? XEUtils.findTree(treeFullData, (item) => parentNodeId === item[keyField], { children: mapChildrenField }) : null;
|
|
477
472
|
const itemRest = getItemCacheObj(item);
|
|
478
473
|
if (matchObj) {
|
|
479
474
|
const { item: parentItem } = matchObj;
|
|
@@ -494,7 +489,7 @@ function insertTreeNode($xeTree, newRecords, isAppend) {
|
|
|
494
489
|
pMapChilds[funcName](item);
|
|
495
490
|
}
|
|
496
491
|
else {
|
|
497
|
-
if (
|
|
492
|
+
if (parentNodeId) {
|
|
498
493
|
warnLog('vxe.error.unableInsert');
|
|
499
494
|
}
|
|
500
495
|
treeFullData[funcName](item);
|
|
@@ -511,7 +506,7 @@ function createInternalData() {
|
|
|
511
506
|
afterVisibleList: [],
|
|
512
507
|
nodeMaps: {},
|
|
513
508
|
selectCheckboxMaps: {},
|
|
514
|
-
|
|
509
|
+
indeterminateNodeMaps: {},
|
|
515
510
|
treeExpandedMaps: {},
|
|
516
511
|
treeExpandLazyLoadedMaps: {},
|
|
517
512
|
lastScrollLeft: 0,
|
|
@@ -523,8 +518,8 @@ function createInternalData() {
|
|
|
523
518
|
offsetSize: 0,
|
|
524
519
|
rowHeight: 0
|
|
525
520
|
},
|
|
526
|
-
|
|
527
|
-
|
|
521
|
+
removeNodeMaps: {},
|
|
522
|
+
insertNodeMaps: {},
|
|
528
523
|
// prevDragNode: null,
|
|
529
524
|
// prevDragToChild: false,
|
|
530
525
|
// prevDragPos: ''
|
|
@@ -546,10 +541,11 @@ function createReactData() {
|
|
|
546
541
|
treeList: [],
|
|
547
542
|
updateExpandedFlag: 1,
|
|
548
543
|
updateCheckboxFlag: 1,
|
|
549
|
-
|
|
550
|
-
|
|
544
|
+
insertNodeFlag: 1,
|
|
545
|
+
removeNodeFlag: 1,
|
|
551
546
|
dragNode: null,
|
|
552
|
-
dragTipText: ''
|
|
547
|
+
dragTipText: '',
|
|
548
|
+
isCrossDragNode: false
|
|
553
549
|
};
|
|
554
550
|
}
|
|
555
551
|
export default {
|
|
@@ -729,7 +725,7 @@ export default {
|
|
|
729
725
|
const props = $xeTree;
|
|
730
726
|
return Object.assign({}, getConfig().tree.virtualYConfig, props.virtualYConfig);
|
|
731
727
|
},
|
|
732
|
-
|
|
728
|
+
computeIsNodeCurrent() {
|
|
733
729
|
const $xeTree = this;
|
|
734
730
|
const props = $xeTree;
|
|
735
731
|
const nodeOpts = $xeTree.computeNodeOpts;
|
|
@@ -739,7 +735,7 @@ export default {
|
|
|
739
735
|
}
|
|
740
736
|
return props.isCurrent;
|
|
741
737
|
},
|
|
742
|
-
|
|
738
|
+
computeIsNodeHover() {
|
|
743
739
|
const $xeTree = this;
|
|
744
740
|
const props = $xeTree;
|
|
745
741
|
const nodeOpts = $xeTree.computeNodeOpts;
|
|
@@ -881,8 +877,8 @@ export default {
|
|
|
881
877
|
const reactData = $xeTree.reactData;
|
|
882
878
|
const internalData = $xeTree.internalData;
|
|
883
879
|
const { updateCheckboxFlag } = reactData;
|
|
884
|
-
const {
|
|
885
|
-
return !!(updateCheckboxFlag &&
|
|
880
|
+
const { indeterminateNodeMaps } = internalData;
|
|
881
|
+
return !!(updateCheckboxFlag && indeterminateNodeMaps[nodeid]);
|
|
886
882
|
},
|
|
887
883
|
isIndeterminateByCheckboxNode(node) {
|
|
888
884
|
const $xeTree = this;
|
|
@@ -1224,10 +1220,10 @@ export default {
|
|
|
1224
1220
|
const expandMaps = {};
|
|
1225
1221
|
if (transform) {
|
|
1226
1222
|
const fullData = [];
|
|
1227
|
-
XEUtils.eachTree(afterTreeList, (item, index, items, path,
|
|
1223
|
+
XEUtils.eachTree(afterTreeList, (item, index, items, path, parentNode) => {
|
|
1228
1224
|
const nodeid = $xeTree.getNodeId(item);
|
|
1229
|
-
const parentNodeid = $xeTree.getNodeId(
|
|
1230
|
-
if (!
|
|
1225
|
+
const parentNodeid = $xeTree.getNodeId(parentNode);
|
|
1226
|
+
if (!parentNode || (expandMaps[parentNodeid] && treeExpandedMaps[parentNodeid])) {
|
|
1231
1227
|
expandMaps[nodeid] = 1;
|
|
1232
1228
|
fullData.push(item);
|
|
1233
1229
|
}
|
|
@@ -1268,6 +1264,7 @@ export default {
|
|
|
1268
1264
|
loadData(list) {
|
|
1269
1265
|
const $xeTree = this;
|
|
1270
1266
|
const props = $xeTree;
|
|
1267
|
+
const reactData = $xeTree.reactData;
|
|
1271
1268
|
const internalData = $xeTree.internalData;
|
|
1272
1269
|
const { expandAll, expandNodeKeys, transform, rootParentValue, rootValues } = props;
|
|
1273
1270
|
const { initialized, scrollYStore } = internalData;
|
|
@@ -1284,6 +1281,10 @@ export default {
|
|
|
1284
1281
|
})
|
|
1285
1282
|
: list ? list.slice(0) : [];
|
|
1286
1283
|
internalData.treeFullData = fullData;
|
|
1284
|
+
internalData.insertNodeMaps = {};
|
|
1285
|
+
reactData.insertNodeFlag++;
|
|
1286
|
+
internalData.removeNodeMaps = {};
|
|
1287
|
+
reactData.removeNodeFlag++;
|
|
1287
1288
|
Object.assign(scrollYStore, {
|
|
1288
1289
|
startIndex: 0,
|
|
1289
1290
|
endIndex: 1,
|
|
@@ -1524,7 +1525,7 @@ export default {
|
|
|
1524
1525
|
const reactData = $xeTree.reactData;
|
|
1525
1526
|
const internalData = $xeTree.internalData;
|
|
1526
1527
|
const { transform } = props;
|
|
1527
|
-
const { treeFullData, nodeMaps } = internalData;
|
|
1528
|
+
const { treeFullData, nodeMaps, removeNodeMaps, insertNodeMaps } = internalData;
|
|
1528
1529
|
const keyField = $xeTree.computeKeyField;
|
|
1529
1530
|
const parentField = $xeTree.computeParentField;
|
|
1530
1531
|
const childrenField = $xeTree.computeChildrenField;
|
|
@@ -1562,26 +1563,26 @@ export default {
|
|
|
1562
1563
|
const parentMapChilds = parentNode ? parentNode[mapChildrenField] : treeFullData;
|
|
1563
1564
|
const parentRest = nodeMaps[$xeTree.getNodeId(parentNode)];
|
|
1564
1565
|
const parentLevel = parentRest ? parentRest.level : 0;
|
|
1565
|
-
treeRecords.forEach((
|
|
1566
|
+
treeRecords.forEach((item, i) => {
|
|
1566
1567
|
if (parentNode) {
|
|
1567
|
-
if (
|
|
1568
|
-
errLog('vxe.error.errProp', [`${parentField}=${
|
|
1569
|
-
|
|
1568
|
+
if (item[parentField] !== parentNode[keyField]) {
|
|
1569
|
+
errLog('vxe.error.errProp', [`${parentField}=${item[parentField]}`, `${parentField}=${parentNode[keyField]}`]);
|
|
1570
|
+
item[parentField] = parentNode[keyField];
|
|
1570
1571
|
}
|
|
1571
1572
|
}
|
|
1572
1573
|
else {
|
|
1573
|
-
if (
|
|
1574
|
-
if (!XEUtils.eqNull(
|
|
1575
|
-
errLog('vxe.error.errProp', [`${parentField}=${
|
|
1574
|
+
if (item[parentField] !== null) {
|
|
1575
|
+
if (!XEUtils.eqNull(item[parentField])) {
|
|
1576
|
+
errLog('vxe.error.errProp', [`${parentField}=${item[parentField]}`, 'null']);
|
|
1576
1577
|
}
|
|
1577
|
-
|
|
1578
|
+
item[parentField] = null;
|
|
1578
1579
|
}
|
|
1579
1580
|
}
|
|
1580
1581
|
let targetIndex = matchMapObj.index + i;
|
|
1581
1582
|
if (isInsertNextNode) {
|
|
1582
1583
|
targetIndex = targetIndex + 1;
|
|
1583
1584
|
}
|
|
1584
|
-
parentMapChilds.splice(targetIndex, 0,
|
|
1585
|
+
parentMapChilds.splice(targetIndex, 0, item);
|
|
1585
1586
|
});
|
|
1586
1587
|
XEUtils.eachTree(treeRecords, (item) => {
|
|
1587
1588
|
const nodeid = $xeTree.getNodeId(item);
|
|
@@ -1611,7 +1612,22 @@ export default {
|
|
|
1611
1612
|
}
|
|
1612
1613
|
}
|
|
1613
1614
|
}
|
|
1614
|
-
|
|
1615
|
+
const handleStatus = (newItem) => {
|
|
1616
|
+
const nodeid = $xeTree.getNodeId(newItem);
|
|
1617
|
+
// 如果是被删除的数据,则还原状态
|
|
1618
|
+
if (removeNodeMaps[nodeid]) {
|
|
1619
|
+
delete removeNodeMaps[nodeid];
|
|
1620
|
+
if (insertNodeMaps[nodeid]) {
|
|
1621
|
+
delete insertNodeMaps[nodeid];
|
|
1622
|
+
}
|
|
1623
|
+
}
|
|
1624
|
+
else {
|
|
1625
|
+
insertNodeMaps[nodeid] = newItem;
|
|
1626
|
+
}
|
|
1627
|
+
};
|
|
1628
|
+
XEUtils.eachTree(treeRecords, handleStatus, { children: mapChildrenField });
|
|
1629
|
+
reactData.removeNodeFlag++;
|
|
1630
|
+
reactData.insertNodeFlag++;
|
|
1615
1631
|
$xeTree.cacheNodeMap();
|
|
1616
1632
|
$xeTree.handleData(true);
|
|
1617
1633
|
$xeTree.updateAfterDataIndex();
|
|
@@ -1638,13 +1654,66 @@ export default {
|
|
|
1638
1654
|
const $xeTree = this;
|
|
1639
1655
|
return $xeTree.handleInsertNodeAt(records, targetNodeOrNodeid, true);
|
|
1640
1656
|
},
|
|
1657
|
+
handleInsertChildNodeAt(records, parentNodeOrParentId, targetNodeOrNodeid, isInsertNextNode) {
|
|
1658
|
+
const $xeTree = this;
|
|
1659
|
+
const props = $xeTree;
|
|
1660
|
+
const internalData = $xeTree.internalData;
|
|
1661
|
+
const { transform } = props;
|
|
1662
|
+
const { nodeMaps } = internalData;
|
|
1663
|
+
const keyField = $xeTree.computeKeyField;
|
|
1664
|
+
const parentField = $xeTree.computeParentField;
|
|
1665
|
+
if (!transform) {
|
|
1666
|
+
errLog('vxe.error.reqSupportProp', ['insertChild() | insertChildAt() | insertChildNextAt()', 'transform']);
|
|
1667
|
+
return Promise.resolve({ node: null, nodes: [] });
|
|
1668
|
+
}
|
|
1669
|
+
if (!XEUtils.isArray(records)) {
|
|
1670
|
+
records = [records];
|
|
1671
|
+
}
|
|
1672
|
+
let parentNode = parentNodeOrParentId;
|
|
1673
|
+
if (XEUtils.isString(parentNodeOrParentId) || XEUtils.isNumber(parentNodeOrParentId)) {
|
|
1674
|
+
const nodeRest = nodeMaps[parentNodeOrParentId];
|
|
1675
|
+
if (nodeRest) {
|
|
1676
|
+
parentNode = nodeRest.item;
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1679
|
+
return $xeTree.handleInsertNodeAt(records.map((item) => Object.assign({}, item, { [parentField]: parentNode[keyField] })), targetNodeOrNodeid, isInsertNextNode);
|
|
1680
|
+
},
|
|
1681
|
+
insertChild(records, parentNodeOrParentId) {
|
|
1682
|
+
const $xeTree = this;
|
|
1683
|
+
return $xeTree.handleInsertChildNodeAt(records, parentNodeOrParentId, null);
|
|
1684
|
+
},
|
|
1685
|
+
insertChildAt(records, parentNodeOrParentId, targetNode) {
|
|
1686
|
+
const $xeTree = this;
|
|
1687
|
+
return $xeTree.handleInsertChildNodeAt(records, parentNodeOrParentId, targetNode);
|
|
1688
|
+
},
|
|
1689
|
+
insertChildNextAt(records, parentNodeOrParentId, targetNode) {
|
|
1690
|
+
const $xeTree = this;
|
|
1691
|
+
return $xeTree.handleInsertChildNodeAt(records, parentNodeOrParentId, targetNode, true);
|
|
1692
|
+
},
|
|
1693
|
+
getInsertRecords() {
|
|
1694
|
+
const $xeTree = this;
|
|
1695
|
+
const internalData = $xeTree.internalData;
|
|
1696
|
+
const { insertNodeMaps } = internalData;
|
|
1697
|
+
const insertRecords = [];
|
|
1698
|
+
XEUtils.each(insertNodeMaps, (item) => {
|
|
1699
|
+
insertRecords.push(item);
|
|
1700
|
+
});
|
|
1701
|
+
return insertRecords;
|
|
1702
|
+
},
|
|
1703
|
+
isInsertByNode(node) {
|
|
1704
|
+
const $xeTree = this;
|
|
1705
|
+
const reactData = $xeTree.reactData;
|
|
1706
|
+
const internalData = $xeTree.internalData;
|
|
1707
|
+
const nodeid = $xeTree.getNodeId(node);
|
|
1708
|
+
return !!reactData.insertNodeFlag && !!internalData.insertNodeMaps[nodeid];
|
|
1709
|
+
},
|
|
1641
1710
|
remove(nodes) {
|
|
1642
1711
|
const $xeTree = this;
|
|
1643
1712
|
const props = $xeTree;
|
|
1644
1713
|
const reactData = $xeTree.reactData;
|
|
1645
1714
|
const internalData = $xeTree.internalData;
|
|
1646
1715
|
const { transform } = props;
|
|
1647
|
-
const { treeFullData } = internalData;
|
|
1716
|
+
const { treeFullData, insertNodeMaps, removeNodeMaps } = internalData;
|
|
1648
1717
|
const childrenField = $xeTree.computeChildrenField;
|
|
1649
1718
|
const mapChildrenField = $xeTree.computeMapChildrenField;
|
|
1650
1719
|
if (!transform) {
|
|
@@ -1661,6 +1730,13 @@ export default {
|
|
|
1661
1730
|
if (!nodes.length) {
|
|
1662
1731
|
return Promise.resolve({ node: null, nodes: [] });
|
|
1663
1732
|
}
|
|
1733
|
+
// 如果是新增,则保存记录
|
|
1734
|
+
nodes.forEach((item) => {
|
|
1735
|
+
if (!$xeTree.isInsertByNode(item)) {
|
|
1736
|
+
const nodeid = $xeTree.getNodeId(item);
|
|
1737
|
+
removeNodeMaps[nodeid] = item;
|
|
1738
|
+
}
|
|
1739
|
+
});
|
|
1664
1740
|
// 从数据源中移除
|
|
1665
1741
|
if (treeFullData === nodes) {
|
|
1666
1742
|
nodes = delList = treeFullData.slice(0);
|
|
@@ -1681,8 +1757,15 @@ export default {
|
|
|
1681
1757
|
}
|
|
1682
1758
|
});
|
|
1683
1759
|
}
|
|
1684
|
-
|
|
1685
|
-
|
|
1760
|
+
// 从新增中移除已删除的数据
|
|
1761
|
+
nodes.forEach((item) => {
|
|
1762
|
+
const nodeid = $xeTree.getNodeId(item);
|
|
1763
|
+
if (insertNodeMaps[nodeid]) {
|
|
1764
|
+
delete insertNodeMaps[nodeid];
|
|
1765
|
+
}
|
|
1766
|
+
});
|
|
1767
|
+
reactData.removeNodeFlag++;
|
|
1768
|
+
reactData.insertNodeFlag++;
|
|
1686
1769
|
$xeTree.cacheNodeMap();
|
|
1687
1770
|
$xeTree.handleData(true);
|
|
1688
1771
|
$xeTree.updateAfterDataIndex();
|
|
@@ -1696,26 +1779,23 @@ export default {
|
|
|
1696
1779
|
return { node: delList.length ? delList[delList.length - 1] : null, nodes: delList };
|
|
1697
1780
|
});
|
|
1698
1781
|
},
|
|
1699
|
-
getInsertRecords() {
|
|
1700
|
-
const $xeTree = this;
|
|
1701
|
-
const internalData = $xeTree.internalData;
|
|
1702
|
-
const { insertRowMaps } = internalData;
|
|
1703
|
-
const insertRecords = [];
|
|
1704
|
-
XEUtils.each(insertRowMaps, (row) => {
|
|
1705
|
-
insertRecords.push(row);
|
|
1706
|
-
});
|
|
1707
|
-
return insertRecords;
|
|
1708
|
-
},
|
|
1709
1782
|
getRemoveRecords() {
|
|
1710
1783
|
const $xeTree = this;
|
|
1711
1784
|
const internalData = $xeTree.internalData;
|
|
1712
|
-
const {
|
|
1785
|
+
const { removeNodeMaps } = internalData;
|
|
1713
1786
|
const removeRecords = [];
|
|
1714
|
-
XEUtils.each(
|
|
1715
|
-
removeRecords.push(
|
|
1787
|
+
XEUtils.each(removeNodeMaps, (item) => {
|
|
1788
|
+
removeRecords.push(item);
|
|
1716
1789
|
});
|
|
1717
1790
|
return removeRecords;
|
|
1718
1791
|
},
|
|
1792
|
+
isRemoveByNode(node) {
|
|
1793
|
+
const $xeTree = this;
|
|
1794
|
+
const reactData = $xeTree.reactData;
|
|
1795
|
+
const internalData = $xeTree.internalData;
|
|
1796
|
+
const nodeid = $xeTree.getNodeId(node);
|
|
1797
|
+
return !!reactData.removeNodeFlag && !!internalData.removeNodeMaps[nodeid];
|
|
1798
|
+
},
|
|
1719
1799
|
handleNodeMousedownEvent(evnt, node) {
|
|
1720
1800
|
const $xeTree = this;
|
|
1721
1801
|
const props = $xeTree;
|
|
@@ -1746,12 +1826,12 @@ export default {
|
|
|
1746
1826
|
const { showRadio, showCheckbox, trigger } = props;
|
|
1747
1827
|
const radioOpts = $xeTree.computeRadioOpts;
|
|
1748
1828
|
const checkboxOpts = $xeTree.computeCheckboxOpts;
|
|
1749
|
-
const
|
|
1829
|
+
const isNodeCurrent = $xeTree.computeIsNodeCurrent;
|
|
1750
1830
|
let triggerCurrent = false;
|
|
1751
1831
|
let triggerRadio = false;
|
|
1752
1832
|
let triggerCheckbox = false;
|
|
1753
1833
|
let triggerExpand = false;
|
|
1754
|
-
if (
|
|
1834
|
+
if (isNodeCurrent) {
|
|
1755
1835
|
triggerCurrent = true;
|
|
1756
1836
|
$xeTree.changeCurrentEvent(evnt, node);
|
|
1757
1837
|
}
|
|
@@ -1781,12 +1861,12 @@ export default {
|
|
|
1781
1861
|
const props = $xeTree;
|
|
1782
1862
|
const reactData = $xeTree.reactData;
|
|
1783
1863
|
const { menuConfig } = props;
|
|
1784
|
-
const
|
|
1864
|
+
const isNodeCurrent = $xeTree.computeIsNodeCurrent;
|
|
1785
1865
|
const menuOpts = $xeTree.computeMenuOpts;
|
|
1786
1866
|
if (menuConfig ? isEnableConf(menuOpts) : menuOpts.enabled) {
|
|
1787
1867
|
const { options, visibleMethod } = menuOpts;
|
|
1788
1868
|
if (!visibleMethod || visibleMethod({ $tree: $xeTree, options, node })) {
|
|
1789
|
-
if (
|
|
1869
|
+
if (isNodeCurrent) {
|
|
1790
1870
|
$xeTree.changeCurrentEvent(evnt, node);
|
|
1791
1871
|
}
|
|
1792
1872
|
else if (reactData.currentNode) {
|
|
@@ -1846,15 +1926,15 @@ export default {
|
|
|
1846
1926
|
childRecords = [];
|
|
1847
1927
|
}
|
|
1848
1928
|
if (childRecords) {
|
|
1849
|
-
return $xeTree.loadChildrenNode(node, childRecords).then(
|
|
1929
|
+
return $xeTree.loadChildrenNode(node, childRecords).then(childNodes => {
|
|
1850
1930
|
const { treeExpandedMaps } = internalData;
|
|
1851
|
-
if (
|
|
1931
|
+
if (childNodes.length && !treeExpandedMaps[nodeid]) {
|
|
1852
1932
|
treeExpandedMaps[nodeid] = true;
|
|
1853
1933
|
}
|
|
1854
1934
|
reactData.updateExpandedFlag++;
|
|
1855
1935
|
// 如果当前节点已选中,则展开后子节点也被选中
|
|
1856
1936
|
if (!checkStrictly && $xeTree.isCheckedByCheckboxNodeId(nodeid)) {
|
|
1857
|
-
$xeTree.handleCheckedCheckboxNode(
|
|
1937
|
+
$xeTree.handleCheckedCheckboxNode(childNodes, true);
|
|
1858
1938
|
}
|
|
1859
1939
|
$xeTree.dispatchEvent('load-success', { node, data: childRecords }, new Event('load-success'));
|
|
1860
1940
|
return $xeTree.$nextTick();
|
|
@@ -1967,23 +2047,23 @@ export default {
|
|
|
1967
2047
|
const reactData = $xeTree.reactData;
|
|
1968
2048
|
const internalData = $xeTree.internalData;
|
|
1969
2049
|
const { transform } = props;
|
|
1970
|
-
const { selectCheckboxMaps,
|
|
2050
|
+
const { selectCheckboxMaps, indeterminateNodeMaps, afterTreeList } = internalData;
|
|
1971
2051
|
const childrenField = $xeTree.computeChildrenField;
|
|
1972
2052
|
const mapChildrenField = $xeTree.computeMapChildrenField;
|
|
1973
2053
|
const checkboxOpts = $xeTree.computeCheckboxOpts;
|
|
1974
2054
|
const { checkStrictly, checkMethod } = checkboxOpts;
|
|
1975
2055
|
if (!checkStrictly) {
|
|
1976
|
-
const
|
|
1977
|
-
const
|
|
2056
|
+
const childNodeMaps = {};
|
|
2057
|
+
const childNodeList = [];
|
|
1978
2058
|
XEUtils.eachTree(afterTreeList, (node) => {
|
|
1979
2059
|
const nodeid = $xeTree.getNodeId(node);
|
|
1980
2060
|
const childList = node[childrenField];
|
|
1981
|
-
if (childList && childList.length && !
|
|
1982
|
-
|
|
1983
|
-
|
|
2061
|
+
if (childList && childList.length && !childNodeMaps[nodeid]) {
|
|
2062
|
+
childNodeMaps[nodeid] = 1;
|
|
2063
|
+
childNodeList.unshift([node, nodeid, childList]);
|
|
1984
2064
|
}
|
|
1985
2065
|
}, { children: transform ? mapChildrenField : childrenField });
|
|
1986
|
-
|
|
2066
|
+
childNodeList.forEach(vals => {
|
|
1987
2067
|
const node = vals[0];
|
|
1988
2068
|
const nodeid = vals[1];
|
|
1989
2069
|
const childList = vals[2];
|
|
@@ -1999,7 +2079,7 @@ export default {
|
|
|
1999
2079
|
if (isSelect) {
|
|
2000
2080
|
sLen++;
|
|
2001
2081
|
}
|
|
2002
|
-
else if (
|
|
2082
|
+
else if (indeterminateNodeMaps[childNodeid]) {
|
|
2003
2083
|
hLen++;
|
|
2004
2084
|
}
|
|
2005
2085
|
vLen++;
|
|
@@ -2008,7 +2088,7 @@ export default {
|
|
|
2008
2088
|
if (isSelect) {
|
|
2009
2089
|
sLen++;
|
|
2010
2090
|
}
|
|
2011
|
-
else if (
|
|
2091
|
+
else if (indeterminateNodeMaps[childNodeid]) {
|
|
2012
2092
|
hLen++;
|
|
2013
2093
|
}
|
|
2014
2094
|
}
|
|
@@ -2019,7 +2099,7 @@ export default {
|
|
|
2019
2099
|
if (isSelect) {
|
|
2020
2100
|
sLen++;
|
|
2021
2101
|
}
|
|
2022
|
-
else if (
|
|
2102
|
+
else if (indeterminateNodeMaps[childNodeid]) {
|
|
2023
2103
|
hLen++;
|
|
2024
2104
|
}
|
|
2025
2105
|
vLen++;
|
|
@@ -2049,8 +2129,8 @@ export default {
|
|
|
2049
2129
|
const halfSelect = !isSelected && (sLen > 0 || hLen > 0);
|
|
2050
2130
|
if (isSelected) {
|
|
2051
2131
|
selectCheckboxMaps[nodeid] = node;
|
|
2052
|
-
if (
|
|
2053
|
-
delete
|
|
2132
|
+
if (indeterminateNodeMaps[nodeid]) {
|
|
2133
|
+
delete indeterminateNodeMaps[nodeid];
|
|
2054
2134
|
}
|
|
2055
2135
|
}
|
|
2056
2136
|
else {
|
|
@@ -2058,11 +2138,11 @@ export default {
|
|
|
2058
2138
|
delete selectCheckboxMaps[nodeid];
|
|
2059
2139
|
}
|
|
2060
2140
|
if (halfSelect) {
|
|
2061
|
-
|
|
2141
|
+
indeterminateNodeMaps[nodeid] = node;
|
|
2062
2142
|
}
|
|
2063
2143
|
else {
|
|
2064
|
-
if (
|
|
2065
|
-
delete
|
|
2144
|
+
if (indeterminateNodeMaps[nodeid]) {
|
|
2145
|
+
delete indeterminateNodeMaps[nodeid];
|
|
2066
2146
|
}
|
|
2067
2147
|
}
|
|
2068
2148
|
}
|
|
@@ -2293,7 +2373,7 @@ export default {
|
|
|
2293
2373
|
const $xeTree = this;
|
|
2294
2374
|
const reactData = $xeTree.reactData;
|
|
2295
2375
|
const internalData = $xeTree.internalData;
|
|
2296
|
-
internalData.
|
|
2376
|
+
internalData.indeterminateNodeMaps = {};
|
|
2297
2377
|
internalData.selectCheckboxMaps = {};
|
|
2298
2378
|
reactData.updateCheckboxFlag++;
|
|
2299
2379
|
$xeTree.updateCheckboxStatus();
|
|
@@ -2321,7 +2401,7 @@ export default {
|
|
|
2321
2401
|
selectMaps[nodeid] = true;
|
|
2322
2402
|
}, { children: transform ? mapChildrenField : childrenField });
|
|
2323
2403
|
}
|
|
2324
|
-
internalData.
|
|
2404
|
+
internalData.indeterminateNodeMaps = {};
|
|
2325
2405
|
internalData.selectCheckboxMaps = selectMaps;
|
|
2326
2406
|
reactData.updateCheckboxFlag++;
|
|
2327
2407
|
$xeTree.updateCheckboxStatus();
|
|
@@ -2533,10 +2613,10 @@ export default {
|
|
|
2533
2613
|
const parentLevel = parentNodeItem ? parentNodeItem.level : 0;
|
|
2534
2614
|
const parentNodes = parentNodeItem ? parentNodeItem.nodes : [];
|
|
2535
2615
|
return $xeTree.createNode(childRecords).then((nodeList) => {
|
|
2536
|
-
XEUtils.eachTree(nodeList, (
|
|
2537
|
-
const itemNodeId = $xeTree.getNodeId(
|
|
2616
|
+
XEUtils.eachTree(nodeList, (childNode, index, items, path, parent, nodes) => {
|
|
2617
|
+
const itemNodeId = $xeTree.getNodeId(childNode);
|
|
2538
2618
|
nodeMaps[itemNodeId] = {
|
|
2539
|
-
item:
|
|
2619
|
+
item: childNode,
|
|
2540
2620
|
index: -1,
|
|
2541
2621
|
$index: -1,
|
|
2542
2622
|
_index: -1,
|
|
@@ -2579,17 +2659,207 @@ export default {
|
|
|
2579
2659
|
/**
|
|
2580
2660
|
* 处理跨树拖拽完成
|
|
2581
2661
|
*/
|
|
2582
|
-
handleCrossTreeNodeDragFinishEvent() {
|
|
2662
|
+
handleCrossTreeNodeDragFinishEvent(evnt) {
|
|
2663
|
+
const $xeTree = this;
|
|
2664
|
+
const reactData = $xeTree.reactData;
|
|
2665
|
+
const internalData = $xeTree.internalData;
|
|
2666
|
+
const crossTreeDragNodeInfo = getCrossTreeDragNodeInfo($xeTree);
|
|
2667
|
+
const { treeList } = reactData;
|
|
2668
|
+
const { nodeMaps } = internalData;
|
|
2669
|
+
const dragOpts = $xeTree.computeDragOpts;
|
|
2670
|
+
const { animation, isCrossTreeDrag } = dragOpts;
|
|
2671
|
+
const mapChildrenField = $xeTree.computeMapChildrenField;
|
|
2672
|
+
const el = $xeTree.$refs.refElem;
|
|
2673
|
+
if (!el) {
|
|
2674
|
+
return;
|
|
2675
|
+
}
|
|
2676
|
+
if (isCrossTreeDrag && crossTreeDragNodeObj && crossTreeDragNodeInfo) {
|
|
2677
|
+
const { node: dragNode } = crossTreeDragNodeInfo;
|
|
2678
|
+
if (dragNode) {
|
|
2679
|
+
const dragNodeid = $xeTree.getNodeId(dragNode);
|
|
2680
|
+
const dragNodeRest = nodeMaps[dragNodeid];
|
|
2681
|
+
let dragNodeHeight = 0;
|
|
2682
|
+
let rsIndex = -1;
|
|
2683
|
+
if (dragNodeRest) {
|
|
2684
|
+
if (animation) {
|
|
2685
|
+
const oldItemEl = el.querySelector(`.vxe-tree--node-wrapper[nodeid="${dragNodeid}"]`);
|
|
2686
|
+
const targetItemEl = oldItemEl;
|
|
2687
|
+
if (targetItemEl) {
|
|
2688
|
+
dragNodeHeight = targetItemEl.offsetHeight;
|
|
2689
|
+
}
|
|
2690
|
+
}
|
|
2691
|
+
rsIndex = dragNodeRest.$index;
|
|
2692
|
+
}
|
|
2693
|
+
const dragRangeList = rsIndex > -1 && rsIndex < treeList.length - 1 ? treeList.slice(rsIndex + 1) : [];
|
|
2694
|
+
const dragList = XEUtils.toTreeArray([dragNode], {
|
|
2695
|
+
updated: true,
|
|
2696
|
+
children: mapChildrenField
|
|
2697
|
+
});
|
|
2698
|
+
$xeTree.remove(dragList).then(() => {
|
|
2699
|
+
if (animation && dragNodeHeight && dragRangeList.length) {
|
|
2700
|
+
const wrapperEl = el;
|
|
2701
|
+
const dtClss = [];
|
|
2702
|
+
dragRangeList.forEach(item => {
|
|
2703
|
+
const nodeid = $xeTree.getNodeId(item);
|
|
2704
|
+
dtClss.push(`.vxe-tree--node-wrapper[nodeid="${nodeid}"]`);
|
|
2705
|
+
});
|
|
2706
|
+
const dtTrList = wrapperEl.querySelectorAll(dtClss.join(','));
|
|
2707
|
+
moveRowAnimateToTb(dtTrList, dragNodeHeight);
|
|
2708
|
+
}
|
|
2709
|
+
});
|
|
2710
|
+
$xeTree.dispatchEvent('node-remove-dragend', {
|
|
2711
|
+
node: dragNode
|
|
2712
|
+
}, evnt);
|
|
2713
|
+
handleNodeDragEndClearStatus($xeTree);
|
|
2714
|
+
}
|
|
2715
|
+
}
|
|
2583
2716
|
},
|
|
2584
2717
|
/**
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2718
|
+
* 处理跨树拖至新的空树
|
|
2719
|
+
*/
|
|
2720
|
+
handleCrossTreeNodeDragoverEmptyEvent(evnt) {
|
|
2721
|
+
const $xeTree = this;
|
|
2722
|
+
const reactData = $xeTree.reactData;
|
|
2723
|
+
const internalData = $xeTree.internalData;
|
|
2724
|
+
const { treeList } = reactData;
|
|
2725
|
+
const dragOpts = $xeTree.computeDragOpts;
|
|
2726
|
+
const { isCrossTreeDrag } = dragOpts;
|
|
2727
|
+
if (isCrossTreeDrag && crossTreeDragNodeObj && !treeList.length) {
|
|
2728
|
+
const { $oldTree, $newTree } = crossTreeDragNodeObj;
|
|
2729
|
+
if ($oldTree) {
|
|
2730
|
+
const oldTreeReactData = $oldTree;
|
|
2731
|
+
if ($oldTree.xID !== $xeTree.xID) {
|
|
2732
|
+
if ($newTree && $newTree.xID !== $xeTree.xID) {
|
|
2733
|
+
$newTree.hideCrossTreeNodeDropClearStatus();
|
|
2734
|
+
}
|
|
2735
|
+
evnt.preventDefault();
|
|
2736
|
+
$oldTree.hideCrossTreeNodeDropClearStatus();
|
|
2737
|
+
crossTreeDragNodeObj.$newTree = $xeTree;
|
|
2738
|
+
internalData.prevDragNode = null;
|
|
2739
|
+
reactData.dragTipText = oldTreeReactData.dragTipText;
|
|
2740
|
+
showDropTip($xeTree, evnt, evnt.currentTarget, true, '');
|
|
2741
|
+
}
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2588
2744
|
},
|
|
2589
2745
|
/**
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2746
|
+
* 处理跨树拖插入
|
|
2747
|
+
*/
|
|
2748
|
+
handleCrossTreeNodeDragInsertEvent(evnt) {
|
|
2749
|
+
const $xeTree = this;
|
|
2750
|
+
const reactData = $xeTree.reactData;
|
|
2751
|
+
const internalData = $xeTree.internalData;
|
|
2752
|
+
const crossTreeDragNodeInfo = getCrossTreeDragNodeInfo($xeTree);
|
|
2753
|
+
const { prevDragNode, prevDragPos, prevDragToChild } = internalData;
|
|
2754
|
+
const dragOpts = $xeTree.computeDragOpts;
|
|
2755
|
+
const { animation, isSelfToChildDrag, isCrossTreeDrag, dragEndMethod, dragToChildMethod } = dragOpts;
|
|
2756
|
+
const parentField = $xeTree.computeParentField;
|
|
2757
|
+
const mapChildrenField = $xeTree.computeMapChildrenField;
|
|
2758
|
+
const childrenField = $xeTree.computeChildrenField;
|
|
2759
|
+
// 跨表拖拽
|
|
2760
|
+
if (isCrossTreeDrag && crossTreeDragNodeObj && crossTreeDragNodeInfo) {
|
|
2761
|
+
const { node: oldNode } = crossTreeDragNodeInfo;
|
|
2762
|
+
const { $oldTree } = crossTreeDragNodeObj;
|
|
2763
|
+
const el = $xeTree.$refs.refElem;
|
|
2764
|
+
if (!el) {
|
|
2765
|
+
return;
|
|
2766
|
+
}
|
|
2767
|
+
if ($oldTree && oldNode) {
|
|
2768
|
+
const dragNode = oldNode;
|
|
2769
|
+
let dragOffsetIndex = -1;
|
|
2770
|
+
if (prevDragNode) {
|
|
2771
|
+
dragOffsetIndex = prevDragPos === 'bottom' ? 1 : 0;
|
|
2772
|
+
}
|
|
2773
|
+
const dragParams = {
|
|
2774
|
+
oldNode: dragNode,
|
|
2775
|
+
newNode: prevDragNode,
|
|
2776
|
+
dragNode,
|
|
2777
|
+
dragPos: prevDragPos,
|
|
2778
|
+
dragToChild: !!prevDragToChild,
|
|
2779
|
+
offsetIndex: dragOffsetIndex
|
|
2780
|
+
};
|
|
2781
|
+
const isDragToChildFlag = isSelfToChildDrag && dragToChildMethod ? dragToChildMethod(dragParams) : prevDragToChild;
|
|
2782
|
+
const errRest = {
|
|
2783
|
+
status: false
|
|
2784
|
+
};
|
|
2785
|
+
Promise.resolve(dragEndMethod ? dragEndMethod(dragParams) : true).then((status) => {
|
|
2786
|
+
if (!status) {
|
|
2787
|
+
if ($oldTree) {
|
|
2788
|
+
if ($oldTree.xID !== $xeTree.xID) {
|
|
2789
|
+
$oldTree.handleCrossTreeNodeDragCancelEvent(evnt);
|
|
2790
|
+
}
|
|
2791
|
+
}
|
|
2792
|
+
handleNodeDragEndClearStatus($xeTree);
|
|
2793
|
+
return errRest;
|
|
2794
|
+
}
|
|
2795
|
+
let insertRest = Promise.resolve();
|
|
2796
|
+
const dragList = XEUtils.toTreeArray([dragNode], {
|
|
2797
|
+
updated: true,
|
|
2798
|
+
children: mapChildrenField
|
|
2799
|
+
});
|
|
2800
|
+
$oldTree.handleCrossTreeNodeDragFinishEvent(evnt);
|
|
2801
|
+
if (prevDragNode) {
|
|
2802
|
+
dragNode[parentField] = prevDragNode[parentField];
|
|
2803
|
+
}
|
|
2804
|
+
else {
|
|
2805
|
+
dragNode[parentField] = null;
|
|
2806
|
+
}
|
|
2807
|
+
dragList.forEach(item => {
|
|
2808
|
+
item[childrenField] = undefined;
|
|
2809
|
+
item[mapChildrenField] = undefined;
|
|
2810
|
+
});
|
|
2811
|
+
if (prevDragNode) {
|
|
2812
|
+
if (prevDragPos === 'bottom') {
|
|
2813
|
+
insertRest = $xeTree.insertNextAt(dragList, prevDragNode);
|
|
2814
|
+
}
|
|
2815
|
+
else {
|
|
2816
|
+
insertRest = $xeTree.insertAt(dragList, prevDragNode);
|
|
2817
|
+
}
|
|
2818
|
+
}
|
|
2819
|
+
else {
|
|
2820
|
+
insertRest = $xeTree.insert(dragList);
|
|
2821
|
+
}
|
|
2822
|
+
$xeTree.dispatchEvent('node-insert-dragend', {
|
|
2823
|
+
oldNode,
|
|
2824
|
+
newNode: prevDragNode,
|
|
2825
|
+
dragNode,
|
|
2826
|
+
dragPos: prevDragPos,
|
|
2827
|
+
dragToChild: isDragToChildFlag,
|
|
2828
|
+
offsetIndex: dragOffsetIndex
|
|
2829
|
+
}, evnt);
|
|
2830
|
+
clearNodeDragData($xeTree);
|
|
2831
|
+
insertRest.then(() => {
|
|
2832
|
+
const { treeList } = reactData;
|
|
2833
|
+
const { nodeMaps } = internalData;
|
|
2834
|
+
const oldNodeid = $xeTree.getNodeId(dragNode);
|
|
2835
|
+
const oldNodeRest = nodeMaps[oldNodeid];
|
|
2836
|
+
let dragNodeHeight = 0;
|
|
2837
|
+
let rsIndex = -1;
|
|
2838
|
+
if (oldNodeRest) {
|
|
2839
|
+
if (animation) {
|
|
2840
|
+
const oldItemEl = el.querySelector(`.vxe-tree--node-wrapper[nodeid="${oldNodeid}"]`);
|
|
2841
|
+
const targetItemEl = oldItemEl;
|
|
2842
|
+
if (targetItemEl) {
|
|
2843
|
+
dragNodeHeight = targetItemEl.offsetHeight;
|
|
2844
|
+
}
|
|
2845
|
+
}
|
|
2846
|
+
rsIndex = oldNodeRest.$index;
|
|
2847
|
+
}
|
|
2848
|
+
const dragRangeList = rsIndex > -1 ? treeList.slice(rsIndex) : [];
|
|
2849
|
+
if (animation && dragNodeHeight && dragRangeList.length) {
|
|
2850
|
+
const wrapperEl = el;
|
|
2851
|
+
const dtClss = [];
|
|
2852
|
+
dragRangeList.forEach(item => {
|
|
2853
|
+
const nodeid = $xeTree.getNodeId(item);
|
|
2854
|
+
dtClss.push(`.vxe-tree--node-wrapper[nodeid="${nodeid}"]`);
|
|
2855
|
+
});
|
|
2856
|
+
const dtTrList = wrapperEl.querySelectorAll(dtClss.join(','));
|
|
2857
|
+
moveRowAnimateToTb(dtTrList, -dragNodeHeight);
|
|
2858
|
+
}
|
|
2859
|
+
});
|
|
2860
|
+
});
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2593
2863
|
},
|
|
2594
2864
|
hideCrossTreeNodeDropClearStatus() {
|
|
2595
2865
|
const $xeTree = this;
|
|
@@ -2598,9 +2868,9 @@ export default {
|
|
|
2598
2868
|
getCheckboxIndeterminateNodes() {
|
|
2599
2869
|
const $xeTree = this;
|
|
2600
2870
|
const internalData = $xeTree.internalData;
|
|
2601
|
-
const { nodeMaps,
|
|
2871
|
+
const { nodeMaps, indeterminateNodeMaps } = internalData;
|
|
2602
2872
|
const list = [];
|
|
2603
|
-
XEUtils.each(
|
|
2873
|
+
XEUtils.each(indeterminateNodeMaps, (item, nodeid) => {
|
|
2604
2874
|
const nodeItem = nodeMaps[nodeid];
|
|
2605
2875
|
if (nodeItem) {
|
|
2606
2876
|
list.push(nodeItem.item);
|
|
@@ -2611,10 +2881,11 @@ export default {
|
|
|
2611
2881
|
handleNodeDragMousedownEvent(evnt, params) {
|
|
2612
2882
|
const $xeTree = this;
|
|
2613
2883
|
const reactData = $xeTree.reactData;
|
|
2884
|
+
const crossTreeDragNodeInfo = getCrossTreeDragNodeInfo($xeTree);
|
|
2614
2885
|
evnt.stopPropagation();
|
|
2615
2886
|
const { node } = params;
|
|
2616
2887
|
const dragConfig = $xeTree.computeDragOpts;
|
|
2617
|
-
const { trigger, dragStartMethod } = dragConfig;
|
|
2888
|
+
const { isCrossTreeDrag, trigger, dragStartMethod } = dragConfig;
|
|
2618
2889
|
const dragEl = evnt.currentTarget;
|
|
2619
2890
|
const itemEl = trigger === 'node' ? dragEl : dragEl.parentElement.parentElement;
|
|
2620
2891
|
clearNodeDropOrigin($xeTree);
|
|
@@ -2624,10 +2895,15 @@ export default {
|
|
|
2624
2895
|
hideDropTip($xeTree);
|
|
2625
2896
|
return;
|
|
2626
2897
|
}
|
|
2898
|
+
if (isCrossTreeDrag) {
|
|
2899
|
+
crossTreeDragNodeInfo.node = node;
|
|
2900
|
+
crossTreeDragNodeObj = { $oldTree: $xeTree, $newTree: null };
|
|
2901
|
+
}
|
|
2627
2902
|
reactData.dragNode = node;
|
|
2903
|
+
reactData.isCrossDragNode = false;
|
|
2628
2904
|
itemEl.draggable = true;
|
|
2629
2905
|
updateNodeDropOrigin($xeTree, node);
|
|
2630
|
-
|
|
2906
|
+
updateNodeDropTipContent($xeTree, itemEl);
|
|
2631
2907
|
$xeTree.dispatchEvent('node-dragstart', params, evnt);
|
|
2632
2908
|
},
|
|
2633
2909
|
handleNodeDragMouseupEvent() {
|
|
@@ -2648,6 +2924,18 @@ export default {
|
|
|
2648
2924
|
const { dragNode } = reactData;
|
|
2649
2925
|
const { nodeMaps, prevDragNode, prevDragPos, prevDragToChild } = internalData;
|
|
2650
2926
|
const hasChildField = $xeTree.computeHasChildField;
|
|
2927
|
+
const dragConfig = $xeTree.computeDragOpts;
|
|
2928
|
+
const { isCrossDrag, isCrossTreeDrag } = dragConfig;
|
|
2929
|
+
// 跨树拖拽
|
|
2930
|
+
if (isCrossTreeDrag && crossTreeDragNodeObj) {
|
|
2931
|
+
const { $newTree } = crossTreeDragNodeObj;
|
|
2932
|
+
if ($newTree && $newTree.xID !== $xeTree.xID) {
|
|
2933
|
+
if (isCrossDrag) {
|
|
2934
|
+
$newTree.handleCrossTreeNodeDragInsertEvent(evnt);
|
|
2935
|
+
}
|
|
2936
|
+
return;
|
|
2937
|
+
}
|
|
2938
|
+
}
|
|
2651
2939
|
if (lazy && prevDragToChild) {
|
|
2652
2940
|
// 懒加载
|
|
2653
2941
|
const newNodeid = $xeTree.getNodeId(prevDragNode);
|
|
@@ -2676,7 +2964,7 @@ export default {
|
|
|
2676
2964
|
const dragConfig = $xeTree.computeDragOpts;
|
|
2677
2965
|
const parentField = $xeTree.computeParentField;
|
|
2678
2966
|
const hasChildField = $xeTree.computeHasChildField;
|
|
2679
|
-
const { isCrossDrag, isPeerDrag, isToChildDrag } = dragConfig;
|
|
2967
|
+
const { isCrossTreeDrag, isCrossDrag, isPeerDrag, isToChildDrag } = dragConfig;
|
|
2680
2968
|
if (!dragNode && !isCrossDrag) {
|
|
2681
2969
|
evnt.preventDefault();
|
|
2682
2970
|
}
|
|
@@ -2692,6 +2980,32 @@ export default {
|
|
|
2692
2980
|
internalData.prevDragToChild = !!(transform && (isCrossDrag && isToChildDrag) && isControlKey);
|
|
2693
2981
|
internalData.prevDragNode = node;
|
|
2694
2982
|
internalData.prevDragPos = dragPos;
|
|
2983
|
+
// 跨树拖拽
|
|
2984
|
+
if (isCrossTreeDrag && isCrossDrag && crossTreeDragNodeObj) {
|
|
2985
|
+
const { $oldTree, $newTree } = crossTreeDragNodeObj;
|
|
2986
|
+
if ($oldTree) {
|
|
2987
|
+
const oldTreeReactData = $oldTree.reactData;
|
|
2988
|
+
if ($oldTree.xID === $xeTree.xID) {
|
|
2989
|
+
if ($newTree) {
|
|
2990
|
+
$newTree.hideCrossTreeNodeDropClearStatus();
|
|
2991
|
+
}
|
|
2992
|
+
reactData.isCrossDragNode = false;
|
|
2993
|
+
oldTreeReactData.isCrossDragNode = false;
|
|
2994
|
+
crossTreeDragNodeObj.$newTree = null;
|
|
2995
|
+
}
|
|
2996
|
+
else if (isCrossDrag) {
|
|
2997
|
+
if ($newTree && $newTree.xID !== $xeTree.xID) {
|
|
2998
|
+
$newTree.hideCrossTreeNodeDropClearStatus();
|
|
2999
|
+
}
|
|
3000
|
+
$oldTree.hideCrossTreeNodeDropClearStatus();
|
|
3001
|
+
oldTreeReactData.isCrossDragNode = true;
|
|
3002
|
+
reactData.dragTipText = oldTreeReactData.dragTipText;
|
|
3003
|
+
crossTreeDragNodeObj.$newTree = $xeTree;
|
|
3004
|
+
showDropTip($xeTree, evnt, itemEl, true, dragPos);
|
|
3005
|
+
return;
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
}
|
|
2695
3009
|
if ((dragNode && $xeTree.getNodeId(dragNode) === nodeid) ||
|
|
2696
3010
|
(isControlKey && lazy && node[hasChildField] && nodeItem && !nodeItem.treeLoaded) ||
|
|
2697
3011
|
(!isCrossDrag && transform && (isPeerDrag ? dragNode[parentField] !== node[parentField] : nodeItem.level))) {
|
|
@@ -3025,11 +3339,16 @@ export default {
|
|
|
3025
3339
|
const radioOpts = $xeTree.computeRadioOpts;
|
|
3026
3340
|
const checkboxOpts = $xeTree.computeCheckboxOpts;
|
|
3027
3341
|
const loadingOpts = $xeTree.computeLoadingOpts;
|
|
3028
|
-
const
|
|
3342
|
+
const isNodeHover = $xeTree.computeIsNodeHover;
|
|
3029
3343
|
const treeStyle = $xeTree.computeTreeStyle;
|
|
3344
|
+
const dragOpts = $xeTree.computeDragOpts;
|
|
3030
3345
|
const loadingSlot = slots.loading;
|
|
3031
3346
|
const headerSlot = slots.header;
|
|
3032
3347
|
const footerSlot = slots.footer;
|
|
3348
|
+
const teOns = {};
|
|
3349
|
+
if (dragOpts.isCrossTreeDrag && !treeList.length) {
|
|
3350
|
+
teOns.dragover = $xeTree.handleCrossTreeNodeDragoverEmptyEvent;
|
|
3351
|
+
}
|
|
3033
3352
|
return h('div', {
|
|
3034
3353
|
ref: 'refElem',
|
|
3035
3354
|
class: ['vxe-tree', {
|
|
@@ -3037,10 +3356,11 @@ export default {
|
|
|
3037
3356
|
'show--line': showLine,
|
|
3038
3357
|
'checkbox--highlight': checkboxOpts.highlight,
|
|
3039
3358
|
'radio--highlight': radioOpts.highlight,
|
|
3040
|
-
'node--hover':
|
|
3359
|
+
'node--hover': isNodeHover,
|
|
3041
3360
|
'node--trigger': trigger === 'node',
|
|
3042
3361
|
'is--loading': loading
|
|
3043
|
-
}]
|
|
3362
|
+
}],
|
|
3363
|
+
on: teOns
|
|
3044
3364
|
}, [
|
|
3045
3365
|
headerSlot
|
|
3046
3366
|
? h('div', {
|