| | |
| | | if (res.data !== null && (res.data.content != null)) { |
| | | this.dataForm = res.data |
| | | this.diagramJson = JSON.parse(this.dataForm.content) |
| | | if (this.diagramJson.cells.length !== 0) { |
| | | this.graph.fromJSON(this.diagramJson) |
| | | } else { |
| | | this.graph.fromJSON(RBDDefault) |
| | | } |
| | | this.isFirstLoad = false; |
| | | console.log(this.diagramJson.cells.length, 'this.diagramJson.cells.length') |
| | | |
| | |
| | | // this.graph.centerContent() |
| | | // this.graph.zoomToFit() |
| | | } else { |
| | | await this.clearDiagram() |
| | | this.graph.fromJSON(RBDDefault) |
| | | } |
| | | }, |
| | | async clearDiagram() { |
| | |
| | | } |
| | | if (startNode && endNode) { |
| | | let centerY = graphNode.position().y |
| | | let result = this.addNodeAndConnect(graphNode, dragNode, dragNode.position().x, centerY) |
| | | let result = this.addNodeAndConnect(graphNode, dragNode, dragNode.position().x - dragNode.size().width/2, centerY) |
| | | if (!result){ |
| | | dragNode.remove() |
| | | return |
| | |
| | | width =100 |
| | | height = 60 |
| | | } else if (dragNodeType === 'bridgeConnection') { |
| | | width =450 |
| | | height = 160 |
| | | width =550 |
| | | height = 115 |
| | | leftTopX = leftX - width/2 |
| | | leftTopY = centerY - height/2 |
| | | // leftTopY = 240/2 |
| | | } else { |
| | | width =270 |
| | |
| | | dragNode.position(leftX, centerY) |
| | | return {newStartNode: dragNode, newEndNode: dragNode} |
| | | } else if (dragNodeType === 'bridgeConnection') { |
| | | return this.createBridgeConnection(leftX, centerY, dragNode) |
| | | return this.createBridgeConnection(leftTopX, leftTopY, dragNode) |
| | | } else { |
| | | return this.createParallelBrach(leftX, centerY, dragNode) |
| | | return this.createParallelBrach(leftTopX, leftTopY, dragNode) |
| | | } |
| | | }, |
| | | // 相交的边 |
| | |
| | | })*/ |
| | | }, |
| | | createBridgeConnection(x, y, dragNode) { |
| | | const leftTopDashedBox = this.createDashedBox(x + 120, y) |
| | | const rightTopDashedBox = this.createDashedBox(x + 400, y) |
| | | console.log(x,y,'leftX centerY') |
| | | const leftTopDashedBox = this.createDashedBox(x + 40, y) |
| | | const rightTopDashedBox = this.createDashedBox(x + 380, y) |
| | | |
| | | const leftConnectNode = this.createConnectNode(x + 50, y + 80) |
| | | const alignCenterDashedBox = this.createDashedBox(x + 260, y + 80) |
| | | const rightConnectNode = this.createBridgeNode(x + 550, y + 80) |
| | | const leftConnectNode = this.createConnectNode(x, y + 87) |
| | | const alignCenterDashedBox = this.createDashedBox(x+ 210, y + 87) |
| | | const rightConnectNode = this.createBridgeNode(x + 530, y + 87) |
| | | |
| | | const leftBottomDashedBox = this.createDashedBox(x + 120, y + 160) |
| | | const rightBottomDashedBox = this.createDashedBox(x + 400, y + 160) |
| | | const leftBottomDashedBox = this.createDashedBox(x+ 50, y + 160) |
| | | const rightBottomDashedBox = this.createDashedBox(x + 370 , y + 160) |
| | | |
| | | rightConnectNode.setData({startNodeId: leftConnectNode.id}) |
| | | leftConnectNode.setData({endNodeId: rightConnectNode.id}) |
| | |
| | | const dragNodeId = getUUID().toString() |
| | | let connectNode = this.graph.addNode({ |
| | | shape: 'image', |
| | | // imageUrl: require('/public/modelImg/' + item.imgPath + '.png'), |
| | | width: 10, |
| | | height: 10, |
| | | id: connectId, |