From eebe63a6727e6495321d1433ebd2779b5a36d45a Mon Sep 17 00:00:00 2001
From: king <18310653075@163.com>
Date: 星期四, 31 十二月 2020 22:08:14 +0800
Subject: [PATCH] 2020-12-31

---
 src/templates/sharecomponent/settingcalcomponent/verifycard/utils.jsx |   54 ++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 34 insertions(+), 20 deletions(-)

diff --git a/src/templates/sharecomponent/settingcalcomponent/verifycard/utils.jsx b/src/templates/sharecomponent/settingcalcomponent/verifycard/utils.jsx
index 8d04983..d690943 100644
--- a/src/templates/sharecomponent/settingcalcomponent/verifycard/utils.jsx
+++ b/src/templates/sharecomponent/settingcalcomponent/verifycard/utils.jsx
@@ -7,7 +7,7 @@
    * @return {Object}  setting       椤甸潰璁剧疆
    * @return {Array}   columns       鏄剧ず瀛楁
    */
-  static getDebugSql (setting, scripts, columns, searches) {
+  static getDebugSql (setting, scripts, columns, searches, calendar) {
     let sql = ''
     let _dataresource = ''
     let _customScript = ''
@@ -22,12 +22,12 @@
     }
 
     if (_customScript) {
-      _customScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000) select @ErrorCode='',@retmsg =''
+      _customScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50) select @ErrorCode='',@retmsg =''
         ${_customScript}
       `
     }
 
-    if (setting.interType === 'inner' && !setting.innerFunc && setting.execute !== 'false') {
+    if (setting.execute !== 'false') {
       _dataresource = setting.dataresource
     }
     
@@ -38,28 +38,38 @@
       _customScript = _customScript.replace(/@\$|\$@/ig, '')
     }
     
+    // 澶栬仈鏁版嵁搴撴浛鎹�
+    if (window.GLOB.externalDatabase !== null) {
+      _dataresource = _dataresource.replace(/@db@/ig, window.GLOB.externalDatabase)
+      _customScript = _customScript.replace(/@db@/ig, window.GLOB.externalDatabase)
+    }
+    
     // 姝e垯鏇挎崲
-    let _regoptions = searches.map(item => {
-      return {
-        reg: new RegExp('@' + item.key + '@', 'ig'),
-        value: `'${item.value}'`
-      }
-    })
+    let _regoptions = []
     let _search = ''
 
-    // 鏃ュ巻涓殑骞翠唤鏇挎崲
     if (setting.queryType === 'statistics' || _customScript) {
-      _regoptions.push({
-        reg: new RegExp('@calendarDate@', 'ig'),
-        value: `1970-01-01 00:00:00.000`
-      })
-      _regoptions.push({
-        reg: new RegExp('@calendarDate1@', 'ig'),
-        value: `2030-12-31 23:59:59.999`
+      _regoptions = searches.map(item => {
+        return {
+          reg: new RegExp('@' + item.key + '@', 'ig'),
+          value: `'0'`
+        }
       })
     }
 
-    if (setting.queryType === 'statistics' && _dataresource) {
+    // 鏃ュ巻涓殑骞翠唤鏇挎崲
+    if (calendar.refresh === 'true') {
+      _regoptions.push({
+        reg: new RegExp('@calendarDate@', 'ig'),
+        value: `'1970-01-01 00:00:00.000'`
+      })
+      _regoptions.push({
+        reg: new RegExp('@calendarDate1@', 'ig'),
+        value: `'2030-12-31 23:59:59.999'`
+      })
+    }
+
+    if ((setting.queryType === 'statistics' || calendar.refresh === 'true') && _dataresource) {
       _regoptions.forEach(item => {
         _dataresource = _dataresource.replace(item.reg, item.value)
       })
@@ -96,15 +106,19 @@
     }
 
     if (_customScript) {
-      sql = `${_customScript}
+      sql = `/* sql 楠岃瘉 */
+        ${_customScript}
         ${_dataresource}
         aaa:
         if @ErrorCode!=''
           insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@
       `
     } else {
-      sql = _dataresource
+      sql = `/* sql 楠岃瘉 */
+        ${_dataresource}`
     }
+    sql = sql.replace(/\n\s{8}/ig, '\n')
+    console.info(sql)
     
     return sql
   }

--
Gitblit v1.8.0