From e9640ccdc9fe57f91919e3f51462c780e44fadb0 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 23 十二月 2020 13:14:20 +0800
Subject: [PATCH] 2020-12-23

---
 src/templates/comtableconfig/index.jsx |  509 +++++++++++++++++++++++++------------------------------
 1 files changed, 232 insertions(+), 277 deletions(-)

diff --git a/src/templates/comtableconfig/index.jsx b/src/templates/comtableconfig/index.jsx
index e23bbbf..a6d10ff 100644
--- a/src/templates/comtableconfig/index.jsx
+++ b/src/templates/comtableconfig/index.jsx
@@ -202,13 +202,11 @@
     })
   }
 
-  getFuncNames = (data, funcNames, tableNames) => {
+  getFuncNames = (data) => {
+    let funcNames = []
+    let tableNames = []
+
     data.forEach(item => {
-      // if (item.subfuncs) {
-      //   this.getFuncNames(item.subfuncs, funcNames, tableNames)
-      //   return
-      // }
-      
       if (item.tableName) {
         tableNames.push(item.tableName)
       }
@@ -220,6 +218,8 @@
         funcNames.push({func: item.callbackFunc, label: item.label || ''})
       }
     })
+
+    tableNames = Array.from(new Set(tableNames))
 
     return {
       func: funcNames,
@@ -354,297 +354,252 @@
       })
     }
 
-    new Promise(resolve => {
-      // let deffers = []
-      // _config.funcs.forEach(item => {
-      //   if (item.type === 'tab') {
-      //     let deffer = new Promise(resolve => {
-      //       Api.getSystemConfig({
-      //         func: 'sPC_Get_LongParam',
-      //         MenuID: item.linkTab
-      //       }).then(result => {
-      //         if (result.status && result.LongParam) {
-      //           let _LongParam = ''
+    // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser
+    delete _config.type
+    delete _config.isAdd
+
+    let _LongParam = ''
+
+    try {
+      _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config)))
+    } catch (e) {
+      notification.warning({
+        top: 92,
+        message: '缂栬瘧閿欒',
+        duration: 5
+      })
+      this.setState({
+        menucloseloading: false,
+        menuloading: false
+      })
+      return
+    }
+
+    let _sort = 0
+    let btntabs = []
+
+    let btnParam = {             // 娣诲姞鑿滃崟鎸夐挳
+      func: 'sPC_Button_AddUpt',
+      Type: 40,                  // 娣诲姞鑿滃崟涓嬬殑鎸夐挳type涓�40锛屾寜閽笅鐨勬寜閽畉ype涓�60
+      ParentID: menu.MenuID,
+      MenuNo: _config.MenuNo,
+      Template: _config.Template || '',
+      PageParam: '',
+      LongParam: '',
+      LText: []
+    }
+
+    _config.action.forEach(item => {
+      _sort++
+      if (item.OpenType === 'popview') {
+        btntabs.push({
+          uuid: item.uuid,
+          linkTab: item.linkTab,
+          label: item.label,
+          sort: _sort
+        })
+      }
       
-      //           if (result.LongParam) {
-      //             try {
-      //               _LongParam = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
-      //             } catch (e) {
-      //               console.warn('Parse Failure')
-      //               _LongParam = ''
-      //             }
-      //           }
+      btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${_sort * 10}' as Sort`)
+    })
+
+    btnParam.LText = btnParam.LText.join(' union all ')
+    btnParam.LText = Utils.formatOptions(btnParam.LText)
+    btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+    btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp)
     
-      //           if (_LongParam) {
-      //             item.menuNo = _LongParam.tabNo || ''
-      //             item.subfuncs = _LongParam.funcs || []
-      //           }
-      //         }
-      //         resolve()
-      //       })
-      //     })
+    let tabParam = { // 娣诲姞鑿滃崟tab椤�
+      func: 'sPC_sMenusTab_AddUpt',
+      MenuID: menu.MenuID
+    }
 
-      //     deffers.push(deffer)
-      //   }
-      // })
+    let _LText = []
 
-      // if (deffers.length === 0) {
-      //   resolve()
-      // } else {
-      //   Promise.all(deffers).then(() => {
-      //     resolve()
-      //   })
-      // }
-      resolve()
-    }).then(() => {
-      // 淇濆瓨鏃跺垹闄ら厤缃被鍨嬶紝system 銆乽ser
-      delete _config.type
-      delete _config.isAdd
-
-      let _LongParam = ''
-
-      try {
-        _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(_config)))
-      } catch (e) {
-        notification.warning({
-          top: 92,
-          message: '缂栬瘧閿欒',
-          duration: 5
-        })
-        this.setState({
-          menucloseloading: false,
-          menuloading: false
-        })
-        return
-      }
-
-      let _sort = 0
-      let btntabs = []
-
-      let btnParam = {             // 娣诲姞鑿滃崟鎸夐挳
-        func: 'sPC_Button_AddUpt',
-        Type: 40,                  // 娣诲姞鑿滃崟涓嬬殑鎸夐挳type涓�40锛屾寜閽笅鐨勬寜閽畉ype涓�60
-        ParentID: menu.MenuID,
-        MenuNo: _config.MenuNo,
-        Template: _config.Template || '',
-        PageParam: '',
-        LongParam: '',
-        LText: []
-      }
-
-      _config.action.forEach(item => {
+    btntabs.forEach(item => {
+      _LText.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${item.sort * 10}' as Sort`)
+    })
+    _config.tabgroups.forEach(group => {
+      group.sublist.forEach(item => {
         _sort++
-        if (item.OpenType === 'popview') {
-          btntabs.push({
-            uuid: item.uuid,
-            linkTab: item.linkTab,
-            label: item.label,
-            sort: _sort
+        _LText.push(`select '${menu.MenuID}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${_sort * 10}' as Sort`)
+      })
+    })
+
+    _LText = _LText.join(' union all ')
+
+    // 娓呯┖鑿滃崟涓嬪叧鑱旂殑鏍囩
+    if (!_LText) {
+      _LText = `select '${menu.MenuID}' as MenuID ,'' as Tabid,'' as TabName ,'0' as Sort`
+    }
+
+    tabParam.LText = Utils.formatOptions(_LText)
+    tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
+    tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp)
+
+    let _vals = this.getFuncNames(_config.funcs)
+
+    let param = {
+      func: 'sPC_TrdMenu_AddUpt',
+      FstID: _config.fstMenuId,
+      SndID: _config.ParentId,
+      ParentID: _config.ParentId,
+      MenuID: menu.MenuID,
+      MenuNo: _config.MenuNo,
+      EasyCode: _config.easyCode || '',
+      Template: _config.Template || '',
+      MenuName: _config.MenuName,
+      PageParam: JSON.stringify({...menu.PageParam, Template: _config.Template, OpenType: _config.OpenType}),
+      LongParam: _LongParam,
+      LText: _vals.func.map(item => `select '${menu.MenuID}' as MenuID,'${item.func}' as ProcName,'${item.label}' as MenuName`),
+      LTexttb: _vals.table.map(item => `select '${menu.MenuID}' as MenuID,'${item}' as tbName`)
+    }
+
+    if (menu.menuSort) { // 鑿滃崟鏂板缓鏃惰缃帓搴�
+      param.Sort = menu.menuSort
+    }
+
+    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')
+    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+
+    if (openEdition) { // 鐗堟湰绠$悊
+      param.open_edition = openEdition
+    }
+
+    // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣�
+    // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆
+    new Promise(resolve => {
+      if (delActions.length > 0) {
+        let deffers = delActions.map(item => {
+          let _param = {
+            func: 'sPC_MainMenu_Del',
+            MenuID: item.card ? item.card.uuid : item.uuid
+          }
+
+          if (item.type === 'action') {
+            let _ParentParam = null
+
+            try {
+              _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card)))
+            } catch (e) {
+              console.warn('Stringify Failure')
+              _ParentParam = null
+            }
+
+            if (_ParentParam) { // 鍒犻櫎鎸夐挳鏃讹紝淇濆瓨鎸夐挳閰嶇疆淇℃伅锛岀敤浜庢仮澶嶆寜閽�
+              _param.ParentParam = _ParentParam
+            }
+          }
+
+          return new Promise(resolve => {
+            Api.getSystemConfig(_param).then(response => {
+              resolve(response)
+            })
           })
-        }
-        
-        btnParam.LText.push(`select '${item.uuid}' as menuid, '${item.label}' as menuname, '${_sort * 10}' as Sort`)
-      })
-
-      btnParam.LText = btnParam.LText.join(' union all ')
-      btnParam.LText = Utils.formatOptions(btnParam.LText)
-      btnParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      btnParam.secretkey = Utils.encrypt(btnParam.LText, btnParam.timestamp)
-      
-      let tabParam = { // 娣诲姞鑿滃崟tab椤�
-        func: 'sPC_sMenusTab_AddUpt',
-        MenuID: menu.MenuID
-      }
-
-      let _LText = []
-
-      btntabs.forEach(item => {
-        _LText.push(`select '${item.uuid}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${item.sort * 10}' as Sort`)
-      })
-      _config.tabgroups.forEach(group => {
-        group.sublist.forEach(item => {
-          _sort++
-          _LText.push(`select '${menu.MenuID}' as MenuID ,'${item.linkTab}' as Tabid,'${item.label}' as TabName ,'${_sort * 10}' as Sort`)
         })
-      })
-
-      _LText = _LText.join(' union all ')
-
-      // 娓呯┖鑿滃崟涓嬪叧鑱旂殑鏍囩
-      if (!_LText) {
-        _LText = `select '${menu.MenuID}' as MenuID ,'' as Tabid,'' as TabName ,'0' as Sort`
-      }
-
-      tabParam.LText = Utils.formatOptions(_LText)
-      tabParam.timestamp = moment().format('YYYY-MM-DD HH:mm:ss')
-      tabParam.secretkey = Utils.encrypt(tabParam.LText, tabParam.timestamp)
-
-      let _vals = this.getFuncNames(_config.funcs, [], [])
-      let _tables = Array.from(new Set(_vals.table))
-
-      let param = {
-        func: 'sPC_TrdMenu_AddUpt',
-        FstID: _config.fstMenuId,
-        SndID: _config.ParentId,
-        ParentID: _config.ParentId,
-        MenuID: menu.MenuID,
-        MenuNo: _config.MenuNo,
-        EasyCode: _config.easyCode || '',
-        Template: _config.Template || '',
-        MenuName: _config.MenuName,
-        PageParam: JSON.stringify({...menu.PageParam, Template: _config.Template, OpenType: _config.OpenType}),
-        LongParam: _LongParam,
-        LText: _vals.func.map(item => `select '${menu.MenuID}' as MenuID,'${item.func}' as ProcName,'${item.label}' as MenuName`),
-        LTexttb: _tables.map(item => `select '${menu.MenuID}' as MenuID,'${item}' as tbName`)
-      }
-
-      if (menu.menuSort) { // 鑿滃崟鏂板缓鏃惰缃帓搴�
-        param.Sort = menu.menuSort
-      }
-
-      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')
-      param.secretkey = Utils.encrypt(param.LText, param.timestamp)
-
-      if (openEdition) { // 鐗堟湰绠$悊
-        param.open_edition = openEdition
-      }
-
-      // 鏈夋寜閽垨鏍囩鍒犻櫎鏃讹紝鍏堣繘琛屽垹闄ゆ搷浣�
-      // 鍒犻櫎鎴愬姛鍚庯紝淇濆瓨椤甸潰閰嶇疆
-      new Promise(resolve => {
-        if (delActions.length > 0) {
-          let deffers = delActions.map(item => {
-            let _param = {
-              func: 'sPC_MainMenu_Del',
-              MenuID: item.card ? item.card.uuid : item.uuid
-            }
-
-            if (item.type === 'action') {
-              let _ParentParam = null
-
-              try {
-                _ParentParam = window.btoa(window.encodeURIComponent(JSON.stringify(item.card)))
-              } catch (e) {
-                console.warn('Stringify Failure')
-                _ParentParam = null
-              }
-
-              if (_ParentParam) { // 鍒犻櫎鎸夐挳鏃讹紝淇濆瓨鎸夐挳閰嶇疆淇℃伅锛岀敤浜庢仮澶嶆寜閽�
-                _param.ParentParam = _ParentParam
-              }
-            }
-
-            return new Promise(resolve => {
-              Api.getSystemConfig(_param).then(response => {
-                resolve(response)
-              })
-            })
-          })
-          Promise.all(deffers).then(result => {
-            let error = null
-            result.forEach(response => {
-              if (!response.status) {
-                error = response
-              }
-            })
-  
-            if (error) {
-              this.setState({
-                menuloading: false,
-                menucloseloading: false
-              })
-              notification.warning({
-                top: 92,
-                message: error.message,
-                duration: 5
-              })
-              resolve(false)
-            } else {
-              this.setState({
-                delActions: []
-              })
-              resolve(true)
+        Promise.all(deffers).then(result => {
+          let error = null
+          result.forEach(response => {
+            if (!response.status) {
+              error = response
             }
           })
-        } else if (delActions.length === 0) {
-          resolve(true)
-        }
-      }).then(resp => {
-        if (resp === false) return
 
-        if (thawButtons.length > 0) {
-          let defers = thawButtons.map(item => {
-            return new Promise((resolve) => {
-              Api.getSystemConfig({
-                func: 'sPC_MainMenu_ReDel',
-                MenuID: item
-              }).then(res => {
-                if (res.status) {
-                  resolve('')
-                } else {
-                  resolve(res.message)
-                }
-              })
-            })
-          })
-
-          return Promise.all(defers)
-        } else {
-          return true
-        }
-      }).then(res => {
-        if (res === true || res === false) return res
-
-        let msg = res.filter(Boolean)[0]
-        if (msg) {
-          notification.warning({
-            top: 92,
-            message: msg,
-            duration: 5
-          })
-          return false
-        } else {
-          this.setState({
-            thawButtons: []
-          })
-          return true
-        }
-      }).then(resp => {
-        if (resp === false) return
-        let localParam = fromJS(param).toJS()
-        Api.getSystemConfig(param).then(response => {
-          if (response.status) {
-            this.setState({
-              config: _config,
-              openEdition: response.open_edition || '',
-              originMenu: fromJS(_config).toJS()
-            })
-
-            localParam.func = 'sPC_TrdMenu_AddUpt_For_Local'
-            delete localParam.LongParam
-            delete localParam.PageParam
-            delete localParam.Template
-            delete localParam.Sort
-            delete localParam.EasyCode
-            delete localParam.open_edition
-
-            this.submitAction(btnParam, tabParam, localParam)
-          } else {
+          if (error) {
             this.setState({
               menuloading: false,
               menucloseloading: false
             })
             notification.warning({
               top: 92,
-              message: response.message,
+              message: error.message,
               duration: 5
             })
+            resolve(false)
+          } else {
+            this.setState({
+              delActions: []
+            })
+            resolve(true)
           }
         })
+      } else if (delActions.length === 0) {
+        resolve(true)
+      }
+    }).then(resp => {
+      if (resp === false) return
+
+      if (thawButtons.length > 0) {
+        let defers = thawButtons.map(item => {
+          return new Promise((resolve) => {
+            Api.getSystemConfig({
+              func: 'sPC_MainMenu_ReDel',
+              MenuID: item
+            }).then(res => {
+              if (res.status) {
+                resolve('')
+              } else {
+                resolve(res.message)
+              }
+            })
+          })
+        })
+
+        return Promise.all(defers)
+      } else {
+        return true
+      }
+    }).then(res => {
+      if (res === true || res === false) return res
+
+      let msg = res.filter(Boolean)[0]
+      if (msg) {
+        notification.warning({
+          top: 92,
+          message: msg,
+          duration: 5
+        })
+        return false
+      } else {
+        this.setState({
+          thawButtons: []
+        })
+        return true
+      }
+    }).then(resp => {
+      if (resp === false) return
+      let localParam = fromJS(param).toJS()
+      Api.getSystemConfig(param).then(response => {
+        if (response.status) {
+          this.setState({
+            config: _config,
+            openEdition: response.open_edition || '',
+            originMenu: fromJS(_config).toJS()
+          })
+
+          localParam.func = 'sPC_TrdMenu_AddUpt_For_Local'
+          delete localParam.LongParam
+          delete localParam.PageParam
+          delete localParam.Template
+          delete localParam.Sort
+          delete localParam.EasyCode
+          delete localParam.open_edition
+
+          this.submitAction(btnParam, tabParam, localParam)
+        } else {
+          this.setState({
+            menuloading: false,
+            menucloseloading: false
+          })
+          notification.warning({
+            top: 92,
+            message: response.message,
+            duration: 5
+          })
+        }
       })
     })
   }

--
Gitblit v1.8.0