import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import { is, fromJS } from 'immutable'
|
import { notification, Spin, Row, Col, Modal } from 'antd'
|
import moment from 'moment'
|
|
import Api from '@/api'
|
import Utils from '@/utils/utils.js'
|
import { getStructuredParams, getStructDefaultParam } from '@/utils/utils-datamanage.js'
|
import MKEmitter from '@/utils/events.js'
|
import asyncComponent from '@/utils/asyncComponent'
|
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 BaseTable = asyncComponent(() => import('../components/table/base-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 CustomChart = asyncComponent(() => import('../components/chart/custom-chart'))
|
const TimeLine = asyncComponent(() => import('../components/timeline/normal-timeline'))
|
const Voucher = asyncComponent(() => import('../components/module/voucher'))
|
const Iframe = asyncComponent(() => import('../components/iframe'))
|
const Calendar = asyncComponent(() => import('../components/calendar'))
|
const AntvG6 = asyncComponent(() => import('../components/chart/antv-G6'))
|
const AntvX6 = asyncComponent(() => import('../components/chart/antv-X6'))
|
|
class CustomPage extends Component {
|
static propTpyes = {
|
param: PropTypes.any, // 其他页面传递的参数
|
Tab: PropTypes.string, // 弹窗标签
|
}
|
|
state = {
|
BID: '', // 页面跳转时携带ID
|
viewlost: false, // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用
|
lostmsg: '', // 页面丢失时的提示信息
|
config: null, // 页面配置信息,包括组件等
|
loading: false, // 列表数据加载中
|
}
|
|
/**
|
* @description 获取页面配置信息
|
*/
|
async loadconfig () {
|
const { Tab, param } = this.props
|
|
let config = Tab.config || ''
|
|
if (config) {
|
try { // 配置信息解析
|
config = JSON.stringify(config)
|
config = config.replace(/@mywebsite@\//ig, window.GLOB.baseurl)
|
config = JSON.parse(config)
|
config.MenuName = Tab.logLabel || Tab.label || ''
|
} catch (e) {
|
console.warn('Parse Failure')
|
config = ''
|
}
|
}
|
|
// 页面配置解析错误时提示
|
if (!config) {
|
this.setState({
|
viewlost: true
|
})
|
return
|
}
|
|
// 页面未启用时,显示未启用页面
|
if (!config.enabled) {
|
this.setState({
|
viewlost: true,
|
lostmsg: '抱歉,您访问的页面未启用,请联系管理员。'
|
})
|
return
|
}
|
|
// 数据缓存设置
|
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 tbMap = new Map()
|
let urlparam = {} // url参数
|
if (param) {
|
Object.keys(param).forEach(key => {
|
if (/^\$/.test(key)) {
|
urlparam[key] = param[key]
|
} else {
|
urlparam[key.toLowerCase()] = param[key]
|
}
|
})
|
}
|
|
window.GLOB.CacheData.set(Tab.uuid, urlparam)
|
|
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 (Tab.$process && window.GLOB.UserCacheMap.has(Tab.$flowId)) {
|
let flow = window.GLOB.UserCacheMap.get(Tab.$flowId)
|
regs.push({ reg: /@works_flow_code@/ig, value: `'${flow.flow_code || ''}'` })
|
}
|
|
config.components = this.filterComponent(config.components, roleId, balMap, tbMap, urlparam, Tab, Tab.uuid, Tab.uuid, regs)
|
|
// 获取主搜索条件
|
config.components.forEach(component => {
|
if (component.type !== 'search') return
|
|
window.GLOB.SearchBox.set(Tab.uuid, component.$searches)
|
|
if (component.$s_req) {
|
window.GLOB.SearchBox.set(Tab.uuid + 'required', true)
|
}
|
})
|
|
let params = []
|
let BID = urlparam.$BID || ''
|
|
config.components = this.formatSetting(config.components, params, balMap, tbMap)
|
|
this.setState({
|
BID: BID,
|
config
|
}, () => {
|
if (params.length > 0) {
|
this.loadmaindata(params)
|
}
|
})
|
}
|
|
filterComponent = (components, roleId, balMap, tbMap, urlparam, Tab, searchId, syncId, regs) => {
|
return components.filter(item => {
|
item.$pageId = Tab.uuid
|
item.$searchId = searchId
|
item.$syncId = syncId
|
|
if (Tab.$process) {
|
item.$process = true
|
item.$flowId = Tab.$flowId
|
}
|
|
if (item.style && item.style.boxShadow) {
|
delete item.style.hShadow
|
delete item.style.vShadow
|
delete item.style.shadowBlur
|
delete item.style.shadowColor
|
}
|
|
item.$menuname = (Tab.logLabel || Tab.label || '') + '-' + (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 || '')]
|
}
|
}
|
|
tab.$menuname = (Tab.logLabel || Tab.label || '') + '-' + (tab.label || '')
|
|
return true
|
})
|
|
if (item.setting.supModule) {
|
item.setting.controlField = item.setting.controlField.toLowerCase()
|
|
if (item.setting.supModule === 'preview') {
|
item.setting.supModule = ''
|
let val = urlparam[item.setting.controlField] || ''
|
|
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 = urlparam[item.setting.selectField] || ''
|
|
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 = Tab.uuid
|
|
let _searchId = searchId
|
|
if (tab.components.findIndex(cell => cell.type === 'search') > -1) {
|
_searchId = tab.uuid
|
}
|
|
tab.components = this.filterComponent(tab.components, roleId, balMap, tbMap, urlparam, Tab, _searchId, tab.uuid, regs)
|
|
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, balMap, tbMap, urlparam, Tab, searchId, syncId, regs)
|
|
return true
|
} else if (['pie', 'bar', 'line', 'dashboard', 'scatter', 'chart'].includes(item.type)) {
|
if (
|
item.plot.blacklist && item.plot.blacklist.length > 0 &&
|
item.plot.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0
|
) {
|
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 && item.wrap.supType === 'multi') { // 数据卡、table多上级组件
|
item.supNodes = item.supNodes.map(node => node.componentId)
|
if (item.supNodes[0]) {
|
item.setting.supModule = item.supNodes[0]
|
} else {
|
item.supNodes = null
|
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
|
} else {
|
item.setting.supModule = ''
|
}
|
}
|
|
// 搜索条件初始化
|
if (item.search) {
|
Utils.initSearchVal(item)
|
|
item.$searches = Utils.initMainSearch(item.search)
|
}
|
|
// 权限过滤
|
if (item.action && item.action.length > 0) {
|
item.action = item.action.filter(cell => {
|
if (cell.hidden === 'true' || cell.OpenType === 'popview') return false
|
|
cell = this.resetButton(item, cell, Tab)
|
cell.$toolbtn = true
|
|
return true
|
})
|
}
|
|
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 === 'index') {
|
col.field = '$Index'
|
col.type = 'text'
|
} else 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' || cell.OpenType === 'popview') return false
|
|
cell = this.resetButton(item, cell, Tab)
|
} 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 = ''
|
}
|
|
if (col.marks && col.marks.length === 0) {
|
col.marks = null
|
}
|
|
return true
|
})
|
}
|
|
item.cols = getCols(item.cols)
|
|
if (item.hasExtend) {
|
item.setting.hasExtend = true
|
item.setting.tableMode = 'compatible'
|
item.setting.extendTime = moment().format('YYYY-MM-DD HH:mm:ss')
|
item.colsCtrls = null
|
}
|
|
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' || cell.OpenType === 'popview') return false
|
|
cell = this.resetButton(item, cell, Tab)
|
} else {
|
cell = this.resetElement(cell)
|
}
|
|
return true
|
})
|
|
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' || cell.OpenType === 'popview') return false
|
|
cell = this.resetButton(item, cell, Tab)
|
} else {
|
cell = this.resetElement(cell)
|
}
|
|
return true
|
})
|
})
|
} 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
|
}
|
if (item.wrap.datatype === 'public') {
|
balMap.set(item.wrap.publicId + 'public', true)
|
}
|
item.elements = item.elements.filter(cell => {
|
if (cell.eleType === 'button') {
|
if (cell.hidden === 'true' || cell.OpenType === 'popview') return false
|
|
cell = this.resetButton(item, cell, Tab)
|
} else {
|
cell = this.resetElement(cell)
|
}
|
|
return true
|
})
|
} else if (item.type === 'form') {
|
if (item.wrap.datatype === 'public') {
|
balMap.set(item.wrap.publicId + 'public', true)
|
}
|
item.subcards = item.subcards.map(group => {
|
group.subButton.uuid = group.uuid
|
group.subButton.OpenType = 'formSubmit'
|
group.subButton.execError = 'never'
|
|
if (!group.subButton.Ot) {
|
group.subButton.Ot = item.wrap.datatype === 'static' ? 'notRequired' : 'requiredSgl'
|
}
|
|
group.subButton = this.resetButton(item, group.subButton, Tab)
|
|
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
|
})
|
}
|
|
// 整理数据源
|
if (item.setting && item.format && (!item.wrap || !['public', 'static'].includes(item.wrap.datatype))) {
|
item.setting.arr_field = item.columns ? item.columns.map(col => col.field).join(',') : ''
|
item.setting.useMSearch = item.setting.useMSearch === 'true'
|
item.setting.laypage = item.setting.laypage === 'true' // 是否分页,转为boolean 统一格式
|
|
if (item.wrap && item.wrap.goback === 'true') {
|
item.setting.sync = 'false'
|
}
|
|
if (item.format === 'object') {
|
item.setting.laypage = false
|
item.setting.$top = true
|
}
|
|
if (item.setting.interType !== 'system') { // 不使用系统函数时
|
item.setting.sync = 'false'
|
item.setting.dataresource = ''
|
} else {
|
let _customScript = ''
|
let _tailScript = ''
|
item.scripts && item.scripts.forEach(script => {
|
if (script.status === 'false') return
|
if (script.position !== 'back') {
|
_customScript += `
|
${script.sql}
|
`
|
} else {
|
_tailScript += `
|
${script.sql}
|
`
|
}
|
})
|
delete item.scripts
|
item.setting.$name = item.$menuname || ''
|
item.setting.execute = item.setting.execute !== 'false' // 默认sql是否执行,转为boolean 统一格式
|
|
if (!item.setting.execute) {
|
item.setting.dataresource = ''
|
}
|
if (/\s/.test(item.setting.dataresource)) {
|
item.setting.dataresource = '(' + item.setting.dataresource + ') tb'
|
}
|
|
if (sessionStorage.getItem('dataM') === 'true') { // 数据权限
|
item.setting.dataresource = item.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 {
|
item.setting.dataresource = item.setting.dataresource.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
|
_customScript = _customScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
|
_tailScript = _tailScript.replace(/@\$|\$@/ig, '').replace(/@datam@/ig, '\'\'')
|
}
|
|
regs.forEach(cell => {
|
item.setting.dataresource = item.setting.dataresource.replace(cell.reg, cell.value)
|
_customScript = _customScript.replace(cell.reg, cell.value)
|
_tailScript = _tailScript.replace(cell.reg, cell.value)
|
})
|
|
item.setting.customScript = _customScript // 整理后自定义脚本
|
item.setting.tailScript = _tailScript // 后置自定义脚本
|
|
item.setting.custompage = /@pageSize@|@orderBy@|@mk_total/i.test(item.setting.dataresource + item.setting.customScript)
|
|
if (!item.setting.execute || item.setting.custompage) {
|
item.forbidLine = true
|
}
|
|
if (item.setting.sync === 'true') {
|
// pageable 是否分页,组件属性,不分页的组件才可以统一查询
|
if ((!item.pageable || (item.pageable && !item.setting.laypage)) && item.setting.onload === 'true') {
|
|
} else {
|
item.setting.sync = 'false'
|
}
|
}
|
}
|
}
|
|
if (item.type === 'card' && item.subtype === 'datacard') {
|
tbMap.set(item.uuid, item)
|
} else if (item.type === 'table' && item.subtype !== 'editable') {
|
tbMap.set(item.uuid, item)
|
}
|
|
return true
|
})
|
}
|
|
resetButton = (item, cell, Tab) => {
|
cell.logLabel = item.$menuname + '-' + cell.label
|
cell.Ot = cell.Ot || 'requiredSgl'
|
cell.syncComponentId = cell.syncComponent ? (cell.syncComponent.pop() || '') : ''
|
cell.$menuId = item.uuid
|
cell.$MenuID = Tab.$MenuID
|
cell.$tabId = Tab.uuid
|
|
if (Tab.$process) {
|
cell.$process = true
|
cell.$flowId = Tab.$flowId
|
}
|
|
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.$menuname
|
|
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'
|
}
|
}
|
}
|
|
if (cell.verify) {
|
if (cell.verify.invalid === 'true') {
|
if (item.wrap && (item.wrap.datatype === 'static' || item.wrap.datatype === 'public')) {
|
cell.verify.invalid = 'false'
|
} else if (item.setting && item.setting.maxScript && item.setting.maxScript >= 300) {
|
cell.verify.invalid = 'false'
|
} else if (cell.intertype !== 'system' && cell.procMode !== 'system') {
|
cell.verify.invalid = 'false'
|
} else if (cell.sqlType === 'insert') {
|
cell.verify.invalid = 'false'
|
} else if (cell.Ot === 'notRequired') {
|
cell.verify.invalid = 'false'
|
}
|
}
|
|
if (cell.verify.linkEnable === 'true' && /@/.test(cell.verify.linkUrl)) {
|
cell.returnValue = 'true'
|
}
|
|
if (cell.verify.preHandle === 'true') {
|
let script = cell.verify.pre_func
|
if (!/#position-/.test(script) || /#position-init/.test(script)) {
|
try {
|
// eslint-disable-next-line
|
let func = new Function('btn', 'position', 'systemType', script)
|
func(cell, 'init', window.GLOB.systemType)
|
} catch (e) {
|
console.warn(e)
|
}
|
}
|
if (/#position-inner/.test(script)) {
|
cell.$innerScript = script
|
}
|
if (/#position-outer/.test(script)) {
|
cell.$outerScript = script
|
}
|
if (/#position-callback/.test(script)) {
|
cell.$callbackScript = script
|
}
|
}
|
}
|
|
if (cell.syncComponentId) {
|
if (cell.syncComponentId === item.setting.supModule) {
|
cell.syncComponentId = ''
|
if (['line', 'grid', 'line_grid'].includes(cell.execSuccess)) {
|
cell.execSuccess = 'mainline'
|
}
|
} else if (cell.syncComponentId === 'multiComponent') {
|
let ids = cell.syncComponents.map(m => {
|
return m.syncComId.pop() || ''
|
})
|
|
if (item.supNodes) {
|
item.supNodes.forEach(node => {
|
if (!ids.includes(node)) return
|
|
if (['line', 'grid', 'line_grid'].includes(cell.execSuccess)) {
|
cell.execSuccess = 'mainline'
|
}
|
ids = ids.filter(id => id !== node)
|
})
|
} else if (item.setting.supModule && ids.includes(item.setting.supModule)) {
|
if (['line', 'grid', 'line_grid'].includes(cell.execSuccess)) {
|
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 (cell.marks && cell.marks.length === 0) {
|
cell.marks = null
|
}
|
if (cell.anchors && cell.anchors.length === 0) {
|
cell.anchors = null
|
}
|
|
if (cell.linkmenu && cell.linkmenu.length > 0) {
|
let menu_id = cell.linkmenu.pop()
|
cell.linkThdMenu = window.GLOB.mkThdMenus.get(menu_id) || ''
|
if (!cell.linkThdMenu) {
|
cell.link = ''
|
}
|
}
|
|
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.type === '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
|
}
|
|
// 格式化默认设置
|
formatSetting = (components, params, balMap, tbMap) => {
|
let delay = 20
|
return components.map(component => {
|
if (component.type === 'tabs') {
|
component.subtabs = component.subtabs.map(tab => {
|
tab.components = this.formatSetting(tab.components, null, balMap, tbMap)
|
return tab
|
})
|
return component
|
} else if (component.type === 'group') {
|
component.components = this.formatSetting(component.components, params, balMap, tbMap)
|
return component
|
}
|
|
if (component.type === 'balcony') {
|
if (component.wrap.linkType === 'sync') {
|
let conf = tbMap.get(component.wrap.syncModuleId)
|
|
if (conf) {
|
component.syncConfig = {
|
uuid: conf.uuid,
|
wrap: conf.wrap,
|
setting: conf.setting,
|
columns: conf.columns
|
}
|
|
if (component.wrap.checkAll === 'show') {
|
if (conf.subtype === 'datacard' && conf.wrap.cardType !== 'checkbox') {
|
component.wrap.checkAll = 'hidden'
|
} else if (conf.subtype === 'normaltable' && conf.wrap.tableType !== 'checkbox') {
|
component.wrap.checkAll = 'hidden'
|
}
|
}
|
}
|
}
|
} else if (balMap.has(component.uuid)) {
|
component.setting.$hasSyncModule = true
|
}
|
|
if (balMap.has(component.uuid + 'public')) {
|
component.$hasTopModule = true
|
}
|
|
if (component.wrap && component.wrap.datatype === 'public') {
|
if (tbMap.has(component.wrap.publicId)) {
|
let tb = tbMap.get(component.wrap.publicId)
|
component.setting = {...tb.setting}
|
component.$searchId = tb.$searchId
|
component.wrap.publicId = component.wrap.publicId + 'tb'
|
} else {
|
component.wrap.datatype = 'static'
|
component.setting = component.setting || {}
|
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
|
}
|
|
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.setting.interType !== 'system') return component
|
|
// 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
|
|
return component
|
})
|
}
|
|
/**
|
* @description 主表数据加载
|
*/
|
loadmaindata = (params) => {
|
const { Tab } = this.props
|
const { config } = this.state
|
let param = getStructuredParams(params, config, this.state.BID || '')
|
|
this.setState({loading: true})
|
|
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', Tab.uuid)
|
} else {
|
MKEmitter.emit('transferSyncData', Tab.uuid)
|
|
if (!result.message) return
|
|
if (/将截断字符串或二进制数据/ig.test(result.message)) {
|
result.message = result.message + '请检查字段集'
|
}
|
if (result.ErrCode === 'N') {
|
Modal.error({
|
title: result.message,
|
})
|
} else if (result.ErrCode !== '-2') {
|
notification.error({
|
top: 92,
|
message: result.message,
|
duration: 10
|
})
|
}
|
}
|
})
|
}
|
|
UNSAFE_componentWillMount () {
|
// 组件加载时,获取菜单数据
|
this.loadconfig()
|
}
|
|
shouldComponentUpdate (nextProps, nextState) {
|
return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
|
}
|
|
/**
|
* @description 组件销毁,清除state更新,清除快捷键设置
|
*/
|
componentWillUnmount () {
|
this.setState = () => {
|
return
|
}
|
|
window.GLOB.CacheData.delete(this.props.Tab.uuid)
|
if (this.state.config) {
|
this.deleteCache(this.state.config.components)
|
}
|
}
|
|
deleteCache = (components) => {
|
components.forEach(item => {
|
if (item.type === 'tabs') {
|
item.subtabs.forEach(tab => {
|
this.deleteCache(tab.components)
|
})
|
} else if (item.type === 'group') {
|
this.deleteCache(item.components)
|
} else 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)
|
}
|
})
|
}
|
|
getComponents = () => {
|
const { config, BID } = this.state
|
|
if (!config) 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 === 'basetable') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<BaseTable 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 === 'normaltable') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<NormalTable 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 (
|
<NormalGroup config={item} style={style} key={item.uuid}/>
|
)
|
} 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 === 'module' && item.subtype === 'voucher') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<Voucher config={item}/>
|
</Col>
|
)
|
} else if (item.type === 'iframe') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<Iframe 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 {
|
return null
|
}
|
})
|
}
|
|
render() {
|
const { viewlost, config, loading } = this.state
|
|
return (
|
<div className={'pop-page-wrap ' + (loading ? 'loading' : '')} style={config ? config.style : null}>
|
{loading ? <Spin className="view-spin" size="large" /> : null}
|
<Row className="component-wrap">{this.getComponents()}</Row>
|
{viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
|
</div>
|
)
|
}
|
}
|
|
export default CustomPage
|