From b8e1395f02c929eaa96b949cf6027ee2a43856a6 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 06 九月 2022 19:03:37 +0800 Subject: [PATCH] 2022-09-06 --- src/tabviews/custom/index.jsx | 783 +++++++++++++++++++++++++++++++++++++------------------ 1 files changed, 523 insertions(+), 260 deletions(-) diff --git a/src/tabviews/custom/index.jsx b/src/tabviews/custom/index.jsx index e2180a4..abe3ac2 100644 --- a/src/tabviews/custom/index.jsx +++ b/src/tabviews/custom/index.jsx @@ -3,15 +3,13 @@ import { connect } from 'react-redux' import { is, fromJS } from 'immutable' import { notification, Spin, Row, Col } from 'antd' -import moment from 'moment' -import md5 from 'md5' import Api from '@/api' import options from '@/store/options.js' 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 UtilsDM, { getStructuredParams, getStructDefaultParam } from '@/utils/utils-datamanage.js' import asyncComponent from '@/utils/asyncComponent' import MKEmitter from '@/utils/events.js' import NotFount from '@/components/404' @@ -25,18 +23,25 @@ const AntvScatter = asyncComponent(() => import('./components/chart/antv-scatter')) const DataCard = asyncComponent(() => import('./components/card/data-card')) const PropCard = asyncComponent(() => import('./components/card/prop-card')) -const NormalForm = asyncComponent(() => import('./components/form/normal-form')) +const SimpleForm = asyncComponent(() => import('./components/form/simple-form')) +const StepForm = asyncComponent(() => import('./components/form/step-form')) +const TabForm = asyncComponent(() => import('./components/form/tab-form')) const CarouselDataCard = asyncComponent(() => import('./components/carousel/data-card')) const CarouselPropCard = asyncComponent(() => import('./components/carousel/prop-card')) const TableCard = asyncComponent(() => import('./components/card/table-card')) const MainSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch')) const NormalTable = asyncComponent(() => import('./components/table/normal-table')) +const EditTable = asyncComponent(() => import('./components/table/edit-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 NormalTree = asyncComponent(() => import('./components/tree/antd-tree')) +const Balcony = asyncComponent(() => import('./components/card/balcony')) const SettingComponent = asyncComponent(() => import('@/tabviews/zshare/settingcomponent')) const PagemsgComponent = asyncComponent(() => import('@/tabviews/zshare/pageMessage')) +const CustomChart = asyncComponent(() => import('./components/chart/custom-chart')) +const TimeLine = asyncComponent(() => import('./components/timeline/normal-timeline')) +const Voucher = asyncComponent(() => import('./components/module/voucher')) class CustomPage extends Component { static propTpyes = { @@ -68,11 +73,11 @@ * @description 鑾峰彇椤甸潰閰嶇疆淇℃伅 */ async loadconfig () { - const { permAction, permMenus, param } = this.props + const { permAction, MenuID } = this.props let _param = { func: 'sPC_Get_LongParam', - MenuID: this.props.MenuID + MenuID: MenuID } let result = await Api.getCacheConfig(_param) @@ -88,7 +93,7 @@ } // HS涓嶄娇鐢ㄨ嚜瀹氫箟璁剧疆 - if (result.LongParamUser && this.props.menuType !== 'HS') { + if (result.LongParamUser && !window.GLOB.mkHS) { try { // 閰嶇疆淇℃伅瑙f瀽 let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) if (userConfig) { @@ -131,7 +136,13 @@ // 鏉冮檺杩囨护 let roleId = sessionStorage.getItem('role_id') || '' // 瑙掕壊ID - config.components = this.filterComponent(config.components, roleId, permAction, permMenus) + let balMap = new Map() + let skip = config.permission === 'false' || window.GLOB.mkHS + let param = this.props.param || {} // url鍙傛暟 + + window.GLOB.CacheData.set(MenuID, param) + + config.components = this.filterComponent(config.components, roleId, permAction, balMap, skip, param, MenuID) // 鑾峰彇涓绘悳绱㈡潯浠� let mainSearch = [] @@ -140,7 +151,7 @@ component.search = component.search.map(item => { item.oriInitval = item.initval - if (['text', 'select', 'link'].includes(item.type) && param && param.$searchkey === item.field) { + if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) { item.initval = param.$searchval } @@ -151,7 +162,7 @@ }) let params = [] - let BID = param && param.$BID ? param.$BID : '' + let BID = param.$BID || '' let inherit = {} if (config.cacheUseful === 'true') { // 缂撳瓨缁ф壙 @@ -162,7 +173,6 @@ let userName = sessionStorage.getItem('User_Name') || '' let fullName = sessionStorage.getItem('Full_Name') || '' - let city = sessionStorage.getItem('city') || '' if (sessionStorage.getItem('isEditState') === 'true') { userName = sessionStorage.getItem('CloudUserName') || '' @@ -171,8 +181,7 @@ let regs = [ { reg: /@userName@/ig, value: `'${userName}'` }, - { reg: /@fullName@/ig, value: `'${fullName}'` }, - { reg: /@login_city@/ig, value: `'${city}'` } + { reg: /@fullName@/ig, value: `'${fullName}'` } ] if (window.GLOB.externalDatabase !== null) { @@ -183,7 +192,7 @@ } if (config.urlFields) { config.urlFields.forEach(field => { - let val = `'${param ? (param[field] || '') : ''}'` + let val = `'${param[field] || ''}'` regs.push({ reg: new RegExp('@' + field + '@', 'ig'), value: val @@ -191,7 +200,11 @@ }) } - config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs) + config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs, balMap) + + if ([...balMap.keys()].length > 0) { + config.components = this.filterBalcony(config.components, balMap) + } this.setState({ BID: BID, @@ -282,6 +295,8 @@ return } + item.MenuName = config.MenuName || '' + inters.push(item) }) @@ -292,7 +307,7 @@ loadOutResource = (inters) => { let setting = inters.shift() - let param = UtilsDM.getPrevQueryParams(setting, [], this.state.BID, this.props.menuType) + let param = UtilsDM.getPrevQueryParams(setting, [], this.state.BID) Api.genericInterface(param).then(res => { if (res.status) { @@ -393,15 +408,7 @@ `)) 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) - } + param = UtilsDM.getCallBackQueryParams(setting, sql, errSql, this.state.BID) } else { param.func = 's_ex_result_back' param.s_ex_result = lines.map((item, index) => ({ @@ -412,7 +419,7 @@ Sort: index + 1 })) - if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { + if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { let sql = lines.map(item => (` ${item.insert} ${item.selects.join(` union all @@ -438,8 +445,19 @@ }) } - filterComponent = (components, roleId, permAction, permMenus) => { + filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId) => { return components.filter(item => { + item.$pageId = pageId + + if (item.style && item.style.boxShadow) { + delete item.style.hShadow + delete item.style.vShadow + delete item.style.shadowBlur + delete item.style.shadowColor + } + + item.$menuname = (this.props.MenuName || '') + '-' + (item.name || '') + if (item.type === 'tabs') { if ( item.setting.blacklist && item.setting.blacklist.length > 0 && @@ -454,26 +472,70 @@ tab.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0 ) { return false + } else if (tab.hide === 'true') { + return false } return true }) + if (item.setting.supModule) { + let pid = item.setting.supModule.pop() + item.setting.supModule = pid || '' + + 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.selectField) { + item.setting.selectField = item.setting.selectField.toLowerCase() + + let val = '' + Object.keys(urlparam).forEach(key => { + if (key.toLowerCase() === item.setting.selectField) { + val = urlparam[key] + } + }) + + let activeKey = '' + + item.subtabs.forEach(tab => { + if (!activeKey && tab.selectVal === val) { + activeKey = tab.uuid + } + }) + + item.activeKey = activeKey + } + item.subtabs = item.subtabs.map(tab => { - tab.components = this.filterComponent(tab.components, roleId, permAction, permMenus) + tab.$pageId = pageId + + tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId) return tab }) - let supIds = [] - item.subtabs.forEach(tab => { - tab.components.forEach(comp => { - if (comp.type === 'tabs' && comp.parentIds) { - supIds.push(...comp.parentIds) - } else if (comp.setting && comp.setting.supModule) { - supIds.push(comp.setting.supModule) - } - }) - }) - item.parentIds = supIds + return true } else if (item.type === 'group') { if ( item.setting.blacklist && item.setting.blacklist.length > 0 && @@ -482,8 +544,10 @@ return false } - item.components = this.filterComponent(item.components, roleId, permAction, permMenus) - } else if (['pie', 'bar', 'line', 'dashboard', 'scatter'].includes(item.type)) { + item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId) + + return true + } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart'].includes(item.type)) { if ( item.plot.blacklist && item.plot.blacklist.length > 0 && item.plot.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0 @@ -504,17 +568,29 @@ item.search = Utils.initSearchVal(item.search) } - if (item.type === 'table' && item.subtype === 'normaltable') { + if (item.type === 'table' && (item.subtype === 'normaltable' || item.subtype === 'editable')) { let statFields = [] let getCols = (cols) => { return cols.filter(col => { - if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { - return false - } else if (col.Hide === 'true') { - return false + if (item.subtype !== 'editable') { + if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { + return false + } else if (col.Hide === 'true') { + return false + } + } else if (col.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { + col.Hide = 'true' } - if (col.type === 'number' && col.sum === 'true' && !statFields.includes(col.field)) { - statFields.push(col) + 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') { + col.decimal = col.decimal > 2 ? col.decimal - 2 : 0 + } + } } else if (col.type === 'colspan') { col.subcols = getCols(col.subcols || []) if (col.subcols.length === 0) { @@ -522,8 +598,28 @@ } } else if (col.type === 'custom') { col.elements = col.elements.map(cell => { - if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height) { - cell.innerHeight = 'auto' + 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 if (cell.eleType === 'icon') { + 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 }) @@ -531,7 +627,7 @@ if (col.linkmenu && col.linkmenu.length > 0) { let menu_id = col.linkmenu.pop() - col.linkThdMenu = permMenus.filter(m => m.MenuID === menu_id)[0] || '' + col.linkThdMenu = this.props.permMenus.filter(m => m.MenuID === menu_id)[0] || '' } else { col.linkThdMenu = '' } @@ -544,17 +640,37 @@ 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) { + let pid = item.setting.supModule.pop() + if (pid && pid !== 'empty') { + item.setting.supModule = pid + } else { + item.setting.supModule = '' + } + } + // 鏉冮檺杩囨护 - let isHS = this.props.menuType === 'HS' let tabId = this.props.Tab ? this.props.Tab.uuid : '' // 寮圭獥鏍囩鎸夐挳Id if (item.action && item.action.length > 0) { item.action = item.action.filter(cell => { - cell.logLabel = item.name + '-' + cell.label + if (item.hidden === 'true') return false + + cell.logLabel = item.$menuname + '-' + cell.label cell.ContainerId = this.state.ContainerId - cell.syncComponentId = cell.syncComponent ? cell.syncComponent.pop() : '' + cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' cell.$menuId = item.uuid + cell.$MenuID = this.props.MenuID cell.$tabId = tabId cell.$view = 'CustomPage' + cell.$toolbtn = true + + if (!mutil && cell.syncComponentId === item.setting.supModule) { + cell.syncComponentId = '' + } if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) @@ -565,28 +681,35 @@ cell.style = {...cell.style, ...cell.btnstyle} } - return isHS || permAction[cell.uuid] + return skip || permAction[cell.uuid] }) } if (item.type === 'card') { item.subcards && item.subcards.forEach(card => { - let _hasheight = card.style.height && card.style.height !== 'auto' - - if (card.style.shadow) { // 鍗$墖闃村奖 - card.style.boxShadow = '0 0 4px ' + card.style.shadow - delete card.style.shadow + if (card.style.boxShadow) { + delete card.style.hShadow + delete card.style.vShadow + delete card.style.shadowBlur + delete card.style.shadowColor } card.elements = card.elements.filter(cell => { if (cell.eleType === 'button') { - cell.logLabel = item.name + '-' + cell.label - cell.Ot = 'requiredSgl' + 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.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' cell.$menuId = item.uuid + cell.$MenuID = this.props.MenuID cell.$tabId = tabId cell.$view = 'CustomPage' + + if (!mutil && cell.syncComponentId === item.setting.supModule) { + cell.syncComponentId = '' + } if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) @@ -595,21 +718,48 @@ card.style = card.style || {} card.style = {...card.style, ...card.btnstyle} } - } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) { - cell.innerHeight = 'auto' + } 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 if (cell.eleType === 'icon') { + 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.eleType !== 'button' || isHS || permAction[cell.uuid] + return cell.eleType !== 'button' || skip || permAction[cell.uuid] }) card.backElements = card.backElements.filter(cell => { if (cell.eleType === 'button') { - cell.logLabel = item.name + '-' + cell.label - cell.Ot = 'requiredSgl' + 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.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' cell.$menuId = item.uuid + cell.$MenuID = this.props.MenuID cell.$tabId = tabId cell.$view = 'CustomPage' + + if (!mutil && cell.syncComponentId === item.setting.supModule) { + cell.syncComponentId = '' + } if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) @@ -618,50 +768,156 @@ card.style = card.style || {} card.style = {...card.style, ...card.btnstyle} } - } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) { - cell.innerHeight = 'auto' + } 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 if (cell.eleType === 'icon') { + 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.eleType !== 'button' || isHS || permAction[cell.uuid] + + return cell.eleType !== 'button' || skip || permAction[cell.uuid] }) }) - } else if ((item.type === 'table' && item.subtype === 'tablecard') || item.type === 'carousel') { + } else if (item.type === 'balcony') { + if (item.wrap.linkType === 'sync') { + item.wrap.syncModuleId = item.wrap.syncModule.pop() + balMap.set(item.wrap.syncModuleId, true) + } else if (item.wrap.linkType === 'sup') { + item.wrap.supModule = item.wrap.supModule.pop() + item.setting.supModule = item.wrap.supModule + } + item.elements = item.elements.filter(cell => { + 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.$tabId = tabId + cell.$view = 'CustomPage' + + if (cell.syncComponentId === item.wrap.supModule) { + cell.syncComponentId = '' + } + + if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� + cell = this.getPrinter(cell, item.uuid) + } + } 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 if (cell.eleType === 'icon') { + 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.eleType !== 'button' || skip || permAction[cell.uuid] + }) + } else if ((item.type === 'table' && item.subtype === 'tablecard') || item.type === 'carousel' || item.type === 'timeline') { item.subcards && item.subcards.forEach(card => { - let _hasheight = card.style.height && card.style.height !== 'auto' card.elements = card.elements.filter(cell => { if (cell.eleType === 'button') { - cell.logLabel = item.name + '-' + cell.label - cell.Ot = 'requiredSgl' + 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.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' cell.$menuId = item.uuid + cell.$MenuID = this.props.MenuID cell.$tabId = tabId cell.$view = 'CustomPage' + + if (cell.syncComponentId === item.setting.supModule) { + cell.syncComponentId = '' + } if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) } - if (card.btnstyle) { // 鍏煎 card.style = card.style || {} card.style = {...card.style, ...card.btnstyle} } - } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height && _hasheight) { - cell.innerHeight = 'auto' + } 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 if (cell.eleType === 'icon') { + 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.eleType !== 'button' || isHS || permAction[cell.uuid] + return cell.eleType !== 'button' || skip || permAction[cell.uuid] }) }) - } else if (item.type === 'table' && item.subtype === 'normaltable') { + } else if (item.type === 'table' && (item.subtype === 'normaltable' || item.subtype === 'editable')) { item.cols = item.cols.filter(col => { if (col.type !== 'action') return true col.elements = col.elements.filter(cell => { - cell.logLabel = item.name + '-' + cell.label - cell.Ot = 'requiredSgl' + 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.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : '' cell.$menuId = item.uuid + cell.$MenuID = this.props.MenuID cell.$tabId = tabId cell.$view = 'CustomPage' + + if (cell.syncComponentId === item.setting.supModule) { + cell.syncComponentId = '' + } if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 鎵撳嵃鏈鸿缃� cell = this.getPrinter(cell, item.uuid) @@ -672,24 +928,92 @@ cell.style = {...cell.style, ...cell.btnstyle} } - return isHS || permAction[cell.uuid] + return skip || permAction[cell.uuid] }) return col.elements.length !== 0 }) - } - if (item.setting && item.setting.supModule) { - 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 } + } else if (item.type === 'form') { + item.subcards = item.subcards.map(group => { + group.subButton.uuid = group.uuid + group.subButton.$menuId = group.uuid + // 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() : '' + + if (group.subButton.syncComponentId === item.setting.supModule) { + group.subButton.syncComponentId = '' + } + + group.fields = group.fields.map(cell => { + // 鏁版嵁婧恠ql璇彞锛岄澶勭悊锛屾潈闄愰粦鍚嶅崟瀛楁璁剧疆涓洪殣钘忚〃鍗� + if (['select', 'link', 'multiselect', 'radio', 'checkbox', 'checkcard'].includes(cell.type) && cell.resourceType === '1') { + let _option = Utils.getSelectQueryOptions(cell) + + cell.data_sql = Utils.formatOptions(_option.sql) + cell.base_sql = window.btoa(window.encodeURIComponent(_option.sql)) + cell.arr_field = _option.field + } + + // 瀛楁鏉冮檺榛戝悕鍗� + if (!cell.blacklist || !roleId || cell.blacklist.length === 0) return cell + if (cell.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { + cell.hidden = 'true' + } + + return cell + }) + + return group + }) } - if (item.wrap && item.wrap.doubleClick) { - let index = item.action.findIndex((btn) => btn.uuid === item.wrap.doubleClick) - if (index === -1) { - item.wrap.doubleClick = '' + + return true + }) + } + + filterBalcony = (components, balMap) => { + return components.filter(item => { + if (item.type === 'tabs') { + item.subtabs = item.subtabs.map(tab => { + tab.components = this.filterBalcony(tab.components, balMap) + return tab + }) + } else if (item.type === 'group') { + item.components = this.filterBalcony(item.components, balMap) + } + + if (item.type === 'balcony' && item.wrap.linkType === 'sync') { + let conf = balMap.get(item.wrap.syncModuleId) + + if (!conf || conf === true) { + return false + } + + item.syncConfig = { + uuid: conf.uuid, + wrap: conf.wrap, + setting: conf.setting, + columns: conf.columns + } + + if (item.wrap.checkAll === 'show') { + if (conf.subtype === 'datacard' && conf.wrap.cardType !== 'checkbox') { + item.wrap.checkAll = 'hidden' + } else if (conf.subtype === 'normaltable' && conf.wrap.tableType !== 'checkbox') { + item.wrap.checkAll = 'hidden' + } } } @@ -716,17 +1040,18 @@ } // 鏍煎紡鍖栭粯璁よ缃� - formatSetting = (components, params, mainSearch, inherit, regs) => { + formatSetting = (components, params, mainSearch, 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, [], [], inherit, regs) + tab.components = this.formatSetting(tab.components, null, null, inherit, regs, balMap) tab = {...tab, ...inherit} return tab }) return component } else if (component.type === 'group') { - component.components = this.formatSetting(component.components, [], [], inherit, regs) + component.components = this.formatSetting(component.components, null, null, inherit, regs, balMap) component = {...component, ...inherit} return component } @@ -759,7 +1084,7 @@ } }) delete component.scripts - component.setting.$name = component.name || '' + component.setting.$name = component.$menuname || '' component.setting.execute = component.setting.execute !== 'false' // 榛樿sql鏄惁鎵ц锛岃浆涓篵oolean 缁熶竴鏍煎紡 component.setting.laypage = component.setting.laypage === 'true' // 鏄惁鍒嗛〉锛岃浆涓篵oolean 缁熶竴鏍煎紡 @@ -771,13 +1096,13 @@ } if (sessionStorage.getItem('dataM') === 'true') { // 鏁版嵁鏉冮檺 - component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*') + component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@datam@/ig, 'Y') component.setting.dataresource = component.setting.dataresource.replace(/@\$/ig, '*/') - _customScript = _customScript.replace(/\$@/ig, '/*') + _customScript = _customScript.replace(/\$@/ig, '/*').replace(/@datam@/ig, 'Y') _customScript = _customScript.replace(/@\$/ig, '*/') } else { - component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '') - _customScript = _customScript.replace(/@\$|\$@/ig, '') + component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '') + _customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '') } regs.forEach(cell => { @@ -790,7 +1115,7 @@ // floor 缁勪欢鐨勫眰绾� // dataName 绯荤粺鐢熸垚鐨勬暟鎹簮鍚嶇О // pageable 鏄惁鍒嗛〉锛岀粍浠跺睘鎬э紝涓嶅垎椤电殑缁勪欢鎵嶅彲浠ョ粺涓�鏌ヨ - if (component.floor === 1 && component.dataName && (!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true' && component.setting.sync === 'true') { + if (params && component.dataName && (!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) @@ -808,10 +1133,17 @@ component.setting.sync = 'false' component.setting.onload = 'false' } else { - params.push(this.getDefaultParam(component, searchlist)) + params.push(getStructDefaultParam(component, searchlist, params.length === 0)) } - } else if (component.floor === 1) { + } else if (params) { component.setting.sync = 'false' + component.setting.delay = delay + delay += 20 + } + + if (balMap.has(component.uuid)) { + component.setting.$hasSyncModule = true + balMap.set(component.uuid, component) } return component @@ -819,135 +1151,14 @@ } /** - * @description 鑾峰彇绯荤粺瀛樺偍杩囩▼ sPC_Get_TableData 鐨勫弬鏁� - */ - getDefaultParam = (component, searchlist) => { - const { columns, setting, dataName, format } = component - - let arr_field = columns.map(col => col.field) - let _dataresource = setting.dataresource - let _customScript = setting.customScript - - - if (setting.queryType === 'statistics' || _customScript) { - let allSearch = Utils.getAllSearchOptions(searchlist) - let regoptions = allSearch.map(item => { - return { - reg: new RegExp('@' + item.key + '@', 'ig'), - value: `'${item.value}'` - } - }) - - regoptions.forEach(item => { - if (_dataresource && setting.queryType === 'statistics') { - _dataresource = _dataresource.replace(item.reg, item.value) - } - _customScript = _customScript.replace(item.reg, item.value) - }) - } - - _dataresource = _dataresource.replace(/@select\$|\$select@/ig, '') - _customScript = _customScript.replace(/@select\$|\$select@/ig, '') - _dataresource = _dataresource.replace(/\$sum@/ig, '/*') - _dataresource = _dataresource.replace(/@sum\$/ig, '*/') - _customScript = _customScript.replace(/\$sum@/ig, '/*') - _customScript = _customScript.replace(/@sum\$/ig, '*/') - - let _search = '' - if (setting.queryType !== 'statistics' && _dataresource) { - _search = Utils.joinMainSearchkey(searchlist) - _search = _search ? 'where ' + _search : '' - } - - if (setting.order && _dataresource) { - _dataresource = `select top 1000 ${arr_field.join(',')} from (select ${arr_field.join(',')} ,ROW_NUMBER() over(order by ${setting.order}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows ` - } else if (_dataresource) { - _dataresource = `select top 1000 ${arr_field.join(',')} from ${_dataresource} ${_search} ` - } - - // 娴嬭瘯绯荤粺鎵撳嵃鏌ヨ璇彞 - if ((options.sysType === 'local' && !window.GLOB.systemType) || window.debugger === true) { - _customScript && console.info(`${setting.$name ? `/*缁勪欢-${setting.$name} 鑷畾涔夎剼鏈�*/\n` : ''}${_dataresource ? '' : '/*涓嶆墽琛岄粯璁ql*/\n'}${_customScript}`) - _dataresource && console.info(`${setting.$name ? `/*缁勪欢-${setting.$name} 鏁版嵁婧�*/\n` : ''}` + _dataresource) - } - - return { - name: dataName, - columns: columns, - par_tablename: '', - type: format === 'array' ? format : '', - primaryKey: setting.primaryKey || '', - foreign_key: '', - sql: _dataresource, - script: _customScript - } - } - - /** * @description 涓昏〃鏁版嵁鍔犺浇 */ loadmaindata = (params) => { - const { config } = this.state - let LText_field = [] - let diffUser = false - let userName = sessionStorage.getItem('User_Name') || '' - let fullName = sessionStorage.getItem('Full_Name') || '' - let city = sessionStorage.getItem('city') || '' - - if (sessionStorage.getItem('isEditState') === 'true') { - userName = sessionStorage.getItem('CloudUserName') || '' - fullName = sessionStorage.getItem('CloudFullName') || '' - } - - let _LText = params.map((item, index) => { - let _script = item.script - - if (index === 0) { - _script = `declare @ErrorCode nvarchar(50),@retmsg nvarchar(4000),@UserName nvarchar(50),@FullName nvarchar(50),@login_city nvarchar(50) - select @ErrorCode='',@retmsg ='',@UserName='${userName}', @FullName='${fullName}', @login_city='${city}' - ${_script} - ` - } - if (!diffUser && (/@userid@/ig.test(item.sql) || /@userid@/ig.test(_script))) { - diffUser = true - } - - item.columns.forEach(cell => { - LText_field.push(`Select '${item.name}' as tablename,'${cell.field}' as fieldname,'${cell.datatype}' as field_type`) - }) - return `Select '${item.name}' as tablename,'${window.btoa(window.encodeURIComponent(item.sql))}' as LText,'${window.btoa(window.encodeURIComponent(_script))}' as Lcustomize,'${item.type}' as table_type,'${item.primaryKey}' as primary_key,'${item.par_tablename}' as par_tablename,'${item.foreign_key}' as foreign_key,'${index}' as Sort` - }) - - // 鎶婂ぇ鎺ュ彛sPC_Get_structured_data鐨刲text鎷嗘垚涓変唤锛岀涓�娈碉細@LText1锛岀浜屾@LText锛岀涓夋@LText2 - let param = { - func: 'sPC_Get_structured_data', - LText: _LText.join(' union all '), - LText_field: LText_field.join(' union all '), - BID: this.state.BID || '' - } - - let { LText, LText1, LText2 } = Utils.sPCInUpDeFormatOptions(param.LText) - - param.LText1 = LText1 - param.LText = LText - param.LText2 = LText2 - param.LText_field = Utils.formatOptions(param.LText_field) - - if (config.cacheUseful === 'true') { - param.time_type = config.timeUnit - param.time_limit = config.cacheTime - if (diffUser) { - param.userid = sessionStorage.getItem('UserID') - } - param.data_md5 = md5(JSON.stringify(param)) - } - - param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') - param.secretkey = Utils.encrypt(param.LText, param.timestamp) + let param = getStructuredParams(params, this.state.config, this.state.BID || '') this.setState({loading: true, loadingview: false}) - Api.getLocalConfig(param).then(result => { + Api.genericInterface(param).then(result => { if (result.status) { delete result.status delete result.message @@ -1011,6 +1222,23 @@ } MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) + + window.GLOB.CacheData.delete(this.props.MenuID) + this.deleteCache(this.state.config.components) + } + + deleteCache = (components) => { + components.forEach(item => { + if (item.type === 'tabs') { + item.subtabs.forEach(tab => { + this.deleteCache(tab.components) + }) + } else if (item.type === 'group') { + this.deleteCache(item.components) + } else { + window.GLOB.CacheData.delete(item.uuid) + } + }) } reloadview = () => { @@ -1020,7 +1248,8 @@ viewlost: false, // 椤甸潰涓㈠け锛�1銆佹湭鑾峰彇鍒伴厤缃�-椤甸潰涓㈠け锛�2銆侀〉闈㈡湭鍚敤 config: null, // 椤甸潰閰嶇疆淇℃伅锛屽寘鎷粍浠剁瓑 loading: false, // 鍒楄〃鏁版嵁鍔犺浇涓� - shortcuts: null + shortcuts: null, + data: '' }, () => { this.loadconfig() }) @@ -1033,51 +1262,57 @@ } getComponents = () => { - const { menuType } = this.props const { config, BID, data, mainSearch } = this.state if (!config || !config.components) return return config.components.map(item => { - let _bid = BID - if (item.setting && item.setting.supModule) { - _bid = '' - } - if (item.type === 'bar' || item.type === 'line') { return ( <Col span={item.width} key={item.uuid}> - <AntvBarAndLine config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} /> + <AntvBarAndLine config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'pie') { return ( <Col span={item.width} key={item.uuid}> - <AntvPie config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} /> + <AntvPie config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'scatter') { return ( <Col span={item.width} key={item.uuid}> - <AntvScatter config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} /> + <AntvScatter config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'dashboard') { return ( <Col span={item.width} key={item.uuid}> - <AntvDashboard config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} /> + <AntvDashboard config={item} data={data} mainSearch={mainSearch}/> </Col> ) - } else if (item.type === 'form') { + } else if (item.type === 'form' && item.subtype === 'simpleform') { return ( <Col span={item.width} key={item.uuid}> - <NormalForm config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} /> + <SimpleForm config={item} data={data} mainSearch={mainSearch}/> + </Col> + ) + } else if (item.type === 'form' && item.subtype === 'stepform') { + return ( + <Col span={item.width} key={item.uuid}> + <StepForm config={item} data={data} mainSearch={mainSearch}/> + </Col> + ) + } else if (item.type === 'form' && item.subtype === 'tabform') { + return ( + <Col span={item.width} key={item.uuid}> + <TabForm config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'search') { return ( <Col span={item.width} key={item.uuid}> - <MainSearch config={item} BID={BID} menuType={menuType} refreshdata={this.resetSearch} /> + <MainSearch config={item} BID={BID} refreshdata={this.resetSearch} /> </Col> ) } else if (item.type === 'tabs') { @@ -1089,61 +1324,91 @@ } else if (item.type === 'card' && item.subtype === 'datacard') { return ( <Col span={item.width} key={item.uuid}> - <DataCard config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} /> + <DataCard config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'card' && item.subtype === 'propcard') { return ( <Col span={item.width} key={item.uuid}> - <PropCard config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} /> + <PropCard config={item} data={data} mainSearch={mainSearch}/> + </Col> + ) + } else if (item.type === 'balcony') { + return ( + <Col span={item.width} key={item.uuid}> + <Balcony config={item} data={data}/> + </Col> + ) + } else if (item.type === 'timeline') { + return ( + <Col span={item.width} key={item.uuid}> + <TimeLine config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'carousel' && item.subtype === 'datacard') { return ( <Col span={item.width} key={item.uuid}> - <CarouselDataCard config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} /> + <CarouselDataCard config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'carousel' && item.subtype === 'propcard') { return ( <Col span={item.width} key={item.uuid}> - <CarouselPropCard config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} /> + <CarouselPropCard config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'table' && item.subtype === 'tablecard') { return ( <Col span={item.width} key={item.uuid}> - <TableCard config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} /> + <TableCard config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'table' && item.subtype === 'normaltable') { return ( <Col span={item.width} key={item.uuid}> - <NormalTable config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} /> + <NormalTable config={item} data={data} mainSearch={mainSearch}/> + </Col> + ) + } else if (item.type === 'table' && item.subtype === 'editable') { + return ( + <Col span={item.width} key={item.uuid}> + <EditTable config={item} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'group' && item.subtype === 'normalgroup') { return ( <Col span={item.width} key={item.uuid}> - <NormalGroup config={item} BID={_bid} mainSearch={mainSearch} menuType={menuType} /> + <NormalGroup config={item} mainSearch={mainSearch}/> </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} /> + <BraftEditor config={item} data={data} mainSearch={mainSearch}/> </Col> ) } else if (item.type === 'tree') { return ( <Col span={item.width} key={item.uuid}> - <NormalTree config={item} data={data} BID={_bid} mainSearch={mainSearch} menuType={menuType} /> + <NormalTree config={item} data={data} mainSearch={mainSearch}/> </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} /> + <SandBox config={item} data={data} mainSearch={mainSearch}/> + </Col> + ) + } else if (item.type === 'chart') { + return ( + <Col span={item.width} key={item.uuid}> + <CustomChart config={item} data={data} mainSearch={mainSearch}/> + </Col> + ) + } else if (item.type === 'module' && item.subtype === 'voucher') { + return ( + <Col span={item.width} key={item.uuid}> + <Voucher config={item}/> </Col> ) } else { @@ -1153,15 +1418,14 @@ } render() { - const { menuType } = this.props const { loadingview, viewlost, config, loading, shortcuts } = this.state return ( <div className={'custom-page-wrap ' + (loadingview || loading ? 'loading' : '')} id={this.state.ContainerId} style={config ? config.style : null}> {(loadingview || loading) ? <Spin className="view-spin" size="large" /> : null} - <Row>{this.getComponents()}</Row> - {menuType !== 'HS' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null} - {menuType !== 'HS' && shortcuts ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts} permAction={this.props.permAction}/> : null} + <Row className="component-wrap">{this.getComponents()}</Row> + {!window.GLOB.mkHS && window.GLOB.systemType !== 'production' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null} + {!window.GLOB.mkHS && shortcuts ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts} permAction={this.props.permAction}/> : null} {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} </div> ) @@ -1170,7 +1434,6 @@ const mapStateToProps = (state) => { return { - menuType: state.editLevel, refreshTab: state.refreshTab, permAction: state.permAction, permMenus: state.permMenus -- Gitblit v1.8.0