import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { is, fromJS } from 'immutable'
|
import { notification, Spin, Row, Col, Modal } from 'antd'
|
|
import Api from '@/api'
|
import Utils from '@/utils/utils.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'
|
import './index.scss'
|
|
// 通用组件
|
const AntvBarAndLine = asyncComponent(() => import('./components/chart/antv-bar-line'))
|
const AntvPie = asyncComponent(() => import('./components/chart/antv-pie'))
|
const AntvTabs = asyncComponent(() => import('./components/tabs/antv-tabs'))
|
const AntvDashboard = asyncComponent(() => import('./components/chart/antv-dashboard'))
|
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 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 CustomChart = asyncComponent(() => import('./components/chart/custom-chart'))
|
const TimeLine = asyncComponent(() => import('./components/timeline/normal-timeline'))
|
const AntvG6 = asyncComponent(() => import('./components/chart/antv-G6'))
|
const AntvX6 = asyncComponent(() => import('./components/chart/antv-X6'))
|
const Voucher = asyncComponent(() => import('./components/module/voucher'))
|
const Account = asyncComponent(() => import('./components/module/account'))
|
const Iframe = asyncComponent(() => import('./components/iframe'))
|
const Calendar = asyncComponent(() => import('./components/calendar'))
|
const DebugTable = asyncComponent(() => import('@/tabviews/debugtable'))
|
const FlowFloat = asyncComponent(() => import('@/tabviews/zshare/flowFloat'))
|
const TableNodes = asyncComponent(() => import('@/tabviews/zshare/tablenodes'))
|
const MkInterfaces = asyncComponent(() => import('@/tabviews/custom/components/interfaces'))
|
|
class CustomPage extends Component {
|
static propTpyes = {
|
param: PropTypes.any, // 其他页面传递的参数
|
MenuID: PropTypes.string, // 菜单Id
|
MenuName: PropTypes.string, // 菜单名称
|
changeTemp: PropTypes.func
|
}
|
|
state = {
|
ContainerId: Utils.getuuid(), // 菜单外层html Id
|
BID: '', // 页面跳转时携带ID
|
loadingview: true, // 页面加载中
|
viewlost: false, // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用
|
lostmsg: '', // 页面丢失时的提示信息
|
config: null, // 页面配置信息,包括组件等
|
loading: false, // 列表数据加载中
|
visible: false, // 标签页控制
|
shortcuts: null, // 快捷键
|
loadinginter: false
|
}
|
|
stepInter = null
|
|
/**
|
* @description 获取页面配置信息
|
*/
|
async loadconfig () {
|
const { MenuID, MenuName } = this.props
|
|
let _param = {
|
func: 'sPC_Get_LongParam',
|
MenuID: MenuID
|
}
|
|
let result = await Api.getCacheConfig(_param)
|
|
if (result.status) {
|
let config = ''
|
let shortcuts = []
|
|
try { // 配置信息解析
|
config = window.decodeURIComponent(window.atob(result.LongParam))
|
config = config.replace(/@mywebsite@\//ig, window.GLOB.baseurl)
|
config = JSON.parse(config)
|
config.MenuID = MenuID
|
config.MenuName = MenuName || config.MenuName
|
} catch (e) {
|
console.warn('Parse Failure')
|
config = ''
|
}
|
|
// 页面配置解析错误时提示
|
if (!config) {
|
this.setState({
|
viewlost: true,
|
loadingview: false
|
})
|
return
|
}
|
|
// 页面未启用时,显示未启用页面
|
if (!config.enabled) {
|
this.setState({
|
viewlost: true,
|
loadingview: false,
|
lostmsg: '抱歉,您访问的页面未启用,请联系管理员。'
|
})
|
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
|
}
|
|
if (config.process === 'true') {
|
let unset = true
|
if (result.works_flow_code && result.works_long_param) {
|
try { // 流程信息解析
|
let flowConfig = JSON.parse(window.decodeURIComponent(window.atob(result.works_long_param)))
|
flowConfig.flow_code = result.works_flow_code
|
flowConfig.flow_name = result.works_flow_name
|
config.flow_code = result.works_flow_code
|
config.flow_name = result.works_flow_name
|
unset = false
|
|
window.GLOB.UserCacheMap.set('flow' + MenuID, flowConfig)
|
} catch (e) {
|
unset = true
|
console.warn('Parse Failure')
|
}
|
}
|
|
if (unset) {
|
config.interfaces = []
|
this.setState({
|
config: config,
|
viewlost: true,
|
loadingview: false,
|
lostmsg: '抱歉,您访问的页面未设置工作流,请联系管理员。'
|
})
|
return
|
}
|
} else if (result.works_flow_code) {
|
Api.getSystemConfig({
|
func: 's_works_flow_param_sso_menu_upt_v6',
|
upt_type: 'del',
|
works_flow_code: '',
|
works_flow_name: '',
|
long_param: '',
|
flow_id: '',
|
menuid: config.MenuID,
|
menuname: config.MenuName,
|
username: sessionStorage.getItem('User_Name') || '',
|
fullName: sessionStorage.getItem('Full_Name') || ''
|
})
|
}
|
|
// HS不使用自定义设置
|
if (result.LongParamUser) {
|
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', 'minute'].includes(config.timeUnit)) {
|
config.timeUnit = 'day'
|
}
|
config.cacheTime = config.cacheTime || 1
|
}
|
|
// 权限过滤
|
let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
|
let balMap = new Map()
|
let skip = config.permission === 'false' || window.GLOB.mkHS
|
let param = this.props.param || {} // url参数
|
|
window.GLOB.CacheData.set(MenuID, param)
|
|
let userName = sessionStorage.getItem('User_Name') || ''
|
let fullName = sessionStorage.getItem('Full_Name') || ''
|
|
let regs = [
|
{ reg: /@userName@/ig, value: `'${userName}'` },
|
{ reg: /@fullName@/ig, value: `'${fullName}'` }
|
]
|
|
if (window.GLOB.externalDatabase !== null) {
|
regs.push({
|
reg: /@db@/ig,
|
value: window.GLOB.externalDatabase
|
})
|
}
|
if (config.urlFields) {
|
config.urlFields.forEach(field => {
|
let val = `'${param[field] || ''}'`
|
regs.push({
|
reg: new RegExp('@' + field + '@', 'ig'),
|
value: val
|
})
|
})
|
}
|
|
if (config.flow_code) {
|
regs.push({ reg: /@works_flow_code@/ig, value: `'${config.flow_code}'` })
|
}
|
|
config.$cache = config.cacheLocal === 'true'
|
config.$time = config.localCacheTime || 0
|
|
if (window.GLOB.systemType !== 'production' && result.modifydate) {
|
let s = (new Date().getTime() - new Date(result.modifydate).getTime()) / (1000 * 60 * 60)
|
if (!isNaN(s) && s < 2) {
|
config.$cache = false
|
config.$time = 0
|
config.cacheUseful = 'false'
|
}
|
}
|
|
let initInters = []
|
|
config.interfaces = this.formatInterSetting(config.interfaces, regs, MenuID, initInters)
|
config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, skip, param, MenuID, config.interfaces, config.$cache, config.$time, config.MenuName, MenuID, MenuID, config.process === 'true')
|
|
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.forEach(component => {
|
if (component.type !== 'search') return
|
|
if (param.$searchkey) {
|
component.search = component.search.map(item => {
|
if (['text', 'select', 'link', 'checkcard'].includes(item.type) && param.$searchkey === item.field) {
|
item.initval = param.$searchval
|
}
|
|
return item
|
})
|
|
component.$searches = Utils.initMainSearch(component.search)
|
}
|
|
window.GLOB.SearchBox.set(MenuID, component.$searches)
|
|
if (component.$s_req) {
|
window.GLOB.SearchBox.set(MenuID + 'required', true)
|
}
|
})
|
|
config.components = this.formatSetting(config.components, params, inherit, regs, balMap)
|
|
if (balMap.size > 0) {
|
config.components = this.filterBalcony(config.components, balMap)
|
}
|
|
if (initInters.length > 0) {
|
this.stepInter = {
|
MenuID: MenuID,
|
inters: initInters,
|
params: params
|
}
|
}
|
|
this.setState({
|
BID: BID,
|
loadinginter: this.stepInter !== null,
|
shortcuts: shortcuts.length > 0 ? shortcuts : null,
|
config
|
}, () => {
|
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
|
})
|
}, 1000)
|
} else {
|
this.loadmaindata(params)
|
}
|
|
this.setShortcut()
|
})
|
} else {
|
this.setState({
|
loadingview: false,
|
viewlost: true
|
})
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 5
|
})
|
}
|
}
|
|
setShortcut = () => {
|
const { shortcuts } = this.state
|
|
document.onkeydown = (event) => {
|
let e = event || window.event
|
let keyCode = e.keyCode || e.which || e.charCode
|
let preKey = ''
|
|
if (e.ctrlKey) {
|
preKey = 'ctrl'
|
} else if (e.shiftKey) {
|
preKey = 'shift'
|
} else if (e.altKey) {
|
preKey = 'alt'
|
}
|
|
if (!preKey || !keyCode) return
|
|
let _shortcut = `${preKey}+${keyCode}`
|
|
if (window.GLOB.breakpoint && _shortcut === 'ctrl+67') {
|
window.GLOB.breakpoint = false
|
sessionStorage.removeItem('breakpoint')
|
|
MKEmitter.emit('debugChange')
|
}
|
|
if (!shortcuts) return
|
|
shortcuts.some(item => {
|
if (item.$shortcut === _shortcut) {
|
MKEmitter.emit('triggerBtnId', item.uuid)
|
return true
|
}
|
return false
|
})
|
}
|
}
|
|
filterComponent = (components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, cache, time, MenuName, searchId, syncId, process) => {
|
return components.filter(item => {
|
item.$pageId = pageId
|
item.$searchId = searchId
|
item.$syncId = syncId
|
|
if (process) {
|
item.$process = process
|
item.$flowId = 'flow' + this.props.MenuID
|
}
|
|
if (cache) {
|
item.$cache = cache
|
item.$time = time
|
|
if (item.wrap && item.wrap.cacheLocal === 'false') {
|
item.$cache = false
|
} else if (item.plot && item.plot.cacheLocal === 'false') {
|
item.$cache = false
|
}
|
|
if (!item.$cache && item.setting && item.setting.sync === 'true') {
|
item.setting.sync = 'false'
|
}
|
}
|
|
if (item.style && item.style.boxShadow) {
|
delete item.style.hShadow
|
delete item.style.vShadow
|
delete item.style.shadowBlur
|
delete item.style.shadowColor
|
}
|
|
item.$menuname = (MenuName || '') + '-' + (item.name || '')
|
|
if (item.type === 'tabs') {
|
if (
|
item.setting.blacklist && item.setting.blacklist.length > 0 &&
|
item.setting.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0
|
) {
|
return false
|
}
|
|
if (item.setting.supModule) {
|
let pid = item.setting.supModule.pop()
|
item.setting.supModule = pid || ''
|
} else {
|
item.setting.supModule = ''
|
}
|
|
item.subtabs = item.subtabs.filter(tab => {
|
if (
|
tab.blacklist && tab.blacklist.length > 0 &&
|
tab.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0
|
) {
|
return false
|
} else if (tab.hide === 'true') {
|
return false
|
}
|
|
if (item.setting.supModule) {
|
if (tab.controlVal === '@pass@') {
|
tab.$pass = true
|
} else if (/,/ig.test(tab.controlVal)) {
|
tab.controlVals = tab.controlVal.split(',')
|
} else {
|
tab.controlVals = [(tab.controlVal || '')]
|
}
|
}
|
|
return true
|
})
|
|
if (item.setting.supModule) {
|
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.$pass) return true
|
|
return !tab.controlVals.includes(val)
|
})
|
}
|
}
|
|
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.$pageId = pageId
|
tab.$cache = cache
|
tab.$time = time
|
|
let _searchId = searchId
|
|
if (tab.components.findIndex(cell => cell.type === 'search') > -1) {
|
_searchId = tab.uuid
|
}
|
|
tab.components = this.filterComponent(tab.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, cache, time, MenuName, _searchId, tab.uuid, process)
|
|
if (_searchId === tab.uuid) {
|
tab.components.forEach(cell => {
|
if (cell.type !== 'search') return
|
window.GLOB.SearchBox.set(_searchId, cell.$searches)
|
if (cell.$s_req) {
|
window.GLOB.SearchBox.set(_searchId + 'required', true)
|
}
|
})
|
}
|
|
return tab
|
})
|
|
return true
|
} else if (item.type === 'group') {
|
if (
|
item.setting.blacklist && item.setting.blacklist.length > 0 &&
|
item.setting.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0
|
) {
|
return false
|
}
|
|
item.components = this.filterComponent(item.components, roleId, permAction, balMap, skip, urlparam, pageId, interfaces, cache, time, MenuName, searchId, syncId, process)
|
|
return true
|
} else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart', 'antvG6', 'antvX6'].includes(item.type)) {
|
if (
|
item.plot.blacklist && item.plot.blacklist.length > 0 &&
|
item.plot.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0
|
) {
|
return false
|
}
|
} else if (item.wrap) {
|
if (
|
item.wrap.blacklist && item.wrap.blacklist.length > 0 &&
|
item.wrap.blacklist.filter(v => roleId.indexOf(v) > -1).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'
|
}
|
|
// 搜索条件初始化
|
if (item.search) {
|
Utils.initSearchVal(item)
|
|
item.$searches = Utils.initMainSearch(item.search)
|
}
|
|
if (item.wrap && item.wrap.supType === 'multi') { // 数据卡多上级组件
|
item.setting.supModule = item.supNodes[0].componentId
|
} else if (item.setting && item.setting.supModule && typeof(item.setting.supModule) !== 'string') {
|
let pid = item.setting.supModule.pop()
|
if (pid && pid !== 'empty') {
|
item.setting.supModule = pid
|
} else {
|
item.setting.supModule = ''
|
}
|
}
|
|
let pass = skip
|
|
if (item.wrap && item.wrap.permission === 'false') {
|
pass = true
|
}
|
|
// 权限过滤
|
if (item.action && item.action.length > 0) {
|
item.action = item.action.filter(cell => {
|
if (cell.hidden === 'true') return false
|
|
cell = this.resetButton(item, cell)
|
|
cell.$toolbtn = true
|
|
if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置
|
cell = this.getPrinter(cell, item.uuid)
|
}
|
|
return pass || permAction[cell.uuid]
|
})
|
}
|
|
if (item.type === 'table') {
|
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
|
} else if (col.type === 'action') {
|
col.type = 'custom'
|
}
|
|
if (col.type === 'number') {
|
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 === 'formula') {
|
if (typeof(col.decimal) === 'number') {
|
col.round = Math.pow(10, col.decimal)
|
}
|
} else if (col.type === 'colspan') {
|
col.subcols = getCols(col.subcols || [])
|
if (col.subcols.length === 0) {
|
return false
|
}
|
} else if (col.type === 'custom') {
|
col.elements = col.elements.filter(cell => {
|
if (cell.eleType === 'button') {
|
if (cell.hidden === 'true') return false
|
|
cell = this.resetButton(item, cell)
|
|
if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置
|
cell = this.getPrinter(cell, item.uuid)
|
}
|
|
return pass || permAction[cell.uuid]
|
} else {
|
cell = this.resetElement(cell)
|
}
|
return true
|
})
|
|
if (col.elements.length === 0) {
|
return false
|
}
|
}
|
|
if (col.linkmenu && col.linkmenu.length > 0) {
|
let menu_id = col.linkmenu.pop()
|
col.linkThdMenu = window.GLOB.mkThdMenus.get(menu_id) || ''
|
} else {
|
col.linkThdMenu = ''
|
}
|
|
return true
|
})
|
}
|
|
item.cols = getCols(item.cols)
|
|
if (item.subtype === 'editable') {
|
item.submit.logLabel = item.$menuname + '-提交'
|
item.submit.$menuId = item.uuid
|
item.submit.syncComponentId = item.submit.syncComponent ? (item.submit.syncComponent.pop() || '') : ''
|
|
if (item.submit.syncComponentId && item.submit.syncComponentId === item.setting.supModule) {
|
item.submit.syncComponentId = ''
|
if (item.submit.execSuccess === 'grid') {
|
item.submit.execSuccess = 'mainline'
|
}
|
}
|
}
|
} else if (item.type === 'card' || item.type === 'carousel' || item.type === 'timeline') {
|
item.subcards && item.subcards.forEach(card => {
|
if (card.style.boxShadow) {
|
delete card.style.hShadow
|
delete card.style.vShadow
|
delete card.style.shadowBlur
|
delete card.style.shadowColor
|
}
|
|
card.elements = card.elements.filter(cell => {
|
if (cell.eleType === 'button') {
|
if (cell.hidden === 'true') return false
|
|
cell = this.resetButton(item, cell)
|
|
if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置
|
cell = this.getPrinter(cell, item.uuid)
|
}
|
} else {
|
cell = this.resetElement(cell)
|
}
|
|
return cell.eleType !== 'button' || pass || permAction[cell.uuid]
|
})
|
|
if (card.setting.click === 'menus') {
|
if (card.menus) {
|
card.menus = card.menus.filter(m => !!m.MenuID)
|
if (card.menus.length === 0) {
|
card.menus = null
|
}
|
}
|
if (!card.menus || item.subtype !== 'datacard' || card.$cardType === 'extendCard') {
|
card.setting.click = ''
|
}
|
} else if (card.setting.click === 'menu') {
|
if (!Array.isArray(card.setting.menu)) {
|
card.setting.click = ''
|
}
|
}
|
|
if (item.subtype === 'dualdatacard' && card.$cardType !== 'extendCard') {
|
if (card.backSetting && card.backSetting.click === 'menu') {
|
if (!Array.isArray(card.backSetting.menu)) {
|
card.backSetting.click = ''
|
}
|
}
|
}
|
|
if (!card.backElements || card.backElements.length === 0) return
|
|
card.backElements = card.backElements.filter(cell => {
|
if (cell.eleType === 'button') {
|
if (cell.hidden === 'true') return false
|
|
cell = this.resetButton(item, cell)
|
|
if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置
|
cell = this.getPrinter(cell, item.uuid)
|
}
|
} else {
|
cell = this.resetElement(cell)
|
}
|
|
return cell.eleType !== 'button' || pass || permAction[cell.uuid]
|
})
|
})
|
} 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 = this.resetButton(item, cell)
|
|
if (cell.OpenType === 'funcbutton' && cell.funcType === 'print' && cell.verify) { // 打印机设置
|
cell = this.getPrinter(cell, item.uuid)
|
}
|
} else {
|
cell = this.resetElement(cell)
|
}
|
|
return cell.eleType !== 'button' || pass || permAction[cell.uuid]
|
})
|
} else if (item.type === 'form') {
|
item.subcards = item.subcards.map(group => {
|
group.subButton.uuid = group.uuid
|
group.subButton.$menuId = group.uuid
|
group.subButton.$MenuID = this.props.MenuID
|
// group.subButton.$forbid = true // 不声明数据源变量
|
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 (item.$process) {
|
group.subButton.$process = true
|
group.subButton.$flowId = 'flow' + this.props.MenuID
|
}
|
|
if (item.$cache && item.$time) {
|
group.$cache = item.$cache
|
group.$time = item.$time
|
}
|
|
group.subButton.syncComponentId = group.subButton.syncComponent ? (group.subButton.syncComponent.pop() || '') : ''
|
|
if (group.subButton.syncComponentId && group.subButton.syncComponentId === item.setting.supModule) {
|
group.subButton.syncComponentId = ''
|
if (group.subButton.execSuccess === 'grid') {
|
group.subButton.execSuccess = 'mainline'
|
}
|
}
|
|
if (group.subButton.verify && group.subButton.verify.invalid === 'true') {
|
if (item.wrap.datatype === 'static') {
|
group.subButton.verify.invalid = 'false'
|
} else if (group.subButton.sqlType === 'insert') {
|
group.subButton.verify.invalid = 'false'
|
} else if (group.subButton.Ot === 'notRequired') {
|
group.subButton.verify.invalid = 'false'
|
} else if (group.subButton.intertype !== 'system' && group.subButton.procMode !== 'system') {
|
group.subButton.verify.invalid = 'false'
|
}
|
}
|
|
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.base_sql = _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
|
})
|
} 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
|
})
|
}
|
|
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'
|
}
|
}
|
}
|
|
return true
|
})
|
}
|
|
resetButton = (item, cell) => {
|
cell.logLabel = item.$menuname + '-' + cell.label
|
cell.Ot = cell.Ot || 'requiredSgl'
|
cell.ContainerId = this.state.ContainerId
|
cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
|
cell.$menuId = item.uuid
|
cell.$MenuID = this.props.MenuID
|
cell.$view = 'popview'
|
|
if (item.$process) {
|
cell.$process = true
|
cell.$flowId = 'flow' + this.props.MenuID
|
}
|
|
if (cell.btnstyle) { // 兼容
|
cell.style = cell.style || {}
|
cell.style = {...cell.style, ...cell.btnstyle}
|
}
|
|
if (cell.controlField) {
|
if (/,/ig.test(cell.controlVal)) {
|
cell.controlVals = cell.controlVal.split(',')
|
} else {
|
cell.controlVals = [(cell.controlVal || '')]
|
}
|
}
|
|
if (cell.OpenType === 'excelOut') { // 导出
|
cell.$menuName = item.name
|
|
if (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0) {
|
cell.errorType = 'error1'
|
} else if (cell.intertype === 'system' && cell.verify.dataType !== 'custom') {
|
if (item.setting.interType !== 'system') {
|
cell.errorType = 'error2'
|
} else if (item.type === 'balcony' || item.subtype === 'propcard') {
|
cell.errorType = 'error2'
|
}
|
}
|
} else if (cell.OpenType === 'pop' && item.$cache && item.$time && cell.modal) {
|
cell.modal.$cache = item.$cache
|
cell.modal.$time = item.$time
|
cell.modal.uuid = cell.uuid + 'pop'
|
}
|
|
if (cell.verify && cell.verify.invalid === 'true') {
|
if (item.wrap && item.wrap.datatype === 'static') {
|
cell.verify.invalid = 'false'
|
} else if (cell.intertype !== 'system' && cell.procMode !== 'system') {
|
cell.verify.invalid = 'false'
|
} else if (cell.sqlType === 'insert') {
|
cell.verify.invalid = 'false'
|
} else if (cell.Ot === 'notRequired') {
|
cell.verify.invalid = 'false'
|
}
|
}
|
|
if (cell.syncComponentId) {
|
if (cell.syncComponentId === item.setting.supModule) {
|
cell.syncComponentId = ''
|
if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
|
cell.execSuccess = 'mainline'
|
}
|
} else if (cell.syncComponentId === 'multiComponent') {
|
let ids = cell.syncComponents.map(m => {
|
return m.syncComId.pop() || ''
|
})
|
|
if (item.setting.supModule && ids.includes(item.setting.supModule)) {
|
if (cell.execSuccess === 'line' || cell.execSuccess === 'grid') {
|
cell.execSuccess = 'mainline'
|
}
|
ids = ids.filter(id => id !== item.setting.supModule)
|
}
|
|
if (ids.length === 0) {
|
cell.syncComponentId = ''
|
} else {
|
cell.syncComponentIds = ids
|
}
|
}
|
}
|
|
return cell
|
}
|
|
resetElement = (cell) => {
|
cell.style = cell.style || {}
|
|
if (cell.style.display === 'inline-block') {
|
cell.style.verticalAlign = 'top'
|
}
|
|
if (['text', 'number', 'formula'].includes(cell.eleType)) {
|
if (!cell.height) {
|
cell.innerHeight = 'auto'
|
}
|
|
cell.innerHeight = cell.innerHeight || 'auto'
|
cell.alignItems = cell.height > 1 ? cell.alignItems : ''
|
|
if (cell.eleType === 'number' && typeof(cell.decimal) === 'number') {
|
cell.round = Math.pow(10, cell.decimal)
|
if (cell.format === 'percent') {
|
cell.decimal = cell.decimal > 2 ? cell.decimal - 2 : 0
|
}
|
} else if (cell.eleType === 'formula' && typeof(cell.decimal) === 'number') {
|
cell.round = Math.pow(10, cell.decimal)
|
}
|
} else if (cell.eleType === 'icon') {
|
if (!cell.innerHeight) { // 兼容
|
let fontSize = 14
|
let lineHeight = 1.5
|
|
if (cell.style.fontSize) {
|
fontSize = parseInt(cell.style.fontSize)
|
}
|
if (cell.style.lineHeight) {
|
lineHeight = parseFloat(cell.style.lineHeight)
|
}
|
|
cell.innerHeight = fontSize * lineHeight
|
}
|
}
|
|
return cell
|
}
|
|
getPrinter = (item, parentId) => {
|
let _item = window.GLOB.UserCacheMap.get(parentId + item.uuid)
|
|
item.verify.logLabel = item.logLabel
|
|
if (_item) {
|
item.printer = _item.printer || ''
|
item.verify.defaultPrinter = _item.printer || ''
|
if (item.verify.printerTypeList && _item.printerList) {
|
item.verify.printerTypeList = item.verify.printerTypeList.map(cell => {
|
cell.printer = _item.printerList[cell.Value] || ''
|
|
return cell
|
})
|
}
|
}
|
|
return item
|
}
|
|
// 格式化默认设置
|
formatSetting = (components, params, inherit, regs, balMap) => {
|
let delay = 20
|
return components.map(component => {
|
if (component.type === 'tabs') {
|
component.subtabs = component.subtabs.map(tab => {
|
tab.components = this.formatSetting(tab.components, null, inherit, regs, balMap)
|
tab = {...tab, ...inherit}
|
return tab
|
})
|
return component
|
} else if (component.type === 'group') {
|
component.components = this.formatSetting(component.components, params, null, regs, balMap)
|
return component
|
} else if (component.wrap && component.wrap.datatype === 'public') {
|
component.setting.useMSearch = false
|
component.setting.sync = 'false'
|
|
return component
|
} else if (component.wrap && component.wrap.datatype === 'static') {
|
component.format = ''
|
component.setting = component.setting || {}
|
component.setting.useMSearch = false
|
component.setting.sync = 'false'
|
|
return component
|
} else if (!component.setting || !component.format) {
|
return component
|
}
|
|
component.setting.arr_field = component.columns ? component.columns.map(col => col.field).join(',') : ''
|
component.setting.useMSearch = component.setting.useMSearch === 'true'
|
if (component.setting.useMSearch) {
|
if (!window.GLOB.SearchBox.has(component.$searchId)) {
|
component.setting.useMSearch = false
|
} else if (window.GLOB.SearchBox.has(component.$searchId + 'required')) {
|
component.$s_req = true
|
}
|
}
|
|
if (component.wrap && component.wrap.goback === 'true') {
|
component.setting.sync = 'false'
|
}
|
|
if (component.setting.interType !== 'system') { // 不使用系统函数时
|
component.setting.sync = 'false'
|
component.setting.dataresource = ''
|
component.setting.laypage = component.setting.laypage === 'true'
|
return component
|
}
|
|
let _customScript = ''
|
let _tailScript = ''
|
component.scripts && component.scripts.forEach(script => {
|
if (script.status === 'false') return
|
if (script.position !== 'back') {
|
_customScript += `
|
${script.sql}
|
`
|
} else {
|
_tailScript += `
|
${script.sql}
|
`
|
}
|
})
|
delete component.scripts
|
component.setting.$name = component.$menuname || ''
|
component.setting.execute = component.setting.execute !== 'false' // 默认sql是否执行,转为boolean 统一格式
|
component.setting.laypage = component.setting.laypage === 'true' // 是否分页,转为boolean 统一格式
|
|
if (!component.setting.execute) {
|
component.setting.dataresource = ''
|
}
|
if (/\s/.test(component.setting.dataresource)) {
|
component.setting.dataresource = '(' + component.setting.dataresource + ') tb'
|
}
|
|
if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
|
component.setting.dataresource = component.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
|
_customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
|
_tailScript = _tailScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
|
} else {
|
component.setting.dataresource = component.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
|
_customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
|
_tailScript = _tailScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
|
}
|
|
regs.forEach(cell => {
|
component.setting.dataresource = component.setting.dataresource.replace(cell.reg, cell.value)
|
_customScript = _customScript.replace(cell.reg, cell.value)
|
_tailScript = _tailScript.replace(cell.reg, cell.value)
|
})
|
|
component.setting.customScript = _customScript // 整理后自定义脚本
|
component.setting.tailScript = _tailScript // 后置自定义脚本
|
|
component.setting.custompage = /@pageSize@|@orderBy@/i.test(component.setting.dataresource + component.setting.customScript)
|
|
if (!component.setting.execute || component.setting.custompage) {
|
component.forbidLine = true
|
}
|
|
if (component.setting.sync === 'true') {
|
// pageable 是否分页,组件属性,不分页的组件才可以统一查询
|
if ((!component.pageable || (component.pageable && !component.setting.laypage)) && component.setting.onload === 'true') {
|
|
} else {
|
component.setting.sync = 'false'
|
}
|
}
|
|
// dataName 系统生成的数据源名称
|
if (component.setting.sync === 'true') {
|
component.dataName = 'mk' + component.uuid.slice(-18)
|
|
if (params) {
|
let searchlist = component.$searches || []
|
|
if (component.setting.useMSearch) {
|
let mainSearch = window.GLOB.SearchBox.get(component.$searchId)
|
let keys = component.$s_keys || []
|
mainSearch.forEach(item => {
|
if (keys.includes(item.key.toLowerCase())) return
|
|
searchlist.push(item)
|
})
|
}
|
|
if (component.$s_req && searchlist.filter(item => item.required && item.value === '').length > 0) {
|
component.setting.sync = 'false'
|
component.setting.onload = 'false'
|
} else {
|
params.push(getStructDefaultParam(component, searchlist, params.length === 0))
|
}
|
}
|
}
|
|
component.setting.delay = delay
|
delay += 20
|
|
if (balMap.has(component.uuid)) {
|
component.setting.$hasSyncModule = true
|
balMap.set(component.uuid, component)
|
}
|
|
return component
|
})
|
}
|
|
// 格式化默认设置
|
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
|
inter.$searchId = MenuID
|
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'
|
}
|
|
inter.setting.useMSearch = inter.setting.useMSearch === 'true'
|
inter.setting.arr_field = inter.columns.map(col => col.field).join(',')
|
|
if (inter.setting.interType !== 'system') return inter
|
|
let _customScript = ''
|
let _tailScript = ''
|
inter.scripts.forEach(script => {
|
if (script.status === 'false') return
|
if (script.position !== 'back') {
|
_customScript += `
|
${script.sql}
|
`
|
} else {
|
_tailScript += `
|
${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(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
|
_customScript = _customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
|
_tailScript = _tailScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/').replace(/@datam@/ig, '\'Y\'')
|
} else {
|
inter.setting.dataresource = inter.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
|
_customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
|
_tailScript = _tailScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
|
}
|
|
regs.forEach(cell => {
|
inter.setting.dataresource = inter.setting.dataresource.replace(cell.reg, cell.value)
|
_customScript = _customScript.replace(cell.reg, cell.value)
|
_tailScript = _tailScript.replace(cell.reg, cell.value)
|
})
|
|
inter.setting.customScript = _customScript // 整理后自定义脚本
|
inter.setting.tailScript = _tailScript // 后置自定义脚本
|
|
inter.setting.custompage = /@pageSize@|@orderBy@/i.test(inter.setting.dataresource + inter.setting.customScript)
|
|
return inter
|
})
|
}
|
|
/**
|
* @description 主表数据加载
|
*/
|
loadmaindata = (params) => {
|
const { config, BID } = this.state
|
let param = getStructuredParams(params, config, BID || '')
|
|
this.setState({loading: true, loadingview: false})
|
|
if (config.$cache && config.$time) {
|
Api.getLCacheConfig(params[0].uuid, config.$time, BID).then(res => {
|
if (!res.valid) {
|
this.getMainData(param, params, config.MenuID)
|
} else {
|
this.setState({
|
loading: false
|
})
|
}
|
})
|
} else {
|
this.getMainData(param, params, config.MenuID)
|
}
|
}
|
|
getMainData = (param, params, MenuID) => {
|
Api.genericInterface(param).then(result => {
|
this.setState({
|
loading: false
|
})
|
|
if (result.status) {
|
if (result.message) {
|
if (result.ErrCode === 'Y') {
|
Modal.success({
|
title: result.message
|
})
|
} else if (result.ErrCode === 'S') {
|
notification.success({
|
top: 92,
|
message: result.message,
|
duration: 2
|
})
|
}
|
}
|
|
params.forEach((item) => {
|
let _data = result[item.name] || ''
|
if (_data && !Array.isArray(_data)) {
|
_data = [_data]
|
}
|
window.GLOB.SyncData.set(item.name, _data)
|
})
|
|
MKEmitter.emit('transferSyncData', MenuID)
|
} else {
|
MKEmitter.emit('transferSyncData', MenuID)
|
|
if (!result.message) return
|
if (result.ErrCode === 'N') {
|
Modal.error({
|
title: result.message,
|
})
|
} else if (result.ErrCode !== '-2') {
|
notification.error({
|
top: 92,
|
message: result.message,
|
duration: 10
|
})
|
}
|
}
|
})
|
}
|
|
reloadMenuView = (menuId) => {
|
const { MenuID } = this.props
|
|
if (MenuID !== menuId) return
|
|
this.reloadview()
|
}
|
|
resetActiveMenu = (menuId) => {
|
const { MenuID } = this.props
|
|
if (MenuID !== menuId) return
|
|
this.setShortcut()
|
}
|
|
UNSAFE_componentWillMount () {
|
// 组件加载时,获取菜单数据
|
this.loadconfig()
|
}
|
|
shouldComponentUpdate (nextProps, nextState) {
|
return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
|
}
|
|
componentDidMount () {
|
MKEmitter.addListener('interFinish', this.interFinish)
|
MKEmitter.addListener('debugChange', this.debugChange)
|
MKEmitter.addListener('reloadMenuView', this.reloadMenuView)
|
MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu)
|
}
|
|
/**
|
* @description 组件销毁,清除state更新,清除快捷键设置
|
*/
|
componentWillUnmount () {
|
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 if (item.type === 'search') {
|
window.GLOB.SearchBox.delete(item.$searchId)
|
} else {
|
window.GLOB.CacheData.delete(item.uuid)
|
}
|
if (item.dataName) {
|
window.GLOB.SyncData.delete(item.dataName)
|
}
|
})
|
}
|
|
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, // 页面加载中
|
viewlost: false, // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用
|
config: null, // 页面配置信息,包括组件等
|
loading: false, // 列表数据加载中
|
shortcuts: null
|
}, () => {
|
this.loadconfig()
|
})
|
}
|
|
getComponents = () => {
|
const { config, BID, loadinginter } = this.state
|
|
if (!config || !config.components || loadinginter) return
|
|
return config.components.map(item => {
|
let style = null
|
|
if (item.style && item.style.clear === 'left') {
|
style = {clear: 'left'}
|
} else if (item.style && item.style.clear === 'right') {
|
style = {float: 'right'}
|
}
|
|
if (item.type === 'card' && item.subtype === 'datacard') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<DataCard config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'card' && item.subtype === 'propcard') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<PropCard config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'card' && item.subtype === 'dualdatacard') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<DoubleDataCard config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'table' && item.subtype === 'normaltable') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<NormalTable config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'bar' || item.type === 'line') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<AntvBarAndLine config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'pie') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<AntvPie config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'scatter') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<AntvScatter config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'dashboard') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<AntvDashboard config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'form' && item.subtype === 'simpleform') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<SimpleForm config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'form' && item.subtype === 'stepform') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<StepForm config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'form' && item.subtype === 'tabform') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<TabForm config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'search') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<MainSearch config={item} BID={BID}/>
|
</Col>
|
)
|
} else if (item.type === 'tabs') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<AntvTabs config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'balcony') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<Balcony config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'timeline') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<TimeLine config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'carousel' && item.subtype === 'datacard') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<CarouselDataCard config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'carousel' && item.subtype === 'propcard') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<CarouselPropCard config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'card' && item.subtype === 'tablecard') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<TableCard config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'table' && item.subtype === 'editable') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<EditTable config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'group' && item.subtype === 'normalgroup') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<NormalGroup config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'editor') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<BraftEditor config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'tree') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<NormalTree config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'calendar') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<Calendar config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'code') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<SandBox config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'chart') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<CustomChart config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'antvG6') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<AntvG6 config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'antvX6') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<AntvX6 config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'module' && item.subtype === 'voucher') {
|
return (
|
<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}/>
|
</Col>
|
)
|
} else {
|
return null
|
}
|
})
|
}
|
|
render() {
|
const { loadingview, viewlost, config, loading, shortcuts, BID } = this.state
|
|
if (!config || viewlost) {
|
return (
|
<div className="custom-page-wrap">
|
{loadingview ? <Spin className="view-spin" size="large" /> : null}
|
{viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
|
<div className="user-tools">
|
{config && config.process === 'true' ? <FlowFloat init={true} config={config}/> : null}
|
</div>
|
</div>
|
)
|
}
|
|
return (
|
<div className={`custom-page-wrap ${config.minWidth ? 'mk-scroll' : ''} ${loading ? 'loading' : ''} ${config.mask === 'false' ? 'mk-no-mask' : ''}`} id={this.state.ContainerId} style={config.style}>
|
{loading && !config.$cache ? <Spin className="view-spin" size="large" /> : null}
|
<Row id={'menu' + config.uuid} style={{minWidth: config.minWidth || 'unset'}} className="component-wrap">{this.getComponents()}</Row>
|
{config.interfaces.length > 0 ? <MkInterfaces BID={BID} interfaces={config.interfaces}/> : null}
|
{window.GLOB.breakpoint ? <DebugTable /> : null}
|
<div className="user-tools">
|
{config.process === 'true' ? <FlowFloat config={config}/> : null}
|
<SettingComponent config={config} shortcuts={shortcuts || []}/>
|
<TableNodes config={config} />
|
</div>
|
</div>
|
)
|
}
|
}
|
|
export default CustomPage
|