Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
IT-monitor
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张伯涛
IT-monitor
Commits
dcd8109d
Commit
dcd8109d
authored
May 30, 2022
by
Asjoker
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 拓扑图 - 自适应高宽 & 标签页图标修改
parent
f42530d5
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
292 additions
and
284 deletions
+292
-284
click-event-edit.js
packages/cc-topology/src/behavior/click-event-edit.js
+31
-31
cc-topology.vue
packages/cc-topology/src/cc-topology.vue
+256
-251
index.html
public/index.html
+1
-1
rongchuanglogo.png
public/rongchuanglogo.png
+0
-0
topology.vue
src/views/demos/topology.vue
+4
-1
No files found.
packages/cc-topology/src/behavior/click-event-edit.js
View file @
dcd8109d
...
@@ -16,7 +16,7 @@ export default {
...
@@ -16,7 +16,7 @@ export default {
sendThis
,
// 暴露函数
sendThis
,
// 暴露函数
name
:
'click-event-edit'
,
name
:
'click-event-edit'
,
options
:
{
options
:
{
getEvents
()
{
getEvents
()
{
return
{
return
{
'node:click'
:
'onNodeClick'
,
'node:click'
:
'onNodeClick'
,
'node:contextmenu'
:
'onNodeRightClick'
,
'node:contextmenu'
:
'onNodeRightClick'
,
...
@@ -27,7 +27,7 @@ export default {
...
@@ -27,7 +27,7 @@ export default {
'canvas:click'
:
'onCanvasClick'
'canvas:click'
:
'onCanvasClick'
}
}
},
},
onNodeClick
(
event
)
{
onNodeClick
(
event
)
{
// todo..."selected"是g6自带的状态,在"drag-add-edge"中的"node:mouseup"事件也会触发,故此处不需要设置"selected"状态
// todo..."selected"是g6自带的状态,在"drag-add-edge"中的"node:mouseup"事件也会触发,故此处不需要设置"selected"状态
// let clickNode = event.item;
// let clickNode = event.item;
// clickNode.setState('selected', !clickNode.hasState('selected'));
// clickNode.setState('selected', !clickNode.hasState('selected'));
...
@@ -35,19 +35,19 @@ export default {
...
@@ -35,19 +35,19 @@ export default {
vm
.
rightMenuShow
=
false
vm
.
rightMenuShow
=
false
this
.
updateVmData
(
event
)
this
.
updateVmData
(
event
)
},
},
onNodeRightClick
(
event
)
{
onNodeRightClick
(
event
)
{
le
t
graph
=
vm
.
graph
cons
t
graph
=
vm
.
graph
le
t
clickNode
=
event
.
item
cons
t
clickNode
=
event
.
item
le
t
clickNodeModel
=
clickNode
.
getModel
()
cons
t
clickNodeModel
=
clickNode
.
getModel
()
le
t
selectedNodes
=
graph
.
findAllByState
(
'node'
,
'selected'
)
cons
t
selectedNodes
=
graph
.
findAllByState
(
'node'
,
'selected'
)
le
t
selectedNodeIds
=
selectedNodes
.
map
(
item
=>
{
cons
t
selectedNodeIds
=
selectedNodes
.
map
(
item
=>
{
return
item
.
getModel
().
id
return
item
.
getModel
().
id
})
})
vm
.
selectedNode
=
clickNode
vm
.
selectedNode
=
clickNode
// 如果当前点击节点是之前选中的某个节点,就进行下面的处理
// 如果当前点击节点是之前选中的某个节点,就进行下面的处理
if
(
selectedNodes
.
length
>
1
&&
selectedNodeIds
.
indexOf
(
clickNodeModel
.
id
)
>
-
1
)
{
if
(
selectedNodes
.
length
>
1
&&
selectedNodeIds
.
indexOf
(
clickNodeModel
.
id
)
>
-
1
)
{
vm
.
rightMenuShow
=
true
vm
.
rightMenuShow
=
true
le
t
rightMenu
=
vm
.
$refs
.
rightMenu
cons
t
rightMenu
=
vm
.
$refs
.
rightMenu
rightMenu
.
style
.
left
=
event
.
clientX
+
'px'
rightMenu
.
style
.
left
=
event
.
clientX
+
'px'
rightMenu
.
style
.
top
=
event
.
clientY
+
'px'
rightMenu
.
style
.
top
=
event
.
clientY
+
'px'
}
else
{
}
else
{
...
@@ -64,17 +64,17 @@ export default {
...
@@ -64,17 +64,17 @@ export default {
}
}
graph
.
paint
()
graph
.
paint
()
},
},
onEdgeClick
(
event
)
{
onEdgeClick
(
event
)
{
le
t
clickEdge
=
event
.
item
cons
t
clickEdge
=
event
.
item
clickEdge
.
setState
(
'selected'
,
!
clickEdge
.
hasState
(
'selected'
))
clickEdge
.
setState
(
'selected'
,
!
clickEdge
.
hasState
(
'selected'
))
vm
.
currentFocus
=
'edge'
vm
.
currentFocus
=
'edge'
this
.
updateVmData
(
event
)
this
.
updateVmData
(
event
)
},
},
onEdgeRightClick
(
event
)
{
onEdgeRightClick
(
event
)
{
le
t
graph
=
vm
.
graph
cons
t
graph
=
vm
.
graph
le
t
clickEdge
=
event
.
item
cons
t
clickEdge
=
event
.
item
le
t
clickEdgeModel
=
clickEdge
.
getModel
()
cons
t
clickEdgeModel
=
clickEdge
.
getModel
()
le
t
selectedEdges
=
graph
.
findAllByState
(
'edge'
,
'selected'
)
cons
t
selectedEdges
=
graph
.
findAllByState
(
'edge'
,
'selected'
)
// 如果当前点击节点不是之前选中的单个节点,才进行下面的处理
// 如果当前点击节点不是之前选中的单个节点,才进行下面的处理
if
(
!
(
selectedEdges
.
length
===
1
&&
clickEdgeModel
.
id
===
selectedEdges
[
0
].
getModel
().
id
))
{
if
(
!
(
selectedEdges
.
length
===
1
&&
clickEdgeModel
.
id
===
selectedEdges
[
0
].
getModel
().
id
))
{
// 先取消所有节点的选中状态
// 先取消所有节点的选中状态
...
@@ -88,31 +88,31 @@ export default {
...
@@ -88,31 +88,31 @@ export default {
}
}
// let point = { x: event.x, y: event.y }
// let point = { x: event.x, y: event.y }
},
},
onComboClick
(
event
)
{
onComboClick
(
event
)
{
vm
.
currentFocus
=
'combo'
vm
.
currentFocus
=
'combo'
this
.
updateVmData
(
event
)
this
.
updateVmData
(
event
)
},
},
onComboRightClick
(
event
)
{
onComboRightClick
(
event
)
{
vm
.
rightMenuShow
=
true
vm
.
rightMenuShow
=
true
le
t
rightMenu
=
vm
.
$refs
.
rightMenu
cons
t
rightMenu
=
vm
.
$refs
.
rightMenu
rightMenu
.
style
.
left
=
event
.
clientX
+
'px'
rightMenu
.
style
.
left
=
event
.
clientX
+
'px'
rightMenu
.
style
.
top
=
event
.
clientY
+
'px'
rightMenu
.
style
.
top
=
event
.
clientY
+
'px'
vm
.
currentFocus
=
'combo'
vm
.
currentFocus
=
'combo'
this
.
updateVmData
(
event
)
this
.
updateVmData
(
event
)
},
},
onCanvasClick
()
{
onCanvasClick
()
{
vm
.
currentFocus
=
'canvas'
vm
.
currentFocus
=
'canvas'
vm
.
rightMenuShow
=
false
vm
.
rightMenuShow
=
false
},
},
updateVmData
(
event
)
{
updateVmData
(
event
)
{
if
(
event
.
item
.
_cfg
.
type
===
'node'
)
{
if
(
event
.
item
.
_cfg
.
type
===
'node'
)
{
// 更新vm的data: selectedNode 和 selectedNodeParams
// 更新vm的data: selectedNode 和 selectedNodeParams
le
t
clickNode
=
event
.
item
cons
t
clickNode
=
event
.
item
if
(
clickNode
.
hasState
(
'selected'
))
{
if
(
clickNode
.
hasState
(
'selected'
))
{
le
t
clickNodeModel
=
clickNode
.
getModel
()
cons
t
clickNodeModel
=
clickNode
.
getModel
()
vm
.
selectedNode
=
clickNode
vm
.
selectedNode
=
clickNode
le
t
nodeAppConfig
=
{
...
vm
.
nodeAppConfig
}
cons
t
nodeAppConfig
=
{
...
vm
.
nodeAppConfig
}
Object
.
keys
(
nodeAppConfig
).
forEach
(
function
(
key
)
{
Object
.
keys
(
nodeAppConfig
).
forEach
(
function
(
key
)
{
nodeAppConfig
[
key
]
=
''
nodeAppConfig
[
key
]
=
''
})
})
vm
.
selectedNodeParams
=
{
vm
.
selectedNodeParams
=
{
...
@@ -122,12 +122,12 @@ export default {
...
@@ -122,12 +122,12 @@ export default {
}
}
}
else
if
(
event
.
item
.
_cfg
.
type
===
'edge'
)
{
}
else
if
(
event
.
item
.
_cfg
.
type
===
'edge'
)
{
// 更新vm的data: selectedEdge 和 selectedEdgeParams
// 更新vm的data: selectedEdge 和 selectedEdgeParams
le
t
clickEdge
=
event
.
item
cons
t
clickEdge
=
event
.
item
if
(
clickEdge
.
hasState
(
'selected'
))
{
if
(
clickEdge
.
hasState
(
'selected'
))
{
le
t
clickEdgeModel
=
clickEdge
.
getModel
()
cons
t
clickEdgeModel
=
clickEdge
.
getModel
()
vm
.
selectedEdge
=
clickEdge
vm
.
selectedEdge
=
clickEdge
le
t
edgeAppConfig
=
{
...
vm
.
edgeAppConfig
}
cons
t
edgeAppConfig
=
{
...
vm
.
edgeAppConfig
}
Object
.
keys
(
edgeAppConfig
).
forEach
(
function
(
key
)
{
Object
.
keys
(
edgeAppConfig
).
forEach
(
function
(
key
)
{
edgeAppConfig
[
key
]
=
''
edgeAppConfig
[
key
]
=
''
})
})
vm
.
selectedEdgeParams
=
{
vm
.
selectedEdgeParams
=
{
...
@@ -137,8 +137,8 @@ export default {
...
@@ -137,8 +137,8 @@ export default {
}
}
}
else
if
(
event
.
item
.
_cfg
.
type
===
'combo'
)
{
}
else
if
(
event
.
item
.
_cfg
.
type
===
'combo'
)
{
// 更新vm的data: selectedCombo 和 selectedComboParams
// 更新vm的data: selectedCombo 和 selectedComboParams
le
t
clickCombo
=
event
.
item
cons
t
clickCombo
=
event
.
item
le
t
clickComboModel
=
clickCombo
.
getModel
()
cons
t
clickComboModel
=
clickCombo
.
getModel
()
vm
.
selectedCombo
=
clickCombo
vm
.
selectedCombo
=
clickCombo
vm
.
selectedComboParams
=
{
vm
.
selectedComboParams
=
{
label
:
clickComboModel
.
label
||
''
,
label
:
clickComboModel
.
label
||
''
,
...
...
packages/cc-topology/src/cc-topology.vue
View file @
dcd8109d
<
template
>
<
template
>
<div
class=
"topology"
v-loading=
"loading
"
>
<div
v-loading=
"loading"
class=
"topology
"
>
<!-- container -->
<!-- container -->
<el-row
:class=
"graphBg"
style=
"height: 100%"
@
contextmenu
.
native
.
prevent
>
<el-row
:class=
"graphBg"
style=
"height: 100%"
@
contextmenu
.
native
.
prevent
>
<!-- toolbar -->
<!-- toolbar -->
<div
v-if=
"toolbarShow && graphMode === 'edit'"
>
<div
v-if=
"toolbarShow && graphMode === 'edit'"
>
<toolbar-edit
></toolbar-edit
>
<toolbar-edit
/
>
</div>
</div>
<div
v-else-if=
"toolbarShow"
>
<div
v-else-if=
"toolbarShow"
>
<toolbar-preview
ref=
"toolbarPreview"
></toolbar-preview
>
<toolbar-preview
ref=
"toolbarPreview"
/
>
</div>
</div>
<!-- graph-container -->
<!-- graph-container -->
<el-col
class=
"graph-container"
:span=
"graphMode === 'edit' && graphPanelShow === true ? 19 : 24"
<el-col
ref=
"graphContainer"
>
ref=
"graphContainer"
<div
id=
"mount-topology"
@
dragenter=
"dragenterHandler"
@
dragover=
"dragoverHandler"
@
drop=
"dropHandler"
></div>
class=
"graph-container"
<div
class=
"right-menu"
ref=
"rightMenu"
v-show=
"rightMenuShow"
@
contextmenu
.
prevent
>
:span=
"graphMode === 'edit' && graphPanelShow === true ? 19 : 24"
>
<div
id=
"mount-topology"
@
dragenter=
"dragenterHandler"
@
dragover=
"dragoverHandler"
@
drop=
"dropHandler"
/>
<div
v-show=
"rightMenuShow"
ref=
"rightMenu"
class=
"right-menu"
@
contextmenu
.
prevent
>
<ul
v-if=
"currentFocus === 'node' && selectedNodes.length > 1"
>
<ul
v-if=
"currentFocus === 'node' && selectedNodes.length > 1"
>
<li
@
click=
"alignHandler('horizontal')"
>
水平对齐
</li>
<li
@
click=
"alignHandler('horizontal')"
>
水平对齐
</li>
<li
@
click=
"alignHandler('vertical')"
>
垂直对齐
</li>
<li
@
click=
"alignHandler('vertical')"
>
垂直对齐
</li>
...
@@ -25,16 +28,16 @@
...
@@ -25,16 +28,16 @@
</div>
</div>
</el-col>
</el-col>
<!-- graph-pannel -->
<!-- graph-pannel -->
<el-col
class=
"graph-pannel"
v-if=
"graphMode === 'edit' && graphPanelShow === true
"
:span=
"5"
>
<el-col
v-if=
"graphMode === 'edit' && graphPanelShow === true"
class=
"graph-pannel
"
:span=
"5"
>
<div
v-if=
"currentFocus === 'node'"
>
<div
v-if=
"currentFocus === 'node'"
>
<div
class=
"pannel-title"
>
节点
</div>
<div
class=
"pannel-title"
>
节点
</div>
<div
class=
"pannel-body"
>
<div
class=
"pannel-body"
>
<span>
节点标签
</span>
<span>
节点标签
</span>
<el-input
class=
"params-input"
v-model=
"selectedNodeParams.label"
size=
"mini"
></el-input
>
<el-input
v-model=
"selectedNodeParams.label"
class=
"params-input"
size=
"mini"
/
>
<!--
<input
class=
"params-input"
type=
"text"
autocomplete=
"off"
v-model=
"selectedNodeParams.label"
/>
-->
<!--
<input
class=
"params-input"
type=
"text"
autocomplete=
"off"
v-model=
"selectedNodeParams.label"
/>
-->
<div
v-for=
"(value, key) in nodeAppConfig"
:key=
"key"
>
<div
v-for=
"(value, key) in nodeAppConfig"
:key=
"key"
>
<span>
{{
value
}}
</span>
<span>
{{
value
}}
</span>
<el-input
class=
"params-input"
v-model=
"selectedNodeParams.appConfig[key]"
size=
"mini"
></el-input
>
<el-input
v-model=
"selectedNodeParams.appConfig[key]"
class=
"params-input"
size=
"mini"
/
>
<!--
<input
class=
"params-input"
type=
"text"
autocomplete=
"off"
v-model=
"selectedNodeParams.appConfig[key]"
/>
-->
<!--
<input
class=
"params-input"
type=
"text"
autocomplete=
"off"
v-model=
"selectedNodeParams.appConfig[key]"
/>
-->
</div>
</div>
</div>
</div>
...
@@ -43,11 +46,11 @@
...
@@ -43,11 +46,11 @@
<div
class=
"pannel-title"
>
连线
</div>
<div
class=
"pannel-title"
>
连线
</div>
<div
class=
"pannel-body"
>
<div
class=
"pannel-body"
>
<span>
连线标签
</span>
<span>
连线标签
</span>
<el-input
class=
"params-input"
v-model=
"selectedEdgeParams.label"
size=
"mini"
></el-input
>
<el-input
v-model=
"selectedEdgeParams.label"
class=
"params-input"
size=
"mini"
/
>
<!--
<input
class=
"params-input"
type=
"text"
autocomplete=
"off"
v-model=
"selectedEdgeParams.label"
/>
-->
<!--
<input
class=
"params-input"
type=
"text"
autocomplete=
"off"
v-model=
"selectedEdgeParams.label"
/>
-->
<div
v-for=
"(value, key) in edgeAppConfig"
:key=
"key"
>
<div
v-for=
"(value, key) in edgeAppConfig"
:key=
"key"
>
<span>
{{
value
}}
</span>
<span>
{{
value
}}
</span>
<el-input
class=
"params-input"
v-model=
"selectedEdgeParams.appConfig[key]"
size=
"mini"
></el-input
>
<el-input
v-model=
"selectedEdgeParams.appConfig[key]"
class=
"params-input"
size=
"mini"
/
>
<!--
<input
class=
"params-input"
type=
"text"
autocomplete=
"off"
v-model=
"selectedEdgeParams.appConfig[key]"
/>
-->
<!--
<input
class=
"params-input"
type=
"text"
autocomplete=
"off"
v-model=
"selectedEdgeParams.appConfig[key]"
/>
-->
</div>
</div>
</div>
</div>
...
@@ -56,39 +59,39 @@
...
@@ -56,39 +59,39 @@
<div
class=
"pannel-title"
>
分组
</div>
<div
class=
"pannel-title"
>
分组
</div>
<div
class=
"pannel-body"
>
<div
class=
"pannel-body"
>
<span>
分组标签
</span>
<span>
分组标签
</span>
<el-input
class=
"params-input"
v-model=
"selectedComboParams.label"
size=
"mini"
></el-input
>
<el-input
v-model=
"selectedComboParams.label"
class=
"params-input"
size=
"mini"
/
>
<span>
标签位置
</span>
<span>
标签位置
</span>
<el-select
class=
"params-select"
v-model=
"selectedComboParams.labelPosition
"
placeholder=
"请选择"
size=
"mini"
>
<el-select
v-model=
"selectedComboParams.labelPosition"
class=
"params-select
"
placeholder=
"请选择"
size=
"mini"
>
<el-option
label=
"top"
value=
"top"
></el-option
>
<el-option
label=
"top"
value=
"top"
/
>
<el-option
label=
"left"
value=
"left"
></el-option
>
<el-option
label=
"left"
value=
"left"
/
>
<el-option
label=
"right"
value=
"right"
></el-option
>
<el-option
label=
"right"
value=
"right"
/
>
<el-option
label=
"bottom"
value=
"bottom"
></el-option
>
<el-option
label=
"bottom"
value=
"bottom"
/
>
<el-option
label=
"center"
value=
"center"
></el-option
>
<el-option
label=
"center"
value=
"center"
/
>
</el-select>
</el-select>
<span>
水平偏移
</span>
<span>
水平偏移
</span>
<el-input-number
<el-input-number
class=
"params-input-number"
v-model=
"selectedComboParams.labelRefX"
v-model=
"selectedComboParams.labelRefX"
class=
"params-input-number"
:controls=
"false"
:controls=
"false"
:min=
"-100"
:min=
"-100"
:max=
"100"
:max=
"100"
label=
"标签水平方向偏移"
label=
"标签水平方向偏移"
size=
"mini"
>
size=
"mini"
</el-input-number
>
/
>
<span>
垂直偏移
</span>
<span>
垂直偏移
</span>
<el-input-number
<el-input-number
class=
"params-input-number"
v-model=
"selectedComboParams.labelRefY"
v-model=
"selectedComboParams.labelRefY"
class=
"params-input-number"
:controls=
"false"
:controls=
"false"
:min=
"-100"
:min=
"-100"
:max=
"100"
:max=
"100"
label=
"标签水平方向偏移"
label=
"标签水平方向偏移"
size=
"mini"
>
size=
"mini"
</el-input-number
>
/
>
<span>
分组形状
</span>
<span>
分组形状
</span>
<el-select
class=
"params-select"
v-model=
"selectedComboParams.type
"
placeholder=
"请选择"
size=
"mini"
>
<el-select
v-model=
"selectedComboParams.type"
class=
"params-select
"
placeholder=
"请选择"
size=
"mini"
>
<el-option
label=
"circle"
value=
"circle"
></el-option
>
<el-option
label=
"circle"
value=
"circle"
/
>
<el-option
label=
"rect"
value=
"rect"
></el-option
>
<el-option
label=
"rect"
value=
"rect"
/
>
</el-select>
</el-select>
</div>
</div>
</div>
</div>
...
@@ -96,16 +99,18 @@
...
@@ -96,16 +99,18 @@
<div
class=
"pannel-title"
>
画布
</div>
<div
class=
"pannel-title"
>
画布
</div>
<div
class=
"pannel-body"
>
<div
class=
"pannel-body"
>
<div
<div
class=
"node-type"
v-for=
"nodeType in nodeTypeList"
v-for=
"nodeType in nodeTypeList"
:key=
"nodeType.guid"
>
:key=
"nodeType.guid"
class=
"node-type"
>
<img
<img
:src=
"nodeType.imgSrc"
:src=
"nodeType.imgSrc"
:alt=
"nodeType.label"
:alt=
"nodeType.label"
:title=
"nodeType.desc"
:title=
"nodeType.desc"
draggable=
"true"
draggable=
"true"
@
dragstart=
"dragstartHandler($event, nodeType)"
@
dragstart=
"dragstartHandler($event, nodeType)"
@
dragend=
"dragendHandler"
>
@
dragend=
"dragendHandler"
>
<label>
{{
nodeType
.
label
}}
</label>
<label>
{{
nodeType
.
label
}}
</label>
</div>
</div>
</div>
</div>
...
@@ -183,7 +188,7 @@ export default {
...
@@ -183,7 +188,7 @@ export default {
}
}
}
}
},
},
data
()
{
data
()
{
return
{
return
{
graphPanelShow
:
true
,
graphPanelShow
:
true
,
graphBg
:
'default-style'
,
graphBg
:
'default-style'
,
...
@@ -240,32 +245,32 @@ export default {
...
@@ -240,32 +245,32 @@ export default {
}
}
},
},
computed
:
{
computed
:
{
disableUndo
:
function
()
{
disableUndo
:
function
()
{
return
this
.
historyIndex
===
0
||
this
.
historyIndex
-
(
this
.
undoCount
+
1
)
<
0
return
this
.
historyIndex
===
0
||
this
.
historyIndex
-
(
this
.
undoCount
+
1
)
<
0
},
},
disableRedo
:
function
()
{
disableRedo
:
function
()
{
return
this
.
historyIndex
===
0
||
this
.
historyIndex
===
10
||
this
.
undoCount
<
1
return
this
.
historyIndex
===
0
||
this
.
historyIndex
===
10
||
this
.
undoCount
<
1
},
},
disableCopy
:
function
()
{
disableCopy
:
function
()
{
return
this
.
selectedNodes
.
length
===
0
return
this
.
selectedNodes
.
length
===
0
},
},
disablePaste
:
function
()
{
disablePaste
:
function
()
{
return
this
.
nodesInClipboard
.
length
===
0
return
this
.
nodesInClipboard
.
length
===
0
},
},
disableDelete
:
function
()
{
disableDelete
:
function
()
{
return
this
.
selectedNodes
.
length
===
0
&&
this
.
selectedEdges
.
length
===
0
return
this
.
selectedNodes
.
length
===
0
&&
this
.
selectedEdges
.
length
===
0
},
},
selectedNodes
:
function
()
{
selectedNodes
:
function
()
{
le
t
self
=
this
cons
t
self
=
this
le
t
graph
=
self
.
graph
cons
t
graph
=
self
.
graph
if
(
graph
&&
!
graph
.
destroyed
)
{
if
(
graph
&&
!
graph
.
destroyed
)
{
return
graph
.
findAllByState
(
'node'
,
'selected'
)
return
graph
.
findAllByState
(
'node'
,
'selected'
)
}
else
{
}
else
{
return
[]
return
[]
}
}
},
},
selectedEdges
:
function
()
{
selectedEdges
:
function
()
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
graph
&&
!
graph
.
destroyed
)
{
if
(
graph
&&
!
graph
.
destroyed
)
{
return
graph
.
findAllByState
(
'edge'
,
'selected'
)
return
graph
.
findAllByState
(
'edge'
,
'selected'
)
}
else
{
}
else
{
...
@@ -273,9 +278,74 @@ export default {
...
@@ -273,9 +278,74 @@ export default {
}
}
}
}
},
},
created
()
{
watch
:
{
layoutType
()
{
this
.
initTopo
(
this
.
graphData
)
},
graphMode
()
{
this
.
changeGraphSize
()
},
selectedNodeParams
:
{
deep
:
true
,
handler
:
function
(
newVal
,
oldVal
)
{
const
selectedNodeModel
=
this
.
selectedNode
.
getModel
()
if
(
utils
.
isObjectValueEqual
(
selectedNodeModel
.
appConfig
,
newVal
.
appConfig
)
&&
selectedNodeModel
.
label
===
newVal
.
label
)
{
return
}
// 实时监听input值的变化,停止输入500ms后执行update,而不是时时update
clearTimeout
(
this
.
selectedNodeParamsTimeout
)
this
.
selectedNodeParamsTimeout
=
setTimeout
(()
=>
{
selectedNodeModel
.
label
=
newVal
.
label
selectedNodeModel
.
appConfig
=
newVal
.
appConfig
this
.
selectedNode
.
update
(
selectedNodeModel
)
},
500
)
}
},
selectedEdgeParams
:
{
deep
:
true
,
handler
:
function
(
newVal
,
oldVal
)
{
const
selectedEdgeModel
=
this
.
selectedEdge
.
getModel
()
if
(
utils
.
isObjectValueEqual
(
selectedEdgeModel
.
appConfig
,
newVal
.
appConfig
)
&&
selectedEdgeModel
.
label
===
newVal
.
label
)
{
return
}
// 实时监听input值的变化,停止输入500ms后执行update,而不是时时update
clearTimeout
(
this
.
selectedEdgeParamsTimeout
)
this
.
selectedEdgeParamsTimeout
=
setTimeout
(()
=>
{
const
selectedEdgeModel
=
this
.
selectedEdge
.
getModel
()
selectedEdgeModel
.
label
=
newVal
.
label
selectedEdgeModel
.
appConfig
=
newVal
.
appConfig
this
.
selectedEdge
.
update
(
selectedEdgeModel
)
},
500
)
}
},
selectedComboParams
:
{
deep
:
true
,
handler
:
function
(
newVal
,
oldVal
)
{
const
selectedComboModel
=
this
.
selectedCombo
.
getModel
()
if
(
selectedComboModel
.
label
===
newVal
.
label
&&
selectedComboModel
.
labelCfg
.
position
===
newVal
.
labelPosition
&&
selectedComboModel
.
labelCfg
.
refX
===
newVal
.
labelRefX
&&
selectedComboModel
.
labelCfg
.
refY
===
newVal
.
labelRefY
&&
selectedComboModel
.
type
===
newVal
.
type
)
{
return
}
// 实时监听input值的变化,停止输入500ms后执行update,而不是时时update
clearTimeout
(
this
.
selectedComboParamsTimeout
)
this
.
selectedComboParamsTimeout
=
setTimeout
(()
=>
{
const
selectedComboModel
=
this
.
selectedCombo
.
getModel
()
selectedComboModel
.
label
=
newVal
.
label
selectedComboModel
.
labelCfg
.
position
=
newVal
.
labelPosition
?
newVal
.
labelPosition
:
'top'
selectedComboModel
.
labelCfg
.
refX
=
newVal
.
labelRefX
?
newVal
.
labelRefX
:
0
selectedComboModel
.
labelCfg
.
refY
=
newVal
.
labelRefY
?
newVal
.
labelRefY
:
0
selectedComboModel
.
type
=
newVal
.
type
?
newVal
.
type
:
'circle'
this
.
selectedCombo
.
update
(
selectedComboModel
)
},
500
)
}
}
},
created
()
{
},
},
mounted
()
{
mounted
()
{
ccNode
.
obj
.
ccImage
.
sendThis
(
this
)
ccNode
.
obj
.
ccImage
.
sendThis
(
this
)
ccBehavior
.
obj
.
clickEventEdit
.
sendThis
(
this
)
ccBehavior
.
obj
.
clickEventEdit
.
sendThis
(
this
)
ccBehavior
.
obj
.
dragAddEdge
.
sendThis
(
this
)
ccBehavior
.
obj
.
dragAddEdge
.
sendThis
(
this
)
...
@@ -290,57 +360,57 @@ export default {
...
@@ -290,57 +360,57 @@ export default {
})()
})()
}
}
},
},
beforeRouteUpdate
(
to
,
from
,
next
)
{
beforeRouteUpdate
(
to
,
from
,
next
)
{
this
.
clearHistoryData
()
this
.
clearHistoryData
()
next
()
next
()
},
},
beforeRouteLeave
(
to
,
from
,
next
)
{
beforeRouteLeave
(
to
,
from
,
next
)
{
this
.
clearHistoryData
()
this
.
clearHistoryData
()
next
()
next
()
},
},
beforeDestroy
()
{
beforeDestroy
()
{
this
.
clearHistoryData
()
this
.
clearHistoryData
()
},
},
methods
:
{
methods
:
{
openFullScreenLoading
()
{
openFullScreenLoading
()
{
this
.
loading
=
true
this
.
loading
=
true
},
},
closeFullScreenLoading
()
{
closeFullScreenLoading
()
{
le
t
self
=
this
cons
t
self
=
this
self
.
$nextTick
(()
=>
{
self
.
$nextTick
(()
=>
{
self
.
loading
=
false
self
.
loading
=
false
})
})
},
},
dragstartHandler
(
event
,
nodeType
)
{
dragstartHandler
(
event
,
nodeType
)
{
event
.
dataTransfer
.
setData
(
'text'
,
JSON
.
stringify
(
nodeType
))
event
.
dataTransfer
.
setData
(
'text'
,
JSON
.
stringify
(
nodeType
))
},
},
dragenterHandler
(
event
)
{
dragenterHandler
(
event
)
{
event
.
preventDefault
()
event
.
preventDefault
()
},
},
dragoverHandler
(
event
)
{
dragoverHandler
(
event
)
{
event
.
preventDefault
()
event
.
preventDefault
()
},
},
dropHandler
(
event
)
{
dropHandler
(
event
)
{
le
t
nodeTypeStr
=
event
.
dataTransfer
.
getData
(
'text'
)
cons
t
nodeTypeStr
=
event
.
dataTransfer
.
getData
(
'text'
)
le
t
nodeType
=
JSON
.
parse
(
nodeTypeStr
)
cons
t
nodeType
=
JSON
.
parse
(
nodeTypeStr
)
le
t
clientX
=
event
.
clientX
cons
t
clientX
=
event
.
clientX
le
t
clientY
=
event
.
clientY
cons
t
clientY
=
event
.
clientY
this
.
addNode
(
clientX
,
clientY
,
nodeType
)
this
.
addNode
(
clientX
,
clientY
,
nodeType
)
},
},
dragendHandler
()
{
dragendHandler
()
{
},
},
initTopo
(
graphData
)
{
initTopo
(
graphData
)
{
le
t
self
=
this
cons
t
self
=
this
if
(
self
.
graph
)
{
if
(
self
.
graph
)
{
self
.
graph
.
destroy
()
self
.
graph
.
destroy
()
}
}
// 图画布的定义
// 图画布的定义
le
t
graphContainer
=
self
.
$refs
.
graphContainer
.
$el
cons
t
graphContainer
=
self
.
$refs
.
graphContainer
.
$el
le
t
graphWidth
=
graphContainer
.
clientWidth
-
20
cons
t
graphWidth
=
graphContainer
.
clientWidth
-
20
le
t
graphHeight
=
graphContainer
.
clientHeight
-
20
cons
t
graphHeight
=
graphContainer
.
clientHeight
-
20
// Plugins
// Plugins
le
t
plugins
=
[]
cons
t
plugins
=
[]
le
t
modes
=
{
cons
t
modes
=
{
default
:
[
default
:
[
'drag-canvas'
,
'drag-canvas'
,
'drag-node'
,
'drag-node'
,
...
@@ -357,18 +427,18 @@ export default {
...
@@ -357,18 +427,18 @@ export default {
// 'click-select',
// 'click-select',
{
{
type
:
'tooltip'
,
type
:
'tooltip'
,
formatText
(
model
)
{
formatText
(
model
)
{
return
model
.
description
||
model
.
label
return
model
.
description
||
model
.
label
}
}
},
},
{
{
type
:
'edge-tooltip'
,
type
:
'edge-tooltip'
,
formatText
(
model
)
{
formatText
(
model
)
{
return
model
.
description
||
'source:'
+
self
.
graph
.
findById
(
model
.
source
).
getModel
().
label
+
' target:'
+
self
.
graph
.
findById
(
model
.
target
).
getModel
().
label
return
model
.
description
||
'source:'
+
self
.
graph
.
findById
(
model
.
source
).
getModel
().
label
+
' target:'
+
self
.
graph
.
findById
(
model
.
target
).
getModel
().
label
}
}
},
},
// Group Behavior
// Group Behavior
'collapse-expand-combo'
,
'collapse-expand-combo'
// 自定义Behavior
// 自定义Behavior
// 'my-collapse-expand'
// 'my-collapse-expand'
],
],
...
@@ -407,7 +477,7 @@ export default {
...
@@ -407,7 +477,7 @@ export default {
{
{
type
:
'brush-select'
,
type
:
'brush-select'
,
trigger
:
'drag'
,
trigger
:
'drag'
,
onSelect
()
{
onSelect
()
{
this
.
graph
.
setMode
(
'edit'
)
this
.
graph
.
setMode
(
'edit'
)
window
.
document
.
getElementById
(
'multi-select'
).
style
.
backgroundColor
=
'transparent'
window
.
document
.
getElementById
(
'multi-select'
).
style
.
backgroundColor
=
'transparent'
}
}
...
@@ -430,8 +500,8 @@ export default {
...
@@ -430,8 +500,8 @@ export default {
self
.
autoZoomHandler
()
self
.
autoZoomHandler
()
},
},
/* 自动布局 */
/* 自动布局 */
forceLayoutHandler
()
{
forceLayoutHandler
()
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
graph
&&
!
graph
.
destroyed
)
{
if
(
graph
&&
!
graph
.
destroyed
)
{
this
.
openFullScreenLoading
()
this
.
openFullScreenLoading
()
graph
.
updateLayout
({
graph
.
updateLayout
({
...
@@ -446,47 +516,47 @@ export default {
...
@@ -446,47 +516,47 @@ export default {
})
})
}
}
},
},
changeEdgeShapeHandler
(
edgeShape
)
{
changeEdgeShapeHandler
(
edgeShape
)
{
this
.
currentEdgeShape
=
_
.
find
(
this
.
edgeShapeList
,
{
'guid'
:
edgeShape
})
this
.
currentEdgeShape
=
_
.
find
(
this
.
edgeShapeList
,
{
'guid'
:
edgeShape
})
this
.
graph
.
$C
.
edge
.
type
=
this
.
currentEdgeShape
[
'guid'
]
this
.
graph
.
$C
.
edge
.
type
=
this
.
currentEdgeShape
[
'guid'
]
},
},
undoHandler
()
{
undoHandler
()
{
if
(
this
.
historyIndex
>
0
&&
this
.
historyIndex
-
(
this
.
undoCount
+
1
)
>=
0
)
{
if
(
this
.
historyIndex
>
0
&&
this
.
historyIndex
-
(
this
.
undoCount
+
1
)
>=
0
)
{
this
.
undoCount
+=
1
this
.
undoCount
+=
1
le
t
key
=
`graph_history_
${
this
.
historyIndex
-
this
.
undoCount
}
`
cons
t
key
=
`graph_history_
${
this
.
historyIndex
-
this
.
undoCount
}
`
le
t
historyData
=
this
.
getHistoryData
(
key
)
cons
t
historyData
=
this
.
getHistoryData
(
key
)
this
.
changeGraphData
(
JSON
.
parse
(
historyData
))
this
.
changeGraphData
(
JSON
.
parse
(
historyData
))
this
.
refreshGraph
()
this
.
refreshGraph
()
}
}
},
},
redoHandler
()
{
redoHandler
()
{
if
(
this
.
undoCount
>
0
)
{
if
(
this
.
undoCount
>
0
)
{
le
t
key
=
`graph_history_
${
this
.
historyIndex
-
this
.
undoCount
+
1
}
`
cons
t
key
=
`graph_history_
${
this
.
historyIndex
-
this
.
undoCount
+
1
}
`
le
t
historyData
=
this
.
getHistoryData
(
key
)
cons
t
historyData
=
this
.
getHistoryData
(
key
)
this
.
changeGraphData
(
JSON
.
parse
(
historyData
))
this
.
changeGraphData
(
JSON
.
parse
(
historyData
))
this
.
undoCount
-=
1
this
.
undoCount
-=
1
this
.
refreshGraph
()
this
.
refreshGraph
()
}
}
},
},
copyHandler
()
{
copyHandler
()
{
this
.
nodesInClipboard
=
this
.
selectedNodes
this
.
nodesInClipboard
=
this
.
selectedNodes
this
.
pasteCount
=
0
this
.
pasteCount
=
0
},
},
pasteHandler
()
{
pasteHandler
()
{
this
.
pasteCount
+=
1
// 连续paste次数统计
this
.
pasteCount
+=
1
// 连续paste次数统计
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
le
t
nodesInClipboard
=
this
.
nodesInClipboard
cons
t
nodesInClipboard
=
this
.
nodesInClipboard
if
(
graph
&&
!
graph
.
destroyed
&&
nodesInClipboard
.
length
>
0
)
{
if
(
graph
&&
!
graph
.
destroyed
&&
nodesInClipboard
.
length
>
0
)
{
// ************** 记录【粘贴】前的数据状态 start **************
// ************** 记录【粘贴】前的数据状态 start **************
le
t
historyData
=
JSON
.
stringify
(
graph
.
save
())
cons
t
historyData
=
JSON
.
stringify
(
graph
.
save
())
let
key
=
`graph_history_
${
this
.
historyIndex
}
`
let
key
=
`graph_history_
${
this
.
historyIndex
}
`
this
.
addHistoryData
(
key
,
historyData
)
this
.
addHistoryData
(
key
,
historyData
)
// ************** 记录【粘贴】前的数据状态 end **************
// ************** 记录【粘贴】前的数据状态 end **************
// 开始粘贴
// 开始粘贴
for
(
let
i
=
0
;
i
<
nodesInClipboard
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
nodesInClipboard
.
length
;
i
++
)
{
le
t
node
=
nodesInClipboard
[
i
]
cons
t
node
=
nodesInClipboard
[
i
]
le
t
model
=
node
.
getModel
()
cons
t
model
=
node
.
getModel
()
le
t
newModel
=
{
cons
t
newModel
=
{
...
model
,
...
model
,
id
:
utils
.
generateUUID
(),
id
:
utils
.
generateUUID
(),
x
:
model
.
x
+
10
*
this
.
pasteCount
,
x
:
model
.
x
+
10
*
this
.
pasteCount
,
...
@@ -500,7 +570,7 @@ export default {
...
@@ -500,7 +570,7 @@ export default {
if
(
this
.
undoCount
>
0
)
{
if
(
this
.
undoCount
>
0
)
{
this
.
historyIndex
=
this
.
historyIndex
-
this
.
undoCount
// 此时的historyIndex应当更新为【撤销】后所在的索引位置
this
.
historyIndex
=
this
.
historyIndex
-
this
.
undoCount
// 此时的historyIndex应当更新为【撤销】后所在的索引位置
for
(
let
i
=
1
;
i
<=
this
.
undoCount
;
i
++
)
{
for
(
let
i
=
1
;
i
<=
this
.
undoCount
;
i
++
)
{
le
t
key
=
`graph_history_
${
this
.
historyIndex
+
i
}
`
cons
t
key
=
`graph_history_
${
this
.
historyIndex
+
i
}
`
this
.
removeHistoryData
(
key
)
this
.
removeHistoryData
(
key
)
}
}
this
.
undoCount
=
0
this
.
undoCount
=
0
...
@@ -508,18 +578,18 @@ export default {
...
@@ -508,18 +578,18 @@ export default {
// 存储【粘贴】后的数据状态
// 存储【粘贴】后的数据状态
this
.
historyIndex
+=
1
this
.
historyIndex
+=
1
key
=
`graph_history_
${
this
.
historyIndex
}
`
key
=
`graph_history_
${
this
.
historyIndex
}
`
le
t
currentData
=
JSON
.
stringify
(
graph
.
save
())
cons
t
currentData
=
JSON
.
stringify
(
graph
.
save
())
this
.
addHistoryData
(
key
,
currentData
)
this
.
addHistoryData
(
key
,
currentData
)
// ************** 记录【粘贴】后的数据状态 end **************
// ************** 记录【粘贴】后的数据状态 end **************
}
}
},
},
deleteHandler
()
{
deleteHandler
()
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
le
t
selectedNodes
=
graph
.
findAllByState
(
'node'
,
'selected'
)
cons
t
selectedNodes
=
graph
.
findAllByState
(
'node'
,
'selected'
)
le
t
selectedEdges
=
graph
.
findAllByState
(
'edge'
,
'selected'
)
cons
t
selectedEdges
=
graph
.
findAllByState
(
'edge'
,
'selected'
)
if
(
this
.
selectedNodes
.
length
>
0
||
this
.
selectedEdges
.
length
>
0
)
{
if
(
this
.
selectedNodes
.
length
>
0
||
this
.
selectedEdges
.
length
>
0
)
{
// ************** 记录【删除】前的数据状态 start **************
// ************** 记录【删除】前的数据状态 start **************
le
t
historyData
=
JSON
.
stringify
(
graph
.
save
())
cons
t
historyData
=
JSON
.
stringify
(
graph
.
save
())
let
key
=
`graph_history_
${
this
.
historyIndex
}
`
let
key
=
`graph_history_
${
this
.
historyIndex
}
`
this
.
addHistoryData
(
key
,
historyData
)
this
.
addHistoryData
(
key
,
historyData
)
// ************** 记录【删除】前的数据状态 end **************
// ************** 记录【删除】前的数据状态 end **************
...
@@ -536,7 +606,7 @@ export default {
...
@@ -536,7 +606,7 @@ export default {
if
(
this
.
undoCount
>
0
)
{
if
(
this
.
undoCount
>
0
)
{
this
.
historyIndex
=
this
.
historyIndex
-
this
.
undoCount
// 此时的historyIndex应当更新为【撤销】后所在的索引位置
this
.
historyIndex
=
this
.
historyIndex
-
this
.
undoCount
// 此时的historyIndex应当更新为【撤销】后所在的索引位置
for
(
let
i
=
1
;
i
<=
this
.
undoCount
;
i
++
)
{
for
(
let
i
=
1
;
i
<=
this
.
undoCount
;
i
++
)
{
le
t
key
=
`graph_history_
${
this
.
historyIndex
+
i
}
`
cons
t
key
=
`graph_history_
${
this
.
historyIndex
+
i
}
`
this
.
removeHistoryData
(
key
)
this
.
removeHistoryData
(
key
)
}
}
this
.
undoCount
=
0
this
.
undoCount
=
0
...
@@ -544,36 +614,36 @@ export default {
...
@@ -544,36 +614,36 @@ export default {
// 记录【删除】后的数据状态
// 记录【删除】后的数据状态
this
.
historyIndex
+=
1
this
.
historyIndex
+=
1
key
=
`graph_history_
${
this
.
historyIndex
}
`
key
=
`graph_history_
${
this
.
historyIndex
}
`
le
t
currentData
=
JSON
.
stringify
(
graph
.
save
())
cons
t
currentData
=
JSON
.
stringify
(
graph
.
save
())
this
.
addHistoryData
(
key
,
currentData
)
this
.
addHistoryData
(
key
,
currentData
)
// ************** 记录【删除】后的数据状态 end **************
// ************** 记录【删除】后的数据状态 end **************
}
}
},
},
zoomInHandler
()
{
zoomInHandler
()
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
graph
&&
!
graph
.
destroyed
)
{
if
(
graph
&&
!
graph
.
destroyed
)
{
graph
.
zoom
(
1.2
)
graph
.
zoom
(
1.2
)
}
}
},
},
zoomOutHandler
()
{
zoomOutHandler
()
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
graph
&&
!
graph
.
destroyed
)
{
if
(
graph
&&
!
graph
.
destroyed
)
{
graph
.
zoom
(
0.8
)
graph
.
zoom
(
0.8
)
}
}
},
},
autoZoomHandler
()
{
autoZoomHandler
()
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
graph
&&
!
graph
.
destroyed
&&
graph
.
save
().
nodes
.
length
>
0
)
{
if
(
graph
&&
!
graph
.
destroyed
&&
graph
.
save
().
nodes
.
length
>
0
)
{
graph
.
fitView
(
10
)
graph
.
fitView
(
10
)
}
}
},
},
resetZoomHandler
()
{
resetZoomHandler
()
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
graph
&&
!
graph
.
destroyed
)
{
if
(
graph
&&
!
graph
.
destroyed
)
{
graph
.
zoomTo
(
1
)
graph
.
zoomTo
(
1
)
}
}
},
},
enableMinimapHandler
(
enableMinimap
)
{
enableMinimapHandler
(
enableMinimap
)
{
if
(
enableMinimap
)
{
if
(
enableMinimap
)
{
this
.
minimap
=
new
G6
.
Minimap
({
this
.
minimap
=
new
G6
.
Minimap
({
size
:
[
200
,
120
],
size
:
[
200
,
120
],
...
@@ -586,16 +656,16 @@ export default {
...
@@ -586,16 +656,16 @@ export default {
}
}
},
},
// 右键菜单
// 右键菜单
alignHandler
(
coordinate
)
{
alignHandler
(
coordinate
)
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
this
.
selectedNodes
.
length
>
1
&&
this
.
selectedNode
)
{
if
(
this
.
selectedNodes
.
length
>
1
&&
this
.
selectedNode
)
{
// ************** 记录【节点对齐】前的数据状态 start **************
// ************** 记录【节点对齐】前的数据状态 start **************
le
t
historyData
=
JSON
.
stringify
(
graph
.
save
())
cons
t
historyData
=
JSON
.
stringify
(
graph
.
save
())
let
key
=
`graph_history_
${
this
.
historyIndex
}
`
let
key
=
`graph_history_
${
this
.
historyIndex
}
`
this
.
addHistoryData
(
key
,
historyData
)
this
.
addHistoryData
(
key
,
historyData
)
// ************** 记录【节点对齐】前的数据状态 end **************
// ************** 记录【节点对齐】前的数据状态 end **************
// 开始节点对齐
// 开始节点对齐
le
t
cfg
=
coordinate
===
'horizontal'
?
{
y
:
this
.
selectedNode
.
getModel
().
y
}
:
{
x
:
this
.
selectedNode
.
getModel
().
x
}
cons
t
cfg
=
coordinate
===
'horizontal'
?
{
y
:
this
.
selectedNode
.
getModel
().
y
}
:
{
x
:
this
.
selectedNode
.
getModel
().
x
}
for
(
let
i
=
0
,
len
=
this
.
selectedNodes
.
length
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
,
len
=
this
.
selectedNodes
.
length
;
i
<
len
;
i
++
)
{
this
.
selectedNodes
[
i
].
updatePosition
(
cfg
)
this
.
selectedNodes
[
i
].
updatePosition
(
cfg
)
}
}
...
@@ -606,7 +676,7 @@ export default {
...
@@ -606,7 +676,7 @@ export default {
if
(
this
.
undoCount
>
0
)
{
if
(
this
.
undoCount
>
0
)
{
this
.
historyIndex
=
this
.
historyIndex
-
this
.
undoCount
// 此时的historyIndex应当更新为【撤销】后所在的索引位置
this
.
historyIndex
=
this
.
historyIndex
-
this
.
undoCount
// 此时的historyIndex应当更新为【撤销】后所在的索引位置
for
(
let
i
=
1
;
i
<=
this
.
undoCount
;
i
++
)
{
for
(
let
i
=
1
;
i
<=
this
.
undoCount
;
i
++
)
{
le
t
key
=
`graph_history_
${
this
.
historyIndex
+
i
}
`
cons
t
key
=
`graph_history_
${
this
.
historyIndex
+
i
}
`
this
.
removeHistoryData
(
key
)
this
.
removeHistoryData
(
key
)
}
}
this
.
undoCount
=
0
this
.
undoCount
=
0
...
@@ -614,25 +684,25 @@ export default {
...
@@ -614,25 +684,25 @@ export default {
// 记录【节点对齐】后的数据状态
// 记录【节点对齐】后的数据状态
this
.
historyIndex
+=
1
this
.
historyIndex
+=
1
key
=
`graph_history_
${
this
.
historyIndex
}
`
key
=
`graph_history_
${
this
.
historyIndex
}
`
le
t
currentData
=
JSON
.
stringify
(
graph
.
save
())
cons
t
currentData
=
JSON
.
stringify
(
graph
.
save
())
this
.
addHistoryData
(
key
,
currentData
)
this
.
addHistoryData
(
key
,
currentData
)
// ************** 记录【节点对齐】后的数据状态 end **************
// ************** 记录【节点对齐】后的数据状态 end **************
}
}
this
.
rightMenuShow
=
false
this
.
rightMenuShow
=
false
},
},
createComboHandler
()
{
createComboHandler
()
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
graph
&&
!
graph
.
destroyed
&&
this
.
selectedNodes
.
length
>
1
&&
this
.
selectedNode
)
{
if
(
graph
&&
!
graph
.
destroyed
&&
this
.
selectedNodes
.
length
>
1
&&
this
.
selectedNode
)
{
// ************** 记录【添加分组】前的数据状态 start **************
// ************** 记录【添加分组】前的数据状态 start **************
le
t
historyData
=
JSON
.
stringify
(
graph
.
save
())
cons
t
historyData
=
JSON
.
stringify
(
graph
.
save
())
le
t
key
=
`graph_history_
${
this
.
historyIndex
}
`
cons
t
key
=
`graph_history_
${
this
.
historyIndex
}
`
this
.
addHistoryData
(
key
,
historyData
)
this
.
addHistoryData
(
key
,
historyData
)
// ************** 记录【添加分组】前的数据状态 end **************
// ************** 记录【添加分组】前的数据状态 end **************
le
t
nodeIds
=
this
.
selectedNodes
.
map
(
item
=>
{
cons
t
nodeIds
=
this
.
selectedNodes
.
map
(
item
=>
{
return
item
.
_cfg
.
id
return
item
.
_cfg
.
id
})
})
// 创建分组
// 创建分组
le
t
combo
=
graph
.
createCombo
({
cons
t
combo
=
graph
.
createCombo
({
id
:
utils
.
generateUUID
()
id
:
utils
.
generateUUID
()
},
nodeIds
)
},
nodeIds
)
// ************** 记录【添加分组】后的数据状态 start **************
// ************** 记录【添加分组】后的数据状态 start **************
...
@@ -642,39 +712,39 @@ export default {
...
@@ -642,39 +712,39 @@ export default {
if
(
this
.
undoCount
>
0
)
{
if
(
this
.
undoCount
>
0
)
{
this
.
historyIndex
=
this
.
historyIndex
-
this
.
undoCount
// 此时的historyIndex应当更新为【撤销】后所在的索引位置
this
.
historyIndex
=
this
.
historyIndex
-
this
.
undoCount
// 此时的historyIndex应当更新为【撤销】后所在的索引位置
for
(
let
i
=
1
;
i
<=
this
.
undoCount
;
i
++
)
{
for
(
let
i
=
1
;
i
<=
this
.
undoCount
;
i
++
)
{
le
t
key
=
`graph_history_
${
this
.
historyIndex
+
i
}
`
cons
t
key
=
`graph_history_
${
this
.
historyIndex
+
i
}
`
this
.
removeHistoryData
(
key
)
this
.
removeHistoryData
(
key
)
}
}
this
.
undoCount
=
0
this
.
undoCount
=
0
}
}
// 记录【添加分组】后的数据状态
// 记录【添加分组】后的数据状态
this
.
historyIndex
+=
1
this
.
historyIndex
+=
1
le
t
key
=
`graph_history_
${
this
.
historyIndex
}
`
cons
t
key
=
`graph_history_
${
this
.
historyIndex
}
`
le
t
currentData
=
JSON
.
stringify
(
graph
.
save
())
cons
t
currentData
=
JSON
.
stringify
(
graph
.
save
())
this
.
addHistoryData
(
key
,
currentData
)
this
.
addHistoryData
(
key
,
currentData
)
}
}
// ************** 记录【添加分组】后的数据状态 end **************
// ************** 记录【添加分组】后的数据状态 end **************
this
.
rightMenuShow
=
false
this
.
rightMenuShow
=
false
}
}
},
},
removeComboHandler
()
{
removeComboHandler
()
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
this
.
selectedCombo
)
{
if
(
this
.
selectedCombo
)
{
// ************** 记录【删除】前的数据状态 start **************
// ************** 记录【删除】前的数据状态 start **************
le
t
historyData
=
JSON
.
stringify
(
graph
.
save
())
cons
t
historyData
=
JSON
.
stringify
(
graph
.
save
())
let
key
=
`graph_history_
${
this
.
historyIndex
}
`
let
key
=
`graph_history_
${
this
.
historyIndex
}
`
this
.
addHistoryData
(
key
,
historyData
)
this
.
addHistoryData
(
key
,
historyData
)
// ************** 记录【删除】前的数据状态 end **************
// ************** 记录【删除】前的数据状态 end **************
// 开始删除
// 开始删除
// FIXME... graph.uncombo() 后,combos 依旧存在 graph.save() 中。
// FIXME... graph.uncombo() 后,combos 依旧存在 graph.save() 中。
let
{
nodes
:
subNodes
,
combos
:
subCombos
}
=
this
.
selectedCombo
.
getChildren
()
const
{
nodes
:
subNodes
,
combos
:
subCombos
}
=
this
.
selectedCombo
.
getChildren
()
subNodes
.
forEach
(
subNode
=>
{
subNodes
.
forEach
(
subNode
=>
{
le
t
subNodeModel
=
subNode
.
getModel
()
cons
t
subNodeModel
=
subNode
.
getModel
()
subNodeModel
.
comboId
=
undefined
subNodeModel
.
comboId
=
undefined
subNode
.
update
(
subNodeModel
)
subNode
.
update
(
subNodeModel
)
})
})
subCombos
.
forEach
(
subCombo
=>
{
subCombos
.
forEach
(
subCombo
=>
{
le
t
subComboModel
=
subCombo
.
getModel
()
cons
t
subComboModel
=
subCombo
.
getModel
()
subComboModel
.
comboId
=
undefined
subComboModel
.
comboId
=
undefined
subCombo
.
update
(
subComboModel
)
subCombo
.
update
(
subComboModel
)
})
})
...
@@ -685,7 +755,7 @@ export default {
...
@@ -685,7 +755,7 @@ export default {
if
(
this
.
undoCount
>
0
)
{
if
(
this
.
undoCount
>
0
)
{
this
.
historyIndex
=
this
.
historyIndex
-
this
.
undoCount
// 此时的historyIndex应当更新为【撤销】后所在的索引位置
this
.
historyIndex
=
this
.
historyIndex
-
this
.
undoCount
// 此时的historyIndex应当更新为【撤销】后所在的索引位置
for
(
let
i
=
1
;
i
<=
this
.
undoCount
;
i
++
)
{
for
(
let
i
=
1
;
i
<=
this
.
undoCount
;
i
++
)
{
le
t
key
=
`graph_history_
${
this
.
historyIndex
+
i
}
`
cons
t
key
=
`graph_history_
${
this
.
historyIndex
+
i
}
`
this
.
removeHistoryData
(
key
)
this
.
removeHistoryData
(
key
)
}
}
this
.
undoCount
=
0
this
.
undoCount
=
0
...
@@ -693,23 +763,23 @@ export default {
...
@@ -693,23 +763,23 @@ export default {
// 记录【删除】后的数据状态
// 记录【删除】后的数据状态
this
.
historyIndex
+=
1
this
.
historyIndex
+=
1
key
=
`graph_history_
${
this
.
historyIndex
}
`
key
=
`graph_history_
${
this
.
historyIndex
}
`
le
t
currentData
=
JSON
.
stringify
(
graph
.
save
())
cons
t
currentData
=
JSON
.
stringify
(
graph
.
save
())
this
.
addHistoryData
(
key
,
currentData
)
this
.
addHistoryData
(
key
,
currentData
)
// ************** 记录【删除】后的数据状态 end **************
// ************** 记录【删除】后的数据状态 end **************
this
.
rightMenuShow
=
false
this
.
rightMenuShow
=
false
}
}
},
},
addNode
(
clientX
,
clientY
,
nodeType
)
{
addNode
(
clientX
,
clientY
,
nodeType
)
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
graph
&&
!
graph
.
destroyed
)
{
if
(
graph
&&
!
graph
.
destroyed
)
{
// ************** 记录【添加节点】前的数据状态 start **************
// ************** 记录【添加节点】前的数据状态 start **************
le
t
historyData
=
JSON
.
stringify
(
graph
.
save
())
cons
t
historyData
=
JSON
.
stringify
(
graph
.
save
())
le
t
key
=
`graph_history_
${
this
.
historyIndex
}
`
cons
t
key
=
`graph_history_
${
this
.
historyIndex
}
`
this
.
addHistoryData
(
key
,
historyData
)
this
.
addHistoryData
(
key
,
historyData
)
// ************** 记录【添加节点】前的数据状态 end **************
// ************** 记录【添加节点】前的数据状态 end **************
// 开始添加
// 开始添加
le
t
droppoint
=
graph
.
getPointByClient
(
clientX
,
clientY
)
cons
t
droppoint
=
graph
.
getPointByClient
(
clientX
,
clientY
)
le
t
node
=
graph
.
addItem
(
'node'
,
{
cons
t
node
=
graph
.
addItem
(
'node'
,
{
id
:
utils
.
generateUUID
(),
id
:
utils
.
generateUUID
(),
x
:
droppoint
.
x
,
x
:
droppoint
.
x
,
y
:
droppoint
.
y
,
y
:
droppoint
.
y
,
...
@@ -740,23 +810,23 @@ export default {
...
@@ -740,23 +810,23 @@ export default {
if
(
this
.
undoCount
>
0
)
{
if
(
this
.
undoCount
>
0
)
{
this
.
historyIndex
=
this
.
historyIndex
-
this
.
undoCount
// 此时的historyIndex应当更新为【撤销】后所在的索引位置
this
.
historyIndex
=
this
.
historyIndex
-
this
.
undoCount
// 此时的historyIndex应当更新为【撤销】后所在的索引位置
for
(
let
i
=
1
;
i
<=
this
.
undoCount
;
i
++
)
{
for
(
let
i
=
1
;
i
<=
this
.
undoCount
;
i
++
)
{
le
t
key
=
`graph_history_
${
this
.
historyIndex
+
i
}
`
cons
t
key
=
`graph_history_
${
this
.
historyIndex
+
i
}
`
this
.
removeHistoryData
(
key
)
this
.
removeHistoryData
(
key
)
}
}
this
.
undoCount
=
0
this
.
undoCount
=
0
}
}
// 记录【添加节点】后的数据状态
// 记录【添加节点】后的数据状态
this
.
historyIndex
+=
1
this
.
historyIndex
+=
1
le
t
key
=
`graph_history_
${
this
.
historyIndex
}
`
cons
t
key
=
`graph_history_
${
this
.
historyIndex
}
`
le
t
currentData
=
JSON
.
stringify
(
graph
.
save
())
cons
t
currentData
=
JSON
.
stringify
(
graph
.
save
())
this
.
addHistoryData
(
key
,
currentData
)
this
.
addHistoryData
(
key
,
currentData
)
}
}
// ************** 记录【添加节点】后的数据状态 end **************
// ************** 记录【添加节点】后的数据状态 end **************
}
}
},
},
unselectAllNodes
()
{
unselectAllNodes
()
{
},
},
addHistoryData
(
key
,
value
)
{
addHistoryData
(
key
,
value
)
{
try
{
try
{
sessionStorage
.
setItem
(
key
,
value
)
sessionStorage
.
setItem
(
key
,
value
)
}
catch
(
oException
)
{
}
catch
(
oException
)
{
...
@@ -771,55 +841,55 @@ export default {
...
@@ -771,55 +841,55 @@ export default {
}
}
}
}
},
},
getHistoryData
(
key
)
{
getHistoryData
(
key
)
{
return
sessionStorage
.
getItem
(
key
)
return
sessionStorage
.
getItem
(
key
)
},
},
removeHistoryData
(
key
)
{
removeHistoryData
(
key
)
{
sessionStorage
.
removeItem
(
key
)
sessionStorage
.
removeItem
(
key
)
},
},
clearHistoryData
()
{
clearHistoryData
()
{
le
t
keys
=
Object
.
keys
(
sessionStorage
)
cons
t
keys
=
Object
.
keys
(
sessionStorage
)
keys
.
forEach
(
key
=>
{
keys
.
forEach
(
key
=>
{
if
(
key
.
startsWith
(
'graph_history'
))
{
if
(
key
.
startsWith
(
'graph_history'
))
{
sessionStorage
.
removeItem
(
key
)
sessionStorage
.
removeItem
(
key
)
}
}
})
})
},
},
onresizeHandler
()
{
onresizeHandler
()
{
// 实时监听窗口大小变化
// 实时监听窗口大小变化
le
t
self
=
this
cons
t
self
=
this
clearTimeout
(
this
.
onresizeTimeout
)
clearTimeout
(
this
.
onresizeTimeout
)
this
.
onresizeTimeout
=
setTimeout
(()
=>
{
this
.
onresizeTimeout
=
setTimeout
(()
=>
{
le
t
graph
=
self
.
graph
cons
t
graph
=
self
.
graph
if
(
graph
&&
!
graph
.
destroyed
)
{
if
(
graph
&&
!
graph
.
destroyed
)
{
le
t
graphContainer
=
self
.
$refs
.
graphContainer
.
$el
cons
t
graphContainer
=
self
.
$refs
.
graphContainer
.
$el
le
t
graphWidth
=
graphContainer
.
clientWidth
-
20
cons
t
graphWidth
=
graphContainer
.
clientWidth
-
20
le
t
graphHeight
=
graphContainer
.
clientHeight
-
20
cons
t
graphHeight
=
graphContainer
.
clientHeight
-
20
graph
.
changeSize
(
graphWidth
,
graphHeight
)
graph
.
changeSize
(
graphWidth
,
graphHeight
)
}
}
},
1000
)
},
1000
)
},
},
/* 暴露给外部的接口 */
/* 暴露给外部的接口 */
refreshGraph
()
{
refreshGraph
()
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
graph
&&
!
graph
.
destroyed
)
{
if
(
graph
&&
!
graph
.
destroyed
)
{
graph
.
refresh
()
graph
.
refresh
()
}
}
},
},
getGraphData
()
{
getGraphData
()
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
graph
&&
!
graph
.
destroyed
)
{
if
(
graph
&&
!
graph
.
destroyed
)
{
// FIXME... graph.uncombo() 后,combos 依旧存在 graph.save() 中。
// FIXME... graph.uncombo() 后,combos 依旧存在 graph.save() 中。
let
{
nodes
,
edges
,
groups
,
combos
}
=
graph
.
save
()
const
{
nodes
,
edges
,
groups
,
combos
}
=
graph
.
save
()
le
t
nodeComboIds
=
[]
cons
t
nodeComboIds
=
[]
nodes
.
forEach
(
node
=>
{
nodes
.
forEach
(
node
=>
{
le
t
nodeComboId
=
node
.
comboId
cons
t
nodeComboId
=
node
.
comboId
if
(
typeof
nodeComboId
!==
'undefined'
&&
nodeComboIds
.
indexOf
(
nodeComboId
)
<
0
)
{
if
(
typeof
nodeComboId
!==
'undefined'
&&
nodeComboIds
.
indexOf
(
nodeComboId
)
<
0
)
{
nodeComboIds
.
push
(
nodeComboId
)
nodeComboIds
.
push
(
nodeComboId
)
}
}
})
})
graph
.
findAll
(
'combo'
,
combo
=>
{
graph
.
findAll
(
'combo'
,
combo
=>
{
le
t
comboId
=
combo
.
get
(
'model'
).
id
cons
t
comboId
=
combo
.
get
(
'model'
).
id
if
(
nodeComboIds
.
indexOf
(
comboId
)
<
0
)
{
if
(
nodeComboIds
.
indexOf
(
comboId
)
<
0
)
{
console
.
log
(
'G6 bug'
)
console
.
log
(
'G6 bug'
)
_
.
remove
(
combos
,
combo
=>
{
_
.
remove
(
combos
,
combo
=>
{
...
@@ -832,44 +902,44 @@ export default {
...
@@ -832,44 +902,44 @@ export default {
return
{
nodes
:
[],
edges
:
[],
groups
:
[],
combos
:
[]
}
return
{
nodes
:
[],
edges
:
[],
groups
:
[],
combos
:
[]
}
}
}
},
},
changeGraphData
(
data
)
{
changeGraphData
(
data
)
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
graph
&&
!
graph
.
destroyed
)
{
if
(
graph
&&
!
graph
.
destroyed
)
{
graph
.
changeData
(
data
)
graph
.
changeData
(
data
)
graph
.
refresh
()
graph
.
refresh
()
}
}
},
},
changeGraphSize
(
graphWidth
=
0
,
graphHeight
=
0
)
{
changeGraphSize
(
graphWidth
=
0
,
graphHeight
=
0
)
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
graph
&&
!
graph
.
destroyed
)
{
if
(
graph
&&
!
graph
.
destroyed
)
{
le
t
graphContainer
=
this
.
$refs
.
graphContainer
.
$el
cons
t
graphContainer
=
this
.
$refs
.
graphContainer
.
$el
graphWidth
=
graphWidth
||
graphContainer
.
clientWidth
-
20
graphWidth
=
graphWidth
||
graphContainer
.
clientWidth
-
20
graphHeight
=
graphHeight
||
graphContainer
.
clientHeight
-
20
graphHeight
=
graphHeight
||
graphContainer
.
clientHeight
-
20
graph
.
changeSize
(
graphWidth
,
graphHeight
)
graph
.
changeSize
(
graphWidth
,
graphHeight
)
}
}
},
},
changeGraphMode
(
graphData
,
graphMode
)
{
changeGraphMode
(
graphData
,
graphMode
)
{
this
.
graphMode
=
graphMode
this
.
graphMode
=
graphMode
this
.
initTopo
(
graphData
)
this
.
initTopo
(
graphData
)
},
},
changeGraphTheme
(
themeValue
)
{
changeGraphTheme
(
themeValue
)
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
graph
&&
!
graph
.
destroyed
)
{
if
(
graph
&&
!
graph
.
destroyed
)
{
le
t
nodes
=
graph
.
getNodes
()
cons
t
nodes
=
graph
.
getNodes
()
le
t
edges
=
graph
.
getEdges
()
cons
t
edges
=
graph
.
getEdges
()
switch
(
themeValue
)
{
switch
(
themeValue
)
{
case
'darkStyle'
:
case
'darkStyle'
:
this
.
graphBg
=
'dark-style'
this
.
graphBg
=
'dark-style'
graph
.
$T
=
theme
.
darkStyle
graph
.
$T
=
theme
.
darkStyle
for
(
let
i
=
0
,
len
=
edges
.
length
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
,
len
=
edges
.
length
;
i
<
len
;
i
++
)
{
le
t
edge
=
edges
[
i
]
cons
t
edge
=
edges
[
i
]
le
t
edgeModel
=
edge
.
getModel
()
cons
t
edgeModel
=
edge
.
getModel
()
edgeModel
.
style
=
graph
.
$T
.
edgeStyle
.
default
edgeModel
.
style
=
graph
.
$T
.
edgeStyle
.
default
edge
.
update
(
edgeModel
)
edge
.
update
(
edgeModel
)
}
}
for
(
let
i
=
0
,
len
=
nodes
.
length
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
,
len
=
nodes
.
length
;
i
<
len
;
i
++
)
{
le
t
node
=
nodes
[
i
]
cons
t
node
=
nodes
[
i
]
le
t
nodeModel
=
node
.
getModel
()
cons
t
nodeModel
=
node
.
getModel
()
nodeModel
.
labelCfg
=
graph
.
$T
.
nodeLabelCfg
nodeModel
.
labelCfg
=
graph
.
$T
.
nodeLabelCfg
node
.
update
(
nodeModel
)
node
.
update
(
nodeModel
)
}
}
...
@@ -879,14 +949,14 @@ export default {
...
@@ -879,14 +949,14 @@ export default {
this
.
graphBg
=
'office-style'
this
.
graphBg
=
'office-style'
graph
.
$T
=
theme
.
officeStyle
graph
.
$T
=
theme
.
officeStyle
for
(
let
i
=
0
,
len
=
edges
.
length
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
,
len
=
edges
.
length
;
i
<
len
;
i
++
)
{
le
t
edge
=
edges
[
i
]
cons
t
edge
=
edges
[
i
]
le
t
edgeModel
=
edge
.
getModel
()
cons
t
edgeModel
=
edge
.
getModel
()
edgeModel
.
style
=
graph
.
$T
.
edgeStyle
.
default
edgeModel
.
style
=
graph
.
$T
.
edgeStyle
.
default
edge
.
update
(
edgeModel
)
edge
.
update
(
edgeModel
)
}
}
for
(
let
i
=
0
,
len
=
nodes
.
length
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
,
len
=
nodes
.
length
;
i
<
len
;
i
++
)
{
le
t
node
=
nodes
[
i
]
cons
t
node
=
nodes
[
i
]
le
t
nodeModel
=
node
.
getModel
()
cons
t
nodeModel
=
node
.
getModel
()
nodeModel
.
labelCfg
=
graph
.
$T
.
nodeLabelCfg
nodeModel
.
labelCfg
=
graph
.
$T
.
nodeLabelCfg
node
.
update
(
nodeModel
)
node
.
update
(
nodeModel
)
}
}
...
@@ -896,14 +966,14 @@ export default {
...
@@ -896,14 +966,14 @@ export default {
this
.
graphBg
=
'default-style'
this
.
graphBg
=
'default-style'
graph
.
$T
=
theme
.
defaultStyle
graph
.
$T
=
theme
.
defaultStyle
for
(
let
i
=
0
,
len
=
edges
.
length
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
,
len
=
edges
.
length
;
i
<
len
;
i
++
)
{
le
t
edge
=
edges
[
i
]
cons
t
edge
=
edges
[
i
]
le
t
edgeModel
=
edge
.
getModel
()
cons
t
edgeModel
=
edge
.
getModel
()
edgeModel
.
style
=
graph
.
$T
.
edgeStyle
.
default
edgeModel
.
style
=
graph
.
$T
.
edgeStyle
.
default
edge
.
update
(
edgeModel
)
edge
.
update
(
edgeModel
)
}
}
for
(
let
i
=
0
,
len
=
nodes
.
length
;
i
<
len
;
i
++
)
{
for
(
let
i
=
0
,
len
=
nodes
.
length
;
i
<
len
;
i
++
)
{
le
t
node
=
nodes
[
i
]
cons
t
node
=
nodes
[
i
]
le
t
nodeModel
=
node
.
getModel
()
cons
t
nodeModel
=
node
.
getModel
()
nodeModel
.
labelCfg
=
graph
.
$T
.
nodeLabelCfg
nodeModel
.
labelCfg
=
graph
.
$T
.
nodeLabelCfg
node
.
update
(
nodeModel
)
node
.
update
(
nodeModel
)
}
}
...
@@ -911,88 +981,23 @@ export default {
...
@@ -911,88 +981,23 @@ export default {
}
}
}
}
},
},
downloadFullImage
()
{
downloadFullImage
()
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
graph
&&
!
graph
.
destroyed
)
{
if
(
graph
&&
!
graph
.
destroyed
)
{
le
t
name
=
'graph_'
+
_
.
now
()
cons
t
name
=
'graph_'
+
_
.
now
()
graph
.
downloadFullImage
(
name
,
'image/png'
,
{
graph
.
downloadFullImage
(
name
,
'image/png'
,
{
backgroundColor
:
'transparent'
,
backgroundColor
:
'transparent'
,
padding
:
[
30
,
15
,
15
,
15
]
padding
:
[
30
,
15
,
15
,
15
]
})
})
}
}
},
},
downloadImage
()
{
downloadImage
()
{
le
t
graph
=
this
.
graph
cons
t
graph
=
this
.
graph
if
(
graph
&&
!
graph
.
destroyed
)
{
if
(
graph
&&
!
graph
.
destroyed
)
{
le
t
name
=
'graph_'
+
_
.
now
()
cons
t
name
=
'graph_'
+
_
.
now
()
graph
.
downloadImage
(
name
,
'image/png'
,
'transparent'
)
graph
.
downloadImage
(
name
,
'image/png'
,
'transparent'
)
}
}
}
}
},
watch
:
{
layoutType
()
{
this
.
initTopo
(
this
.
graphData
)
},
graphMode
()
{
this
.
changeGraphSize
()
},
selectedNodeParams
:
{
deep
:
true
,
handler
:
function
(
newVal
,
oldVal
)
{
let
selectedNodeModel
=
this
.
selectedNode
.
getModel
()
if
(
utils
.
isObjectValueEqual
(
selectedNodeModel
.
appConfig
,
newVal
.
appConfig
)
&&
selectedNodeModel
.
label
===
newVal
.
label
)
{
return
}
// 实时监听input值的变化,停止输入500ms后执行update,而不是时时update
clearTimeout
(
this
.
selectedNodeParamsTimeout
)
this
.
selectedNodeParamsTimeout
=
setTimeout
(()
=>
{
selectedNodeModel
.
label
=
newVal
.
label
selectedNodeModel
.
appConfig
=
newVal
.
appConfig
this
.
selectedNode
.
update
(
selectedNodeModel
)
},
500
)
}
},
selectedEdgeParams
:
{
deep
:
true
,
handler
:
function
(
newVal
,
oldVal
)
{
let
selectedEdgeModel
=
this
.
selectedEdge
.
getModel
()
if
(
utils
.
isObjectValueEqual
(
selectedEdgeModel
.
appConfig
,
newVal
.
appConfig
)
&&
selectedEdgeModel
.
label
===
newVal
.
label
)
{
return
}
// 实时监听input值的变化,停止输入500ms后执行update,而不是时时update
clearTimeout
(
this
.
selectedEdgeParamsTimeout
)
this
.
selectedEdgeParamsTimeout
=
setTimeout
(()
=>
{
let
selectedEdgeModel
=
this
.
selectedEdge
.
getModel
()
selectedEdgeModel
.
label
=
newVal
.
label
selectedEdgeModel
.
appConfig
=
newVal
.
appConfig
this
.
selectedEdge
.
update
(
selectedEdgeModel
)
},
500
)
}
},
selectedComboParams
:
{
deep
:
true
,
handler
:
function
(
newVal
,
oldVal
)
{
let
selectedComboModel
=
this
.
selectedCombo
.
getModel
()
if
(
selectedComboModel
.
label
===
newVal
.
label
&&
selectedComboModel
.
labelCfg
.
position
===
newVal
.
labelPosition
&&
selectedComboModel
.
labelCfg
.
refX
===
newVal
.
labelRefX
&&
selectedComboModel
.
labelCfg
.
refY
===
newVal
.
labelRefY
&&
selectedComboModel
.
type
===
newVal
.
type
)
{
return
}
// 实时监听input值的变化,停止输入500ms后执行update,而不是时时update
clearTimeout
(
this
.
selectedComboParamsTimeout
)
this
.
selectedComboParamsTimeout
=
setTimeout
(()
=>
{
let
selectedComboModel
=
this
.
selectedCombo
.
getModel
()
selectedComboModel
.
label
=
newVal
.
label
selectedComboModel
.
labelCfg
.
position
=
newVal
.
labelPosition
?
newVal
.
labelPosition
:
'top'
selectedComboModel
.
labelCfg
.
refX
=
newVal
.
labelRefX
?
newVal
.
labelRefX
:
0
selectedComboModel
.
labelCfg
.
refY
=
newVal
.
labelRefY
?
newVal
.
labelRefY
:
0
selectedComboModel
.
type
=
newVal
.
type
?
newVal
.
type
:
'circle'
this
.
selectedCombo
.
update
(
selectedComboModel
)
},
500
)
}
}
}
}
}
}
</
script
>
</
script
>
...
...
public/index.html
View file @
dcd8109d
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<meta
charset=
"utf-8"
>
<meta
charset=
"utf-8"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge,chrome=1"
>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge,chrome=1"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
>
<link
rel=
"icon"
href=
"<%= BASE_URL %>
monitorL
ogo.png"
>
<link
rel=
"icon"
href=
"<%= BASE_URL %>
rongchuangl
ogo.png"
>
<!-- <link rel="stylesheet" href="//at.alicdn.com/t/font_2011217_f70ptj9y4oc.css">-->
<!-- <link rel="stylesheet" href="//at.alicdn.com/t/font_2011217_f70ptj9y4oc.css">-->
<!-- <title><%= webpackConfig.name %></title>-->
<!-- <title><%= webpackConfig.name %></title>-->
<title>
网络设备监控管理平台
</title>
<title>
网络设备监控管理平台
</title>
...
...
public/rongchuanglogo.png
0 → 100644
View file @
dcd8109d
4.55 KB
src/views/demos/topology.vue
View file @
dcd8109d
...
@@ -632,7 +632,10 @@ export default {
...
@@ -632,7 +632,10 @@ export default {
<
style
lang=
"scss"
scoped
>
<
style
lang=
"scss"
scoped
>
.el-container
{
.el-container
{
height
:
900px
!
important
;
position
:
absolute
;
width
:
calc
(
100vw
-
228px
);
height
:
calc
(
92
.4vh
-
95px
);
padding
:
0
10px
;
.el-header
{
.el-header
{
line-height
:
60px
;
line-height
:
60px
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment