fix:修复删除节点对应连线没有删除的bug,以及移动后切换project 没有回到中心点的问题

This commit is contained in:
zhangyu
2020-09-01 09:56:13 +08:00
parent 2469e93b61
commit 00ba7fb1cf
3 changed files with 27 additions and 3 deletions

View File

@@ -223,6 +223,7 @@
this.$refs['form'].validate((valid) => { this.$refs['form'].validate((valid) => {
if (valid) { if (valid) {
let model=Object.assign({id:undefined},{...this.form},{color: {color:this.form.color,highlight:this.form.color,hover:this.form.color,opacity:1.0}}); let model=Object.assign({id:undefined},{...this.form},{color: {color:this.form.color,highlight:this.form.color,hover:this.form.color,opacity:1.0}});
model.label=this.form.lineName;
model.width = parseInt(model.width) || 4; model.width = parseInt(model.width) || 4;
model.smooth={ model.smooth={
roundness:(Math.random()*8 +1)/10 ,//获取0.1-0.9之间的随机数 roundness:(Math.random()*8 +1)/10 ,//获取0.1-0.9之间的随机数

View File

@@ -70,7 +70,7 @@
<popDataMain :moduleId="this.selNodeId" :projectId="this.allModuleInfo.basic.id"></popDataMain> <popDataMain :moduleId="this.selNodeId" :projectId="this.allModuleInfo.basic.id"></popDataMain>
</div> </div>
<div v-if="popDataShow.total"> <div v-if="popDataShow.total">
<total-chart :moduleId="this.selNodeId" :projectId="this.allModuleInfo.basic.id" :nodesArray="nodesArray"></total-chart> <total-chart :moduleId="this.totalId" :projectId="this.allModuleInfo.basic.id" :nodesArray="totalArray"></total-chart>
</div> </div>
<div v-if="popDataShow.info"> <div v-if="popDataShow.info">
<popDataInfo :moduleId="this.selNodeId" :projectId="this.allModuleInfo.basic.id"></popDataInfo> <popDataInfo :moduleId="this.selNodeId" :projectId="this.allModuleInfo.basic.id"></popDataInfo>
@@ -195,6 +195,8 @@
}, },
data(){ data(){
return { return {
totalId:'',
totalArray:[],
allModuleInfos:[], allModuleInfos:[],
relativeModelTop:{}, relativeModelTop:{},
moduleDataS:[], moduleDataS:[],
@@ -263,7 +265,7 @@
saveTopology(){ saveTopology(){
let nodes=this.formatNodes([...this.nodesArray]); let nodes=this.formatNodes([...this.nodesArray]);
let edges=this.formatEdges([...this.edgesArray]); let edges=this.formatEdges([...this.edgesArray]);
this.$put('/project/topo',{topo:JSON.stringify({nodes:nodes,lines:edges}),projectId:this.allModuleInfo.basic.id}).then(res=>{ this.$put('/project/topo',{topo:JSON.stringify({nodes:nodes,lines:edges,viewsCenter:this.viewsCenter,zoom:this.zoom}),projectId:this.allModuleInfo.basic.id}).then(res=>{
if(res.code==200){ if(res.code==200){
this.$message({ this.$message({
message: this.$t("tip.saveSuccess"), message: this.$t("tip.saveSuccess"),
@@ -505,7 +507,9 @@
//工具栏 //工具栏
nodeDel(){ nodeDel(){
let nodesArray=this.nodesArray.filter((item)=>item.id!==this.selNodeId); let nodesArray=this.nodesArray.filter((item)=>item.id!==this.selNodeId);
let edgesArray=this.edgesArray.filter((item)=>item.from!==this.selNodeId || this.to!==this.selNodeId); let edgesArray=this.edgesArray.filter((item)=>!(item.from===this.selNodeId || item.to===this.selNodeId));
console.log(edgesArray,"edgesArray");
this.selNodeId='';
this.$emit('setTopologyData',nodesArray, edgesArray); this.$emit('setTopologyData',nodesArray, edgesArray);
this.setNetworkData(nodesArray, edgesArray); this.setNetworkData(nodesArray, edgesArray);
this.networkPopClose(); this.networkPopClose();
@@ -524,6 +528,7 @@
// 工具的点击 对应的操作 // 工具的点击 对应的操作
popClick(id){ popClick(id){
this.lineData='';
this.popDataShowUpdate(id); this.popDataShowUpdate(id);
}, },
modelTopUpdate(){//model上的图标 实时更新 modelTopUpdate(){//model上的图标 实时更新
@@ -590,6 +595,14 @@
main:false, main:false,
}; };
if(key&&!this.editVisNetwork){ if(key&&!this.editVisNetwork){
if(key==='total'&&this.selNodeId){
this.totalId=this.selNodeId
this.totalArray=this.nodesArray;
}
if(key==='total'&&this.lineData){
this.totalId=this.lineData.id;
this.totalArray=this.edgesArray;
}
this.popDataShow[key]=true; this.popDataShow[key]=true;
} }
}, },
@@ -624,7 +637,14 @@
}); });
this.network.on("selectEdge", function (params) { // 选择边 this.network.on("selectEdge", function (params) { // 选择边
this_.selNodeId='';
this_.lineData=this_.edgesArray.find((item)=>item.id===params.edges[0]); this_.lineData=this_.edgesArray.find((item)=>item.id===params.edges[0]);
console.log(this_.lineData);
if(this_.lineData.expressions&&this_.lineData.expressions.length){
this_.popDataShowUpdate('total')
}else{
this_.popDataShowUpdate()
}
// this_.lineData.color=this_.lineData.color.color; // this_.lineData.color=this_.lineData.color.color;
// this_.addLineShow=true; // this_.addLineShow=true;
// this_.isLineAdd=false; // this_.isLineAdd=false;

View File

@@ -210,7 +210,9 @@
this.$refs['topology'].setData(); this.$refs['topology'].setData();
},500) },500)
} }
// res.data.topo.viewsCenter?res.data.topo.viewsCenter:
this.$refs['topology'].viewsCenter={x:0,y:0}; this.$refs['topology'].viewsCenter={x:0,y:0};
// res.data.topo.zoom?res.data.topo.zoom:
this.$refs['topology'].zoom=1; this.$refs['topology'].zoom=1;
}) })
}, },
@@ -246,6 +248,7 @@
item.dashes=[15,15]; item.dashes=[15,15];
item.from=item.source; item.from=item.source;
item.to=item.target; item.to=item.target;
item.label=item.name;
}); });
return arr return arr
}, },