From 2404d8a1bed5509432652f11aba6a1efa04aa160 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期五, 18 九月 2020 19:24:26 +0800 Subject: [PATCH] 2020-09-18 --- src/utils/utils-datamanage.js | 93 ++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 93 insertions(+), 0 deletions(-) diff --git a/src/utils/utils-datamanage.js b/src/utils/utils-datamanage.js index 3aac834..ebfef57 100644 --- a/src/utils/utils-datamanage.js +++ b/src/utils/utils-datamanage.js @@ -183,4 +183,97 @@ return param } + + /** + * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鍚堣鍊肩殑鍙傛暟 + */ + static getStatQueryDataParams (setting, statFields, search, orderBy, pageIndex, pageSize, 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) + + 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 + }) + } + + 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 => `sum(${col.field}) 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 (dataManager) { + param.dataM = 'Y' + } + + return param + } } \ No newline at end of file -- Gitblit v1.8.0