king
2023-07-25 2a3cc4e6cecfc6dab8b60adf93f7fde898ddc939
src/tabviews/custom/components/carousel/data-card/index.jsx
@@ -49,7 +49,10 @@
    }
    let _data = null
    if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) {
    if (_config.setting.sync === 'true') {
      _config.setting.onload = 'false'
      if (window.GLOB.SyncData.has(_config.dataName)) {
      _data = window.GLOB.SyncData.get(_config.dataName) || []
      if (_config.$cache) {
@@ -71,6 +74,7 @@
      window.GLOB.SyncData.delete(_config.dataName)
    }
    }
    if (_card.setting.click) {
      _card.style.cursor = 'pointer'
@@ -91,15 +95,7 @@
      BData: BData || '',
      config: _config,
      card: _card,
      arr_field: _config.columns.map(col => col.field).join(','),
    }, () => {
      if (config.setting.sync !== 'true' && _config.setting.onload === 'true') {
        setTimeout(() => {
          this.loadData()
        }, _config.setting.delay || 0)
      } else {
        this.openModal()
      }
      arr_field: _config.columns.map(col => col.field).join(',')
    })
  }
@@ -125,20 +121,7 @@
      })
    }
    if (config.$cache && !this.loaded) {
      Api.getLCacheConfig(config.uuid).then(res => {
        if (!res || this.loaded) return
        let _data = res.map((item, index) => {
          item.key = index
          item.$$uuid = item[config.setting.primaryKey] || ''
          item.$Index = index + 1 + ''
          return item
        })
        this.setState({data: _data})
      })
    }
    this.initExec()
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -158,6 +141,66 @@
    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
            let _data = res.map((item, index) => {
              item.key = index
              item.$$uuid = item[config.setting.primaryKey] || ''
              item.$Index = index + 1 + ''
              return item
            })
            this.setState({data: _data})
          })
        }
      } else {
        if (!this.loaded) {
          Api.getLCacheConfig(config.uuid, 0).then(res => {
            if (!res || this.loaded) return
            let _data = res.map((item, index) => {
              item.key = index
              item.$$uuid = item[config.setting.primaryKey] || ''
              item.$Index = index + 1 + ''
              return item
            })
            this.setState({data: _data})
          })
        }
        if (config.setting.onload === 'true') {
          setTimeout(() => {
            this.loadData()
          }, config.setting.delay || 0)
        } else if (this.loaded) {
          this.openModal()
        }
      }
    } else if (config.setting.onload === 'true') {
      setTimeout(() => {
        this.loadData()
      }, config.setting.delay || 0)
    } else if (this.loaded) {
      this.openModal()
    }
  }
  transferSyncData = (syncId) => {
    const { config } = this.state