From 3df2d3624c6b768d29670b537f8d6a71d3ef122c Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 12 四月 2020 22:04:53 +0800
Subject: [PATCH] 2020-04-12

---
 src/templates/formtabconfig/index.jsx |   90 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 79 insertions(+), 11 deletions(-)

diff --git a/src/templates/formtabconfig/index.jsx b/src/templates/formtabconfig/index.jsx
index f38b376..d577483 100644
--- a/src/templates/formtabconfig/index.jsx
+++ b/src/templates/formtabconfig/index.jsx
@@ -69,7 +69,8 @@
     groupVisible: false,     // 缂栬緫缁勬ā鎬佹
     optionLibs: null,        // 鑷畾涔変笅鎷夐�夐」搴�
     activeKey: '0',          // 榛樿灞曞紑鍩烘湰淇℃伅
-    pasteVisible: false      // 绮樿创妯℃�佹
+    pasteVisible: false,     // 绮樿创妯℃�佹
+    sqlVerifing: false       // sql楠岃瘉
   }
 
   /**
@@ -723,11 +724,46 @@
           return
         }
 
-        this.setState({
-          config: {..._config, groups: _groups},
-          optionLibs: optionLibs,
-          modaltype: ''
-        })
+        if ((res.type === 'select' || res.type === 'multiselect' || res.type === 'link') && res.resourceType === '1' && /\s/.test(res.dataSource)) {
+          this.setState({
+            sqlVerifing: true
+          })
+  
+          let param = {
+            func: 's_debug_sql',
+            LText: res.dataSource
+          }
+          param.LText = Utils.formatOptions(param.LText)
+          param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
+          param.secretkey = Utils.encrypt(param.LText, param.timestamp)
+  
+          if (window.GLOB.mainSystemApi && res.database === 'sso') {
+            param.rduri = window.GLOB.mainSystemApi
+          }
+          
+          Api.getLocalConfig(param).then(result => {
+            if (result.status) {
+              this.setState({
+                sqlVerifing: false,
+                config: {..._config, groups: _groups},
+                optionLibs: optionLibs,
+                modaltype: ''
+              })
+            } else {
+              this.setState({sqlVerifing: false})
+
+              Modal.error({
+                title: result.message
+              })
+            }
+          })
+        } else {
+          this.setState({
+            config: {..._config, groups: _groups},
+            optionLibs: optionLibs,
+            modaltype: ''
+          })
+        }
       })
     } else if (modaltype === 'actionEdit') {
       this.actionFormRef.handleConfirm().then(res => {
@@ -1583,10 +1619,41 @@
         Api.getLocalConfig(param)
       }
 
-      this.setState({
-        config: {...config, setting: res},
-        settingVisible: false,
-      })
+      if (res.interType === 'inner' && !res.innerFunc && res.dataresource && /\s/.test(res.dataresource)) {
+        this.setState({
+          sqlVerifing: true
+        })
+
+        let param = {
+          func: 's_debug_sql',
+          LText: res.dataresource
+        }
+
+        param.LText = Utils.formatOptions(param.LText)
+        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) {
+            this.setState({
+              sqlVerifing: false,
+              config: {...config, setting: res},
+              settingVisible: false
+            })
+          } else {
+            this.setState({sqlVerifing: false})
+            
+            Modal.error({
+              title: result.message
+            })
+          }
+        })
+      } else {
+        this.setState({
+          config: {...config, setting: res},
+          settingVisible: false
+        })
+      }
     })
   }
 
@@ -2123,6 +2190,7 @@
           width={700}
           maskClosable={false}
           onOk={this.handleSubmit}
+          confirmLoading={this.state.sqlVerifing}
           onCancel={this.editModalCancel}
           destroyOnClose
         >
@@ -2238,7 +2306,7 @@
           footer={[
             <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>
+            <Button key="confirm" type="primary" loading={this.state.sqlVerifing} onClick={this.settingSave}>{this.state.dict['header.confirm']}</Button>
           ]}
           destroyOnClose
         >

--
Gitblit v1.8.0