| | |
| | | import PropTypes from 'prop-types' |
| | | import { is, fromJS } from 'immutable' |
| | | import { notification, Spin, Row, Col } from 'antd' |
| | | import md5 from 'md5' |
| | | |
| | | import Api from '@/api' |
| | | import Utils from '@/utils/utils.js' |
| | |
| | | // 通用组件 |
| | | const AntvTabs = asyncComponent(() => import('@/tabviews/custom/components/tabs/antv-tabs')) |
| | | const MkBaseTable = asyncComponent(() => import('@/tabviews/custom/components/table/base-table')) |
| | | const FlowFloat = asyncComponent(() => import('@/tabviews/zshare/flowFloat')) |
| | | const SettingComponent = asyncComponent(() => import('@/tabviews/zshare/settingcomponent')) |
| | | const TableNodes = asyncComponent(() => import('@/tabviews/zshare/tablenodes')) |
| | | const DeepSeek = asyncComponent(() => import('@/tabviews/zshare/deepseek')) |
| | | const AutoMatic = asyncComponent(() => import('@/tabviews/zshare/automatic')) |
| | | const DebugTable = asyncComponent(() => import('@/tabviews/debugtable')) |
| | | |
| | |
| | | lostmsg: '', // 页面丢失时的提示信息 |
| | | config: null, // 页面配置信息,包括组件等 |
| | | userConfig: null, // 用户自定义设置 |
| | | loading: false, // 列表数据加载中 |
| | | visible: false, // 标签页控制 |
| | | shortcuts: null, // 快捷键 |
| | | autoMatic: null |
| | | autoMatic: null, |
| | | noParam: false |
| | | } |
| | | |
| | | /** |
| | | * @description 获取页面配置信息 |
| | | */ |
| | | async loadconfig () { |
| | | const { MenuID, MenuName } = this.props |
| | | 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) |
| | |
| | | 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) { |
| | | 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 && !window.GLOB.mkHS) { |
| | | if (result.LongParamUser) { |
| | | try { // 配置信息解析 |
| | | let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) |
| | | if (userConfig) { |
| | | shortcuts = userConfig.action |
| | | userConfig.printers.forEach(item => { |
| | | shortcuts = userConfig.action || [] |
| | | userConfig.printers && userConfig.printers.forEach(item => { |
| | | window.GLOB.UserCacheMap.set(item.parentId + item.uuid, item) |
| | | }) |
| | | } |
| | |
| | | // 权限过滤 |
| | | let roleId = sessionStorage.getItem('role_id') || '' // 角色ID |
| | | let skip = window.GLOB.mkHS |
| | | let param = this.props.param || {} // url参数 |
| | | 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 |
| | | } |
| | | } |
| | | |
| | | window.GLOB.CacheData.set(MenuID, param) |
| | | 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') || '' |
| | |
| | | } |
| | | if (config.urlFields) { |
| | | config.urlFields.forEach(field => { |
| | | let val = `'${param[field] || ''}'` |
| | | let val = `'${urlparam[field.toLowerCase()]}'` |
| | | regs.push({ |
| | | reg: new RegExp('@' + field + '@', 'ig'), |
| | | value: val |
| | |
| | | }) |
| | | } |
| | | |
| | | config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, skip, param, MenuID, config.MenuName) |
| | | if (config.flow_code) { |
| | | regs.push({ reg: /@works_flow_code@/ig, value: `'${config.flow_code}'` }) |
| | | } |
| | | |
| | | config.components = this.filterComponent(config.components, roleId, window.GLOB.mkActions, skip, urlparam, MenuID, config.MenuName, config.process === 'true') |
| | | |
| | | let autoMatic = null |
| | | if (config.autoMatic && config.autoMatic.enable === 'true') { |
| | |
| | | } |
| | | }) |
| | | } |
| | | |
| | | |
| | | // 获取主搜索条件 |
| | | config.components.forEach(component => { |
| | | if (component.type === 'tabs') return |
| | | |
| | | if (param.$searchkey) { |
| | | component.search = component.search.map(item => { |
| | | if (['text', 'select', 'link'].includes(item.type) && param.$searchkey === item.field) { |
| | | item.initval = param.$searchval |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | | component.$searches = Utils.initMainSearch(component.search) |
| | | } |
| | | |
| | | if (component.$searches.length) { |
| | | component.$main = true |
| | |
| | | } |
| | | }) |
| | | |
| | | let BID = param.$BID || '' |
| | | let BID = urlparam.$BID || '' |
| | | |
| | | config.components = this.formatSetting(config.components, regs) |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | filterComponent = (components, roleId, permAction, skip, urlparam, pageId, MenuName) => { |
| | | filterComponent = (components, roleId, permAction, skip, urlparam, pageId, MenuName, process) => { |
| | | return components.filter(item => { |
| | | item.$pageId = pageId |
| | | item.$searchId = pageId |
| | | |
| | | if (process) { |
| | | item.$process = process |
| | | item.$flowId = 'flow' + this.props.MenuID |
| | | } |
| | | |
| | | item.$menuname = (MenuName || '') + '-' + (item.name || '主表') |
| | | |
| | |
| | | if (tab.permission !== 'true') { // 权限未开启不做权限控制 |
| | | skip = true |
| | | } |
| | | tab.components = this.filterComponent(tab.components, roleId, permAction, skip, urlparam, pageId, MenuName) |
| | | tab.components = this.filterComponent(tab.components, roleId, permAction, skip, urlparam, pageId, MenuName, process) |
| | | return tab |
| | | }) |
| | | |
| | |
| | | } else { |
| | | item.name = (MenuName || '') |
| | | } |
| | | |
| | | // 搜索条件初始化 |
| | | Utils.initSearchVal(item) |
| | | |
| | | item.$searches = Utils.initMainSearch(item.search) |
| | | |
| | | if (item.setting.supModule) { |
| | | let pid = item.setting.supModule.pop() |
| | |
| | | item.setting.supModule = '' |
| | | } |
| | | } |
| | | |
| | | // 搜索条件初始化 |
| | | 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) |
| | | |
| | | let statFields = [] |
| | | let getCols = (cols) => { |
| | |
| | | col.type = 'custom' |
| | | } |
| | | |
| | | if (col.type === 'number') { |
| | | if (col.type === 'index') { |
| | | col.field = '$Index' |
| | | col.type = 'text' |
| | | } else if (col.type === 'number') { |
| | | if (col.sum === 'true') { |
| | | statFields.push(col) |
| | | } |
| | |
| | | cell = this.getPrinter(cell, item.uuid) |
| | | } |
| | | |
| | | return skip || permAction[cell.uuid] |
| | | return skip || permAction[cell.uuid] || cell.permission === 'false' |
| | | } else if (['text', 'number', 'formula'].includes(cell.eleType)) { |
| | | if (!cell.height) { |
| | | cell.innerHeight = 'auto' |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | 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 (cell.marks && cell.marks.length === 0) { |
| | | cell.marks = null |
| | | } |
| | | if (cell.anchors && cell.anchors.length === 0) { |
| | | cell.anchors = null |
| | | } |
| | | |
| | | return true |
| | | }) |
| | | |
| | |
| | | |
| | | if (col.linkmenu && col.linkmenu.length > 0) { |
| | | let menu_id = col.linkmenu.pop() |
| | | col.linkThdMenu = window.GLOB.mkThdMenus.filter(m => m.MenuID === menu_id)[0] || '' |
| | | col.linkThdMenu = window.GLOB.mkThdMenus.get(menu_id) || '' |
| | | } else { |
| | | col.linkThdMenu = '' |
| | | } |
| | | |
| | | if (col.marks && col.marks.length === 0) { |
| | | col.marks = null |
| | | } |
| | | |
| | | return true |
| | |
| | | cell = this.getPrinter(cell, item.uuid) |
| | | } |
| | | |
| | | return skip || permAction[cell.uuid] |
| | | return skip || permAction[cell.uuid] || cell.permission === 'false' |
| | | }) |
| | | } |
| | | |
| | |
| | | cell.$MenuID = this.props.MenuID |
| | | cell.$view = 'popview' |
| | | |
| | | if (item.$process) { |
| | | cell.$process = true |
| | | cell.$flowId = 'flow' + this.props.MenuID |
| | | } |
| | | |
| | | if (cell.controlField) { |
| | | if (/,/ig.test(cell.controlVal)) { |
| | | cell.controlVals = cell.controlVal.split(',') |
| | |
| | | } |
| | | |
| | | if (cell.OpenType === 'excelOut') { // 导出 |
| | | cell.$menuName = item.name |
| | | cell.$menuName = item.$menuname |
| | | } else if (cell.OpenType === 'pop' && cell.modal) { |
| | | cell.modal.uuid = cell.uuid + '_pop' |
| | | } |
| | | |
| | | if (!cell.verify || !cell.verify.columns || cell.verify.columns.length === 0) { |
| | | cell.errorType = 'error1' |
| | | } else if (cell.intertype === 'system' && cell.verify.dataType !== 'custom' && item.setting.interType !== 'system') { |
| | | cell.errorType = 'error2' |
| | | if (cell.verify) { |
| | | if (cell.verify.invalid === 'true') { |
| | | 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 (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) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | } else if (cell.syncComponentId === 'multiComponent') { |
| | | let ids = cell.syncComponents.map(m => { |
| | | if (Array.isArray(m)) return m.pop() || '' |
| | | return m.syncComId.pop() || '' |
| | | }) |
| | | |
| | |
| | | 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 (component.setting.interType !== 'system') { // 不使用系统函数时 |
| | | component.setting.sync = 'false' |
| | | component.setting.dataresource = '' |
| | | component.setting.laypage = component.setting.laypage === 'true' |
| | | return component |
| | | } |
| | | |
| | | component.setting.uuid = component.uuid |
| | | |
| | | let _customScript = '' |
| | | let _tailScript = '' |
| | | component.scripts && component.scripts.forEach(script => { |
| | | if (script.status !== 'false') { |
| | | if (script.status === 'false') return |
| | | if (script.position !== 'back') { |
| | | _customScript += ` |
| | | ${script.sql} |
| | | ` |
| | | } else { |
| | | _tailScript += ` |
| | | ${script.sql} |
| | | ` |
| | | } |
| | |
| | | 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 = false |
| | | |
| | | if (component.setting.laypage) { |
| | | component.setting.custompage = /@pageSize@/i.test(component.setting.dataresource + component.setting.customScript) |
| | | if (/order\s+by\s+sort_id\s*$/i.test(component.setting.dataresource)) { |
| | | component.setting.custompage = true |
| | | } else if (/@pageSize@|@orderBy@|@mk_total/i.test(component.setting.dataresource + component.setting.customScript)) { |
| | | component.setting.custompage = true |
| | | } |
| | | |
| | | component.setting.delay = delay |
| | | if (/\s/.test(component.setting.dataresource)) { |
| | | component.setting.dataresource = '(' + component.setting.dataresource + ') tb' |
| | | } |
| | | |
| | | if (!component.setting.execute || component.setting.custompage) { |
| | | component.forbidLine = true |
| | | } |
| | | |
| | | component.setting.delay = delay + (component.setting.delay || 0) |
| | | delay += 20 |
| | | |
| | | return component |
| | | }) |
| | | } |
| | | |
| | | reloadMenuView = (menuId) => { |
| | | reloadMenuView = (menuId, clear) => { |
| | | const { MenuID } = this.props |
| | | |
| | | if (MenuID !== menuId) return |
| | | |
| | | this.reloadview() |
| | | this.reloadview(clear) |
| | | } |
| | | |
| | | resetActiveMenu = (menuId) => { |
| | |
| | | }) |
| | | } |
| | | |
| | | reloadview = () => { |
| | | reloadview = (clear) => { |
| | | window.GLOB.CacheData.delete(this.props.MenuID) |
| | | if (this.state.config) { |
| | | this.deleteCache(this.state.config.components) |
| | |
| | | loadingview: true, // 页面加载中 |
| | | viewlost: false, // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用 |
| | | config: null, // 页面配置信息,包括组件等 |
| | | loading: false, // 列表数据加载中 |
| | | shortcuts: null, |
| | | noParam: clear === true |
| | | }, () => { |
| | | this.loadconfig() |
| | | }) |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { loadingview, viewlost, config, loading, shortcuts, autoMatic } = this.state |
| | | const { loadingview, viewlost, config, shortcuts, autoMatic } = this.state |
| | | |
| | | if (!config || viewlost) { |
| | | return ( |
| | | <div className="custom-table-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-table-wrap ' + (loadingview || loading ? 'loading' : '')} id={this.state.ContainerId} style={config ? config.style : null}> |
| | | {(loadingview || loading) ? <Spin className="view-spin" size="large" /> : null} |
| | | <div className="custom-table-wrap" id={this.state.ContainerId} style={config.style}> |
| | | <Row className="component-wrap">{this.getComponents()}</Row> |
| | | {config && window.GLOB.breakpoint ? <DebugTable /> : null} |
| | | {!window.GLOB.mkHS && config && autoMatic ? <AutoMatic autoMatic={autoMatic} tabId={config.MenuID} config={config.components[0]} /> : null} |
| | | {!window.GLOB.mkHS && window.GLOB.systemType !== 'production' ? <TableNodes config={config} /> : null} |
| | | {!window.GLOB.mkHS && config ? <SettingComponent config={config} shortcuts={shortcuts || []}/> : null} |
| | | {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} |
| | | {window.GLOB.breakpoint ? <DebugTable /> : null} |
| | | <div className="user-tools"> |
| | | {autoMatic ? <AutoMatic autoMatic={autoMatic} tabId={config.MenuID} config={config.components[0]} /> : null} |
| | | {config.process === 'true' ? <FlowFloat config={config}/> : null} |
| | | <SettingComponent config={config} shortcuts={shortcuts || []}/> |
| | | <TableNodes config={config} /> |
| | | <DeepSeek/> |
| | | </div> |
| | | </div> |
| | | ) |
| | | } |