king
2020-07-16 9a82bce9cf0ed4a51c1b0b0669eaa38cedbace07
src/tabviews/commontable/index.jsx
@@ -6,25 +6,28 @@
import moment from 'moment'
import Api from '@/api'
import options from '@/store/options.js'
import zhCN from '@/locales/zh-CN/main.js'
import enUS from '@/locales/en-US/main.js'
import Utils from '@/utils/utils.js'
import asyncComponent from '@/utils/asyncComponent'
import asyncLoadComponent from '@/utils/asyncLoadComponent'
import {refreshTabView, modifyTabview} from '@/store/action'
import asyncSpinComponent from '@/utils/asyncSpinComponent'
import { refreshTabView } from '@/store/action'
import MainTable from '@/tabviews/zshare/normalTable'
import MainSearch from '@/tabviews/zshare/topSearch'
import NotFount from '@/components/404'
import './index.scss'
const MainAction = asyncLoadComponent(() => import('@/tabviews/zshare/actionList'))
const VerifyCard = asyncComponent(() => import('@/tabviews/zshare/verifycard'))
const SubTable = asyncComponent(() => import('@/tabviews/subtable'))
const SubTabTable = asyncComponent(() => import('@/tabviews/subtabtable'))
const FormTab = asyncComponent(() => import('@/tabviews/formtab'))
const CardComponent = asyncComponent(() => import('@/tabviews/zshare/cardcomponent'))
const ChartComponent = asyncComponent(() => import('@/tabviews/zshare/chartcomponent'))
// 通用组件
const MainAction = asyncSpinComponent(() => import('@/tabviews/zshare/actionList'))
const MainTable = asyncSpinComponent(() => import('@/tabviews/zshare/normalTable'))
const SettingComponent = asyncComponent(() => import('@/tabviews/zshare/settingcomponent'))
const SubTable = asyncSpinComponent(() => import('@/tabviews/subtable'))
const CardComponent = asyncSpinComponent(() => import('@/tabviews/zshare/cardcomponent'))
const ChartComponent = asyncSpinComponent(() => import('@/tabviews/zshare/chartcomponent'))
// 自定义标签
const SecretKeyTable = asyncSpinComponent(() => import('./secretKeyTable'))
const { TabPane } = Tabs
const { TreeNode } = Tree
@@ -41,13 +44,12 @@
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    ContainerId: Utils.getuuid(), // 菜单外层html Id
    view: 'commontable',  // 当前页面默认为主表
    BID: null,            // 页面跳转时携带ID
    loadingview: true,    // 页面加载中
    viewlost: false,      // 页面丢失:1、未获取到配置-页面丢失;2、页面未启用
    lostmsg: '',          // 页面丢失时的提示信息
    config: {},           // 页面配置信息,包括按钮、搜索、显示列、标签等
    userConfig: null,     // 用户自定义设置
    userParam: null,      // 保存用户编辑中的配置
    searchlist: null,     // 搜索条件
    actions: null,        // 按钮集
    columns: null,        // 显示列
@@ -55,6 +57,8 @@
    arr_field: '',        // 使用 sPC_Get_TableData 时的查询字段集
    setting: null,        // 页面全局设置:数据源、按钮及显示列固定、主键等
    data: null,           // 列表数据集
    selectedData: [],     // 已选表格数据
    resetTable: false,    // 表格重置,值在true与false之间切换,切换时表格重置
    total: 0,             // 总数
    loading: false,       // 列表数据加载中
    pageIndex: 1,         // 页码
@@ -63,16 +67,8 @@
    search: '',           // 搜索条件数组,使用时需分场景处理
    BIDs: {},             // 上级表id
    pickup: false,        // 主表数据隐藏显示切换
    popAction: false,     // 弹框页面,按钮信息
    popData: null,        // 弹框页面,所选的表格数据
    visible: false,       // 弹框显示隐藏控制
    treevisible: false,   // 菜单结构树弹框显示隐藏控制
    tabBtn: null,         // 表单标签按钮
    tabParam: null,       // 表单标签参数
    refreshtabs: null,    // 需要刷新的标签集
    confirmLoading: false,// 自定义设置模态框加载中
    revertLoading: false, // 恢复默认设置
    settingVisible: false,// 自定义设置模态框
    triggerBtn: null,     // 点击表格中或快捷键触发的按钮
    tabActive: null,      // 标签页展开控制
    chartId: ''           // 展开图表ID
@@ -102,7 +98,8 @@
        config = ''
      }
      
      if (result.LongParamUser) {
      // HS不使用自定义设置
      if (result.LongParamUser && this.props.menuType !== 'HS') {
        try { // 配置信息解析
          userConfig = JSON.parse(window.decodeURIComponent(window.atob(result.LongParamUser)))
          _curUserConfig = userConfig[this.props.MenuID]
@@ -131,48 +128,75 @@
        return
      }
      // 兼容标签
      if (!config.tabgroups) {
        config.tabgroups = [{ uuid: 'tabs', sublist: [] }]
      } else if (typeof(config.tabgroups[0]) === 'string') {
        let _tabgroups = []
        config.tabgroups.forEach(groupId => {
          let _group = {
            uuid: groupId,
            sublist: fromJS(config[groupId]).toJS()
          }
      if (!config.version || config.version < '1.0') {
        // 兼容标签
        if (!config.tabgroups) {
          config.tabgroups = [{ uuid: 'tabs', sublist: [] }]
        } else if (typeof(config.tabgroups[0]) === 'string') {
          let _tabgroups = []
          config.tabgroups.forEach(groupId => {
            let _group = {
              uuid: groupId,
              sublist: fromJS(config[groupId]).toJS()
            }
            delete config[groupId]
            _tabgroups.push(_group)
          })
          config.tabgroups = _tabgroups
        }
        // 兼容图表
        if (!config.charts) {
          config.expand = true
          config.charts = [{ uuid: Utils.getuuid(), label: '', title: '', chartType: 'table', icon: 'table', Hide: 'false', blacklist: [] }]
        } else {
          config.charts.forEach(card => {
            if (card.chartType === 'card') {
              card.details = card.details.map(_cell => {
                _cell.fontSize = _cell.fontSize || 14
                if (!_cell.width) {
                  _cell.width = 100
                } else if (_cell.width === 'helf') {
                  _cell.width = 50
                } else if (_cell.width === 'third') {
                  _cell.width = 33
                }
                if (!_cell.fontWeight && _cell.bold === 'true') {
                  _cell.fontWeight = 'normal'
                }
                _cell.height = _cell.height || 1
  
          delete config[groupId]
          _tabgroups.push(_group)
        })
        config.tabgroups = _tabgroups
                return _cell
              })
            }
          })
        }
      }
      // 兼容图表
      let chartId = ''
      if (!config.charts) {
        config.expand = true
        config.charts = [{
          uuid: Utils.getuuid(),
          label: '',
          title: '',
          chartType: 'table',
          icon: 'table',
          Hide: 'false',
          blacklist: []
        }]
      } else if (config.charts.length === 1) {
        config.expand = true
      }
      chartId = config.charts[0].uuid
      // 权限过滤
      config.action = config.action.filter(item => permAction[item.uuid])
      config.tabgroups.forEach(group => {
        group.sublist = group.sublist.filter(tab => permAction[tab.linkTab])
      })
      if (this.props.menuType !== 'HS') {
        config.action = config.action.filter(item => permAction[item.uuid])
        config.tabgroups.forEach(group => {
          group.sublist = group.sublist.filter(tab => permAction[tab.linkTab])
        })
      }
      // 去除空行标签
      config.tabgroups = config.tabgroups.filter(group => group.sublist.length > 0)
      // HS下自定义处理的标签
      if (this.props.menuType === 'HS') {
        config.tabgroups.forEach(group => {
          group.sublist = group.sublist.map(tab => {
            if (tab.linkTab === '1586577325055l2ng7t75g7i4ek2ng8o') {
              tab.type = 'SecretKeyTable'
            }
            return tab
          })
        })
      }
      // 视图权限
      config.charts = config.charts.filter(item => {
@@ -193,35 +217,48 @@
      if (config.charts.length <= 1) {
        config.expand = true
      }
      let chartId = config.charts[0] ? config.charts[0].uuid : ''
      // 字段权限黑名单
      config.search = config.search.filter(item => {
        if (!item.blacklist || item.blacklist.length === 0) return true
      config.search = config.search.map(item => {
        item.oriInitval = item.initval
        if (['text', 'select', 'link'].includes(item.type) && param) {
          if (param.searchkey === item.field) {
            item.initval = param.searchval
          } else if (param.BID && item.field === 'BID') {
            item.initval = param.BID
          }
        }
        if (!item.blacklist || item.blacklist.length === 0) return item
        let _black = item.blacklist.filter(v => {
          return this.props.permRoles.indexOf(v) !== -1
        })
        if (_black.length > 0) {
          return false
        } else {
          return true
          item.Hide = 'true'
        }
        return item
      })
      config.columns = config.columns.filter(col => {
        if (!col.field || !col.blacklist || col.blacklist.length === 0 || config.setting.primaryKey === col.field) return true
      config.columns = config.columns.map(col => {
        if (!col.field || !col.blacklist || col.blacklist.length === 0 || config.setting.primaryKey === col.field) return col
        let _black = col.blacklist.filter(v => {
          return this.props.permRoles.indexOf(v) !== -1
        })
        if (_black.length > 0) {
          return false
        } else {
          return true
          col.Hide = 'true'
        }
        return col
      })
      // 标记主页面,用于按钮固定及表单挂载设置
      config.setting.tabType = 'main'
      if (_curUserConfig) {
        config.setting = {...config.setting, ..._curUserConfig.setting}
@@ -255,7 +292,6 @@
      let _tabActive = {} // 筛选展开的tab页
      config.tabgroups.forEach(group => {
        if (group.sublist.length === 0) return
        _tabActive[group.uuid] = group.sublist[0].uuid
      })
@@ -284,8 +320,9 @@
      config.columns.forEach(col => {
        if (col.field) {
          _arrField.push(col.field)
          _logcolumns.push(col)
          col.nameField && _arrField.push(col.nameField) // 链接名字段
        }
        if (col.type === 'colspan' && col.sublist) { // 筛选隐藏列
          _hideCol = _hideCol.concat(col.sublist)
@@ -306,7 +343,7 @@
        col.sort = index
        if (col.type === 'colspan' && col.sublist) {
          let _col = JSON.parse(JSON.stringify(col))
          let _col = fromJS(col).toJS()
          let subColumn = []
          _col.sublist.forEach(sub => {
            if (colMap.has(sub)) {
@@ -319,20 +356,15 @@
          _columns.push(col)
        }
      })
      if (config.gridBtn && config.gridBtn.display && _operations.length > 0) {
        _columns.push({
          ...config.gridBtn,
          operations: _operations
        })
        config.gridBtn.operations = _operations
        _columns.push(config.gridBtn)
      }
      let valid = true // 搜索条件必填验证, 初始搜索条件
      let valid = true // 搜索条件必填验证, 初始搜索条件, 如通过上级透视,写入搜索条件
      let initSearch = config.search.map(item => {
        let _item = JSON.parse(JSON.stringify(item))
        if (_item.type === 'text' && param && param.searchkey === _item.field) {
          _item.initval = param.searchval
        }
        let _item = fromJS(item).toJS()
        if (_item.required === 'true' && !_item.initval) {
          valid = false
@@ -356,6 +388,7 @@
      }
      this.setState({
        BID: param && param.BID ? param.BID : '',
        loadingview: false,
        chartId: chartId,
        config: config,
@@ -369,7 +402,6 @@
        arr_field: _arrField.join(','),
        search: Utils.initMainSearch(initSearch) // 搜索条件初始化(含有时间格式,需要转化)
      }, () => {
        this.improveSearch()
        if (config.setting.onload !== 'false' && valid) { // 初始化可加载
          this.loadmaindata()
        }
@@ -485,103 +517,10 @@
  }
  /**
   * @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.dataManager) { // 数据权限
          param.LText = param.LText.replace(/\$@/ig, '/*')
          param.LText = param.LText.replace(/@\$/ig, '*/')
        } else {
          param.LText = param.LText.replace(/@\$|\$@/ig, '')
        }
        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) {
        notification.warning({
          top: 92,
          message: 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 {
          notification.warning({
            top: 92,
            message: res.search.label + ':' + res.message,
            duration: 5
          })
        }
      })
      this.setState({searchlist})
    })
  }
  /**
   * @description 主表数据加载
   */ 
  async loadmaindata () {
    const { setting, BIDs, search } = this.state
    const { setting, BIDs, search, BID } = this.state
    let param = ''
    let requireFields = search.filter(item => item.required && (!item.value || item.value.length === 0))
@@ -607,10 +546,12 @@
      param = this.getDefaultParam()
    }
    this.handleTableId('mainTable', '', '')
    if (!param) { // 未获取参数时,不发请求
      return
    if (BID) {
      param.BID = BID
    }
    // 数据管理权限
    if (this.props.dataManager) {
      param.dataM = 'Y'
    }
    let result = await Api.genericInterface(param)
@@ -625,7 +566,8 @@
        pickup: false,
        BIDs: {
          ...BIDs,
          mainTable: ''
          mainTable: '',
          mainTabledata: ''
        }
      })
    } else {
@@ -650,7 +592,6 @@
    let param = {
      OrderCol: orderBy || setting.order,
      dataM: this.props.dataManager ? 'Y' : '',
      ..._search
    }
@@ -662,10 +603,18 @@
    if (setting.interType === 'inner') {
      param.func = setting.innerFunc
    } else {
      if (setting.sysInterface === 'true' && window.GLOB.mainSystemApi) {
        param.rduri = window.GLOB.mainSystemApi
      } else if (setting.sysInterface !== 'true') {
        param.rduri = setting.interface
      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) {
@@ -700,8 +649,7 @@
      obj_name: 'data',
      arr_field: arr_field,
      custom_script: setting.customScript || '',
      default_sql: setting.default || 'true',
      dataM: this.props.dataManager ? 'Y' : ''
      default_sql: setting.default || 'true'
    }
    
    let _orderBy = orderBy || setting.order
@@ -744,10 +692,10 @@
    let DateCount = ''
    if (setting.default !== 'false' && setting.laypage !== 'false') {
      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`
      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 `
      DateCount = `select count(1) as total from ${_dataresource} ${_search}`
    } else if (setting.default !== '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`
      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 = ''
    }
@@ -774,7 +722,7 @@
        LText += `
          aaa:
          if @ErrorCode!=''
            insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@
            insert into tmp_err_retmsg (ID, ErrorCode, retmsg, CreateUserID) select @time_id@,@ErrorCode, @retmsg,@UserID@
        `
      } else {
        param.custom_script += `
@@ -791,6 +739,10 @@
    param.timestamp = moment().format('YYYY-MM-DD HH:mm:ss') + '.000'
    param.secretkey = Utils.encrypt(param.LText, param.timestamp)
    param.DateCount = Utils.formatOptions(DateCount)
    if (this.props.menuType === 'HS') { // 云端数据验证
      param.open_key = Utils.encrypt(param.secretkey, param.timestamp, true)
    }
    return param
  }
@@ -811,9 +763,9 @@
        this.loadmaindata()
      })
    } else {
      this.refs.mainTable && this.refs.mainTable.resetTable()
      this.setState({
        resetTable: !this.state.resetTable,
        selectedData: [],
        pageIndex: 1,
        search: searches
      }, () => {
@@ -835,6 +787,7 @@
    }
    this.setState({
      selectedData: [],
      pageIndex: pagination.current,
      pageSize: pagination.pageSize,
      orderBy: (sorter.field && sorter.order) ? `${sorter.field} ${sorter.order}` : ''
@@ -847,8 +800,9 @@
   * @description 表格刷新
   */
  reloadtable = () => {
    this.refs.mainTable && this.refs.mainTable.resetTable()
    this.setState({
      resetTable: !this.state.resetTable,
      selectedData: [],
      pageIndex: 1
    }, () => {
      this.loadmaindata()
@@ -859,28 +813,9 @@
   * @description 页面刷新,重新获取配置
   */
  reloadview = () => {
    this.setState({
      view: 'commontable',
      loadingview: true,
      viewlost: false,
      lostmsg: '',
      config: {},
      userConfig: null,
      userParam: null,
      searchlist: null,
      actions: null,
      columns: null,
      arr_field: '',
      setting: null,
      data: null,
      total: 0,
      loading: false,
      pageIndex: 1,
      pageSize: 10,
      orderBy: '',
      search: '',
      BIDs: {},
      pickup: false
    this.setState({ loadingview: true, viewlost: false, lostmsg: '',
      data: null, total: 0, loading: false, pageIndex: 1,
      pageSize: 10, orderBy: '', search: '', BIDs: {}, pickup: false
    }, () => {
      this.loadconfig()
    })
@@ -889,37 +824,12 @@
  /**
   * @description 按钮操作完成后(成功或失败),页面刷新,重置页码及选择项
   */
  refreshbyaction = (btn, type) => {
    if (btn.execSuccess === 'grid' && type === 'success') {
  refreshbyaction = (position) => {
    if (position === 'grid') {
      this.reloadtable()
    } else if (btn.execError === 'grid' && type === 'error') {
      this.reloadtable()
    } else if (btn.execSuccess === 'view' && type === 'success') {
    } else if (position === 'view') {
      this.reloadview()
    } else if (btn.execError === 'view' && type === 'error') {
      this.reloadview()
    } else if (btn.popClose === 'view' && type === 'pop') {
      this.reloadview()
    } else if (btn.popClose === 'grid' && type === 'pop') {
      this.reloadtable()
    }
  }
  /**
   * @description 表单操作完成后刷新主页面
   */
  refreshbyformtab = (type) => {
    this.setState({
      view: 'commontable',
      tabBtn: null,
      tabParam: null
    }, () => {
      if (type === 'grid') {
        this.reloadtable()
      } else if (type === 'view') {
        this.reloadview()
      }
    })
  }
  /**
@@ -928,9 +838,11 @@
  handleMainTable = (type, tab) => {
    if (type === 'maingrid' && tab.supMenu === 'mainTable') {
      this.reloadtable()
    } else if (type === 'maingrid' && tab.supMenu) {
    } else if (type === 'mainline' && tab.supMenu === 'mainTable') {
      this.reloadtable()
    } else if ((type === 'maingrid' || type === 'mainline') && tab.supMenu) {
      this.setState({
        refreshtabs: [tab.supMenu]
        refreshtabs: [type, tab.supMenu]
      }, () => {
        this.setState({
          refreshtabs: null
@@ -963,14 +875,10 @@
  }
  /**
   * @description 获取表格选择项
   * @description 表格选择项切换
   */
  gettableselected = () => {
    let data = []
    this.refs.mainTable && this.refs.mainTable.state.selectedRowKeys.forEach(item => {
      data.push(this.refs.mainTable.props.data[item])
    })
    return data
  changeSelectedData = (selectedData) => {
    this.setState({selectedData})
  }
  /**
@@ -1010,84 +918,6 @@
    this.setState({
      pickup: !pickup
    })
  }
  /**
   * @description 触发按钮弹窗(标签页)
   */
  triggerPopview = (btn, data) => {
    const { setting } = this.state
    let _primaryId = ''
    if (data && data[0] && setting.primaryKey) {
      _primaryId = data[0][setting.primaryKey] || ''
    }
    if (btn.OpenType === 'popview') {
      this.setState({
        popAction: btn,
        popData: data[0] || null,
        visible: true
      })
    } else if (btn.OpenType === 'tab') {
      const { tabviews, MenuNo, MenuID } = this.props
      let newtab = {
        MenuNo: MenuNo,
        MenuID: btn.uuid,
        MenuName: btn.label,
        type: btn.tabTemplate,
        selected: true,
        param: {
          menuType: 'main',
          parentId: this.props.MenuID,
          btn: btn,
          data: data[0] || null,
          primaryId: btn.Ot !== 'notRequired' ? _primaryId : '',
          arr_field: this.state.arr_field
        }
      }
      let index = 0
      let isexit = false
      let tabs = tabviews.map((tab, i) => {
        tab.selected = false
        if (tab.MenuID === MenuID) {
          index = i
        } else if (tab.MenuID === btn.uuid) {
          tab.selected = true
          isexit = true
        }
        return tab
      })
      if (!isexit) {
        tabs.splice(index + 1, 0, newtab)
      }
      this.props.modifyTabview(tabs)
    } else if (btn.OpenType === 'blank') {
      this.setState({
        view: 'formtab',
        tabBtn: btn,
        tabParam: {
          menuType: 'main',
          btn: btn,
          data: data[0] || null,
          primaryId: btn.Ot !== 'notRequired' ? _primaryId : '',
          arr_field: this.state.arr_field
        }
      })
    }
  }
  popclose = () => {
    this.setState({
      visible: false
    })
    this.refreshbyaction(this.state.popAction, 'pop')
  }
  handleviewconfig = (e) => {
@@ -1149,127 +979,6 @@
    })
  }
  controlCustomSetting = () => {
    this.setState({
      settingVisible: true,
      confirmLoading: false,
      revertLoading: false
    })
  }
  changeMenuParam = (param) => {
    this.setState({userParam: param})
  }
  linkTrigger = (menu) => {
    const { tabviews, MenuID } = this.props
    menu.selected = true
    let index = 0
    let isexit = false
    let tabs = tabviews.map((tab, i) => {
      tab.selected = false
      if (tab.MenuID === MenuID) {
        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)
  }
  settingRevert = () => {
    let param = {
      func: 's_TrdMenu_UserParam_del',
      MenuID: this.props.MenuID
    }
    this.setState({
      revertLoading: true
    })
    Api.getSystemConfig(param).then(result => {
      if (!result.status) {
        this.setState({
          revertLoading: false
        })
        notification.warning({
          top: 92,
          message: result.message,
          duration: 5
        })
        return
      }
      this.setState({
        settingVisible: false,
        revertLoading: false
      }, () => {
        window.GLOB.CacheMap = new Map()
        this.reloadview()
      })
    })
  }
  settingSubmit = () => {
    const { userParam } = this.state
    let _LongParam = ''
    try {
      _LongParam = window.btoa(window.encodeURIComponent(JSON.stringify(userParam)))
    } catch (e) {
      notification.warning({
        top: 92,
        message: '编译错误',
        duration: 5
      })
      return
    }
    let easyCode = userParam[this.props.MenuID] ? userParam[this.props.MenuID].easyCode : ''
    let param = {
      func: 'sPC_TrdMenu_UserParam',
      MenuID: this.props.MenuID,
      EasyCode: easyCode || '',
      LongParam: _LongParam
    }
    this.setState({
      confirmLoading: true
    })
    Api.getSystemConfig(param).then(result => {
      if (!result.status) {
        this.setState({
          confirmLoading: false
        })
        notification.warning({
          top: 92,
          message: result.message,
          duration: 5
        })
        return
      }
      this.setState({
        settingVisible: false,
        confirmLoading: false
      }, () => {
        window.GLOB.CacheMap = new Map()
        this.reloadview()
      })
    })
  }
  /**
   * @description 图表视图切换
   */
@@ -1300,7 +1009,6 @@
        if (item.type === 'text' && item.key === nextProps.param.searchkey) {
          item.value = nextProps.param.searchval
        }
        return item
      })
      this.refreshbysearch(search)
@@ -1322,244 +1030,191 @@
  }
  render() {
    const { view, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, triggerBtn, userConfig, tabActive, chartId, search } = this.state
    const { BID, setting, searchlist, pageSize, actions, columns, loadingview, viewlost, pickup, config, triggerBtn, userConfig, tabActive, chartId, search, selectedData } = this.state
    return (
      <div>
        {view === 'commontable' ? <div className="commontable pick-control" id={this.state.ContainerId}>
          {loadingview && <Spin size="large" />}
          {searchlist && searchlist.length > 0 ?
            <MainSearch
              ref="mainSearch"
              dict={this.state.dict}
              searchlist={searchlist}
              refreshdata={this.refreshbysearch}
            /> : null
          }
          {setting && setting.onload !== 'false' ? <div className="chart-view">
            {/* 视图组 */}
            {!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
      <div className="commontable pick-control" id={this.state.ContainerId}>
        {loadingview && <Spin size="large" />}
        {searchlist && searchlist.length > 0 ?
          <MainSearch
            BID={BID}
            dict={this.state.dict}
            searchlist={searchlist}
            menuType={this.props.menuType}
            dataManager={this.props.dataManager}
            refreshdata={this.refreshbysearch}
          /> : null
        }
        {setting && setting.onload !== 'false' ? <div className="chart-view">
          {/* 视图组 */}
          {!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 && item.title ? <p className="chart-table chart-title">{item.title}</p> : null}
                    <div style={{minHeight: '25px'}}>
                      <MainAction
                        type="main"
                        menuType="main"
                        setting={setting}
                        actions={actions}
                        triggerBtn={triggerBtn}
                        dict={this.state.dict}
                        MenuID={this.props.MenuID}
                        permRoles={this.props.permRoles}
                        dataManager={this.props.dataManager}
                        logcolumns={this.state.logcolumns}
                        ContainerId={this.state.ContainerId}
                        refreshdata={this.refreshbyaction}
                        triggerPopview={this.triggerPopview}
                        getexceloutparam={this.getexceloutparam}
                        gettableselected={this.gettableselected}
                      />
                    </div>
                    <div className="main-table-box">
                      <Icon className="custom-control" type="setting" onClick={this.controlCustomSetting} />
                      {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && this.state.data && this.state.data.length > 0 ?
                        <Switch title="收起" className="main-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null
                      }
                      <MainTable
                        ref="mainTable"
                        tableId="mainTable"
                        pickup={pickup}
                        config={config}
                        setting={setting}
                        columns={columns}
                        pageSize={pageSize}
                        dict={this.state.dict}
                        data={this.state.data}
                        total={this.state.total}
                        MenuID={this.props.MenuID}
                        memberLevel={this.props.memberLevel}
                        loading={this.state.loading}
                        pagination={setting.laypage !== 'false'}
                        refreshdata={this.refreshbytable}
                        buttonTrigger={this.buttonTrigger}
                        linkTrigger={this.linkTrigger}
                        handleTableId={this.handleTableId}
                      />
                    </div>
                  </Col>
                )
              } else if (item.chartType === 'card') {
                return (
                  <Col span={item.width} key={item.uuid}>
                    <CardComponent
                      plot={item}
            if (item.chartType === 'table') {
              return (
                <Col span={item.width || 24} key={item.uuid}>
                  {config.charts.length > 1 && item.title ? <p className="chart-table chart-title">{item.title}</p> : null}
                  <div style={{minHeight: '25px'}}>
                    <MainAction
                      BID={BID}
                      setting={setting}
                      actions={actions}
                      dict={this.state.dict}
                      triggerBtn={triggerBtn}
                      MenuID={this.props.MenuID}
                      selectedData={selectedData}
                      logcolumns={this.state.logcolumns}
                      ContainerId={this.state.ContainerId}
                      operations={config.gridBtn.operations || []}
                      refreshdata={this.refreshbyaction}
                      getexceloutparam={this.getexceloutparam}
                    />
                  </div>
                  <div className="main-table-box">
                    {this.props.menuType !== 'HS' ? <SettingComponent
                      config={config}
                      columns={columns}
                      dict={this.state.dict}
                      MenuID={this.props.MenuID}
                      MenuName={this.props.MenuName}
                      permAction={this.props.permAction}
                      permRoles={this.props.permRoles}
                      userConfig={this.state.userConfig}
                      reloadview={this.reloadview}
                    /> : null}
                    {(setting.tableType === 'radio' || setting.tableType === 'checkbox') && this.state.data && this.state.data.length > 0 ?
                      <Switch title="收起" className="main-pickup" checkedChildren="开" unCheckedChildren="关" defaultChecked={pickup} onChange={this.pickupChange} /> : null
                    }
                    <MainTable
                      tableId="mainTable"
                      loading={this.state.loading}
                      pickup={pickup}
                      config={config}
                      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}
                      refreshdata={this.refreshbytable}
                      buttonTrigger={this.buttonTrigger}
                      handleTableId={this.handleTableId}
                      resetTable={this.state.resetTable}
                      chgSelectData={this.changeSelectedData}
                    />
                    <div style={{display: 'none'}}>
                      <MainAction
                        type="main"
                        menuType="main"
                        setting={setting}
                        actions={actions}
                        triggerBtn={triggerBtn}
                        dict={this.state.dict}
                        MenuID={this.props.MenuID}
                        permRoles={this.props.permRoles}
                        dataManager={this.props.dataManager}
                        logcolumns={this.state.logcolumns}
                        ContainerId={this.state.ContainerId}
                        refreshdata={this.refreshbyaction}
                        triggerPopview={this.triggerPopview}
                        getexceloutparam={this.getexceloutparam}
                        gettableselected={this.gettableselected}
                      />
                    </div>
                  </Col>
                )
              } else {
                return (
                  <Col span={item.width} key={item.uuid}>
                    <ChartComponent
                      plot={item}
                      config={config}
                      data={this.state.data}
                      loading={this.state.loading}
                    />
                  </Col>
                )
              }
            })}
          </div> : null }
          {setting && setting.onload !== 'false' &&
            config.tabgroups.map(group => {
              if (group.sublist.length === 0) return null
              return (
                <Tabs activeKey={tabActive[group.uuid]} key={group.uuid} onChange={(key) => this.setState({tabActive: {...tabActive, [group.uuid]: key}})}>
                  {group.sublist.map(_tab => {
                    return (
                      <TabPane tab={
                        <span>
                          {_tab.icon ? <Icon type={_tab.icon} /> : null}
                          {_tab.label}
                        </span>
                      } key={_tab.uuid}>
                        {_tab.type === 'SubTable' ?
                          <SubTable
                            Tab={_tab}
                            menuType="main"
                            MenuID={_tab.linkTab}
                            mainSearch={_tab.searchPass === 'true' ? search : null}
                            userConfig={userConfig ? userConfig[_tab.uuid] : null}
                            triggerBtn={triggerBtn}
                            SupMenuID={this.props.MenuID}
                            refreshtabs={this.state.refreshtabs}
                            ContainerId={this.state.ContainerId}
                            BID={this.state.BIDs[_tab.supMenu] || ''}
                            BData={this.state.BIDs[_tab.supMenu + 'data'] || ''}
                            handleTableId={this.handleTableId}
                            handleMainTable={(type) => this.handleMainTable(type, _tab)}
                          /> : null}
                      </TabPane>
                    )
                  })}
                </Tabs>
                  </div>
                </Col>
              )
            })
          }
          <Button
            icon="copy"
            shape="circle"
            className="common-table-copy"
            onClick={this.handleviewconfig}
          />
          <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.state.popData ? this.state.popData[setting.primaryKey] : ''}
              menuType="main"
              SupMenuID={this.props.MenuID}
              MenuID={this.state.popAction.linkTab}
              BData={this.state.popData || ''}
              ContainerId={this.state.ContainerId}
              refreshSupView={this.reloadtable}
            />}
          </Modal>
          <Modal
            className="menu-tree-modal"
            title={'菜单结构树'}
            width={'650px'}
            maskClosable={false}
            visible={this.state.treevisible}
            onCancel={() => this.setState({treevisible: false})}
            footer={[
              <Button key="close" onClick={() => this.setState({treevisible: false})}>{this.state.dict['main.close']}</Button>
            ]}
            destroyOnClose
          >
            <div className="menu-header">
              <span>菜单名称:{this.props.MenuName}</span>
              <span>菜单参数:{<Paragraph copyable>{this.props.MenuNo}</Paragraph>}</span>
            </div>
            {this.state.treevisible ? <Tree defaultExpandAll showLine={true}>
              {this.getTreeNode(config.funcs)}
            </Tree> : null}
          </Modal>
          {/* 按钮使用系统存储过程时,验证信息模态框 */}
          <Modal
            wrapClassName="common-table-custom-modal"
            title={'自定义设置'}
            maskClosable={false}
            width={950}
            visible={this.state.settingVisible}
            onCancel={() => { this.setState({ settingVisible: false }) }}
            footer={[
              <Button key="revert" type="danger" loading={this.state.revertLoading} onClick={this.settingRevert}>{this.state.dict['main.revert.default']}</Button>,
              <Button key="cancel" onClick={() => { this.setState({ settingVisible: false }) }}>{this.state.dict['main.cancel']}</Button>,
              <Button key="confirm" type="primary" loading={this.state.confirmLoading} onClick={this.settingSubmit}>{this.state.dict['main.submit']}</Button>
            ]}
            destroyOnClose
          >
            {this.state.settingVisible ?
              <VerifyCard
                MenuID={this.props.MenuID}
                MenuName={this.props.MenuName}
                permAction={this.props.permAction}
                permRoles={this.props.permRoles}
                config={this.state.config}
                userConfig={this.state.userConfig}
                columns={this.state.columns}
                handleParam={this.changeMenuParam}
              /> : null
            } else if (item.chartType === 'card') {
              return (
                <Col span={item.width} key={item.uuid}>
                  <CardComponent
                    BID={BID}
                    plot={item}
                    config={config}
                    tableId="mainTable"
                    data={this.state.data}
                    MenuID={this.props.MenuID}
                    loading={this.state.loading}
                    logcolumns={this.state.logcolumns}
                    ContainerId={this.state.ContainerId}
                    refreshdata={this.refreshbyaction}
                    handleTableId={this.handleTableId}
                  />
                </Col>
              )
            } else {
              return (
                <Col span={item.width} key={item.uuid}>
                  <ChartComponent
                    BID={BID}
                    plot={item}
                    config={config}
                    data={this.state.data}
                    getexceloutparam={this.getexceloutparam}
                    loading={this.state.loading}
                  />
                </Col>
              )
            }
          </Modal>
          {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
        </div> : null}
        {view === 'formtab' ? <FormTab MenuID={this.state.tabBtn.uuid} param={this.state.tabParam} refresh={this.refreshbyformtab}/> : null}
          })}
        </div> : null }
        {setting && setting.onload !== 'false' &&
          config.tabgroups.map(group => (
            <Tabs activeKey={tabActive[group.uuid]} key={group.uuid} onChange={(key) => this.setState({tabActive: {...tabActive, [group.uuid]: key}})}>
              {group.sublist.map(_tab => {
                return (
                  <TabPane tab={
                    <span>
                      {_tab.icon ? <Icon type={_tab.icon} /> : null}
                      {_tab.label}
                    </span>
                  } key={_tab.uuid}>
                    {_tab.type === 'SubTable' ?
                      <SubTable
                        Tab={_tab}
                        MenuID={_tab.linkTab}
                        mainSearch={_tab.searchPass === 'true' ? search : null}
                        userConfig={userConfig ? userConfig[_tab.uuid] : null}
                        triggerBtn={triggerBtn}
                        SupMenuID={this.props.MenuID}
                        refreshtabs={this.state.refreshtabs}
                        ContainerId={this.state.ContainerId}
                        BID={this.state.BIDs[_tab.supMenu] || ''}
                        BData={this.state.BIDs[_tab.supMenu + 'data'] || ''}
                        handleTableId={this.handleTableId}
                        handleMainTable={(type) => this.handleMainTable(type, _tab)}
                      /> : null}
                    {_tab.type === 'SecretKeyTable' ?
                      <SecretKeyTable
                        Tab={_tab}
                        MenuID={_tab.linkTab}
                        SupMenuID={this.props.MenuID}
                        refreshtabs={this.state.refreshtabs}
                        ContainerId={this.state.ContainerId}
                        BID={this.state.BIDs[_tab.supMenu] || ''}
                        BData={this.state.BIDs[_tab.supMenu + 'data'] || ''}
                        handleMainTable={(type) => this.handleMainTable(type, _tab)}
                      /> : null}
                  </TabPane>
                )
              })}
            </Tabs>)
          )
        }
        {options.sysType !== 'cloud' ? <Button
          icon="copy"
          shape="circle"
          className="common-table-copy"
          onClick={this.handleviewconfig}
        /> : null}
        <Modal
          className="menu-tree-modal"
          title={'菜单结构树'}
          width={'650px'}
          maskClosable={false}
          visible={this.state.treevisible}
          onCancel={() => this.setState({treevisible: false})}
          footer={[
            <Button key="close" onClick={() => this.setState({treevisible: false})}>{this.state.dict['main.close']}</Button>
          ]}
          destroyOnClose
        >
          <div className="menu-header">
            <span>菜单名称:{this.props.MenuName}</span>
            <span>菜单参数:{<Paragraph copyable>{this.props.MenuNo}</Paragraph>}</span>
          </div>
          {this.state.treevisible ? <Tree defaultExpandAll showLine={true}>
            {this.getTreeNode(config.funcs)}
          </Tree> : null}
        </Modal>
        {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
      </div>
    )
  }
@@ -1567,20 +1222,19 @@
const mapStateToProps = (state) => {
  return {
    menuType: state.editLevel,
    tabviews: state.tabviews,
    refreshTab: state.refreshTab,
    permAction: state.permAction,
    permMenus: state.permMenus,
    permRoles: state.permRoles,
    memberLevel: state.memberLevel,
    dataManager: state.dataManager
  }
}
const mapDispatchToProps = (dispatch) => {
  return {
    refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab)),
    modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews))
    refreshTabView: (refreshTab) => dispatch(refreshTabView(refreshTab))
  }
}