From fbc7f238317e5fe54707ff571a37d649f7b03c6d Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期三, 18 三月 2020 14:15:21 +0800
Subject: [PATCH] 2020-03-18

---
 src/templates/subtableconfig/index.jsx |  425 ++++------------------------------------------------
 1 files changed, 36 insertions(+), 389 deletions(-)

diff --git a/src/templates/subtableconfig/index.jsx b/src/templates/subtableconfig/index.jsx
index fc2a7e6..edf4641 100644
--- a/src/templates/subtableconfig/index.jsx
+++ b/src/templates/subtableconfig/index.jsx
@@ -29,6 +29,7 @@
 import MenuForm from '@/templates/tableshare/menuform'
 import TransferForm from '@/components/transferform'
 import SourceElement from '@/templates/tableshare/dragelement/source'
+import CreateFunc from '@/templates/tableshare/createfunc'
 import Source from './source'
 import './index.scss'
 
@@ -75,7 +76,6 @@
     originActions: null,     // 鍘熷鎸夐挳淇℃伅锛屼娇鐢ㄥ凡鏈夌敤鎴锋ā鏉�
     delActions: [],          // 鍒犻櫎鎸夐挳鍒楄〃
     copyActions: [],         // 澶嶅埗鎸夐挳缁�
-    funcLoading: false,      // 瀛樺偍杩囩▼鍒涘缓涓�
     showColumnName: false,   // 鏄剧ず鍒楀瓧娈靛悕鎺у埗
     tabviews: [],            // 鎵�鏈夋爣绛鹃〉
     profileVisible: false,   // 楠岃瘉淇℃伅妯℃�佹
@@ -642,9 +642,6 @@
       let btn = res         // 鎸夐挳淇℃伅
       let newLText = ''     // 鍒涘缓瀛樺偍杩囩▼sql
       let DelText = ''      // 鍒犻櫎瀛樺偍杩囩▼sql
-      let isExit = false    // 瀛樺偍杩囩▼鏄惁瀛樺湪
-      let sysTVPText = ''   // 宸叉湁鐨勫瓨鍌ㄨ繃绋嬭鍙�(浜戠)
-      let localTVPText = '' // 宸叉湁鐨勫瓨鍌ㄨ繃绋嬭鍙�(鏈湴)
 
       // 鍒涘缓瀛樺偍杩囩▼锛屽繀椤诲~鍐欏唴閮ㄥ嚱鏁板悕
       if (!btn.innerFunc) {
@@ -655,11 +652,6 @@
         })
         return
       }
-
-      // 鍒涘缓涓�
-      this.setState({
-        funcLoading: true
-      })
 
       new Promise(resolve => {
         // 寮圭獥锛堣〃鍗曪級绫绘寜閽紝鍏堣幏鍙栨寜閽厤缃俊鎭紝濡傛灉灏氭湭閰嶇疆鎸夐挳鍒欎細鎶ラ敊骞剁粓姝€��
@@ -699,12 +691,12 @@
               DelText = Utils.formatOptions(Utils.dropfunc(_param.funcName))
               resolve(true)
             } else {
-              resolve(false)
               notification.warning({
                 top: 92,
                 message: '寮圭獥锛堣〃鍗曪級鎸夐挳锛岃鍏堥厤缃〃鍗曚俊鎭紒',
                 duration: 10
               })
+              resolve(false)
             }
           })
         } else if (btn.OpenType === 'excelIn') {
@@ -745,207 +737,42 @@
           resolve(true)
         }
       }).then(res => {
-        // 鑾峰彇浜戠鍙婃湰鍦帮紝鏄惁宸插瓨鍦ㄨ瀛樺偍杩囩▼鐨勪俊鎭�
-        if (res === false) return res
+        if (!res) return
 
-        let sysDefer = new Promise(resolve => {
-          Api.getSystemConfig({
-            func: 'sPC_Get_TVP', // 浜戠鑾峰彇瀛樺偍缁撴灉
-            TVPName: btn.innerFunc
-          }).then(result => {
-            resolve(result)
-          })
-        })
+        this.refs.btnCreatFunc.exec(btn.innerFunc, newLText, DelText).then(result => {
+          if (result !== 'success') return
 
-        let localDefer = new Promise(resolve => {
-          let _param = { // 鑾峰彇鏈湴瀛樺偍杩囩▼淇℃伅
-            func: 's_get_userproc',
-            LText: btn.innerFunc
-          }
-          _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
-          _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
-          
-          Api.getLocalConfig(_param).then(result => {
-            resolve(result)
-          })
-        })
-        
-        return Promise.all([sysDefer, localDefer])
-      }).then(res => {
-        // 浜戠缁撴灉涓庢柊璇彞涓嶅悓鏃讹紝鏇存柊浜戠淇℃伅
-        if (res === false) return res
-
-        let isError = false
-
-        res.forEach((result, index) => {
-          if (!result.status) {
-            notification.warning({
-              top: 92,
-              message: result.message,
-              duration: 10
-            })
-            isError = true
-          } else if (index === 0) {
-            sysTVPText = result.TVPText
-          } else {
-            if (result.Ltext) { // 鏈湴瀛樺偍杩囩▼鏄惁瀛樺湪
-              isExit = true
+          _config.action = _config.action.map(item => {
+            if (item.uuid === btn.uuid) {
+              return btn
+            } else {
+              return item
             }
-            localTVPText = Utils.formatOptions(result.Ltext)
-          }
-        })
-
-        if (isError) return false
-        
-        if ((newLText === localTVPText) && (newLText === sysTVPText)) {
-          return 'drop'
-        } else if (!localTVPText || (localTVPText === sysTVPText)) {
-          // 鏈湴瀛樺偍杩囩▼涓嶅瓨鍦紝灏嗘柊鐨勫瓨鍌ㄨ繃绋嬫洿鏂拌嚦浜戠
-          return Api.getSystemConfig({
-            func: 'sPC_TVP_InUp',
-            TVPName: btn.innerFunc,
-            TVPText: newLText,
-            TypeName: 'P'
           })
-        } else {
-          return new Promise(resolve => {
-            Api.getSystemConfig({ // 娣诲姞鐜版湁鐨勬湰鍦板瓨鍌ㄨ繃绋嬭嚦浜戠
-              func: 'sPC_TVP_InUp',
-              TVPName: btn.innerFunc,
-              TVPText: localTVPText,
-              TypeName: 'P'
-            }).then(result => {
-              if (result.status) {
-                Api.getSystemConfig({
-                  func: 'sPC_TVP_InUp', // 娣诲姞鏈�鏂扮殑瀛樺偍杩囩▼鑷充簯绔�
-                  TVPName: btn.innerFunc,
-                  TVPText: newLText,
-                  TypeName: 'P'
-                }).then(response => {
-                  resolve(response)
-                })
-              } else {
-                resolve(result)
-              }
-            })
-          })
-        }
-      }).then(res => {
-        // 浜戠淇℃伅鏇存柊鍚庯紝鍒ゆ柇鏄垹闄ゆ垨鏄洿鎺ユ柊寤哄瓨鍌ㄨ繃绋�
-        if (res === false || res === 'drop') return res
+          _config.action = _config.action.filter(item => !item.origin)
 
-        if (!res.status) {
-          notification.warning({
-            top: 92,
-            message: res.message,
-            duration: 10
-          })
-          return false
-        } else if (isExit) {
-          return 'drop'
-        } else {
-          return 'create'
-        }
-      }).then(res => {
-        // 鍒犻櫎瀛樺偍杩囩▼
-        if (res === false || res === 'create') return res
+          // 鍒ゆ柇鏄惁瀛樺湪鎿嶄綔鍒�
+          let _hasGridbtn = _config.action.filter(act => act.position === 'grid').length > 0
 
-        let _param = {
-          func: 'sPC_TableData_InUpDe',
-          LText: DelText,
-          TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋�
-        }
-
-        _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
-        _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
-
-        return Api.getLocalConfig(_param)
-      }).then(res => {
-        // 鏍规嵁涓婅堪鎿嶄綔缁撴灉锛屽垽鏂槸鍚︽柊寤哄瓨鍌ㄨ繃绋�
-        if (res === false || res === 'create') return res
-
-        if (!res.status) {
-          notification.warning({
-            top: 92,
-            message: res.message,
-            duration: 10
-          })
-          return false
-        } else {
-          return 'create'
-        }
-      }).then(res => {
-        // 鏂板缓瀛樺偍杩囩▼
-        if (res === false) return res
-
-        let _param = {
-          func: 'sPC_TableData_InUpDe',
-          LText: newLText,
-          TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋�
-        }
-        _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
-        _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
-
-        return Api.getLocalConfig(_param)
-      }).then(res => {
-        // 澶勭悊鏂板缓缁撴灉
-        if (res === false) return res
-
-        if (!res.status) {
-          notification.warning({
-            top: 92,
-            message: res.message,
-            duration: 10
-          })
-          return false
-        } else {
-          notification.success({
-            top: 92,
-            message: '鍒涘缓鎴愬姛',
-            duration: 2
-          })
-          return true
-        }
-      }).then(res => {
-        // 鏂板缓鎴愬姛鍚庯紝鏇存柊椤甸潰鎸夐挳淇℃伅
-        if (res === false) {
-          this.setState({
-            funcLoading: false
-          })
-          return
-        }
-
-        _config.action = _config.action.map(item => {
-          if (item.uuid === btn.uuid) {
-            return btn
+          if (_config.gridBtn) {
+            _config.gridBtn.display = _hasGridbtn
           } else {
-            return item
+            _config.gridBtn = {
+              display: _hasGridbtn,
+              Align: 'center',
+              IsSort: 'false',
+              uuid: Utils.getuuid(),
+              label: this.state.dict['header.form.column.action'],
+              type: 'action',
+              style: 'button',
+              show: 'horizontal',
+              Width: 120
+            }
           }
-        })
-        _config.action = _config.action.filter(item => !item.origin)
-
-        // 鍒ゆ柇鏄惁瀛樺湪鎿嶄綔鍒�
-        let _hasGridbtn = _config.action.filter(act => act.position === 'grid').length > 0
-
-        if (_config.gridBtn) {
-          _config.gridBtn.display = _hasGridbtn
-        } else {
-          _config.gridBtn = {
-            display: _hasGridbtn,
-            Align: 'center',
-            IsSort: 'false',
-            uuid: Utils.getuuid(),
-            label: this.state.dict['header.form.column.action'],
-            type: 'action',
-            style: 'button',
-            show: 'horizontal',
-            Width: 120
-          }
-        }
-
-        this.setState({
-          config: _config,
-          funcLoading: false
+  
+          this.setState({
+            config: _config,
+          })
         })
       })
     })
@@ -982,195 +809,15 @@
         Api.getLocalConfig(param)
       }
 
-      this.setState({
-        funcLoading: true
-      })
-
       let newLText = Utils.formatOptions(Utils.getTableFunc(setting, {MenuID: config.uuid, MenuName: config.tabName, MenuNo: config.tabNo}, config)) // 鍒涘缓瀛樺偍杩囩▼sql
       let DelText = Utils.formatOptions(Utils.dropfunc(setting.innerFunc))          // 鍒犻櫎瀛樺偍杩囩▼sql
-      let isExit = false    // 瀛樺偍杩囩▼鏄惁瀛樺湪
-
-      new Promise(resolve => {
-        let sysDefer = new Promise(resolve => {
-          Api.getSystemConfig({
-            func: 'sPC_Get_TVP', // 浜戠鑾峰彇瀛樺偍缁撴灉
-            TVPName: setting.innerFunc
-          }).then(result => {
-            if (!result.status) {
-              notification.warning({
-                top: 92,
-                message: result.message,
-                duration: 10
-              })
-              resolve(false)
-            } else {
-              resolve(result)
-            }
-          })
-        })
-
-        let localDefer = new Promise(resolve => {
-          let _param = { // 鑾峰彇鏈湴瀛樺偍杩囩▼淇℃伅
-            func: 's_get_userproc',
-            LText: setting.innerFunc
-          }
-          _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
-          _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
-          
-          Api.getLocalConfig(_param).then(result => {
-            if (!result.status) {
-              notification.warning({
-                top: 92,
-                message: result.message,
-                duration: 10
-              })
-              resolve(false)
-            } else {
-              resolve(result)
-            }
-          })
-        })
-        
-        Promise.all([sysDefer, localDefer]).then(result => {
-          resolve(result)
-        })
-      }).then(res => {
-        // 鑾峰彇浜戠鍙婃湰鍦帮紝鏄惁宸插瓨鍦ㄨ瀛樺偍杩囩▼鐨勪俊鎭�
-        if (res === false) return res
-        if (res[0] === false || res[1] === false) return false
-
-        let cloudfunc = ''
-        let localfunc = ''
-        res.forEach((item, index) => {
-          if (index === 0 && item.TVPText) {
-            cloudfunc = item.TVPText
-          } else if (index === 1 && item.Ltext) {
-            isExit = true
-            localfunc = Utils.formatOptions(item.Ltext)
-          }
-        })
-
-        if ((newLText === localfunc) && (newLText === cloudfunc)) {
-          return 'drop'
-        } else if (!localfunc || (cloudfunc === localfunc)) {
-          // 鏈湴瀛樺偍杩囩▼涓嶅瓨鍦紝鎴栦簯绔拰鏈湴瀛樺偍杩囩▼涓�鑷存椂锛屽皢鏂扮殑瀛樺偍杩囩▼鏇存柊鑷充簯绔�
-          return Api.getSystemConfig({
-            func: 'sPC_TVP_InUp',
-            TVPName: setting.innerFunc,
-            TVPText: newLText,
-            TypeName: 'P'
-          })
-        } else {
-          return new Promise(resolve => {
-            Api.getSystemConfig({ // 娣诲姞鐜版湁鐨勬湰鍦板瓨鍌ㄨ繃绋嬭嚦浜戠
-              func: 'sPC_TVP_InUp',
-              TVPName: setting.innerFunc,
-              TVPText: localfunc,
-              TypeName: 'P'
-            }).then(result => {
-              if (result.status) {
-                Api.getSystemConfig({
-                  func: 'sPC_TVP_InUp', // 娣诲姞鏈�鏂扮殑瀛樺偍杩囩▼鑷充簯绔�
-                  TVPName: setting.innerFunc,
-                  TVPText: newLText,
-                  TypeName: 'P'
-                }).then(response => {
-                  resolve(response)
-                })
-              } else {
-                resolve(result)
-              }
-            })
-          })
-        }
-      }).then(res => {
-        // 浜戠淇℃伅鏇存柊鍚庯紝鍒ゆ柇鏄垹闄ゆ垨鏄洿鎺ユ柊寤哄瓨鍌ㄨ繃绋�
-        if (res === false || res === 'drop') return res
-
-        if (!res.status) {
-          notification.warning({
-            top: 92,
-            message: res.message,
-            duration: 10
-          })
-          return false
-        } else if (isExit) {
-          return 'drop'
-        } else {
-          return 'create'
-        }
-      }).then(res => {
-        // 鍒犻櫎瀛樺偍杩囩▼
-        if (res === false || res === 'create') return res
-
-        let _param = {
-          func: 'sPC_TableData_InUpDe',
-          LText: DelText,
-          TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋�
-        }
-
-        _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
-        _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
-
-        return Api.getLocalConfig(_param)
-      }).then(res => {
-        // 鏍规嵁涓婅堪鎿嶄綔缁撴灉锛屽垽鏂槸鍚︽柊寤哄瓨鍌ㄨ繃绋�
-        if (res === false || res === 'create') return res
-
-        if (!res.status) {
-          notification.warning({
-            top: 92,
-            message: res.message,
-            duration: 10
-          })
-          return false
-        } else {
-          return 'create'
-        }
-      }).then(res => {
-        // 鏂板缓瀛樺偍杩囩▼
-        if (res === false) return res
-
-        let _param = {
-          func: 'sPC_TableData_InUpDe',
-          LText: newLText,
-          TypeCharOne: 'proc' // 鍒犻櫎鎴栧垱寤哄瓨鍌ㄨ繃绋�
-        }
-        _param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
-        _param.secretkey = Utils.encrypt(_param.LText, _param.timestamp)
-
-        return Api.getLocalConfig(_param)
-      }).then(res => {
-        // 澶勭悊鏂板缓缁撴灉
-        if (res === false) return res
-
-        if (!res.status) {
-          notification.warning({
-            top: 92,
-            message: res.message,
-            duration: 10
-          })
-          return false
-        } else {
-          notification.success({
-            top: 92,
-            message: '鍒涘缓鎴愬姛',
-            duration: 2
-          })
-          return true
-        }
-      }).then(res => {
-        // 鏂板缓鎴愬姛鍚庯紝鏇存柊椤甸潰鎸夐挳淇℃伅
-        if (res === false) {
+      
+      this.refs.tableCreatFunc.exec(setting.innerFunc, newLText, DelText).then(result => {
+        if (result === 'success') {
           this.setState({
-            funcLoading: false
+            config: {...config, setting: setting}
           })
-          return
         }
-
-        this.setState({
-          config: {...config, setting: setting}
-        })
       })
     })
   }
@@ -2549,7 +2196,7 @@
           maskClosable={false}
           onCancel={this.editModalCancel}
           footer={[
-            modaltype === 'actionEdit' ? <Button key="delete" className="mk-btn mk-purple" onClick={this.creatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button> : null,
+            modaltype === 'actionEdit' ? <CreateFunc key="create" dict={this.state.dict} ref="btnCreatFunc" trigger={this.creatFunc}/> : null,
             <Button key="cancel" onClick={this.editModalCancel}>{this.state.dict['header.cancel']}</Button>,
             <Button key="confirm" type="primary" onClick={this.handleSubmit}>{this.state.dict['header.confirm']}</Button>
           ]}
@@ -2692,7 +2339,7 @@
             })
           }}
           footer={[
-            <Button key="delete" className="mk-btn mk-purple" onClick={this.tableCreatFunc} loading={this.state.funcLoading}>{this.state.dict['header.menu.func.create']}</Button>,
+            <CreateFunc key="create" dict={this.state.dict} ref="tableCreatFunc" trigger={this.tableCreatFunc}/>,
             <Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>{this.state.dict['header.cancel']}</Button>,
             <Button key="confirm" type="primary" onClick={this.settingSave}>{this.state.dict['header.confirm']}</Button>
           ]}

--
Gitblit v1.8.0