From f724c64b419f148985c0bd5a1153e3fc7d84b9e6 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 12 七月 2023 17:03:27 +0800
Subject: [PATCH] Merge branch 'develop'

---
 src/tabviews/custom/components/chart/antv-X6/index.jsx |  124 +++++++++++++++++++++++++++++-----------
 1 files changed, 89 insertions(+), 35 deletions(-)

diff --git a/src/tabviews/custom/components/chart/antv-X6/index.jsx b/src/tabviews/custom/components/chart/antv-X6/index.jsx
index 3090207..71aed16 100644
--- a/src/tabviews/custom/components/chart/antv-X6/index.jsx
+++ b/src/tabviews/custom/components/chart/antv-X6/index.jsx
@@ -2,7 +2,7 @@
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
 import { Spin, Tooltip, message, Modal, notification } from 'antd'
-import { UndoOutlined, RedoOutlined, VerticalAlignTopOutlined, VerticalAlignBottomOutlined, SaveOutlined, ZoomInOutlined, ZoomOutOutlined, OneToOneOutlined, QuestionCircleOutlined } from '@ant-design/icons'
+import { UndoOutlined, RedoOutlined, VerticalAlignTopOutlined, VerticalAlignBottomOutlined, SaveOutlined, ZoomInOutlined, ZoomOutOutlined, OneToOneOutlined, QuestionCircleOutlined, ClearOutlined } from '@ant-design/icons'
 import { Graph, Shape } from '@antv/x6'
 import { Stencil } from '@antv/x6-plugin-stencil'
 import { Transform } from '@antv/x6-plugin-transform'
@@ -17,10 +17,11 @@
 import MKEmitter from '@/utils/events.js'
 import asyncComponent from '@/utils/asyncComponent'
 import NormalHeader from '@/tabviews/custom/components/share/normalheader'
-import lanes from '@/menu/components/chart/antv-X6/lane.json'
-import xflows from '@/menu/components/chart/antv-X6/xflow.json'
+// import lanes from '@/menu/components/chart/antv-X6/lane.json'
+// import xflows from '@/menu/components/chart/antv-X6/xflow.json'
 import './index.scss'
 
+const { confirm } = Modal
 const NodeUpdate = asyncComponent(() => import('./nodeupdate'))
 
 const groups = {
@@ -483,13 +484,14 @@
   }
 
   async loadData () {
-    const { config, BID } = this.state
+    const { BID } = this.state
 
-    if (config.setting.supModule && !BID) { // BID 涓嶅瓨鍦ㄦ椂锛屼笉鍋氭煡璇�
+    if (!BID) {
       if (!is(fromJS(this.data), fromJS([]))) {
         this.cells = []
         this.handleData()
       }
+      this.setState({empty: true})
       return
     }
 
@@ -497,35 +499,27 @@
       loading: true
     })
 
-    if (config) {
-      if (config.plot.subtype === 'xflow') {
-        this.cells = xflows
-      } else {
-        this.cells = lanes
-      }
-      this.handleData()
-
-      setTimeout(() => {
-        this.setState({
-          loading: false
-        })
-      }, 2000)
-      return
-    }
-
     let param = {
-      func: '',
-      BID: BID
+      func: 's_get_works_flow_local_param_v6',
+      ID: BID
     }
 
     let result = await Api.genericInterface(param)
     if (result.status) {
+      let item = result.data && result.data[0] ? result.data[0] : null
+      let cells = []
+
+      if (item && item.long_param) {
+        let long_param = JSON.parse(window.decodeURIComponent(window.atob(item.long_param)))
+        cells = long_param.cells || []
+      }
+
+      this.cells = cells
+      this.handleData()
+
       this.setState({
         loading: false
       })
-
-      this.cells = result.data || []
-      this.handleData()
 
       if (result.message) {
         if (result.ErrCode === 'Y') {
@@ -1357,13 +1351,68 @@
   }
 
   save = () => {
-    // let nodes = this.mkGraph.toJSON()
-    // this.mkGraph.toPNG((dataUri) => {
-    //   Api.fileuploadbase64({
-    //     Base64Img: dataUri
-    //   }).then(res => {
-    //   })
-    // }, {padding: 20})
+    const { BID } = this.state
+
+    if (!BID) {
+      Modal.error({
+        title: '鏈幏鍙栧埌娴佺▼ID锛屼笉鍙繚瀛橈紒',
+      })
+      return
+    }
+
+    this.setState({
+      loading: true
+    })
+
+    let nodes = this.mkGraph.toJSON()
+    this.mkGraph.toPNG((dataUri) => {
+      let param = {
+        func: 's_works_flow_param_upt_v6',
+        long_param: window.btoa(window.encodeURIComponent(JSON.stringify(nodes))),
+        flow_image: dataUri,
+        ID: BID,
+        BID: ''
+      }
+  
+      Api.genericInterface(param).then(res => {
+        if (res.status) {
+          notification.success({
+            top: 92,
+            message: '淇濆瓨鎴愬姛锛�',
+            duration: 2
+          })
+        } else {
+          notification.error({
+            top: 92,
+            message: res.message,
+            duration: 10
+          })
+        }
+      
+        this.setState({
+          loading: false
+        })
+      })
+    }, {padding: 20})
+  }
+
+  clearNode = () => {
+    let cells = this.mkGraph.getCells()
+    const that = this
+
+    if (cells.length === 0) return
+
+    confirm({
+      title: '纭畾娓呯┖鍏冪礌鍚�?',
+      content: '娓呯┖鍚庝笉鍙仮澶嶃��',
+      okText: '纭畾',
+      cancelText: '鍙栨秷',
+      onOk() {
+        that.mkGraph.removeCells(cells)
+        that.mkGraph.cleanHistory()
+      },
+      onCancel() {}
+    })
   }
 
   deleteLane = (cell, graph) => {
@@ -1693,11 +1742,13 @@
 
     if (config.plot.function === 'show') {
       if (config.plot.empty === 'hidden' && this.cells.length === 0) {
-        style.display = 'none'
+        style.position = 'absolute'
+        style.width = '100%'
+        style.zIndex = -1
       }
 
       return (
-        <div className="custom-x6-plot-box" id={'anchor' + config.uuid} style={config.style}>
+        <div className="custom-x6-plot-box" id={'anchor' + config.uuid} style={style}>
           {loading ?
             <div className="loading-mask">
               <div className="ant-spin-blur"></div>
@@ -1744,6 +1795,9 @@
             <Tooltip title="鍓嶈繘">
               <RedoOutlined onClick={this.setprev}/>
             </Tooltip>
+            <Tooltip title="娓呯┖">
+              <ClearOutlined onClick={this.clearNode}/>
+            </Tooltip>
             <Tooltip overlayStyle={{maxWidth: 260}} title="蹇嵎閿細澶嶅埗锛坈trl+c锛夈�佸壀鍒囷紙ctrl+x锛夈�佺矘璐达紙ctrl+v锛夈�佸悗閫�锛坈trl+z锛夈�佸墠杩涳紙ctrl+shift+z锛夈�佸垹闄わ紙backspace 鎴� delete锛�">
               <QuestionCircleOutlined />
             </Tooltip>

--
Gitblit v1.8.0