king
2021-07-28 137fb8ea6af2789b3238b22bac31d80bced41dfe
src/tabviews/zshare/actionList/excelInbutton/index.jsx
@@ -28,7 +28,23 @@
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    loading: false,
    disabled: false,
    primaryId: '',
  }
  UNSAFE_componentWillMount () {
    const { btn, selectedData } = this.props
    let disabled = false
    if (btn.controlField && selectedData && selectedData.length > 0) { // 表格中按钮隐藏控制
      selectedData.forEach(item => {
        let s = item[btn.controlField] + ''
        if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
          disabled = true
        }
      })
      this.setState({disabled})
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -40,6 +56,24 @@
    if (position === 'toolbar') {
      MKEmitter.addListener('triggerBtnId', this.actionTrigger)
    }
  }
  UNSAFE_componentWillReceiveProps (nextProps) {
    const { btn, selectedData } = this.props
    if (btn.controlField && !is(fromJS(nextProps.selectedData || []), fromJS(selectedData || []))) {
      let disabled = false
      if (nextProps.selectedData && nextProps.selectedData.length > 0) { // 表格中按钮隐藏控制
        nextProps.selectedData.forEach(item => {
          let s = item[btn.controlField] + ''
          if (s === btn.controlVal || (btn.controlVal && btn.controlVal.split(',').includes(s))) {
            disabled = true
          }
        })
      }
      this.setState({disabled})
    }
  }
@@ -74,7 +108,7 @@
    if ((triggerId && btn.uuid !== triggerId) || loading) return
    if (Tab && Tab.supMenu && !BID) {
    if (((Tab && Tab.supMenu) || setting.supModule) && !BID) {
      notification.warning({
        top: 92,
        message: '需要上级主键值!',
@@ -103,7 +137,7 @@
    }
    let primaryId = '' // 导入时行Id
    if (btn.Ot === 'requiredSgl') {
    if (btn.Ot === 'requiredSgl' && setting.primaryKey) {
      primaryId = data[0][setting.primaryKey] || ''
    }
@@ -408,13 +442,14 @@
  render() {
    const { btn, show } = this.props
    const { loading } = this.state
    const { loading, disabled } = this.state
    if (show === 'actionList') {
      return <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
        <Button
          icon={btn.icon}
          loading={loading}
          disabled={disabled}
          className={'mk-btn mk-' + btn.class}
          onClick={() => {this.actionTrigger()}}
        >{btn.label}</Button>
@@ -426,7 +461,8 @@
          type="link"
          title={show === 'icon' ? btn.label : ''}
          loading={loading}
          style={btn.btnstyle}
          disabled={disabled}
          style={btn.style}
          icon={show === 'text' ? '' : (show === 'icon' ? (btn.icon || 'upload') : (btn.icon || ''))}
          onClick={() => {this.actionTrigger()}}
        >{show === 'icon' ? '' : btn.label}</Button>