king
2023-08-27 da64ab0923bf8817fc8599a6e37b953ce38f64c8
src/tabviews/custom/components/code/sand-box/index.jsx
@@ -48,7 +48,7 @@
        _data = window.GLOB.SyncData.get(_config.dataName) || []
  
        if (_config.$cache) {
          Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS())
          Api.writeCacheConfig(_config.uuid, fromJS(_data).toJS(), BID)
        }
  
        _config.setting.sync = 'false'
@@ -72,8 +72,7 @@
    this.setState({
      data: _data,
      BID: BID || '',
      config: _config,
      arr_field: _config.columns.map(col => col.field).join(',')
      config: _config
    })
  }
@@ -107,22 +106,22 @@
  }
  initExec = () => {
    const { config } = this.state
    const { config, BID } = this.state
    if (config.wrap.datatype !== 'static') {
      if (config.$cache) {
        if (config.$time) {
          if (!this.loaded) {
            Api.getLCacheConfig(config.uuid, config.$time).then(res => {
              if (!res && config.setting.onload === 'true') {
            Api.getLCacheConfig(config.uuid, config.$time, BID).then(res => {
              if (!res.valid && config.setting.onload === 'true') {
                setTimeout(() => {
                  this.loadData()
                  this.loadData('init')
                }, config.setting.delay || 0)
              }
    
              if (!res || this.loaded) return
              if (!res.data || this.loaded) return
  
              this.setState({data: res}, () => {
              this.setState({data: res.data}, () => {
                this.renderView()
              })
            })
@@ -131,10 +130,10 @@
          }
        } else {
          if (!this.loaded) {
            Api.getLCacheConfig(config.uuid, 0).then(res => {
              if (!res || this.loaded) return
            Api.getLCacheConfig(config.uuid, 0, BID).then(res => {
              if (!res.data || this.loaded) return
      
              this.setState({data: res}, () => {
              this.setState({data: res.data}, () => {
                this.renderView()
              })
            })
@@ -142,7 +141,7 @@
  
          if (config.setting.onload === 'true') {
            setTimeout(() => {
              this.loadData()
              this.loadData('init')
            }, config.setting.delay || 0)
          } else if (this.loaded) {
            this.renderView()
@@ -161,14 +160,14 @@
  }
  transferSyncData = (syncId) => {
    const { config } = this.state
    const { config, BID } = this.state
    if (config.$syncId !== syncId) return
    let _data = window.GLOB.SyncData.get(config.dataName) || []
    if (config.$cache) {
      Api.writeCacheConfig(config.uuid, fromJS(_data).toJS())
      Api.writeCacheConfig(config.uuid, fromJS(_data).toJS(), BID)
    }
    if (!is(fromJS(this.state.data), fromJS(_data))) {
@@ -204,8 +203,8 @@
    this.loadData()
  }
  async loadData () {
    const { config, arr_field, BID } = this.state
  async loadData (type) {
    const { config, BID } = this.state
    if (config.wrap.datatype === 'static') {
      this.setState({
@@ -236,15 +235,15 @@
    })
    let _orderBy = config.setting.order || ''
    let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, 1, 1, BID)
    let param = UtilsDM.getQueryDataParams(config.setting, searches, _orderBy, 1, 1, BID)
    let result = await Api.genericInterface(param)
    if (result.status) {
      let _data = result.data || []
      this.loaded = true
      if (config.$cache && config.setting.onload !== 'false') {
        Api.writeCacheConfig(config.uuid, result.data || [])
      if (config.$cache && type === 'init') {
        Api.writeCacheConfig(config.uuid, result.data || [], BID)
      }
      if (!is(fromJS(this.state.data), fromJS(_data))) {