king
2021-11-17 c51f5e007a3e03c9d6731ab7f28f0080de009990
src/tabviews/zshare/actionList/excelInbutton/index.jsx
@@ -12,7 +12,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'
class ExcelInButton extends Component {
  static propTpyes = {
@@ -28,7 +28,9 @@
  state = {
    dict: sessionStorage.getItem('lang') !== 'en-US' ? zhCN : enUS,
    loading: false,
    selines: null,
    disabled: false,
    hidden: false,
    primaryId: '',
  }
@@ -43,7 +45,7 @@
          disabled = true
        }
      })
      this.setState({disabled})
      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
    }
  }
@@ -69,7 +71,7 @@
          }
        })
      }
      this.setState({disabled})
      this.setState({disabled, hidden: disabled && btn.control === 'hidden'})
    }
  }
@@ -79,30 +81,15 @@
    }
    MKEmitter.removeListener('triggerBtnId', this.actionTrigger)
  }
  /**
   * @description 按钮状态改变
   */
  updateStatus = (type) => {
    if (type === 'start') {
      this.setState({
        loading: true
      })
    } else if (type === 'over') {
      this.setState({
        loading: false
      })
    }
  }
  
  /**
   * @description 触发按钮操作
   */
  actionTrigger = (triggerId, record, type) => {
    const { setting, Tab, BID, btn, selectedData } = this.props
    const { loading } = this.state
    const { loading, disabled } = this.state
    if ((triggerId && btn.uuid !== triggerId) || loading) return
    if ((triggerId && btn.uuid !== triggerId) || loading || disabled) return
    if (((Tab && Tab.supMenu) || setting.supModule) && !BID) {
      notification.warning({
@@ -142,6 +129,7 @@
    }
    this.setState({
      selines: data,
      primaryId: primaryId
    }, () => {
      this.refs.excelIn.exceltrigger()
@@ -182,7 +170,7 @@
    })
    if (btn.execSuccess !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn)
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execSuccess, btn, '', this.state.selines)
    }
    if (btn.switchTab && btn.switchTab.length > 0) {
      let id = btn.switchTab[btn.switchTab.length - 1]
@@ -226,7 +214,7 @@
    })
    if (btn.execError !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn)
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.execError, btn, '', this.state.selines)
    }
  }
@@ -257,7 +245,7 @@
        })
      }
      this.updateStatus('over')
      this.setState({ loading: false })
      return
    }
@@ -267,7 +255,7 @@
        message: '未获取到工作表《' + sheetName + '》数据!',
        duration: 5
      })
      this.updateStatus('over')
      this.setState({ loading: false })
      return
    } else if (data.length * btn.verify.columns.length > 30000) {
      notification.warning({
@@ -285,7 +273,7 @@
        message: result.errors,
        duration: 5
      })
      this.updateStatus('over')
      this.setState({ loading: false })
      return
    }
@@ -451,7 +439,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 <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
@@ -462,7 +452,7 @@
          className={'mk-btn mk-' + btn.class}
          onClick={() => {this.actionTrigger()}}
        >{btn.label}</Button>
        <ExcelIn btn={btn} triggerExcelIn={() => this.updateStatus('start')} returndata={this.getexceldata} ref="excelIn" />
        <ExcelIn btn={btn} triggerExcelIn={() => this.setState({ loading: true })} returndata={this.getexceldata} ref="excelIn" />
      </div>
    } else { // icon、text、 all 卡片
      let label = ''
@@ -491,7 +481,7 @@
          icon={icon}
          onClick={() => {this.actionTrigger()}}
        >{label}</Button>
        <ExcelIn btn={btn} triggerExcelIn={() => this.updateStatus('start')} returndata={this.getexceldata} ref="excelIn" />
        <ExcelIn btn={btn} triggerExcelIn={() => this.setState({ loading: true })} returndata={this.getexceldata} ref="excelIn" />
      </div>
    }
  }