king
2021-12-16 b5364600d98c8749caba625ec813d4fe670d0a19
src/tabviews/custom/components/card/data-card/index.jsx
@@ -41,7 +41,9 @@
    total: null,
    precards: [],
    nextcards: [],
    selected: 'false'
    selected: 'false',
    supNodes: [],
    supComs: null
  }
  UNSAFE_componentWillMount () {
@@ -144,7 +146,13 @@
      return item
    })
    let supComs = null
    if (_config.wrap.supType === 'multi') {
      supComs = _config.supNodes.map(item => item.componentId)
    }
    this.setState({
      supComs,
      selected,
      precards,
      nextcards,
@@ -227,7 +235,7 @@
   * @param {*} btn        // 执行的按钮
   */
  refreshByButtonResult = (menuId, position, btn, id, lines) => {
    const { config, BID } = this.state
    const { config, BID, supComs, supNodes } = this.state
    if (config.uuid !== menuId) return
@@ -243,15 +251,38 @@
      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)
    if (supComs) {
      if (btn.syncComponentId && btn.syncComponentId !== config.uuid && !supComs.includes(btn.syncComponentId)) {
        MKEmitter.emit('reloadData', btn.syncComponentId)                        // 同级标签刷新
      }
      if (position === 'mainline' || position === 'popclose') {                 // 主表行刷新
        let supNode = supNodes[supNodes.length - 1]
        supComs.forEach((item, i) => {
          setTimeout(() => {
            if (supNode && supNode.key === item) {
              MKEmitter.emit('reloadData', item, supNode.value)
            } else {
              MKEmitter.emit('reloadData', item)
            }
          }, i * 10)
        })
        if (position === 'popclose') {                                      // 标签关闭刷新
          btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId)
        }
      }
    } else {
      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)
      }
    }
  }
@@ -327,13 +358,35 @@
  }
  resetParentParam = (MenuID, id, data) => {
    const { config } = this.state
    const { config, supComs } = this.state
    if (!config.setting.supModule || config.setting.supModule !== MenuID) return
    if (id !== this.state.BID || id !== '') {
      this.setState({ BID: id, BData: data, pageIndex: 1 }, () => {
        this.loadData()
      })
    if (supComs) {
      if (!supComs.includes(MenuID)) return
      let supNodes = this.state.supNodes.filter(item => item.key !== MenuID)
      let bid = ''
      let _data = null
      if (id) {
        supNodes.push({key: MenuID, value: id, data})
      }
      if (supNodes.length > 0) {
        bid = supNodes[supNodes.length - 1].value
        _data = supNodes[supNodes.length - 1].data
      }
      if (bid !== this.state.BID || bid !== '') {
        this.setState({ BID: bid, BData: _data, pageIndex: 1 }, () => {
          this.loadData()
        })
      }
    } else {
      if (!config.setting.supModule || config.setting.supModule !== MenuID) return
      if (id !== this.state.BID || id !== '') {
        this.setState({ BID: id, BData: data, pageIndex: 1 }, () => {
          this.loadData()
        })
      }
    }
  }