From dfb7b774d9934f4f5b3edf1a39bf73be9c90c55d Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 13 十一月 2020 15:44:57 +0800 Subject: [PATCH] 移出数据表 --- src/utils/utils-datamanage.js | 125 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 124 insertions(+), 1 deletions(-) diff --git a/src/utils/utils-datamanage.js b/src/utils/utils-datamanage.js index 3aac834..d214736 100644 --- a/src/utils/utils-datamanage.js +++ b/src/utils/utils-datamanage.js @@ -86,7 +86,7 @@ arr_field: arrFields, default_sql: setting.execute ? 'true' : 'false' } - + let _dataresource = setting.dataresource let _customScript = '' @@ -99,6 +99,13 @@ let regoptions = null if (setting.queryType === 'statistics' || _customScript) { let allSearch = Utils.getAllSearchOptions(search) + let userName = sessionStorage.getItem('User_Name') || '' + let fullName = sessionStorage.getItem('Full_Name') || '' + + if (sessionStorage.getItem('isEditState') === 'true') { + userName = sessionStorage.getItem('CloudUserName') || '' + fullName = sessionStorage.getItem('CloudFullName') || '' + } regoptions = allSearch.map(item => { return { @@ -107,6 +114,12 @@ } }) regoptions.push({ + reg: new RegExp('@userName@', 'ig'), + value: userName + }, { + reg: new RegExp('@fullName@', 'ig'), + value: fullName + }, { reg: new RegExp('@orderBy@', 'ig'), value: orderBy }, { @@ -183,4 +196,114 @@ return param } + + /** + * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鍚堣鍊肩殑鍙傛暟 + */ + static getStatQueryDataParams (setting, statFields, search, orderBy, BID, menuType, dataManager) { + let param = { + func: 'sPC_Get_TableData', + obj_name: 'data', + arr_field: statFields.map(col => col.field).join(','), + default_sql: setting.execute ? 'true' : 'false' + } + + let _dataresource = setting.dataresource + let _customScript = '' + + if (setting.customScript) { + _customScript = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000) select @ErrorCode='',@retmsg ='' + ${setting.customScript} + ` + } + + let regoptions = null + if (setting.queryType === 'statistics' || _customScript) { + let allSearch = Utils.getAllSearchOptions(search) + let userName = sessionStorage.getItem('User_Name') || '' + let fullName = sessionStorage.getItem('Full_Name') || '' + + if (sessionStorage.getItem('isEditState') === 'true') { + userName = sessionStorage.getItem('CloudUserName') || '' + fullName = sessionStorage.getItem('CloudFullName') || '' + } + + regoptions = allSearch.map(item => { + return { + reg: new RegExp('@' + item.key + '@', 'ig'), + value: `'${item.value}'` + } + }) + regoptions.push({ + reg: new RegExp('@userName@', 'ig'), + value: userName + }, { + reg: new RegExp('@fullName@', 'ig'), + value: fullName + }, { + 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 + } + + if (setting.queryType === 'statistics') { // 缁熻鏁版嵁婧愶紝鍐呭鏇挎崲 + regoptions.forEach(item => { + _dataresource = _dataresource.replace(item.reg, item.value) + }) + } + + if (_customScript) { + regoptions.forEach(item => { + _customScript = _customScript.replace(item.reg, item.value) + }) + } + + let LText = ` select ${statFields.map(col => `isnull(sum(${col.field}),0) as ${col.field}`).join(',')} from ${_dataresource} ${_search} ` + + if (_customScript) { + LText = `${LText} + aaa: + if @ErrorCode!='' + insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@ + ` + } + + // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞 + if ((options.sysType === 'local' && !window.GLOB.systemType) || window.debugger === true) { + _customScript && console.log(`${LText ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${_customScript}`) + LText && console.log(LText) + } + + param.custom_script = Utils.formatOptions(_customScript) + param.LText = Utils.formatOptions(LText) + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.secretkey = Utils.encrypt(param.LText, param.timestamp) + param.DateCount = '' + + if (menuType === 'HS') { // 浜戠鏁版嵁楠岃瘉 + param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + } + + if (BID) { + param.BID = BID + } + + // 鏁版嵁绠$悊鏉冮檺 + if (dataManager) { + param.dataM = 'Y' + } + + return param + } } \ No newline at end of file -- Gitblit v1.8.0