From f2914103477e253f8af4b9f847933c0c7848c330 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 29 六月 2023 18:21:31 +0800
Subject: [PATCH] 2023-06-29

---
 src/tabviews/custom/components/chart/antv-X6/index.jsx |   94 +++++++++++++++++++++++++++++++----------------
 1 files changed, 62 insertions(+), 32 deletions(-)

diff --git a/src/tabviews/custom/components/chart/antv-X6/index.jsx b/src/tabviews/custom/components/chart/antv-X6/index.jsx
index 66b6b4c..4bb634b 100644
--- a/src/tabviews/custom/components/chart/antv-X6/index.jsx
+++ b/src/tabviews/custom/components/chart/antv-X6/index.jsx
@@ -330,21 +330,6 @@
       }
     }
   },
-  // {
-  //   inherit: 'rect',
-  //   width: 66,
-  //   height: 36,
-  //   attrs: {
-  //     body: {
-  //       strokeWidth: 0,
-  //       fill: 'transparent'
-  //     },
-  //     text: {
-  //       fontSize: 12,
-  //       fill: '#262626'
-  //     }
-  //   }
-  // },
   true
 )
 
@@ -386,7 +371,7 @@
     if (BData) {
       BID = BData.$BID || ''
     }
-    
+
     this.setState({
       config: _config,
       BID: BID || '',
@@ -912,19 +897,19 @@
       showPorts(ports, false)
     })
 
-    graph.on('node:click', ({ e, x, y, node, view }) => {
+    graph.on('node:click', ({ node }) => {
       this.selectNode = node
       
       this.setState({node: node.store.data})
     })
-    graph.on('edge:click', ({ e, x, y, edge, view }) => {
+    graph.on('edge:click', ({ edge }) => {
       this.selectNode = edge
       
       this.setState({node: edge.store.data})
 
       graph.clearTransformWidgets()
     })
-    graph.on('blank:click', ({ e, x, y }) => {
+    graph.on('blank:click', () => {
       this.selectNode = null
       
       this.setState({node: null})
@@ -989,8 +974,7 @@
     })
 
     const p3 = graph.createNode({
-      shape: 'mk-text',
-      label: '鏂囨湰'
+      shape: 'mk-text'
     })
     
     stencil.load([p1, p2, p3], 'group2')
@@ -1095,8 +1079,15 @@
     })
 
     graph
+      .use(new Transform({
+        resizing: true,
+        rotating: true
+      }))
       .use(new Selection())
-      .use(new Snapline())
+      .use(new Snapline({
+        enabled: true,
+        filter: (Graph) => Graph.prop('shape') !== 'lane'
+      }))
       .use(new Keyboard())
       .use(new Clipboard())
       .use(new History())
@@ -1141,14 +1132,18 @@
     graph.bindKey(['meta+c', 'ctrl+c'], () => {
       const cells = graph.getSelectedCells()
       if (cells.length) {
-        graph.copy(cells)
+        if (cells[0].prop('shape') !== 'lane' && cells[0].prop('shape') !== 'edge') {
+          graph.copy(cells)
+        }
       }
       return false
     })
     graph.bindKey(['meta+x', 'ctrl+x'], () => {
       const cells = graph.getSelectedCells()
       if (cells.length) {
-        graph.cut(cells)
+        if (cells[0].prop('shape') !== 'lane' && cells[0].prop('shape') !== 'edge') {
+          graph.cut(cells)
+        }
       }
       return false
     })
@@ -1175,9 +1170,19 @@
     graph.bindKey(['backspace', 'delete'], () => {
       const cells = graph.getSelectedCells()
       if (cells.length) {
-        graph.removeCells(cells)
         this.selectNode = null
         this.setState({node: null})
+        
+        if (cells[0].prop('shape') === 'lane') {
+          graph.startBatch('delete-lane')
+
+          graph.removeCells(cells)
+          this.deleteLane(cells[0], graph)
+
+          graph.stopBatch('delete-lane')
+        } else {
+          graph.removeCells(cells)
+        }
       }
     })
 
@@ -1199,8 +1204,10 @@
       showPorts(ports, false)
     })
 
-    graph.on('node:added', ({ cell, index, options }) => {
+    graph.on('node:added', ({ cell }) => {
       if (cell.prop('shape') === 'lane') {
+        if (cell.prop('zIndex') === 0) return
+
         graph.startBatch('add-lane')
 
         this.addLane(cell, graph)
@@ -1212,22 +1219,26 @@
         if (num <= 1) {
           message.warning('璇锋坊鍔犳吵閬擄紒')
           graph.removeCells([cell])
-        } else {
+        } else if (!cell.prop('parent')) {
           this.addNode(cell, graph)
         }
       }
     })
-    graph.on('node:click', ({ e, x, y, node, view }) => {
+    graph.on('node:click', ({ node }) => {
       this.selectNode = node
       this.setState({node: node.store.data})
+
+      if (node.prop('shape') === 'lane') {
+        graph.clearTransformWidgets()
+      }
     })
-    graph.on('edge:click', ({ e, x, y, edge, view }) => {
+    graph.on('edge:click', ({ edge }) => {
       this.selectNode = edge
       this.setState({node: edge.store.data})
 
       graph.clearTransformWidgets()
     })
-    graph.on('blank:click', ({ e, x, y }) => {
+    graph.on('blank:click', () => {
       this.selectNode = null
       
       this.setState({node: null})
@@ -1292,8 +1303,7 @@
     })
 
     const p3 = graph.createNode({
-      shape: 'mk-text',
-      label: '鏂囨湰'
+      shape: 'mk-text'
     })
     
     stencil.load([p1, p2, p3], 'group2')
@@ -1372,6 +1382,25 @@
     // }, {padding: 20})
   }
 
+  deleteLane = (cell, graph) => {
+    let id = cell.id
+
+    let nodes = graph.getNodes()
+    let cells = []
+
+    nodes.forEach(item => {
+      if (item.prop('shape') === 'lane') return
+
+      if (item.prop('parent') === id) {
+        cells.push(item)
+      }
+    })
+
+    graph.removeCells(cells)
+
+    this.resetlane(cell.id, cell.prop('position/x'), -cell.prop('size/width'))
+  }
+
   addLane = (cell, graph) => {
     const { config } = this.state
 
@@ -1406,6 +1435,7 @@
     }
 
     let height = 400
+
     if (typeof(config.plot.height) === 'number' || /px/.test(config.plot.height)) {
       height = parseInt(config.plot.height)
     }

--
Gitblit v1.8.0