| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import { connect } from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import { notification, Spin, Row, Col } from 'antd' |
| | | |
| | | 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, { getStructuredParams, getStructDefaultParam } from '@/utils/utils-datamanage.js' |
| | | import { getStructuredParams, getStructDefaultParam } from '@/utils/utils-datamanage.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import NotFount from '@/components/404' |
| | |
| | | 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 DoubleDataCard = asyncComponent(() => import('./components/card/double-data-card')) |
| | | 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 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 AntvG6 = asyncComponent(() => import('./components/chart/antv-G6')) |
| | | const Voucher = asyncComponent(() => import('./components/module/voucher')) |
| | | const Account = asyncComponent(() => import('./components/module/account')) |
| | | const Iframe = asyncComponent(() => import('./components/iframe')) |
| | | const DebugTable = asyncComponent(() => import('@/tabviews/debugtable')) |
| | | const TableNodes = asyncComponent(() => import('@/tabviews/zshare/tablenodes')) |
| | | const MkInterfaces = asyncComponent(() => import('@/tabviews/custom/components/interfaces')) |
| | | |
| | | class CustomPage extends Component { |
| | | static propTpyes = { |
| | |
| | | Tab: PropTypes.string, // 弹窗标签 |
| | | MenuID: PropTypes.string, // 菜单Id |
| | | MenuNo: PropTypes.string, // 菜单参数 |
| | | MenuName: PropTypes.string // 菜单名称 |
| | | MenuName: PropTypes.string, // 菜单名称 |
| | | changeTemp: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | |
| | | data: null, // 列表数据集 |
| | | loading: false, // 列表数据加载中 |
| | | visible: false, // 标签页控制 |
| | | treevisible: false, // 菜单结构树弹框显示隐藏控制 |
| | | shortcuts: null // 快捷键 |
| | | shortcuts: null, // 快捷键 |
| | | loadinginter: false |
| | | } |
| | | |
| | | stepInter = null |
| | | |
| | | /** |
| | | * @description 获取页面配置信息 |
| | | */ |
| | | async loadconfig () { |
| | | const { permAction, param } = this.props |
| | | const { MenuID } = this.props |
| | | |
| | | let _param = { |
| | | func: 'sPC_Get_LongParam', |
| | | MenuID: this.props.MenuID |
| | | MenuID: MenuID |
| | | } |
| | | let result = await Api.getCacheConfig(_param) |
| | | |
| | |
| | | let shortcuts = [] |
| | | |
| | | try { // 配置信息解析 |
| | | config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) |
| | | config = window.decodeURIComponent(window.atob(result.LongParam)) |
| | | config = config.replace(/@mywebsite@\//ig, window.GLOB.baseurl) |
| | | config = JSON.parse(config) |
| | | config.MenuID = MenuID |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | config = '' |
| | | } |
| | | |
| | | // HS不使用自定义设置 |
| | | if (result.LongParamUser && !window.GLOB.mkHS) { |
| | | try { // 配置信息解析 |
| | | let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) |
| | | if (userConfig) { |
| | | shortcuts = userConfig.action |
| | | userConfig.printers.forEach(item => { |
| | | window.GLOB.UserCacheMap.set(item.parentId + item.uuid, item) |
| | | }) |
| | | } |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | } |
| | | } |
| | | |
| | | // 页面配置解析错误时提示 |
| | |
| | | return |
| | | } |
| | | |
| | | // 模板错误 |
| | | if (config.Template !== 'CustomPage') { |
| | | if (config.Template === 'BaseTable' || config.Template === 'CommonTable') { |
| | | this.props.changeTemp(MenuID, config.Template) |
| | | } else { |
| | | this.setState({ |
| | | viewlost: true, |
| | | loadingview: false, |
| | | lostmsg: '菜单信息错误,可能原因:1、当前用户无权限;2、打开此菜单的按钮需要更新。' |
| | | }) |
| | | } |
| | | |
| | | return |
| | | } |
| | | |
| | | // HS不使用自定义设置 |
| | | if (result.LongParamUser && !window.GLOB.mkHS) { |
| | | try { // 配置信息解析 |
| | | let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) |
| | | if (userConfig) { |
| | | shortcuts = userConfig.action |
| | | userConfig.printers.forEach(item => { |
| | | window.GLOB.UserCacheMap.set(item.parentId + item.uuid, item) |
| | | }) |
| | | } |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | } |
| | | } |
| | | |
| | | // 数据缓存设置 |
| | | if (config.cacheUseful === 'true') { |
| | | if (!['day', 'hour'].includes(config.timeUnit)) { |
| | |
| | | let roleId = sessionStorage.getItem('role_id') || '' // 角色ID |
| | | let balMap = new Map() |
| | | let skip = config.permission === 'false' || window.GLOB.mkHS |
| | | config.components = this.filterComponent(config.components, roleId, permAction, balMap, skip) |
| | | |
| | | // 获取主搜索条件 |
| | | let mainSearch = [] |
| | | config.components.forEach(component => { |
| | | if (component.type !== 'search') return |
| | | let param = this.props.param || {} // url参数 |
| | | |
| | | component.search = component.search.map(item => { |
| | | item.oriInitval = item.initval |
| | | if (['text', 'select', 'link'].includes(item.type) && param && param.$searchkey === item.field) { |
| | | item.initval = param.$searchval |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | mainSearch = Utils.initMainSearch(component.search) |
| | | }) |
| | | |
| | | let params = [] |
| | | let BID = param && param.$BID ? param.$BID : '' |
| | | let inherit = {} |
| | | |
| | | if (config.cacheUseful === 'true') { // 缓存继承 |
| | | inherit.cacheUseful = config.cacheUseful |
| | | inherit.timeUnit = config.timeUnit |
| | | inherit.cacheTime = config.cacheTime |
| | | } |
| | | window.GLOB.CacheData.set(MenuID, param) |
| | | |
| | | let userName = sessionStorage.getItem('User_Name') || '' |
| | | let fullName = sessionStorage.getItem('Full_Name') || '' |
| | |
| | | } |
| | | 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 |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | let popview = 'CustomPage' |
| | | |
| | | if (config.version === 2.0) { |
| | | popview = 'popview' |
| | | } |
| | | |
| | | config.$cache = config.cacheLocal === 'true' |
| | | |
| | | 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) |
| | | |
| | | // 获取主搜索条件 |
| | | 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) |
| | | }) |
| | | |
| | | let params = [] |
| | | let BID = param.$BID || '' |
| | | let inherit = {} |
| | | |
| | | if (config.cacheUseful === 'true') { // 缓存继承 |
| | | inherit.cacheUseful = config.cacheUseful |
| | | inherit.timeUnit = config.timeUnit |
| | | inherit.cacheTime = config.cacheTime |
| | | } |
| | | |
| | | config.components = this.formatSetting(config.components, params, mainSearch, inherit, regs, balMap) |
| | |
| | | config.components = this.filterBalcony(config.components, balMap) |
| | | } |
| | | |
| | | if (initInters.length > 0) { |
| | | this.stepInter = { |
| | | MenuID: MenuID, |
| | | inters: initInters, |
| | | params: params |
| | | } |
| | | } |
| | | |
| | | this.setState({ |
| | | BID: BID, |
| | | shortcuts, |
| | | loadinginter: this.stepInter !== null, |
| | | shortcuts: shortcuts.length > 0 ? shortcuts : null, |
| | | config, |
| | | mainSearch |
| | | }, () => { |
| | | if (!params || params.length === 0) { |
| | | if (config.normalcss) { |
| | | let node = document.getElementById(config.uuid) |
| | | node && node.remove() |
| | | |
| | | let ele = document.createElement('style') |
| | | ele.id = config.uuid |
| | | ele.innerHTML = config.normalcss |
| | | document.getElementsByTagName('head')[0].appendChild(ele) |
| | | } |
| | | |
| | | if (this.stepInter) { |
| | | |
| | | } else if (params.length === 0) { |
| | | setTimeout(() => { // 延时加载状态 |
| | | this.setState({ |
| | | loadingview: false |
| | |
| | | if (!this.props.Tab) { |
| | | this.setShortcut() |
| | | } |
| | | |
| | | this.loadData() |
| | | }) |
| | | } else { |
| | | this.setState({ |
| | |
| | | setShortcut = () => { |
| | | const { shortcuts } = this.state |
| | | |
| | | if (!shortcuts || shortcuts.length === 0) { |
| | | document.onkeydown = () => {} |
| | | return |
| | | } |
| | | |
| | | document.onkeydown = (event) => { |
| | | let e = event || window.event |
| | | let keyCode = e.keyCode || e.which || e.charCode |
| | |
| | | } |
| | | |
| | | if (!preKey || !keyCode) return |
| | | |
| | | |
| | | let _shortcut = `${preKey}+${keyCode}` |
| | | |
| | | if (window.GLOB.breakpoint && _shortcut === 'ctrl+67') { |
| | | window.debugger = false |
| | | window.GLOB.breakpoint = false |
| | | sessionStorage.removeItem('breakpoint') |
| | | |
| | | MKEmitter.emit('debugChange') |
| | | } |
| | | |
| | | if (!shortcuts) return |
| | | |
| | | shortcuts.some(item => { |
| | | if (item.$shortcut === _shortcut) { |
| | |
| | | } |
| | | } |
| | | |
| | | loadData = () => { |
| | | const { config } = this.state |
| | | |
| | | if (!config.interfaces || config.interfaces.length === 0) return |
| | | |
| | | let inters = [] |
| | | |
| | | config.interfaces.forEach(item => { |
| | | if (item.status !== 'true') return |
| | | |
| | | if (window.GLOB.systemType === 'production' && !item.proInterface) { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: `《${item.name}》未设置正式系统地址!`, |
| | | duration: 3 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | item.MenuName = config.MenuName || '' |
| | | |
| | | inters.push(item) |
| | | }) |
| | | |
| | | if (inters.length > 0) { |
| | | this.loadOutResource(inters) |
| | | } |
| | | } |
| | | |
| | | loadOutResource = (inters) => { |
| | | let setting = inters.shift() |
| | | let param = UtilsDM.getPrevQueryParams(setting, [], this.state.BID) |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | if (res.mk_ex_invoke === 'false' || res.mk_ex_invoke === false) { |
| | | if (inters.length > 0) { |
| | | this.loadOutResource(inters) |
| | | } |
| | | } else { |
| | | this.customOuterRequest(res, setting, inters) |
| | | } |
| | | } else { |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | customOuterRequest = (result, setting, inters) => { |
| | | let url = '' |
| | | |
| | | if (window.GLOB.systemType === 'production') { |
| | | url = setting.proInterface |
| | | } else { |
| | | url = setting.interface |
| | | } |
| | | |
| | | let mkey = result.mk_api_key || '' |
| | | |
| | | delete result.mk_ex_invoke |
| | | delete result.status |
| | | delete result.message |
| | | delete result.ErrCode |
| | | delete result.ErrMesg |
| | | delete result.mk_api_key |
| | | |
| | | let param = {} |
| | | |
| | | Object.keys(result).forEach(key => { |
| | | key = key.replace(/^mk_/ig, '') |
| | | param[key] = result[key] |
| | | }) |
| | | |
| | | Api.directRequest(url, setting.method, param, setting.cross).then(res => { |
| | | if (typeof(res) !== 'object') { |
| | | let error = '未知的返回结果!' |
| | | |
| | | if (typeof(res) === 'string') { |
| | | error = res.replace(/'/ig, '"') |
| | | } |
| | | |
| | | let _result = { |
| | | mk_api_key: mkey, |
| | | $ErrCode: 'E', |
| | | $ErrMesg: error |
| | | } |
| | | |
| | | this.customCallbackRequest(_result, setting, inters) |
| | | } else { |
| | | if (Array.isArray(res)) { |
| | | res = { data: res } |
| | | } |
| | | res.mk_api_key = mkey |
| | | this.customCallbackRequest(res, setting, inters) |
| | | } |
| | | }, (e) => { |
| | | let _result = { |
| | | mk_api_key: mkey, |
| | | $ErrCode: 'E', |
| | | $ErrMesg: e && e.statusText ? e.statusText : '' |
| | | } |
| | | |
| | | this.customCallbackRequest(_result, setting, inters) |
| | | }) |
| | | } |
| | | |
| | | customCallbackRequest = (result, setting, inters) => { |
| | | let errSql = '' |
| | | if (result.$ErrCode === 'E') { |
| | | errSql = ` |
| | | set @ErrorCode='E' |
| | | set @retmsg='${result.$ErrMesg}' |
| | | ` |
| | | delete result.$ErrCode |
| | | delete result.$ErrMesg |
| | | } |
| | | |
| | | let lines = UtilsDM.getCallBackSql(setting, result) |
| | | let param = {} |
| | | |
| | | if (setting.callbackType === 'script') { // 使用自定义脚本 |
| | | let sql = lines.map(item => (` |
| | | ${item.insert} |
| | | ${item.selects.join(` union all |
| | | `)} |
| | | `)) |
| | | sql = sql.join('') |
| | | |
| | | param = UtilsDM.getCallBackQueryParams(setting, sql, errSql, this.state.BID) |
| | | } else { |
| | | param.func = 's_ex_result_back' |
| | | param.s_ex_result = lines.map((item, index) => ({ |
| | | MenuID: this.props.MenuID || '', |
| | | MenuName: this.props.MenuName || '', |
| | | TableName: item.table, |
| | | LongText: window.btoa(window.encodeURIComponent(`${item.insert} ${item.selects.join(` union all `)}`)), |
| | | Sort: index + 1 |
| | | })) |
| | | |
| | | if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) { |
| | | let sql = lines.map(item => (` |
| | | ${item.insert} |
| | | ${item.selects.join(` union all |
| | | `)} |
| | | `)) |
| | | sql = sql.join('') |
| | | console.info(sql.replace(/\n\s{10}/ig, '\n')) |
| | | } |
| | | } |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | if (inters.length > 0) { |
| | | this.loadOutResource(inters) |
| | | } |
| | | } else { |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | }) |
| | | } |
| | | |
| | | filterComponent = (components, roleId, permAction, balMap, skip) => { |
| | | filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache) => { |
| | | return components.filter(item => { |
| | | item.$pageId = pageId |
| | | item.$cache = cache |
| | | |
| | | if (item.style && item.style.boxShadow) { |
| | | delete item.style.hShadow |
| | |
| | | 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, balMap, skip) |
| | | tab.$pageId = pageId |
| | | |
| | | tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache) |
| | | 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 && |
| | |
| | | return false |
| | | } |
| | | |
| | | item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip) |
| | | item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, popview, cache) |
| | | |
| | | return true |
| | | } else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart'].includes(item.type)) { |
| | | if ( |
| | | item.plot.blacklist && item.plot.blacklist.length > 0 && |
| | |
| | | ) { |
| | | return false |
| | | } |
| | | |
| | | if (item.wrap.datatype === 'public') { |
| | | let inter = interfaces.filter(int => item.wrap.publicId === int.uuid)[0] |
| | | if (!inter) { |
| | | item.wrap.datatype = 'static' |
| | | } else { |
| | | item.setting = inter.setting |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (item.subtype === 'tablecard') { // 兼容 |
| | | item.type = 'card' |
| | | } |
| | | |
| | | // 搜索条件初始化 |
| | |
| | | item.search = Utils.initSearchVal(item.search) |
| | | } |
| | | |
| | | if (item.type === 'table' && (item.subtype === 'normaltable' || item.subtype === 'editable')) { |
| | | if (item.type === 'table') { |
| | | let statFields = [] |
| | | let getCols = (cols) => { |
| | | return cols.filter(col => { |
| | | 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.blacklist && col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) { |
| | | return false |
| | | } else if (col.Hide === 'true') { |
| | | return false |
| | | } |
| | | 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) { |
| | |
| | | } |
| | | } else if (col.type === 'custom') { |
| | | col.elements = col.elements.map(cell => { |
| | | if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height) { |
| | | cell.innerHeight = 'auto' |
| | | } 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 |
| | | } |
| | | cell = this.resetElement(cell) |
| | | return cell |
| | | }) |
| | | } |
| | | |
| | | if (col.linkmenu && col.linkmenu.length > 0) { |
| | | let menu_id = col.linkmenu.pop() |
| | | col.linkThdMenu = this.props.permMenus.filter(m => m.MenuID === menu_id)[0] || '' |
| | | col.linkThdMenu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menu_id)[0] || '' |
| | | } else { |
| | | col.linkThdMenu = '' |
| | | } |
| | |
| | | if (item.wrap && item.wrap.supType === 'multi') { // 数据卡多上级组件 |
| | | mutil = true |
| | | item.setting.supModule = item.supNodes[0].componentId |
| | | } else if (item.setting && item.setting.supModule) { |
| | | } 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 |
| | |
| | | } |
| | | |
| | | // 权限过滤 |
| | | let tabId = this.props.Tab ? this.props.Tab.uuid : '' // 弹窗标签按钮Id |
| | | if (item.action && item.action.length > 0) { |
| | | item.action = item.action.filter(cell => { |
| | | if (item.hidden === 'true') return false |
| | | 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' |
| | | cell = this.resetButton(item, cell, 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} |
| | | } |
| | | |
| | | return skip || permAction[cell.uuid] |
| | | }) |
| | | } |
| | | |
| | | if (item.type === 'card') { |
| | | if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') { |
| | | item.subcards && item.subcards.forEach(card => { |
| | | let _hasheight = card.style.height && card.style.height !== 'auto' |
| | | |
| | | if (card.style.boxShadow) { |
| | | delete card.style.hShadow |
| | | delete card.style.vShadow |
| | |
| | | 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.$tabId = tabId |
| | | cell.$view = 'CustomPage' |
| | | cell = this.resetButton(item, cell, popview) |
| | | |
| | | 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 (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 (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 |
| | | } else { |
| | | cell = this.resetElement(cell) |
| | | } |
| | | |
| | | return cell.eleType !== 'button' || skip || permAction[cell.uuid] |
| | | }) |
| | | |
| | | if (!card.backElements || card.backElements.length === 0) return |
| | | |
| | | card.backElements = card.backElements.filter(cell => { |
| | | 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.$tabId = tabId |
| | | cell.$view = 'CustomPage' |
| | | cell = this.resetButton(item, cell, popview) |
| | | |
| | | 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 (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 (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 |
| | | } else { |
| | | cell = this.resetElement(cell) |
| | | } |
| | | |
| | | |
| | | return cell.eleType !== 'button' || skip || permAction[cell.uuid] |
| | | }) |
| | | }) |
| | |
| | | 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' |
| | | cell = this.resetButton(item, cell, popview) |
| | | |
| | | if (cell.syncComponentId === item.wrap.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) |
| | | } |
| | | } else if (['text', 'number', 'link'].includes(cell.eleType) && !cell.height) { |
| | | cell.innerHeight = 'auto' |
| | | } 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 |
| | | } else { |
| | | cell = this.resetElement(cell) |
| | | } |
| | | |
| | | 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') { |
| | | 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.$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 (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 === 'normaltable' || item.subtype === 'editable')) { |
| | | } 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.$tabId = tabId |
| | | cell.$view = 'CustomPage' |
| | | |
| | | cell = this.resetButton(item, cell, 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} |
| | | } |
| | | |
| | | return skip || permAction[cell.uuid] |
| | |
| | | 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 // 不声明数据源变量 |
| | | 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' |
| | |
| | | |
| | | if (group.subButton.syncComponentId === item.setting.supModule) { |
| | | group.subButton.syncComponentId = '' |
| | | if (group.subButton.execSuccess === 'grid') { |
| | | group.subButton.execSuccess = 'mainline' |
| | | } |
| | | } |
| | | |
| | | group.fields = group.fields.map(cell => { |
| | | // 数据源sql语句,预处理,权限黑名单字段设置为隐藏表单 |
| | | 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.base_sql = _option.sql |
| | | cell.arr_field = _option.field |
| | | } |
| | | |
| | |
| | | |
| | | 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 |
| | |
| | | }) |
| | | } |
| | | |
| | | 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 || '')] |
| | | } |
| | | } |
| | | |
| | | 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 === '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) |
| | | |
| | |
| | | component.components = this.formatSetting(component.components, null, null, inherit, regs, balMap) |
| | | component = {...component, ...inherit} |
| | | return component |
| | | } |
| | | } else if (component.wrap && component.wrap.datatype === 'public') { |
| | | component.setting.useMSearch = false |
| | | |
| | | if (component.setting) { |
| | | component.setting.useMSearch = component.setting.useMSearch === 'true' |
| | | component.setting.syncRefresh = (component.setting.useMSearch && component.setting.syncRefresh === 'true') |
| | | } |
| | | |
| | | if (component.wrap && component.wrap.datatype === 'static') { |
| | | return component |
| | | } else if (component.wrap && component.wrap.datatype === 'static') { |
| | | component.format = '' |
| | | component.setting = component.setting || {} |
| | | component.setting.useMSearch = false |
| | | component.setting.syncRefresh = false |
| | | |
| | | return component |
| | | } else if (!component.setting || !component.format) { |
| | | return component |
| | | } |
| | | |
| | | if (!component.setting || !component.format) return component // 1、不使用系统函数时;2、 没有动态数据 数据格式 array 或 object |
| | | component.setting.useMSearch = component.setting.useMSearch === 'true' |
| | | |
| | | if (component.wrap && component.wrap.goback === 'true') { |
| | | component.setting.sync = 'false' |
| | | } |
| | | |
| | | if (component.setting.interType !== 'system') { // 不使用系统函数时 |
| | | component.setting.sync = 'false' |
| | | component.setting.laypage = component.setting.laypage === 'true' |
| | |
| | | } |
| | | |
| | | 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 => { |
| | |
| | | |
| | | component.setting.customScript = _customScript // 整理后自定义脚本 |
| | | |
| | | // floor 组件的层级 |
| | | // dataName 系统生成的数据源名称 |
| | | if (component.setting.sync === 'true') { |
| | | component.dataName = 'mk' + component.uuid.slice(-18) |
| | | } |
| | | |
| | | // floor 组件的层级 |
| | | // pageable 是否分页,组件属性,不分页的组件才可以统一查询 |
| | | if (params && component.dataName && (!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true' && component.setting.sync === 'true') { |
| | | 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) |
| | |
| | | } |
| | | } else if (params) { |
| | | component.setting.sync = 'false' |
| | | component.setting.delay = delay |
| | | delay += 20 |
| | | } |
| | | |
| | | component.setting.delay = delay |
| | | delay += 20 |
| | | |
| | | if (balMap.has(component.uuid)) { |
| | | component.setting.$hasSyncModule = true |
| | |
| | | }) |
| | | } |
| | | |
| | | // 格式化默认设置 |
| | | formatInterSetting = (inters, regs, MenuID, initInters) => { |
| | | if (!inters) return [] |
| | | |
| | | 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 |
| | | |
| | | if (inter.setting.supModule) { |
| | | let pid = inter.setting.supModule.pop() |
| | | if (pid && pid !== 'empty') { |
| | | inter.setting.supModule = pid |
| | | } else { |
| | | inter.setting.supModule = '' |
| | | } |
| | | } |
| | | |
| | | if (initlimit && inter.setting.loadlevel !== 'init') { |
| | | inter.setting.onload = 'false' |
| | | } |
| | | |
| | | if (inter.setting.interType !== 'system') return inter |
| | | |
| | | let _customScript = '' |
| | | inter.scripts.forEach(script => { |
| | | if (script.status !== 'false') { |
| | | _customScript += ` |
| | | ${script.sql} |
| | | ` |
| | | } |
| | | }) |
| | | delete inter.scripts |
| | | |
| | | inter.setting.$name = '公共数据源-' + inter.setting.name |
| | | inter.setting.execute = inter.setting.execute !== 'false' |
| | | inter.setting.laypage = true |
| | | |
| | | if (!inter.setting.execute) { |
| | | inter.setting.dataresource = '' |
| | | } |
| | | if (/\s/.test(inter.setting.dataresource)) { |
| | | inter.setting.dataresource = '(' + inter.setting.dataresource + ') tb' |
| | | } |
| | | |
| | | 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, '*/') |
| | | } else { |
| | | inter.setting.dataresource = inter.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'') |
| | | _customScript = _customScript.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) |
| | | }) |
| | | |
| | | inter.setting.customScript = _customScript // 整理后自定义脚本 |
| | | |
| | | return inter |
| | | }) |
| | | } |
| | | |
| | | /** |
| | | * @description 主表数据加载 |
| | | */ |
| | | loadmaindata = (params) => { |
| | | let param = getStructuredParams(params, this.state.config, this.state.BID || '') |
| | | const { config } = this.state |
| | | let param = getStructuredParams(params, 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 |
| | | 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, |
| | |
| | | } |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('interFinish', this.interFinish) |
| | | MKEmitter.addListener('debugChange', this.debugChange) |
| | | MKEmitter.addListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu) |
| | | } |
| | |
| | | this.setState = () => { |
| | | return |
| | | } |
| | | MKEmitter.removeListener('interFinish', this.interFinish) |
| | | MKEmitter.removeListener('debugChange', this.debugChange) |
| | | MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) |
| | | |
| | | window.GLOB.CacheData.delete(this.props.MenuID) |
| | | if (this.state.config) { |
| | | this.deleteCache(this.state.config.components) |
| | | 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 |
| | | } |
| | | } |
| | | |
| | | debugChange = () => { |
| | | this.setState({visible: !this.state.visible}) |
| | | } |
| | | |
| | | 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 = () => { |
| | | window.GLOB.CacheData.delete(this.props.MenuID) |
| | | |
| | | if (this.state.config) { |
| | | this.deleteCache(this.state.config.components) |
| | | this.state.config.interfaces.forEach(m => { |
| | | window.GLOB.CacheData.delete(m.uuid) |
| | | }) |
| | | } |
| | | |
| | | this.stepInter = null |
| | | |
| | | this.setState({ |
| | | BID: '', // 页面跳转时携带ID |
| | | loadingview: true, // 页面加载中 |
| | |
| | | } |
| | | |
| | | getComponents = () => { |
| | | const { config, BID, data, mainSearch } = this.state |
| | | const { config, BID, data, mainSearch, loadinginter } = this.state |
| | | |
| | | if (!config || !config.components) return |
| | | if (!config || !config.components || loadinginter) return |
| | | |
| | | return config.components.map(item => { |
| | | let _bid = BID |
| | | if (item.setting && item.setting.supModule) { |
| | | _bid = '' |
| | | let style = null |
| | | |
| | | if (item.style && item.style.clear === 'left') { |
| | | style = {clear: 'left'} |
| | | } |
| | | |
| | | if (item.type === 'bar' || item.type === 'line') { |
| | | if (item.type === 'card' && item.subtype === 'datacard') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <AntvBarAndLine config={item} data={data} BID={_bid} mainSearch={mainSearch}/> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <DataCard config={item} data={data} mainSearch={mainSearch}/> |
| | | </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}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'card' && item.subtype === 'dualdatacard') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <DoubleDataCard config={item} mainSearch={mainSearch}/> |
| | | </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}/> |
| | | </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}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'pie') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <AntvPie config={item} data={data} BID={_bid} mainSearch={mainSearch}/> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <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}/> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <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}/> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvDashboard config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'form' && item.subtype === 'simpleform') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <SimpleForm config={item} data={data} BID={_bid} mainSearch={mainSearch}/> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <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} BID={_bid} mainSearch={mainSearch}/> |
| | | <Col span={item.width} style={style} 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} BID={_bid} mainSearch={mainSearch}/> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TabForm config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'search') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <MainSearch config={item} BID={BID} refreshdata={this.resetSearch} /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'tabs') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <AntvTabs config={item} BID={BID} mainSearch={mainSearch} /> |
| | | </Col> |
| | | ) |
| | | } 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}/> |
| | | </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}/> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvTabs config={item} mainSearch={mainSearch} /> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'balcony') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <Balcony config={item} data={data} BID={_bid}/> |
| | | <Col span={item.width} style={style} 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} BID={_bid}/> |
| | | <Col span={item.width} style={style} 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}/> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <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}/> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <CarouselPropCard config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'table' && item.subtype === 'tablecard') { |
| | | } else if (item.type === 'card' && item.subtype === 'tablecard') { |
| | | return ( |
| | | <Col span={item.width} key={item.uuid}> |
| | | <TableCard config={item} data={data} BID={_bid} 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}/> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <TableCard 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} BID={_bid} mainSearch={mainSearch}/> |
| | | <Col span={item.width} style={style} 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}/> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <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}/> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <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}/> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <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}/> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <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} BID={_bid} mainSearch={mainSearch}/> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <CustomChart config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'antvG6') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <AntvG6 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} BID={_bid} /> |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <Voucher config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'module' && item.subtype === 'account') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <Account config={item}/> |
| | | </Col> |
| | | ) |
| | | } else if (item.type === 'iframe') { |
| | | return ( |
| | | <Col span={item.width} style={style} key={item.uuid}> |
| | | <Iframe config={item} data={data} mainSearch={mainSearch}/> |
| | | </Col> |
| | | ) |
| | | } else { |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { loadingview, viewlost, config, loading, shortcuts } = this.state |
| | | const { loadingview, viewlost, config, loading, shortcuts, BID } = 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 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} |
| | | <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> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | refreshTab: state.refreshTab, |
| | | permAction: state.permAction, |
| | | permMenus: state.permMenus |
| | | } |
| | | } |
| | | |
| | | const mapDispatchToProps = () => { |
| | | return {} |
| | | } |
| | | |
| | | export default connect(mapStateToProps, mapDispatchToProps)(CustomPage) |
| | | export default CustomPage |