king
2021-01-08 da7068bd48791cdee966c786ce0dfd46f6e03df9
src/tabviews/custom/components/card/prop-card/index.jsx
@@ -106,8 +106,9 @@
  }
  componentDidMount () {
    MKEmitter.addListener('syncRefreshComponentId', this.reload)
    MKEmitter.addListener('reloadData', this.reloadData)
    MKEmitter.addListener('resetSelectLine', this.resetParentParam)
    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -118,8 +119,9 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('syncRefreshComponentId', this.reload)
    MKEmitter.removeListener('reloadData', this.reloadData)
    MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
  }
  /**
@@ -151,6 +153,31 @@
    }
  }
  /**
   * @description 按钮执行完成后页面刷新
   * @param {*} menuId     // 菜单Id
   * @param {*} position   // 刷新位置
   * @param {*} btn        // 执行的按钮
   */
  refreshByButtonResult = (menuId, position, btn) => {
    const { config, BID } = this.state
    if (config.uuid !== menuId) return
    this.loadData()                                                            // 数据刷新
    if (btn.syncComponentId && btn.syncComponentId !== config.uuid && btn.syncComponentId !== config.setting.supModule) {
      MKEmitter.emit('reloadData', btn.syncComponentId)                        // 同级标签刷新
    }
    if (position === 'mainline' && config.setting.supModule) {                 // 主表行刷新
      MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty'))
    } else if (position === 'popclose') {                                      // 标签关闭刷新
      config.setting.supModule && MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty'))
      btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId)
    }
  }
  resetParentParam = (MenuID, id) => {
    const { config } = this.state
@@ -162,10 +189,10 @@
    }
  }
  reload = (syncId) => {
  reloadData = (menuId) => {
    const { config } = this.state
    if (syncId && syncId !== config.uuid) return
    if (menuId !== config.uuid) return
    this.loadData()
  }
@@ -227,20 +254,6 @@
    }
  }
  updateStatus = (type, position, btn) => {
    const { config } = this.state
    if (type === 'refresh' && position === 'grid') {
      this.loadData()
      if (btn && btn.syncComponent && btn.syncComponent[0]) {
        let syncId = btn.syncComponent.slice(-1)[0]
        if (config.uuid !== syncId) {
          MKEmitter.emit('syncRefreshComponentId', syncId)
        }
      }
    }
  }
  changeCard = (index, item) => {
    const { config, data, activeKey } = this.state
@@ -268,7 +281,7 @@
        <div className={`card-row-list ${config.wrap.cardType || ''} ${config.wrap.scale || ''}`}>
          {config.subcards.map((item, index) => (
            <Col className={activeKey === index ? 'active' : ''} key={index} span={item.setting.width || 6} offset={item.offset || 0} onClick={() => {this.changeCard(index, item)}}>
              <CardItem card={item} cards={config} data={data} updateStatus={this.updateStatus}/>
              <CardItem card={item} cards={config} data={data}/>
            </Col>
          ))}
        </div>