| | |
| | | import React, {Component} from 'react' |
| | | import PropTypes from 'prop-types' |
| | | import {connect} from 'react-redux' |
| | | import { is, fromJS } from 'immutable' |
| | | import { notification, Spin, Tabs, Icon, Switch, Row, Col } from 'antd' |
| | | import { notification, Spin, Tabs, Switch, Row, Col, Modal } from 'antd' |
| | | |
| | | import Api from '@/api' |
| | | import zhCN from '@/locales/zh-CN/main.js' |
| | | import enUS from '@/locales/en-US/main.js' |
| | | import Utils from '@/utils/utils.js' |
| | | import options from '@/store/options.js' |
| | | import UtilsDM from '@/utils/utils-datamanage.js' |
| | | import { updateCommonTable } from '@/utils/utils-update.js' |
| | | import asyncComponent from '@/utils/asyncComponent' |
| | | import asyncSpinComponent from '@/utils/asyncSpinComponent' |
| | | import MkIcon from '@/components/mk-icon' |
| | | import MKEmitter from '@/utils/events.js' |
| | | import NotFount from '@/components/404' |
| | | import './index.scss' |
| | |
| | | const SubTable = asyncSpinComponent(() => import('@/tabviews/subtable')) |
| | | const CardComponent = asyncSpinComponent(() => import('@/tabviews/zshare/cardcomponent')) |
| | | const ChartComponent = asyncSpinComponent(() => import('@/tabviews/zshare/chartcomponent')) |
| | | const PagemsgComponent = asyncComponent(() => import('@/tabviews/zshare/pageMessage')) |
| | | const AutoMatic = asyncComponent(() => import('@/tabviews/zshare/automatic')) |
| | | const DebugTable = asyncComponent(() => import('@/tabviews/debugtable')) |
| | | |
| | | const { TabPane } = Tabs |
| | | |
| | |
| | | param: PropTypes.any, // 其他页面传递的搜索条件等参数 |
| | | MenuID: PropTypes.string, // 菜单Id |
| | | MenuNo: PropTypes.string, // 菜单参数 |
| | | MenuName: PropTypes.string // 菜单名称 |
| | | MenuName: PropTypes.string, // 菜单名称 |
| | | changeTemp: PropTypes.func |
| | | } |
| | | |
| | | state = { |
| | | dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS, |
| | | ContainerId: Utils.getuuid(), // 菜单外层html Id |
| | | BID: null, // 页面跳转时携带ID |
| | | loadingview: true, // 页面加载中 |
| | |
| | | lostmsg: '', // 页面丢失时的提示信息 |
| | | config: {}, // 页面配置信息,包括按钮、搜索、显示列、标签等 |
| | | shortcuts: null, // 快捷键 |
| | | searchlist: null, // 搜索条件 |
| | | actions: null, // 按钮集 |
| | | columns: null, // 显示列 |
| | | arr_field: '', // 使用 sPC_Get_TableData 时的查询字段集 |
| | | setting: null, // 页面全局设置:数据源、按钮及显示列固定、主键等 |
| | | data: [], // 列表数据集 |
| | | selectedData: [], // 已选表格数据 |
| | |
| | | statFields: [], // 合计字段 |
| | | statFValue: [], // 合计值 |
| | | absFields: [], // 绝对值字段 |
| | | loadCustomApi: true, // 加载外部资源 |
| | | hasReqFields: false, |
| | | autoMatic: null |
| | | autoMatic: null, |
| | | visible: false |
| | | } |
| | | |
| | | /** |
| | | * @description 获取页面配置信息 |
| | | */ |
| | | async loadconfig () { |
| | | const { permAction, permMenus, param, MenuName, MenuID } = this.props |
| | | const { param, MenuName, MenuID } = this.props |
| | | |
| | | let _param = { |
| | | func: 'sPC_Get_LongParam', |
| | |
| | | |
| | | try { // 配置信息解析 |
| | | config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam))) |
| | | config.MenuID = MenuID |
| | | config.MenuName = MenuName |
| | | config.setting.MenuName = MenuName |
| | | config.setting.$name = MenuName |
| | | } catch (e) { |
| | | console.warn('Parse Failure') |
| | | config = '' |
| | | } |
| | | |
| | | // 页面配置解析错误时提示 |
| | | if (!config) { |
| | | this.setState({ |
| | | loadingview: false, |
| | | viewlost: true |
| | | }) |
| | | return |
| | | } |
| | | |
| | | // 页面未启用时,显示未启用页面 |
| | | if (!config.enabled) { |
| | | this.setState({ |
| | | loadingview: false, |
| | | viewlost: true, |
| | | lostmsg: '抱歉,您访问的页面未启用,请联系管理员。' |
| | | }) |
| | | return |
| | | } |
| | | |
| | | // 模板错误 |
| | | if (config.Template === 'BaseTable' || config.Template === 'CustomPage') { |
| | | this.props.changeTemp(MenuID, config.Template) |
| | | return |
| | | } |
| | | |
| | | // HS不使用自定义设置 |
| | | if (result.LongParamUser && this.props.menuType !== 'HS') { |
| | | if (result.LongParamUser) { |
| | | try { // 配置信息解析 |
| | | let userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser))) |
| | | if (userConfig && !userConfig.version) { |
| | |
| | | }) |
| | | }) |
| | | } else 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) |
| | | }) |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | // 页面配置解析错误时提示 |
| | | if (!config) { |
| | | this.setState({ |
| | | loadingview: false, |
| | | viewlost: true |
| | | }) |
| | | return |
| | | } |
| | | |
| | | // 页面未启用时,显示未启用页面 |
| | | if (!config.enabled) { |
| | | this.setState({ |
| | | loadingview: false, |
| | | viewlost: true, |
| | | lostmsg: this.state.dict['main.view.unenabled'] |
| | | }) |
| | | return |
| | | } |
| | | // 信息初始化赋值 |
| | | config.MenuID = MenuID |
| | | config.MenuName = MenuName |
| | | config.setting.MenuName = MenuName |
| | | config.setting.$name = MenuName |
| | | |
| | | // 版本兼容 |
| | | config = updateCommonTable(config) |
| | | |
| | | // 权限过滤 |
| | | if (this.props.menuType !== 'HS') { |
| | | config.action = config.action.filter(item => permAction[item.uuid]) |
| | | if (!window.GLOB.mkHS) { |
| | | config.action = config.action.filter(item => item.hidden !== 'true' && window.GLOB.mkActions[item.uuid]) |
| | | config.tabgroups.forEach(group => { |
| | | group.sublist = group.sublist.filter(tab => { |
| | | if (tab.supMenu === 'mainTable') { |
| | | tab.supMenu = MenuID |
| | | } |
| | | return permAction[tab.linkTab] |
| | | tab.ContainerId = this.state.ContainerId |
| | | |
| | | // return window.GLOB.mkActions[tab.linkTab] |
| | | return tab |
| | | }) |
| | | }) |
| | | } else { |
| | | config.action = config.action.filter(item => item.hidden !== 'true') |
| | | config.tabgroups.forEach(group => { |
| | | group.sublist = group.sublist.map(tab => { |
| | | if (tab.supMenu === 'mainTable') { |
| | | tab.supMenu = MenuID |
| | | } |
| | | tab.ContainerId = this.state.ContainerId |
| | | |
| | | return tab |
| | | }) |
| | | }) |
| | |
| | | config.tabgroups = config.tabgroups.filter(group => group.sublist.length > 0) |
| | | |
| | | let roleId = sessionStorage.getItem('role_id') || '' // 角色ID |
| | | // 视图权限 |
| | | config.charts = config.charts.filter(item => { |
| | | if (item.Hide === 'true') return false |
| | | if (!item.blacklist || item.blacklist.length === 0) return true |
| | | return item.blacklist.filter(v => roleId.indexOf(v) > -1).length === 0 |
| | | }) |
| | | |
| | | if (config.charts.length <= 1) { |
| | | config.expand = true |
| | | let chartId = '' |
| | | |
| | | if (config.charts) { |
| | | // 视图权限 |
| | | config.charts = config.charts.filter(item => { |
| | | if (item.Hide === 'true') return false |
| | | if (!item.blacklist || item.blacklist.length === 0) return true |
| | | return item.blacklist.filter(v => roleId.indexOf(v) > -1).length === 0 |
| | | }) |
| | | |
| | | if (config.charts.length <= 1) { |
| | | config.expand = true |
| | | } |
| | | chartId = config.charts[0] ? config.charts[0].uuid : '' |
| | | } |
| | | let chartId = config.charts[0] ? config.charts[0].uuid : '' |
| | | |
| | | config.search = Utils.initSearchVal(config.search) |
| | | Utils.initSearchVal(config) |
| | | |
| | | // 字段透视及必填标志 |
| | | let hasReqFields = false |
| | | config.search = config.search.map(item => { |
| | | if (['text', 'select', 'link'].includes(item.type) && param && param.$searchkey === item.field) { |
| | | if (['text', 'select', 'link', 'checkcard'].includes(item.type) && param && param.$searchkey === item.field.toLowerCase()) { |
| | | item.initval = param.$searchval |
| | | } |
| | | |
| | | if (item.required) { |
| | | hasReqFields = true |
| | | } |
| | | |
| | | return item |
| | | }) |
| | | |
| | |
| | | |
| | | // 标记主页面,用于按钮固定及表单挂载设置 |
| | | config.setting.tabType = 'main' |
| | | config.setting.ContainerId = this.state.ContainerId |
| | | |
| | | // 数据源信息预处理 |
| | | config.setting.laypage = config.setting.laypage !== 'false' // 是否分页,转为boolean 统一格式 |
| | |
| | | config.setting.customScript = '' // 自定义脚本 |
| | | config.setting.dataresource = config.setting.dataresource || '' |
| | | |
| | | if (config.setting.interType === 'system' || (config.setting.interType === 'custom' && config.setting.requestMode === 'system')) { |
| | | if (config.setting.interType === 'system') { |
| | | if (config.setting.scripts && config.setting.scripts.length > 0) { |
| | | let _customScript = '' |
| | | config.setting.scripts.forEach(item => { |
| | |
| | | } |
| | | |
| | | if (sessionStorage.getItem('dataM') === 'true') { // 数据权限 |
| | | config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*') |
| | | config.setting.dataresource = config.setting.dataresource.replace(/@\$/ig, '*/') |
| | | config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*') |
| | | config.setting.customScript = config.setting.customScript.replace(/@\$/ig, '*/') |
| | | config.setting.dataresource = config.setting.dataresource.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/') |
| | | config.setting.customScript = config.setting.customScript.replace(/\$@/ig, '/*').replace(/@\$/ig, '*/') |
| | | } else { |
| | | config.setting.dataresource = config.setting.dataresource.replace(/@\$|\$@/ig, '') |
| | | config.setting.customScript = config.setting.customScript.replace(/@\$|\$@/ig, '') |
| | |
| | | |
| | | let userName = sessionStorage.getItem('User_Name') || '' |
| | | let fullName = sessionStorage.getItem('Full_Name') || '' |
| | | let city = sessionStorage.getItem('city') || '' |
| | | |
| | | if (sessionStorage.getItem('isEditState') === 'true') { |
| | | userName = sessionStorage.getItem('CloudUserName') || '' |
| | | fullName = sessionStorage.getItem('CloudFullName') || '' |
| | | } |
| | | |
| | | let regs = [ |
| | | { reg: /@userName@/ig, value: `'${userName}'` }, |
| | | { reg: /@fullName@/ig, value: `'${fullName}'` }, |
| | | { reg: /@login_city@/ig, value: `'${city}'` } |
| | | { reg: /@fullName@/ig, value: `'${fullName}'` } |
| | | ] |
| | | |
| | | regs.forEach(cell => { |
| | |
| | | config.setting.customScript = config.setting.customScript.replace(reg, val) |
| | | }) |
| | | } |
| | | } else { |
| | | config.setting.dataresource = '' |
| | | } |
| | | |
| | | let _arrField = [] // 字段集 |
| | |
| | | |
| | | let _actions = [] // 工具栏按钮 |
| | | let _operations = [] // 操作列按钮(存在时) |
| | | let colors = { primary: '#1890ff', yellow: '#c49f47', orange: 'orange', danger: '#ff4d4f', green: '#26C281', dgreen: '#32c5d2', purple: '#8E44AD', cyan: '#13c2c2', gray: '#E7E7EF', default: 'rgba(0, 0, 0, 0.65)' } |
| | | |
| | | config.action.forEach(item => { |
| | | item.logLabel = MenuName + '-' + item.label // 用于sPC_TableData_InUpDe记录操作按钮 |
| | | item.$menuId = this.props.MenuID |
| | | item.$old = true |
| | | item.ContainerId = this.state.ContainerId |
| | | |
| | | if (item.OpenType === 'excelOut') { // 导出 |
| | | item.$menuName = MenuName |
| | | } |
| | | |
| | | if (item.verify && item.verify.invalid === 'true') { |
| | | if (item.sqlType === 'insert') { |
| | | item.verify.invalid = 'false' |
| | | } else if (item.Ot === 'notRequired') { |
| | | item.verify.invalid = 'false' |
| | | } else if (item.intertype !== 'system' && item.procMode !== 'system') { |
| | | item.verify.invalid = 'false' |
| | | } |
| | | } |
| | | |
| | | if (item.OpenType === 'funcbutton' && item.funcType === 'print' && item.verify) { // 打印机设置 |
| | | let _item = window.GLOB.UserCacheMap.get(this.props.MenuID + item.uuid) |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | if (item.controlField) { |
| | | if (/,/ig.test(item.controlVal)) { |
| | | item.controlVals = item.controlVal.split(',') |
| | | } else { |
| | | item.controlVals = [(item.controlVal || '')] |
| | | } |
| | | } |
| | | |
| | | item.show = 'button' |
| | | |
| | | let _c = item.class ? item.class.replace('border-', '') : '' |
| | | let color = colors[_c] || '#1890ff' |
| | | |
| | | if (item.position === 'toolbar') { |
| | | item.$toolbtn = true |
| | | |
| | | if (item.class === 'default') { |
| | | item.style = {color: 'rgba(0, 0, 0, 0.65)', backgroundColor: '#fff', borderColor: '#d9d9d9', marginRight: '15px'} |
| | | } else if (item.class.indexOf('border') > -1) { |
| | | item.style = {color: color, backgroundColor: '#fff', borderColor: color, marginRight: '15px'} |
| | | } else { |
| | | item.style = {color: item.class === 'gray' ? 'rgba(0, 0, 0, 0.65)' : '#fff', backgroundColor: color, borderColor: color, marginRight: '15px'} |
| | | } |
| | | |
| | | _actions.push(item) |
| | | } else if (item.position === 'grid') { |
| | | item.style = {color: color, backgroundColor: 'transparent', borderColor: 'transparent'} |
| | | _operations.push(item) |
| | | } |
| | | }) |
| | |
| | | |
| | | if (col.linkmenu && col.linkmenu.length > 0) { |
| | | let menu_id = col.linkmenu.slice(-1)[0] |
| | | col.linkThdMenu = permMenus.filter(m => m.MenuID === menu_id)[0] || '' |
| | | col.linkThdMenu = window.GLOB.mkThdMenus.get(menu_id) || '' |
| | | } else { |
| | | col.linkThdMenu = '' |
| | | } |
| | | |
| | | if (col.type === 'number') { |
| | | col.decimal = col.decimal || 0 |
| | | col.round = Math.pow(10, col.decimal) |
| | | |
| | | if (col.format === 'percent') { |
| | | col.decimal = col.decimal > 2 ? col.decimal - 2 : 0 |
| | | } |
| | | } |
| | | |
| | | col.nameField && _arrField.push(col.nameField) // 链接名字段 |
| | |
| | | config.setting.selected = 'false' |
| | | } else if (config.setting.selected === 'init' && config.setting.onload === 'false') { |
| | | config.setting.selected = 'false' |
| | | } else { |
| | | config.setting.orisel = true |
| | | } |
| | | |
| | | let autoMatic = null |
| | |
| | | }) |
| | | } |
| | | |
| | | if (config.setting.controlField) { |
| | | if (config.setting.controlVal) { |
| | | config.setting.controlVal = config.setting.controlVal.split(',') |
| | | } else { |
| | | config.setting.controlVal = [''] |
| | | } |
| | | } |
| | | |
| | | config.type = 'table' |
| | | config.wrap = { |
| | | show: config.setting.show || '', |
| | | float: config.setting.float || '', |
| | | advanceType: config.setting.advanceType || '', |
| | | advanceWidth: config.setting.advanceWidth || '', |
| | | drawerPlacement: config.setting.drawerPlacement || '', |
| | | searchRatio: config.setting.searchRatio || '', |
| | | searchLwidth: config.setting.searchLwidth, |
| | | borderRadius: config.setting.borderRadius, |
| | | resetContrl: config.setting.resetContrl, |
| | | } |
| | | |
| | | config.setting.arr_field = _arrField.join(',') |
| | | |
| | | this.setState({ |
| | | pageSize: config.setting.pageSize || 10, |
| | | loadingview: false, |
| | | absFields, |
| | | autoMatic, |
| | | chartId, |
| | | config, |
| | | statFields, |
| | | shortcuts, |
| | | shortcuts: shortcuts.length > 0 ? shortcuts : null, |
| | | setting: config.setting, |
| | | searchlist: config.search, |
| | | actions: _actions, |
| | | columns: _columns, |
| | | arr_field: _arrField.join(','), |
| | | BID: param && param.$BID ? param.$BID : '', |
| | | search: Utils.initMainSearch(config.search), |
| | | hasReqFields |
| | | search: Utils.initMainSearch(config.search) |
| | | }, () => { |
| | | if (config.setting.onload !== 'false') { // 初始化可加载 |
| | | this.loadData() |
| | |
| | | setShortcut = () => { |
| | | const { shortcuts } = this.state |
| | | |
| | | if (!shortcuts || shortcuts.length === 0) { |
| | | document.onkeydown = () => {} |
| | | return |
| | | } |
| | | |
| | | document.onkeydown = (event) => { |
| | | let e = event || window.event |
| | | let keyCode = e.keyCode || e.which || e.charCode |
| | |
| | | |
| | | 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) |
| | |
| | | } |
| | | } |
| | | |
| | | loadData = () => { |
| | | loadData = (id) => { |
| | | const { MenuID } = this.props |
| | | const { setting, search, loadCustomApi, hasReqFields, ContainerId } = this.state |
| | | const { setting, search, config, ContainerId } = this.state |
| | | |
| | | this.setState({ |
| | | selectedData: [] |
| | | }) |
| | | MKEmitter.emit('changeTableLine', ContainerId, MenuID, '', '') |
| | | |
| | | if (hasReqFields) { |
| | | if (config.$s_req) { |
| | | let requireFields = search.filter(item => item.required && item.value === '') |
| | | |
| | | if (requireFields.length > 0) { |
| | |
| | | } |
| | | } |
| | | |
| | | if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) { |
| | | if (setting.interType === 'custom') { |
| | | notification.warning({ |
| | | top: 92, |
| | | message: '未设置正式系统地址!', |
| | | message: '系统不在支持自定义接口!', |
| | | duration: 3 |
| | | }) |
| | | return |
| | | } |
| | | |
| | | if (setting.interType === 'custom' && loadCustomApi) { |
| | | if (setting.execTime === 'once') { |
| | | this.setState({loadCustomApi: false}) |
| | | } |
| | | |
| | | this.loadOutResource() |
| | | if (setting.execType === 'async') { |
| | | this.loadmaindata() |
| | | } |
| | | } else { |
| | | this.loadmaindata() |
| | | } |
| | | } |
| | | |
| | | loadOutResource = () => { |
| | | const { setting, search, BID } = this.state |
| | | |
| | | let param = UtilsDM.getPrevQueryParams(setting, search, BID, this.props.menuType) |
| | | |
| | | if (setting.execType === 'sync') { |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | } |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | if (res.mk_ex_invoke === 'false' || res.mk_ex_invoke === false) { |
| | | this.loadmaindata() |
| | | } else { |
| | | this.customOuterRequest(res) |
| | | } |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | }, () => { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | }) |
| | | } |
| | | |
| | | customOuterRequest = (result) => { |
| | | const { setting } = this.state |
| | | let url = '' |
| | | |
| | | if (window.GLOB.systemType === 'production') { |
| | | url = setting.proInterface |
| | | } else { |
| | | url = setting.interface |
| | | } |
| | | |
| | | let mkey = result.mk_api_key || '' |
| | | |
| | | delete result.mk_ex_invoke // 是否继续执行 |
| | | delete result.status |
| | | delete result.message |
| | | delete result.ErrCode |
| | | delete result.ErrMesg |
| | | delete result.mk_api_key // 当前请求的key值,用于回调 |
| | | |
| | | let param = {} |
| | | |
| | | Object.keys(result).forEach(key => { |
| | | key = key.replace(/^mk_/ig, '') |
| | | param[key] = result[key] |
| | | }) |
| | | |
| | | Api.directRequest(url, setting.method, param, setting.cross).then(res => { |
| | | if (typeof(res) !== 'object') { |
| | | let error = '未知的返回结果!' |
| | | |
| | | if (typeof(res) === 'string') { |
| | | error = res.replace(/'/ig, '"') |
| | | } |
| | | |
| | | let _result = { |
| | | mk_api_key: mkey, |
| | | $ErrCode: 'E', |
| | | $ErrMesg: error |
| | | } |
| | | |
| | | this.customCallbackRequest(_result) |
| | | } else { |
| | | if (Array.isArray(res)) { |
| | | res = { data: res } |
| | | } |
| | | res.mk_api_key = mkey |
| | | this.customCallbackRequest(res) |
| | | } |
| | | }, (e) => { |
| | | let _result = { |
| | | mk_api_key: mkey, |
| | | $ErrCode: 'E', |
| | | $ErrMesg: e && e.statusText ? e.statusText : '' |
| | | } |
| | | |
| | | this.customCallbackRequest(_result) |
| | | }) |
| | | } |
| | | |
| | | customCallbackRequest = (result) => { |
| | | const { setting } = this.state |
| | | let errSql = '' |
| | | if (result.$ErrCode === 'E') { |
| | | errSql = ` |
| | | set @ErrorCode='E' |
| | | set @retmsg='${result.$ErrMesg}' |
| | | ` |
| | | delete result.$ErrCode |
| | | delete result.$ErrMesg |
| | | } |
| | | |
| | | let lines = UtilsDM.getCallBackSql(setting, result) |
| | | let param = {} |
| | | |
| | | if (setting.callbackType === 'script') { // 使用自定义脚本 |
| | | let sql = lines.map(item => (` |
| | | ${item.insert} |
| | | ${item.selects.join(` union all |
| | | `)} |
| | | `)) |
| | | sql = sql.join('') |
| | | |
| | | param = UtilsDM.getCallBackQueryParams(setting, sql, errSql) |
| | | |
| | | if (this.state.BID) { |
| | | param.BID = this.state.BID |
| | | } |
| | | |
| | | if (this.props.menuType === 'HS') { // 函数 sPC_TableData_InUpDe 云端验证 |
| | | param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp) |
| | | } |
| | | } else { |
| | | param.func = 's_ex_result_back' |
| | | param.s_ex_result = lines.map((item, index) => ({ |
| | | MenuID: this.state.config.MenuID, |
| | | MenuName: this.state.config.MenuName, |
| | | TableName: item.table, |
| | | LongText: window.btoa(window.encodeURIComponent(`${item.insert} ${item.selects.join(` union all `)}`)), |
| | | Sort: index + 1 |
| | | })) |
| | | |
| | | if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) { |
| | | let sql = lines.map(item => (` |
| | | ${item.insert} |
| | | ${item.selects.join(` union all |
| | | `)} |
| | | `)) |
| | | sql = sql.join('') |
| | | console.info(sql.replace(/\n\s{10}/ig, '\n')) |
| | | } |
| | | } |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | | this.loadmaindata() |
| | | } else { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | notification.error({ |
| | | top: 92, |
| | | message: res.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | }, () => { |
| | | this.setState({ |
| | | loading: false |
| | | }) |
| | | }) |
| | | this.loadmaindata(id) |
| | | } |
| | | |
| | | /** |
| | | * @description 主表数据加载 |
| | | */ |
| | | async loadmaindata () { |
| | | const { setting, arr_field, search, orderBy, BID, pageIndex, pageSize, absFields, autoMatic } = this.state |
| | | async loadmaindata (id) { |
| | | const { setting, search, orderBy, BID, pageIndex, pageSize, absFields, autoMatic } = this.state |
| | | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | let _orderBy = orderBy || setting.order |
| | | let param = UtilsDM.getQueryDataParams(setting, arr_field, search, _orderBy, pageIndex, pageSize, BID, this.props.menuType) |
| | | let param = UtilsDM.getQueryDataParams(setting, search, _orderBy, pageIndex, pageSize, BID) |
| | | |
| | | delete param.s_version_up |
| | | |
| | | let result = await Api.genericInterface(param) |
| | | |
| | |
| | | start = pageSize * (pageIndex - 1) + 1 |
| | | } |
| | | |
| | | if (setting.selected !== 'false') { |
| | | if (setting.selected !== 'false' || (setting.orisel && id)) { |
| | | setTimeout(() => { |
| | | MKEmitter.emit('mkTableCheckTopLine', this.props.MenuID) |
| | | MKEmitter.emit('mkTableCheckTopLine', this.props.MenuID, id) |
| | | }, 200) |
| | | if (setting.selected === 'init') { |
| | | this.setState({setting: {...setting, selected: 'false'}}) |
| | |
| | | |
| | | item.key = index |
| | | item.$$uuid = item[setting.primaryKey] || '' |
| | | item.$$key = '' + item.key + item.$$uuid |
| | | item.$$BID = BID || '' |
| | | item.$Index = start + index + '' |
| | | |
| | | if (setting.controlField) { |
| | | if (setting.controlVal.includes(item[setting.controlField] + '')) { |
| | | item.$disabled = true |
| | | } |
| | | } |
| | | |
| | | return item |
| | | }), |
| | |
| | | if (autoMatic) { |
| | | MKEmitter.emit('autoMaticError', this.props.MenuID) |
| | | } |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | |
| | | if (result.ErrCode === 'N') { |
| | | Modal.error({ |
| | | title: result.message, |
| | | }) |
| | | } else { |
| | | notification.error({ |
| | | top: 92, |
| | | message: result.message, |
| | | duration: 10 |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | * @description 获取单行数据 |
| | | */ |
| | | async loadmainLinedata (id) { |
| | | const { setting, arr_field, search, orderBy, BID, pageIndex, pageSize, absFields } = this.state |
| | | const { setting, search, orderBy, BID, pageIndex, pageSize, absFields } = this.state |
| | | |
| | | this.setState({ |
| | | loading: true |
| | | }) |
| | | |
| | | let _orderBy = orderBy || setting.order |
| | | let param = UtilsDM.getQueryDataParams(setting, arr_field, search, _orderBy, pageIndex, pageSize, BID, this.props.menuType, id) |
| | | let param = UtilsDM.getQueryDataParams(setting, search, _orderBy, pageIndex, pageSize, BID, id) |
| | | |
| | | delete param.s_version_up |
| | | |
| | | let result = await Api.genericInterface(param) |
| | | if (result.status) { |
| | |
| | | data = data.map(item => { |
| | | if (item.$$uuid === _data.$$uuid) { |
| | | _data.key = item.key |
| | | _data.$$key = '' + item.key + item.$$uuid |
| | | _data.$Index = item.$Index |
| | | return _data |
| | | } else { |
| | |
| | | getStatFieldsValue = () => { |
| | | const { setting, search, BID, orderBy, statFields } = this.state |
| | | |
| | | if (statFields.length === 0 || !(setting.interType === 'system' || (setting.interType === 'custom' && setting.requestMode === 'system')) || !setting.dataresource) return |
| | | if (statFields.length === 0 || setting.interType !== 'system' || !setting.dataresource) return |
| | | |
| | | let _orderBy = orderBy || setting.order |
| | | let param = UtilsDM.getStatQueryDataParams(setting, statFields, search, _orderBy, BID, this.props.menuType) |
| | | let param = UtilsDM.getStatQueryDataParams(setting, statFields, search, _orderBy, BID) |
| | | |
| | | Api.genericInterface(param).then(res => { |
| | | if (res.status) { |
| | |
| | | /** |
| | | * @description 表格刷新 |
| | | */ |
| | | reloadtable = (btn) => { |
| | | reloadtable = (btn, id = '') => { |
| | | if (!btn || btn.resetPageIndex !== 'false') { |
| | | MKEmitter.emit('resetTable', this.props.MenuID) // 列表重置 |
| | | this.setState({ |
| | | pageIndex: 1 |
| | | }, () => { |
| | | this.loadData() |
| | | this.loadData(id) |
| | | }) |
| | | } else { |
| | | MKEmitter.emit('resetTable', this.props.MenuID, 'false') // 列表重置 |
| | | this.loadData() |
| | | this.loadData(id) |
| | | } |
| | | } |
| | | |
| | |
| | | /** |
| | | * @description 导出Excel时,获取页面搜索排序等参数 |
| | | */ |
| | | queryModuleParam = (menuId, btnId) => { |
| | | const { MenuName, MenuID } = this.props |
| | | const { arr_field, orderBy, search, setting} = this.state |
| | | queryModuleParam = (menuId, callback) => { |
| | | const { MenuID } = this.props |
| | | const { orderBy, search, setting } = this.state |
| | | |
| | | if (MenuID !== menuId) return |
| | | |
| | | MKEmitter.emit('returnModuleParam', MenuID, btnId, { |
| | | arr_field: arr_field, |
| | | callback({ |
| | | orderBy: orderBy || setting.order, |
| | | search: search, |
| | | menuName: MenuName |
| | | search: search |
| | | }) |
| | | } |
| | | |
| | |
| | | const { MenuID } = this.props |
| | | |
| | | if (MenuID !== menuId) return |
| | | if (id === 'empty') return |
| | | |
| | | if (id === 'formtab') { // 表单标签页刷新 |
| | | this.reloadtable(btn) |
| | |
| | | * @param {*} position // 刷新位置 |
| | | * @param {*} btn // 执行的按钮 |
| | | */ |
| | | refreshByButtonResult = (menuId, position, btn) => { |
| | | refreshByButtonResult = (menuId, position, btn, id, lines) => { |
| | | const { MenuID } = this.props |
| | | |
| | | if (MenuID !== menuId) return |
| | | |
| | | this.reloadtable(btn) |
| | | if (position === 'line' && lines && lines.length === 1) { |
| | | this.loadmainLinedata(lines[0].$$uuid) |
| | | } else { |
| | | this.reloadtable(btn, id) |
| | | } |
| | | } |
| | | |
| | | debugChange = () => { |
| | | this.setState({visible: !this.state.visible}) |
| | | } |
| | | |
| | | UNSAFE_componentWillMount () { |
| | |
| | | |
| | | componentDidMount () { |
| | | MKEmitter.addListener('reloadData', this.reloadData) |
| | | MKEmitter.addListener('debugChange', this.debugChange) |
| | | MKEmitter.addListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.addListener('changeTableLine', this.changeTableLine) |
| | | MKEmitter.addListener('resetActiveMenu', this.resetActiveMenu) |
| | |
| | | } |
| | | document.onkeydown = () => {} |
| | | MKEmitter.removeListener('reloadData', this.reloadData) |
| | | MKEmitter.removeListener('debugChange', this.debugChange) |
| | | MKEmitter.removeListener('reloadMenuView', this.reloadMenuView) |
| | | MKEmitter.removeListener('changeTableLine', this.changeTableLine) |
| | | MKEmitter.removeListener('resetActiveMenu', this.resetActiveMenu) |
| | |
| | | } |
| | | |
| | | render() { |
| | | const { menuType, MenuID } = this.props |
| | | const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, chartId, search, selectedData, shortcuts, autoMatic } = this.state |
| | | const { MenuID } = this.props |
| | | const { BID, setting, pageSize, actions, columns, loadingview, viewlost, pickup, config, chartId, search, selectedData, shortcuts } = this.state |
| | | |
| | | return ( |
| | | <div className="commontable" id={this.state.ContainerId}> |
| | | {loadingview ? <Spin size="large" /> : null} |
| | | {searchlist && searchlist.length ? |
| | | <MainSearch BID={BID} searchlist={searchlist} setting={setting} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null |
| | | {config && config.search && config.search.length ? |
| | | <MainSearch BID={BID} config={config} refreshdata={this.refreshbysearch}/> : null |
| | | } |
| | | {setting ? <Row className="chart-view" gutter={16}> |
| | | {setting && config.charts ? <Row className="chart-view" gutter={16}> |
| | | {/* 视图组 */} |
| | | {!config.expand ? <Tabs activeKey={chartId} onChange={this.changeChart}> |
| | | {config.charts.map(item => ( |
| | | <TabPane tab={<Icon type={item.icon} />} key={item.uuid}></TabPane> |
| | | <TabPane tab={<MkIcon type={item.icon} />} key={item.uuid}></TabPane> |
| | | ))} |
| | | </Tabs> : null} |
| | | {config.charts.map(item => { |
| | |
| | | setting={setting} |
| | | actions={actions} |
| | | columns={columns} |
| | | dict={this.state.dict} |
| | | MenuID={MenuID} |
| | | selectedData={selectedData} |
| | | ContainerId={this.state.ContainerId} |
| | | /> |
| | | </div> |
| | | <div className="main-table-box"> |
| | |
| | | setting={setting} |
| | | columns={columns} |
| | | pageSize={pageSize} |
| | | dict={this.state.dict} |
| | | data={this.state.data} |
| | | total={this.state.total} |
| | | loading={this.state.loading} |
| | | statFValue={this.state.statFValue} |
| | | ContainerId={this.state.ContainerId} |
| | | refreshdata={this.refreshbytable} |
| | | chgSelectData={this.changeSelectedData} |
| | | /> |
| | |
| | | columns={columns} |
| | | data={this.state.data} |
| | | loading={this.state.loading} |
| | | ContainerId={this.state.ContainerId} |
| | | /> |
| | | </Col> |
| | | ) |
| | |
| | | } |
| | | })} |
| | | </Row> : null } |
| | | {setting && !config.charts ? <div className="chart-view"> |
| | | <div className="commontable-main-action"> |
| | | <MainAction |
| | | BID={BID} |
| | | setting={setting} |
| | | actions={actions} |
| | | columns={columns} |
| | | MenuID={MenuID} |
| | | selectedData={selectedData} |
| | | /> |
| | | </div> |
| | | <div className="main-table-box"> |
| | | {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && this.state.data && this.state.data.length > 0 ? |
| | | <Switch title="收起" className="main-pickup" checkedChildren="开" unCheckedChildren="关" checked={pickup} onChange={this.pickupChange} /> : null |
| | | } |
| | | <MainTable |
| | | MenuID={MenuID} |
| | | tableId={MenuID} |
| | | pickup={pickup} |
| | | setting={setting} |
| | | columns={columns} |
| | | pageSize={pageSize} |
| | | data={this.state.data} |
| | | total={this.state.total} |
| | | loading={this.state.loading} |
| | | statFValue={this.state.statFValue} |
| | | refreshdata={this.refreshbytable} |
| | | chgSelectData={this.changeSelectedData} |
| | | /> |
| | | </div> |
| | | </div> : null } |
| | | {setting && config.tabgroups.map(group => ( |
| | | <Tabs key={group.uuid}> |
| | | {group.sublist.map(_tab => { |
| | | return ( |
| | | <TabPane tab={ |
| | | <span id={_tab.uuid}> |
| | | {_tab.icon ? <Icon type={_tab.icon} /> : null} |
| | | {_tab.icon ? <MkIcon type={_tab.icon} /> : null} |
| | | {_tab.label} |
| | | </span> |
| | | } key={_tab.uuid}> |
| | |
| | | SupMenuID={MenuID} |
| | | MenuID={_tab.linkTab} |
| | | mainSearch={_tab.searchPass === 'true' ? search : null} |
| | | ContainerId={this.state.ContainerId} |
| | | BID={this.state.BIDs[_tab.supMenu] || ''} |
| | | BData={this.state.BIDs[_tab.supMenu + 'data'] || ''} |
| | | /> |
| | |
| | | })} |
| | | </Tabs>)) |
| | | } |
| | | {menuType !== 'HS' && autoMatic ? <AutoMatic autoMatic={autoMatic} config={config} /> : null} |
| | | {menuType !== 'HS' && window.GLOB.systemType !== 'production' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null} |
| | | {menuType !== 'HS' && shortcuts ? <SettingComponent config={config} dict={this.state.dict} shortcuts={shortcuts} permAction={this.props.permAction}/> : null} |
| | | {setting && window.GLOB.breakpoint ? <DebugTable /> : null} |
| | | {setting ? <SettingComponent config={config} shortcuts={shortcuts || []}/> : null} |
| | | {viewlost ? <NotFount msg={this.state.lostmsg} /> : null} |
| | | </div> |
| | | ) |
| | | } |
| | | } |
| | | |
| | | const mapStateToProps = (state) => { |
| | | return { |
| | | menuType: state.editLevel, |
| | | permAction: state.permAction, |
| | | permMenus: state.permMenus |
| | | } |
| | | } |
| | | |
| | | const mapDispatchToProps = () => { |
| | | return {} |
| | | } |
| | | |
| | | export default connect(mapStateToProps, mapDispatchToProps)(NormalTable) |
| | | export default NormalTable |