2020-08-19 11:44:26 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="content">
|
2020-08-25 15:12:29 +08:00
|
|
|
|
<div class="edit-topology" v-if="editVisNetwork">
|
2020-08-20 11:31:51 +08:00
|
|
|
|
<span v-show="!selectNodeTitle&&editVisNetwork" class="edit-topology-module">
|
2020-09-03 09:51:50 +08:00
|
|
|
|
{{$t('project.topology.module')}} :
|
|
|
|
|
|
<span class="edit-topology-add" @click="addModelShow">{{$t('project.topology.add')}}</span>
|
2020-09-02 09:38:26 +08:00
|
|
|
|
<!--<span class="edit-topology-remove" @click="nodeDel">Remove</span>-->
|
2020-08-19 11:44:26 +08:00
|
|
|
|
</span>
|
2020-08-20 11:31:51 +08:00
|
|
|
|
<span v-show="!selectNodeTitle&&editVisNetwork" class="edit-topologyLine">
|
2020-09-03 09:51:50 +08:00
|
|
|
|
{{$t('project.topology.line')}} :
|
|
|
|
|
|
<span class="edit-topology-add" @click="addLineTitleShow">{{$t('project.topology.add')}}</span>
|
2020-09-02 09:38:26 +08:00
|
|
|
|
<!--<span class="edit-topology-remove" @click="lineDel">Remove</span>-->
|
2020-08-19 11:44:26 +08:00
|
|
|
|
</span>
|
2020-08-20 14:47:14 +08:00
|
|
|
|
<span v-show="!selectNodeTitle&&editVisNetwork" class="edit-topologyLine">
|
2020-09-03 09:51:50 +08:00
|
|
|
|
<el-button @click="saveTopology" class="saveTopology">{{$t('project.topology.save')}}</el-button>
|
|
|
|
|
|
<el-button @click="cancelTopology" class="cancelTopology">{{$t('project.topology.cancel')}}</el-button>
|
2020-08-20 14:47:14 +08:00
|
|
|
|
</span>
|
2020-09-03 09:51:50 +08:00
|
|
|
|
<span class="edit-topology-line-cancel" v-show="selectNodeTitle&&editVisNetwork"> {{$t('project.topology.selTwoNode')}} <span class="edit-topologyCancel" @click="closeAddLine">{{$t('project.topology.cancel')}}</span></span>
|
2020-08-19 11:44:26 +08:00
|
|
|
|
</div>
|
2020-09-03 09:51:50 +08:00
|
|
|
|
<div class="edit-topology" v-else></div>
|
2020-08-19 15:33:16 +08:00
|
|
|
|
<div class="network" ref="network" v-clickoutside="networkPopClose" @mousedown="(e)=>{modelTopMouseDown(e)}" @mouseup="(e)=>modelTopMouseUp(e)">
|
2020-08-20 11:31:51 +08:00
|
|
|
|
<!--拓扑图-->
|
|
|
|
|
|
<div id="network_id" ref="visNetwork" :class="{'cursorMove': cursorMove}"></div>
|
|
|
|
|
|
<!--空拓扑图-->
|
|
|
|
|
|
<div class="network-null" v-if="nodesArray.length===0">
|
|
|
|
|
|
<i class="nz-icon nz-icon-add-node" @click="addModelShow"></i>
|
2020-08-26 09:50:09 +08:00
|
|
|
|
<img src="./image/emptyData.png" width="303px" height="184px"/>
|
2020-08-20 11:31:51 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<!--拓扑图工具-->
|
|
|
|
|
|
<div
|
|
|
|
|
|
id="network-pop"
|
|
|
|
|
|
class="network-pop"
|
|
|
|
|
|
:style="{transform:'scale('+zoom+')'}"
|
|
|
|
|
|
v-show="networkPopShow"
|
|
|
|
|
|
>
|
|
|
|
|
|
<i class="nz-icon nz-icon-hexagonBorder" v-for="item in popData" :style="{top:item.top,left:item.left}" @click="popClick(item.id)">
|
|
|
|
|
|
<i class="nz-icon nz-icon-liubianxing"></i>
|
|
|
|
|
|
<i :class="[item.className,{'nz-icon':item.className},'noMove']"></i>
|
2020-08-19 11:44:26 +08:00
|
|
|
|
</i>
|
2020-08-20 11:31:51 +08:00
|
|
|
|
<!--<i class="nz-icon nz-icon-delete" @click="nodeDel"></i>-->
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!--拓扑图选中-->
|
|
|
|
|
|
<div class="sel-node" id="nodeArr1" v-show="NodeArr[0]&&NodeArrShow" :style="{transform:'scale('+zoom+')'}">
|
|
|
|
|
|
<div class="sel-node-top"></div>
|
|
|
|
|
|
<div class="sel-node-right"></div>
|
|
|
|
|
|
<div class="sel-node-bottom"></div>
|
|
|
|
|
|
<div class="sel-node-left"></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<div class="sel-node" id="nodeArr2" v-show="NodeArr[1]&&NodeArrShow" :style="{transform:'scale('+zoom+')'}">
|
|
|
|
|
|
<div class="sel-node-top"></div>
|
|
|
|
|
|
<div class="sel-node-right"></div>
|
|
|
|
|
|
<div class="sel-node-bottom"></div>
|
|
|
|
|
|
<div class="sel-node-left"></div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<!--图谱图右侧-->
|
|
|
|
|
|
<!--<div class="networkContent">33333</div>-->
|
|
|
|
|
|
<!--model上的图标-->
|
|
|
|
|
|
<i class="nz-icon nz-icon-shuidi"
|
|
|
|
|
|
v-show="item.show"
|
|
|
|
|
|
v-for="(item,index) in modelTop"
|
2020-09-03 14:31:21 +08:00
|
|
|
|
:style="{top:(item.y- 80 + 5*(10-zoom*10))+'px',left:(item.x-26 + 5*(1-zoom))+'px',transform:'scale('+zoom+')'}"
|
2020-08-20 11:31:51 +08:00
|
|
|
|
:ref="'modelTopId'+index"
|
|
|
|
|
|
@mousedown="modelTopClick(item,index)"
|
|
|
|
|
|
>
|
|
|
|
|
|
<!--@mousedown="(e)=>modelTopMouseDown(item,index,e)"-->
|
|
|
|
|
|
<!--@mouseup="modelTopMouseUp(item,index)"-->
|
|
|
|
|
|
<i class="nz-icon nz-icon-model"></i>
|
|
|
|
|
|
</i>
|
|
|
|
|
|
<!--悬浮network部分-->
|
2020-08-20 14:47:14 +08:00
|
|
|
|
<div class="network-info">
|
2020-08-24 17:04:27 +08:00
|
|
|
|
<div v-if="popDataShow.main">
|
|
|
|
|
|
<popDataMain :moduleId="this.selNodeId" :projectId="this.allModuleInfo.basic.id"></popDataMain>
|
|
|
|
|
|
</div>
|
2020-08-24 18:03:53 +08:00
|
|
|
|
<div v-if="popDataShow.total">
|
2020-09-01 09:56:13 +08:00
|
|
|
|
<total-chart :moduleId="this.totalId" :projectId="this.allModuleInfo.basic.id" :nodesArray="totalArray"></total-chart>
|
2020-08-24 18:03:53 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div v-if="popDataShow.info">
|
|
|
|
|
|
<popDataInfo :moduleId="this.selNodeId" :projectId="this.allModuleInfo.basic.id"></popDataInfo>
|
|
|
|
|
|
</div>
|
2020-08-20 14:47:14 +08:00
|
|
|
|
</div>
|
2020-09-01 14:26:27 +08:00
|
|
|
|
<!--拓扑图的放大缩小-->
|
|
|
|
|
|
<!--<div class="network-zoom">-->
|
|
|
|
|
|
<!--<div @click='zoomChange(0.1)'><i class="nz-icon nz-icon-hexagonBorder zoom-icon"></i></div>-->
|
|
|
|
|
|
<!--<div @click='zoomChange(-0.1)'><i class="nz-icon nz-icon-hexagonBorder zoom-icon"></i></div>-->
|
|
|
|
|
|
<!--</div>-->
|
2020-08-20 11:31:51 +08:00
|
|
|
|
|
2020-08-19 11:44:26 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<transition name="right-box">
|
2020-08-21 15:33:44 +08:00
|
|
|
|
<add-model
|
|
|
|
|
|
v-if="addNodeShow"
|
|
|
|
|
|
@addModel="addModel"
|
|
|
|
|
|
:nodeData="nodeData"
|
2020-09-03 09:51:50 +08:00
|
|
|
|
@close="closeAddNode"
|
2020-08-21 15:33:44 +08:00
|
|
|
|
@del="nodeDel"
|
|
|
|
|
|
:isAdd="isNodeAdd"
|
|
|
|
|
|
:moduleDataS="moduleDataS"
|
2020-08-27 15:23:52 +08:00
|
|
|
|
:projectName="allModuleInfo.basic"
|
2020-08-21 15:33:44 +08:00
|
|
|
|
></add-model>
|
2020-08-19 11:44:26 +08:00
|
|
|
|
</transition>
|
|
|
|
|
|
<transition name="right-box">
|
2020-08-21 15:33:44 +08:00
|
|
|
|
<add-line
|
|
|
|
|
|
v-if="addLineShow"
|
|
|
|
|
|
@addLine="addLine"
|
|
|
|
|
|
@lineDel="lineDel"
|
|
|
|
|
|
:selectNode="NodeArr"
|
|
|
|
|
|
:lineData="lineData"
|
|
|
|
|
|
:isAdd="isLineAdd"
|
|
|
|
|
|
@close="closeAddLine"
|
|
|
|
|
|
@del="lineDel"
|
|
|
|
|
|
></add-line>
|
2020-08-19 11:44:26 +08:00
|
|
|
|
</transition>
|
2020-08-24 17:04:27 +08:00
|
|
|
|
<!--endpoint-->
|
|
|
|
|
|
<transition name="right-box">
|
2020-08-28 11:06:14 +08:00
|
|
|
|
<endpointTable v-if="popDataShow.endpoint" :moduleId="this.selNodeId" :projectId="this.allModuleInfo.basic.id" @close="popDataShowUpdate">endpoint</endpointTable>
|
2020-08-24 17:04:27 +08:00
|
|
|
|
</transition>
|
2020-08-27 18:00:03 +08:00
|
|
|
|
<!--asset-->
|
2020-08-24 17:04:27 +08:00
|
|
|
|
<transition name="right-box">
|
2020-08-27 18:00:03 +08:00
|
|
|
|
<assetTable v-if="popDataShow.asset" :moduleId="this.selNodeId" :projectId="this.allModuleInfo.basic.id" @close="popDataShowUpdate">alert</assetTable>
|
2020-08-24 17:04:27 +08:00
|
|
|
|
</transition>
|
|
|
|
|
|
<!--alert-->
|
|
|
|
|
|
<transition name="right-box">
|
2020-08-26 11:28:09 +08:00
|
|
|
|
<alertTable v-if="popDataShow.alert" :moduleId="this.selNodeId" :projectId="this.allModuleInfo.basic.id" @close="popDataShowUpdate">alert</alertTable>
|
2020-08-24 17:04:27 +08:00
|
|
|
|
</transition>
|
2020-08-19 11:44:26 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script>
|
|
|
|
|
|
import Vis from 'vis'
|
|
|
|
|
|
import addNode from './addNode'
|
|
|
|
|
|
import addLine from './addLine'
|
2020-08-25 10:00:08 +08:00
|
|
|
|
import popDataMain from './popData/Main'
|
|
|
|
|
|
import popDataInfo from './popData/Info'
|
2020-08-25 15:12:29 +08:00
|
|
|
|
import TotalChart from "./popData/totalChart";
|
2020-08-26 11:28:09 +08:00
|
|
|
|
import alertTable from "./popData/alertTable";
|
2020-08-27 18:00:03 +08:00
|
|
|
|
import assetTable from "./popData/assetTable";
|
2020-08-28 11:06:14 +08:00
|
|
|
|
import endpointTable from "./popData/endpointTable";
|
2020-08-19 11:44:26 +08:00
|
|
|
|
export default {
|
|
|
|
|
|
name:"topology",
|
|
|
|
|
|
components: {
|
2020-08-25 15:12:29 +08:00
|
|
|
|
TotalChart,
|
2020-08-26 11:28:09 +08:00
|
|
|
|
alertTable,
|
2020-08-27 18:00:03 +08:00
|
|
|
|
assetTable,
|
2020-08-28 11:06:14 +08:00
|
|
|
|
endpointTable,
|
2020-08-19 11:44:26 +08:00
|
|
|
|
'add-model':addNode,
|
|
|
|
|
|
'add-line':addLine,
|
2020-08-24 17:04:27 +08:00
|
|
|
|
'popDataMain':popDataMain,
|
2020-08-24 18:03:53 +08:00
|
|
|
|
'popDataInfo':popDataInfo,
|
2020-08-19 11:44:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
props:{
|
|
|
|
|
|
nodesArray:{
|
|
|
|
|
|
type:Array
|
|
|
|
|
|
},
|
|
|
|
|
|
edgesArray:{
|
|
|
|
|
|
type:Array
|
|
|
|
|
|
},
|
|
|
|
|
|
isFullScreen:{
|
|
|
|
|
|
type:Boolean,
|
|
|
|
|
|
},
|
2020-08-20 11:31:51 +08:00
|
|
|
|
editVisNetwork:{
|
|
|
|
|
|
type:Boolean,
|
2020-08-20 14:47:14 +08:00
|
|
|
|
},
|
|
|
|
|
|
allModuleInfo:{}
|
2020-08-19 11:44:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
watch:{
|
|
|
|
|
|
NodeArr(n){
|
2020-08-26 09:58:39 +08:00
|
|
|
|
if(n.length===2){
|
2020-08-19 11:44:26 +08:00
|
|
|
|
this.lineData={
|
2020-09-07 14:33:34 +08:00
|
|
|
|
arrows:'0',
|
2020-08-19 11:44:26 +08:00
|
|
|
|
label:'',
|
|
|
|
|
|
color:'#1e90ff',
|
|
|
|
|
|
lineId:'',
|
2020-09-07 14:33:34 +08:00
|
|
|
|
width:'1',
|
2020-09-07 17:29:18 +08:00
|
|
|
|
dashes:false,
|
2020-08-19 11:44:26 +08:00
|
|
|
|
id:'',
|
2020-08-26 09:58:39 +08:00
|
|
|
|
};
|
2020-08-19 11:44:26 +08:00
|
|
|
|
this.addLineShow=true;
|
|
|
|
|
|
this.selectNodeTitle=false;
|
|
|
|
|
|
this.isLineAdd=true;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.selNodeArrUpdate()
|
2020-08-20 11:31:51 +08:00
|
|
|
|
},
|
|
|
|
|
|
editVisNetwork(n){
|
|
|
|
|
|
if(!n){
|
|
|
|
|
|
this.NodeArr=[];
|
|
|
|
|
|
this.selNodeId='';
|
|
|
|
|
|
this.selectNodeTitle=false;
|
|
|
|
|
|
}
|
2020-08-20 14:47:14 +08:00
|
|
|
|
},
|
|
|
|
|
|
allModuleInfo:{
|
|
|
|
|
|
immediate: true,
|
|
|
|
|
|
deep: true,
|
|
|
|
|
|
handler(n){
|
2020-08-26 09:58:39 +08:00
|
|
|
|
this.allModuleInfos={...n};
|
2020-08-20 17:09:22 +08:00
|
|
|
|
this.arrayDiff();
|
2020-08-20 14:47:14 +08:00
|
|
|
|
},
|
2020-08-20 17:09:22 +08:00
|
|
|
|
},
|
|
|
|
|
|
// nodesArray:{
|
|
|
|
|
|
// immediate: true,
|
|
|
|
|
|
// deep: true,
|
|
|
|
|
|
// handler(n){
|
|
|
|
|
|
// this.setNetworkData(n,this.edgesArray);
|
|
|
|
|
|
// },
|
|
|
|
|
|
// },
|
2020-08-19 11:44:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
data(){
|
|
|
|
|
|
return {
|
2020-09-01 09:56:13 +08:00
|
|
|
|
totalId:'',
|
|
|
|
|
|
totalArray:[],
|
2020-08-20 14:47:14 +08:00
|
|
|
|
allModuleInfos:[],
|
2020-08-19 15:33:16 +08:00
|
|
|
|
relativeModelTop:{},
|
2020-08-20 17:09:22 +08:00
|
|
|
|
moduleDataS:[],
|
2020-08-19 15:33:16 +08:00
|
|
|
|
index:'',
|
2020-08-19 11:44:26 +08:00
|
|
|
|
zoom:1,
|
|
|
|
|
|
domScale:1,
|
|
|
|
|
|
selectNodeTitle:false,
|
|
|
|
|
|
// 拓扑图工具
|
|
|
|
|
|
networkPopTop:0,
|
|
|
|
|
|
networkPopLeft:0,
|
|
|
|
|
|
networkPopShow:false,
|
|
|
|
|
|
addNodeShow:false,
|
|
|
|
|
|
addLineShow:false,
|
|
|
|
|
|
NodeArrShow:false,
|
|
|
|
|
|
cursorMove:false,
|
|
|
|
|
|
NodeArr:[],
|
|
|
|
|
|
selNodeId:'',
|
|
|
|
|
|
lineData:{
|
|
|
|
|
|
arrows:'',
|
|
|
|
|
|
label:'',
|
|
|
|
|
|
color:'#1e90ff',
|
|
|
|
|
|
lineId:'',
|
|
|
|
|
|
id:'',
|
2020-09-07 17:29:18 +08:00
|
|
|
|
dashes:[],
|
2020-08-19 11:44:26 +08:00
|
|
|
|
},
|
2020-09-07 11:34:13 +08:00
|
|
|
|
hoverEdge:false,
|
2020-08-19 11:44:26 +08:00
|
|
|
|
isLineAdd:true,
|
|
|
|
|
|
isNodeAdd:true,
|
|
|
|
|
|
nodeData:{
|
|
|
|
|
|
modelId:'',
|
|
|
|
|
|
label:'',
|
|
|
|
|
|
x:'',
|
|
|
|
|
|
y:'',
|
|
|
|
|
|
image:'',
|
|
|
|
|
|
},
|
|
|
|
|
|
popData:[
|
2020-08-24 18:03:53 +08:00
|
|
|
|
{top:'-20px', left:'-17px',className:'nz-icon-endpoint',id:'endpoint'},
|
|
|
|
|
|
{top:'-20px', left:'28px',className:'nz-icon-shujuku',id:'asset'},
|
|
|
|
|
|
{top:'18px', left:'52px',className:'nz-icon-chart',id:'total'},
|
|
|
|
|
|
{top:'56px', left:'28px',className:'',id:'other'},
|
|
|
|
|
|
{top:'56px', left:'-17px',className:'nz-icon-info-normal',id:'info'},
|
|
|
|
|
|
{top:'18px', left:'-38px',className:'nz-icon-gaojing',id:'alert'},
|
2020-08-19 11:44:26 +08:00
|
|
|
|
],
|
2020-08-24 11:22:59 +08:00
|
|
|
|
popDataShow:{
|
|
|
|
|
|
endpoint:false,
|
|
|
|
|
|
asset:false,
|
|
|
|
|
|
total:false,
|
|
|
|
|
|
other:false,
|
|
|
|
|
|
info:false,
|
|
|
|
|
|
alert:false,
|
|
|
|
|
|
main:false,
|
|
|
|
|
|
},
|
2020-08-19 11:44:26 +08:00
|
|
|
|
modelTop:[],
|
|
|
|
|
|
//viewsCenter
|
|
|
|
|
|
viewsCenter:{
|
|
|
|
|
|
x:0,y:0
|
|
|
|
|
|
},
|
|
|
|
|
|
// 拓扑图数据
|
|
|
|
|
|
nodes:[],
|
|
|
|
|
|
edges:[],
|
|
|
|
|
|
// network:null,
|
|
|
|
|
|
container:null,
|
|
|
|
|
|
options:{},
|
|
|
|
|
|
data:{}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
2020-08-24 11:22:59 +08:00
|
|
|
|
methods:{// 保存拓扑图数据
|
|
|
|
|
|
saveTopology(){
|
2020-08-26 14:51:45 +08:00
|
|
|
|
let nodes=this.formatNodes([...this.nodesArray]);
|
|
|
|
|
|
let edges=this.formatEdges([...this.edgesArray]);
|
2020-09-01 09:56:13 +08:00
|
|
|
|
this.$put('/project/topo',{topo:JSON.stringify({nodes:nodes,lines:edges,viewsCenter:this.viewsCenter,zoom:this.zoom}),projectId:this.allModuleInfo.basic.id}).then(res=>{
|
2020-09-03 14:31:21 +08:00
|
|
|
|
if(res.code===200){
|
2020-08-27 15:23:52 +08:00
|
|
|
|
this.$message({
|
|
|
|
|
|
message: this.$t("tip.saveSuccess"),
|
|
|
|
|
|
type: 'success'
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(res=>{
|
|
|
|
|
|
this.$message({
|
|
|
|
|
|
message: res.msg,
|
|
|
|
|
|
type: 'error'
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|
2020-09-02 09:38:26 +08:00
|
|
|
|
// this.$put('/project/topo',{topo:'{}',projectId:this.allModuleInfo.basic.id});
|
2020-08-24 15:42:06 +08:00
|
|
|
|
this.$emit('editVisNetworkChange',false);
|
2020-08-24 11:22:59 +08:00
|
|
|
|
},
|
2020-09-01 14:31:03 +08:00
|
|
|
|
cancelTopology(){
|
|
|
|
|
|
this.$emit('reload');
|
|
|
|
|
|
},
|
2020-08-26 14:51:45 +08:00
|
|
|
|
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={
|
2020-09-01 15:32:46 +08:00
|
|
|
|
"name": item.label,
|
2020-08-26 14:51:45 +08:00
|
|
|
|
"width": item.width,
|
|
|
|
|
|
"arrows": item.arrows,
|
|
|
|
|
|
"color": item.color,
|
|
|
|
|
|
"source": item.from,
|
|
|
|
|
|
"target": item.to,
|
|
|
|
|
|
"smooth": item.smooth,
|
|
|
|
|
|
"expressions": item.expressions,
|
2020-09-07 17:29:18 +08:00
|
|
|
|
"dashes":item.dashes,
|
2020-08-26 14:51:45 +08:00
|
|
|
|
};
|
|
|
|
|
|
arr1.push(obj)
|
|
|
|
|
|
});
|
|
|
|
|
|
return arr1
|
|
|
|
|
|
},
|
2020-08-19 11:44:26 +08:00
|
|
|
|
//拓扑图方法
|
2020-08-26 09:58:39 +08:00
|
|
|
|
init(){
|
2020-08-19 11:44:26 +08:00
|
|
|
|
let this_ = this;
|
|
|
|
|
|
this_.nodes = new Vis.DataSet(this_.nodesArray);
|
|
|
|
|
|
this_.edges = new Vis.DataSet(this_.edgesArray);
|
|
|
|
|
|
this_.container = this.$refs.visNetwork;
|
2020-08-20 11:31:51 +08:00
|
|
|
|
this_.networkPop = document.getElementById('network-pop');
|
2020-08-19 11:44:26 +08:00
|
|
|
|
this_.data = {
|
|
|
|
|
|
nodes: this_.nodes,
|
|
|
|
|
|
edges: this_.edges
|
|
|
|
|
|
};
|
|
|
|
|
|
this_.options = {
|
|
|
|
|
|
autoResize: true,
|
|
|
|
|
|
clickToUse:true,
|
|
|
|
|
|
groups:{
|
|
|
|
|
|
useDefaultGroups: true,
|
|
|
|
|
|
myGroupId:{
|
|
|
|
|
|
/*node options*/
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
nodes: {
|
|
|
|
|
|
shape: 'dot',
|
|
|
|
|
|
size: 40,
|
|
|
|
|
|
borderWidth: 2,
|
|
|
|
|
|
font:{
|
2020-08-27 18:00:03 +08:00
|
|
|
|
size:16,
|
2020-08-19 11:44:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
edges: {
|
|
|
|
|
|
width: 2,
|
|
|
|
|
|
smooth:{ //设置两个节点之前的连线的状态
|
2020-09-02 09:38:26 +08:00
|
|
|
|
enabled: false,//默认是true,设置为false之后,两个节点之前的连线始终为直线,不会出现贝塞尔曲线
|
2020-08-19 11:44:26 +08:00
|
|
|
|
roundness:0.5,
|
|
|
|
|
|
type: "curvedCW",
|
|
|
|
|
|
},
|
2020-09-04 13:53:00 +08:00
|
|
|
|
font:{
|
|
|
|
|
|
align:'bottom',
|
|
|
|
|
|
vadjust:10,
|
|
|
|
|
|
},
|
2020-08-19 11:44:26 +08:00
|
|
|
|
selfReferenceSize:40,
|
2020-09-03 09:51:50 +08:00
|
|
|
|
arrowStrikethrough:false,
|
2020-09-04 13:53:00 +08:00
|
|
|
|
chosen:{
|
|
|
|
|
|
edge:(values, id, selected, hovering)=>{
|
2020-09-07 11:34:13 +08:00
|
|
|
|
if(this_.hoverEdge){
|
|
|
|
|
|
values.middleArrow=true;
|
|
|
|
|
|
values.middleArrowScale=1;
|
|
|
|
|
|
values.middleArrowType='circle';
|
|
|
|
|
|
}
|
2020-09-04 13:53:00 +08:00
|
|
|
|
},
|
|
|
|
|
|
},
|
2020-08-19 11:44:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
layout:{
|
|
|
|
|
|
randomSeed: 666,
|
|
|
|
|
|
},
|
|
|
|
|
|
physics: { //计算节点之前斥力,进行自动排列的属性
|
|
|
|
|
|
enabled: false, //默认是true,设置为false后,节点将不会自动改变,拖动谁谁动。不影响其他的节点
|
|
|
|
|
|
barnesHut: {
|
|
|
|
|
|
gravitationalConstant: -4000,
|
|
|
|
|
|
centralGravity: 0.3,
|
|
|
|
|
|
springLength: 120,
|
|
|
|
|
|
springConstant: 0.04,
|
|
|
|
|
|
damping: 0.09,
|
|
|
|
|
|
avoidOverlap: 0
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
interaction:{
|
|
|
|
|
|
dragNodes: true, //是否能拖动节点
|
2020-08-24 15:42:06 +08:00
|
|
|
|
dragView: true, //是否能拖动画布
|
2020-08-19 11:44:26 +08:00
|
|
|
|
hover: true, //鼠标移过后加粗该节点和连接线
|
|
|
|
|
|
multiselect: false, //按 ctrl 多选
|
|
|
|
|
|
selectable: true, //是否可以点击选择
|
|
|
|
|
|
selectConnectedEdges: false, //选择节点后是否显示连接线
|
|
|
|
|
|
hoverConnectedEdges: true, //鼠标滑动节点后是否显示连接线
|
|
|
|
|
|
zoomView: true, //是否能缩放画布
|
|
|
|
|
|
navigationButtons:true,
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
manipulation: { //该属性表示可以编辑,出现编辑操作按钮
|
|
|
|
|
|
enabled: false,
|
|
|
|
|
|
},
|
|
|
|
|
|
};
|
|
|
|
|
|
this_.network = new Vis.Network(this_.container, this_.data, this_.options);
|
|
|
|
|
|
this_.network.moveTo({
|
|
|
|
|
|
position: this_.viewsCenter,
|
2020-08-24 15:42:06 +08:00
|
|
|
|
scale: this_.zoom,
|
2020-08-19 11:44:26 +08:00
|
|
|
|
offset: {x:0, y:0},
|
|
|
|
|
|
});
|
|
|
|
|
|
this_.containerCanvas=document.querySelectorAll("#network_id canvas")[0];
|
|
|
|
|
|
this_.modelTopUpdate();
|
|
|
|
|
|
},
|
|
|
|
|
|
resetAllNodes() {
|
|
|
|
|
|
this.setNetworkData(this.nodesArray,this.edgesArray);
|
|
|
|
|
|
},
|
|
|
|
|
|
resetAllNodesStabilize() {
|
|
|
|
|
|
let this_ = this;
|
|
|
|
|
|
this_.resetAllNodes();
|
|
|
|
|
|
this_.network.stabilize();
|
|
|
|
|
|
},
|
2020-08-26 16:01:33 +08:00
|
|
|
|
setData(){
|
|
|
|
|
|
this.setNetworkData(this.nodesArray,this.edgesArray);
|
|
|
|
|
|
},
|
2020-08-19 11:44:26 +08:00
|
|
|
|
setNetworkData(nodes,edges){//动态设置拓扑图数据
|
|
|
|
|
|
let this_ = this;
|
|
|
|
|
|
this.nodes = new Vis.DataSet(nodes);
|
|
|
|
|
|
this.edges = new Vis.DataSet(edges);
|
|
|
|
|
|
this.network.setData({
|
|
|
|
|
|
nodes:this_.nodes,
|
|
|
|
|
|
edges: this_.edges
|
|
|
|
|
|
});
|
|
|
|
|
|
this_.network.moveTo({
|
|
|
|
|
|
position: this_.viewsCenter,
|
2020-08-24 15:42:06 +08:00
|
|
|
|
scale: this_.zoom,
|
2020-08-19 11:44:26 +08:00
|
|
|
|
offset: {x:0, y:0},
|
|
|
|
|
|
});
|
|
|
|
|
|
this.$nextTick(()=>{
|
|
|
|
|
|
this_.modelTopUpdate();
|
2020-08-27 15:23:52 +08:00
|
|
|
|
this_.arrayDiff();
|
|
|
|
|
|
this_.popDataShowUpdate();
|
2020-08-19 11:44:26 +08:00
|
|
|
|
})
|
|
|
|
|
|
},
|
|
|
|
|
|
addModel(model){ // 添加model
|
|
|
|
|
|
this.addNodeShow=false;
|
|
|
|
|
|
if(!model){return}
|
|
|
|
|
|
let nodesArray=[...this.nodesArray];
|
|
|
|
|
|
if(!this.isNodeAdd){
|
|
|
|
|
|
model={...nodesArray.find(item=>item.id===model.id),...model};
|
|
|
|
|
|
nodesArray=nodesArray.filter(item=>item.id!==model.id);
|
|
|
|
|
|
}else{
|
2020-08-24 10:56:15 +08:00
|
|
|
|
model={...model,...this.network.DOMtoCanvas({x:80,y:100})};
|
2020-08-19 11:44:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
nodesArray.push(model);
|
|
|
|
|
|
this.$emit("setTopologyData",nodesArray,this.edgesArray);
|
|
|
|
|
|
this.setNetworkData(nodesArray,this.edgesArray);
|
2020-08-26 16:01:33 +08:00
|
|
|
|
this.$nextTick(()=>{
|
|
|
|
|
|
this.arrayDiff();
|
|
|
|
|
|
this.$emit('editVisNetworkChange',true);
|
|
|
|
|
|
})
|
2020-08-19 11:44:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
addModelShow(){ // 显示添加节点弹窗
|
|
|
|
|
|
this.addNodeShow=true;
|
|
|
|
|
|
this.isNodeAdd=true;
|
|
|
|
|
|
this.nodeData={
|
|
|
|
|
|
modelId:'',
|
|
|
|
|
|
label:'',
|
|
|
|
|
|
x:'',
|
|
|
|
|
|
y:'',
|
|
|
|
|
|
image:'',
|
2020-09-02 09:38:26 +08:00
|
|
|
|
id:'',
|
2020-08-19 11:44:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
addLine(edges){ // 添加或者編輯line
|
|
|
|
|
|
this.addLineShow=false;
|
|
|
|
|
|
if(!edges){return}
|
|
|
|
|
|
let edgesArray =[...this.edgesArray];
|
|
|
|
|
|
if(!this.isLineAdd){
|
|
|
|
|
|
edges={...edgesArray.find(item=>item.id===edges.id),...edges};
|
|
|
|
|
|
edgesArray=edgesArray.filter(item=>item.id!==edges.id);
|
|
|
|
|
|
}else{
|
|
|
|
|
|
edges.from=this.NodeArr[0];
|
|
|
|
|
|
edges.to=this.NodeArr[1];
|
|
|
|
|
|
}
|
|
|
|
|
|
edgesArray.push(edges);
|
|
|
|
|
|
this.$emit("setTopologyData",this.nodesArray,edgesArray);
|
|
|
|
|
|
this.setNetworkData(this.nodesArray,edgesArray);
|
|
|
|
|
|
this.NodeArr=[];
|
|
|
|
|
|
this.NodeArrShow=false;
|
|
|
|
|
|
},
|
|
|
|
|
|
addLineTitleShow(){ // 显示添加线弹窗
|
|
|
|
|
|
// this.addLineShow=true;
|
|
|
|
|
|
this.selectNodeTitle=true;
|
|
|
|
|
|
this.NodeArrShow=true;
|
|
|
|
|
|
},
|
|
|
|
|
|
closeAddLine(){
|
|
|
|
|
|
this.selectNodeTitle=false;
|
|
|
|
|
|
this.addLineShow=false;
|
|
|
|
|
|
this.NodeArr=[];
|
|
|
|
|
|
this.NodeArrShow=false;
|
|
|
|
|
|
this.network.unselectAll();
|
|
|
|
|
|
},
|
2020-09-03 09:51:50 +08:00
|
|
|
|
closeAddNode(){
|
|
|
|
|
|
this.addNodeShow=false;
|
|
|
|
|
|
this.arrayDiff();
|
|
|
|
|
|
},
|
2020-08-19 11:44:26 +08:00
|
|
|
|
setNodePosition(selId){ // 移动节点后 设置节点坐标
|
|
|
|
|
|
let position = this.network.getPositions([selId]);
|
|
|
|
|
|
let selItem = this.nodesArray.find((item)=>item.id===selId);
|
|
|
|
|
|
this.nodeData = selItem;
|
|
|
|
|
|
selItem.x=position[selId].x;
|
|
|
|
|
|
selItem.y=position[selId].y;
|
|
|
|
|
|
this.$emit("setTopologyData",this.nodesArray,this.edgesArray);
|
|
|
|
|
|
},
|
2020-08-24 10:56:15 +08:00
|
|
|
|
setPopPosition(selId){//设置节点工具栏位置以及是否显示
|
2020-08-19 11:44:26 +08:00
|
|
|
|
if(!selId){return}
|
|
|
|
|
|
let position=this.network.canvasToDOM(this.network.getPositions([selId])[selId]);
|
|
|
|
|
|
this.networkPop.style.top = position.y - 85 + 7*(10-this.zoom*10)+'px';
|
2020-08-26 09:58:39 +08:00
|
|
|
|
this.networkPop.style.left = position.x - 32*this.zoom - 5*(1-this.zoom) +'px';
|
|
|
|
|
|
if(!this.isFullScreen&&this.NodeArr.length===0&&!this.editVisNetwork){
|
2020-08-19 11:44:26 +08:00
|
|
|
|
this.networkPopShow=true;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.NodeArr=[...this.NodeArr]
|
|
|
|
|
|
},
|
|
|
|
|
|
networkPopClose(){//关闭节点工具栏
|
|
|
|
|
|
this.networkPopShow=false;
|
2020-08-20 11:31:51 +08:00
|
|
|
|
// this.selNodeId=''
|
2020-08-26 09:58:39 +08:00
|
|
|
|
if(this.network){
|
|
|
|
|
|
this.network.unselectAll();
|
|
|
|
|
|
}
|
2020-08-19 11:44:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
//工具栏
|
|
|
|
|
|
nodeDel(){
|
|
|
|
|
|
let nodesArray=this.nodesArray.filter((item)=>item.id!==this.selNodeId);
|
2020-09-01 09:56:13 +08:00
|
|
|
|
let edgesArray=this.edgesArray.filter((item)=>!(item.from===this.selNodeId || item.to===this.selNodeId));
|
|
|
|
|
|
this.selNodeId='';
|
2020-08-19 11:44:26 +08:00
|
|
|
|
this.$emit('setTopologyData',nodesArray, edgesArray);
|
|
|
|
|
|
this.setNetworkData(nodesArray, edgesArray);
|
|
|
|
|
|
this.networkPopClose();
|
2020-08-25 15:12:29 +08:00
|
|
|
|
this.arrayDiff();
|
2020-08-19 11:44:26 +08:00
|
|
|
|
},
|
2020-09-01 15:32:46 +08:00
|
|
|
|
nodeEdit(){
|
2020-09-03 09:51:50 +08:00
|
|
|
|
this.moduleDataS.module.push(this.allModuleInfos.module.find(item=>item.id===this.selNodeId));
|
2020-09-01 15:32:46 +08:00
|
|
|
|
this.addNodeShow=true;
|
|
|
|
|
|
this.isNodeAdd=false;
|
|
|
|
|
|
},
|
2020-08-19 11:44:26 +08:00
|
|
|
|
lineDel(){
|
|
|
|
|
|
if(!this.lineData.id){return}
|
|
|
|
|
|
let edgesArray=this.edgesArray.filter((item)=>item.id!==this.lineData.id);
|
|
|
|
|
|
this.$emit('setTopologyData',this.nodesArray, edgesArray);
|
|
|
|
|
|
this.setNetworkData(this.nodesArray,edgesArray);
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
// 工具的点击 对应的操作
|
|
|
|
|
|
popClick(id){
|
2020-09-01 09:56:13 +08:00
|
|
|
|
this.lineData='';
|
2020-08-24 18:03:53 +08:00
|
|
|
|
this.popDataShowUpdate(id);
|
2020-08-19 11:44:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
modelTopUpdate(){//model上的图标 实时更新
|
|
|
|
|
|
this.modelTop=[];
|
|
|
|
|
|
this.nodesArray.forEach((item)=>{
|
|
|
|
|
|
let position=this.network.canvasToDOM({x:item.x,y:item.y});
|
|
|
|
|
|
this.modelTop.push({
|
|
|
|
|
|
show:true,
|
|
|
|
|
|
x:position.x,
|
|
|
|
|
|
y:position.y,
|
|
|
|
|
|
id:item.id,
|
|
|
|
|
|
})
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2020-08-20 14:47:14 +08:00
|
|
|
|
selNodeArrUpdate(){// 选中框位置更新
|
2020-08-19 11:44:26 +08:00
|
|
|
|
this.NodeArr.forEach((id,index)=>{
|
|
|
|
|
|
let selNode = this.nodesArray.find(item=>item.id===id);
|
|
|
|
|
|
let position=this.network.canvasToDOM({x:selNode.x,y:selNode.y});
|
|
|
|
|
|
document.getElementById('nodeArr'+(index+1)).style.top=position.y+'px';
|
|
|
|
|
|
document.getElementById('nodeArr'+(index+1)).style.left=position.x+'px';
|
|
|
|
|
|
})
|
|
|
|
|
|
},
|
2020-08-19 15:33:16 +08:00
|
|
|
|
modelTopMouseDown(e){
|
2020-08-26 09:58:39 +08:00
|
|
|
|
if(!this.index&&this.index!==0){return}
|
2020-08-19 15:33:16 +08:00
|
|
|
|
this.relativeModelTop={
|
|
|
|
|
|
x:e.clientX-(parseFloat(this.$refs['modelTopId'+this.index][0].style.left)),
|
|
|
|
|
|
y:e.clientY-(parseFloat(this.$refs['modelTopId'+this.index][0].style.top)),
|
|
|
|
|
|
};
|
|
|
|
|
|
this.$refs['network'].addEventListener('mousemove',this.modelTopMouseMove);
|
2020-08-19 11:44:26 +08:00
|
|
|
|
},
|
2020-08-26 09:58:39 +08:00
|
|
|
|
modelTopMouseUp(){
|
2020-08-19 15:33:16 +08:00
|
|
|
|
this.index='';
|
|
|
|
|
|
this.relativeModelTop={};
|
|
|
|
|
|
this.$refs['network'].removeEventListener('mousemove',this.modelTopMouseMove);
|
2020-08-19 11:44:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
modelTopMouseMove(e){
|
2020-09-04 13:53:00 +08:00
|
|
|
|
let position={
|
|
|
|
|
|
x:e.clientX-this.relativeModelTop.x,
|
|
|
|
|
|
y:e.clientY-this.relativeModelTop.y
|
|
|
|
|
|
};
|
|
|
|
|
|
this.$refs['modelTopId'+this.index][0].style.top=position.y+'px';
|
|
|
|
|
|
this.$refs['modelTopId'+this.index][0].style.left=position.x+'px';
|
|
|
|
|
|
// {top:(item.y- 80 + 5*(10-zoom*10))+'px',left:(item.x-26)+'px'
|
|
|
|
|
|
let cancvs=this.network.DOMtoCanvas({
|
|
|
|
|
|
x:position.x+26-5*(1-this.zoom),
|
|
|
|
|
|
y:position.y+80-(50*(1-this.zoom)),
|
|
|
|
|
|
});
|
|
|
|
|
|
this.network.moveNode(this.selNodeId,cancvs.x,cancvs.y);
|
|
|
|
|
|
let selItem = this.nodesArray.find((item)=>item.id===this.selNodeId);
|
|
|
|
|
|
selItem.x=cancvs.x;
|
|
|
|
|
|
selItem.y=cancvs.y;
|
|
|
|
|
|
this.$emit("setTopologyData",this.nodesArray,this.edgesArray);
|
|
|
|
|
|
if(this.networkPopShow){
|
|
|
|
|
|
this.setPopPosition(this.selNodeId);
|
|
|
|
|
|
}
|
2020-08-19 15:33:16 +08:00
|
|
|
|
},
|
|
|
|
|
|
modelTopClick(item,index){
|
|
|
|
|
|
this.index=index;
|
|
|
|
|
|
this.selNodeId=item.id;
|
2020-08-24 18:03:53 +08:00
|
|
|
|
if(this.selNodeId){
|
2020-08-24 11:22:59 +08:00
|
|
|
|
this.setPopPosition(this.selNodeId);
|
2020-08-24 18:03:53 +08:00
|
|
|
|
this.popDataShowUpdate('main')
|
2020-08-24 11:22:59 +08:00
|
|
|
|
}
|
2020-08-20 17:09:22 +08:00
|
|
|
|
},
|
|
|
|
|
|
// 数组取差集
|
|
|
|
|
|
arrayDiff(){
|
|
|
|
|
|
// this.moduleDataS=this.allModuleInfos-this.nodesArray
|
2020-08-25 15:12:29 +08:00
|
|
|
|
this.moduleDataS={...this.allModuleInfos};
|
2020-08-20 17:09:22 +08:00
|
|
|
|
this.nodesArray.forEach((item)=>{
|
|
|
|
|
|
this.moduleDataS.module=this.moduleDataS.module.filter((item1)=> item.id!==item1.id)
|
|
|
|
|
|
})
|
2020-08-24 11:22:59 +08:00
|
|
|
|
},
|
|
|
|
|
|
//工具栏点击后显示对应内容
|
2020-09-04 10:04:41 +08:00
|
|
|
|
popDataShowUpdate(key,flag){//key 显示对应的弹窗 flag是否不显示工具栏
|
2020-08-24 11:22:59 +08:00
|
|
|
|
this.popDataShow={
|
|
|
|
|
|
endpoint:false,
|
|
|
|
|
|
asset:false,
|
|
|
|
|
|
total:false,
|
|
|
|
|
|
other:false,
|
|
|
|
|
|
info:false,
|
|
|
|
|
|
alert:false,
|
|
|
|
|
|
main:false,
|
|
|
|
|
|
};
|
2020-08-24 17:04:27 +08:00
|
|
|
|
if(key&&!this.editVisNetwork){
|
2020-09-01 09:56:13 +08:00
|
|
|
|
if(key==='total'&&this.selNodeId){
|
2020-09-01 14:26:27 +08:00
|
|
|
|
this.totalId=this.selNodeId;
|
2020-09-01 09:56:13 +08:00
|
|
|
|
this.totalArray=this.nodesArray;
|
|
|
|
|
|
}
|
|
|
|
|
|
if(key==='total'&&this.lineData){
|
|
|
|
|
|
this.totalId=this.lineData.id;
|
|
|
|
|
|
this.totalArray=this.edgesArray;
|
|
|
|
|
|
}
|
2020-09-03 14:31:21 +08:00
|
|
|
|
this.$nextTick(()=>{
|
|
|
|
|
|
this.popDataShow[key]=true;
|
|
|
|
|
|
})
|
2020-08-24 11:22:59 +08:00
|
|
|
|
}
|
2020-09-04 10:04:41 +08:00
|
|
|
|
if(this.selNodeId&&!flag){
|
|
|
|
|
|
this.setPopPosition(this.selNodeId);
|
|
|
|
|
|
}
|
2020-08-24 11:22:59 +08:00
|
|
|
|
},
|
2020-09-01 14:26:27 +08:00
|
|
|
|
//拓扑图放大缩小
|
|
|
|
|
|
zoomChange(num){
|
|
|
|
|
|
this.zoom+=num;
|
|
|
|
|
|
if(this.zoom<0){//每次缩小0.1 保证缩放大于0
|
|
|
|
|
|
this.zoom=0.01;
|
|
|
|
|
|
}
|
|
|
|
|
|
this.network.moveTo({
|
|
|
|
|
|
position: this.viewsCenter,
|
|
|
|
|
|
scale: this.zoom,
|
|
|
|
|
|
offset: {x:0, y:0},
|
|
|
|
|
|
});
|
|
|
|
|
|
this.$nextTick(()=>{
|
|
|
|
|
|
this.modelTopUpdate();
|
|
|
|
|
|
this.setPopPosition(this.selNodeId);
|
|
|
|
|
|
this.popDataShowUpdate();
|
|
|
|
|
|
})
|
|
|
|
|
|
}
|
2020-08-19 11:44:26 +08:00
|
|
|
|
},
|
|
|
|
|
|
mounted(){
|
|
|
|
|
|
setTimeout(()=>{
|
|
|
|
|
|
let this_=this;
|
|
|
|
|
|
this.init('modal');
|
2020-09-03 14:31:21 +08:00
|
|
|
|
this.network.on("click", function (params) {
|
2020-08-19 11:44:26 +08:00
|
|
|
|
this_.networkPopClose();
|
2020-09-03 14:31:21 +08:00
|
|
|
|
if(!params.edges.length&&!params.nodes.length){
|
2020-09-04 10:04:41 +08:00
|
|
|
|
this_.popDataShowUpdate('',true);
|
2020-09-03 14:31:21 +08:00
|
|
|
|
}
|
2020-08-26 09:58:39 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2020-09-01 15:32:46 +08:00
|
|
|
|
this.network.on("selectNode", function (params) { //选择节点
|
2020-08-26 09:58:39 +08:00
|
|
|
|
let selId=params.nodes[0];
|
2020-08-19 11:44:26 +08:00
|
|
|
|
if(selId){
|
|
|
|
|
|
this_.selNodeId=selId;
|
|
|
|
|
|
this_.cursorMove=true;
|
2020-08-26 09:58:39 +08:00
|
|
|
|
this_.nodeData=this_.nodesArray.find((item)=>item.id===selId);
|
2020-08-19 11:44:26 +08:00
|
|
|
|
if(this_.NodeArr.indexOf(selId)!==-1){
|
2020-08-26 09:58:39 +08:00
|
|
|
|
let index = this_.NodeArr.indexOf(selId);
|
|
|
|
|
|
this_.NodeArr=this_.NodeArr.filter((item,i)=> i !== index);
|
|
|
|
|
|
return
|
2020-08-19 11:44:26 +08:00
|
|
|
|
}
|
2020-08-21 15:33:44 +08:00
|
|
|
|
if(this_.selectNodeTitle&&this_.NodeArrShow){
|
2020-08-19 11:44:26 +08:00
|
|
|
|
this_.NodeArr.push(selId);
|
|
|
|
|
|
this_.network.selectNodes(this_.NodeArr,true);
|
|
|
|
|
|
return
|
|
|
|
|
|
}
|
2020-09-02 09:38:26 +08:00
|
|
|
|
if(this_.NodeArr.length===0&&this_.editVisNetwork){
|
2020-09-01 15:32:46 +08:00
|
|
|
|
this_.nodeEdit();
|
|
|
|
|
|
}
|
2020-08-19 11:44:26 +08:00
|
|
|
|
this_.setPopPosition(selId,params);
|
2020-08-24 11:22:59 +08:00
|
|
|
|
this_.popDataShowUpdate('main');
|
2020-08-19 11:44:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.network.on("selectEdge", function (params) { // 选择边
|
2020-09-01 09:56:13 +08:00
|
|
|
|
this_.selNodeId='';
|
2020-08-21 15:33:44 +08:00
|
|
|
|
this_.lineData=this_.edgesArray.find((item)=>item.id===params.edges[0]);
|
2020-09-01 15:32:46 +08:00
|
|
|
|
if(this_.editVisNetwork){
|
|
|
|
|
|
this_.lineData.color=this_.lineData.color.color?this_.lineData.color.color:this_.lineData.color;
|
|
|
|
|
|
this_.addLineShow=true;
|
|
|
|
|
|
this_.isLineAdd=false;
|
2020-09-03 14:31:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
if(!this_.editVisNetwork){
|
|
|
|
|
|
if(this_.lineData.expressions&&this_.lineData.expressions.length){
|
|
|
|
|
|
this_.popDataShowUpdate('total')
|
|
|
|
|
|
}else{
|
|
|
|
|
|
this_.popDataShowUpdate()
|
|
|
|
|
|
}
|
2020-09-01 09:56:13 +08:00
|
|
|
|
}
|
2020-08-20 14:47:14 +08:00
|
|
|
|
// this_.lineData.color=this_.lineData.color.color;
|
|
|
|
|
|
// this_.addLineShow=true;
|
2020-08-19 11:44:26 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2020-09-07 11:34:13 +08:00
|
|
|
|
this.network.on("hoverEdge", function () { // 悬停边
|
|
|
|
|
|
this_.hoverEdge=true;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
this.network.on("blurEdge", function () { // 边失去焦点
|
|
|
|
|
|
this_.hoverEdge=false;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2020-08-19 11:44:26 +08:00
|
|
|
|
this.network.on("dragStart", function (params) {//节点移动开始
|
|
|
|
|
|
this_.NodeArrShow=false;
|
2020-08-24 10:56:15 +08:00
|
|
|
|
let selId=params.nodes[0];
|
|
|
|
|
|
if(selId){
|
|
|
|
|
|
this_.selNodeId=selId
|
|
|
|
|
|
}
|
2020-08-19 15:33:16 +08:00
|
|
|
|
// if(!selId){
|
|
|
|
|
|
// this_.modelTop.forEach(item=>{
|
|
|
|
|
|
// item.show=false;
|
|
|
|
|
|
// })
|
|
|
|
|
|
// }
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2020-09-03 14:31:21 +08:00
|
|
|
|
this.network.on("dragging", function () {//节点移动中
|
2020-08-19 15:33:16 +08:00
|
|
|
|
this_.viewsCenter=this_.network.getViewPosition();
|
2020-09-03 14:31:21 +08:00
|
|
|
|
// let selId=params.nodes[0];
|
2020-08-19 15:33:16 +08:00
|
|
|
|
if(this_.selNodeId){
|
2020-08-24 10:56:15 +08:00
|
|
|
|
this_.setNodePosition(this_.selNodeId)
|
|
|
|
|
|
}
|
|
|
|
|
|
if(this_.selNodeId&&this_.networkPopShow){
|
2020-08-19 15:33:16 +08:00
|
|
|
|
this_.setPopPosition(this_.selNodeId);
|
2020-08-19 11:44:26 +08:00
|
|
|
|
}
|
2020-08-19 15:33:16 +08:00
|
|
|
|
if(this_.NodeArr.length>0){
|
|
|
|
|
|
this_.NodeArrShow=true;
|
|
|
|
|
|
}
|
|
|
|
|
|
this_.modelTopUpdate();
|
|
|
|
|
|
this_.selNodeArrUpdate();
|
2020-08-19 11:44:26 +08:00
|
|
|
|
});
|
|
|
|
|
|
|
2020-09-03 14:31:21 +08:00
|
|
|
|
this.network.on("dragEnd", function () {//节点移动结束
|
2020-08-19 11:44:26 +08:00
|
|
|
|
this_.viewsCenter=this_.network.getViewPosition();
|
2020-08-19 15:33:16 +08:00
|
|
|
|
if(this_.selNodeId){
|
2020-08-24 10:56:15 +08:00
|
|
|
|
this_.setNodePosition(this_.selNodeId)
|
|
|
|
|
|
}
|
|
|
|
|
|
if(this_.selNodeId&&this_.networkPopShow){
|
2020-08-19 15:33:16 +08:00
|
|
|
|
this_.setPopPosition(this_.selNodeId);
|
|
|
|
|
|
}
|
2020-08-19 11:44:26 +08:00
|
|
|
|
if(this_.NodeArr.length>0){
|
|
|
|
|
|
this_.NodeArrShow=true;
|
|
|
|
|
|
}
|
|
|
|
|
|
this_.modelTopUpdate();
|
|
|
|
|
|
this_.selNodeArrUpdate();
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2020-09-03 14:31:21 +08:00
|
|
|
|
this.network.on("hoverNode", function () {//hoverNode
|
2020-08-19 11:44:26 +08:00
|
|
|
|
this_.cursorMove=true;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2020-09-03 14:31:21 +08:00
|
|
|
|
this.network.on("blurNode", function () {//blurNode
|
2020-08-19 11:44:26 +08:00
|
|
|
|
this_.cursorMove=false;
|
|
|
|
|
|
});
|
2020-09-03 14:31:21 +08:00
|
|
|
|
this.network.on("hoverEdge", function () {//hoverNode
|
2020-08-27 18:00:03 +08:00
|
|
|
|
this_.cursorMove=true;
|
|
|
|
|
|
});
|
|
|
|
|
|
|
2020-09-03 14:31:21 +08:00
|
|
|
|
this.network.on("blurEdge", function () {//blurNode
|
2020-08-27 18:00:03 +08:00
|
|
|
|
this_.cursorMove=false;
|
|
|
|
|
|
});
|
2020-08-19 11:44:26 +08:00
|
|
|
|
|
|
|
|
|
|
this.network.on("zoom", function (params) {//检测缩放
|
|
|
|
|
|
this_.zoom=params.scale;
|
|
|
|
|
|
this_.modelTopUpdate();
|
|
|
|
|
|
this_.selNodeArrUpdate();
|
2020-08-19 15:33:16 +08:00
|
|
|
|
if(this_.networkPopShow){
|
|
|
|
|
|
this_.setPopPosition(this_.selNodeId);
|
|
|
|
|
|
}
|
2020-08-19 11:44:26 +08:00
|
|
|
|
return false
|
|
|
|
|
|
});
|
2020-09-07 11:34:13 +08:00
|
|
|
|
this.network.on("resize", function (params,a) {//检测resize
|
|
|
|
|
|
|
2020-08-20 09:40:15 +08:00
|
|
|
|
setTimeout(()=>{
|
2020-09-07 11:34:13 +08:00
|
|
|
|
this_.zoom=this_.network.canvasToDOM({x:0,y:1}).y-this_.network.canvasToDOM({x:0,y:0}).y;
|
2020-08-20 09:40:15 +08:00
|
|
|
|
this_.modelTopUpdate();
|
|
|
|
|
|
this_.selNodeArrUpdate();
|
|
|
|
|
|
if(this_.networkPopShow){
|
|
|
|
|
|
this_.setPopPosition(this_.selNodeId);
|
|
|
|
|
|
}
|
2020-09-03 14:31:21 +08:00
|
|
|
|
});
|
2020-08-20 09:40:15 +08:00
|
|
|
|
return false
|
|
|
|
|
|
});
|
2020-08-19 11:44:26 +08:00
|
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
.content{
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.edit-topology{
|
2020-08-19 11:44:26 +08:00
|
|
|
|
width: 100%;
|
|
|
|
|
|
height: 28px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.network{
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
height: calc(100% - 30px);
|
|
|
|
|
|
position: relative;
|
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.network-pop{
|
2020-08-19 11:44:26 +08:00
|
|
|
|
position: absolute;
|
|
|
|
|
|
z-index: 10;
|
|
|
|
|
|
/*border: 1px solid #e6e6e6;*/
|
|
|
|
|
|
border-radius: 5px;
|
|
|
|
|
|
height: 32px;
|
|
|
|
|
|
/*background: #fff;*/
|
|
|
|
|
|
padding: 0 3px;
|
|
|
|
|
|
line-height: 32px;
|
2020-08-24 17:04:27 +08:00
|
|
|
|
|
2020-08-19 11:44:26 +08:00
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.network-pop .nz-icon-hexagonBorder{
|
2020-08-19 11:44:26 +08:00
|
|
|
|
position: absolute;
|
|
|
|
|
|
font-size: 48px;
|
|
|
|
|
|
color: #84d5c2;
|
|
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.network-pop .nz-icon-liubianxing{
|
2020-08-19 11:44:26 +08:00
|
|
|
|
color:#e2f3ef;
|
|
|
|
|
|
font-size: 44px;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
left: 2px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.nz-icon.noMove{
|
|
|
|
|
|
position: absolute;
|
2020-09-03 14:31:21 +08:00
|
|
|
|
top: 0;
|
2020-08-19 11:44:26 +08:00
|
|
|
|
left: 14px;
|
|
|
|
|
|
font-size: 20px;
|
|
|
|
|
|
color: #27c09c;
|
|
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.network-pop .nz-icon-hexagonBorder:hover{
|
2020-08-19 11:44:26 +08:00
|
|
|
|
transform: scale(1.2);
|
|
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.network-pop .nz-icon-hexagonBorder:hover .nz-icon-liubianxing{
|
2020-08-19 11:44:26 +08:00
|
|
|
|
transform: scale(1.1);
|
|
|
|
|
|
left: 4px;
|
|
|
|
|
|
font-size: 41px;
|
2020-09-03 09:51:50 +08:00
|
|
|
|
color: #D7FAF1;
|
|
|
|
|
|
top: -1px;
|
2020-08-19 11:44:26 +08:00
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.network-pop .nz-icon-hexagonBorder:hover .noMove{
|
2020-08-19 11:44:26 +08:00
|
|
|
|
transform: scale(1.1);
|
|
|
|
|
|
}
|
2020-09-03 14:31:21 +08:00
|
|
|
|
/*.btmTriangle{*/
|
|
|
|
|
|
/*position: absolute;*/
|
|
|
|
|
|
/*width: 0;*/
|
|
|
|
|
|
/*height: 0;*/
|
|
|
|
|
|
/*border-width: 10px;*/
|
|
|
|
|
|
/*border-style: solid;*/
|
|
|
|
|
|
/*border-color:#e6e6e6 transparent transparent transparent;*/
|
|
|
|
|
|
/*bottom: -20px;*/
|
|
|
|
|
|
/*left: 50%;*/
|
|
|
|
|
|
/*transform: translateX(-50%);*/
|
|
|
|
|
|
/*}*/
|
|
|
|
|
|
/*.btmTriangle:after{*/
|
|
|
|
|
|
/*content: '';*/
|
|
|
|
|
|
/*display:block;*/
|
|
|
|
|
|
/*width:0;*/
|
|
|
|
|
|
/*height:0;*/
|
|
|
|
|
|
/*border-width: 10px;*/
|
|
|
|
|
|
/*border-style:solid;*/
|
|
|
|
|
|
/*border-color:#fff transparent transparent transparent;*/
|
|
|
|
|
|
/*position:absolute;*/
|
|
|
|
|
|
/*bottom: -7px;*/
|
|
|
|
|
|
/*left: -9px;*/
|
|
|
|
|
|
/*}*/
|
2020-08-20 11:31:51 +08:00
|
|
|
|
#network_id,.network-null{
|
|
|
|
|
|
width: 100%;
|
2020-08-19 11:44:26 +08:00
|
|
|
|
height: 100%;
|
|
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.network-null{
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
flex-direction: column;
|
|
|
|
|
|
justify-content: center;
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
}
|
|
|
|
|
|
.network-null .nz-icon-add-node{
|
|
|
|
|
|
color: #23BF9A;
|
|
|
|
|
|
font-size: 50px;
|
|
|
|
|
|
margin-bottom: 24px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
2020-08-19 11:44:26 +08:00
|
|
|
|
.cursorMove{
|
|
|
|
|
|
cursor: move;
|
|
|
|
|
|
}
|
|
|
|
|
|
#network_id2{
|
|
|
|
|
|
height: 100%;
|
|
|
|
|
|
}
|
|
|
|
|
|
.networkContent{
|
|
|
|
|
|
width: 40%;
|
|
|
|
|
|
}
|
|
|
|
|
|
.nz-icon-delete{
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
color: #ee6723;
|
|
|
|
|
|
margin-left: 10px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.nz-icon-edit{
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.edit-topology{
|
2020-08-19 11:44:26 +08:00
|
|
|
|
color: #1a1a1a;
|
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
|
font-weight: bold;
|
2020-08-20 11:31:51 +08:00
|
|
|
|
height: 28px;
|
2020-08-19 11:44:26 +08:00
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.edit-topology-module,.edit-topology-line-cancel{
|
2020-08-19 11:44:26 +08:00
|
|
|
|
margin-left: 30px;
|
|
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.edit-topologyLine{
|
2020-09-02 09:38:26 +08:00
|
|
|
|
margin-left: 60px;
|
2020-08-19 11:44:26 +08:00
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.edit-topology-add,.edit-topology-remove,.edit-topologyCancel{
|
2020-08-19 11:44:26 +08:00
|
|
|
|
color: #1989fa;
|
|
|
|
|
|
margin-left: 30px;
|
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.sel-node{
|
2020-08-19 11:44:26 +08:00
|
|
|
|
position: absolute;
|
|
|
|
|
|
width: 0;
|
|
|
|
|
|
height: 0;
|
|
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.sel-node-top {
|
2020-08-19 11:44:26 +08:00
|
|
|
|
width: 120px;
|
|
|
|
|
|
height: 0;
|
2020-09-04 13:53:00 +08:00
|
|
|
|
border-top: 4px dashed #FF8C0A;
|
2020-08-19 11:44:26 +08:00
|
|
|
|
position: absolute;
|
|
|
|
|
|
left: -60px;
|
|
|
|
|
|
top: -60px;
|
|
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.sel-node-right {
|
2020-09-03 14:31:21 +08:00
|
|
|
|
width: 0;
|
2020-08-19 11:44:26 +08:00
|
|
|
|
height: 120px;
|
2020-09-04 13:53:00 +08:00
|
|
|
|
border-right: 4px dashed #FF8C0A;
|
2020-08-19 11:44:26 +08:00
|
|
|
|
position: absolute;
|
|
|
|
|
|
left: 60px;
|
|
|
|
|
|
top: -60px;
|
|
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.sel-node-bottom {
|
2020-08-19 11:44:26 +08:00
|
|
|
|
width: 120px;
|
|
|
|
|
|
height: 0;
|
2020-09-04 13:53:00 +08:00
|
|
|
|
border-bottom: 4px dashed #FF8C0A;
|
2020-08-19 11:44:26 +08:00
|
|
|
|
position: absolute;
|
|
|
|
|
|
left: -60px;
|
|
|
|
|
|
top: 60px;
|
|
|
|
|
|
}
|
2020-08-20 11:31:51 +08:00
|
|
|
|
.sel-node-left {
|
2020-09-03 14:31:21 +08:00
|
|
|
|
width: 0;
|
2020-08-19 11:44:26 +08:00
|
|
|
|
height: 120px;
|
2020-09-04 13:53:00 +08:00
|
|
|
|
border-left: 4px dashed #FF8C0A;
|
2020-08-19 11:44:26 +08:00
|
|
|
|
position: absolute;
|
|
|
|
|
|
left: -60px;
|
|
|
|
|
|
top: -60px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.nz-icon-shuidi{
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
font-size: 48px;
|
2020-09-08 14:15:48 +08:00
|
|
|
|
color: rgba(190,233,222,0.45);
|
2020-09-03 09:51:50 +08:00
|
|
|
|
border-radius: 50%;
|
|
|
|
|
|
height: 60px;
|
|
|
|
|
|
width: 38px;
|
2020-08-19 11:44:26 +08:00
|
|
|
|
}
|
|
|
|
|
|
.nz-icon-model{
|
|
|
|
|
|
color: #23BF9A;
|
|
|
|
|
|
position: absolute;
|
2020-09-08 14:15:48 +08:00
|
|
|
|
top: 17px;
|
2020-08-19 11:44:26 +08:00
|
|
|
|
left: 15px;
|
|
|
|
|
|
font-size: 18px;
|
|
|
|
|
|
}
|
2020-08-20 14:47:14 +08:00
|
|
|
|
.network-info{
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
right: 0;
|
|
|
|
|
|
top: 0;
|
|
|
|
|
|
}
|
2020-08-24 15:02:23 +08:00
|
|
|
|
.saveTopology{
|
2020-09-01 15:32:46 +08:00
|
|
|
|
background-image: linear-gradient(180deg, #F5B93E 0%, #EE9D3F 100%);
|
2020-08-24 15:02:23 +08:00
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
color: #FFFFFF;
|
|
|
|
|
|
padding: 4px 14px;
|
|
|
|
|
|
}
|
2020-09-01 15:32:46 +08:00
|
|
|
|
.cancelTopology{
|
|
|
|
|
|
background-image: linear-gradient(180deg, #F0F0F0 0%, #D8D8D8 99%);
|
|
|
|
|
|
border-radius: 4px;
|
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
|
color: #333333;
|
|
|
|
|
|
padding: 4px 14px;
|
|
|
|
|
|
}
|
2020-09-01 14:26:27 +08:00
|
|
|
|
.network-zoom{
|
|
|
|
|
|
position: absolute;
|
|
|
|
|
|
bottom: 15px;
|
|
|
|
|
|
right: 15px;
|
|
|
|
|
|
}
|
|
|
|
|
|
.zoom-icon{
|
|
|
|
|
|
font-size: 42px;
|
|
|
|
|
|
}
|
2020-08-19 11:44:26 +08:00
|
|
|
|
</style>
|