king
2023-07-25 2a3cc4e6cecfc6dab8b60adf93f7fde898ddc939
src/tabviews/custom/components/card/double-data-card/index.jsx
@@ -116,8 +116,6 @@
    _config.subcards = null
    
    let _data = null
    let selected = 'false'
    if (_config.wrap.selected === 'always' || _config.wrap.selected === 'init' || _config.wrap.selected === 'sign') {
      selected = _config.wrap.selected
@@ -129,8 +127,6 @@
    _config.wrap.pagestyle = _config.wrap.pagestyle || 'page'
    _config.wrap.wrapClass =  `${_config.wrap.selStyle} ${_config.wrap.cardType || ''}`
    this.loaded = _data !== null
    let wrapStyle = null
    let subcard = fromJS(_card).toJS()
@@ -186,7 +182,6 @@
      selected,
      precards,
      nextcards,
      data: _data,
      BID: BID || '',
      BData: BData || '',
      config: _config,
@@ -196,12 +191,6 @@
      card: _card,
      search: _config.$searches,
      arr_field: _config.columns.map(col => col.field).join(','),
    }, () => {
      if (_config.setting.onload === 'true') {
        setTimeout(() => {
          this.loadData()
        }, _config.setting.delay || 0)
      }
    })
  }
@@ -229,10 +218,35 @@
      })
    }
    if (config.$cache && !this.loaded) {
      Api.getLCacheConfig(config.uuid).then(res => {
        if (!res || this.loaded) return
        let _data = res.map((item, index) => {
    if (config.setting.onload === 'true') {
      this.initExec()
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState))
  }
  componentWillUnmount () {
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('reloadData', this.reloadData)
    MKEmitter.removeListener('searchRefresh', this.searchRefresh)
    MKEmitter.removeListener('refreshLineData', this.refreshLineData)
    MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
    MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
    this.timer && this.timer.stop()
  }
  initExec = () => {
    const { config } = this.state
    if (config.$cache) {
      let getData = (res) => {
        return res.map((item, index) => {
          let children = []
          if (item[config.setting.subdata]) {
@@ -268,28 +282,36 @@
          return item
        })
      }
      if (config.$time && !config.setting.laypage) {
        Api.getLCacheConfig(config.uuid, config.$time).then(res => {
          if (!res) {
            setTimeout(() => {
              this.loadData()
            }, config.setting.delay || 0)
          }
        this.setState({data: _data})
      })
          if (!res) return
          this.setState({data: getData(res)})
        })
      } else {
        Api.getLCacheConfig(config.uuid, 0).then(res => {
          if (!res || this.loaded) return
          this.setState({data: getData(res)})
        })
        setTimeout(() => {
          this.loadData()
        }, config.setting.delay || 0)
      }
    } else {
      setTimeout(() => {
        this.loadData()
      }, config.setting.delay || 0)
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
    return !is(fromJS(this.state), fromJS(nextState))
  }
  componentWillUnmount () {
    this.setState = () => {
      return
    }
    MKEmitter.removeListener('reloadData', this.reloadData)
    MKEmitter.removeListener('searchRefresh', this.searchRefresh)
    MKEmitter.removeListener('refreshLineData', this.refreshLineData)
    MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
    MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
    this.timer && this.timer.stop()
  }
  searchRefresh = (searchId) => {
@@ -304,9 +326,6 @@
  /**
   * @description 按钮执行完成后页面刷新
   * @param {*} menuId     // 菜单Id
   * @param {*} position   // 刷新位置
   * @param {*} btn        // 执行的按钮
   */
  refreshByButtonResult = (menuId, position, btn, id = '', lines) => {
    const { config, BID } = this.state