From 316877c1d9e5b6d92334f30b03d97d7e833cd934 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 02 二月 2021 16:01:57 +0800 Subject: [PATCH] 2021-02-02 --- src/tabviews/custom/index.jsx | 195 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 194 insertions(+), 1 deletions(-) diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index ac068c0..f6c7e40 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' @@ -26,6 +27,8 @@ const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch')) const NormalTable = asyncComponent(() => import('./components/table/normal-table')) const NormalGroup = asyncComponent(() => import('./components/group/normal-group')) +const BraftEditor = asyncComponent(() => import('./components/editor/braft-editor')) +const SandBox = asyncComponent(() => import('./components/code/sand-box')) const SettingComponent = asyncComponent(() => import('@/tabviews/zshare/settingcomponent')) const PagemsgComponent = asyncComponent(() => import('@/tabviews/zshare/pageMessage')) @@ -178,6 +181,8 @@ if (!this.props.Tab) { this.setShortcut() } + + this.loadData() }) } else { this.setState({ @@ -225,6 +230,178 @@ return false }) } + } + + 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 = (inters) => { + let setting = inters.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 (inters.length > 0) { + this.loadOutResource(inters) + } + } else { + this.customOuterRequest(res, setting, inters) + } + } else { + notification.error({ + top: 92, + message: res.message, + duration: 10 + }) + } + }) + } + + customOuterRequest = (result, setting, inters) => { + 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, inters) + } else { + res.mk_api_key = mkey + this.customCallbackRequest(res, setting, inters) + } + }, (e) => { + let _result = { + mk_api_key: mkey, + $ErrCode: 'E', + $ErrMesg: e && e.statusText ? e.statusText : '' + } + + this.customCallbackRequest(_result, setting, inters) + }) + } + + customCallbackRequest = (result, setting, inters) => { + 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 (inters.length > 0) { + this.loadOutResource(inters) + } + } else { + notification.error({ + top: 92, + message: res.message, + duration: 10 + }) + } + }) } filterComponent = (components, roleId, permAction, permMenus) => { @@ -482,8 +659,12 @@ return component } + if (['propcard', 'brafteditor', 'sandbox'].includes(component.subtype) && component.wrap.datatype === 'static') { + component.format = '' + } + if (!component.setting) return component // 涓嶄娇鐢ㄧ郴缁熷嚱鏁版椂 - if (!component.format || (component.subtype === 'propcard' && component.wrap.datatype === 'static')) return component // 娌℃湁鍔ㄦ�佹暟鎹� 鏁版嵁鏍煎紡 array 鎴� object + if (!component.format) return component // 娌℃湁鍔ㄦ�佹暟鎹� 鏁版嵁鏍煎紡 array 鎴� object if (component.setting.interType !== 'system') { // 涓嶄娇鐢ㄧ郴缁熷嚱鏁版椂 component.setting.sync = 'false' component.setting.laypage = component.setting.laypage === 'true' @@ -822,6 +1003,18 @@ <NormalGroup config={item} BID={_bid} mainSearch={mainSearch} menuType={menuType} /> </Col> ) + } else if (item.type === 'editor') { + return ( + <Col span={item.width} key={item.uuid}> + <BraftEditor config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} /> + </Col> + ) + } else if (item.type === 'code') { + return ( + <Col span={item.width} key={item.uuid}> + <SandBox config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} /> + </Col> + ) } else { return null } -- Gitblit v1.8.0