import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import {connect} from 'react-redux'
|
import { is, fromJS } from 'immutable'
|
import { notification, Spin, Modal, Button, Switch, Col, Icon, Tabs} from 'antd'
|
import moment from 'moment'
|
|
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 { modifyTabview } from '@/store/action'
|
|
import ChartComponent from '@/tabviews/zshare/chartcomponent'
|
import SubTable from '@/tabviews/zshare/normalTable'
|
import SubSearch from '@/tabviews/zshare/topSearch'
|
import asyncComponent from '@/utils/asyncComponent'
|
import asyncLoadComponent from '@/utils/asyncLoadComponent'
|
import NotFount from '@/components/404'
|
|
import './index.scss'
|
|
const { TabPane } = Tabs
|
const SubAction = asyncComponent(() => import('@/tabviews/zshare/actionList'))
|
const SubTabTable = asyncLoadComponent(() => import('@/tabviews/subtabtable'))
|
|
class SubTabViewTable extends Component {
|
static propTpyes = {
|
menuType: PropTypes.any, // 菜单类型,普通菜单或HS
|
Tab: PropTypes.object, // 标签信息
|
BID: PropTypes.string, // 上级数据ID
|
BData: PropTypes.any, // 上级数据
|
MenuID: PropTypes.string, // 菜单Id
|
SupMenuID: PropTypes.string, // 上级菜单Id
|
mainSearch: PropTypes.any, // 主表搜索条件
|
ContainerId: PropTypes.any, // 三级菜单Container(html) ID
|
handleTableId: PropTypes.func, // 控制表格数据切换时,更新在主表中的id
|
handleMainTable: PropTypes.func, // 刷新主表
|
refreshtabs: PropTypes.any, // 标签刷新控制
|
userConfig: PropTypes.any, // 用户自定义设置
|
triggerBtn: PropTypes.any // 快捷键或点击行按钮触发事件
|
}
|
|
state = {
|
dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
|
loadingview: true, // 页面加载中
|
viewlost: false, // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用
|
lostmsg: '', // 页面丢失时的提示信息
|
config: null, // 页面配置信息,包括按钮、搜索、显示列、标签等
|
searchlist: null, // 搜索条件
|
actions: null, // 按钮集
|
columns: null, // 显示列
|
logcolumns: null, // 日志中显示的列信息 (增加至全部列,除去合并列)
|
arr_field: '', // 使用 sPC_Get_TableData 时的查询字段集
|
setting: null, // 页面全局设置:数据源、按钮及显示列固定、主键等
|
data: null, // 列表数据集
|
total: 0, // 总数
|
loading: false, // 列表数据加载中
|
pageIndex: 1, // 页码
|
pageSize: 10, // 每页数据条数
|
orderBy: '', // 排序
|
search: '', // 搜索条件数组,使用时需分场景处理
|
popAction: false, // 弹框页面,按钮信息
|
popData: false, // 弹框页面,所选的表格数据
|
visible: false, // 弹框显示隐藏控制
|
pickup: false, // 子表数据隐藏显示切换
|
triggerBtn: null // 按钮触发
|
}
|
|
/**
|
* @description 上级菜单id变化时,刷新数据
|
*/
|
UNSAFE_componentWillReceiveProps(nextProps) {
|
if (this.state.config && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) {
|
this.refs.subTable.resetTable()
|
this.loadmaindata(nextProps.BID, 'refresh')
|
} else if (this.state.config && nextProps.refreshtabs && nextProps.refreshtabs.includes(this.props.Tab.uuid)) {
|
this.reloadtable()
|
} else if (nextProps.triggerBtn && !is(fromJS(this.props.triggerBtn), fromJS(nextProps.triggerBtn)) && nextProps.triggerBtn.parentId === this.props.Tab.uuid) {
|
let trigger = nextProps.triggerBtn
|
|
trigger.parentId = this.props.MenuID
|
|
this.setState({
|
triggerBtn: trigger
|
})
|
} else if (!this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
|
this.setState({}, () => {
|
this.loadmaindata()
|
})
|
}
|
}
|
|
/**
|
* @description 获取页面配置信息
|
*/
|
async loadconfig () {
|
const { permAction, permMenus, Tab, BID, userConfig } = this.props
|
|
let param = {
|
func: 'sPC_Get_LongParam',
|
MenuID: this.props.MenuID
|
}
|
let result = await Api.getSystemCacheConfig(param)
|
if (result.status) {
|
let config = ''
|
|
try { // 配置信息解析
|
config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
|
} 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: this.state.dict['main.view.unenabled']
|
})
|
return
|
}
|
|
let _arrField = [] // 字段集
|
let _columns = [] // 显示列
|
let _logcolumns = [] // 日志显示列
|
let _hideCol = [] // 隐藏及合并列中字段的uuid集
|
let colMap = new Map()
|
|
// 兼容图表
|
if (!config.charts) {
|
config.expand = false
|
config.charts = [{
|
uuid: Utils.getuuid(),
|
label: '',
|
title: '',
|
chartType: 'table',
|
icon: 'table',
|
Hide: 'false',
|
blacklist: []
|
}]
|
}
|
|
// 权限过滤
|
if (this.props.menuType !== 'HS') {
|
config.action = config.action.filter(item => permAction[item.uuid])
|
|
// 字段权限黑名单
|
config.search = config.search.filter(item => {
|
if (!item.blacklist || item.blacklist.length === 0) return true
|
|
let _black = item.blacklist.filter(v => {
|
return this.props.permRoles.indexOf(v) !== -1
|
})
|
|
if (_black.length > 0) {
|
return false
|
} else {
|
return true
|
}
|
})
|
|
config.columns = config.columns.filter(col => {
|
if (!col.field || !col.blacklist || col.blacklist.length === 0 || config.setting.primaryKey === col.field) return true
|
|
let _black = col.blacklist.filter(v => {
|
return this.props.permRoles.indexOf(v) !== -1
|
})
|
|
if (_black.length > 0) {
|
return false
|
} else {
|
return true
|
}
|
})
|
|
// 视图权限
|
config.charts = config.charts.filter(item => {
|
if (!item.blacklist || item.blacklist.length === 0) return true
|
|
let _black = item.blacklist.filter(v => {
|
return this.props.permRoles.indexOf(v) !== -1
|
})
|
|
if (_black.length > 0 || item.Hide === 'true') {
|
return false
|
} else {
|
return true
|
}
|
})
|
}
|
|
if (config.charts.length <= 1) {
|
config.expand = true
|
}
|
|
if (userConfig) {
|
config.setting.tableType = userConfig.setting.tableType
|
|
config.action = config.action.map(item => {
|
if (userConfig.action[item.uuid]) {
|
delete userConfig.action[item.uuid].label
|
item = {...item, ...userConfig.action[item.uuid]}
|
}
|
|
if (item.execMode) {
|
item.OpenType = 'funcbutton'
|
}
|
|
if (item.OpenType === 'funcbutton' && item.funcType === 'print' && item.verify && item.printer) {
|
item.verify.defaultPrinter = item.printer.defaultPrinter || ''
|
if (item.verify.printerTypeList && item.printer.printerList) {
|
item.verify.printerTypeList = item.verify.printerTypeList.map(cell => {
|
cell.printer = item.printer.printerList[cell.Value] || ''
|
|
return cell
|
})
|
}
|
}
|
|
return item
|
})
|
}
|
|
// 1、筛选字段集,2、过滤隐藏列及合并列中的字段uuid
|
config.columns.forEach(col => {
|
if (col.field) {
|
_arrField.push(col.field)
|
|
_logcolumns.push(col)
|
}
|
if (col.type === 'colspan' && col.sublist) { // 筛选隐藏列
|
_hideCol = _hideCol.concat(col.sublist)
|
} else if (col.Hide === 'true') {
|
_hideCol.push(col.uuid)
|
}
|
colMap.set(col.uuid, col)
|
})
|
|
// 生成显示列,处理合并列中的字段
|
config.columns.forEach((col, index) => {
|
if (_hideCol.includes(col.uuid)) return
|
|
if (col.linkThdMenu && !permMenus[col.linkThdMenu.MenuID]) {
|
col.linkThdMenu = ''
|
}
|
|
col.sort = index
|
|
if (col.type === 'colspan' && col.sublist) {
|
let _col = JSON.parse(JSON.stringify(col))
|
let subColumn = []
|
_col.sublist.forEach(sub => {
|
if (colMap.has(sub)) {
|
subColumn.push(colMap.get(sub))
|
}
|
})
|
_col.subColumn = subColumn
|
_columns.push(_col)
|
} else {
|
_columns.push(col)
|
}
|
})
|
|
let _actions = [] // 工具栏按钮
|
let _operations = [] // 操作列按钮(存在时)
|
|
config.action.forEach(item => {
|
if (item.execMode) {
|
item.OpenType = 'funcbutton'
|
}
|
|
if (item.position === 'toolbar') {
|
_actions.push(item)
|
} else if (item.position === 'grid') {
|
_operations.push(item)
|
}
|
})
|
|
if (config.gridBtn && config.gridBtn.display && _operations.length > 0) {
|
_columns.push({
|
...config.gridBtn,
|
operations: _operations
|
})
|
}
|
|
let valid = true // 搜索条件必填验证
|
config.search.forEach(field => {
|
if (field.required === 'true' && !field.initval) {
|
valid = false
|
}
|
})
|
|
// 添加用户显示列设置
|
if (userConfig) {
|
_columns = _columns.map(item => {
|
if (userConfig.columns[item.uuid]) {
|
delete userConfig.columns[item.uuid].label
|
item = {...item, ...userConfig.columns[item.uuid]}
|
}
|
|
return item
|
})
|
|
_columns.sort((pre, next) => {
|
return pre.sort - next.sort
|
})
|
}
|
|
this.setState({
|
loadingview: false,
|
config: config,
|
setting: config.setting,
|
searchlist: config.search,
|
actions: _actions,
|
columns: _columns,
|
logcolumns: _logcolumns,
|
arr_field: _arrField.join(','),
|
search: Utils.initMainSearch(config.search) // 搜索条件初始化(含有时间格式,需要转化)
|
}, () => {
|
this.improveSearch()
|
|
if (config.setting.onload !== 'false' && (!Tab.supMenu || BID) && valid) { // 初始化可加载
|
this.loadmaindata()
|
}
|
})
|
} else {
|
this.setState({
|
loadingview: false,
|
viewlost: true
|
})
|
let prex = Tab && Tab.label ? Tab.label + ': ' : ''
|
|
notification.warning({
|
top: 92,
|
message: prex + result.message,
|
duration: 5
|
})
|
}
|
}
|
|
/**
|
* @description 搜索条件下拉选项预加载
|
*/
|
improveSearch = () => {
|
let searchlist = JSON.parse(JSON.stringify(this.state.searchlist))
|
let deffers = []
|
searchlist.forEach(item => {
|
if (item.type !== 'multiselect' && item.type !== 'select' && item.type !== 'link') return
|
if (item.setAll === 'true') {
|
item.options.unshift({
|
key: Utils.getuuid(),
|
Value: '',
|
Text: this.state.dict['main.all']
|
})
|
}
|
|
if (item.resourceType === '1' && item.dataSource) {
|
let _option = Utils.getSelectQueryOptions(item)
|
let _sql = Utils.formatOptions(_option.sql)
|
let isSSO = item.database === 'sso'
|
|
let param = {
|
func: 'sPC_Get_SelectedList',
|
LText: _sql,
|
obj_name: 'data',
|
arr_field: _option.field
|
}
|
|
if (this.props.BID) {
|
param.BID = this.props.BID
|
}
|
|
param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
param.secretkey = Utils.encrypt(param.LText, param.timestamp)
|
|
let defer = new Promise(resolve => {
|
Api.getSystemCacheConfig(param, isSSO).then(res => {
|
res.search = item
|
resolve(res)
|
})
|
})
|
deffers.push(defer)
|
} else if (item.resourceType === '1' && !item.dataSource) {
|
let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + '-' : ''
|
|
notification.warning({
|
top: 92,
|
message: prex + item.label + ': ' + this.state.dict['main.datasource.settingerror'],
|
duration: 5
|
})
|
}
|
})
|
|
if (deffers.length === 0) {
|
this.setState({searchlist: JSON.parse(JSON.stringify(searchlist))})
|
return
|
}
|
|
Promise.all(deffers).then(result => {
|
result.forEach(res => {
|
if (res.status) {
|
searchlist = searchlist.map(item => {
|
if (item.uuid === res.search.uuid) {
|
res.data.forEach(cell => {
|
let _item = {
|
key: Utils.getuuid(),
|
Value: cell[res.search.valueField],
|
Text: cell[res.search.valueText]
|
}
|
|
if (res.search.type === 'link') {
|
_item.parentId = cell[res.search.linkField]
|
}
|
|
item.options.push(_item)
|
})
|
}
|
return item
|
})
|
} else {
|
let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + '-' : ''
|
|
notification.warning({
|
top: 92,
|
message: prex + res.search.label + ':' + res.message,
|
duration: 5
|
})
|
}
|
})
|
this.setState({searchlist})
|
})
|
}
|
|
/**
|
* @description 子表数据加载
|
*/
|
async loadmaindata (bid, type) {
|
const { setting, search } = this.state
|
let param = ''
|
let _BID = this.props.BID
|
|
let requireFields = search.filter(item => item.required && !item.value)
|
|
if (requireFields.length > 0) {
|
notification.warning({
|
top: 92,
|
message: this.state.dict['form.required.input'] + requireFields.map(item => item.label).join('、') + ' !',
|
duration: 3
|
})
|
return
|
}
|
|
this.setState({
|
loading: true
|
})
|
|
if (type === 'refresh') {
|
_BID = bid
|
if (!bid) { // 主表ID不存在时,不查询子表
|
this.setState({
|
data: [],
|
total: 0,
|
loading: false
|
})
|
|
return
|
}
|
}
|
|
if (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc)) {
|
param = this.getCustomParam(_BID)
|
} else {
|
param = this.getDefaultParam(_BID)
|
}
|
|
this.handleTableId()
|
|
let result = await Api.genericInterface(param)
|
if (result.status) {
|
this.setState({
|
data: result.data.map((item, index) => {
|
item.key = index
|
return item
|
}),
|
total: result.total,
|
pickup: false,
|
loading: false
|
})
|
} else {
|
this.setState({
|
loading: false
|
})
|
let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + ': ' : ''
|
|
notification.error({
|
top: 92,
|
message: prex + result.message,
|
duration: 10
|
})
|
}
|
}
|
|
/**
|
* @description 获取用户自定义存储过程传参
|
*/
|
getCustomParam = (BID) => {
|
const { mainSearch } = this.props
|
const { pageIndex, pageSize, orderBy, search, setting } = this.state
|
|
let searches = search
|
if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
|
searches = [...mainSearch, ...search]
|
}
|
|
let _search = Utils.formatCustomMainSearch(searches)
|
|
let param = {
|
OrderCol: orderBy || setting.order,
|
BID: BID,
|
..._search
|
}
|
|
if (setting.laypage !== 'false') {
|
param.PageIndex = pageIndex
|
param.PageSize = pageSize
|
}
|
|
if (setting.interType === 'inner') {
|
param.func = setting.innerFunc
|
} else {
|
if (this.props.menuType === 'HS') {
|
if (setting.sysInterface === 'true' && options.cloudServiceApi) {
|
param.rduri = options.cloudServiceApi
|
} else if (setting.sysInterface !== 'true') {
|
param.rduri = setting.interface
|
}
|
} else {
|
if (setting.sysInterface === 'true' && window.GLOB.mainSystemApi) {
|
param.rduri = window.GLOB.mainSystemApi
|
} else if (setting.sysInterface !== 'true') {
|
param.rduri = setting.interface
|
}
|
}
|
|
if (setting.outerFunc) {
|
param.func = setting.outerFunc
|
}
|
}
|
|
return param
|
}
|
|
/**
|
* @description 获取系统存储过程 sPC_Get_TableData 的参数
|
*/
|
getDefaultParam = (BID) => {
|
const { mainSearch } = this.props
|
const { arr_field, pageIndex, pageSize, orderBy, search, setting } = this.state
|
|
let searches = search
|
if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
|
searches = [...mainSearch, ...search]
|
}
|
|
let _search = Utils.joinMainSearchkey(searches)
|
_search = _search ? 'where ' + _search : ''
|
|
let param = {
|
func: 'sPC_Get_TableData',
|
obj_name: 'data',
|
arr_field: arr_field,
|
BID: BID,
|
custom_script: setting.customScript || '',
|
default_sql: setting.default || 'true'
|
}
|
|
let _orderBy = orderBy || setting.order
|
let _dataresource = setting.dataresource
|
|
if (/\s/.test(_dataresource)) {
|
_dataresource = '(' + _dataresource + ') tb'
|
}
|
|
if (setting.queryType === 'statistics') { // 统计数据源,内容替换
|
let allSearch = Utils.getAllSearchOptions(search)
|
|
let options = allSearch.map(item => {
|
return {
|
reg: new RegExp('@' + item.key + '@', 'ig'),
|
value: item.value
|
}
|
})
|
|
options.forEach(item => {
|
_dataresource = _dataresource.replace(item.reg, `'${item.value}'`)
|
})
|
|
_search = ''
|
}
|
|
let LText = `select top ${pageSize} ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_dataresource} ${_search}) tmptable where rows > ${pageSize * (pageIndex - 1)} order by tmptable.rows`
|
let DateCount = `select count(1) as total from ${_dataresource} ${_search}`
|
|
if (setting.laypage === 'false') {
|
LText = `select ${arr_field} from (select ${arr_field} ,ROW_NUMBER() over(order by ${_orderBy}) as rows from ${_dataresource} ${_search}) tmptable order by tmptable.rows`
|
DateCount = ''
|
}
|
|
param.custom_script = Utils.formatOptions(param.custom_script)
|
param.LText = Utils.formatOptions(LText)
|
param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
|
param.secretkey = Utils.encrypt(param.LText, param.timestamp)
|
param.DateCount = Utils.formatOptions(DateCount)
|
|
return param
|
}
|
|
/**
|
* @description 搜索条件改变时,重置表格数据
|
* 含有初始不加载的页面,修改设置
|
*/
|
refreshbysearch = (searches) => {
|
this.refs.subTable.resetTable()
|
|
this.setState({
|
pageIndex: 1,
|
search: searches
|
}, () => {
|
this.loadmaindata()
|
})
|
}
|
|
/**
|
* @description 表格条件改变时重置数据(分页或排序)
|
*/
|
refreshbytable = (pagination, filters, sorter) => {
|
if (sorter.order) {
|
let _chg = {
|
ascend: 'asc',
|
descend: 'desc'
|
}
|
sorter.order = _chg[sorter.order]
|
}
|
|
this.setState({
|
pageIndex: pagination.current,
|
pageSize: pagination.pageSize,
|
orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : ''
|
}, () => {
|
this.loadmaindata()
|
})
|
}
|
|
/**
|
* @description 表格刷新
|
*/
|
reloadtable = () => {
|
this.refs.subTable.resetTable()
|
this.setState({
|
pageIndex: 1
|
}, () => {
|
this.loadmaindata()
|
})
|
}
|
|
/**
|
* @description 页面刷新,重新获取配置
|
*/
|
reloadview = () => {
|
this.setState({
|
loadingview: true,
|
viewlost: false,
|
lostmsg: '',
|
config: null,
|
searchlist: null,
|
actions: null,
|
columns: null,
|
arr_field: '',
|
setting: null,
|
data: null,
|
total: 0,
|
loading: false,
|
pageIndex: 1,
|
pageSize: 10,
|
orderBy: '',
|
search: '',
|
triggerBtn: null
|
}, () => {
|
this.loadconfig()
|
})
|
}
|
|
/**
|
* @description 按钮操作完成后(成功或失败),页面刷新,重置页码及选择项
|
*/
|
refreshbyaction = (btn, type) => {
|
if (btn.execSuccess === 'grid' && type === 'success') {
|
this.reloadtable()
|
} else if (btn.execError === 'grid' && type === 'error') {
|
this.reloadtable()
|
} else if (btn.execSuccess === 'view' && type === 'success') {
|
this.reloadview()
|
} else if (btn.execError === 'view' && type === 'error') {
|
this.reloadview()
|
} else if (btn.popClose === 'grid' && type === 'pop') {
|
this.reloadtable()
|
} else if (btn.popClose === 'view' && type === 'pop') {
|
this.reloadview()
|
} else if (btn.popClose === 'maingrid' && type === 'pop') {
|
this.props.handleMainTable('maingrid')
|
} else if (btn.popClose === 'equaltab' && type === 'pop') {
|
this.reloadtable()
|
this.props.handleMainTable('equaltab')
|
} else if (btn.execSuccess === 'maingrid' && type === 'success') {
|
this.props.handleMainTable('maingrid')
|
} else if (btn.execSuccess === 'equaltab' && type === 'success') {
|
this.reloadtable()
|
this.props.handleMainTable('equaltab')
|
}
|
}
|
|
/**
|
* @description 导出Excel时,获取页面搜索排序等参数
|
*/
|
getexceloutparam = () => {
|
const { Tab, mainSearch } = this.props
|
const { arr_field, orderBy, search, setting} = this.state
|
|
let searches = search
|
if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
|
searches = [...mainSearch, ...search]
|
}
|
|
return {
|
arr_field: arr_field,
|
orderBy: orderBy || setting.order,
|
search: searches,
|
menuName: Tab.label
|
}
|
}
|
|
/**
|
* @description 获取表格选择项
|
*/
|
gettableselected = () => {
|
let data = []
|
this.refs.subTable.state.selectedRowKeys.forEach(item => {
|
data.push(this.refs.subTable.props.data[item])
|
})
|
return data
|
}
|
|
/**
|
* @description 表格中,按钮触发事件传递
|
*/
|
buttonTrigger = (btn, record) => {
|
this.setState({
|
triggerBtn: {
|
uuid: new Date().getTime(),
|
parentId: this.props.MenuID,
|
button: btn,
|
data: record
|
}
|
})
|
}
|
|
/**
|
* @description 表格Id变化
|
*/
|
handleTableId = (type = this.props.Tab.uuid, id = '', data = '') => {
|
this.props.handleTableId(type, id, data)
|
}
|
|
/**
|
* @description 触发按钮弹窗(标签页)
|
*/
|
triggerPopview = (btn, data) => {
|
this.setState({
|
popAction: btn,
|
popData: data[0] ? data[0] : null,
|
visible: true
|
})
|
}
|
|
/**
|
* @description 数据展开合并切换
|
*/
|
pickupChange = () => {
|
const { pickup } = this.state
|
|
this.setState({
|
pickup: !pickup
|
})
|
}
|
|
linkTrigger = (menu) => {
|
const { tabviews, SupMenuID } = this.props
|
|
menu.selected = true
|
|
let index = 0
|
let isexit = false
|
let tabs = tabviews.map((tab, i) => {
|
tab.selected = false
|
|
if (tab.MenuID === SupMenuID) {
|
index = i
|
} else if (tab.MenuID === menu.MenuID) {
|
tab.param = menu.param
|
tab.selected = true
|
isexit = true
|
}
|
|
return tab
|
})
|
|
if (!isexit) {
|
tabs.splice(index + 1, 0, menu)
|
}
|
|
this.props.modifyTabview(tabs)
|
}
|
|
popclose = () => {
|
this.setState({
|
visible: false
|
})
|
this.refreshbyaction(this.state.popAction, 'pop')
|
}
|
|
UNSAFE_componentWillMount() {
|
// 组件加载时,获取菜单数据
|
this.loadconfig()
|
}
|
|
shouldComponentUpdate (nextProps, nextState) { // handleMainTable 函数判断时不相等
|
return !is(fromJS({...this.props, handleMainTable: '', handleTableId: ''}), fromJS({...nextProps, handleMainTable: '', handleTableId: ''})) || !is(fromJS(this.state), fromJS(nextState))
|
}
|
|
/**
|
* @description 组件销毁,清除state更新
|
*/
|
componentWillUnmount () {
|
this.setState = () => {
|
return
|
}
|
}
|
|
render() {
|
const { config, setting, searchlist, actions, columns, loadingview, viewlost, pickup, triggerBtn } = this.state
|
|
return (
|
<div className="subtable" id={'subtable' + this.props.MenuID}>
|
{loadingview && <Spin size="large" />}
|
{searchlist && searchlist.length > 0 ?
|
<SubSearch
|
refreshdata={this.refreshbysearch}
|
searchlist={searchlist}
|
dict={this.state.dict}
|
/> : null
|
}
|
{config ? <div className="chart-view">
|
{/* 视图组 */}
|
{!config.expand ? <Tabs>
|
{config.charts.map(item => (
|
<TabPane tab={
|
<Icon type={item.icon} />
|
} key={item.uuid}>
|
{item.chartType === 'table' ?
|
<Col span={item.width || 24} key={item.uuid}>
|
{config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null}
|
<div className="sub-action">
|
<SubAction
|
type="sub"
|
menuType={this.props.menuType}
|
triggerBtn={triggerBtn}
|
setting={setting}
|
actions={actions}
|
Tab={this.props.Tab}
|
BID={this.props.BID}
|
BData={this.props.BData}
|
dict={this.state.dict}
|
MenuID={this.props.MenuID}
|
permRoles={this.props.permRoles}
|
logcolumns={this.state.logcolumns}
|
refreshdata={this.refreshbyaction}
|
ContainerId={this.props.ContainerId}
|
triggerPopview={this.triggerPopview}
|
getexceloutparam={this.getexceloutparam}
|
gettableselected={this.gettableselected}
|
/>
|
</div>
|
<div className="subtable-box">
|
{this.state.data && this.state.data.length > 0 ?
|
<Switch title="收起" className="subtable-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null
|
}
|
<SubTable
|
ref="subTable"
|
menuType={this.props.menuType}
|
tableId={this.props.Tab.uuid}
|
pickup={pickup}
|
setting={setting}
|
columns={columns}
|
dict={this.state.dict}
|
data={this.state.data}
|
total={this.state.total}
|
MenuID={this.props.MenuID}
|
loading={this.state.loading}
|
pagination={setting.laypage !== 'false'}
|
refreshdata={this.refreshbytable}
|
buttonTrigger={this.buttonTrigger}
|
linkTrigger={this.linkTrigger}
|
handleTableId={this.handleTableId}
|
/>
|
</div>
|
</Col> : null
|
}
|
{item.chartType !== 'table' ?
|
<Col span={item.width} key={item.uuid}>
|
<ChartComponent
|
plot={item}
|
data={this.state.data}
|
config={config}
|
/>
|
</Col> : null
|
}
|
</TabPane>
|
))}
|
</Tabs> : null}
|
{config.expand && config.charts.map(item => {
|
if (item.chartType === 'table') {
|
return (
|
<Col span={item.width || 24} key={item.uuid}>
|
{config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null}
|
<div className="sub-action">
|
<SubAction
|
type="sub"
|
menuType={this.props.menuType}
|
triggerBtn={triggerBtn}
|
setting={setting}
|
actions={actions}
|
Tab={this.props.Tab}
|
BID={this.props.BID}
|
BData={this.props.BData}
|
dict={this.state.dict}
|
MenuID={this.props.MenuID}
|
permRoles={this.props.permRoles}
|
logcolumns={this.state.logcolumns}
|
refreshdata={this.refreshbyaction}
|
ContainerId={this.props.ContainerId}
|
triggerPopview={this.triggerPopview}
|
getexceloutparam={this.getexceloutparam}
|
gettableselected={this.gettableselected}
|
/>
|
</div>
|
<div className="subtable-box">
|
{this.state.data && this.state.data.length > 0 ?
|
<Switch title="收起" className="subtable-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null
|
}
|
<SubTable
|
ref="subTable"
|
menuType={this.props.menuType}
|
tableId={this.props.Tab.uuid}
|
pickup={pickup}
|
setting={setting}
|
columns={columns}
|
dict={this.state.dict}
|
data={this.state.data}
|
total={this.state.total}
|
MenuID={this.props.MenuID}
|
loading={this.state.loading}
|
pagination={setting.laypage !== 'false'}
|
refreshdata={this.refreshbytable}
|
buttonTrigger={this.buttonTrigger}
|
linkTrigger={this.linkTrigger}
|
handleTableId={this.handleTableId}
|
/>
|
</div>
|
</Col>
|
)
|
} else {
|
return (
|
<Col span={item.width} key={item.uuid}>
|
<ChartComponent
|
plot={item}
|
data={this.state.data}
|
config={config}
|
/>
|
</Col>
|
)
|
}
|
})}
|
</div> : null }
|
<Modal
|
className="popview-modal"
|
title={this.state.popAction.label}
|
width={'80vw'}
|
maskClosable={false}
|
visible={this.state.visible}
|
onCancel={this.popclose}
|
footer={[
|
<Button key="close" onClick={this.popclose}>{this.state.dict['main.close']}</Button>
|
]}
|
destroyOnClose
|
>
|
{<SubTabTable
|
BID={this.props.BID}
|
menuType={this.props.menuType}
|
BData={this.props.BData}
|
SupMenuID={this.props.MenuID}
|
ContainerId={this.props.ContainerId}
|
MenuID={this.state.popAction.linkTab}
|
ID={this.state.popData ? this.state.popData[setting.primaryKey] : ''}
|
refreshSupView={this.reloadtable}
|
/>}
|
</Modal>
|
{viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
|
</div>
|
)
|
}
|
}
|
|
const mapStateToProps = (state) => {
|
return {
|
tabviews: state.tabviews,
|
permAction: state.permAction,
|
permRoles: state.permRoles,
|
permMenus: state.permMenus
|
}
|
}
|
|
const mapDispatchToProps = (dispatch) => {
|
return {
|
modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews))
|
}
|
}
|
|
export default connect(mapStateToProps, mapDispatchToProps)(SubTabViewTable)
|