king
2021-01-08 da7068bd48791cdee966c786ce0dfd46f6e03df9
src/tabviews/zshare/actionList/popupbutton/index.jsx
@@ -24,7 +24,6 @@
    MenuID: PropTypes.string,         // 菜单ID
    btn: PropTypes.object,            // 按钮
    setting: PropTypes.any,           // 页面通用设置
    updateStatus: PropTypes.func,     // 按钮状态更新
  }
  state = {
@@ -45,15 +44,47 @@
    if (position === 'toolbar') {
      MKEmitter.addListener('triggerBtnId', this.actionTrigger)
    }
    MKEmitter.addListener('openNewTab', this.openNewTab)
    MKEmitter.addListener('refreshPopButton', this.refreshPopButton)
  }
  componentWillUnmount () {
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('openNewTab', this.openNewTab)
    MKEmitter.removeListener('triggerBtnId', this.actionTrigger)
    MKEmitter.removeListener('refreshPopButton', this.refreshPopButton)
  }
  
  /**
   * @description 打开新标签时,关闭弹窗标签页
   */
  openNewTab = () => {
    this.setState({
      visible: false,
      loading: false
    })
  }
  /**
   * @description 弹窗标签页刷新
   */
  refreshPopButton = (tabId) => {
    const { btn } = this.props
    if (btn.uuid !== tabId) return
    if (btn.$type === 'CustomPage') {
      if (btn.popClose !== 'never') {
        MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.popClose, btn)
      }
    } else {
      let position = btn.popClose !== 'never' ? btn.popClose : 'grid'
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, position, btn)
    }
  }
  /**
   * @description 触发按钮操作
   */
@@ -115,12 +146,6 @@
    })
  }
  // 操作后刷新主表
  reloadtable = () => {
    const { btn } = this.props
    this.props.updateStatus('refresh', 'grid', btn)
  }
  /**
   * @description 弹窗关闭
   */
@@ -132,7 +157,9 @@
      loading: false
    })
    this.props.updateStatus('refresh', btn.popClose, btn)
    if (btn.popClose !== 'never') {
      MKEmitter.emit('refreshByButtonResult', btn.$menuId, btn.popClose, btn)
    }
  }
  render() {
@@ -149,13 +176,14 @@
        >{btn.label}</Button> : null}
        {show !== 'actionList' ? <Button
          type="link"
          title={show === 'icon' ? btn.label : ''}
          loading={loading}
          style={btn.btnstyle}
          icon={show === 'text' ? '' : (btn.icon || '')}
          onClick={() => {this.actionTrigger()}}
        >{show === 'icon' && btn.icon ? '' : btn.label}</Button> : null}
        <Modal
          className={'popview-modal ' + (btn.$menuId ? 'custom-popview' : '')}
          className={'popview-modal ' + (btn.$type === 'CustomPage' ? 'custom-popview' : '')}
          title={btn.label}
          width={'80vw'}
          maskClosable={false}
@@ -166,15 +194,14 @@
          ]}
          destroyOnClose
        >
          {!btn.$menuId ? <SubTabTable
          {btn.$type !== 'CustomPage' ? <SubTabTable
            Tab={btn}
            MenuID={btn.linkTab}
            SupMenuID={this.props.MenuID}
            BID={popData ? primaryId : this.props.BID}
            BData={popData || this.props.BData}
            SupMenuID={this.props.MenuID}
            refreshSupView={this.reloadtable}
          /> : null}
          {btn.$menuId ? <CustomPage MenuID={btn.uuid} param={{BID: (popData ? primaryId : this.props.BID), data: (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}
        </Modal>
      </div>
    )