From 5ca389a3b7bfc54067547e2b8663ce413f602f3f Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期日, 31 一月 2021 20:41:30 +0800 Subject: [PATCH] 2021-01-31 --- src/tabviews/custom/index.jsx | 175 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 175 insertions(+), 0 deletions(-) diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index c772dd4..98e030c 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -11,6 +11,7 @@ import zhCN from '@/locales/zh-CN/main.js' import enUS from '@/locales/en-US/main.js' import Utils from '@/utils/utils.js' +import UtilsDM from '@/utils/utils-datamanage.js' import asyncComponent from '@/utils/asyncComponent' import MKEmitter from '@/utils/events.js' import NotFount from '@/components/404' @@ -180,6 +181,8 @@ if (!this.props.Tab) { this.setShortcut() } + + this.loadData() }) } else { this.setState({ @@ -229,6 +232,178 @@ } } + loadData = () => { + const { config } = this.state + + if (!config.interfaces || config.interfaces.length === 0) return + + let inters = [] + + config.interfaces.forEach(item => { + if (item.status !== 'true') return + + if (window.GLOB.systemType === 'production' && !item.proInterface) { + notification.warning({ + top: 92, + message: `銆�${item.name}銆嬫湭璁剧疆姝e紡绯荤粺鍦板潃!`, + duration: 3 + }) + return + } + + inters.push(item) + }) + + if (inters.length > 0) { + this.loadOutResource(inters) + } + } + + loadOutResource = (params) => { + let setting = params.shift() + let param = UtilsDM.getPrevQueryParams(setting, [], this.state.BID, this.props.menuType) + + Api.genericInterface(param).then(res => { + if (res.status) { + if (res.mk_ex_invoke === 'false') { + if (params.length > 0) { + this.loadOutResource(params) + } + } else { + this.customOuterRequest(res, setting, params) + } + } else { + notification.error({ + top: 92, + message: res.message, + duration: 10 + }) + } + }) + } + + customOuterRequest = (result, setting, params) => { + let url = '' + + if (window.GLOB.systemType === 'production') { + url = setting.proInterface + } else { + url = setting.interface + } + + let mkey = result.mk_api_key || '' + + delete result.mk_ex_invoke + delete result.status + delete result.message + delete result.ErrCode + delete result.ErrMesg + delete result.mk_api_key + + let param = {} + + Object.keys(result).forEach(key => { + key = key.replace(/^mk_/ig, '') + param[key] = result[key] + }) + + Api.directRequest(url, setting.method, param).then(res => { + if (typeof(res) !== 'object' || Array.isArray(res)) { + let error = '鏈煡鐨勮繑鍥炵粨鏋滐紒' + + if (typeof(res) === 'string') { + error = res.replace(/'/ig, '"') + } + + let _result = { + mk_api_key: mkey, + $ErrCode: 'E', + $ErrMesg: error + } + + this.customCallbackRequest(_result, setting, params) + } else { + res.mk_api_key = mkey + this.customCallbackRequest(res, setting, params) + } + }, (e) => { + let _result = { + mk_api_key: mkey, + $ErrCode: 'E', + $ErrMesg: e && e.statusText ? e.statusText : '' + } + + this.customCallbackRequest(_result, setting, params) + }) + } + + customCallbackRequest = (result, setting, params) => { + let errSql = '' + if (result.$ErrCode === 'E') { + errSql = ` + set @ErrorCode='E' + set @retmsg='${result.$ErrMesg}' + ` + delete result.$ErrCode + delete result.$ErrMesg + } + + let lines = UtilsDM.getCallBackSql(setting, result) + let param = {} + + if (setting.callbackType === 'script') { // 浣跨敤鑷畾涔夎剼鏈� + let sql = lines.map(item => (` + ${item.insert} + ${item.selects.join(` union all + `)} + `)) + sql = sql.join('') + + param = UtilsDM.getCallBackQueryParams(setting, sql, errSql) + + if (this.state.BID) { + param.BID = this.state.BID + } + + if (this.props.menuType === 'HS') { // 鍑芥暟 sPC_TableData_InUpDe 浜戠楠岃瘉 + param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) + } + } else { + param.func = 's_ex_result_back' + param.s_ex_result = lines.map((item, index) => ({ + MenuID: this.props.MenuID, + MenuName: this.props.MenuName, + TableName: item.table, + LongText: window.btoa(window.encodeURIComponent(`${item.insert} ${item.selects.join(` union all `)}`)), + Sort: index + 1 + })) + + if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { + let sql = lines.map(item => (` + ${item.insert} + ${item.selects.join(` union all + `)} + `)) + sql = sql.join('') + console.info(sql.replace(/\n\s{10}/ig, '\n')) + } + } + + Api.genericInterface(param).then(res => { + if (res.status) { + if (params.length > 0) { + this.loadOutResource(params) + } + } else { + notification.error({ + top: 92, + message: res.message, + duration: 10 + }) + } + }) + } + filterComponent = (components, roleId, permAction, permMenus) => { return components.filter(item => { if (item.type === 'tabs') { -- Gitblit v1.8.0