king
2023-06-14 08cce3334a2dc81d690b518136b0aaea64e48b0b
src/tabviews/custom/components/carousel/prop-card/index.jsx
@@ -31,10 +31,11 @@
    visible: false
  }
  loaded = false
  UNSAFE_componentWillMount () {
    const { data, initdata } = this.props
    let _config = fromJS(this.props.config).toJS()
    let _cols = new Map()
    let _data = {$$empty: true}
    let _sync = false
@@ -51,7 +52,7 @@
      BID = BData.$BID || ''
    }
    
    if (_config.setting && _config.wrap.datatype === 'dynamic') {
    if (_config.wrap.datatype === 'dynamic') {
      _sync = _config.setting.sync === 'true'
      if (_sync && data) {
@@ -60,23 +61,22 @@
          _data = _data[0] || {$$empty: true}
        }
        _sync = false
        this.loaded = true
      } else if (_sync && initdata) {
        _data = initdata
        if (Array.isArray(_data)) {
          _data = _data[0] || {$$empty: true}
        }
        _sync = false
        this.loaded = true
      }
    } else if (_config.wrap.datatype === 'static') {
      this.loaded = true
    }
    _data.$$uuid = _data[_config.setting.primaryKey] || ''
    _data.$$BID = BID || ''
    _data.$$BData = BData || ''
    _config.columns.forEach(item => {
      if (item.type !== 'number') return
      _cols.set(item.field, item)
    })
    if (!_config.wrap.height) { // 兼容
      _config.wrap.height = _config.style.height || '300px'
@@ -88,12 +88,6 @@
      if (card.setting.click) {
        card.style.cursor = 'pointer'
      }
      card.elements = card.elements.map(item => {
        if (item.eleType === 'number' && item.field && _cols.has(item.field) && typeof(item.decimal) !== 'number') {
          item.decimal = _cols.get(item.field).decimal || 0
        }
        return item
      })
    })
    _config.wrap.speed = (_config.wrap.speed || 3) * 1000
@@ -128,6 +122,17 @@
      this.timer = new TimerTask()
      this.timer.init(config.uuid, config.timer, config.timerRepeats, () => {
        this.loadData('timer')
      })
    }
    if (config.$cache && !this.loaded) {
      Api.getLCacheConfig(config.uuid).then(res => {
        if (!res || this.loaded) return
        let _data = res[0]
        _data.$$uuid = _data[config.setting.primaryKey] || ''
        this.setState({data: _data})
      })
    }
  }
@@ -167,6 +172,8 @@
      _data.$$BID = BID || ''
      _data.$$BData = BData || ''
      this.loaded = true
      this.setState({sync: false, data: _data}, () => {
        if (config.wrap.display === 'modal') {
          this.openModal()
@@ -179,7 +186,7 @@
    }
  }
  openModal = () => {
  openModal = (ErrCode) => {
    const { config, data } = this.state
    
    let code = config.wrap.code || ('modal' + config.uuid)
@@ -191,6 +198,10 @@
      localStorage.setItem(code, data.$$uuid || 'true')
      Api.getAppVersion(true)
      if (ErrCode === '-1') {
        return
      }
    }
    setTimeout(() => {
@@ -271,6 +282,8 @@
      this.setState({
        data: {$$BID: BID || '', $$BData: BData, $$empty: true}
      })
      this.loaded = true
      return
    }
@@ -294,6 +307,11 @@
    if (result.status) {
      let _data = {}
      this.loaded = true
      if (config.$cache && config.setting.onload !== 'false') {
        Api.writeCacheConfig(config.uuid, result.data || '')
      }
      if (!result.data || !result.data[0]) {
        _data.$$empty = true
      } else {
@@ -309,9 +327,16 @@
        loading: false
      }, () => {
        if (config.wrap.display === 'modal') {
          this.openModal()
          this.openModal(result.ErrCode)
        }
      })
      if (config.timer && config.clearField && result.data && result.data[0]) {
        let vals = (config.clearValue || '').split(',')
        if (vals.includes(result.data[0][config.clearField])) {
          this.timer && this.timer.stop()
        }
      }
    } else {
      this.setState({
        loading: false