king
2023-07-25 54700ad91869ba468190e1462f2aeef3a9d9a5b7
src/tabviews/custom/components/card/prop-card/index.jsx
@@ -36,8 +36,6 @@
    let _config = fromJS(config).toJS()
    let _data = { $$empty: true }
    let _sync = false
    let BID = ''
    let BData = ''
@@ -51,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) || []
@@ -119,40 +119,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.datatype === 'public') {
        if (_data.$$loaded && selected !== 'false') {
          setTimeout(() => {
            this.checkTopLine()
          }, 200)
        }
      } else if (!_sync && selected !== 'false') {
        setTimeout(() => {
          this.checkTopLine()
        }, 200)
      }
      if (_config.wrap.datatype === 'dynamic' && this.loaded) {
        if (_config.wrap.goback === 'true' && _data.$$empty) {
          this.timer && this.timer.stop()
          MKEmitter.emit('closeTabView', _config.$pageId)
        } else {
          this.autoExec()
        }
      } else if (_config.wrap.datatype === 'static') {
        this.autoExec()
      }
      if (_data.$$uuid) {
        setTimeout(() => {
          this.transferLine()
        }, 200)
      }
      arr_field: _config.columns.map(col => col.field).join(',')
    })
  }
@@ -182,16 +149,7 @@
      this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData(true)})
    }
    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) {
@@ -214,6 +172,113 @@
    this.timer && this.timer.stop()
  }
  initExec = () => {
    const { config, selected, data } = 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 && config.setting.onload === 'true') {
                setTimeout(() => {
                  this.loadData()
                }, config.setting.delay || 0)
              }
              if (!res || this.loaded) return
              let _data = res[0] || {$$empty: true}
              _data.$$uuid = _data[config.setting.primaryKey] || ''
              this.setState({data: _data})
            })
          }
        } else {
          if (!this.loaded) {
            Api.getLCacheConfig(config.uuid, 0).then(res => {
              if (!res || this.loaded) return
              let _data = res[0] || {$$empty: true}
              _data.$$uuid = _data[config.setting.primaryKey] || ''
              this.setState({data: _data})
            })
          }
          if (config.setting.onload === 'true') {
            setTimeout(() => {
              this.loadData()
            }, config.setting.delay || 0)
          } else if (this.loaded) {
            if (config.wrap.goback === 'true' && data.$$empty) {
              this.timer && this.timer.stop()
              MKEmitter.emit('closeTabView', config.$pageId)
            } else {
              if (selected !== 'false') {
                this.checkTopLine()
              } else {
                this.transferLine()
              }
              this.autoExec()
            }
          }
        }
      } else if (config.setting.onload === 'true') {
        setTimeout(() => {
          this.loadData()
        }, config.setting.delay || 0)
      } else if (this.loaded) {
        if (config.wrap.goback === 'true' && data.$$empty) {
          this.timer && this.timer.stop()
          MKEmitter.emit('closeTabView', config.$pageId)
        } else {
          if (selected !== 'false') {
            this.checkTopLine()
          } else {
            this.transferLine()
          }
          this.autoExec()
        }
      }
    } else if (config.wrap.datatype === 'public') {
      if (this.loaded) {
        if (config.wrap.goback === 'true' && data.$$empty) {
          this.timer && this.timer.stop()
          MKEmitter.emit('closeTabView', config.$pageId)
        } else {
          if (selected !== 'false') {
            this.checkTopLine()
          } else if (data.$$uuid) {
            this.transferLine()
          }
          this.autoExec()
        }
      }
    } else {
      if (selected !== 'false') {
        setTimeout(() => {
          this.checkTopLine()
        }, 200)
      }
      if (config.$cache && config.$time && config.wrap.autoExec) {
        Api.getLCacheConfig(config.uuid, config.$time).then(res => {
          if (!res) {
            this.autoExec()
          } else {
            Api.writeCacheConfig(config.uuid, [])
          }
        })
      } else {
        this.autoExec()
      }
    }
  }
  transferSyncData = (syncId) => {
    const { config } = this.state