king
2021-01-08 da7068bd48791cdee966c786ce0dfd46f6e03df9
src/tabviews/custom/components/card/table-card/index.jsx
@@ -102,9 +102,10 @@
  }
  componentDidMount () {
    MKEmitter.addListener('syncRefreshComponentId', this.reload)
    MKEmitter.addListener('reloadData', this.reloadData)
    MKEmitter.addListener('resetSelectLine', this.resetParentParam)
    MKEmitter.addListener('getexceloutparam', this.getexceloutparam)
    MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -115,9 +116,10 @@
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('syncRefreshComponentId', this.reload)
    MKEmitter.removeListener('reloadData', this.reloadData)
    MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
    MKEmitter.removeListener('getexceloutparam', this.getexceloutparam)
    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
  }
  /**
@@ -149,6 +151,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(btn)                                                         // 数据刷新
    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
@@ -160,16 +187,12 @@
    }
  }
  reload = (syncId) => {
  reloadData = (menuId) => {
    const { config } = this.state
    if (syncId && syncId !== config.uuid) return
    if (config.uuid !== menuId) return
    this.setState({
      pageIndex: 1
    }, () => {
      this.loadData()
    })
    this.loadData()
  }
   /**
@@ -259,20 +282,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)
        }
      }
    }
  }
  changePageIndex = (page) => {
    this.setState({
      pageIndex: page
@@ -312,7 +321,7 @@
      line.push(
        <Col key={index} span={24}>
          <div className="card-item-box" style={item.style}>
            <CardCellComponent seq={seq} data={data} cards={config} cardCell={item} elements={item.elements} updateStatus={this.updateStatus}/>
            <CardCellComponent seq={seq} data={data} cards={config} cardCell={item} elements={item.elements}/>
          </div>
        </Col>
      )