| | |
| | | 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 |
| | |
| | | param.PageSize = pageSize |
| | | } else if (setting.$re_year) { |
| | | param.mk_year = year |
| | | } |
| | | |
| | | if (setting.hasExtend) { |
| | | param.mk_time = setting.extendTime |
| | | } |
| | | |
| | | if (setting.interType === 'inner') { |
| | |
| | | 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' |
| | | } |
| | |
| | | { 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 }) |
| | | } |
| | |
| | | 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 |
| | |
| | | param.sub_field = setting.sub_field |
| | | } |
| | | |
| | | // exec_type: 'y' 解码字段:LText、LText1、LText2、custom_script、DateCount |
| | | // exec_type 解码字段:LText、LText1、LText2、custom_script、DateCount |
| | | |
| | | 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 |
| | |
| | | param.s_debug_type = 'Y' |
| | | } |
| | | |
| | | if (window.GLOB.forcedUpdate) { |
| | | param.s_version_up = 'true' |
| | | } |
| | | |
| | | if (window.GLOB.mkHS) { // 云端数据验证 |
| | | param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) |
| | | |
| | |
| | | if (setting.tableName === 's_custom_script' && window.GLOB.mainSystemApi) { |
| | | param.rduri = window.GLOB.mainSystemApi |
| | | } |
| | | } else if (window.GLOB.forcedUpdate) { |
| | | param.s_version_up = 'true' |
| | | } |
| | | |
| | | return param |
| | |
| | | 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' |
| | | } |
| | |
| | | { 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'`}, |
| | | ) |
| | | |
| | |
| | | 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') |
| | |
| | | } |
| | | |
| | | 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 |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | /** |
| | | * @description 生成sPC_Get_structured_data请求参数 |
| | | * 1、把大接口sPC_Get_structured_data的ltext拆成三份,第一段:@LText1,第二段@LText,第三段@LText2 |
| | | */ |
| | | export function getStructuredParams (params, config, BID) { |
| | | let LText_field = [] |
| | |
| | | { 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'`}, |
| | | ] |
| | | |
| | |
| | | |
| | | 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 |
| | |
| | | } |
| | | |
| | | 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 |
| | | } |