king
2024-06-21 2bccb9ec7bdefe23292a22bc153463cfa1479a49
src/tabviews/subtabtable/index.jsx
@@ -1,16 +1,12 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import {connect} from 'react-redux'
import { is, fromJS } from 'immutable'
import { notification, Spin, Col, Row, Icon, Tabs} from 'antd'
import { notification, Spin, 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 { updateSubTable } from '@/utils/utils-update.js'
import { updateSubTabTable } from '@/utils/utils-update.js'
import asyncComponent from '@/utils/asyncComponent'
import asyncSpinComponent from '@/utils/asyncSpinComponent'
import NotFount from '@/components/404'
@@ -18,12 +14,9 @@
import './index.scss'
const { TabPane } = Tabs
const SubSearch = asyncComponent(() => import('@/tabviews/zshare/topSearch'))
const SubAction = asyncComponent(() => import('@/tabviews/zshare/actionList'))
const SubTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable'))
const CardComponent = asyncSpinComponent(() => import('@/tabviews/zshare/cardcomponent'))
const ChartComponent = asyncSpinComponent(() => import('@/tabviews/zshare/chartcomponent'))
class SubTabModalTable extends Component {
  static propTpyes = {
@@ -31,20 +24,16 @@
    BID: PropTypes.string,           // 上级数据ID
    BData: PropTypes.any,            // 上级数据
    MenuID: PropTypes.string,        // 菜单Id
    mainSearch: PropTypes.any,       // 主表搜索条件
    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: [],     // 已选表格数据
@@ -54,19 +43,16 @@
    pageSize: 10,         // 每页数据条数
    orderBy: '',          // 排序
    search: '',           // 搜索条件数组,使用时需分场景处理
    chartId: '',          // 展开图表ID
    statFields: [],       // 合计字段
    statFValue: [],       // 合计值
    absFields: [],        // 绝对值字段
    loadCustomApi: true,  // 加载外部资源
    hasReqFields: false
  }
  /**
   * @description 获取页面配置信息
   */
  async loadconfig () {
    const { permAction, Tab } = this.props
    const { Tab } = this.props
    let param = {
      func: 'sPC_Get_LongParam',
@@ -79,6 +65,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 = ''
@@ -98,7 +85,7 @@
        this.setState({
          loadingview: false,
          viewlost: true,
          lostmsg: this.state.dict['main.view.unenabled']
          lostmsg: '抱歉,您访问的页面未启用,请联系管理员。'
        })
        return
      }
@@ -111,7 +98,7 @@
      let absFields = []     // 绝对值字段
      // 版本兼容
      config = updateSubTable(config)
      config = updateSubTabTable(config)
      // 不支持funcbutton、popview 类型按钮
      let labels = []
@@ -132,21 +119,12 @@
      }
      // 权限过滤
      if (this.props.menuType !== 'HS') {
        config.action = config.action.filter(item => permAction[item.uuid])
      }
      config.action = config.action.filter(item => item.hidden !== 'true')
      let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
      Utils.initSearchVal(config)
      // 字段权限黑名单
      config.search = config.search.filter(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'
        }
        return item
      })
      let roleId = sessionStorage.getItem('role_id') || '' // 角色ID
      config.columns = config.columns.map(col => {
        if (!col.blacklist || col.blacklist.length === 0) return col
@@ -157,23 +135,19 @@
        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 = config.charts[0] ? config.charts[0].uuid : ''
      // 1、筛选字段集,2、过滤隐藏列及合并列中的字段uuid
      config.columns.forEach(col => {
        if (col.field) {
          _arrField.push(col.field)
          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') {
@@ -218,14 +192,56 @@
      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 = Tab.label + '-' + item.label // 用于sPC_TableData_InUpDe记录操作按钮
        item.$menuId = this.props.MenuID
        item.$old = true
        if (item.OpenType === 'popview') return
        if (item.OpenType === 'excelOut') { // 导出
          item.$menuName = Tab.label
        }
        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.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)
        }
      })
@@ -235,23 +251,13 @@
        _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 = '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.interType === 'system') {
        if (config.setting.scripts && config.setting.scripts.length > 0) {
          let _customScript = ''
          config.setting.scripts.forEach(item => {
@@ -273,31 +279,72 @@
        }
  
        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 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)
        })
      } else {
        config.setting.dataresource = ''
      }
      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 = ['']
        }
      }
      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,
        chartId,
        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' && valid) { // 初始化可加载
        if (config.setting.onload !== 'false') { // 初始化可加载
          this.loadData()
        }
      })
@@ -314,35 +361,25 @@
    }
  }
  loadData = () => {
    const { mainSearch } = this.props
    const { setting, search, hasReqFields, loadCustomApi } = this.state
  loadData = (id) => {
    const { setting, search, config } = this.state
    let searches = fromJS(search).toJS()
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
      searches = [...mainSearch, ...searches]
    if (config.$s_req) {
      let requireFields = searches.filter(item => item.required && item.value === '')
      if (requireFields.length > 0) {
        this.setState({
          loading: false
        })
        return
      }
    }
    let requireFields = []
    if (hasReqFields) {
      requireFields = searches.filter(item => item.required && (!item.value || item.value.length === 0))
    }
    if (requireFields.length > 0) {
      let labels = requireFields.map(item => item.label)
      labels = Array.from(new Set(labels))
    if (setting.interType === 'custom') {
      notification.warning({
        top: 92,
        message: this.state.dict['form.required.input'] + labels.join('、') + ' !',
        duration: 3
      })
      return
    } else if (window.GLOB.systemType === 'production' && setting.interType === 'custom' && !setting.proInterface) {
      notification.warning({
        top: 92,
        message: '未设置正式系统地址!',
        message: '系统不在支持自定义接口!',
        duration: 3
      })
      return
@@ -352,207 +389,26 @@
      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' || Array.isArray(res)) {
        let error = '未知的返回结果!'
        if (typeof(res) === 'string') {
          error = res.replace(/'/ig, '"')
        }
        let _result = {
          mk_api_key: mkey,
          $ErrCode: 'E',
          $ErrMesg: error
        }
        this.customCallbackRequest(_result)
      } else {
        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 {
      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
      })
    })
    this.loadmaindata(id)
  }
  /**
   * @description 子表数据加载
   */
  async loadmaindata () {
    const { mainSearch, BID } = this.props
    const { setting, arr_field, search, orderBy, pageIndex, pageSize, absFields } = this.state
  async loadmaindata (id) {
    const { BID } = this.props
    const { setting, search, orderBy, pageIndex, pageSize, absFields } = this.state
    let searches = fromJS(search).toJS()
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
      searches = [...mainSearch, ...searches]
    }
    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 param = UtilsDM.getQueryDataParams(setting, searches, _orderBy, pageIndex, pageSize, BID)
    if (param.func === 'sPC_Get_TableData') {
      param.menuname = this.props.Tab.label || ''
    }
    delete param.s_version_up
    let result = await Api.genericInterface(param)
@@ -562,6 +418,15 @@
      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({
@@ -576,8 +441,15 @@
          }
          item.key = index
          item.$$uuid = item[setting.primaryKey] || ''
          item.$$key = '' + item.key + item.$$uuid
          item.$$BID = BID || ''
          item.$Index = start + index
          item.$Index = start + index + ''
          if (setting.controlField) {
            if (setting.controlVal.includes(item[setting.controlField] + '')) {
              item.$disabled = true
            }
          }
          return item
        }),
@@ -588,11 +460,17 @@
      this.setState({
        loading: false
      })
      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
        })
      }
    }
  }
@@ -603,15 +481,11 @@
    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
    if (statFields.length === 0 || setting.interType !== '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]
@@ -646,11 +520,87 @@
  }
  /**
   * @description 获取单行数据
   */
  async loadmainLinedata (id) {
    const { BID } = this.props
    const { setting, 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, searches, _orderBy, pageIndex, pageSize, BID, id)
    delete param.s_version_up
    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.$$key = '' + item.key + item.$$uuid
              _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.MenuID + this.props.Tab.uuid) // 列表重置
    MKEmitter.emit('resetTable', this.props.Tab.uuid) // 列表重置
    this.setState({
      pageIndex: 1,
      search: searches
@@ -683,17 +633,17 @@
  /**
   * @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)
    }
    
  }
@@ -708,22 +658,15 @@
  /**
   * @description 导出Excel时,获取页面搜索排序等参数
   */
  getexceloutparam = (menuId, btnId) => {
    const { Tab, mainSearch, 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
    let searches = search
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
      searches = [...mainSearch, ...search]
    }
    MKEmitter.emit('execExcelout', MenuID, btnId, {
      arr_field: arr_field,
    callback({
      orderBy: orderBy || setting.order,
      search: searches,
      menuName: Tab.label
      search: search
    })
  }
@@ -733,20 +676,17 @@
   * @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)
    }
    MKEmitter.emit('refreshPopButton', this.props.Tab.uuid)
  }
  /**
   * @description 图表视图切换
   */
  changeChart = (uuid) => {
    this.setState({chartId: uuid})
  }
  UNSAFE_componentWillMount () {
@@ -759,7 +699,7 @@
  }
  componentDidMount () {
    MKEmitter.addListener('getexceloutparam', this.getexceloutparam)
    MKEmitter.addListener('queryModuleParam', this.queryModuleParam)
    MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
  }
@@ -770,109 +710,48 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('getexceloutparam', this.getexceloutparam)
    MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
  }
  render() {
    const { config, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, chartId, selectedData } = this.state
    const { config, setting, 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} searchlist={searchlist} menuType={this.props.menuType} refreshdata={this.refreshbysearch}/> : null
        {config && config.search && config.search.length ?
          <SubSearch BID={this.props.BID} config={config} refreshdata={this.refreshbysearch}/> : null
        }
        {config ? <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>
            ))}
          </Tabs> : null}
          {config.charts.map(item => {
            if (!config.expand && chartId !== item.uuid) return null
            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 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>
                  <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}
                    handleTableId={() => {}}
                  />
                </Col>
              )
            } else if (item.chartType === 'card') {
              return (
                <Col className="card-view" span={item.width} key={item.uuid}>
                  <CardComponent
                    tableId=""
                    plot={item}
                    config={config}
                    columns={columns}
                    BID={this.props.BID}
                    data={this.state.data}
                    BData={this.props.BData}
                    loading={this.state.loading}
                    handleTableId={() => {}}
                  />
                </Col>
              )
            } else {
              return (
                <Col span={item.width} key={item.uuid}>
                  <ChartComponent
                    plot={item}
                    config={config}
                    data={this.state.data}
                    loading={this.state.loading}
                  />
                </Col>
              )
            }
          })}
        </Row> : null }
        {config ? <div style={{minHeight: '25px'}}>
          <SubAction
            setting={setting}
            actions={actions}
            columns={columns}
            BID={this.props.BID}
            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}
          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)
export default SubTabModalTable