feat:调用保存接口的按钮

This commit is contained in:
zhangyu
2020-08-26 14:51:45 +08:00
parent 160c3e12f2
commit f935749e96
4 changed files with 60 additions and 27 deletions

View File

@@ -256,11 +256,44 @@
},
methods:{// 保存拓扑图数据
saveTopology(){
let nodes=[...this.nodesArray];
let edges=[...this.edgesArray];
console.log(nodes,edges);
let nodes=this.formatNodes([...this.nodesArray]);
let edges=this.formatEdges([...this.edgesArray]);
console.log(nodes,edges,this.nodesArray,this.edgesArray);
this.$put('/project/topo',{topo:JSON.stringify({nodes,edges}),projectId:this.allModuleInfo.basic.id});
this.$emit('editVisNetworkChange',false);
},
formatNodes(arr){
let arr1=[];
arr.forEach(item=>{
let obj={
"x": item.x,
"y": item.y,
"moduleId": item.moduleId,
"label":item.label,
"iconId": item.iconId,
"expressions": item.expressions
};
arr1.push(obj)
});
return arr1
},
formatEdges(arr){
let arr1=[];
arr.forEach(item=>{
let obj={
"name": item.lineName,
"width": item.width,
"arrows": item.arrows,
"color": item.color,
"source": item.from,
"target": item.to,
"smooth": item.smooth,
"expressions": item.expressions,
};
arr1.push(obj)
});
return arr1
},
//拓扑图方法
init(){
let this_ = this;