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/modalconfig/index.jsx |   55 +++++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 47 insertions(+), 8 deletions(-)

diff --git a/src/templates/modalconfig/index.jsx b/src/templates/modalconfig/index.jsx
index 620b41b..1557bfb 100644
--- a/src/templates/modalconfig/index.jsx
+++ b/src/templates/modalconfig/index.jsx
@@ -68,7 +68,8 @@
     curgroup: null,        // 褰撳墠缁勶紝鏂板缓鎴栫紪杈�
     optionLibs: null,      // 鑷畾涔変笅鎷夐�夐」搴�
     sources: null,         // 琛ㄥ崟绫诲瀷
-    pasteVisible: null     // 琛ㄥ崟绮樿创
+    pasteVisible: null,    // 琛ㄥ崟绮樿创
+    sqlVerifing: false     // sql楠岃瘉
   }
 
   /**
@@ -633,13 +634,50 @@
 
       _config.fields = _config.fields.filter(item => !item.origin)
 
-      this.setState({
-        config: _config,
-        modalType: null,
-        card: null,
-        optionLibs: optionLibs,
-        visible: false
-      })
+      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,
+              modalType: null,
+              card: null,
+              optionLibs: optionLibs,
+              visible: false
+            })
+          } else {
+            this.setState({sqlVerifing: false})
+            
+            Modal.error({
+              title: result.message
+            })
+          }
+        })
+      } else {
+        this.setState({
+          config: _config,
+          modalType: null,
+          card: null,
+          optionLibs: optionLibs,
+          visible: false
+        })
+      }
     })
   }
 
@@ -1341,6 +1379,7 @@
           width={700}
           onCancel={this.editModalCancel}
           onOk={this.handleSubmit}
+          confirmLoading={this.state.sqlVerifing}
           destroyOnClose
         >
           {<ModalForm

--
Gitblit v1.8.0