Merge branch 'hotfix/cjc' into 'main'

修复不同group的结点不能连接的bug

See merge request phenomLi/StructV2!17
This commit is contained in:
chen jiancheng 2022-03-18 12:39:46 +00:00
commit dbb3b3efde
4 changed files with 207 additions and 56 deletions

View File

@ -36,6 +36,21 @@ SV.registerLayout('TriTree', {
}
}
},
parent: {
type: 'line',
sourceAnchor: 4,
targetAnchor: 6,
style: {
stroke: '#999',
lineAppendWidth: 10,
lineWidth: 1.6,
endArrow: 'default',
startArrow: {
path: G6.Arrow.circle(2, -1),
fill: '#999'
}
}
},
r_parent: {
type: 'quadratic',
sourceAnchor: 4,

View File

@ -8,10 +8,10 @@ const SOURCES_DATA = [{
"0x0"
],
"child": [
"0xb07ee0",
"0xb07f10"
"0xfd9ee0",
"0xfd9f10"
],
"id": "0xb07eb0",
"id": "0xfd9eb0",
"name": "T",
"data": "A",
"root": true,
@ -22,12 +22,12 @@ const SOURCES_DATA = [{
"0x0",
"0x0"
],
"id": "0xb07ee0",
"id": "0xfd9ee0",
"name": "T->lchild",
"data": "B",
"type": "default",
"l_parent": [
"0x0"
"0xfd9eb0"
],
"external": [
"T1"
@ -38,12 +38,12 @@ const SOURCES_DATA = [{
"0x0",
"0x0"
],
"id": "0xb07f10",
"id": "0xfd9f10",
"name": "T->rchild",
"data": "C",
"type": "default",
"r_parent": [
"0x0"
"0xfd9eb0"
],
"external": [
"T2"
@ -52,6 +52,144 @@ const SOURCES_DATA = [{
],
"layouter": "TriTree"
},
"TriTree3": {
"data": [{
"external": [
"T3"
],
"parent": [
"0x0"
],
"child": [
"0x0",
"0x0"
],
"id": "0xfd9f40",
"name": "T3",
"data": "D",
"root": true,
"type": "default"
}],
"layouter": "TriTree"
},
"TriTree4": {
"data": [{
"external": [
"T4"
],
"parent": [
"0x0"
],
"child": [
"0x0",
"0x0"
],
"id": "0xfd9f70",
"name": "T4",
"data": "E",
"root": true,
"type": "default"
}],
"layouter": "TriTree"
},
"handleUpdate": {
"isEnterFunction": true,
"isFirstDebug": true
}
}, {
"TriTree0": {
"data": [{
"external": [
"T"
],
"parent": [
"0x0"
],
"child": [
"0xfd9ee0",
"0xfd9f10"
],
"id": "0xfd9eb0",
"name": "T",
"data": "A",
"root": true,
"type": "default"
},
{
"child": [
"0x0",
"0x0"
],
"id": "0xfd9ee0",
"name": "T->lchild",
"data": "B",
"type": "default",
"l_parent": [
"0xfd9eb0"
],
"external": [
"T1"
]
},
{
"child": [
"0x0",
"0x0"
],
"id": "0xfd9f10",
"name": "T->rchild",
"data": "C",
"type": "default",
"r_parent": [
"0xfd9eb0"
],
"external": [
"T2"
]
}
],
"layouter": "TriTree"
},
"TriTree3": {
"data": [{
"external": [
"T3"
],
"parent": [
"0x0"
],
"child": [
"0x0",
"0x0"
],
"id": "0xfd9f40",
"name": "T3",
"data": "D",
"root": true,
"type": "default"
}],
"layouter": "TriTree"
},
"TriTree4": {
"data": [{
"external": [
"T4"
],
"parent": [
"0xfd9f40"
],
"child": [
"0x0",
"0x0"
],
"id": "0xfd9f70",
"name": "T4",
"data": "E",
"root": true,
"type": "default"
}],
"layouter": "TriTree"
},
"handleUpdate": {
"isEnterFunction": false,
"isFirstDebug": false
@ -66,10 +204,10 @@ const SOURCES_DATA = [{
"0x0"
],
"child": [
"0xb07ee0",
"0xb07f10"
"0xfd9ee0",
"0xfd9f10"
],
"id": "0xb07eb0",
"id": "0xfd9eb0",
"name": "T",
"data": "A",
"root": true,
@ -80,12 +218,12 @@ const SOURCES_DATA = [{
"0x0",
"0x0"
],
"id": "0xb07ee0",
"id": "0xfd9ee0",
"name": "T->lchild",
"data": "B",
"type": "default",
"l_parent": [
"0xb07eb0"
"0xfd9eb0"
],
"external": [
"T1"
@ -96,12 +234,12 @@ const SOURCES_DATA = [{
"0x0",
"0x0"
],
"id": "0xb07f10",
"id": "0xfd9f10",
"name": "T->rchild",
"data": "C",
"type": "default",
"r_parent": [
"0x0"
"0xfd9eb0"
],
"external": [
"T2"
@ -110,26 +248,21 @@ const SOURCES_DATA = [{
],
"layouter": "TriTree"
},
"handleUpdate": {
"isEnterFunction": false,
"isFirstDebug": false
}
}, {
"TriTree0": {
"TriTree3": {
"data": [{
"external": [
"T"
"T3"
],
"parent": [
"0x0"
],
"child": [
"0xb07ee0",
"0xb07f10"
"0xfd9f70",
"0x0"
],
"id": "0xb07eb0",
"name": "T",
"data": "A",
"id": "0xfd9f40",
"name": "T3",
"data": "D",
"root": true,
"type": "default"
},
@ -138,31 +271,15 @@ const SOURCES_DATA = [{
"0x0",
"0x0"
],
"id": "0xb07ee0",
"name": "T->lchild",
"data": "B",
"id": "0xfd9f70",
"name": "T3->lchild",
"data": "E",
"type": "default",
"l_parent": [
"0xb07eb0"
"0xfd9f40"
],
"external": [
"T1"
]
},
{
"child": [
"0x0",
"0x0"
],
"id": "0xb07f10",
"name": "T->rchild",
"data": "C",
"type": "default",
"r_parent": [
"0xb07eb0"
],
"external": [
"T2"
"T4"
]
}
],

View File

@ -434,7 +434,7 @@ export class ModelConstructor {
sourceNodeType = info.pop();
targetGroupName = info.pop();
} else {
let field = info.pop();
let field = info.pop();
if (layoutGroupTable.get(targetGroupName).node.find(item => item.sourceType === field)) {
sourceNodeType = field;
} else if (layoutGroupTable.has(field)) {
@ -444,14 +444,25 @@ export class ModelConstructor {
}
}
nodeList = layoutGroupTable.get(targetGroupName).node.filter(item => item.sourceType === sourceNodeType);
// 为了可以连接到不同group的结点
for (let layoutGroup of layoutGroupTable.values()) {
nodeList = layoutGroup.node.filter(item => item.sourceType === sourceNodeType);
if (nodeList === undefined) {
continue;
}
targetNode = nodeList.find(item => item.sourceId === targetId);
if (targetNode) {
break;
}
}
// nodeList = layoutGroupTable.get(targetGroupName).node.filter(item => item.sourceType === sourceNodeType);
// 若目标node不存在返回null
if (nodeList === undefined) {
return null;
}
// // 若目标node不存在返回null
// if (nodeList === undefined) {
// return null;
// }
targetNode = nodeList.find(item => item.sourceId === targetId);
// targetNode = nodeList.find(item => item.sourceId === targetId);
return targetNode || null;
}

View File

@ -67,12 +67,19 @@ export default Util.registerShape(
draggable: true
});
}
let parent = cfg.parent || cfg.l_parent || cfg.r_parent;
const isLeftEmpty =
!cfg.child || cfg.child[0] === undefined || cfg.child[0] === undefined || cfg.child[0] == '0x0',
isRightEmpty =
!cfg.child || cfg.child[1] === undefined || cfg.child[1] === undefined || cfg.child[1] == '0x0',
isparentEmpty = cfg.parent == "0x0" || cfg.l_parent == "0x0" || cfg.r_parent == "0x0";
isparentEmpty = parent[0] == "0x0";
// console.log(cfg.id);
// console.log(parent);
// console.log(isparentEmpty);
if (isparentEmpty) {
{
@ -140,6 +147,7 @@ export default Util.registerShape(
[0.5, 0],
[0.5, 0.125],
[0.6, 1],
[0.5,1]
];
},
}