| | |
| | | * @param {Number} pageSize 每页数量 |
| | | * @param {String} BID 上级ID |
| | | * @param {String} menuType 菜单类型,普通菜单与HS |
| | | * @param {Boolean} dataManager 数据权限 |
| | | * @return {Object} param |
| | | */ |
| | | static getQueryDataParams (setting, arrFields, search = [], orderBy = '', pageIndex = 1, pageSize = 10, BID, menuType, dataManager) { |
| | | static getQueryDataParams (setting, arrFields, search = [], orderBy = '', pageIndex = 1, pageSize = 10, BID, menuType, id) { |
| | | let param = null |
| | | |
| | | if (setting.interType === 'system' || (setting.interType === 'inner' && !setting.innerFunc)) { |
| | | param = this.getDefaultQueryParam(setting, arrFields, search, orderBy, pageIndex, pageSize, menuType) |
| | | param = this.getDefaultQueryParam(setting, arrFields, search, orderBy, pageIndex, pageSize, menuType, id) |
| | | } else { |
| | | param = this.getCustomQueryParam(setting, search, orderBy, pageIndex, pageSize, menuType) |
| | | param = this.getCustomQueryParam(setting, search, orderBy, pageIndex, pageSize, menuType, id) |
| | | } |
| | | |
| | | if (BID) { |
| | | param.BID = BID |
| | | } |
| | | // 数据管理权限 |
| | | if (dataManager) { |
| | | if (sessionStorage.getItem('dataM') === 'true') { |
| | | param.dataM = 'Y' |
| | | } |
| | | |
| | |
| | | /** |
| | | * @description 获取用户自定义存储过程传参 |
| | | */ |
| | | static getCustomQueryParam (setting, search, orderBy, pageIndex, pageSize, menuType) { |
| | | static getCustomQueryParam (setting, search, orderBy, pageIndex, pageSize, menuType, id) { |
| | | let param = Utils.formatCustomMainSearch(search) |
| | | |
| | | if (orderBy) { |
| | | param.OrderCol = orderBy |
| | | } |
| | | |
| | | if (setting.laypage) { |
| | | if (id) { |
| | | param.ID = id |
| | | } else if (setting.laypage) { |
| | | param.PageIndex = pageIndex |
| | | param.PageSize = pageSize |
| | | } |
| | |
| | | /** |
| | | * @description 获取系统存储过程 sPC_Get_TableData 的参数 |
| | | */ |
| | | static getDefaultQueryParam (setting, arrFields, search, orderBy, pageIndex, pageSize, menuType) { |
| | | static getDefaultQueryParam (setting, arrFields, search, orderBy, pageIndex, pageSize, menuType, id) { |
| | | let param = { |
| | | func: 'sPC_Get_TableData', |
| | | obj_name: 'data', |
| | | exec_type: 'y', |
| | | arr_field: arrFields, |
| | | default_sql: setting.execute ? 'true' : 'false' |
| | | } |
| | | |
| | | |
| | | let _dataresource = setting.dataresource |
| | | let _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 { |
| | |
| | | } |
| | | }) |
| | | regoptions.push({ |
| | | reg: new RegExp('@userName@', 'ig'), |
| | | value: userName |
| | | }, { |
| | | reg: new RegExp('@fullName@', 'ig'), |
| | | value: fullName |
| | | }, { |
| | | reg: new RegExp('@orderBy@', 'ig'), |
| | | value: orderBy |
| | | }, { |
| | |
| | | regoptions.forEach(item => { |
| | | _dataresource = _dataresource.replace(item.reg, item.value) |
| | | }) |
| | | } else if (_dataresource) { |
| | | } else if (_dataresource && !id) { |
| | | _search = Utils.joinMainSearchkey(search) |
| | | if (_search) { |
| | | _search = 'where ' + _search |
| | | } |
| | | } else if (_dataresource && id) { |
| | | _search = Utils.joinMainSearchkey(search) |
| | | _search = `where ${_search ? _search + ' AND ' : ''} ${setting.primaryKey || 'ID'}='${id}'` |
| | | } |
| | | |
| | | if (_customScript) { |
| | |
| | | let LText = '' |
| | | let DateCount = '' |
| | | |
| | | if (_dataresource && setting.laypage && orderBy) { |
| | | if (_dataresource && setting.laypage && orderBy && !id) { |
| | | LText = ` 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 ` |
| | | DateCount = `select count(1) as total from ${_dataresource} ${_search}` |
| | | } else if (_dataresource && orderBy) { |
| | |
| | | _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,@UserID@ |
| | | ` |
| | | } |
| | | } |
| | | |
| | | // 测试系统打印查询语句 |
| | | if ((options.sysType === 'local' && !window.GLOB.systemType) || window.debugger === true) { |
| | | _customScript && console.log(`${LText ? '' : '/*不执行默认sql*/\n'}${_customScript}`) |
| | | LText && console.log(LText) |
| | | _customScript && console.info(`${LText ? '' : '/*不执行默认sql*/\n'}${_customScript}`) |
| | | LText && console.info(LText) |
| | | } |
| | | |
| | | param.custom_script = Utils.formatOptions(_customScript) |
| | | param.LText = Utils.formatOptions(LText) |
| | | param.DateCount = Utils.formatOptions(DateCount) |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | if (menuType === 'HS') { // 云端数据验证 |
| | | param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) |
| | | } |
| | | |
| | | return param |
| | | } |
| | | |
| | | /** |
| | | * @description 获取系统存储过程 sPC_Get_TableData 合计值的参数 |
| | | */ |
| | | static getStatQueryDataParams (setting, statFields, search, orderBy, BID, menuType) { |
| | | let param = { |
| | | func: 'sPC_Get_TableData', |
| | | obj_name: 'data', |
| | | exec_type: 'y', |
| | | 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.info(`${LText ? '' : '/*不执行默认sql*/\n'}${_customScript}`) |
| | | LText && console.info(LText) |
| | | } |
| | | |
| | | param.custom_script = Utils.formatOptions(_customScript) |
| | | param.LText = Utils.formatOptions(LText) |
| | | param.DateCount = '' |
| | | |
| | | param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') |
| | | param.secretkey = Utils.encrypt(param.LText, param.timestamp) |
| | | param.DateCount = Utils.formatOptions(DateCount) |
| | | param.secretkey = Utils.encrypt('', param.timestamp) |
| | | |
| | | if (menuType === 'HS') { // 云端数据验证 |
| | | param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) |
| | | } |
| | | |
| | | if (BID) { |
| | | param.BID = BID |
| | | } |
| | | |
| | | // 数据管理权限 |
| | | if (sessionStorage.getItem('dataM') === 'true') { |
| | | param.dataM = 'Y' |
| | | } |
| | | |
| | | return param |
| | | } |
| | | } |