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 md5 from 'md5'
|
|
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 Invoice = asyncComponent(() => import('./components/module/invoice'))
|
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 DeepSeek = asyncComponent(() => import('@/tabviews/zshare/deepseek'))
|
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,
|
noParam: false
|
}
|
|
stepInter = null
|
|
/**
|
* @description 获取页面配置信息
|
*/
|
async loadconfig () {
|
const { MenuID, MenuName, param } = this.props
|
const { noParam } = this.state
|
|
let _param = {
|
func: 'sPC_Get_LongParam',
|
MenuID: MenuID
|
}
|
|
if (window.GLOB.mkHS) {
|
_param.lang = 'zh-CN'
|
}
|
|
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 && 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 tbMap = new Map()
|
let skip = config.permission === 'false' || window.GLOB.mkHS
|
let urlparam = {} // url参数
|
if (param) {
|
if (!noParam) {
|
Object.keys(param).forEach(key => {
|
if (/^\$/.test(key)) {
|
urlparam[key] = param[key]
|
} else {
|
urlparam[key.toLowerCase()] = param[key]
|
}
|
})
|
} else {
|
urlparam.$BID = param.$BID
|
}
|
}
|
|
if (config.urlFields && config.urlFields.length) {
|
config.urlFields.forEach(field => {
|
let key = field.toLowerCase()
|
if (urlparam[key] !== undefined) return
|
|
urlparam[key] = ''
|
})
|
}
|
|
window.GLOB.CacheData.set(MenuID, urlparam)
|
|
if (window.backend && config.allSqls) {
|
let keys = Object.keys(urlparam)
|
config.allSqls.forEach(item => {
|
item.id = md5(window.GLOB.appkey + item.v_id)
|
if (['datasource', 'interface', 'excelOut'].includes(item.type)) {
|
item.urlkeys = keys
|
item.urlparam = urlparam
|
if (config.flow_code) {
|
item.works_flow_code = config.flow_code
|
}
|
}
|
window.GLOB.CacheData.set('sql_' + item.uuid, item)
|
})
|
}
|
|
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 = `'${urlparam[field.toLowerCase()]}'`
|
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.MenuName)
|
config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, balMap, tbMap, skip, urlparam, MenuID, config.$cache, config.$time, config.MenuName, MenuID, MenuID, config.process === 'true', regs)
|
|
let params = []
|
let BID = urlparam.$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
|
|
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, config.interfaces, balMap, tbMap, BID)
|
|
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, tbMap, skip, urlparam, pageId, cache, time, MenuName, searchId, syncId, process, regs) => {
|
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 || '')]
|
}
|
}
|
|
tab.$menuname = (MenuName || '') + '-' + (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 = 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, tbMap, skip, urlparam, pageId, cache, time, MenuName, _searchId, tab.uuid, process, 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, permAction, balMap, tbMap, skip, urlparam, pageId, cache, time, MenuName, searchId, syncId, process, regs)
|
|
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.subtype === 'tablecard') { // 兼容
|
item.type = 'card'
|
}
|
|
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 = ''
|
}
|
} else if (item.type === 'search') {
|
if (item.wrap.supModule) {
|
item.wrap.supModule = item.wrap.supModule.pop()
|
}
|
}
|
|
// 搜索条件初始化
|
if (item.search) {
|
Utils.initSearchVal(item)
|
|
if (urlparam.$searchkey) {
|
let reg = new RegExp('(^|,)' + urlparam.$searchkey + '($|,)', 'ig')
|
item.search.forEach(cell => {
|
if (reg.test(cell.field) && ['text', 'select', 'link', 'checkcard'].includes(cell.type)) {
|
cell.initval = urlparam.$searchval
|
}
|
})
|
}
|
|
item.$searches = Utils.initMainSearch(item.search)
|
|
if (item.type === 'search' && item.wrap.supModule) {
|
if (!item.checkBid) {
|
item.wrap.supModule = ''
|
} else {
|
window.GLOB.SearchBox.set(item.$searchId + 'checkBid', true)
|
}
|
}
|
}
|
|
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] || cell.permission === 'false'
|
})
|
}
|
|
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') 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] || cell.permission === 'false'
|
} 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.sync = 'false'
|
item.setting.tableMode = 'compatible'
|
item.setting.extendTime = moment().format('YYYY-MM-DD HH:mm:ss')
|
item.colsCtrls = null
|
}
|
|
if (item.wrap.tree === 'true') {
|
item.setting.sync = 'false'
|
item.$cache = false
|
item.setting.$tree = true
|
}
|
|
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') {
|
if (item.wrap.datatype === 'public') {
|
balMap.set(item.wrap.publicId + 'public', true)
|
}
|
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] || cell.permission === 'false'
|
})
|
|
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] || cell.permission === 'false'
|
})
|
})
|
} 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') 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] || cell.permission === 'false'
|
})
|
} 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)
|
|
if (group.subButton.linkmenu) {
|
if (Array.isArray(group.subButton.linkmenu) && group.subButton.linkmenu.length > 0) {
|
group.subButton.openmenu = group.subButton.linkmenu
|
}
|
delete group.subButton.linkmenu
|
}
|
|
if (item.$cache && item.$time) { // 表单缓存
|
group.$cache = item.$cache
|
group.$time = item.$time
|
}
|
|
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 = ''
|
}
|
}
|
|
// 整理数据源
|
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 (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 = false
|
|
if (/order\s+by\s+sort_id\s*$/i.test(item.setting.dataresource)) {
|
item.setting.custompage = true
|
} else if (item.setting.$tree || /@pageSize@|@orderBy@|@mk_total/i.test(item.setting.dataresource + item.setting.customScript)) {
|
item.setting.custompage = true
|
}
|
|
if (/\s/.test(item.setting.dataresource)) {
|
item.setting.dataresource = '(' + item.setting.dataresource + ') tb'
|
}
|
|
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' && !_tailScript) {
|
|
} 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) => {
|
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.$menuname
|
} else if (cell.OpenType === 'pop' && cell.modal) {
|
if (item.$cache && item.$time) {
|
cell.modal.$cache = item.$cache
|
cell.modal.$time = item.$time
|
}
|
cell.modal.uuid = cell.uuid + '_pop'
|
}
|
|
if (cell.verify) {
|
let isStatic = item.wrap && (item.wrap.datatype === 'static' || item.wrap.datatype === 'public')
|
if (cell.verify.invalid === 'true') {
|
if (isStatic) {
|
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.uniques && cell.verify.uniques.length > 0 && cell.Ot === 'requiredOnce' && isStatic) {
|
cell.verify.uniques = []
|
}
|
|
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 (window.backend && window.GLOB.CacheData.has('sql_' + cell.uuid) && !/\$backend/.test(script)) {
|
window.GLOB.CacheData.delete('sql_' + cell.uuid)
|
}
|
}
|
if (/#position-outer/.test(script)) {
|
cell.$outerScript = script
|
}
|
if (/#position-callback/.test(script)) {
|
cell.$callbackScript = script
|
|
if (window.backend && window.GLOB.CacheData.has('sql_back_' + cell.uuid) && !/\$backend/.test(script)) {
|
window.GLOB.CacheData.delete('sql_back_' + cell.uuid)
|
}
|
}
|
}
|
}
|
|
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 => {
|
if (Array.isArray(m)) return m.pop() || ''
|
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.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, interfaces, balMap, tbMap, BID) => {
|
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, interfaces, balMap, tbMap, BID)
|
tab = {...tab, ...inherit}
|
return tab
|
})
|
return component
|
} else if (component.type === 'group') {
|
component.components = this.formatSetting(component.components, params, null, interfaces, balMap, tbMap, BID)
|
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 {
|
let inter = interfaces.filter(int => component.wrap.publicId === int.uuid)[0]
|
if (!inter) {
|
component.wrap.datatype = 'static'
|
} else {
|
component.setting = {...inter.setting}
|
component.$searchId = inter.$searchId
|
}
|
}
|
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 (window.GLOB.SearchBox.has(component.$searchId + 'checkBid')) {
|
component.checkBid = true
|
component.setting.checkBid = true
|
}
|
}
|
}
|
|
if (component.setting.interType !== 'system') return component
|
|
component.setting.uuid = component.uuid
|
|
// 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 {
|
let backend = false
|
if (window.backend && params.length === 0 && window.GLOB.CacheData.has('sql_' + component.uuid)) {
|
backend = true
|
} else if (window.backend && params[0] && params[0].exps) {
|
backend = true
|
}
|
if (backend && !window.GLOB.CacheData.has('sql_' + component.uuid)) {
|
component.setting.sync = 'false'
|
} else {
|
params.push(getStructDefaultParam(component, searchlist, params.length === 0, BID))
|
}
|
}
|
}
|
}
|
|
component.setting.delay = delay + (component.setting.delay || 0)
|
delay += 20
|
|
return component
|
})
|
}
|
|
// 格式化默认设置
|
formatInterSetting = (inters, regs, MenuID, initInters, MenuName) => {
|
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.setting.delay || 0)
|
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.laypage = false
|
inter.setting.$top = true
|
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
|
|
inter.setting.uuid = inter.uuid
|
|
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 = (MenuName || '') + '-公共数据源-' + inter.setting.name
|
inter.setting.execute = inter.setting.execute !== 'false'
|
|
if (!inter.setting.execute) {
|
inter.setting.dataresource = ''
|
}
|
|
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 = false
|
|
if (/order\s+by\s+sort_id\s*$/i.test(inter.setting.dataresource)) {
|
inter.setting.custompage = true
|
} else if (/@pageSize@|@orderBy@|@mk_total/i.test(inter.setting.dataresource + inter.setting.customScript)) {
|
inter.setting.custompage = true
|
}
|
|
if (/\s/.test(inter.setting.dataresource)) {
|
inter.setting.dataresource = '(' + inter.setting.dataresource + ') tb'
|
}
|
|
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) {
|
let uuid = params[0].uuid || ''
|
if (params[0].id) {
|
uuid = window.GLOB.CacheData.get('first_' + params[0].id) || ''
|
}
|
Api.getLCacheConfig(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.dataName] || ''
|
if (_data && !Array.isArray(_data)) {
|
_data = [_data]
|
}
|
window.GLOB.SyncData.set(item.dataName, _data)
|
})
|
|
MKEmitter.emit('transferSyncData', MenuID)
|
} else {
|
MKEmitter.emit('transferSyncData', MenuID)
|
|
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
|
})
|
}
|
}
|
})
|
}
|
|
reloadMenuView = (menuId, clear) => {
|
const { MenuID } = this.props
|
|
if (MenuID !== menuId) return
|
|
this.reloadview(clear)
|
}
|
|
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 = (clear) => {
|
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,
|
noParam: clear === true
|
}, () => {
|
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 (
|
<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 === '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 === 'module' && item.subtype === 'invoice') {
|
return (
|
<Col span={item.width} style={style} key={item.uuid}>
|
<Invoice 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} />
|
<DeepSeek/>
|
</div>
|
</div>
|
)
|
}
|
}
|
|
export default CustomPage
|