king
2021-07-28 137fb8ea6af2789b3238b22bac31d80bced41dfe
src/tabviews/zshare/actionList/popupbutton/index.jsx
@@ -31,7 +31,23 @@
    visible: false,
    popData: null,
    primaryId: '',
    disabled: false,
    loading: false,
  }
  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) {
@@ -46,6 +62,24 @@
    }
    MKEmitter.addListener('openNewTab', this.openNewTab)
    MKEmitter.addListener('refreshPopButton', this.refreshPopButton)
  }
  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})
    }
  }
  componentWillUnmount () {
@@ -75,7 +109,7 @@
    if (btn.uuid !== tabId) return
    if (btn.$type === 'CustomPage') {
    if (btn.$view === 'CustomPage') {
      if (btn.popClose !== 'never') {
        MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.popClose, btn)
      }
@@ -94,7 +128,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: '需要上级主键值!',
@@ -113,14 +147,6 @@
        duration: 5
      })
      return
    } else if (!setting.primaryKey) {
      // 需要选择行时,校验是否设置主键
      notification.warning({
        top: 92,
        message: '未设置主键!',
        duration: 5
      })
      return
    } else if (setting.tabType === 'subtab') {
      notification.warning({
        top: 92,
@@ -133,7 +159,7 @@
    let _data = null
    let primaryId = ''
    if (btn.Ot === 'requiredSgl') {
    if (btn.Ot === 'requiredSgl' && setting.primaryKey) {
      _data = data[0]
      primaryId = _data[setting.primaryKey] || ''
    }
@@ -168,13 +194,14 @@
  render() {
    const { btn, show } = this.props
    const { loading, popData, primaryId } = this.state
    const { loading, popData, primaryId, disabled } = this.state
    return (
      <div style={{display: 'inline-block'}} onClick={(e) => e.stopPropagation()}>
        {show === 'actionList' ? <Button
          className={'mk-btn mk-' + btn.class}
          icon={btn.icon}
          disabled={disabled}
          onClick={() => {this.actionTrigger()}}
          loading={loading}
        >{btn.label}</Button> : null}
@@ -182,12 +209,13 @@
          type="link"
          title={show === 'icon' ? btn.label : ''}
          loading={loading}
          style={btn.btnstyle}
          disabled={disabled}
          style={btn.style}
          icon={show === 'text' ? '' : (btn.icon || '')}
          onClick={() => {this.actionTrigger()}}
        >{show === 'icon' && btn.icon ? '' : btn.label}</Button> : null}
        <Modal
          className={'popview-modal ' + (btn.$type === 'CustomPage' ? 'custom-popview' : '')}
          className={'popview-modal ' + (btn.$view === 'CustomPage' ? 'custom-popview' : '')}
          title={btn.label}
          width={'85vw'}
          maskClosable={false}
@@ -198,14 +226,14 @@
          ]}
          destroyOnClose
        >
          {btn.$type !== 'CustomPage' ? <SubTabTable
          {btn.$view !== 'CustomPage' ? <SubTabTable
            Tab={btn}
            MenuID={btn.linkTab}
            SupMenuID={this.props.MenuID}
            BID={popData ? primaryId : this.props.BID}
            BData={popData || this.props.BData}
          /> : null}
          {btn.$type === 'CustomPage' ? <CustomPage Tab={btn} MenuID={btn.uuid} param={{BID: (popData ? primaryId : this.props.BID), data: (popData || this.props.BData)}} /> : null}
          {btn.$view === 'CustomPage' ? <CustomPage Tab={btn} MenuID={btn.uuid} param={{$BID: (popData ? primaryId : this.props.BID), ...(popData || this.props.BData || {})}} /> : null}
        </Modal>
      </div>
    )