king
2021-10-21 1da6506bf58270bacc2a4345002c6b082835580e
src/tabviews/zshare/actionList/tabbutton/index.jsx
@@ -4,7 +4,6 @@
import { is, fromJS } from 'immutable'
import { Button, notification, Icon } from 'antd'
import { modifyTabview } from '@/store/action'
import zhCN from '@/locales/zh-CN/main.js'
import enUS from '@/locales/en-US/main.js'
import MKEmitter from '@/utils/events.js'
@@ -46,11 +45,7 @@
  }
  componentDidMount () {
    const { position } = this.props
    if (position === 'toolbar') {
      MKEmitter.addListener('triggerBtnId', this.actionTrigger)
    }
    MKEmitter.addListener('triggerBtnId', this.actionTrigger)
  }
  UNSAFE_componentWillReceiveProps (nextProps) {
@@ -81,10 +76,17 @@
  /**
   * @description 触发按钮操作
   */
  actionTrigger = (triggerId, record) => {
    const { setting, btn, tabviews, MenuID, selectedData } = this.props
  actionTrigger = (triggerId, record, type) => {
    const { setting, btn, selectedData } = this.props
    const { disabled } = this.state
    if (triggerId && btn.uuid !== triggerId) return
    if ((triggerId && btn.uuid !== triggerId) || disabled) return
    if (type === 'linkbtn' && selectedData && selectedData.length === 1) {
      if (record[0].$Index !== selectedData[0].$Index) {
        return
      }
    }
    
    let data = record || selectedData || []
@@ -112,7 +114,6 @@
        MenuID: btn.uuid,
        MenuName: btn.label,
        type: btn.tabTemplate,
        selected: true,
        param: {
          parentId: this.props.MenuID,
          btn: btn,
@@ -120,10 +121,17 @@
          primaryId: primaryId
        }
      }
    } else if (btn.tabTemplate === 'ThdMenu') {
    } else {
      let menu = null
      if (btn.linkmenu && btn.linkmenu.length > 0) {
      if (btn.MenuID) {
        menu = {
          MenuID: btn.MenuID,
          MenuName: btn.MenuName,
          MenuNo: btn.MenuNo,
          type: btn.tabType
        }
      } else if (btn.linkmenu && btn.linkmenu.length > 0) {
        let menu_id = btn.linkmenu.slice(-1)[0]
        menu = this.props.permMenus.filter(m => m.MenuID === menu_id)[0] || ''
      }
@@ -139,39 +147,16 @@
      newtab = {
        ...menu,
        selected: true,
        param: {
          $BID: primaryId
        }
      }
    }
    let index = 0
    let tabs = tabviews.filter((tab, i) => {
      tab.selected = false
      if (tab.MenuID === MenuID) {
        index = i
      }
      return tab.MenuID !== newtab.MenuID
    })
    if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) {
      this.props.modifyTabview([newtab])
      MKEmitter.emit('modifyTabs', newtab, 'replace')
    } else {
      if (tabviews.length !== tabs.length) {
        this.props.modifyTabview(fromJS(tabs).toJS())
      }
      this.setState({}, () => {
        if (MenuID) {
          tabs.splice(index + 1, 0, newtab)
        } else {
          tabs.push(newtab)
        }
        this.props.modifyTabview(tabs)
      })
      MKEmitter.emit('modifyTabs', newtab, 'plus', true)
    }
    MKEmitter.emit('openNewTab')
@@ -226,15 +211,12 @@
const mapStateToProps = (state) => {
  return {
    tabviews: state.tabviews,
    permMenus: state.permMenus,
  }
}
const mapDispatchToProps = (dispatch) => {
  return {
    modifyTabview: (tabviews) => dispatch(modifyTabview(tabviews))
  }
const mapDispatchToProps = () => {
  return {}
}
export default connect(mapStateToProps, mapDispatchToProps)(TabButton)