From 0eb129a9beddbb86ae74d7106a8e60823206b8d5 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期四, 14 十二月 2023 11:29:15 +0800 Subject: [PATCH] 2023-12-14 --- src/tabviews/custom/index.jsx | 646 +++++++++++++++++++++++++++++++++++++++------------------- 1 files changed, 432 insertions(+), 214 deletions(-) diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index c34c160..5af3787 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -4,8 +4,6 @@ import { notification, Spin, Row, Col, Modal } from 'antd' import Api from '@/api' -import zhCN from '@/locales/zh-CN/main.js' -import enUS from '@/locales/en-US/main.js' import Utils from '@/utils/utils.js' import { getStructuredParams, getStructDefaultParam } from '@/utils/utils-datamanage.js' import asyncComponent from '@/utils/asyncComponent' @@ -44,30 +42,27 @@ const Voucher = asyncComponent(() => import('./components/module/voucher')) const Account = asyncComponent(() => import('./components/module/account')) const Iframe = asyncComponent(() => import('./components/iframe')) +const Calendar = asyncComponent(() => import('./components/calendar')) const DebugTable = asyncComponent(() => import('@/tabviews/debugtable')) +const FlowFloat = asyncComponent(() => import('@/tabviews/zshare/flowFloat')) const TableNodes = asyncComponent(() => import('@/tabviews/zshare/tablenodes')) const MkInterfaces = asyncComponent(() => import('@/tabviews/custom/components/interfaces')) class CustomPage extends Component { static propTpyes = { param: PropTypes.any, // 鍏朵粬椤甸潰浼犻�掔殑鍙傛暟 - Tab: PropTypes.string, // 寮圭獥鏍囩 MenuID: PropTypes.string, // 鑿滃崟Id MenuName: PropTypes.string, // 鑿滃崟鍚嶇О changeTemp: PropTypes.func } state = { - dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, ContainerId: Utils.getuuid(), // 鑿滃崟澶栧眰html Id BID: '', // 椤甸潰璺宠浆鏃舵惡甯D loadingview: true, // 椤甸潰鍔犺浇涓� viewlost: false, // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤 lostmsg: '', // 椤甸潰涓㈠け鏃剁殑鎻愮ず淇℃伅 config: null, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷粍浠剁瓑 - mainSearch: null, // 涓绘悳绱� - userConfig: null, // 鐢ㄦ埛鑷畾涔夎缃� - data: null, // 鍒楄〃鏁版嵁闆� loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� visible: false, // 鏍囩椤垫帶鍒� shortcuts: null, // 蹇嵎閿� @@ -86,6 +81,7 @@ func: 'sPC_Get_LongParam', MenuID: MenuID } + let result = await Api.getCacheConfig(_param) if (result.status) { @@ -117,7 +113,7 @@ this.setState({ viewlost: true, loadingview: false, - lostmsg: this.state.dict['main.view.unenabled'] + lostmsg: '鎶辨瓑锛屾偍璁块棶鐨勯〉闈㈡湭鍚敤锛岃鑱旂郴绠$悊鍛樸��' }) return } @@ -137,8 +133,51 @@ return } + if (config.process === 'true') { + let unset = true + if (result.works_flow_code && result.works_long_param) { + try { // 娴佺▼淇℃伅瑙f瀽 + let flowConfig = JSON.parse(window.decodeURIComponent(window.atob(result.works_long_param))) + flowConfig.flow_code = result.works_flow_code + flowConfig.flow_name = result.works_flow_name + config.flow_code = result.works_flow_code + config.flow_name = result.works_flow_name + unset = false + + window.GLOB.UserCacheMap.set('flow' + MenuID, flowConfig) + } catch (e) { + unset = true + console.warn('Parse Failure') + } + } + + if (unset) { + config.interfaces = [] + this.setState({ + config: config, + viewlost: true, + loadingview: false, + lostmsg: '鎶辨瓑锛屾偍璁块棶鐨勯〉闈㈡湭璁剧疆宸ヤ綔娴侊紝璇疯仈绯荤鐞嗗憳銆�' + }) + return + } + } else if (result.works_flow_code) { + Api.getSystemConfig({ + func: 's_works_flow_param_sso_menu_upt_v6', + upt_type: 'del', + works_flow_code: '', + works_flow_name: '', + long_param: '', + flow_id: '', + menuid: config.MenuID, + menuname: config.MenuName, + username: sessionStorage.getItem('User_Name') || '', + fullName: sessionStorage.getItem('Full_Name') || '' + }) + } + // HS涓嶄娇鐢ㄨ嚜瀹氫箟璁剧疆 - if (result.LongParamUser && !window.GLOB.mkHS) { + if (result.LongParamUser) { try { // 閰嶇疆淇℃伅瑙f瀽 let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) if (userConfig) { @@ -171,11 +210,6 @@ 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') || '' - } - let regs = [ { reg: /@userName@/ig, value: `'${userName}'` }, { reg: /@fullName@/ig, value: `'${fullName}'` } @@ -197,35 +231,26 @@ }) } - let popview = 'CustomPage' - - if (config.version === 2.0) { - popview = 'popview' + if (config.flow_code) { + regs.push({ reg: /@works_flow_code@/ig, value: `'${config.flow_code}'` }) } config.$cache = config.cacheLocal === 'true' + config.$time = config.localCacheTime || 0 + + if (window.GLOB.systemType !== 'production' && result.modifydate) { + let s = (new Date().getTime() - new Date(result.modifydate).getTime()) / (1000 * 60 * 60) + if (!isNaN(s) && s < 2) { + config.$cache = false + config.$time = 0 + config.cacheUseful = 'false' + } + } let initInters = [] config.interfaces = this.formatInterSetting(config.interfaces, regs, MenuID, initInters) - config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces, popview, config.$cache, config.MenuName) - - // 鑾峰彇涓绘悳绱㈡潯浠� - let mainSearch = [] - config.components.forEach(component => { - if (component.type !== 'search') return - - component.search = component.search.map(item => { - item.oriInitval = item.initval - if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) { - item.initval = param.$searchval - } - - return item - }) - - mainSearch = Utils.initMainSearch(component.search) - }) + config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces, config.$cache, config.$time, config.MenuName, MenuID, MenuID, config.process === 'true') let params = [] let BID = param.$BID || '' @@ -237,9 +262,32 @@ inherit.cacheTime = config.cacheTime } - config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs, balMap) + // 瀛楁閫忚 + config.components.forEach(component => { + if (component.type !== 'search') return - if ([...balMap.keys()].length > 0) { + if (param.$searchkey) { + component.search = component.search.map(item => { + if (['text', 'select', 'link', 'checkcard'].includes(item.type) && param.$searchkey === item.field) { + item.initval = param.$searchval + } + + return item + }) + + component.$searches = Utils.initMainSearch(component.search) + } + + window.GLOB.SearchBox.set(MenuID, component.$searches) + + if (component.$s_req) { + window.GLOB.SearchBox.set(MenuID + 'required', true) + } + }) + + config.components = this.formatSetting(config.components, params, inherit, regs, balMap) + + if (balMap.size > 0) { config.components = this.filterBalcony(config.components, balMap) } @@ -255,8 +303,7 @@ BID: BID, loadinginter: this.stepInter !== null, shortcuts: shortcuts.length > 0 ? shortcuts : null, - config, - mainSearch + config }, () => { if (config.normalcss) { let node = document.getElementById(config.uuid) @@ -280,9 +327,7 @@ this.loadmaindata(params) } - if (!this.props.Tab) { - this.setShortcut() - } + this.setShortcut() }) } else { this.setState({ @@ -318,7 +363,6 @@ let _shortcut = `${preKey}+${keyCode}` if (window.GLOB.breakpoint && _shortcut === 'ctrl+67') { - window.debugger = false window.GLOB.breakpoint = false sessionStorage.removeItem('breakpoint') @@ -337,11 +381,32 @@ } } - filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, MenuName) => { + filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, cache, time, MenuName, searchId, syncId, process) => { return components.filter(item => { item.$pageId = pageId - item.$cache = cache + item.$searchId = searchId + item.$syncId = syncId + if (process) { + item.$process = process + item.$flowId = 'flow' + this.props.MenuID + } + + if (cache) { + item.$cache = cache + item.$time = time + + if (item.wrap && item.wrap.cacheLocal === 'false') { + item.$cache = false + } else if (item.plot && item.plot.cacheLocal === 'false') { + item.$cache = false + } + + if (!item.$cache && item.setting && item.setting.sync === 'true') { + item.setting.sync = 'false' + } + } + if (item.style && item.style.boxShadow) { delete item.style.hShadow delete item.style.vShadow @@ -359,6 +424,13 @@ return false } + if (item.setting.supModule) { + let pid = item.setting.supModule.pop() + item.setting.supModule = pid || '' + } else { + item.setting.supModule = '' + } + item.subtabs = item.subtabs.filter(tab => { if ( tab.blacklist && tab.blacklist.length > 0 && @@ -368,35 +440,37 @@ } else if (tab.hide === 'true') { return false } + + if (item.setting.supModule) { + if (tab.controlVal === '@pass@') { + tab.$pass = true + } else if (/,/ig.test(tab.controlVal)) { + tab.controlVals = tab.controlVal.split(',') + } else { + tab.controlVals = [(tab.controlVal || '')] + } + } + return true }) if (item.setting.supModule) { - let pid = item.setting.supModule.pop() - item.setting.supModule = pid || '' + item.setting.controlField = item.setting.controlField.toLowerCase() - if (item.setting.supModule) { - item.setting.controlField = item.setting.controlField.toLowerCase() - - if (item.setting.supModule === 'preview') { - item.setting.supModule = '' - let val = '' - Object.keys(urlparam).forEach(key => { - if (key.toLowerCase() === item.setting.controlField) { - val = urlparam[key] - } - }) - - item.subtabs = item.subtabs.filter(tab => { - if (tab.controlVal === val) { - return false - } else if (/,/ig.test(tab.controlVal)) { - return !tab.controlVal.split(',').includes(val) - } - - return true - }) - } + if (item.setting.supModule === 'preview') { + item.setting.supModule = '' + let val = '' + Object.keys(urlparam).forEach(key => { + if (key.toLowerCase() === item.setting.controlField) { + val = urlparam[key] + } + }) + + item.subtabs = item.subtabs.filter(tab => { + if (tab.$pass) return true + + return !tab.controlVals.includes(val) + }) } } @@ -423,8 +497,27 @@ item.subtabs = item.subtabs.map(tab => { tab.$pageId = pageId + tab.$cache = cache + tab.$time = time - tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, MenuName) + let _searchId = searchId + + if (tab.components.findIndex(cell => cell.type === 'search') > -1) { + _searchId = tab.uuid + } + + tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, cache, time, MenuName, _searchId, tab.uuid, process) + + if (_searchId === tab.uuid) { + tab.components.forEach(cell => { + if (cell.type !== 'search') return + window.GLOB.SearchBox.set(_searchId, cell.$searches) + if (cell.$s_req) { + window.GLOB.SearchBox.set(_searchId + 'required', true) + } + }) + } + return tab }) @@ -437,7 +530,7 @@ return false } - item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, MenuName) + item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, cache, time, MenuName, searchId, syncId, process) return true } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart', 'antvG6', 'antvX6'].includes(item.type)) { @@ -460,7 +553,8 @@ if (!inter) { item.wrap.datatype = 'static' } else { - item.setting = inter.setting + item.setting = {...inter.setting} + item.$searchId = inter.$searchId } } } @@ -470,8 +564,10 @@ } // 鎼滅储鏉′欢鍒濆鍖� - if (item.search && item.search.length > 0) { - item.search = Utils.initSearchVal(item.search) + if (item.search) { + Utils.initSearchVal(item) + + item.$searches = Utils.initMainSearch(item.search) } if (item.wrap && item.wrap.supType === 'multi') { // 鏁版嵁鍗″涓婄骇缁勪欢 @@ -496,7 +592,7 @@ item.action = item.action.filter(cell => { if (cell.hidden === 'true') return false - cell = this.resetButton(item, cell, popview) + cell = this.resetButton(item, cell) cell.$toolbtn = true @@ -509,7 +605,6 @@ } if (item.type === 'table') { - let statFields = [] let getCols = (cols) => { return cols.filter(col => { if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { @@ -521,9 +616,6 @@ } if (col.type === 'number') { - if (col.sum === 'true' && !statFields.includes(col.field)) { - statFields.push(col) - } if (typeof(col.decimal) === 'number') { col.round = Math.pow(10, col.decimal) if (col.format === 'percent') { @@ -544,7 +636,7 @@ if (cell.eleType === 'button') { if (cell.hidden === 'true') return false - cell = this.resetButton(item, cell, popview) + cell = this.resetButton(item, cell) if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) @@ -564,9 +656,13 @@ if (col.linkmenu && col.linkmenu.length > 0) { let menu_id = col.linkmenu.pop() - col.linkThdMenu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menu_id)[0] || '' + col.linkThdMenu = window.GLOB.mkThdMenus.get(menu_id) || '' } else { col.linkThdMenu = '' + } + + if (col.marks && col.marks.length === 0) { + col.marks = null } return true @@ -574,7 +670,6 @@ } item.cols = getCols(item.cols) - item.statFields = statFields if (item.subtype === 'editable') { item.submit.logLabel = item.$menuname + '-鎻愪氦' @@ -601,7 +696,7 @@ if (cell.eleType === 'button') { if (cell.hidden === 'true') return false - cell = this.resetButton(item, cell, popview) + cell = this.resetButton(item, cell) if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) @@ -643,7 +738,7 @@ if (cell.eleType === 'button') { if (cell.hidden === 'true') return false - cell = this.resetButton(item, cell, popview) + cell = this.resetButton(item, cell) if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) @@ -667,7 +762,7 @@ if (cell.eleType === 'button') { if (cell.hidden === 'true') return false - cell = this.resetButton(item, cell, popview) + cell = this.resetButton(item, cell) if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) @@ -681,24 +776,17 @@ } else if (item.type === 'form') { item.subcards = item.subcards.map(group => { group.subButton.uuid = group.uuid - group.subButton.$menuId = group.uuid - group.subButton.$MenuID = this.props.MenuID - // group.subButton.$forbid = true // 涓嶅0鏄庢暟鎹簮鍙橀噺 group.subButton.OpenType = 'formSubmit' group.subButton.execError = 'never' - group.subButton.logLabel = item.$menuname + '-' + group.subButton.label - if (!group.subButton.Ot) { group.subButton.Ot = item.wrap.datatype === 'static' ? 'notRequired' : 'requiredSgl' } - group.subButton.syncComponentId = group.subButton.syncComponent ? (group.subButton.syncComponent.pop() || '') : '' + group.subButton = this.resetButton(item, group.subButton) - if (group.subButton.syncComponentId && group.subButton.syncComponentId === item.setting.supModule) { - group.subButton.syncComponentId = '' - if (group.subButton.execSuccess === 'grid') { - group.subButton.execSuccess = 'mainline' - } + if (item.$cache && item.$time) { // 琛ㄥ崟缂撳瓨 + group.$cache = item.$cache + group.$time = item.$time } group.fields = group.fields.map(cell => { @@ -771,14 +859,19 @@ }) } - resetButton = (item, cell, popview) => { + resetButton = (item, cell) => { cell.logLabel = item.$menuname + '-' + cell.label cell.Ot = cell.Ot || 'requiredSgl' cell.ContainerId = this.state.ContainerId cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' cell.$menuId = item.uuid cell.$MenuID = this.props.MenuID - cell.$view = popview + cell.$view = 'popview' + + if (item.$process) { + cell.$process = true + cell.$flowId = 'flow' + this.props.MenuID + } if (cell.btnstyle) { // 鍏煎 cell.style = cell.style || {} @@ -790,6 +883,48 @@ cell.controlVals = cell.controlVal.split(',') } else { cell.controlVals = [(cell.controlVal || '')] + } + } + + if (cell.OpenType === 'excelOut') { // 瀵煎嚭 + cell.$menuName = item.name + + if (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0) { + cell.errorType = 'error1' + } else if (cell.intertype === 'system' && cell.verify.dataType !== 'custom') { + if (item.setting.interType !== 'system') { + cell.errorType = 'error2' + } else if (item.type === 'balcony' || item.subtype === 'propcard') { + cell.errorType = 'error2' + } + } + } else if (cell.OpenType === 'pop' && item.$cache && item.$time && cell.modal) { + cell.modal.$cache = item.$cache + cell.modal.$time = item.$time + cell.modal.uuid = cell.uuid + 'pop' + } + + if (cell.verify && cell.verify.invalid === 'true') { + if (item.wrap && (item.wrap.datatype === 'static' || item.wrap.datatype === 'public')) { + cell.verify.invalid = 'false' + } else if (item.setting && item.setting.maxScript && item.setting.maxScript >= 300) { + cell.verify.invalid = 'false' + } else if (cell.intertype !== 'system' && cell.procMode !== 'system') { + cell.verify.invalid = 'false' + } else if (cell.sqlType === 'insert') { + cell.verify.invalid = 'false' + } else if (cell.Ot === 'notRequired') { + cell.verify.invalid = 'false' + } + } + + if (cell.verify && cell.verify.preHandle === 'true') { + try { + // eslint-disable-next-line + let func = new Function('btn', 'systemType', cell.verify.pre_func) + func(cell, window.GLOB.systemType) + } catch (e) { + console.warn(e) } } @@ -824,6 +959,15 @@ resetElement = (cell) => { cell.style = cell.style || {} + + if (cell.style.display === 'inline-block') { + cell.style.verticalAlign = 'top' + } + + if (cell.marks && cell.marks.length === 0) { + cell.marks = null + } + if (['text', 'number', 'formula'].includes(cell.eleType)) { if (!cell.height) { cell.innerHeight = 'auto' @@ -862,6 +1006,8 @@ getPrinter = (item, parentId) => { let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid) + item.verify.logLabel = item.logLabel + if (_item) { item.printer = _item.printer || '' item.verify.defaultPrinter = _item.printer || '' @@ -878,50 +1024,69 @@ } // 鏍煎紡鍖栭粯璁よ缃� - formatSetting = (components, params, mainSearch, inherit, regs, balMap) => { + formatSetting = (components, params, inherit, regs, balMap) => { let delay = 20 return components.map(component => { if (component.type === 'tabs') { component.subtabs = component.subtabs.map(tab => { - tab.components = this.formatSetting(tab.components, null, null, inherit, regs, balMap) + tab.components = this.formatSetting(tab.components, null, inherit, regs, balMap) tab = {...tab, ...inherit} return tab }) return component } else if (component.type === 'group') { - component.components = this.formatSetting(component.components, null, null, inherit, regs, balMap) - component = {...component, ...inherit} + component.components = this.formatSetting(component.components, params, null, regs, balMap) return component } else if (component.wrap && component.wrap.datatype === 'public') { - component.setting.useMSearch = false - return component } else if (component.wrap && component.wrap.datatype === 'static') { component.format = '' component.setting = component.setting || {} component.setting.useMSearch = false + component.setting.sync = 'false' return component } else if (!component.setting || !component.format) { return component } + component.setting.arr_field = component.columns ? component.columns.map(col => col.field).join(',') : '' component.setting.useMSearch = component.setting.useMSearch === 'true' + component.setting.laypage = component.setting.laypage === 'true' // 鏄惁鍒嗛〉锛岃浆涓篵oolean 缁熶竴鏍煎紡 + + if (component.setting.useMSearch) { + if (!window.GLOB.SearchBox.has(component.$searchId)) { + component.setting.useMSearch = false + } else if (window.GLOB.SearchBox.has(component.$searchId + 'required')) { + component.$s_req = true + } + } if (component.wrap && component.wrap.goback === 'true') { component.setting.sync = 'false' } + if (component.format === 'object') { + component.setting.laypage = false + component.setting.$top = true + } + if (component.setting.interType !== 'system') { // 涓嶄娇鐢ㄧ郴缁熷嚱鏁版椂 component.setting.sync = 'false' - component.setting.laypage = component.setting.laypage === 'true' + component.setting.dataresource = '' return component } let _customScript = '' + let _tailScript = '' component.scripts && component.scripts.forEach(script => { - if (script.status !== 'false') { + if (script.status === 'false') return + if (script.position !== 'back') { _customScript += ` + ${script.sql} + ` + } else { + _tailScript += ` ${script.sql} ` } @@ -929,8 +1094,7 @@ delete component.scripts component.setting.$name = component.$menuname || '' component.setting.execute = component.setting.execute !== 'false' // 榛樿sql鏄惁鎵ц锛岃浆涓篵oolean 缁熶竴鏍煎紡 - component.setting.laypage = component.setting.laypage === 'true' // 鏄惁鍒嗛〉锛岃浆涓篵oolean 缁熶竴鏍煎紡 - + if (!component.setting.execute) { component.setting.dataresource = '' } @@ -939,51 +1103,63 @@ } if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') - component.setting.dataresource = component.setting.dataresource.replace(/@\$/ig, '*/') - _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') - _customScript = _customScript.replace(/@\$/ig, '*/') + component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') + _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') + _tailScript = _tailScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') } else { component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') + _tailScript = _tailScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') } regs.forEach(cell => { component.setting.dataresource = component.setting.dataresource.replace(cell.reg, cell.value) _customScript = _customScript.replace(cell.reg, cell.value) + _tailScript = _tailScript.replace(cell.reg, cell.value) }) component.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰 + component.setting.tailScript = _tailScript // 鍚庣疆鑷畾涔夎剼鏈� + + component.setting.custompage = /@pageSize@|@orderBy@/i.test(component.setting.dataresource + component.setting.customScript) + + if (!component.setting.execute || component.setting.custompage) { + component.forbidLine = true + } + + if (component.setting.sync === 'true') { + // pageable 鏄惁鍒嗛〉锛岀粍浠跺睘鎬э紝涓嶅垎椤电殑缁勪欢鎵嶅彲浠ョ粺涓�鏌ヨ + if ((!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true') { + + } else { + component.setting.sync = 'false' + } + } // dataName 绯荤粺鐢熸垚鐨勬暟鎹簮鍚嶇О if (component.setting.sync === 'true') { component.dataName = 'mk' + component.uuid.slice(-18) - } - - // floor 缁勪欢鐨勫眰绾� - // pageable 鏄惁鍒嗛〉锛岀粍浠跺睘鎬э紝涓嶅垎椤电殑缁勪欢鎵嶅彲浠ョ粺涓�鏌ヨ - if (params && (!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true' && component.setting.sync === 'true') { - let searchlist = [] - if (component.search && component.search.length > 0) { - searchlist = Utils.initMainSearch(component.search) - } - if (component.setting.useMSearch) { - let keys = searchlist.map(item => item.key) - mainSearch.forEach(item => { - if (!keys.includes(item.key)) { + + if (params) { + let searchlist = component.$searches || [] + + if (component.setting.useMSearch) { + let mainSearch = window.GLOB.SearchBox.get(component.$searchId) + let keys = component.$s_keys || [] + mainSearch.forEach(item => { + if (keys.includes(item.key.toLowerCase())) return + searchlist.push(item) - } - }) + }) + } + + if (component.$s_req && searchlist.filter(item => item.required && item.value === '').length > 0) { + component.setting.sync = 'false' + component.setting.onload = 'false' + } else { + params.push(getStructDefaultParam(component, searchlist, params.length === 0)) + } } - - if (searchlist.filter(item => item.required && item.value === '').length > 0) { - component.setting.sync = 'false' - component.setting.onload = 'false' - } else { - params.push(getStructDefaultParam(component, searchlist, params.length === 0)) - } - } else if (params) { - component.setting.sync = 'false' } component.setting.delay = delay @@ -1018,6 +1194,7 @@ return interfaces.map(inter => { inter.MenuID = MenuID inter.setting.delay = delay + inter.$searchId = MenuID delay += 15 if (inter.setting.supModule) { @@ -1028,17 +1205,28 @@ inter.setting.supModule = '' } } - + if (initlimit && inter.setting.loadlevel !== 'init') { inter.setting.onload = 'false' } + inter.setting.laypage = false + inter.setting.$top = true + inter.setting.useMSearch = inter.setting.useMSearch === 'true' + inter.setting.arr_field = inter.columns.map(col => col.field).join(',') + if (inter.setting.interType !== 'system') return inter let _customScript = '' + let _tailScript = '' inter.scripts.forEach(script => { - if (script.status !== 'false') { + if (script.status === 'false') return + if (script.position !== 'back') { _customScript += ` + ${script.sql} + ` + } else { + _tailScript += ` ${script.sql} ` } @@ -1047,7 +1235,6 @@ inter.setting.$name = '鍏叡鏁版嵁婧�-' + inter.setting.name inter.setting.execute = inter.setting.execute !== 'false' - inter.setting.laypage = true if (!inter.setting.execute) { inter.setting.dataresource = '' @@ -1057,21 +1244,25 @@ } if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - inter.setting.dataresource = inter.setting.dataresource.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') - inter.setting.dataresource = inter.setting.dataresource.replace(/@\$/ig, '*/') - _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, '\'Y\'') - _customScript = _customScript.replace(/@\$/ig, '*/') + inter.setting.dataresource = inter.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') + _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') + _tailScript = _tailScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'') } else { inter.setting.dataresource = inter.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') + _tailScript = _tailScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') } regs.forEach(cell => { inter.setting.dataresource = inter.setting.dataresource.replace(cell.reg, cell.value) _customScript = _customScript.replace(cell.reg, cell.value) + _tailScript = _tailScript.replace(cell.reg, cell.value) }) inter.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰 + inter.setting.tailScript = _tailScript // 鍚庣疆鑷畾涔夎剼鏈� + + inter.setting.custompage = /@pageSize@|@orderBy@/i.test(inter.setting.dataresource + inter.setting.customScript) return inter }) @@ -1081,12 +1272,32 @@ * @description 涓昏〃鏁版嵁鍔犺浇 */ loadmaindata = (params) => { - const { config } = this.state - let param = getStructuredParams(params, config, this.state.BID || '') + const { config, BID } = this.state + let param = getStructuredParams(params, config, BID || '') this.setState({loading: true, loadingview: false}) + if (config.$cache && config.$time) { + Api.getLCacheConfig(params[0].uuid, config.$time, BID).then(res => { + if (!res.valid) { + this.getMainData(param, params, config.MenuID) + } else { + this.setState({ + loading: false + }) + } + }) + } else { + this.getMainData(param, params, config.MenuID) + } + } + + getMainData = (param, params, MenuID) => { Api.genericInterface(param).then(result => { + this.setState({ + loading: false + }) + if (result.status) { if (result.message) { if (result.ErrCode === 'Y') { @@ -1102,31 +1313,18 @@ } } - delete result.status - delete result.message - delete result.ErrMesg - delete result.ErrCode - - if (config.$cache) { - params.forEach((item) => { - let _data = result[item.name] || '' - if (_data && !Array.isArray(_data)) { - _data = [_data] - } - Api.writeCacheConfig(item.uuid, _data) - }) - } - - this.setState({ - data: result, - loading: false + params.forEach((item) => { + let _data = result[item.name] || '' + if (_data && !Array.isArray(_data)) { + _data = [_data] + } + window.GLOB.SyncData.set(item.name, _data) }) + + MKEmitter.emit('transferSyncData', MenuID) } else { - this.setState({ - data: '', - loading: false - }) - + MKEmitter.emit('transferSyncData', MenuID) + if (!result.message) return if (result.ErrCode === 'N') { Modal.error({ @@ -1152,9 +1350,9 @@ } resetActiveMenu = (menuId) => { - const { MenuID, Tab } = this.props + const { MenuID } = this.props - if (MenuID !== menuId || Tab) return + if (MenuID !== menuId) return this.setShortcut() } @@ -1232,8 +1430,13 @@ }) } else if (item.type === 'group') { this.deleteCache(item.components) + } else if (item.type === 'search') { + window.GLOB.SearchBox.delete(item.$searchId) } else { window.GLOB.CacheData.delete(item.uuid) + } + if (item.dataName) { + window.GLOB.SyncData.delete(item.dataName) } }) } @@ -1256,21 +1459,14 @@ viewlost: false, // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤 config: null, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷粍浠剁瓑 loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� - shortcuts: null, - data: '' + shortcuts: null }, () => { this.loadconfig() }) } - resetSearch = (search) => { - this.setState({mainSearch: null}, () => { - this.setState({mainSearch: search}) - }) - } - getComponents = () => { - const { config, BID, data, mainSearch, loadinginter } = this.state + const { config, BID, loadinginter } = this.state if (!config || !config.components || loadinginter) return @@ -1279,156 +1475,164 @@ if (item.style && item.style.clear === 'left') { style = {clear: 'left'} + } else if (item.style && item.style.clear === 'right') { + style = {float: 'right'} } if (item.type === 'card' && item.subtype === 'datacard') { return ( <Col span={item.width} style={style} key={item.uuid}> - <DataCard config={item} data={data} mainSearch={mainSearch}/> + <DataCard config={item}/> </Col> ) } else if (item.type === 'card' && item.subtype === 'propcard') { return ( <Col span={item.width} style={style} key={item.uuid}> - <PropCard config={item} data={data} mainSearch={mainSearch}/> + <PropCard config={item}/> </Col> ) } else if (item.type === 'card' && item.subtype === 'dualdatacard') { return ( <Col span={item.width} style={style} key={item.uuid}> - <DoubleDataCard config={item} mainSearch={mainSearch}/> + <DoubleDataCard config={item}/> </Col> ) } else if (item.type === 'table' && item.subtype === 'normaltable') { return ( <Col span={item.width} style={style} key={item.uuid}> - <NormalTable config={item} data={data} mainSearch={mainSearch}/> + <NormalTable config={item}/> </Col> ) } else if (item.type === 'bar' || item.type === 'line') { return ( <Col span={item.width} style={style} key={item.uuid}> - <AntvBarAndLine config={item} data={data} mainSearch={mainSearch}/> + <AntvBarAndLine config={item}/> </Col> ) } else if (item.type === 'pie') { return ( <Col span={item.width} style={style} key={item.uuid}> - <AntvPie config={item} data={data} mainSearch={mainSearch}/> + <AntvPie config={item}/> </Col> ) } else if (item.type === 'scatter') { return ( <Col span={item.width} style={style} key={item.uuid}> - <AntvScatter config={item} data={data} mainSearch={mainSearch}/> + <AntvScatter config={item}/> </Col> ) } else if (item.type === 'dashboard') { return ( <Col span={item.width} style={style} key={item.uuid}> - <AntvDashboard config={item} data={data} mainSearch={mainSearch}/> + <AntvDashboard config={item}/> </Col> ) } else if (item.type === 'form' && item.subtype === 'simpleform') { return ( <Col span={item.width} style={style} key={item.uuid}> - <SimpleForm config={item} data={data} mainSearch={mainSearch}/> + <SimpleForm config={item}/> </Col> ) } else if (item.type === 'form' && item.subtype === 'stepform') { return ( <Col span={item.width} style={style} key={item.uuid}> - <StepForm config={item} data={data} mainSearch={mainSearch}/> + <StepForm config={item}/> </Col> ) } else if (item.type === 'form' && item.subtype === 'tabform') { return ( <Col span={item.width} style={style} key={item.uuid}> - <TabForm config={item} data={data} mainSearch={mainSearch}/> + <TabForm config={item}/> </Col> ) } else if (item.type === 'search') { return ( <Col span={item.width} style={style} key={item.uuid}> - <MainSearch config={item} BID={BID} refreshdata={this.resetSearch} /> + <MainSearch config={item} BID={BID}/> </Col> ) } else if (item.type === 'tabs') { return ( <Col span={item.width} style={style} key={item.uuid}> - <AntvTabs config={item} mainSearch={mainSearch} /> + <AntvTabs config={item}/> </Col> ) } else if (item.type === 'balcony') { return ( <Col span={item.width} style={style} key={item.uuid}> - <Balcony config={item} data={data}/> + <Balcony config={item}/> </Col> ) } else if (item.type === 'timeline') { return ( <Col span={item.width} style={style} key={item.uuid}> - <TimeLine config={item} data={data} mainSearch={mainSearch}/> + <TimeLine config={item}/> </Col> ) } else if (item.type === 'carousel' && item.subtype === 'datacard') { return ( <Col span={item.width} style={style} key={item.uuid}> - <CarouselDataCard config={item} data={data} mainSearch={mainSearch}/> + <CarouselDataCard config={item}/> </Col> ) } else if (item.type === 'carousel' && item.subtype === 'propcard') { return ( <Col span={item.width} style={style} key={item.uuid}> - <CarouselPropCard config={item} data={data} mainSearch={mainSearch}/> + <CarouselPropCard config={item}/> </Col> ) } else if (item.type === 'card' && item.subtype === 'tablecard') { return ( <Col span={item.width} style={style} key={item.uuid}> - <TableCard config={item} data={data} mainSearch={mainSearch}/> + <TableCard config={item}/> </Col> ) } else if (item.type === 'table' && item.subtype === 'editable') { return ( <Col span={item.width} style={style} key={item.uuid}> - <EditTable config={item} mainSearch={mainSearch}/> + <EditTable config={item}/> </Col> ) } else if (item.type === 'group' && item.subtype === 'normalgroup') { return ( <Col span={item.width} style={style} key={item.uuid}> - <NormalGroup config={item} mainSearch={mainSearch}/> + <NormalGroup config={item}/> </Col> ) } else if (item.type === 'editor') { return ( <Col span={item.width} style={style} key={item.uuid}> - <BraftEditor config={item} data={data} mainSearch={mainSearch}/> + <BraftEditor config={item}/> </Col> ) } else if (item.type === 'tree') { return ( <Col span={item.width} style={style} key={item.uuid}> - <NormalTree config={item} data={data} mainSearch={mainSearch}/> + <NormalTree config={item}/> + </Col> + ) + } else if (item.type === 'calendar') { + return ( + <Col span={item.width} style={style} key={item.uuid}> + <Calendar config={item}/> </Col> ) } else if (item.type === 'code') { return ( <Col span={item.width} style={style} key={item.uuid}> - <SandBox config={item} data={data} mainSearch={mainSearch}/> + <SandBox config={item}/> </Col> ) } else if (item.type === 'chart') { return ( <Col span={item.width} style={style} key={item.uuid}> - <CustomChart config={item} data={data} mainSearch={mainSearch}/> + <CustomChart config={item}/> </Col> ) } else if (item.type === 'antvG6') { return ( <Col span={item.width} style={style} key={item.uuid}> - <AntvG6 config={item} data={data} mainSearch={mainSearch}/> + <AntvG6 config={item}/> </Col> ) } else if (item.type === 'antvX6') { @@ -1452,7 +1656,7 @@ } else if (item.type === 'iframe') { return ( <Col span={item.width} style={style} key={item.uuid}> - <Iframe config={item} data={data} mainSearch={mainSearch}/> + <Iframe config={item}/> </Col> ) } else { @@ -1464,15 +1668,29 @@ render() { const { loadingview, viewlost, config, loading, shortcuts, BID } = this.state + if (!config || viewlost) { + return ( + <div className="custom-page-wrap"> + {loadingview ? <Spin className="view-spin" size="large" /> : null} + {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} + <div className="user-tools"> + {config && config.process === 'true' ? <FlowFloat init={true} config={config}/> : null} + </div> + </div> + ) + } + return ( - <div className={`custom-page-wrap ${config && config.minWidth ? 'mk-scroll' : ''} ${loadingview || loading ? 'loading' : ''}`} id={this.state.ContainerId} style={config ? config.style : null}> - {(loadingview || (loading && !config.$cache)) ? <Spin className="view-spin" size="large" /> : null} - <Row id={config ? 'menu' + config.uuid : ''} style={config && config.minWidth ? {minWidth: config.minWidth} : null} className="component-wrap">{this.getComponents()}</Row> - {config && config.interfaces.length > 0 ? <MkInterfaces BID={BID} interfaces={config.interfaces}/> : null} - {config && window.GLOB.breakpoint ? <DebugTable /> : null} - {!window.GLOB.mkHS && window.GLOB.systemType !== 'production' ? <TableNodes config={config} /> : null} - {!window.GLOB.mkHS && config ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts || []}/> : null} - {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} + <div className={`custom-page-wrap ${config.minWidth ? 'mk-scroll' : ''} ${loading ? 'loading' : ''} ${config.mask === 'false' ? 'mk-no-mask' : ''}`} id={this.state.ContainerId} style={config.style}> + {loading && !config.$cache ? <Spin className="view-spin" size="large" /> : null} + <Row id={'menu' + config.uuid} style={{minWidth: config.minWidth || 'unset'}} className="component-wrap">{this.getComponents()}</Row> + {config.interfaces.length > 0 ? <MkInterfaces BID={BID} interfaces={config.interfaces}/> : null} + {window.GLOB.breakpoint ? <DebugTable /> : null} + <div className="user-tools"> + {config.process === 'true' ? <FlowFloat config={config}/> : null} + <SettingComponent config={config} shortcuts={shortcuts || []}/> + <TableNodes config={config} /> + </div> </div> ) } -- Gitblit v1.8.0