king
2021-11-17 c51f5e007a3e03c9d6731ab7f28f0080de009990
src/tabviews/zshare/actionList/changeuserbutton/index.jsx
@@ -7,7 +7,7 @@
import zhCN from '@/locales/zh-CN/main.js'
import enUS from '@/locales/en-US/main.js'
import MKEmitter from '@/utils/events.js'
import './index.scss'
// import './index.scss'
const { confirm } = Modal
@@ -15,6 +15,7 @@
  static propTpyes = {
    show: PropTypes.any,              // 按钮显示样式控制
    position: PropTypes.any,          // 按钮位置,工具栏为toolbar
    MenuID: PropTypes.any,            // 菜单ID
    BID: PropTypes.string,            // 主表ID
    btn: PropTypes.object,            // 按钮
    selectedData: PropTypes.any,      // 子表中选择数据
@@ -24,6 +25,7 @@
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    disabled: false,
    hidden: false,
    loading: false
  }
@@ -38,7 +40,7 @@
          disabled = true
        }
      })
      this.setState({disabled})
      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
    }
  }
@@ -47,11 +49,7 @@
  }
  componentDidMount () {
    const { position } = this.props
    if (position === 'toolbar') {
      MKEmitter.addListener('triggerBtnId', this.actionTrigger)
    }
    MKEmitter.addListener('triggerBtnId', this.actionTrigger)
  }
  UNSAFE_componentWillReceiveProps (nextProps) {
@@ -68,7 +66,7 @@
          }
        })
      }
      this.setState({disabled})
      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
    }
  }
@@ -82,11 +80,24 @@
  /**
   * @description 触发按钮操作
   */
  actionTrigger = (triggerId, record) => {
    const { setting, selectedData, btn } = this.props
    const { loading } = this.state
  actionTrigger = (triggerId, record, type) => {
    const { setting, selectedData, btn, MenuID } = this.props
    const { loading, disabled } = this.state
    
    if ((triggerId && btn.uuid !== triggerId) || loading) return
    if ((triggerId && btn.uuid !== triggerId) || loading || disabled) return
    if (btn.funcType === 'closetab') {
      MKEmitter.emit('closeTabView', MenuID || btn.$MenuID)
      if (btn.refreshTab && btn.refreshTab.length > 0) {
        MKEmitter.emit('reloadMenuView', btn.refreshTab[btn.refreshTab.length - 1], 'table')
      }
      return
    } else if (type === 'linkbtn' && selectedData && selectedData.length === 1) {
      if (record[0].$Index !== selectedData[0].$Index) {
        return
      }
    }
    
    let data = record || selectedData || []
@@ -151,6 +162,8 @@
              sessionStorage.setItem('localDataM', res.dataM ? 'true' : '')
              sessionStorage.setItem('debug', res.debug || '')
              sessionStorage.setItem('role_id', res.role_id || '')
              sessionStorage.setItem('departmentcode', res.departmentcode || '')
              sessionStorage.setItem('organization', res.organization || '')
              sessionStorage.setItem('localRole_id', res.role_id || '')
              
              sessionStorage.removeItem('CloudAvatar')
@@ -183,7 +196,9 @@
  render() {
    const { btn, show } = this.props
    const { loading, disabled } = this.state
    const { loading, disabled, hidden } = this.state
    if (hidden) return null
    if (show === 'actionList') {
      return (