style:优化代码
This commit is contained in:
@@ -149,14 +149,14 @@
|
|||||||
},
|
},
|
||||||
watch:{
|
watch:{
|
||||||
NodeArr(n){
|
NodeArr(n){
|
||||||
if(n.length==2){
|
if(n.length===2){
|
||||||
this.lineData={
|
this.lineData={
|
||||||
arrows:'',
|
arrows:'',
|
||||||
label:'',
|
label:'',
|
||||||
color:'#1e90ff',
|
color:'#1e90ff',
|
||||||
lineId:'',
|
lineId:'',
|
||||||
id:'',
|
id:'',
|
||||||
}
|
};
|
||||||
this.addLineShow=true;
|
this.addLineShow=true;
|
||||||
this.selectNodeTitle=false;
|
this.selectNodeTitle=false;
|
||||||
this.isLineAdd=true;
|
this.isLineAdd=true;
|
||||||
@@ -174,7 +174,7 @@
|
|||||||
immediate: true,
|
immediate: true,
|
||||||
deep: true,
|
deep: true,
|
||||||
handler(n){
|
handler(n){
|
||||||
this.allModuleInfos={...n}
|
this.allModuleInfos={...n};
|
||||||
this.arrayDiff();
|
this.arrayDiff();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -260,7 +260,7 @@
|
|||||||
this.$emit('editVisNetworkChange',false);
|
this.$emit('editVisNetworkChange',false);
|
||||||
},
|
},
|
||||||
//拓扑图方法
|
//拓扑图方法
|
||||||
init(type){
|
init(){
|
||||||
let this_ = this;
|
let this_ = this;
|
||||||
this_.nodes = new Vis.DataSet(this_.nodesArray);
|
this_.nodes = new Vis.DataSet(this_.nodesArray);
|
||||||
this_.edges = new Vis.DataSet(this_.edgesArray);
|
this_.edges = new Vis.DataSet(this_.edgesArray);
|
||||||
@@ -433,8 +433,8 @@
|
|||||||
if(!selId){return}
|
if(!selId){return}
|
||||||
let position=this.network.canvasToDOM(this.network.getPositions([selId])[selId]);
|
let position=this.network.canvasToDOM(this.network.getPositions([selId])[selId]);
|
||||||
this.networkPop.style.top = position.y - 85 + 7*(10-this.zoom*10)+'px';
|
this.networkPop.style.top = position.y - 85 + 7*(10-this.zoom*10)+'px';
|
||||||
this.networkPop.style.left = position.x - 32*this.zoom - 5*(1-this.zoom*1) +'px';
|
this.networkPop.style.left = position.x - 32*this.zoom - 5*(1-this.zoom) +'px';
|
||||||
if(!this.isFullScreen&&this.NodeArr.length==0&&!this.editVisNetwork){
|
if(!this.isFullScreen&&this.NodeArr.length===0&&!this.editVisNetwork){
|
||||||
this.networkPopShow=true;
|
this.networkPopShow=true;
|
||||||
}
|
}
|
||||||
this.NodeArr=[...this.NodeArr]
|
this.NodeArr=[...this.NodeArr]
|
||||||
@@ -442,7 +442,9 @@
|
|||||||
networkPopClose(){//关闭节点工具栏
|
networkPopClose(){//关闭节点工具栏
|
||||||
this.networkPopShow=false;
|
this.networkPopShow=false;
|
||||||
// this.selNodeId=''
|
// this.selNodeId=''
|
||||||
this.network.unselectAll();
|
if(this.network){
|
||||||
|
this.network.unselectAll();
|
||||||
|
}
|
||||||
},
|
},
|
||||||
//工具栏
|
//工具栏
|
||||||
nodeDel(){
|
nodeDel(){
|
||||||
@@ -453,10 +455,10 @@
|
|||||||
this.networkPopClose();
|
this.networkPopClose();
|
||||||
this.arrayDiff();
|
this.arrayDiff();
|
||||||
},
|
},
|
||||||
nodeEdit(){
|
// nodeEdit(){
|
||||||
this.addNodeShow=true;
|
// this.addNodeShow=true;
|
||||||
this.isNodeAdd=false;
|
// this.isNodeAdd=false;
|
||||||
},
|
// },
|
||||||
lineDel(){
|
lineDel(){
|
||||||
if(!this.lineData.id){return}
|
if(!this.lineData.id){return}
|
||||||
let edgesArray=this.edgesArray.filter((item)=>item.id!==this.lineData.id);
|
let edgesArray=this.edgesArray.filter((item)=>item.id!==this.lineData.id);
|
||||||
@@ -489,14 +491,14 @@
|
|||||||
})
|
})
|
||||||
},
|
},
|
||||||
modelTopMouseDown(e){
|
modelTopMouseDown(e){
|
||||||
if(!this.index&&this.index!==0){return};
|
if(!this.index&&this.index!==0){return}
|
||||||
this.relativeModelTop={
|
this.relativeModelTop={
|
||||||
x:e.clientX-(parseFloat(this.$refs['modelTopId'+this.index][0].style.left)),
|
x:e.clientX-(parseFloat(this.$refs['modelTopId'+this.index][0].style.left)),
|
||||||
y:e.clientY-(parseFloat(this.$refs['modelTopId'+this.index][0].style.top)),
|
y:e.clientY-(parseFloat(this.$refs['modelTopId'+this.index][0].style.top)),
|
||||||
};
|
};
|
||||||
this.$refs['network'].addEventListener('mousemove',this.modelTopMouseMove);
|
this.$refs['network'].addEventListener('mousemove',this.modelTopMouseMove);
|
||||||
},
|
},
|
||||||
modelTopMouseUp(e){
|
modelTopMouseUp(){
|
||||||
this.index='';
|
this.index='';
|
||||||
this.relativeModelTop={};
|
this.relativeModelTop={};
|
||||||
this.$refs['network'].removeEventListener('mousemove',this.modelTopMouseMove);
|
this.$refs['network'].removeEventListener('mousemove',this.modelTopMouseMove);
|
||||||
@@ -540,17 +542,20 @@
|
|||||||
setTimeout(()=>{
|
setTimeout(()=>{
|
||||||
let this_=this;
|
let this_=this;
|
||||||
this.init('modal');
|
this.init('modal');
|
||||||
this.network.on("click", function (params) {
|
this.network.on("click", function () {
|
||||||
let selId=params.nodes[0];
|
|
||||||
this_.networkPopClose();
|
this_.networkPopClose();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.network.on("selectNode", function (params) {
|
||||||
|
let selId=params.nodes[0];
|
||||||
if(selId){
|
if(selId){
|
||||||
this_.selNodeId=selId;
|
this_.selNodeId=selId;
|
||||||
this_.cursorMove=true;
|
this_.cursorMove=true;
|
||||||
this_.nodeData=this_.nodesArray.find((item)=>item.id==selId);
|
this_.nodeData=this_.nodesArray.find((item)=>item.id===selId);
|
||||||
if(this_.NodeArr.indexOf(selId)!==-1){
|
if(this_.NodeArr.indexOf(selId)!==-1){
|
||||||
let index = this_.NodeArr.indexOf(selId);
|
let index = this_.NodeArr.indexOf(selId);
|
||||||
this_.NodeArr=this_.NodeArr.filter((item,i)=> i != index);
|
this_.NodeArr=this_.NodeArr.filter((item,i)=> i !== index);
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if(this_.selectNodeTitle&&this_.NodeArrShow){
|
if(this_.selectNodeTitle&&this_.NodeArrShow){
|
||||||
this_.NodeArr.push(selId);
|
this_.NodeArr.push(selId);
|
||||||
|
|||||||
Reference in New Issue
Block a user