From c18f79e01a2705d34d5ac2923a26913dba07ea14 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期六, 03 八月 2024 16:04:18 +0800 Subject: [PATCH] 2024-08-03 --- src/utils/utils-datamanage.js | 123 +++++++++++++++++++++++++++++------------ 1 files changed, 87 insertions(+), 36 deletions(-) diff --git a/src/utils/utils-datamanage.js b/src/utils/utils-datamanage.js index a06bc3f..26f08c9 100644 --- a/src/utils/utils-datamanage.js +++ b/src/utils/utils-datamanage.js @@ -1,16 +1,13 @@ import md5 from 'md5' import moment from 'moment' +import { notification, Modal } from 'antd' + +import MKEmitter from '@/utils/events.js' import Utils from './utils.js' export default class DataUtils { /** - * @description 鏁版嵁婧愬悕绉帮紝鐢ㄤ簬缁熶竴鏌ヨ - * @param {Object} setting 鏁版嵁婧愯缃� - * @param {Array} search 鎼滅储鏉′欢 - * @param {String} orderBy 鎺掑簭鏂瑰紡 - * @param {Number} pageIndex 椤电爜 - * @param {Number} pageSize 姣忛〉鏁伴噺 - * @param {String} BID 涓婄骇ID + * @description 鏁版嵁婧愮粺涓�鏌ヨ */ static getQueryDataParams (setting, search = [], orderBy = '', pageIndex = 1, pageSize = 10, BID, id, year) { let param = null @@ -51,6 +48,10 @@ param.mk_year = year } + if (setting.hasExtend) { + param.mk_time = setting.extendTime + } + if (setting.interType === 'inner') { param.func = setting.innerFunc @@ -68,6 +69,12 @@ param.$token = setting.exProInterface || '' } else { param.$token = setting.exInterface || '' + } + } else if (setting.sysInterface === 'custom') { + if (window.GLOB.systemType === 'production') { + param.rduri = setting.proInterface + } else { + param.rduri = setting.interface } } else { if (window.GLOB.systemType === 'production' && setting.proInterface) { @@ -96,7 +103,7 @@ let param = { func: 'sPC_Get_TableData', obj_name: 'data', - exec_type: 'y', + exec_type: window.GLOB.execType || 'y', arr_field: setting.arr_field, default_sql: setting.execute ? 'true' : 'false' } @@ -144,9 +151,13 @@ { reg: /@SessionUid@/ig, value: `'${localStorage.getItem('SessionUid') || ''}'`}, { reg: /@UserID@/ig, value: `'${sessionStorage.getItem('UserID') || ''}'`}, { reg: /@Appkey@/ig, value: `'${window.GLOB.appkey || ''}'`}, + { reg: /@lang@/ig, value: `'${sessionStorage.getItem('lang')}'`}, { reg: /@typename@/ig, value: `'admin'`}, ) + if (setting.hasExtend) { + regoptions.push({ reg: /@mk_time@/ig, value: setting.extendTime }) + } if (setting.$re_year) { regoptions.push({ reg: /@mk_year@/ig, value: year }) } @@ -269,18 +280,18 @@ // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞 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')) - DateCount && console.info(`${setting.$name ? `/*${setting.$name} 鎬绘暟鏌ヨ*/\n` : ''}` + DateCount.replace(/\n\s{8}/ig, '\n')) + _customScript && window.mkInfo(`${setting.$name ? `/*${setting.$name} 鑷畾涔夎剼鏈�*/\n` : ''}${LText ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${_customScript}`) + LText && window.mkInfo(`${setting.$name ? `/*${setting.$name} 鏁版嵁婧�*/\n` : ''}` + LText.replace(/\n\s{8}/ig, '\n')) + DateCount && window.mkInfo(`${setting.$name ? `/*${setting.$name} 鎬绘暟鏌ヨ*/\n` : ''}` + DateCount.replace(/\n\s{8}/ig, '\n')) } if (setting.$name) { param.menuname = setting.$name } - param.custom_script = Utils.formatOptions(_customScript) - param.LText = Utils.formatOptions(LText) - param.DateCount = Utils.formatOptions(DateCount) + param.custom_script = Utils.formatOptions(_customScript, param.exec_type) + param.LText = Utils.formatOptions(LText, param.exec_type) + param.DateCount = Utils.formatOptions(DateCount, param.exec_type) if (setting.sub_field) { param.sub_name = setting.subdata @@ -289,9 +300,9 @@ param.sub_field = setting.sub_field } - // exec_type: 'y' 瑙g爜瀛楁锛歀Text銆丩Text1銆丩Text2銆乧ustom_script銆丏ateCount + // exec_type 瑙g爜瀛楁锛歀Text銆丩Text1銆丩Text2銆乧ustom_script銆丏ateCount - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss.SSS') param.secretkey = Utils.encrypt('', param.timestamp) param.username = userName @@ -308,6 +319,12 @@ if (setting.tableName === 's_custom_script' && window.GLOB.mainSystemApi) { param.rduri = window.GLOB.mainSystemApi } + } else if (window.GLOB.forcedUpdate) { + param.s_version_up = 'true' + } + + if (setting.database === 'sso' && window.GLOB.mainSystemApi) { + param.rduri = window.GLOB.mainSystemApi } return param @@ -320,7 +337,7 @@ let param = { func: 'sPC_Get_TableData', obj_name: 'data', - exec_type: 'y', + exec_type: window.GLOB.execType || 'y', arr_field: statFields.map(col => col.field).join(','), default_sql: setting.execute ? 'true' : 'false' } @@ -367,6 +384,7 @@ { reg: /@SessionUid@/ig, value: `'${localStorage.getItem('SessionUid') || ''}'`}, { reg: /@UserID@/ig, value: `'${sessionStorage.getItem('UserID') || ''}'`}, { reg: /@Appkey@/ig, value: `'${window.GLOB.appkey || ''}'`}, + { reg: /@lang@/ig, value: `'${sessionStorage.getItem('lang')}'`}, { reg: /@typename@/ig, value: `'admin'`}, ) @@ -401,16 +419,16 @@ // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞 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')) + _customScript && window.mkInfo(`${setting.$name ? `/*${setting.$name} 鑷畾涔夎剼鏈� 缁熻鏌ヨ*/\n` : ''}${LText ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${_customScript}`) + LText && window.mkInfo(`${setting.$name ? `/*${setting.$name} 鏁版嵁婧� 缁熻鏌ヨ*/\n` : ''}` + LText.replace(/\n\s{8}/ig, '\n')) } if (setting.$name) { param.menuname = setting.$name } - param.custom_script = Utils.formatOptions(_customScript) - param.LText = Utils.formatOptions(LText) + param.custom_script = Utils.formatOptions(_customScript, param.exec_type) + param.LText = Utils.formatOptions(LText, param.exec_type) param.DateCount = '' param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') @@ -433,6 +451,46 @@ } return param + } + + /** + * @description 鏁版嵁鑾峰彇鎴愬姛 + */ + static querySuccess (result) { + if (!result.message) return + + if (result.ErrCode === 'Y') { + Modal.success({ + title: result.message + }) + } else if (result.ErrCode === 'S') { + notification.success({ + top: 92, + message: result.message, + duration: 2 + }) + } + } + + /** + * @description 鏁版嵁鑾峰彇澶辫触 + */ + static queryFail (result) { + if (!result.message && result.ErrCode !== 'version_up') return + + if (result.ErrCode === 'N') { + Modal.error({ + title: result.message, + }) + } else if (result.ErrCode === 'version_up') { + MKEmitter.emit('reloadTabs') + } else if (result.ErrCode !== '-2') { + notification.error({ + top: 92, + message: result.message, + duration: 10 + }) + } } } @@ -512,7 +570,6 @@ /** * @description 鐢熸垚sPC_Get_structured_data璇锋眰鍙傛暟 - * 1銆佹妸澶ф帴鍙PC_Get_structured_data鐨刲text鎷嗘垚涓変唤锛岀涓�娈碉細@LText1锛岀浜屾@LText锛岀涓夋@LText2 */ export function getStructuredParams (params, config, BID) { let LText_field = [] @@ -527,6 +584,7 @@ { reg: /@SessionUid@/ig, value: `'${localStorage.getItem('SessionUid') || ''}'`}, { reg: /@UserID@/ig, value: `'${sessionStorage.getItem('UserID') || ''}'`}, { reg: /@Appkey@/ig, value: `'${window.GLOB.appkey || ''}'`}, + { reg: /@lang@/ig, value: `'${sessionStorage.getItem('lang')}'`}, { reg: /@typename@/ig, value: `'admin'`}, ] @@ -548,8 +606,8 @@ // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞 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) + _script && window.mkInfo(`${item.$name ? `/*${item.$name} 鑷畾涔夎剼鏈紙鍚屾鏌ヨ锛�*/\n` : ''}${_sql ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${_script}`) + _sql && window.mkInfo(`${item.$name ? `/*${item.$name} 鏁版嵁婧愶紙鍚屾鏌ヨ锛�*/\n` : ''}` + _sql) } item.columns.forEach(cell => { @@ -560,23 +618,16 @@ let param = { func: 'sPC_Get_structured_data', - LText: _LText.join(' union all '), - LText_field: LText_field.join(' union all '), BID: BID, username: sessionStorage.getItem('User_Name') || '', fullName: sessionStorage.getItem('Full_Name') || '' } - if (config.MenuName) { - param.menuname = config.MenuName - } + param.menuname = config.MenuName || config.$menuname || '' - let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText) - - param.LText1 = LText1 - param.LText = LText - param.LText2 = LText2 - param.LText_field = Utils.formatOptions(param.LText_field) + param.exec_type = window.GLOB.execType || 'y' + param.LText = Utils.formatOptions(_LText.join(' union all '), param.exec_type) + param.custom_script = Utils.formatOptions(LText_field.join(' union all '), param.exec_type) if (config.cacheUseful === 'true') { param.time_type = config.timeUnit @@ -588,7 +639,7 @@ } param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) + param.secretkey = Utils.encrypt('', param.timestamp) return param } \ No newline at end of file -- Gitblit v1.8.0