king
2023-07-10 19e156d67e400bff8883425f3511812bb4f9d193
src/tabviews/custom/components/carousel/data-card/index.jsx
@@ -38,7 +38,6 @@
    const { data, initdata } = this.props
    let _config = fromJS(this.props.config).toJS()
    let _card = _config.subcards[0]
    let _cols = new Map()
    let _data = null
    let _sync = _config.setting.sync === 'true'
@@ -75,21 +74,9 @@
      })
    }
    _config.columns.forEach(item => {
      if (item.type !== 'number') return
      _cols.set(item.field, item)
    })
    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
    })
    if (!_config.wrap.height) { // 兼容
      _config.wrap.height = _config.style.height || '300px'
@@ -194,7 +181,7 @@
    this.timer && this.timer.stop()
  }
  openModal = () => {
  openModal = (ErrCode) => {
    const { config, data } = this.state
    
    if (config.wrap.display !== 'modal' || !data || data.length === 0) return
@@ -208,6 +195,10 @@
      localStorage.setItem(code, data[0].$$uuid + data.length)
      Api.getAppVersion(true)
      if (ErrCode === '-1') {
        return
      }
    }
    setTimeout(() => {
@@ -230,10 +221,6 @@
      MKEmitter.emit('reloadData', config.setting.supModule, BID)
    } else {
      this.loadData()
    }
    if (position === 'popclose') { // 执行启动弹窗的按钮所选择的刷新项
      btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId)
    }
  }
@@ -299,34 +286,57 @@
    let result = await Api.genericInterface(param)
    if (result.status) {
      this.loaded = true
      if (config.$cache) {
      if (config.$cache && config.setting.onload !== 'false') {
        Api.writeCacheConfig(config.uuid, result.data || '')
      }
      let data = result.data.map((item, index) => {
        item.key = index
        item.$$uuid = item[config.setting.primaryKey] || ''
        item.$$BID = BID || ''
        item.$$BData = BData || ''
        item.$Index = index + 1
        return item
      })
      this.setState({
        data: result.data.map((item, index) => {
          item.key = index
          item.$$uuid = item[config.setting.primaryKey] || ''
          item.$$BID = BID || ''
          item.$$BData = BData || ''
          item.$Index = index + 1
          return item
        }),
        data: data,
        loading: false
      }, () => {
        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()
        }
      }
      if (result.message) {
        if (result.ErrCode === 'Y') {
          Modal.success({
            title: result.message
          })
        } else if (result.ErrCode === 'S') {
          notification.success({
            top: 92,
            message: result.message,
            duration: 2
          })
        }
      }
    } else {
      this.setState({
        loading: false
      })
      this.timer && this.timer.stop()
      
      if (!result.message) return
      if (result.ErrCode === 'N') {
        Modal.error({
          title: result.message,
        })
      } else {
      } else if (result.ErrCode !== '-2') {
        notification.error({
          top: 92,
          message: result.message,