king
2023-07-25 2a3cc4e6cecfc6dab8b60adf93f7fde898ddc939
src/tabviews/custom/components/chart/antv-dashboard/index.jsx
@@ -84,18 +84,22 @@
      BID = BData.$BID || ''
    }
    if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) {
      this.data = window.GLOB.SyncData.get(_config.dataName) || []
    if (_config.setting.sync === 'true') {
      _config.setting.onload = 'false'
      if (_config.$cache) {
        Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS())
      if (window.GLOB.SyncData.has(_config.dataName)) {
        this.data = window.GLOB.SyncData.get(_config.dataName) || []
        if (_config.$cache) {
          Api.writeCacheConfig(_config.uuid, fromJS(this.data).toJS())
        }
        _config.setting.sync = 'false'
        this.loaded = true
        window.GLOB.SyncData.delete(_config.dataName)
      }
      _config.setting.sync = 'false'
      this.loaded = true
      window.GLOB.SyncData.delete(_config.dataName)
    }
    if (_config.subtype !== 'ratioboard') {
@@ -118,17 +122,7 @@
      BID: BID || '',
      arr_field: _config.columns.map(col => col.field).join(','),
      plot: _config.plot
    }, () => {
      if (config.setting.sync !== 'true' && config.setting.onload === 'true') {
        setTimeout(() => {
          this.loadData()
        }, _config.setting.delay || 0)
      }
    })
    if (config.setting.sync === 'true' && this.loaded) {
      this.handleData()
    }
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -156,24 +150,7 @@
      })
    }
    if (config.$cache && !this.loaded) {
      Api.getLCacheConfig(config.uuid).then(res => {
        if (!res || this.loaded) return
        let _data = null
        if (config.subtype === 'ratioboard') {
          _data = res
        } else {
          _data = res[0] || {}
          _data.value = _data[config.plot.valueField] || 0
        }
        if (!is(fromJS(this.data), fromJS(_data))) {
          this.data = _data
          this.handleData()
        }
      })
    }
    this.initExec()
  }
  /**
@@ -191,6 +168,70 @@
    this.timer && this.timer.stop()
  }
  initExec = () => {
    const { config } = this.state
    if (config.$cache) {
      if (config.$time) {
        if (!this.loaded) {
          Api.getLCacheConfig(config.uuid, config.$time).then(res => {
            if (!res && config.setting.onload === 'true') {
              setTimeout(() => {
                this.loadData()
              }, config.setting.delay || 0)
            }
            if (!res || this.loaded) return
            this.data = res
            if (config.subtype !== 'ratioboard') {
              if (Array.isArray(this.data)) {
                this.data = this.data[0] || {}
              }
              this.data.value = this.data[config.plot.valueField] || 0
            }
            this.handleData()
          })
        } else {
          this.handleData()
        }
      } else {
        if (!this.loaded) {
          Api.getLCacheConfig(config.uuid, 0).then(res => {
            if (!res || this.loaded) return
            this.data = res
            if (config.subtype !== 'ratioboard') {
              if (Array.isArray(this.data)) {
                this.data = this.data[0] || {}
              }
              this.data.value = this.data[config.plot.valueField] || 0
            }
            this.handleData()
          })
        }
        if (config.setting.onload === 'true') {
          setTimeout(() => {
            this.loadData()
          }, config.setting.delay || 0)
        } else if (this.loaded) {
          this.handleData()
        }
      }
    } else if (config.setting.onload === 'true') {
      setTimeout(() => {
        this.loadData()
      }, config.setting.delay || 0)
    } else if (this.loaded) {
      this.handleData()
    }
  }
  transferSyncData = (syncId) => {
    const { config } = this.state