From dc258e4600bea2fba1e25054d163a2f4b1326a85 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 08 八月 2023 10:23:38 +0800 Subject: [PATCH] 2023-08-08 --- src/tabviews/custom/index.jsx | 899 ++++++++++++++++++++++++++++++++++------------------------- 1 files changed, 518 insertions(+), 381 deletions(-) diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index 01ff70b..4d233b0 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -1,11 +1,9 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { notification, Spin, Row, Col } from 'antd' +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' @@ -40,9 +38,11 @@ const CustomChart = asyncComponent(() => import('./components/chart/custom-chart')) const TimeLine = asyncComponent(() => import('./components/timeline/normal-timeline')) const AntvG6 = asyncComponent(() => import('./components/chart/antv-G6')) +const AntvX6 = asyncComponent(() => import('./components/chart/antv-X6')) 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 TableNodes = asyncComponent(() => import('@/tabviews/zshare/tablenodes')) const MkInterfaces = asyncComponent(() => import('@/tabviews/custom/components/interfaces')) @@ -52,37 +52,37 @@ param: PropTypes.any, // 鍏朵粬椤甸潰浼犻�掔殑鍙傛暟 Tab: PropTypes.string, // 寮圭獥鏍囩 MenuID: PropTypes.string, // 鑿滃崟Id - MenuNo: PropTypes.string, // 鑿滃崟鍙傛暟 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 // 蹇嵎閿� + shortcuts: null, // 蹇嵎閿� + loadinginter: false } + + stepInter = null /** * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { MenuID } = this.props + const { MenuID, MenuName } = this.props let _param = { func: 'sPC_Get_LongParam', MenuID: MenuID } + let result = await Api.getCacheConfig(_param) if (result.status) { @@ -93,6 +93,8 @@ config = window.decodeURIComponent(window.atob(result.LongParam)) config = config.replace(/@mywebsite@\//ig, window.GLOB.baseurl) config = JSON.parse(config) + config.MenuID = MenuID + config.MenuName = MenuName || config.MenuName } catch (e) { console.warn('Parse Failure') config = '' @@ -112,7 +114,7 @@ this.setState({ viewlost: true, loadingview: false, - lostmsg: this.state.dict['main.view.unenabled'] + lostmsg: '鎶辨瓑锛屾偍璁块棶鐨勯〉闈㈡湭鍚敤锛岃鑱旂郴绠$悊鍛樸��' }) return } @@ -149,7 +151,7 @@ // 鏁版嵁缂撳瓨璁剧疆 if (config.cacheUseful === 'true') { - if (!['day', 'hour'].includes(config.timeUnit)) { + if (!['day', 'hour', 'minute'].includes(config.timeUnit)) { config.timeUnit = 'day' } config.cacheTime = config.cacheTime || 1 @@ -165,11 +167,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}'` }, @@ -199,26 +196,12 @@ } config.$cache = config.cacheLocal === 'true' + config.$time = config.localCacheTime || 0 - config.interfaces = this.formatInterSetting(config.interfaces, regs) - config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces, popview, config.$cache) - - // 鑾峰彇涓绘悳绱㈡潯浠� - let mainSearch = [] - config.components.forEach(component => { - if (component.type !== 'search') return + let initInters = [] - 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.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.$time, config.MenuName, MenuID, MenuID) let params = [] let BID = param.$BID || '' @@ -230,17 +213,48 @@ 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 (param.$searchkey) { + component.search = component.search.map(item => { + if (['text', 'select', 'link'].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.keys()].length > 0) { config.components = this.filterBalcony(config.components, balMap) } + if (initInters.length > 0) { + this.stepInter = { + MenuID: MenuID, + inters: initInters, + params: params + } + } + this.setState({ BID: BID, + loadinginter: this.stepInter !== null, shortcuts: shortcuts.length > 0 ? shortcuts : null, - config, - mainSearch + config }, () => { if (config.normalcss) { let node = document.getElementById(config.uuid) @@ -251,7 +265,10 @@ ele.innerHTML = config.normalcss document.getElementsByTagName('head')[0].appendChild(ele) } - if (params.length === 0) { + + if (this.stepInter) { + + } else if (params.length === 0) { setTimeout(() => { // 寤舵椂鍔犺浇鐘舵�� this.setState({ loadingview: false @@ -318,10 +335,13 @@ } } - filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache) => { + filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, time, MenuName, searchId, syncId) => { return components.filter(item => { item.$pageId = pageId item.$cache = cache + item.$time = time + item.$searchId = searchId + item.$syncId = syncId if (item.style && item.style.boxShadow) { delete item.style.hShadow @@ -330,7 +350,7 @@ delete item.style.shadowColor } - item.$menuname = (this.props.MenuName || '') + '-' + (item.name || '') + item.$menuname = (MenuName || '') + '-' + (item.name || '') if (item.type === 'tabs') { if ( @@ -338,6 +358,13 @@ item.setting.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0 ) { 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 => { @@ -349,35 +376,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) + }) } } @@ -404,8 +433,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) + 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, popview, cache, time, MenuName, _searchId, tab.uuid) + + 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 }) @@ -418,10 +466,10 @@ return false } - item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache) + item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache, time, MenuName, searchId, syncId) return true - } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart'].includes(item.type)) { + } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart', 'antvG6', 'antvX6'].includes(item.type)) { if ( item.plot.blacklist && item.plot.blacklist.length > 0 && item.plot.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0 @@ -451,8 +499,44 @@ } // 鎼滅储鏉′欢鍒濆鍖� - 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') { // 鏁版嵁鍗″涓婄骇缁勪欢 + item.setting.supModule = item.supNodes[0].componentId + } else if (item.setting && item.setting.supModule && typeof(item.setting.supModule) !== 'string') { + let pid = item.setting.supModule.pop() + if (pid && pid !== 'empty') { + item.setting.supModule = pid + } else { + item.setting.supModule = '' + } + } + + let pass = skip + + if (item.wrap && item.wrap.permission === 'false') { + pass = true + } + + // 鏉冮檺杩囨护 + if (item.action && item.action.length > 0) { + item.action = item.action.filter(cell => { + if (cell.hidden === 'true') return false + + cell = this.resetButton(item, cell, popview) + + cell.$toolbtn = true + + if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� + cell = this.getPrinter(cell, item.uuid) + } + + return pass || permAction[cell.uuid] + }) } if (item.type === 'table') { @@ -463,6 +547,8 @@ return false } else if (col.Hide === 'true') { return false + } else if (col.type === 'action') { + col.type = 'custom' } if (col.type === 'number') { @@ -475,26 +561,36 @@ col.decimal = col.decimal > 2 ? col.decimal - 2 : 0 } } + } else if (col.type === 'formula') { + if (typeof(col.decimal) === 'number') { + col.round = Math.pow(10, col.decimal) + } } else if (col.type === 'colspan') { col.subcols = getCols(col.subcols || []) if (col.subcols.length === 0) { return false } } else if (col.type === 'custom') { - col.elements = col.elements.map(cell => { - if (['text', 'number', 'formula'].includes(cell.eleType)) { - if (!cell.height) { - cell.innerHeight = 'auto' + col.elements = col.elements.filter(cell => { + if (cell.eleType === 'button') { + if (cell.hidden === 'true') return false + + cell = this.resetButton(item, cell, popview) + + if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� + cell = this.getPrinter(cell, item.uuid) } - if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') { - cell.round = Math.pow(10, cell.decimal) - if (cell.format === 'percent') { - cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0 - } - } + + return pass || permAction[cell.uuid] + } else { + cell = this.resetElement(cell) } - return cell + return true }) + + if (col.elements.length === 0) { + return false + } } if (col.linkmenu && col.linkmenu.length > 0) { @@ -510,63 +606,20 @@ item.cols = getCols(item.cols) item.statFields = statFields - } - let mutil = false - if (item.wrap && item.wrap.supType === 'multi') { // 鏁版嵁鍗″涓婄骇缁勪欢 - mutil = true - item.setting.supModule = item.supNodes[0].componentId - } else if (item.setting && item.setting.supModule && typeof(item.setting.supModule) !== 'string') { - let pid = item.setting.supModule.pop() - if (pid && pid !== 'empty') { - item.setting.supModule = pid - } else { - item.setting.supModule = '' + if (item.subtype === 'editable') { + item.submit.logLabel = item.$menuname + '-鎻愪氦' + item.submit.$menuId = item.uuid + item.submit.syncComponentId = item.submit.syncComponent ? (item.submit.syncComponent.pop() || '') : '' + + if (item.submit.syncComponentId && item.submit.syncComponentId === item.setting.supModule) { + item.submit.syncComponentId = '' + if (item.submit.execSuccess === 'grid') { + item.submit.execSuccess = 'mainline' + } + } } - } - - // 鏉冮檺杩囨护 - if (item.action && item.action.length > 0) { - item.action = item.action.filter(cell => { - if (cell.hidden === 'true') return false - - cell.logLabel = item.$menuname + '-' + cell.label - 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.$toolbtn = true - - if (!mutil && cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' - } - } - - if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� - cell = this.getPrinter(cell, item.uuid) - } - - if (cell.btnstyle) { // 鍏煎 - cell.style = cell.style || {} - cell.style = {...cell.style, ...cell.btnstyle} - } - - if (cell.controlField) { - if (/,/ig.test(cell.controlVal)) { - cell.controlVals = cell.controlVal.split(',') - } else { - cell.controlVals = [(cell.controlVal || '')] - } - } - - return skip || permAction[cell.uuid] - }) - } - - if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') { + } else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') { item.subcards && item.subcards.forEach(card => { if (card.style.boxShadow) { delete card.style.hShadow @@ -579,45 +632,41 @@ if (cell.eleType === 'button') { if (cell.hidden === 'true') return false - 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 - - if (!mutil && cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' - } - } + cell = this.resetButton(item, cell, popview) if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) } - if (cell.controlField) { - if (/,/ig.test(cell.controlVal)) { - cell.controlVals = cell.controlVal.split(',') - } else { - cell.controlVals = [(cell.controlVal || '')] - } - } - } else if (['text', 'number', 'formula'].includes(cell.eleType)) { - if (!cell.height) { - cell.innerHeight = 'auto' - } - if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') { - cell.round = Math.pow(10, cell.decimal) - if (cell.format === 'percent') { - cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0 - } - } + } else { + cell = this.resetElement(cell) } - return cell.eleType !== 'button' || skip || permAction[cell.uuid] + return cell.eleType !== 'button' || pass || permAction[cell.uuid] }) + + if (card.setting.click === 'menus') { + if (card.menus) { + card.menus = card.menus.filter(m => !!m.MenuID) + if (card.menus.length === 0) { + card.menus = null + } + } + if (!card.menus || item.subtype !== 'datacard' || card.$cardType === 'extendCard') { + card.setting.click = '' + } + } else if (card.setting.click === 'menu') { + if (!Array.isArray(card.setting.menu)) { + card.setting.click = '' + } + } + + if (item.subtype === 'dualdatacard' && card.$cardType !== 'extendCard') { + if (card.backSetting && card.backSetting.click === 'menu') { + if (!Array.isArray(card.backSetting.menu)) { + card.backSetting.click = '' + } + } + } if (!card.backElements || card.backElements.length === 0) return @@ -625,44 +674,16 @@ if (cell.eleType === 'button') { if (cell.hidden === 'true') return false - 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 - - if (!mutil && cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' - } - } + cell = this.resetButton(item, cell, popview) if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) } - if (cell.controlField) { - if (/,/ig.test(cell.controlVal)) { - cell.controlVals = cell.controlVal.split(',') - } else { - cell.controlVals = [(cell.controlVal || '')] - } - } - } else if (['text', 'number', 'formula'].includes(cell.eleType)) { - if (!cell.height) { - cell.innerHeight = 'auto' - } - if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') { - cell.round = Math.pow(10, cell.decimal) - if (cell.format === 'percent') { - cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0 - } - } + } else { + cell = this.resetElement(cell) } - return cell.eleType !== 'button' || skip || permAction[cell.uuid] + return cell.eleType !== 'button' || pass || permAction[cell.uuid] }) }) } else if (item.type === 'balcony') { @@ -677,91 +698,17 @@ if (cell.eleType === 'button') { if (cell.hidden === 'true') return false - cell.logLabel = item.$menuname + '-' + cell.label - cell.ContainerId = this.state.ContainerId - cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' - cell.$menuId = item.uuid - cell.$MenuID = this.props.MenuID - cell.$view = popview - - if (cell.syncComponentId === item.wrap.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' - } - } + cell = this.resetButton(item, cell, popview) if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) } - if (cell.controlField) { - if (/,/ig.test(cell.controlVal)) { - cell.controlVals = cell.controlVal.split(',') - } else { - cell.controlVals = [(cell.controlVal || '')] - } - } - } else if (['text', 'number', 'formula'].includes(cell.eleType)) { - if (!cell.height) { - cell.innerHeight = 'auto' - } - if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') { - cell.round = Math.pow(10, cell.decimal) - if (cell.format === 'percent') { - cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0 - } - } + } else { + cell = this.resetElement(cell) } - return cell.eleType !== 'button' || skip || permAction[cell.uuid] + return cell.eleType !== 'button' || pass || permAction[cell.uuid] }) - } else if (item.type === 'table') { - item.cols = item.cols.filter(col => { - if (col.type !== 'action') return true - col.elements = col.elements.filter(cell => { - if (cell.hidden === 'true') return false - - 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 - - if (cell.syncComponentId === item.setting.supModule) { - cell.syncComponentId = '' - if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { - cell.execSuccess = 'mainline' - } - } - - if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� - cell = this.getPrinter(cell, item.uuid) - } - - if (cell.btnstyle) { // 鍏煎 - cell.style = cell.style || {} - cell.style = {...cell.style, ...cell.btnstyle} - } - - if (cell.controlField) { - if (/,/ig.test(cell.controlVal)) { - cell.controlVals = cell.controlVal.split(',') - } else { - cell.controlVals = [(cell.controlVal || '')] - } - } - - return skip || permAction[cell.uuid] - }) - return col.elements.length !== 0 - }) - - if (item.subtype === 'editable') { - item.submit.logLabel = item.$menuname + '-鎻愪氦' - item.submit.$menuId = item.uuid - } } else if (item.type === 'form') { item.subcards = item.subcards.map(group => { group.subButton.uuid = group.uuid @@ -776,9 +723,9 @@ group.subButton.Ot = item.wrap.datatype === 'static' ? 'notRequired' : 'requiredSgl' } - group.subButton.syncComponentId = group.subButton.syncComponent ? group.subButton.syncComponent.pop() : '' + group.subButton.syncComponentId = group.subButton.syncComponent ? (group.subButton.syncComponent.pop() || '') : '' - if (group.subButton.syncComponentId === item.setting.supModule) { + if (group.subButton.syncComponentId && group.subButton.syncComponentId === item.setting.supModule) { group.subButton.syncComponentId = '' if (group.subButton.execSuccess === 'grid') { group.subButton.execSuccess = 'mainline' @@ -805,6 +752,12 @@ return group }) + } else if (item.subtype === 'voucher') { + if (item.wrap.supModule && item.wrap.supModule.length > 0) { + item.wrap.supModule = item.wrap.supModule.pop() + } else { + item.wrap.supModule = '' + } } return true @@ -849,6 +802,94 @@ }) } + resetButton = (item, cell, popview) => { + 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 + + if (cell.btnstyle) { // 鍏煎 + cell.style = cell.style || {} + cell.style = {...cell.style, ...cell.btnstyle} + } + + if (cell.controlField) { + if (/,/ig.test(cell.controlVal)) { + cell.controlVals = cell.controlVal.split(',') + } else { + cell.controlVals = [(cell.controlVal || '')] + } + } + + if (cell.syncComponentId) { + if (cell.syncComponentId === item.setting.supModule) { + cell.syncComponentId = '' + if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { + cell.execSuccess = 'mainline' + } + } else if (cell.syncComponentId === 'multiComponent') { + let ids = cell.syncComponents.map(m => { + return m.syncComId.pop() || '' + }) + + if (item.setting.supModule && ids.includes(item.setting.supModule)) { + if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') { + cell.execSuccess = 'mainline' + } + ids = ids.filter(id => id !== item.setting.supModule) + } + + if (ids.length === 0) { + cell.syncComponentId = '' + } else { + cell.syncComponentIds = ids + } + } + } + + return cell + } + + resetElement = (cell) => { + cell.style = cell.style || {} + if (['text', 'number', 'formula'].includes(cell.eleType)) { + if (!cell.height) { + cell.innerHeight = 'auto' + } + + cell.innerHeight = cell.innerHeight || 'auto' + cell.alignItems = cell.height > 1 ? cell.alignItems : '' + + if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') { + cell.round = Math.pow(10, cell.decimal) + if (cell.format === 'percent') { + cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0 + } + } else if (cell.eleType === 'formula' && typeof(cell.decimal) === 'number') { + cell.round = Math.pow(10, cell.decimal) + } + } else if (cell.eleType === 'icon') { + if (!cell.innerHeight) { // 鍏煎 + let fontSize = 14 + let lineHeight = 1.5 + + if (cell.style.fontSize) { + fontSize = parseInt(cell.style.fontSize) + } + if (cell.style.lineHeight) { + lineHeight = parseFloat(cell.style.lineHeight) + } + + cell.innerHeight = fontSize * lineHeight + } + } + + return cell + } + getPrinter = (item, parentId) => { let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid) @@ -868,28 +909,29 @@ } // 鏍煎紡鍖栭粯璁よ缃� - 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 + component.setting.sync = '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) { @@ -897,6 +939,13 @@ } component.setting.useMSearch = component.setting.useMSearch === 'true' + 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' @@ -929,10 +978,8 @@ } 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\'') } else { component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') @@ -945,35 +992,43 @@ component.setting.customScript = _customScript // 鏁寸悊鍚庤嚜瀹氫箟鑴氭湰 + if (component.setting.laypage) { + component.setting.custompage = /@pageSize@/i.test(component.setting.dataresource + component.setting.customScript) + } + + 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 @@ -989,13 +1044,24 @@ } // 鏍煎紡鍖栭粯璁よ缃� - formatInterSetting = (inters, regs) => { + formatInterSetting = (inters, regs, MenuID, initInters) => { if (!inters) return [] - let interfaces = inters.filter(m => m.status === 'true') + let initlimit = false + let interfaces = inters.filter(m => { + if (m.status !== 'true') return false + + if (m.setting.loadlevel === 'init') { + initlimit = true + initInters.push(m.uuid) + } + + return true + }) let delay = 15 return interfaces.map(inter => { + inter.MenuID = MenuID inter.setting.delay = delay delay += 15 @@ -1006,6 +1072,10 @@ } else { inter.setting.supModule = '' } + } + + if (initlimit && inter.setting.loadlevel !== 'init') { + inter.setting.onload = 'false' } if (inter.setting.interType !== 'system') return inter @@ -1032,10 +1102,8 @@ } 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\'') } else { inter.setting.dataresource = inter.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') @@ -1061,37 +1129,66 @@ this.setState({loading: true, loadingview: false}) - Api.genericInterface(param).then(result => { - if (result.status) { - 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) + if (config.$cache && config.$time) { + Api.getLCacheConfig(params[0].uuid, config.$time).then(res => { + if (!res.valid) { + this.getMainData(param, params, config.MenuID) + } else { + this.setState({ + loading: false }) } + }) + } else { + this.getMainData(param, params, config.MenuID) + } + } - this.setState({ - data: result, - loading: false + getMainData = (param, params, MenuID) => { + Api.genericInterface(param).then(result => { + this.setState({ + loading: false + }) + + if (result.status) { + if (result.message) { + if (result.ErrCode === 'Y') { + Modal.success({ + title: result.message + }) + } else if (result.ErrCode === 'S') { + notification.success({ + top: 92, + message: result.message, + duration: 2 + }) + } + } + + 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 - }) - notification.error({ - top: 92, - message: result.message, - duration: 10 - }) + MKEmitter.emit('transferSyncData', MenuID) + + if (!result.message) return + if (result.ErrCode === 'N') { + Modal.error({ + title: result.message, + }) + } else if (result.ErrCode !== '-2') { + notification.error({ + top: 92, + message: result.message, + duration: 10 + }) + } } }) } @@ -1122,6 +1219,7 @@ } componentDidMount () { + MKEmitter.addListener('interFinish', this.interFinish) MKEmitter.addListener('debugChange', this.debugChange) MKEmitter.addListener('reloadMenuView', this.reloadMenuView) MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu) @@ -1134,6 +1232,7 @@ this.setState = () => { return } + MKEmitter.removeListener('interFinish', this.interFinish) MKEmitter.removeListener('debugChange', this.debugChange) MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) @@ -1144,6 +1243,30 @@ this.state.config.interfaces.forEach(m => { window.GLOB.CacheData.delete(m.uuid) }) + } + } + + interFinish = (MenuID, interId) => { + if (!this.stepInter || this.stepInter.MenuID !== MenuID) return + + this.stepInter.inters = this.stepInter.inters.filter(item => item !== interId) + + if (this.stepInter.inters.length === 0) { + this.setState({loadinginter: false}) + + if (this.stepInter.params.length === 0) { + setTimeout(() => { // 寤舵椂鍔犺浇鐘舵�� + this.setState({ + loadingview: false + }) + }, 1000) + } else { + this.loadmaindata(this.stepInter.params) + } + + MKEmitter.emit('initFinish', this.stepInter.MenuID) + + this.stepInter = null } } @@ -1159,8 +1282,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) } }) } @@ -1175,185 +1303,194 @@ }) } + this.stepInter = null + this.setState({ BID: '', // 椤甸潰璺宠浆鏃舵惡甯D loadingview: true, // 椤甸潰鍔犺浇涓� 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 } = this.state + const { config, BID, loadinginter } = this.state - if (!config || !config.components) return + if (!config || !config.components || loadinginter) return return config.components.map(item => { let style = null 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') { + return ( + <Col span={item.width} style={style} key={item.uuid}> + <AntvX6 config={item}/> </Col> ) } else if (item.type === 'module' && item.subtype === 'voucher') { @@ -1371,7 +1508,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 { @@ -1384,13 +1521,13 @@ const { loadingview, viewlost, config, loading, shortcuts, BID } = this.state return ( - <div className={`custom-page-wrap ${config && config.minWidth ? 'mk-scroll' : ''} ${loadingview || loading ? 'loading' : ''}`} id={this.state.ContainerId} style={config ? config.style : null}> + <div className={`custom-page-wrap ${config && config.minWidth ? 'mk-scroll' : ''} ${loadingview || loading ? 'loading' : ''} ${config && config.mask === 'false' ? 'mk-no-mask' : ''}`} 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} + {!window.GLOB.mkHS && config ? <SettingComponent config={config} shortcuts={shortcuts || []}/> : null} {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> ) -- Gitblit v1.8.0