update code
parent
04a44952e7
commit
23167ecc5d
|
@ -25,13 +25,63 @@ class RedNodeModel extends RectNodeModel {
|
|||
this.text.x = this.x + 10;
|
||||
this.defaultFill = data.fill || "rgb(253, 208, 162)";
|
||||
|
||||
const startOnlyAsTarget = {
|
||||
message: "开始结点只能连接结束节点",
|
||||
const rule0 = {
|
||||
message: "开始结点只能连接结束节点!",
|
||||
validate: (sourceNode, targetNode, sourceAnchor, targetAnchor) => {
|
||||
return sourceAnchor.type !== targetAnchor.type;
|
||||
let res= sourceAnchor.type !== targetAnchor.type;
|
||||
return res;
|
||||
},
|
||||
};
|
||||
this.sourceRules.push(startOnlyAsTarget);
|
||||
const rule1 = {
|
||||
message: "同一算子不能互联!",
|
||||
validate: (sourceNode, targetNode, sourceAnchor, targetAnchor) => {
|
||||
return sourceNode.id !== targetNode.id;
|
||||
},
|
||||
};
|
||||
const rule2 = {
|
||||
message: "输入类型与输出类型不符!",
|
||||
validate: (sourceNode, targetNode, sourceAnchor, targetAnchor) => {
|
||||
let sp= sourceNode.properties.data.parameters;
|
||||
let tp= targetNode.properties.data.parameters;
|
||||
let inStr="";
|
||||
let outStr="";
|
||||
if(sourceAnchor.type=="start"){
|
||||
inStr=sp.inputs.length>=sourceAnchor.idx?sp.inputs[sourceAnchor.idx-1].oper_inout_data_type:"";
|
||||
}
|
||||
if(sourceAnchor.type=="end"){
|
||||
outStr=sp.outputs.length>=sourceAnchor.idx?sp.outputs[sourceAnchor.idx-1].oper_inout_data_type:"";
|
||||
if(outStr=="same_as_input"){
|
||||
outStr=sp.inputs[0].oper_inout_data_type;
|
||||
}
|
||||
}
|
||||
if(targetAnchor.type=="start"){
|
||||
inStr=tp.inputs.length>=targetAnchor.idx?tp.inputs[targetAnchor.idx-1].oper_inout_data_type:"";
|
||||
}
|
||||
if(targetAnchor.type=="end"){
|
||||
outStr=tp.outputs.length>=targetAnchor.idx?tp.outputs[targetAnchor.idx-1].oper_inout_data_type:"";
|
||||
if(outStr=="same_as_input"){
|
||||
outStr=tp.inputs[0].oper_inout_data_type;
|
||||
}
|
||||
}
|
||||
if(inStr.length>0 && outStr.length>0 ){
|
||||
let tmpS=inStr.split(",").filter(d=>d).map(d=>d.toLowerCase());
|
||||
let tmpE=outStr.split(",").filter(d=>d).map(d=>d.toLowerCase());
|
||||
if(tmpS.sort().join(",")==tmpE.sort().join(",")){
|
||||
return true;
|
||||
}
|
||||
if(tmpS.length>tmpE.length){
|
||||
if((","+tmpS.sort().join(",")).indexOf(","+tmpE.sort().join(","))>=0){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
},
|
||||
};
|
||||
this.sourceRules.push(rule1);
|
||||
this.sourceRules.push(rule0);
|
||||
this.sourceRules.push(rule2);
|
||||
|
||||
}
|
||||
getData() {
|
||||
const data = super.getData();
|
||||
|
|
|
@ -257,6 +257,7 @@ const doOutputSelected=idx=>{
|
|||
.sp-text {
|
||||
flex-grow: 1;
|
||||
display: block;
|
||||
margin-left:4px;
|
||||
}
|
||||
|
||||
.div-param {
|
||||
|
|
|
@ -461,6 +461,7 @@ onMounted(() => {
|
|||
.sp-text {
|
||||
flex-grow: 1;
|
||||
display: block;
|
||||
margin-left:4px;
|
||||
}
|
||||
.div-param{
|
||||
.div-navs{
|
||||
|
|
|
@ -71,8 +71,12 @@ const initEvent=(lf)=>{
|
|||
nodePropKey.value++
|
||||
doUpdateState()
|
||||
});
|
||||
lf.on("connection:not-allowed",(a,b,c)=>{
|
||||
ElMessage.error("开始节点只能连接结束节点!");
|
||||
lf.on("connection:not-allowed",(a,b,c)=>{
|
||||
if(a.msg=="不允许添加连线"){
|
||||
ElMessage.error("开始结点只能连接结束节点!");
|
||||
}else{
|
||||
ElMessage.error(a.msg);
|
||||
}
|
||||
});
|
||||
lf.on("node:delete",data=>{
|
||||
if(data.data.text.value=="目标绘图"){
|
||||
|
|
Loading…
Reference in New Issue