king
2021-10-21 1da6506bf58270bacc2a4345002c6b082835580e
src/tabviews/formtab/index.jsx
@@ -16,7 +16,6 @@
import FormGroup from './formgroup'
import FormAction from './actionList'
import NotFount from '@/components/404'
import { modifyTabview } from '@/store/action'
import './index.scss'
const { TabPane } = Tabs
@@ -49,11 +48,11 @@
   * @description 获取页面配置信息
   */
  async loadconfig () {
    const { permAction } = this.props
    const { permAction, MenuID } = this.props
    let param = {
      func: 'sPC_Get_LongParam',
      MenuID: this.props.MenuID
      MenuID: MenuID
    }
    let result = await Api.getCacheConfig(param)
    if (result.status) {
@@ -104,13 +103,15 @@
        config.tabgroups = _tabgroups
      }
      // 权限过滤
      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.action = config.action.filter(item => permAction[item.uuid])
      config.tabgroups.forEach(group => {
        group.sublist = group.sublist.filter(tab => {
          if (tab.supMenu === 'mainTable') {
            tab.supMenu = MenuID
          }
          return permAction[tab.linkTab]
        })
      }
      })
      // 按钮类型兼容
      config.action = config.action.map(item => {
@@ -142,8 +143,8 @@
        primaryId: this.props.param.primaryId || '',
        data: this.props.param.data || null,
        BIDs: {
          mainTable: config.setting.onload !== 'false' ? (this.props.param.primaryId || '') : '',
          mainTabledata: config.setting.onload !== 'false' ? (config.setting.datatype === 'query' ? '' : this.props.param.data) : ''
          [MenuID]: config.setting.onload !== 'false' ? (this.props.param.primaryId || '') : '',
          [MenuID + 'data']: config.setting.onload !== 'false' ? (config.setting.datatype === 'query' ? '' : this.props.param.data) : ''
        }
      }, () => {
        this.improveSelectOption(config.groups)
@@ -341,11 +342,7 @@
      this.setState({
        data: _data,
        primaryId: _primaryId,
        BIDs: {
          ...BIDs,
          mainTable: _primaryId,
          mainTabledata: _data
        }
        BIDs: { ...BIDs, [this.props.MenuID]: _primaryId, [this.props.MenuID + 'data']: _data }
      })
      if (_data && (setting.interType !== 'inner' || (setting.interType === 'inner' && setting.innerFunc))) {
@@ -494,11 +491,7 @@
          }
          this.setState({
            BIDs: {
              ...BIDs,
              mainTable: primaryId,
              mainTabledata: data
            }
            BIDs: { ...BIDs, [this.props.MenuID]: primaryId, [this.props.MenuID + 'data']: data }
          })
        }
      })
@@ -507,16 +500,7 @@
        MKEmitter.emit('reloadData', this.props.param.parentId, 'formtab', btn)
      }
      let tabs = this.props.tabviews.filter(tab => {
        tab.selected = false
        if (tab.MenuID === this.props.param.parentId) {
          tab.selected = true
        }
        return tab.MenuID !== this.props.MenuID
      })
      this.props.modifyTabview(tabs)
      MKEmitter.emit('closeTabView', this.props.MenuID)
    } else if (type === 'error' && btn.afterExecError === 'notclose') {
      if (btn.execError === 'refresh') {
        this.loadmaindata()
@@ -525,33 +509,8 @@
      if (btn.execError !== 'never') {
        MKEmitter.emit('reloadData', this.props.param.parentId, 'formtab', btn)
      }
      let tabs = this.props.tabviews.filter(tab => {
        tab.selected = false
        if (tab.MenuID === this.props.param.parentId) {
          tab.selected = true
        }
        return tab.MenuID !== this.props.MenuID
      })
      this.props.modifyTabview(tabs)
      MKEmitter.emit('closeTabView', this.props.MenuID)
    }
  }
  /**
   * @description 表格Id变化
   */
  handleTableId = (type, id, data) => {
    const { BIDs } = this.state
    this.setState({
      BIDs: {
        ...BIDs,
        [type]: id,
        [type + 'data']: data
      }
    })
  }
  /**
@@ -594,6 +553,14 @@
    this.loadmaindata()
  }
  changeTableLine = (ContainerId, tableId, id, data) => {
    if (this.state.ContainerId !== ContainerId) return
    this.setState({
      BIDs: {...this.state.BIDs, [tableId]: id, [tableId + 'data']: data}
    })
  }
  UNSAFE_componentWillMount () {
    // 组件加载时,获取菜单数据
    this.loadconfig()
@@ -604,8 +571,9 @@
  }
  componentDidMount () {
    MKEmitter.addListener('reloadMenuView', this.reloadMenuView)
    MKEmitter.addListener('reloadData', this.reloadData)
    MKEmitter.addListener('reloadMenuView', this.reloadMenuView)
    MKEmitter.addListener('changeTableLine', this.changeTableLine)
  }
  /**
@@ -616,8 +584,9 @@
      return
    }
    MKEmitter.removeListener('reloadMenuView', this.reloadMenuView)
    MKEmitter.removeListener('reloadData', this.reloadData)
    MKEmitter.removeListener('reloadMenuView', this.reloadMenuView)
    MKEmitter.removeListener('changeTableLine', this.changeTableLine)
  }
  render() {
@@ -673,7 +642,6 @@
                        ContainerId={this.state.ContainerId}
                        BID={this.state.BIDs[_tab.supMenu] || ''}
                        BData={this.state.BIDs[_tab.supMenu + 'data'] || ''}
                        handleTableId={this.handleTableId}
                      />
                    </TabPane>
                  )
@@ -682,7 +650,7 @@
            )
          })
        }
        {this.props.menuType !== 'HS' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null}
        {this.props.menuType !== 'HS' && window.GLOB.systemType !== 'production' ? <PagemsgComponent menu={{MenuName: this.props.MenuName, MenuNo: this.props.MenuNo}} config={config} dict={this.state.dict} /> : null}
        {viewlost ? <NotFount msg={this.state.lostmsg} /> : null}
      </div>
    )
@@ -692,15 +660,12 @@
const mapStateToProps = (state) => {
  return {
    menuType: state.editLevel,
    tabviews: state.tabviews,
    permAction: state.permAction
  }
}
const mapDispatchToProps = (dispatch) => {
  return {
    modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews))
  }
const mapDispatchToProps = () => {
  return {}
}
export default connect(mapStateToProps, mapDispatchToProps)(NormalTable)