king
2023-08-14 cc20b3cfe18b36c7b0f75937f88679eb031ecc6f
src/tabviews/custom/components/carousel/prop-card/index.jsx
@@ -49,6 +49,8 @@
    }
    
    if (_config.wrap.datatype === 'dynamic') {
      _config.setting.onload = _config.setting.sync === 'true' ? 'false' : 'true'
      if (_config.setting.sync === 'true' && window.GLOB.SyncData.has(_config.dataName)) {
        _data = window.GLOB.SyncData.get(_config.dataName) || []
@@ -64,8 +66,6 @@
        window.GLOB.SyncData.delete(_config.dataName)
      }
    } else if (_config.wrap.datatype === 'static') {
      this.loaded = true
    }
    _data.$$uuid = _data[_config.setting.primaryKey] || ''
@@ -91,15 +91,7 @@
      BID: BID || '',
      BData: BData || '',
      config: _config,
      arr_field: _config.columns.map(col => col.field).join(','),
    }, () => {
      if (_config.wrap.datatype === 'dynamic' && config.setting.sync !== 'true' && _config.setting.onload === 'true') {
        setTimeout(() => {
          this.loadData()
        }, _config.setting.delay || 0)
      } else if (_config.wrap.display === 'modal' && _config.wrap.datatype === 'static') {
        this.openModal()
      }
      arr_field: _config.columns.map(col => col.field).join(',')
    })
  }
@@ -126,16 +118,7 @@
      })
    }
    if (config.$cache && !this.loaded) {
      Api.getLCacheConfig(config.uuid).then(res => {
        if (!res || this.loaded) return
        let _data = res[0] || {$$empty: true}
        _data.$$uuid = _data[config.setting.primaryKey] || ''
        this.setState({data: _data})
      })
    }
    this.initExec()
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -154,6 +137,62 @@
    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
    this.timer && this.timer.stop()
  }
  initExec = () => {
    const { config } = this.state
    if (config.wrap.datatype === 'dynamic') {
      if (config.$cache) {
        if (config.$time) {
          if (!this.loaded) {
            Api.getLCacheConfig(config.uuid, config.$time).then(res => {
              if (!res.valid && config.setting.onload === 'true') {
                setTimeout(() => {
                  this.loadData('init')
                }, config.setting.delay || 0)
              }
              if (!res.data || this.loaded) return
              let _data = res.data[0] || {$$empty: true}
              _data.$$uuid = _data[config.setting.primaryKey] || ''
              this.setState({data: _data})
            })
          } else {
            this.openModal()
          }
        } else {
          if (!this.loaded) {
            Api.getLCacheConfig(config.uuid, 0).then(res => {
              if (!res.data || this.loaded) return
              let _data = res.data[0] || {$$empty: true}
              _data.$$uuid = _data[config.setting.primaryKey] || ''
              this.setState({data: _data})
            })
          }
          if (config.setting.onload === 'true') {
            setTimeout(() => {
              this.loadData('init')
            }, 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()
      }
    } else if (config.wrap.datatype === 'static') {
      this.openModal()
    }
  }
  transferSyncData = (syncId) => {
@@ -178,9 +217,7 @@
    this.loaded = true
    this.setState({data: _data}, () => {
      if (config.wrap.display === 'modal') {
        this.openModal()
      }
      this.openModal()
    })
    window.GLOB.SyncData.delete(config.dataName)
@@ -200,6 +237,8 @@
  openModal = (ErrCode) => {
    const { config, data } = this.state
    if (config.wrap.display !== 'modal') return
    
    let code = config.wrap.code || ('modal' + config.uuid)
    let tip = localStorage.getItem(code)
@@ -319,7 +358,7 @@
      let _data = {}
      this.loaded = true
      if (config.$cache && config.setting.onload !== 'false') {
      if (config.$cache && type === 'init') {
        Api.writeCacheConfig(config.uuid, result.data || [])
      }
@@ -337,9 +376,7 @@
        data: _data,
        loading: false
      }, () => {
        if (config.wrap.display === 'modal') {
          this.openModal(result.ErrCode)
        }
        this.openModal(result.ErrCode)
      })
      if (config.timer && config.clearField && result.data && result.data[0]) {