From 318642cd6837a38a4bf5dfe059bcbb6cafe3bca8 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 02 二月 2021 15:28:28 +0800 Subject: [PATCH] 2021-02-02 --- src/templates/sharecomponent/settingcomponent/settingform/utils.jsx | 117 ++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 96 insertions(+), 21 deletions(-) diff --git a/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx b/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx index ebd508d..09f0df4 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx @@ -7,12 +7,23 @@ * @return {Object} setting 椤甸潰璁剧疆 * @return {Array} regoptions 鎼滅储鏉′欢姝e垯鏇挎崲 */ - static getDebugSql (setting, arr_field, regoptions, search) { + static getDebugSql (setting, scripts, arr_field, regoptions, search) { let sql = '' - let _dataresource = setting.dataresource - let _customScript = setting.customScript + let _dataresource = setting.dataresource || '' + let _customScript = '' + scripts && scripts.forEach(script => { + _customScript += ` + ${script.sql} + ` + }) - if (setting.interType === 'inner' && !setting.innerFunc && setting.default === 'false') { + if (_customScript) { + _customScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50) select @ErrorCode='',@retmsg ='' + ${_customScript} + ` + } + + if (setting.default === 'false') { _dataresource = '' } @@ -22,38 +33,41 @@ if (_customScript) { _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 = regoptions.map(item => { return { reg: new RegExp('@' + item.key + '@', 'ig'), - value: `'${item.value}'` + value: `'0'` } }) + + _regoptions.push({ + reg: new RegExp('@orderBy@', 'ig'), + value: setting.order + }, { + reg: new RegExp('@pageSize@', 'ig'), + value: 10 + }, { + reg: new RegExp('@pageIndex@', 'ig'), + value: 1 + }) + let _search = search if (setting.queryType === 'statistics' && _dataresource) { _regoptions.forEach(item => { _dataresource = _dataresource.replace(item.reg, item.value) }) - _search = '' } if (_customScript) { - _regoptions.push({ - reg: new RegExp('@orderBy@', 'ig'), - value: setting.order - }) - if (setting.laypage !== 'false') { - _regoptions.push({ - reg: new RegExp('@pageSize@', 'ig'), - value: 10 - }, { - reg: new RegExp('@pageIndex@', 'ig'), - value: 1 - }) - } _regoptions.forEach(item => { _customScript = _customScript.replace(item.reg, item.value) }) @@ -69,16 +83,77 @@ } 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 + } + + /** + * @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, '') + _customScript = _customScript.replace(/@userName@|@fullName@/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