From a94b0a4d15b26ecf8fe99f0a1c3e60d60b97766d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 15 八月 2023 14:22:03 +0800 Subject: [PATCH] 2023-08-15 --- src/utils/utils-datamanage.js | 201 +++++++++++++++++++++---------------------------- 1 files changed, 87 insertions(+), 114 deletions(-) diff --git a/src/utils/utils-datamanage.js b/src/utils/utils-datamanage.js index d3609d7..5be52b3 100644 --- a/src/utils/utils-datamanage.js +++ b/src/utils/utils-datamanage.js @@ -1,6 +1,5 @@ import md5 from 'md5' import moment from 'moment' -import options from '@/store/options.js' import Utils from './utils.js' export default class DataUtils { @@ -58,8 +57,8 @@ param.func = setting.innerFunc } else { if (window.GLOB.mkHS) { - if (setting.sysInterface === 'true' && options.cloudServiceApi) { - param.rduri = options.cloudServiceApi + if (setting.sysInterface === 'true' && window.GLOB.cloudServiceApi) { + param.rduri = window.GLOB.cloudServiceApi param.userid = sessionStorage.getItem('CloudUserID') || '' param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' } else if (setting.sysInterface !== 'true') { @@ -125,11 +124,6 @@ let district = sessionStorage.getItem('district') || '' let address = sessionStorage.getItem('address') || '' - if (sessionStorage.getItem('isEditState') === 'true') { - userName = sessionStorage.getItem('CloudUserName') || '' - fullName = sessionStorage.getItem('CloudFullName') || '' - } - let _dataresource = setting.dataresource let _customScript = '' @@ -167,35 +161,33 @@ _customScript = _customScript.replace(/@mk_year@/ig, year) } - let regoptions = null - if (setting.queryType === 'statistics' || _customScript) { - let allSearch = Utils.getAllSearchOptions(search) - regoptions = allSearch.map(item => { - return { - reg: new RegExp('@' + item.key + '@', 'ig'), - value: `'${item.value}'` - } - }) - regoptions.push({ - reg: new RegExp('@orderBy@', 'ig'), - value: orderBy - }, { - reg: new RegExp('@pageSize@', 'ig'), - value: setting.laypage ? pageSize : '9999' - }, { - reg: new RegExp('@pageIndex@', 'ig'), - value: pageIndex - }) - } + let allSearch = Utils.getAllSearchOptions(search) + let regoptions = allSearch.map(item => { + return { + reg: new RegExp('@' + item.key + '@', 'ig'), + value: `'${item.value}'` + } + }) + regoptions.push({ + reg: new RegExp('@orderBy@', 'ig'), + value: orderBy + }, { + reg: new RegExp('@pageSize@', 'ig'), + value: setting.laypage ? pageSize : '9999' + }, { + reg: new RegExp('@pageIndex@', 'ig'), + value: pageIndex + }) + + regoptions.forEach(item => { + _dataresource = _dataresource.replace(item.reg, item.value) + _customScript = _customScript.replace(item.reg, item.value) + }) let _search = '' - let cus_page = /@pageSize@/i.test(_dataresource + _customScript) if (_dataresource) { if (setting.queryType === 'statistics') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 - regoptions.forEach(item => { - _dataresource = _dataresource.replace(item.reg, item.value) - }) if (id) { _dataresource = _dataresource + ` where ${setting.primaryKey || 'ID'}='${id}'` } @@ -211,9 +203,6 @@ } if (_customScript) { - regoptions.forEach(item => { - _customScript = _customScript.replace(item.reg, item.value) - }) if (window.GLOB.breakpoint) { _customScript = _customScript.replace(/\$breakpoint_proc@/ig, window.GLOB.breakpoint) param.func = 'sPC_Get_TableData_debug' @@ -228,15 +217,15 @@ } if (_dataresource && setting.laypage && orderBy && !id) { - if (cus_page) { + if (setting.custompage) { LText = `/*system_query*/select ${arrFields} from ${_dataresource} ${_search} ` } else { LText = `/*system_query*/select top ${pageSize} ${arrFields} from (select ${arrFields} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows ` - } - if (setting.sub_field) { - DateCount = `/*system_query*/select count(1) as total from (select distinct ${setting.primaryKey} from ${_dataresource} ${_search})a` - } else { - DateCount = `/*system_query*/select count(1) as total from ${_dataresource} ${_search}` + if (setting.sub_field) { + DateCount = `/*system_query*/select count(1) as total from (select distinct ${setting.primaryKey} from ${_dataresource} ${_search})a` + } else { + DateCount = `/*system_query*/select count(1) as total from ${_dataresource} ${_search}` + } } } else if (_dataresource && orderBy) { LText = `/*system_query*/select ${arrFields} from (select ${arrFields} ,ROW_NUMBER() over(order by ${orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows ` @@ -249,13 +238,13 @@ LText = `${LText} aaa: if @ErrorCode!='' - insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ + insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'${sessionStorage.getItem('UserID') || ''}' ` } else { _customScript = `${_customScript} aaa: if @ErrorCode!='' - insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ + insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'${sessionStorage.getItem('UserID') || ''}' ` } } else { @@ -266,7 +255,7 @@ } // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞 - if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { + if (window.GLOB.debugger === true) { _customScript && console.info(`${setting.$name ? `/*${setting.$name} 鑷畾涔夎剼鏈�*/\n` : ''}${LText ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${_customScript}`) LText && console.info(`${setting.$name ? `/*${setting.$name} 鏁版嵁婧�*/\n` : ''}` + LText.replace(/\n\s{8}/ig, '\n')) } @@ -291,6 +280,9 @@ param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt('', param.timestamp) + param.username = userName + param.fullname = fullName + if (window.GLOB.probation) { param.s_debug_type = 'Y' } @@ -299,8 +291,8 @@ param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) // special HS鑷畾涔夊嚱鏁版煡璇� - if (setting.tableName === 's_custom_script' && options.cloudServiceApi) { - param.rduri = options.cloudServiceApi + if (setting.tableName === 's_custom_script' && window.GLOB.cloudServiceApi) { + param.rduri = window.GLOB.cloudServiceApi param.userid = sessionStorage.getItem('CloudUserID') || '' param.LoginUID = sessionStorage.getItem('CloudLoginUID') || '' } @@ -320,10 +312,6 @@ arr_field: statFields.map(col => col.field).join(','), default_sql: setting.execute ? 'true' : 'false' } - - // if (setting.transaction === 'true') { - // param.func = 'sPC_Get_TableData_try' - // } let _dataresource = setting.dataresource let _customScript = '' @@ -338,11 +326,6 @@ let city = sessionStorage.getItem('city') || '' let district = sessionStorage.getItem('district') || '' let address = sessionStorage.getItem('address') || '' - - if (sessionStorage.getItem('isEditState') === 'true') { - userName = sessionStorage.getItem('CloudUserName') || '' - fullName = sessionStorage.getItem('CloudFullName') || '' - } if (setting.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) @@ -373,44 +356,37 @@ _dataresource = _dataresource.replace(/@typename@/ig, `'admin'`) _customScript = _customScript.replace(/@typename@/ig, `'admin'`) - let regoptions = null - if (setting.queryType === 'statistics' || _customScript) { - let allSearch = Utils.getAllSearchOptions(search) + let allSearch = Utils.getAllSearchOptions(search) + let regoptions = allSearch.map(item => { + return { + reg: new RegExp('@' + item.key + '@', 'ig'), + value: `'${item.value}'` + } + }) - regoptions = allSearch.map(item => { - return { - reg: new RegExp('@' + item.key + '@', 'ig'), - value: `'${item.value}'` - } - }) - regoptions.push({ - reg: new RegExp('@orderBy@', 'ig'), - value: orderBy - }, { - reg: new RegExp('@pageSize@', 'ig'), - value: 999999 - }, { - reg: new RegExp('@pageIndex@', 'ig'), - value: 1 - }) - } + regoptions.push({ + reg: new RegExp('@orderBy@', 'ig'), + value: orderBy + }, { + reg: new RegExp('@pageSize@', 'ig'), + value: 999999 + }, { + reg: new RegExp('@pageIndex@', 'ig'), + value: 1 + }) - let _search = Utils.joinMainSearchkey(search) - if (_search) { - _search = 'where ' + _search - } + regoptions.forEach(item => { + _dataresource = _dataresource.replace(item.reg, item.value) + _customScript = _customScript.replace(item.reg, item.value) + }) + + let _search = '' - if (setting.queryType === 'statistics') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 - regoptions.forEach(item => { - _dataresource = _dataresource.replace(item.reg, item.value) - }) - _search = '' - } - - if (_customScript) { - regoptions.forEach(item => { - _customScript = _customScript.replace(item.reg, item.value) - }) + if (setting.queryType !== 'statistics') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 + _search = Utils.joinMainSearchkey(search) + if (_search) { + _search = 'where ' + _search + } } let LText = ` /*system_query*/select ${statFields.map(col => `isnull(sum(${col.field}),0) as ${col.field}`).join(',')} from ${_dataresource} ${_search} ` @@ -419,7 +395,7 @@ LText = `${LText} aaa: if @ErrorCode!='' - insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ + insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,'${sessionStorage.getItem('UserID') || ''}' ` } else { LText = `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) @@ -429,7 +405,7 @@ } // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞 - if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { + if (window.GLOB.debugger === true) { _customScript && console.info(`${setting.$name ? `/*${setting.$name} 鑷畾涔夎剼鏈� 缁熻鏌ヨ*/\n` : ''}${LText ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${_customScript}`) LText && console.info(`${setting.$name ? `/*${setting.$name} 鏁版嵁婧� 缁熻鏌ヨ*/\n` : ''}` + LText.replace(/\n\s{8}/ig, '\n')) } @@ -444,6 +420,9 @@ param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') param.secretkey = Utils.encrypt('', param.timestamp) + + param.username = userName + param.fullname = fullName if (window.GLOB.mkHS) { // 浜戠鏁版嵁楠岃瘉 param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) @@ -472,22 +451,18 @@ let _dataresource = setting.dataresource let _customScript = setting.customScript - if (setting.queryType === 'statistics' || _customScript) { - let allSearch = Utils.getAllSearchOptions(searchlist) - let regoptions = allSearch.map(item => { - return { - reg: new RegExp('@' + item.key + '@', 'ig'), - value: `'${item.value}'` - } - }) + let allSearch = Utils.getAllSearchOptions(searchlist) + let regoptions = allSearch.map(item => { + return { + reg: new RegExp('@' + item.key + '@', 'ig'), + value: `'${item.value}'` + } + }) - regoptions.forEach(item => { - if (_dataresource && setting.queryType === 'statistics') { - _dataresource = _dataresource.replace(item.reg, item.value) - } - _customScript = _customScript.replace(item.reg, item.value) - }) - } + regoptions.forEach(item => { + _dataresource = _dataresource.replace(item.reg, item.value) + _customScript = _customScript.replace(item.reg, item.value) + }) _dataresource = _dataresource.replace(/@select\$|\$select@/ig, '') _customScript = _customScript.replace(/@select\$|\$select@/ig, '') @@ -520,11 +495,7 @@ let city = sessionStorage.getItem('city') || '' let district = sessionStorage.getItem('district') || '' let address = sessionStorage.getItem('address') || '' - - if (sessionStorage.getItem('isEditState') === 'true') { - userName = sessionStorage.getItem('CloudUserName') || '' - fullName = sessionStorage.getItem('CloudFullName') || '' - } + _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 ='',@UserName='${userName}', @FullName='${fullName}', @RoleID='${RoleID}', @mk_departmentcode='${departmentcode}', @mk_organization='${organization}', @mk_user_type='${mk_user_type}', @mk_nation='${nation}', @mk_province='${province}', @mk_city='${city}', @mk_district='${district}', @mk_address='${address}' ${_customScript} @@ -585,7 +556,7 @@ _script = _script.replace(/@typename@/ig, `'admin'`) // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞 - if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { + if (window.GLOB.debugger === true) { _script && console.info(`${item.$name ? `/*${item.$name} 鑷畾涔夎剼鏈紙鍚屾鏌ヨ锛�*/\n` : ''}${_sql ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${_script}`) _sql && console.info(`${item.$name ? `/*${item.$name} 鏁版嵁婧愶紙鍚屾鏌ヨ锛�*/\n` : ''}` + _sql) } @@ -600,7 +571,9 @@ func: 'sPC_Get_structured_data', LText: _LText.join(' union all '), LText_field: LText_field.join(' union all '), - BID: BID + BID: BID, + username: sessionStorage.getItem('User_Name') || '', + fullName: sessionStorage.getItem('Full_Name') || '' } if (config.MenuName) { -- Gitblit v1.8.0