king
2022-09-06 b8e1395f02c929eaa96b949cf6027ee2a43856a6
src/tabviews/subtable/index.jsx
@@ -2,7 +2,7 @@
import PropTypes from 'prop-types'
import {connect} from 'react-redux'
import { is, fromJS } from 'immutable'
import { notification, Spin, Switch, Row, Col, Icon, Tabs} from 'antd'
import { notification, Spin, Switch, Row, Col, Tabs} from 'antd'
import Api from '@/api'
import zhCN from '@/locales/zh-CN/main.js'
@@ -13,6 +13,7 @@
import { updateSubTable } from '@/utils/utils-update.js'
import asyncComponent from '@/utils/asyncComponent'
import asyncSpinComponent from '@/utils/asyncSpinComponent'
import MkIcon from '@/components/mk-icon'
import NotFount from '@/components/404'
import MKEmitter from '@/utils/events.js'
@@ -34,7 +35,6 @@
    SupMenuID: PropTypes.string,     // 上级菜单Id
    mainSearch: PropTypes.any,       // 主表搜索条件
    ContainerId: PropTypes.any,      // 三级菜单Container(html) ID
    handleTableId: PropTypes.func,   // 控制表格数据切换时,更新在主表中的id
  }
  state = {
@@ -46,7 +46,7 @@
    searchlist: null,     // 搜索条件
    actions: null,        // 按钮集
    columns: null,        // 显示列
    arr_field: '',        // 使用 sPC_Get_TableData 时的查询字段集
    arr_field: '',        // 查询字段集
    setting: null,        // 页面全局设置:数据源、按钮及显示列固定、主键等
    data: [],             // 列表数据集
    selectedData: [],     // 已选表格数据
@@ -62,23 +62,18 @@
    statFValue: [],       // 合计值
    absFields: [],        // 绝对值字段
    loadCustomApi: true,  // 加载外部资源
    hasReqFields: false
    hasReqFields: false,
    BID: '',
    BData: ''
  }
  /**
   * @description 上级菜单id变化时,刷新数据
   */
  UNSAFE_componentWillReceiveProps(nextProps) {
    const { config, setting } = this.state
    const { setting } = this.state
    if (config && setting && this.props.Tab.supMenu && !is(fromJS(this.props.BID), fromJS(nextProps.BID))) {
      MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 列表重置
      this.setState({
        pageIndex: 1
      }, () => {
        this.loadData()
      })
    } else if (setting && !this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
    if (setting && !this.props.Tab.supMenu && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
      this.setState({}, () => {
        this.loadData()
      })
@@ -89,7 +84,7 @@
   * @description 获取页面配置信息
   */
  async loadconfig () {
    const { permAction, permMenus, Tab, BID } = this.props
    const { permAction, permMenus, Tab } = this.props
    let param = {
      func: 'sPC_Get_LongParam',
@@ -102,6 +97,7 @@
      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 = ''
@@ -137,20 +133,23 @@
      config = updateSubTable(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' && permAction[item.uuid])
      } else {
        config.action = config.action.filter(item => item.hidden !== 'true')
      }
      let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
      // 字段权限黑名单
      config.search = config.search.map(item => {
        item.oriInitval = item.initval
        if (!item.blacklist || item.blacklist.length === 0) return item
        if (item.blacklist.filter(v => roleId.indexOf(v) > -1).length > 0) {
          item.Hide = 'true'
      config.search = Utils.initSearchVal(config.search)
      let hasReqFields = false
      config.search.forEach(field => {
        if (field.required) {
          hasReqFields = true
        }
        return item
      })
      // 字段权限黑名单
      let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
      config.columns = config.columns.map(col => {
        if (!col.blacklist || col.blacklist.length === 0) return col
@@ -161,23 +160,42 @@
        return col
      })
      // 视图权限
      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 : ''
      // 1、筛选字段集,2、过滤隐藏列及合并列中的字段uuid
      config.columns.forEach(col => {
        if (col.field) {
          _arrField.push(col.field)
          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] || ''
          } 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) // 链接名字段
          if (col.Hide !== 'true' && col.type === 'number' && col.sum === 'true') {
@@ -196,13 +214,6 @@
      // 生成显示列,处理合并列中的字段
      config.columns.forEach((col, index) => {
        if (_hideCol.includes(col.uuid)) return
        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] || ''
        } else {
          col.linkThdMenu = ''
        }
        col.sort = index
@@ -249,6 +260,7 @@
          }
        }
        if (item.position === 'toolbar') {
          item.$toolbtn = true
          _actions.push(item)
        } else if (item.position === 'grid') {
          _operations.push(item)
@@ -259,16 +271,6 @@
        config.gridBtn.operations = _operations
        _columns.push(config.gridBtn)
      }
      let valid = true // 搜索条件必填验证
      let hasReqFields = false
      config.search.forEach(field => {
        if (field.required !== 'true') return
        hasReqFields = true
        if (!field.initval) {
          valid = false
        }
      })
      config.setting.tabType = 'sub'
      // 数据源信息预处理
@@ -306,9 +308,46 @@
          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') || ''
        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}'` }
        ]
        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'
      } else {
        config.setting.orisel = true
      }
      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,
        BID: this.props.BID || '',
        BData: this.props.BData || '',
        loadingview: false,
        chartId,
        config,
@@ -319,10 +358,10 @@
        actions: _actions,
        columns: _columns,
        arr_field: _arrField.join(','),
        search: Utils.initMainSearch(config.search), // 搜索条件初始化(含有时间格式,需要转化)
        search: Utils.initMainSearch(config.search),
        hasReqFields
      }, () => {
        if (config.setting.onload !== 'false' && (!Tab.supMenu || BID || Tab.isTreeNode) && valid) { // 初始化可加载
        if (config.setting.onload !== 'false' && (!Tab.supMenu || this.props.BID || Tab.isTreeNode)) { // 初始化可加载
          this.loadData()
        }
      })
@@ -341,39 +380,33 @@
    }
  }
  
  loadData = () => {
    const { mainSearch, BID } = this.props
    const { setting, search, loadCustomApi, hasReqFields } = this.state
  loadData = (id) => {
    const { mainSearch } = this.props
    const { setting, BID, search, loadCustomApi, hasReqFields } = this.state
    let searches = fromJS(search).toJS()
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
      searches = [...mainSearch, ...searches]
    }
    let requireFields = []
    if (hasReqFields) {
      requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0))
      let requireFields = searches.filter(item => item.required && item.value === '')
      if (requireFields.length > 0) {
        this.setState({
          loading: false
        })
        return
      }
    }
    if (requireFields.length > 0) {
      let prex = this.props.Tab && this.props.Tab.label ? this.props.Tab.label + '-' : ''
      let labels = requireFields.map(item => item.label)
      labels = Array.from(new Set(labels))
      notification.warning({
        top: 92,
        message: prex + this.state.dict['form.required.input'] + labels.join('、') + ' !',
        duration: 3
      })
      return
    } else if (this.props.Tab.supMenu && !BID) { // 主表ID不存在时,不查询子表
    if (this.props.Tab.supMenu && !BID) { // 主表ID不存在时,不查询子表
      this.setState({
        data: [],
        selectedData: [],
        statFValue: [],
        total: 0
      })
      this.handleTableId()
      MKEmitter.emit('changeTableLine', this.props.ContainerId, this.props.Tab.uuid, '', '')
      return
    } else if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) {
      notification.warning({
@@ -387,7 +420,7 @@
    this.setState({
      selectedData: []
    })
    this.handleTableId()
    MKEmitter.emit('changeTableLine', this.props.ContainerId, this.props.Tab.uuid, '', '')
    if (setting.interType === 'custom' && loadCustomApi) {
      if (setting.execTime === 'once') {
@@ -396,18 +429,17 @@
      this.loadOutResource(searches)
      if (setting.execType === 'async') {
        this.loadmaindata()
        this.loadmaindata(id)
      }
    } else {
      this.loadmaindata()
      this.loadmaindata(id)
    }
  }
  loadOutResource = (searches) => {
    const { BID } = this.props
    const { setting } = this.state
    const { setting, BID } = this.state
    let param = UtilsDM.getPrevQueryParams(setting, searches, BID, this.props.menuType)
    let param = UtilsDM.getPrevQueryParams(setting, searches, BID)
    if (setting.execType === 'sync') {
      this.setState({
@@ -466,7 +498,7 @@
    })
    Api.directRequest(url, setting.method, param, setting.cross).then(res => {
      if (typeof(res) !== 'object' || Array.isArray(res)) {
      if (typeof(res) !== 'object') {
        let error = '未知的返回结果!'
        if (typeof(res) === 'string') {
@@ -481,6 +513,9 @@
        this.customCallbackRequest(_result)
      } else {
        if (Array.isArray(res)) {
          res = { data: res }
        }
        res.mk_api_key = mkey
        this.customCallbackRequest(res)
      }
@@ -496,7 +531,7 @@
  }
  customCallbackRequest = (result) => {
    const { setting } = this.state
    const { setting, BID } = this.state
    let errSql = ''
    if (result.$ErrCode === 'E') {
      errSql = `
@@ -518,15 +553,7 @@
      `))
      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)
      }
      param = UtilsDM.getCallBackQueryParams(setting, sql, errSql, BID)
    } else {
      param.func = 's_ex_result_back'
      param.s_ex_result = lines.map((item, index) => ({
@@ -537,7 +564,7 @@
        Sort: index + 1
      }))
      if ((window.GLOB.systemType !== 'production' && options.sysType !== 'cloud') || window.debugger === true) {
      if (window.GLOB.debugger === true || (window.debugger === true && options.sysType !== 'cloud')) {
        let sql = lines.map(item => (`
          ${item.insert}
          ${item.selects.join(` union all
@@ -571,9 +598,9 @@
  /**
   * @description 子表数据加载
   */
  async loadmaindata () {
    const { mainSearch, BID } = this.props
    const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state
  async loadmaindata (id) {
    const { mainSearch } = this.props
    const { setting, BID, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state
    let searches = fromJS(search).toJS()
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
@@ -585,17 +612,27 @@
    })
    let _orderBy = orderBy || setting.order
    let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType)
    if (param.func === 'sPC_Get_TableData') {
      param.menuname = this.props.Tab.label || ''
    }
    let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID)
    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' || (setting.orisel && id)) {
        setTimeout(() => {
          MKEmitter.emit('mkTableCheckTopLine', this.props.MenuID, id)
        }, 200)
        if (setting.selected === 'init') {
          this.setState({setting: {...setting, selected: 'false'}})
        }
      }
      this.setState({
        data: result.data.map((item, index) => {
          if (absFields.length) {
@@ -608,7 +645,15 @@
          }
          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
        }),
@@ -634,8 +679,8 @@
   * @description 获取单行数据
   */ 
  async loadmainLinedata (id) {
    const { mainSearch, BID } = this.props
    const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state
    const { mainSearch } = this.props
    const { setting, BID, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state
    let searches = fromJS(search).toJS()
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
@@ -647,17 +692,14 @@
    })
    let _orderBy = orderBy || setting.order
    let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, this.props.menuType, id)
    if (param.func === 'sPC_Get_TableData') {
      param.menuname = this.props.Tab.label || ''
    }
    let param = UtilsDM.getQueryDataParams(setting, arr_field, searches, _orderBy, pageIndex, pageSize, BID, 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]
        let _data = result.data[0] || {}
        if (absFields.length) {
          absFields.forEach(field => {
@@ -668,25 +710,34 @@
          })
        }
        _data.$$uuid = _data[setting.primaryKey] || ''
        _data.$$BID = BID || ''
        try {
          data = data.map(item => {
            if (item[setting.primaryKey] === _data[setting.primaryKey]) {
            if (item.$$uuid === _data.$$uuid) {
              _data.key = item.key
              _data.$$uuid = _data[setting.primaryKey] || ''
              _data.$$BID = BID || ''
              _data.$$key = '' + item.key + item.$$uuid
              _data.$Index = item.$Index
              return _data
            } else {
              return item
            }
          })
        } catch {
          selectedData = selectedData.map(item => {
            if (_data.$$uuid === item.$$uuid) {
              return _data
            }
            return item
          })
        } catch (e) {
          console.warn('数据查询错误')
        }
      }
      this.setState({
        data: data,
        data,
        selectedData,
        loading: false
      })
    } else {
@@ -705,18 +756,13 @@
   * @description 获取合计字段值
   */
  getStatFieldsValue = (searches) => {
    const { BID } = this.props
    const { setting, orderBy, statFields } = this.state
    const { setting, BID, 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)
    let param = UtilsDM.getStatQueryDataParams(setting, statFields, searches, _orderBy, BID)
    if (param.func === 'sPC_Get_TableData') {
      param.menuname = this.props.Tab.label || ''
    }
    Api.genericInterface(param).then(res => {
      if (res.status) {
        let _data = res.data[0]
@@ -755,7 +801,7 @@
   * 含有初始不加载的页面,修改设置
   */
  refreshbysearch = (searches) => {
    MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 列表重置
    MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置
    this.setState({
      pageIndex: 1,
      search: searches,
@@ -788,24 +834,24 @@
  /**
   * @description 表格刷新
   */
  reloadtable = (btn) => {
  reloadtable = (btn, id = '') => {
    if (!btn || btn.resetPageIndex !== 'false') {
      MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid) // 列表重置
      MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置
      this.setState({
        pageIndex: 1
      }, () => {
        this.loadData()
        this.loadData(id)
      })
    } else {
      MKEmitter.emit('resetTable', this.props.MenuID + this.props.Tab.uuid, 'false') // 列表重置
      this.loadData()
      MKEmitter.emit('resetTable', this.props.Tab.uuid, 'false') // 列表重置
      this.loadData(id)
    }
  }
  /**
   * @description 导出Excel时,获取页面搜索排序等参数
   */
  getexceloutparam = (menuId, btnId) => {
  queryModuleParam = (menuId, callback) => {
    const { Tab, mainSearch, MenuID } = this.props
    const { arr_field, orderBy, search, setting} = this.state
@@ -816,7 +862,7 @@
      searches = [...mainSearch, ...search]
    }
    MKEmitter.emit('execExcelout', MenuID, btnId, {
    callback({
      arr_field: arr_field,
      orderBy: orderBy || setting.order,
      search: searches,
@@ -829,13 +875,6 @@
   */
  changeSelectedData = (selectedData) => {
    this.setState({selectedData})
  }
  /**
   * @description 表格Id变化
   */
  handleTableId = (type = this.props.Tab.uuid, id = '', data = '') => {
    this.props.handleTableId(type, id, data)
  }
  /**
@@ -860,7 +899,6 @@
    const { MenuID } = this.props
    if (menuId.indexOf(MenuID) === -1) return
    if (id === 'empty') return
    if (!id) {
      this.reloadtable()
@@ -875,29 +913,54 @@
   * @param {*} position   // 刷新位置
   * @param {*} btn        // 执行的按钮
   */
  refreshByButtonResult = (menuId, position, btn) => {
  refreshByButtonResult = (menuId, position, btn, id, lines) => {
    const { MenuID } = this.props
    if (MenuID !== menuId) return
    const { Tab, SupMenuID, BID } = this.props
    const { Tab, SupMenuID } = this.props
    const { BID } = this.state
    if (position === 'grid' || position === 'view') {
      this.reloadtable(btn)
    if (position === 'line') {
      if (lines && lines.length === 1) {
        this.loadmainLinedata(lines[0].$$uuid)
      } else {
        this.reloadtable(btn, id)
      }
    } else if (position === 'grid' || position === 'view') {
      this.reloadtable(btn, id)
    } else if (position === 'maingrid' || position === 'mainline') {
      this.reloadtable(btn)
      if (Tab.supMenu === 'mainTable') {
        MKEmitter.emit('reloadData', SupMenuID, (BID || 'empty'))   // 主表重置
      } else if (Tab.supMenu) {
        MKEmitter.emit('reloadData', Tab.supMenu, (BID || 'empty')) // 主表重置
      } else if (!Tab.supMenu && Tab.level === 0) {
        MKEmitter.emit('reloadData', SupMenuID, (BID || 'empty'))   // 树形结构,0级标签
      this.reloadtable(btn, id)
      if (Tab.supMenu && BID) {
        MKEmitter.emit('reloadData', Tab.supMenu, BID) // 主表重置
      } else if (!Tab.supMenu && Tab.level === 0 && BID) {
        MKEmitter.emit('reloadData', SupMenuID, BID)   // 树形结构,0级标签
      }
    } else if (position === 'equaltab') {
      this.reloadtable(btn)
      this.reloadtable(btn, id)
      if (Tab.equalTab && Tab.equalTab.length > 0) {
        MKEmitter.emit('reloadData', Tab.equalTab.join(',')) // 同级标签重置
      }
    }
  }
  changeTableLine = (ContainerId, tableId, id, data) => {
    const { Tab } = this.props
    const { setting } = this.state
    if (!Tab.supMenu || tableId !== Tab.supMenu) return
    this.setState({BData: data, BID: id})
    if (!setting) return
    if (id !== this.state.BID || id !== '') {
      MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置
      this.setState({
        pageIndex: 1
      }, () => {
        this.loadData()
      })
    }
  }
@@ -906,13 +969,14 @@
    this.loadconfig()
  }
  shouldComponentUpdate (nextProps, nextState) { // handleTableId 函数判断时不相等
    return !is(fromJS({...this.props, handleTableId: ''}), fromJS({...nextProps, handleTableId: ''})) || !is(fromJS(this.state), fromJS(nextState))
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState))
  }
  componentDidMount () {
    MKEmitter.addListener('reloadData', this.reloadData)
    MKEmitter.addListener('getexceloutparam', this.getexceloutparam)
    MKEmitter.addListener('changeTableLine', this.changeTableLine)
    MKEmitter.addListener('queryModuleParam', this.queryModuleParam)
    MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
  }
@@ -924,24 +988,25 @@
      return
    }
    MKEmitter.removeListener('reloadData', this.reloadData)
    MKEmitter.removeListener('getexceloutparam', this.getexceloutparam)
    MKEmitter.removeListener('changeTableLine', this.changeTableLine)
    MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
  }
  render() {
    const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, chartId, selectedData } = this.state
    const { config, BID, BData, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, chartId, selectedData } = this.state
    return (
      <div className="subtable" id={'subtable' + this.props.MenuID}>
        {loadingview && <Spin />}
        {searchlist && searchlist.length ?
          <SubSearch BID={this.props.BID} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null
          <SubSearch BID={BID} setting={setting} searchlist={searchlist} refreshdata={this.refreshbysearch}/> : null
        }
        {config ? <Row className="chart-view" gutter={16}>
        {config && 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 => {
@@ -952,12 +1017,12 @@
                  {config.charts.length > 1 ? <p className="chart-table chart-title">{item.title}</p> : null}
                  <div className="sub-action">
                    <SubAction
                      BID={BID}
                      BData={BData}
                      setting={setting}
                      actions={actions}
                      columns={columns}
                      Tab={this.props.Tab}
                      BID={this.props.BID}
                      BData={this.props.BData}
                      MenuID={this.props.MenuID}
                      selectedData={selectedData}
                      ContainerId={this.props.ContainerId}
@@ -965,9 +1030,10 @@
                  </div>
                  <div className="subtable-box">
                    {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && this.state.data && this.state.data.length > 0 ?
                      <Switch title="收起" className="subtable-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null
                      <Switch title="收起" className="subtable-pickup" checkedChildren="开" unCheckedChildren="关" checked={pickup} onChange={this.pickupChange} /> : null
                    }
                    <SubTable
                      BData={BData}
                      tableId={this.props.Tab.uuid}
                      pickup={pickup}
                      setting={setting}
@@ -975,14 +1041,12 @@
                      pageSize={pageSize}
                      dict={this.state.dict}
                      data={this.state.data}
                      BData={this.props.BData}
                      total={this.state.total}
                      MenuID={this.props.MenuID}
                      loading={this.state.loading}
                      statFValue={this.state.statFValue}
                      ContainerId={this.props.ContainerId}
                      refreshdata={this.refreshbytable}
                      handleTableId={this.handleTableId}
                      chgSelectData={this.changeSelectedData}
                    />
                  </div>
@@ -992,17 +1056,17 @@
              return (
                <Col className="card-view" span={item.width} key={item.uuid}>
                  <CardComponent
                    BID={BID}
                    plot={item}
                    BData={BData}
                    config={config}
                    columns={columns}
                    Tab={this.props.Tab}
                    BID={this.props.BID}
                    BData={this.props.BData}
                    data={this.state.data}
                    MenuID={this.props.MenuID}
                    loading={this.state.loading}
                    tableId={this.props.Tab.uuid}
                    handleTableId={this.handleTableId}
                    ContainerId={this.props.ContainerId}
                  />
                </Col>
              )
@@ -1010,9 +1074,9 @@
              return (
                <Col span={item.width} key={item.uuid}>
                  <ChartComponent
                    BID={BID}
                    plot={item}
                    config={config}
                    BID={this.props.BID}
                    Tab={this.props.Tab}
                    data={this.state.data}
                    loading={this.state.loading}
@@ -1022,6 +1086,43 @@
            }
          })}
        </Row> : null }
        {config && !config.charts ? <>
          <div className="sub-action">
            <SubAction
              BID={BID}
              BData={BData}
              setting={setting}
              actions={actions}
              columns={columns}
              Tab={this.props.Tab}
              MenuID={this.props.MenuID}
              selectedData={selectedData}
              ContainerId={this.props.ContainerId}
            />
          </div>
          <div className="subtable-box">
            {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && this.state.data && this.state.data.length > 0 ?
              <Switch title="收起" className="subtable-pickup" checkedChildren="开" unCheckedChildren="关" checked={pickup} onChange={this.pickupChange} /> : null
            }
            <SubTable
              BData={BData}
              tableId={this.props.Tab.uuid}
              pickup={pickup}
              setting={setting}
              columns={columns}
              pageSize={pageSize}
              dict={this.state.dict}
              data={this.state.data}
              total={this.state.total}
              MenuID={this.props.MenuID}
              loading={this.state.loading}
              statFValue={this.state.statFValue}
              ContainerId={this.props.ContainerId}
              refreshdata={this.refreshbytable}
              chgSelectData={this.changeSelectedData}
            />
          </div>
        </> : null }
        {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
      </div>
    )
@@ -1030,7 +1131,6 @@
const mapStateToProps = (state) => {
  return {
    menuType: state.editLevel,
    permAction: state.permAction,
    permMenus: state.permMenus,
  }