From 606b0b991748740179fa37448f645e6e9c7f1c41 Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期日, 24 一月 2021 19:17:38 +0800
Subject: [PATCH] 2021-01-24

---
 src/templates/sharecomponent/settingcomponent/settingform/utils.jsx |   56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 56 insertions(+), 0 deletions(-)

diff --git a/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx b/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx
index 9bde95a..4298827 100644
--- a/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx
+++ b/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx
@@ -99,4 +99,60 @@
 
     return sql
   }
+
+  /**
+   * @description 鐢熸垚鍓嶇疆鎴栧悗缃鍙�
+   * @return {String}  scripts       鑴氭湰
+   * @return {Array}   regoptions    鎼滅储鏉′欢姝e垯鏇挎崲
+   */
+  static getCustomDebugSql (scripts, regoptions) {
+    let sql = ''
+    let _customScript = ''
+
+    scripts.forEach(script => {
+      if (script.status === 'false') return
+
+      _customScript += `
+      ${script.sql}
+      `
+    })
+
+    if (_customScript) {
+      _customScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50) select @ErrorCode='',@retmsg =''
+        ${_customScript}
+      `
+    }
+
+    _customScript = _customScript.replace(/@\$|\$@/ig, '')
+    // 澶栬仈鏁版嵁搴撴浛鎹�
+    if (window.GLOB.externalDatabase !== null) {
+      _customScript = _customScript.replace(/@db@/ig, window.GLOB.externalDatabase)
+    }
+    
+    // 姝e垯鏇挎崲
+    if (regoptions) {
+      let _regoptions = regoptions.map(item => {
+        return {
+          reg: new RegExp('@' + item.key + '@', 'ig'),
+          value: `'0'`
+        }
+      })
+      _regoptions.forEach(item => {
+        _customScript = _customScript.replace(item.reg, item.value)
+      })
+    }
+
+    if (_customScript) {
+      sql = `/* sql 楠岃瘉 */
+        ${_customScript}
+        aaa:
+        if @ErrorCode!=''
+          insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@
+      `
+    }
+    sql = sql.replace(/\n\s{8}/ig, '\n')
+    console.info(sql)
+
+    return sql
+  }
 }
\ No newline at end of file

--
Gitblit v1.8.0