king
2023-01-14 004176924ce35c96600f5c18e85478944de8bec6
src/tabviews/custom/components/chart/antv-dashboard/index.jsx
@@ -156,9 +156,11 @@
        }
      }
      this.setState({sync: false, data: _data}, () => {
      this.setState({sync: false, data: _data})
      if (!is(fromJS(this.state.data), fromJS(_data))) {
        this.handleData()
      })
      }
    } else if (config.setting.useMSearch && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
      this.setState({}, () => {
        this.loadData()
@@ -171,7 +173,7 @@
  }
  componentDidMount () {
    const { config } = this.state
    const { config, sync } = this.state
    MKEmitter.addListener('reloadData', this.reloadData)
    MKEmitter.addListener('resetSelectLine', this.resetParentParam)
@@ -180,6 +182,23 @@
      this.timer = new TimerTask()
      this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {
        this.loadData(true)
      })
    }
    if (config.$cache && (config.setting.sync !== 'true' || sync)) {
      Api.getLCacheConfig(config.uuid).then(res => {
        if (!res) return
        let _data = null
        if (config.subtype === 'ratioboard') {
          _data = res
        } else {
          _data = {value: res[0][config.plot.valueField]}
        }
        this.setState({data: _data}, () => {
          this.handleData()
        })
      })
    }
  }
@@ -221,7 +240,10 @@
    if (_element) {
      _element.innerHTML = ''
    }
    this.viewrender()
    setTimeout(() => {
      this.viewrender()
    }, 100)
  }
  async loadData (hastimer) {
@@ -255,6 +277,10 @@
    let result = await Api.genericInterface(param)
    if (result.status) {
      if (config.$cache) {
        Api.writeCacheConfig(config.uuid, result.data || '')
      }
      let data = null
      if (config.subtype === 'ratioboard') {
        data = result.data || []
@@ -264,19 +290,15 @@
          data.value = result.data[0][config.plot.valueField]
        }
      }
      let reset = true
      if (hastimer && is(fromJS(data), fromJS(this.state.data))) {
        reset = false
      }
      this.setState({
        data,
        loading: false
      }, () => {
        if (!reset) return
        this.handleData()
      })
      if (!is(fromJS(this.state.data), fromJS(data))) {
        this.handleData()
      }
    } else {
      this.setState({
        loading: false