From fc6920985f8177f153e376fe7669c272d6b3d184 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期五, 21 二月 2020 22:02:56 +0800
Subject: [PATCH] 2020-02-21

---
 src/templates/comtableconfig/index.jsx |  100 +++++++++++++++++++++++++++++++++++++++++++------
 1 files changed, 87 insertions(+), 13 deletions(-)

diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx
index c150227..5f01667 100644
--- a/src/templates/comtableconfig/index.jsx
+++ b/src/templates/comtableconfig/index.jsx
@@ -105,11 +105,17 @@
       _config.action = _config.action.map(item => {
         let uuid = Utils.getuuid()
 
-        if (item.OpenType === 'pop') { // 鍚湁瀛愰厤缃」鐨勬寜閽�傘�傘��
+        if (item.OpenType === 'pop') { // 鍚湁瀛愰厤缃」鐨勬寜閽�(琛ㄥ崟)
           _oriActions.push({
             prebtn: JSON.parse(JSON.stringify(item)),
             curuuid: uuid,
             Template: 'Modal'
+          })
+        } else if (item.OpenType === 'tab' || item.OpenType === 'blank') { // 鍚湁瀛愰厤缃」鐨勬寜閽�(鏍囩鍚庡綋鍓嶉〉鎵撳紑)
+          _oriActions.push({
+            prebtn: JSON.parse(JSON.stringify(item)),
+            curuuid: uuid,
+            Template: item.tabTemplate
           })
         }
 
@@ -1444,6 +1450,32 @@
     this.props.handleView({tabview: 'template'})
   }
 
+  getFuncNames = (data, funcNames, tableNames) => {
+    data.forEach(item => {
+      if (item.subfuncs) {
+        this.getFuncNames(item.subfuncs, funcNames, tableNames)
+      } else {
+        if (item.tableName) {
+          tableNames.push(item.tableName)
+        }
+        if (item.innerFunc) {
+          funcNames.push(item.innerFunc)
+        }
+        // if (item.outerFunc) {
+        //   funcNames.push(item.outerFunc)
+        // }
+        if (item.callbackFunc) {
+          funcNames.push(item.callbackFunc)
+        }
+      }
+    })
+
+    return {
+      func: funcNames,
+      table: tableNames
+    }
+  }
+
   /**
    * @description 涓夌骇鑿滃崟淇濆瓨
    */
@@ -1529,7 +1561,7 @@
             subtype: 'btn',
             uuid: item.uuid,
             label: item.label,
-            tablename: tablename,
+            tableName: tablename,
             intertype: item.intertype,
             interface: item.interface || '',
             innerFunc: item.innerFunc || '',
@@ -1632,7 +1664,7 @@
           Template: menu.PageParam.Template || '',
           PageParam: '',
           LongParam: '',
-          LText: config.action.map((item, index) => {
+          LText: _config.action.map((item, index) => {
             return `select '${item.uuid}' as menuid, '${item.label}' as menuname, '${(index + 1) * 10}' as Sort`
           })
         }
@@ -1645,15 +1677,20 @@
         let tabParam = { // 娣诲姞鑿滃崟tab椤�
           func: 'sPC_sMenusTab_AddUpt',
           MenuID: menu.MenuID,
-          LText: config.tabs.map((item, index) => {
+          LText: _config.tabs.map((item, index) => {
             return `select '${menu.MenuID}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${(index + 1) * 10}' as Sort`
           })
         }
+
         tabParam.LText = tabParam.LText.join(' union all ')
         tabParam.LText = Utils.formatOptions(tabParam.LText)
         tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
         tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp)
   
+        let _vals = this.getFuncNames(_config.funcs, [], [])
+        let _funcs = Array.from(new Set(_vals.func))
+        let _tables = Array.from(new Set(_vals.table))
+
         let param = {
           func: 'sPC_TrdMenu_AddUpt',
           ParentID: res.parentId,
@@ -1663,9 +1700,18 @@
           MenuName: res.menuName,
           Sort: (this.props.supMenuList.length + 1) * 10,
           PageParam: JSON.stringify(_pageParam),
-          LongParam: _LongParam
+          LongParam: _LongParam,
+          LText: _funcs.map(item => `select '${menu.MenuID}' as MenuID,'${item}' as ProcName`),
+          LTexttb: _tables.map(item => `select '${menu.MenuID}' as MenuID,'${item}' as tbName`)
         }
-  
+
+        param.LText = param.LText.join(' union all ')
+        param.LText = Utils.formatOptions(param.LText)
+        param.LTexttb = param.LTexttb.join(' union all ')
+        param.LTexttb = Utils.formatOptions(param.LTexttb)
+        param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
+        param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+
         // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣�
         // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆
         new Promise(resolve => {
@@ -1811,6 +1857,8 @@
     }).then(response => {
       if (response === false) return response
 
+      if (!this.state.originActions || this.state.originActions.length === 0) return 'true'
+
       let oriActions = []
       this.state.originActions.forEach(item => {
         let curBtn = config.action.filter(cell => item.curuuid === cell.uuid)[0] // 鏌ョ湅鍒濆鍖栨寜閽槸鍚﹀瓨鍦�
@@ -1834,14 +1882,39 @@
         }).then(result => {
           if (result.status && result.LongParam) {
             let _LongParam = ''
-  
+            let _temp = ''
+
             if (result.LongParam) {
+              let _subconfig = ''
               try {
-                _LongParam = window.decodeURIComponent(window.atob(result.LongParam))
-                _LongParam = JSON.parse(_LongParam)
+                _subconfig = window.decodeURIComponent(window.atob(result.LongParam))
+                _subconfig = JSON.parse(_subconfig)
+                _temp = _subconfig.type
               } catch (e) {
-                _LongParam = ''
+                _subconfig = ''
               }
+
+              if (_temp === 'FormTab') {
+                try {
+                  _subconfig.action = _subconfig.action.map(_btn => {
+                    _btn.uuid = Utils.getuuid()
+  
+                    return _btn
+                  })
+                  _subconfig.tabgroups.forEach(_groupId => {
+                    _subconfig[_groupId] = _subconfig[_groupId].map(_tab => {
+                      _tab.uuid = Utils.getuuid()
+  
+                      return _tab
+                    })
+                  })
+                  _subconfig = window.btoa(window.encodeURIComponent(JSON.stringify(_subconfig)))
+                } catch {
+                  _subconfig = ''
+                }
+              }
+
+              _LongParam = _subconfig
             }
 
             if (_LongParam) {
@@ -1850,10 +1923,10 @@
                 ParentID: this.props.menu.MenuID,
                 MenuID: action.curBtn.uuid,
                 MenuNo: this.props.menu.MenuNo,
-                Template: _LongParam.type,
+                Template: _temp,
                 MenuName: action.curBtn.label,
-                PageParam: JSON.stringify({Template: _LongParam.type}),
-                LongParam: result.LongParam
+                PageParam: JSON.stringify({Template: _temp}),
+                LongParam: _LongParam
               }
               Api.getSystemConfig(param).then(() => {})
             }
@@ -1872,6 +1945,7 @@
           this.props.handleView()
         } else {
           this.setState({
+            originActions: [],
             menuloading: false,
             menucloseloading: false
           })

--
Gitblit v1.8.0