|
@@ -19,6 +19,7 @@
|
|
|
<script>
|
|
|
import { ElDropdownMenu } from 'element-ui';
|
|
|
import { myGraph } from '../common/gragh';
|
|
|
+import { baseNode } from '../common/config';
|
|
|
export default {
|
|
|
components:{ElDropdownMenu},
|
|
|
data() {
|
|
@@ -47,23 +48,20 @@ export default {
|
|
|
tempThis.$emit('showDialog',node.data.myETAId)
|
|
|
}
|
|
|
})
|
|
|
- const rect = this.graph.addNode({
|
|
|
- shape:'rect',
|
|
|
- x: 40,
|
|
|
- y: 40,
|
|
|
- width: 120,
|
|
|
- height: 50,
|
|
|
- data:{
|
|
|
- myETAId:652
|
|
|
- },
|
|
|
- label:'test'
|
|
|
- })
|
|
|
+ //mock
|
|
|
+ this.graph.addNode({
|
|
|
+ ...baseNode,
|
|
|
+ ...{
|
|
|
+ data:{myETAId:652},
|
|
|
+ label:'text'
|
|
|
+ }})
|
|
|
//如果有内容
|
|
|
- //graph.centerContent()
|
|
|
this.graph.scrollToContent({ animation: { duration: 600 }})
|
|
|
+ //如果是非编辑页,加载完成画布内容后冻结画布
|
|
|
+ !window.location.pathname.startsWith('/editframe')&&this.graph.freeze()
|
|
|
},
|
|
|
editNode(node){
|
|
|
- //在视口范围内添加一个
|
|
|
+ //获取视口范围
|
|
|
const position = this.graph.getContentArea()
|
|
|
const nodes = this.graph.getNodes()
|
|
|
const currentNode = nodes.find(item=>item.id===node.nodeId)
|
|
@@ -71,29 +69,38 @@ export default {
|
|
|
currentNode.data.myETAId=node.nodeLink
|
|
|
currentNode.label=node.nodeName
|
|
|
}else{
|
|
|
+ //在视口范围内添加节点
|
|
|
this.graph.addNode({
|
|
|
- x:100,
|
|
|
- y:100,
|
|
|
+ ...baseNode,
|
|
|
+ ...{
|
|
|
+ x:position.x+position.width/2,
|
|
|
+ y:position.y+position.height/2,
|
|
|
width:120,
|
|
|
height:50,
|
|
|
data:{
|
|
|
myETAId:node.nodeLink,//存储节点对应的myETA分类id
|
|
|
},
|
|
|
label:node.nodeName||''
|
|
|
- })
|
|
|
+ }})
|
|
|
}
|
|
|
},
|
|
|
handleContext(key){
|
|
|
- //编辑test
|
|
|
const select_cell = this.graph.getSelectedCells()
|
|
|
if(!select_cell.length) return
|
|
|
- const {id} = select_cell[0]
|
|
|
- const node = this.graph.getNodes().find(item=>item.id===id)
|
|
|
- this.$emit('editNode',{
|
|
|
- nodeId:node.id,
|
|
|
- nodeName:node.label,
|
|
|
- nodeLink:node.data.myETAId
|
|
|
- })
|
|
|
+
|
|
|
+ if(key==='edit'){
|
|
|
+ const {id} = select_cell[0]
|
|
|
+ const node = this.graph.getNodes().find(item=>item.id===id)
|
|
|
+ this.$emit('editNode',{
|
|
|
+ nodeId:node.id,
|
|
|
+ nodeName:node.label,
|
|
|
+ nodeLink:node.data.myETAId
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if(key==='del'){
|
|
|
+ this.graph.removeCells(select_cell)
|
|
|
+ this.hideContextMenu()
|
|
|
+ }
|
|
|
//清除选区
|
|
|
this.graph.cleanSelection()
|
|
|
},
|