king
2022-10-12 e657b7ed2c047af4b54cbc26e5ac66cb7656dbb5
src/tabviews/custom/components/card/prop-card/index.jsx
@@ -51,7 +51,7 @@
      BID = BData.$BID || ''
    }
    
    if (_config.wrap.datatype !== 'static') {
    if (_config.wrap.datatype === 'dynamic') {
      _sync = _config.setting.sync === 'true'
      if (_sync && data) {
@@ -67,6 +67,9 @@
        }
        _sync = false
      }
    } else if (_config.wrap.datatype === 'public' && window.GLOB.CacheData.get(_config.wrap.publicId)) {
      _data = window.GLOB.CacheData.get(_config.wrap.publicId)
      _data = fromJS(_data).toJS()
    }
    _data.$$BID = BID || ''
@@ -122,13 +125,25 @@
      config: _config,
      arr_field: _config.columns.map(col => col.field).join(','),
    }, () => {
      if (_config.wrap.datatype !== 'static' && _config.setting.sync !== 'true' && _config.setting.onload === 'true') {
      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.cardType && _data.$$uuid) {
        setTimeout(() => {
          this.transferLine()
        }, 200)
      }
    })
@@ -142,7 +157,11 @@
    MKEmitter.addListener('queryModuleParam', this.queryModuleParam)
    MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
    if (config.timer) {
    if (config.wrap.datatype === 'public') {
      MKEmitter.addListener('mkPublicData', this.mkPublicData)
    }
    if (config.timer && config.wrap.datatype === 'dynamic') {
      this.timer = new TimerTask()
      this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {this.loadData(true)})
    }
@@ -157,6 +176,7 @@
      return
    }
    MKEmitter.removeListener('reloadData', this.reloadData)
    MKEmitter.removeListener('mkPublicData', this.mkPublicData)
    MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
    MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
@@ -185,14 +205,34 @@
      this.setState({sync: false, data: _data}, () => {
        if (selected !== 'false') {
          setTimeout(() => {
            this.checkTopLine()
          }, 200)
          this.checkTopLine()
        } else if (!config.wrap.cardType && _data.$$uuid) {
          this.transferLine()
        }
      })
    } else if ( config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
    } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
      this.setState({}, () => {
        this.loadData()
      })
    }
  }
  mkPublicData = (publicId, data) => {
    const { config, selected, BID, BData } = this.state
    if (config.wrap.datatype === 'public' && config.wrap.publicId === publicId) {
      let _data = fromJS(data).toJS()
      _data.$$BID = BID || ''
      _data.$$BData = BData || ''
      _data.$$uuid = _data[config.setting.primaryKey] || ''
      this.setState({data: _data}, () => {
        if (selected !== 'false') {
          this.checkTopLine()
        } else {
          this.transferLine()
        }
      })
    }
  }
@@ -213,6 +253,14 @@
    }
    MKEmitter.emit('resetSelectLine', config.uuid, primaryId, data)
  }
  transferLine = () => {
    const { config, data } = this.state
    if (config.wrap.cardType) return
    MKEmitter.emit('resetSelectLine', config.uuid, data.$$uuid || '', data)
  }
  /**
@@ -280,6 +328,11 @@
    const { mainSearch } = this.props
    const { config, arr_field, BID, BData, selected } = this.state
    if (config.wrap.datatype === 'public') {
      MKEmitter.emit('reloadData', config.wrap.publicId)
      return
    }
    if (config.wrap.datatype === 'static') {
      this.setState({
        data: {$$BID: BID || '', $$BData: BData, $$empty: true},
@@ -328,6 +381,8 @@
      }, () => {
        if (selected !== 'false') {
          this.checkTopLine()
        } else {
          this.transferLine()
        }
      })