From 9a1416e0b5cdb40f49b3c2061b04b35551d77e99 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 19 九月 2023 18:14:21 +0800 Subject: [PATCH] 2023-09-19 --- src/templates/sharecomponent/settingcomponent/settingform/utils.jsx | 110 ++++++++++--------------------------------------------- 1 files changed, 20 insertions(+), 90 deletions(-) diff --git a/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx b/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx index aca603b..4f1413c 100644 --- a/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx +++ b/src/templates/sharecomponent/settingcomponent/settingform/utils.jsx @@ -1,13 +1,11 @@ +import { getSearchRegs, joinMainSearchkey } from '@/utils/utils-custom.js' + export default class SettingUtils { /** * @description 鐢熸垚椤甸潰鏌ヨ璇彞 - * @return {String} arr_field 鏄剧ず鍒楀瓧娈� - * @return {String} search 鎼滅储鏉′欢 - * @return {Object} setting 椤甸潰璁剧疆 - * @return {Array} regoptions 鎼滅储鏉′欢姝e垯鏇挎崲 */ - static getDebugSql (setting, scripts, arr_field, regoptions, search) { + static getDebugSql (setting, scripts, arr_field, searches = [], urlFields) { let sql = '' let _dataresource = setting.dataresource || '' let _customScript = '' @@ -53,22 +51,22 @@ _customScript = _customScript.replace(/@db@/ig, window.GLOB.externalDatabase) } + let _regoptions = getSearchRegs(searches) + + let _search = joinMainSearchkey(searches) + _search = _search ? 'where ' + _search : '' + // 姝e垯鏇挎崲 - let _regoptions = regoptions.map(item => { - return { - reg: new RegExp('@' + item.key + '@', 'ig'), - value: `'0'`, - type: item.type || '' - } - }) + if (urlFields && urlFields.length > 0) { + urlFields.forEach(field => { + _regoptions.push({ + reg: new RegExp('@' + field + '@', 'ig'), + value: `'0'` + }) + }) + } _regoptions.push({ - reg: new RegExp('@userName@', 'ig'), - value: `''` - }, { - reg: new RegExp('@fullName@', 'ig'), - value: `''` - }, { reg: new RegExp('@orderBy@', 'ig'), value: setting.order }, { @@ -79,24 +77,13 @@ value: 1 }) - let _search = search + _regoptions.forEach(item => { + _dataresource = _dataresource.replace(item.reg, item.value) + _customScript = _customScript.replace(item.reg, item.value) + }) if (setting.queryType === 'statistics' && _dataresource) { - _regoptions.forEach(item => { - _dataresource = _dataresource.replace(item.reg, item.value) - }) _search = '' - } else if (_dataresource) { - _regoptions.forEach(item => { - if (item.type !== 'url') return - _dataresource = _dataresource.replace(item.reg, item.value) - }) - } - - if (_customScript) { - _regoptions.forEach(item => { - _customScript = _customScript.replace(item.reg, item.value) - }) } // 鏁版嵁婧愬鐞�, 瀛樺湪鏄剧ず鍒楁椂 @@ -139,62 +126,5 @@ } return { sql, errors: errors.join('锛�') } - } - - /** - * @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),@RoleID nvarchar(512),@mk_departmentcode nvarchar(512),@mk_organization nvarchar(512),@mk_user_type nvarchar(20),@mk_nation nvarchar(50),@mk_province nvarchar(50),@mk_city nvarchar(50),@mk_district nvarchar(50),@mk_address nvarchar(100) select @ErrorCode='',@retmsg ='' - ${_customScript} - ` - } - - if (window.GLOB.funcs && window.GLOB.funcs.length > 0) { - window.GLOB.funcs.forEach(item => { - let reg = new RegExp('\\$ex@' + item.func_code + '@ex\\$', 'ig') - _customScript = _customScript.replace(reg, `/*$ex@${item.func_code}-begin*/\n${item.key_sql}\n/*@ex$-end*/`) - }) - } - - _customScript = _customScript.replace(/@\$|\$@/ig, '') - _customScript = _customScript.replace(/@userName@|@fullName@/ig, `''`) - - // 姝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 = `${_customScript} - aaa: - if @ErrorCode!='' - insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select '1949-10-01 15:00:00',@ErrorCode, @retmsg,'1949-10-01 15:00:00' - ` - } - - return sql } } \ No newline at end of file -- Gitblit v1.8.0