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/nodeupdate/index.scss |    4 +
 src/tabviews/custom/components/chart/antv-X6/index.jsx             |   94 ++++++++++++++++++++----------
 src/api/index.js                                                   |   10 ++-
 package.json                                                       |    2 
 README.md                                                          |    2 
 src/tabviews/custom/components/chart/antv-X6/nodeupdate/index.jsx  |   10 +++
 6 files changed, 84 insertions(+), 38 deletions(-)

diff --git a/README.md b/README.md
index 68eb8cd..a1068e0 100644
--- a/README.md
+++ b/README.md
@@ -27,6 +27,8 @@
 
 See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
 
+node --max-old-space-size=9000 scripts/build.js
+
 ### `npm run eject`
 
 **Note: this is a one-way operation. Once you `eject`, you can鈥檛 go back!**
diff --git a/package.json b/package.json
index 719c61b..07d00b5 100644
--- a/package.json
+++ b/package.json
@@ -125,7 +125,7 @@
   },
   "scripts": {
     "dev": "set PORT=3001 && node scripts/start.js",
-    "build": "node --max-old-space-size=9000 scripts/build.js",
+    "build": "node --max-old-space-size=2048 scripts/build.js",
     "test": "node scripts/test.js"
   },
   "eslintConfig": {
diff --git a/src/api/index.js b/src/api/index.js
index 7cd5074..781daf3 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -23,10 +23,12 @@
 axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded;charset=UTF-8'
 axios.defaults.withCredentials = false
 
-// axios.interceptors.request.use((config) => {
-//   return config
-// }, (error) => {
-//   return Promise.reject(error)
+// Modal.destroyAll()
+// Modal.error({
+//   title: response.data.message,
+//   onOk: () => {
+//     sessionStorage.clear()
+//   }
 // })
 
 const setCurrentUrl = (res) => {
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)
     }
diff --git a/src/tabviews/custom/components/chart/antv-X6/nodeupdate/index.jsx b/src/tabviews/custom/components/chart/antv-X6/nodeupdate/index.jsx
index e423161..d0b7f99 100644
--- a/src/tabviews/custom/components/chart/antv-X6/nodeupdate/index.jsx
+++ b/src/tabviews/custom/components/chart/antv-X6/nodeupdate/index.jsx
@@ -7,6 +7,8 @@
 
 import './index.scss'
 
+const { TextArea } = Input
+
 class NodeUpdate extends Component {
   static propTpyes = {
     node: PropTypes.object,
@@ -228,7 +230,7 @@
           label: '鍐呭'
         },
         {
-          type: 'text',
+          type: 'textarea',
           field: 'title',
           label: '鏍囩',
           initval: title
@@ -387,6 +389,12 @@
             </Form.Item>
           </Col>
         )
+      } else if (item.type === 'textarea') {
+        fields.push(
+          <Col span={24} key={index} style={{padding: '0 12px'}}>
+            <TextArea defaultValue={item.initval} rows={3} onChange={(e) => this.change(e.target.value, item.field)} />
+          </Col>
+        )
       } else if (item.type === 'number') {
         fields.push(
           <Col span={24} key={index}>
diff --git a/src/tabviews/custom/components/chart/antv-X6/nodeupdate/index.scss b/src/tabviews/custom/components/chart/antv-X6/nodeupdate/index.scss
index 096d405..68f75dc 100644
--- a/src/tabviews/custom/components/chart/antv-X6/nodeupdate/index.scss
+++ b/src/tabviews/custom/components/chart/antv-X6/nodeupdate/index.scss
@@ -8,6 +8,10 @@
     padding-bottom: 2px;
     font-size: 13px;
   }
+  textarea.ant-input {
+    padding: 0px 4px;
+    border-radius: 0px;
+  }
   .ant-form-item {
     display: flex;
     margin-bottom: 10px;

--
Gitblit v1.8.0