From 465be8b618c1fb139d56ed779ff6f4dbc8d89b89 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 04 八月 2023 15:47:14 +0800
Subject: [PATCH] 2023-08-04

---
 src/menu/tablenodes/index.jsx |  169 +++++++++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 149 insertions(+), 20 deletions(-)

diff --git a/src/menu/tablenodes/index.jsx b/src/menu/tablenodes/index.jsx
index 0610c01..26fb797 100644
--- a/src/menu/tablenodes/index.jsx
+++ b/src/menu/tablenodes/index.jsx
@@ -1,7 +1,7 @@
 import React, {Component} from 'react'
 import PropTypes from 'prop-types'
 import { is, fromJS } from 'immutable'
-import { Modal, Button, notification, Spin, Input } from 'antd'
+import { Modal, Button, notification, Spin, Input, message } from 'antd'
 import { ForkOutlined } from '@ant-design/icons'
 
 import Api from '@/api'
@@ -55,7 +55,56 @@
       })
     }
 
-    traversal(config.components)
+    if (config.Template === 'BaseTable') {
+      config.components.forEach(item => {
+        if (item.type === 'tabs') {
+          item.subtabs.forEach(tab => {
+            if (tab.components[0].$tables) {
+              ptbs.push(...tab.components[0].$tables)
+              tab.components[0].$tables.forEach(tb => {
+                tbs.push({
+                  label: tab.label,
+                  table: tb,
+                  color: '#5AD8A6',
+                  id: Utils.getuuid(),
+                  direction: 'left'
+                })
+              })
+            }
+          })
+        } else if (item.$tables) {
+          ptbs.push(...item.$tables)
+          item.$tables.forEach(tb => {
+            tbs.push({
+              label: '涓昏〃',
+              table: tb,
+              color: '#5AD8A6',
+              id: Utils.getuuid(),
+              direction: 'left'
+            })
+          })
+        }
+      })
+    } else {
+      traversal(config.components)
+
+      if (config.interfaces) {
+        config.interfaces.forEach(item => {
+          if (item.$tables) {
+            ptbs.push(...item.$tables)
+            item.$tables.forEach(tb => {
+              tbs.push({
+                label: item.name,
+                table: tb,
+                color: '#5AD8A6',
+                id: Utils.getuuid(),
+                direction: 'left'
+              })
+            })
+          }
+        })
+      }
+    }
 
     return {tbs, ptbs}
   }
@@ -73,7 +122,7 @@
         MenuID: config.uuid
       }
 
-      Api.getSystemConfig(param).then(result => {
+      Api.getCloudConfig(param).then(result => {
         if (!result.status) {
           notification.warning({
             top: 92,
@@ -109,6 +158,7 @@
               id: 'par' + i,
               direction: 'left',
               color: '#5AD8A6',
+              node: 'table',
               children: []
             }
 
@@ -124,6 +174,7 @@
 
         if (result.tb_list) {
           result.tb_list.sort((a, b) => a.tbname > b.tbname ? 1 : -1)
+          let length = result.tb_list.length
           result.tb_list.forEach((item, i) => {
             let cell = {
               label: item.tbname,
@@ -131,6 +182,8 @@
               id: 'table' + i,
               direction: 'right',
               color: '#1890ff',
+              collapsed: false,
+              collable: true,
               children: []
             }
 
@@ -138,15 +191,28 @@
               item[item.tbname].forEach((m, i) => {
                 if (m.debug_url) {
                   let _param = JSON.parse(window.decodeURIComponent(window.atob(m.debug_url)))
+                  let label = _param.MenuName
+
+                  if (_param && _param.type === 'app') {
+                    label += ` (${_param.kei_no} | ${_param.typename}${param.lang !== 'zh-CN' ? ' | ' + param.lang : ''})`
+                  }
+
                   cell.children.push({
-                    label: _param.MenuName,
+                    label: label,
                     id: item.tbname + 'menu' + i,
                     direction: 'right',
                     color: '#1890ff',
+                    type: 'dice-mind-map-leaf',
                     param: _param
                   })
                 }
               })
+            }
+
+            if (cell.children.length > 5 && length > 1) {
+              cell.collapsed = true
+            } else if (cell.children.length === 0) {
+              cell.collable = false
             }
 
             data.children.push(cell)
@@ -167,7 +233,12 @@
     if (menu.direction !== 'right') return
 
     if (menu.depth === 1) {
+      sessionStorage.setItem('mk-table-node', menu.label)
       window.open('#/hs')
+
+      setTimeout(() => {
+        sessionStorage.removeItem('mk-table-node')
+      }, 50)
     } else if (menu.param) {
       if (menu.param.type === 'admin') {
         if (menu.param.MenuType === 'custom') {
@@ -175,6 +246,22 @@
           delete _param.type
           _param = window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
           window.open(`#/menudesign/${_param}`)
+        } else if (menu.param.MenuType === 'BaseTable') {
+          let _param = {...menu.param}
+          delete _param.type
+          delete _param.MenuType
+          _param = window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
+          window.open(`#/tabledesign/${_param}`)
+        }
+      } else if (menu.param.type === 'app') {
+        if (menu.param.typename !== 'pc') {
+          let _param = {...menu.param}
+          _param = window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
+          window.open(`#/mobdesign/${_param}`)
+        } else {
+          let _param = {...menu.param}
+          _param = window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
+          window.open(`#/pcdesign/${_param}`)
         }
       }
     }
@@ -213,12 +300,12 @@
           const stroke = cfg.style.stroke || '#096dd9';
     
           return `
-          <group>
-            <rect draggable="true" style={{width: ${width}, height: 30, stroke: ${stroke}, radius: 4}} keyshape>
-              <text style={{ fontSize: 14, marginLeft: 6, marginTop: 6 }}>${cfg.label}</text>
-            </rect>
-          </group>
-        `;
+            <group>
+              <rect draggable="true" style={{width: ${width}, height: 30, stroke: ${stroke}, radius: 4}} keyshape>
+                <text style={{ fontSize: 14, marginLeft: 6, marginTop: 6 }}>${cfg.label}</text>
+              </rect>
+            </group>
+          `;
         },
         getAnchorPoints() {
           return [
@@ -237,13 +324,13 @@
           const color = cfg.color;
     
           return `
-          <group>
-            <rect draggable="true" style={{width: ${width}, height: 26, cursor: ${cfg.direction !== 'left' ? 'pointer' : 'default'}, fill: 'transparent' }}>
-              <text style={{ fontSize: 12, fill: ${cfg.fontcolor ? cfg.fontcolor : 'black'}, cursor: ${cfg.direction !== 'left' ? 'pointer' : 'default'}, marginLeft: 12, marginTop: 6 }}>${cfg.label}</text>
-            </rect>
-            <rect style={{ fill: ${color}, width: ${width}, cursor: ${cfg.direction !== 'left' ? 'pointer' : 'default'}, height: 2, x: 0, y: 32 }} />
-          </group>
-        `;
+            <group>
+              <rect draggable="true" style={{width: ${width}, height: 26, cursor: ${cfg.direction !== 'left' ? 'pointer' : 'default'}, fill: 'transparent' }}>
+                <text style={{ fontSize: 12, fill: ${cfg.fontcolor ? cfg.fontcolor : 'black'}, cursor: ${cfg.direction !== 'left' ? 'pointer' : 'default'}, marginLeft: 12, marginTop: 6 }}>${cfg.label} ${cfg.collable ? '+' : ''}</text>
+              </rect>
+              <rect style={{ fill: ${color}, width: ${width}, cursor: ${cfg.direction !== 'left' ? 'pointer' : 'default'}, height: 2, x: 0, y: 32 }} />
+            </group>
+          `;
         },
         getAnchorPoints() {
           return [
@@ -263,6 +350,35 @@
       editNode(evt) {
         const item = evt.item;
         const model = item.get('model');
+
+        // 閫変腑鑺傜偣
+        this.graph.getNodes().forEach(node => {
+          let _model = node.get('model')
+          if (_model.fontcolor === '#1890ff') {
+            _model.fontcolor = ''
+            this.graph.updateItem(node, _model, false)
+          }
+        })
+
+        if (model.direction === 'left') {
+          if (model.node === 'table') {
+            model.fontcolor = '#1890ff'
+            this.graph.updateItem(item, model, false)
+
+            let oInput = document.createElement('input')
+            oInput.value = model.label
+            document.body.appendChild(oInput)
+            oInput.select()
+            document.execCommand('Copy')
+            document.body.removeChild(oInput)
+            
+            message.success('琛ㄥ悕澶嶅埗鎴愬姛銆�')
+          }
+          return
+        }
+
+        model.fontcolor = '#1890ff'
+        this.graph.updateItem(item, model, false)
         
         that.changeMenu(model)
       }
@@ -323,7 +439,7 @@
           data.color = color;
         }
     
-        if (d.children) {
+        if (d.children && !d.collapsed) {
           data.children = d.children.map((child) => changeData(child, level + 1, data.color));
         }
         return data;
@@ -364,9 +480,21 @@
           lineWidth: 2,
         },
       },
-      minZoom: 0.5,
+      minZoom: 0.3,
       modes: {
-        default: ['drag-canvas', 'zoom-canvas', 'dice-mindmap'],
+        default: [
+          {
+            type: 'collapse-expand',
+            trigger: 'click',
+            shouldBegin: (e, self) => {
+              if (e.item && e.item.getModel().collable) return true;
+              return false;
+            },
+          },
+          'drag-canvas',
+          'zoom-canvas',
+          'dice-mindmap'
+        ],
       },
     });
     
@@ -400,6 +528,7 @@
           </div>
           <div className="footer">
             <Button key="cancel" onClick={() => { this.setState({ visible: false })}}>鍏抽棴</Button>
+            <span className="tip">娉細鐐瑰嚮琛ㄥ悕鍙睍寮�/鏀惰捣鑿滃崟</span>
           </div>
         </Modal>
       </div>

--
Gitblit v1.8.0