import React, {Component} from 'react'
|
import PropTypes from 'prop-types'
|
import {connect} from 'react-redux'
|
import { is, fromJS } from 'immutable'
|
import { notification, Spin} 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 { updateSubTabTable } from '@/utils/utils-update.js'
|
import asyncComponent from '@/utils/asyncComponent'
|
import asyncSpinComponent from '@/utils/asyncSpinComponent'
|
import NotFount from '@/components/404'
|
import MKEmitter from '@/utils/events.js'
|
|
import './index.scss'
|
|
const SubSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch'))
|
const SubAction = asyncComponent(() => import('@/tabviews/zshare/actionList'))
|
const SubTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable'))
|
|
class SubTabModalTable extends Component {
|
static propTpyes = {
|
Tab: PropTypes.any, // 日历标签信息或标签按钮信息
|
BID: PropTypes.string, // 上级数据ID
|
BData: PropTypes.any, // 上级数据
|
MenuID: PropTypes.string, // 菜单Id
|
SupMenuID: PropTypes.string, // 上级菜单Id
|
}
|
|
state = {
|
dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
|
loadingview: true, // 页面加载中
|
viewlost: false, // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用
|
lostmsg: '', // 页面丢失时的提示信息
|
config: null, // 页面配置信息,包括按钮、搜索、显示列、标签等
|
searchlist: null, // 搜索条件
|
actions: null, // 按钮集
|
columns: null, // 显示列
|
arr_field: '', // 使用 sPC_Get_TableData 时的查询字段集
|
setting: null, // 页面全局设置:数据源、按钮及显示列固定、主键等
|
data: [], // 列表数据集
|
selectedData: [], // 已选表格数据
|
total: 0, // 总数
|
loading: false, // 列表数据加载中
|
pageIndex: 1, // 页码
|
pageSize: 10, // 每页数据条数
|
orderBy: '', // 排序
|
search: '', // 搜索条件数组,使用时需分场景处理
|
statFields: [], // 合计字段
|
statFValue: [], // 合计值
|
absFields: [], // 绝对值字段
|
loadCustomApi: true, // 加载外部资源
|
hasReqFields: false
|
}
|
|
/**
|
* @description 获取页面配置信息
|
*/
|
async loadconfig () {
|
const { permAction, Tab } = this.props
|
|
let param = {
|
func: 'sPC_Get_LongParam',
|
MenuID: this.props.MenuID
|
}
|
let result = await Api.getCacheConfig(param)
|
if (result.status) {
|
let config = ''
|
|
try { // 配置信息解析
|
config = JSON.parse(window.decodeURIComponent(window.atob(result.LongParam)))
|
config.setting.MenuName = Tab.label
|
config.setting.$name = Tab.label
|
} 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 _hideCol = [] // 隐藏及合并列中字段的uuid集
|
let colMap = new Map()
|
let statFields = [] // 合计字段信息
|
let absFields = [] // 绝对值字段
|
|
// 版本兼容
|
config = updateSubTabTable(config)
|
|
// 不支持funcbutton、popview 类型按钮
|
let labels = []
|
config.action = config.action.filter(item => {
|
if (['exec', 'prompt', 'pop', 'tab', 'excelIn', 'excelOut', 'innerpage'].includes(item.OpenType)) return true
|
|
labels.push(item.label)
|
|
return false
|
})
|
|
if (window.GLOB.systemType !== 'production' && labels.length > 0) {
|
notification.warning({
|
top: 92,
|
message: `不支持按钮(${labels.join('、')})的打开方式!`,
|
duration: 5
|
})
|
}
|
|
// 权限过滤
|
if (this.props.menuType !== 'HS') {
|
config.action = config.action.filter(item => permAction[item.uuid])
|
}
|
|
config.search = Utils.initSearchVal(config.search)
|
|
let hasReqFields = false
|
config.search.forEach(field => {
|
if (field.required) {
|
hasReqFields = true
|
}
|
})
|
|
// 字段权限黑名单
|
let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
|
|
config.columns = config.columns.map(col => {
|
if (!col.blacklist || col.blacklist.length === 0) return col
|
if (col.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
|
col.Hide = 'true'
|
}
|
|
return col
|
})
|
|
// 1、筛选字段集,2、过滤隐藏列及合并列中的字段uuid
|
config.columns.forEach(col => {
|
if (col.field) {
|
_arrField.push(col.field)
|
|
col.nameField && _arrField.push(col.nameField) // 链接名字段
|
if (col.Hide !== 'true' && col.type === 'number' && col.sum === 'true') {
|
statFields.push(col)
|
}
|
if (col.format === 'abs') {
|
absFields.push(col.field)
|
}
|
}
|
if (col.type === 'colspan' && col.sublist) { // 筛选隐藏列
|
_hideCol = _hideCol.concat(col.sublist)
|
}
|
colMap.set(col.uuid, col)
|
})
|
|
// 生成显示列,处理合并列中的字段
|
config.columns.forEach(col => {
|
if (_hideCol.includes(col.uuid)) return
|
|
col.linkThdMenu = '' // 弹窗中不可使用字段透视
|
|
if (col.type === 'colspan') {
|
if (col.unfold !== 'true') { // 不展开为旧版合并列
|
col.type = 'old_colspan'
|
}
|
|
let _col = fromJS(col).toJS()
|
let subcols = []
|
_col.sublist && _col.sublist.forEach(sub => {
|
if (colMap.has(sub)) {
|
subcols.push(colMap.get(sub))
|
}
|
})
|
if (subcols.length > 0) {
|
_col.subcols = subcols
|
_columns.push(_col)
|
}
|
} else {
|
_columns.push(col)
|
}
|
})
|
|
let _actions = [] // 工具栏按钮
|
let _operations = [] // 操作列按钮(存在时)
|
|
config.action.forEach(item => {
|
item.logLabel = Tab.label + '-' + item.label // 用于sPC_TableData_InUpDe记录操作按钮
|
item.$menuId = this.props.MenuID
|
|
if (item.position === 'toolbar') {
|
_actions.push(item)
|
} else if (item.position === 'grid') {
|
_operations.push(item)
|
}
|
})
|
|
if (config.gridBtn && config.gridBtn.display && _operations.length > 0) {
|
config.gridBtn.operations = _operations
|
_columns.push(config.gridBtn)
|
}
|
|
config.setting.tabType = 'subtab'
|
// 数据源信息预处理
|
config.setting.laypage = config.setting.laypage !== 'false' // 是否分页,转为boolean 统一格式
|
config.setting.execute = config.setting.default !== 'false' // 默认sql是否执行,转为boolean 统一格式
|
config.setting.customScript = '' // 自定义脚本
|
|
if (config.setting.interType === 'system' || (config.setting.interType === 'custom' && config.setting.requestMode === 'system')) {
|
if (config.setting.scripts && config.setting.scripts.length > 0) {
|
let _customScript = ''
|
config.setting.scripts.forEach(item => {
|
if (item.status === 'false') return
|
_customScript += `
|
${item.sql}
|
`
|
})
|
config.setting.customScript = _customScript
|
}
|
|
if (!config.setting.execute) { // 默认sql 不执行时 置空
|
config.setting.dataresource = ''
|
} else {
|
config.setting.dataresource = config.setting.dataresource || ''
|
}
|
if (/\s/.test(config.setting.dataresource)) {
|
config.setting.dataresource = '(' + config.setting.dataresource + ') tb'
|
}
|
|
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, '*/')
|
} 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}'` }
|
]
|
|
regs.forEach(cell => {
|
config.setting.dataresource = config.setting.dataresource.replace(cell.reg, cell.value)
|
config.setting.customScript = config.setting.customScript.replace(cell.reg, cell.value)
|
})
|
}
|
|
if (config.setting.selected !== 'init' && config.setting.selected !== 'always') {
|
config.setting.selected = 'false'
|
} else if (config.setting.selected === 'init' && config.setting.onload === 'false') {
|
config.setting.selected = 'false'
|
}
|
|
if (config.setting.controlField) {
|
if (config.setting.controlVal) {
|
config.setting.controlVal = config.setting.controlVal.split(',')
|
} else {
|
config.setting.controlVal = ['']
|
}
|
}
|
|
this.setState({
|
pageSize: config.setting.pageSize || 10,
|
loadingview: false,
|
config,
|
absFields,
|
statFields,
|
setting: config.setting,
|
searchlist: config.search,
|
actions: _actions,
|
columns: _columns,
|
arr_field: _arrField.join(','),
|
search: Utils.initMainSearch(config.search), // 搜索条件初始化(含有时间格式,需要转化)
|
hasReqFields
|
}, () => {
|
if (config.setting.onload !== 'false') { // 初始化可加载
|
this.loadData()
|
}
|
})
|
} else {
|
this.setState({
|
loadingview: false,
|
viewlost: true
|
})
|
notification.warning({
|
top: 92,
|
message: result.message,
|
duration: 5
|
})
|
}
|
}
|
|
loadData = () => {
|
const { setting, search, hasReqFields, loadCustomApi } = this.state
|
|
let searches = fromJS(search).toJS()
|
|
if (hasReqFields) {
|
let requireFields = searches.filter(item => item.required && item.value === '')
|
if (requireFields.length > 0) {
|
this.setState({
|
loading: false
|
})
|
return
|
}
|
}
|
|
if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) {
|
notification.warning({
|
top: 92,
|
message: '未设置正式系统地址!',
|
duration: 3
|
})
|
return
|
}
|
|
this.setState({
|
selectedData: []
|
})
|
|
if (setting.interType === 'custom' && loadCustomApi) {
|
if (setting.execTime === 'once') {
|
this.setState({loadCustomApi: false})
|
}
|
|
this.loadOutResource(searches)
|
if (setting.execType === 'async') {
|
this.loadmaindata()
|
}
|
} else {
|
this.loadmaindata()
|
}
|
}
|
|
loadOutResource = (searches) => {
|
const { setting } = this.state
|
|
let param = UtilsDM.getPrevQueryParams(setting, searches, this.props.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
|
|
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.props.BID) {
|
param.BID = this.props.BID
|
}
|
|
if (this.props.menuType === 'HS') { // 函数 sPC_TableData_InUpDe 云端验证
|
param.open_key = Utils.encryptOpenKey(param.secretkey, param.timestamp)
|
}
|
} else {
|
let name = this.props.Tab ? (this.props.Tab.label || '') : ''
|
param.func = 's_ex_result_back'
|
param.s_ex_result = lines.map((item, index) => ({
|
MenuID: this.props.MenuID,
|
MenuName: name,
|
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
|
})
|
})
|
}
|
|
/**
|
* @description 子表数据加载
|
*/
|
async loadmaindata () {
|
const { BID } = this.props
|
const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state
|
|
let searches = fromJS(search).toJS()
|
|
this.setState({
|
loading: true
|
})
|
|
let _orderBy = orderBy || setting.order
|
let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType)
|
|
let result = await Api.genericInterface(param)
|
|
this.getStatFieldsValue(searches)
|
|
if (result.status) {
|
let start = 1
|
if (setting.laypage) {
|
start = pageSize * (pageIndex - 1) + 1
|
}
|
|
if (setting.selected !== 'false') {
|
setTimeout(() => {
|
MKEmitter.emit('mkTableCheckTopLine', this.props.MenuID)
|
}, 200)
|
if (setting.selected === 'init') {
|
this.setState({setting: {...setting, selected: 'false'}})
|
}
|
}
|
|
this.setState({
|
data: result.data.map((item, index) => {
|
if (absFields.length) {
|
absFields.forEach(field => {
|
if (!item[field]) return
|
if (isNaN(Math.abs(item[field]))) return
|
|
item[field] = Math.abs(item[field])
|
})
|
}
|
item.key = index
|
item.$$uuid = item[setting.primaryKey] || ''
|
item.$$BID = BID || ''
|
item.$Index = start + index + ''
|
|
if (setting.controlField) {
|
if (setting.controlVal.includes(item[setting.controlField])) {
|
item.$disabled = true
|
}
|
}
|
|
return item
|
}),
|
total: result.total,
|
loading: false
|
})
|
} else {
|
this.setState({
|
loading: false
|
})
|
notification.error({
|
top: 92,
|
message: result.message,
|
duration: 10
|
})
|
}
|
}
|
|
/**
|
* @description 获取合计字段值
|
*/
|
getStatFieldsValue = (searches) => {
|
const { BID } = this.props
|
const { setting, orderBy, statFields } = this.state
|
|
if (statFields.length === 0 || !(setting.interType === 'system' || (setting.interType === 'custom' && setting.requestMode === 'system')) || !setting.dataresource) return
|
|
let _orderBy = orderBy || setting.order
|
let param = UtilsDM.getStatQueryDataParams(setting, statFields, searches, _orderBy, BID, this.props.menuType)
|
|
Api.genericInterface(param).then(res => {
|
if (res.status) {
|
let _data = res.data[0]
|
let values = []
|
|
if (_data) {
|
statFields.forEach(item => {
|
if (_data[item.field] || _data[item.field] === 0) {
|
let val = +_data[item.field]
|
if (isNaN(val)) {
|
val = 0
|
}
|
val = val.toFixed(item.decimal)
|
values.push({label: item.label, value: val})
|
}
|
})
|
}
|
this.setState({
|
statFValue: values
|
})
|
} else {
|
this.setState({
|
statFValue: []
|
})
|
notification.error({
|
top: 92,
|
message: res.message,
|
duration: 10
|
})
|
}
|
})
|
}
|
|
/**
|
* @description 获取单行数据
|
*/
|
async loadmainLinedata (id) {
|
const { BID } = this.props
|
const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state
|
|
let searches = fromJS(search).toJS()
|
|
this.setState({
|
loading: true
|
})
|
|
let _orderBy = orderBy || setting.order
|
let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType, id)
|
|
let result = await Api.genericInterface(param)
|
if (result.status) {
|
let data = fromJS(this.state.data).toJS()
|
let selectedData = fromJS(this.state.selectedData).toJS()
|
if (result.data && result.data[0]) {
|
let _data = result.data[0] || {}
|
|
if (absFields.length) {
|
absFields.forEach(field => {
|
if (!_data[field]) return
|
if (isNaN(Math.abs(_data[field]))) return
|
|
_data[field] = Math.abs(_data[field])
|
})
|
}
|
|
_data.$$uuid = _data[setting.primaryKey] || ''
|
_data.$$BID = BID || ''
|
|
try {
|
data = data.map(item => {
|
if (item.$$uuid === _data.$$uuid) {
|
_data.key = item.key
|
_data.$Index = item.$Index
|
return _data
|
} else {
|
return item
|
}
|
})
|
selectedData = selectedData.map(item => {
|
if (_data.$$uuid === item.$$uuid) {
|
return _data
|
}
|
return item
|
})
|
} catch (e) {
|
console.warn('数据查询错误')
|
}
|
}
|
|
this.setState({
|
data,
|
selectedData,
|
loading: false
|
})
|
} else {
|
this.setState({
|
loading: false
|
})
|
notification.error({
|
top: 92,
|
message: result.message,
|
duration: 10
|
})
|
}
|
}
|
|
/**
|
* @description 搜索条件改变时,重置表格数据
|
* 含有初始不加载的页面,修改设置
|
*/
|
refreshbysearch = (searches) => {
|
MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置
|
this.setState({
|
pageIndex: 1,
|
search: searches
|
}, () => {
|
this.loadData()
|
})
|
}
|
|
/**
|
* @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.loadData()
|
})
|
}
|
|
/**
|
* @description 表格刷新
|
*/
|
reloadtable = (btn) => {
|
if (!btn || btn.resetPageIndex !== 'false') {
|
MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置
|
this.setState({
|
pageIndex: 1
|
}, () => {
|
this.loadData()
|
})
|
} else {
|
MKEmitter.emit('resetTable', this.props.Tab.uuid, 'false') // 列表重置
|
this.loadData()
|
}
|
|
}
|
|
/**
|
* @description 表格选择项切换
|
*/
|
changeSelectedData = (selectedData) => {
|
this.setState({selectedData})
|
}
|
|
/**
|
* @description 导出Excel时,获取页面搜索排序等参数
|
*/
|
queryModuleParam = (menuId, btnId) => {
|
const { Tab, MenuID } = this.props
|
const { arr_field, orderBy, search, setting} = this.state
|
|
if (MenuID !== menuId) return
|
|
MKEmitter.emit('returnModuleParam', MenuID, btnId, {
|
arr_field: arr_field,
|
orderBy: orderBy || setting.order,
|
search: search,
|
menuName: Tab.label
|
})
|
}
|
|
/**
|
* @description 按钮执行完成后页面刷新
|
* @param {*} menuId // 菜单Id
|
* @param {*} position // 刷新位置
|
* @param {*} btn // 执行的按钮
|
*/
|
refreshByButtonResult = (menuId, position, btn, id, lines) => {
|
const { MenuID } = this.props
|
|
if (MenuID !== menuId) return
|
|
if (position === 'line' && lines && lines.length === 1) {
|
this.loadmainLinedata(lines[0].$$uuid)
|
} else {
|
this.reloadtable(btn)
|
}
|
MKEmitter.emit('refreshPopButton', this.props.Tab.uuid)
|
}
|
|
UNSAFE_componentWillMount () {
|
// 组件加载时,获取菜单数据
|
this.loadconfig()
|
}
|
|
shouldComponentUpdate (nextProps, nextState) {
|
return !is(fromJS(this.props), fromJS(nextProps)) || !is(fromJS(this.state), fromJS(nextState))
|
}
|
|
componentDidMount () {
|
MKEmitter.addListener('queryModuleParam', this.queryModuleParam)
|
MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
|
}
|
|
/**
|
* @description 组件销毁,清除state更新
|
*/
|
componentWillUnmount () {
|
this.setState = () => {
|
return
|
}
|
MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
|
MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
|
}
|
|
render() {
|
const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, selectedData } = this.state
|
|
return (
|
<div className="subtabtable" id={'subtabtable' + this.props.MenuID}>
|
{loadingview && <Spin />}
|
{searchlist && searchlist.length ?
|
<SubSearch BID={this.props.BID} setting={setting} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null
|
}
|
{config ? <div style={{minHeight: '25px'}}>
|
<SubAction
|
setting={setting}
|
actions={actions}
|
columns={columns}
|
BID={this.props.BID}
|
dict={this.state.dict}
|
BData={this.props.BData}
|
selectedData={selectedData}
|
MenuID={this.props.SupMenuID}
|
/>
|
</div> : null}
|
{config ? <SubTable
|
tableId={this.props.Tab.uuid}
|
setting={setting}
|
columns={columns}
|
pageSize={pageSize}
|
data={this.state.data}
|
dict={this.state.dict}
|
BData={this.props.BData}
|
total={this.state.total}
|
MenuID={this.props.MenuID}
|
loading={this.state.loading}
|
refreshdata={this.refreshbytable}
|
statFValue={this.state.statFValue}
|
chgSelectData={this.changeSelectedData}
|
/> : null}
|
{viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
|
</div>
|
)
|
}
|
}
|
|
const mapStateToProps = (state) => {
|
return {
|
menuType: state.editLevel,
|
permAction: state.permAction,
|
memberLevel: state.memberLevel
|
}
|
}
|
|
const mapDispatchToProps = () => {
|
return {}
|
}
|
|
export default connect(mapStateToProps, mapDispatchToProps)(SubTabModalTable)
|