king
2024-05-16 b69b5f6329ca5f87932436b7a6c1ddfc3377e10f
src/tabviews/custom/components/carousel/prop-card/index.jsx
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Spin, notification, Carousel, Modal, Checkbox, Button } from 'antd'
import { Spin, Carousel, Modal, Checkbox, Button } from 'antd'
import { LeftOutlined, RightOutlined } from '@ant-design/icons'
import asyncComponent from '@/utils/asyncComponent'
@@ -55,7 +55,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'
@@ -66,16 +66,32 @@
        window.GLOB.SyncData.delete(_config.dataName)
      }
    } else {
      _config.subcards.forEach(card => {
        card.elements.forEach(ele => {
          if (ele.eleType === 'button') return
          if (ele.datatype === 'dynamic' && ele.field) {
            ele.field = ele.field.toLowerCase()
          }
        })
      })
    }
    _data.$$uuid = _data[_config.setting.primaryKey] || ''
    _data.$$BID = BID || ''
    _data.$$BData = BData || ''
    if (_config.wrap.datatype === 'static' && BData) {
      Object.keys(BData).forEach(key => {
        if (/\$/.test(key)) return
        _data[key.toLowerCase()] = BData[key]
      })
    }
    if (!_config.wrap.height) { // 兼容
      _config.wrap.height = _config.style.height || '300px'
      delete _config.style.height
    }
    delete _config.style.height
    _config.subcards.forEach(card => {
      card.style.height = _config.wrap.height
@@ -139,13 +155,13 @@
  }
  initExec = () => {
    const { config } = this.state
    const { config, BID } = this.state
    if (config.wrap.datatype === 'dynamic') {
      if (config.$cache) {
        if (config.$time) {
          if (!this.loaded) {
            Api.getLCacheConfig(config.uuid, config.$time).then(res => {
            Api.getLCacheConfig(config.uuid, config.$time, BID).then(res => {
              if (!res.valid && config.setting.onload === 'true') {
                setTimeout(() => {
                  this.loadData('init')
@@ -164,7 +180,7 @@
          }
        } else {
          if (!this.loaded) {
            Api.getLCacheConfig(config.uuid, 0).then(res => {
            Api.getLCacheConfig(config.uuid, 0, BID).then(res => {
              if (!res.data || this.loaded) return
      
              let _data = res.data[0] || {$$empty: true}
@@ -204,7 +220,7 @@
    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)
    }
    _data = _data[0] || {$$empty: true}
@@ -270,8 +286,8 @@
    if (config.uuid !== menuId) return
    if ((position === 'mainline' || position === 'popclose') && config.setting.supModule && BID) { // 刷新源组件时,附带刷新上级行与当前组件
      MKEmitter.emit('reloadData', config.setting.supModule, BID)
    if (['mainline', 'maingrid', 'popclose'].includes(position) && config.setting.supModule) {
      MKEmitter.emit('reloadData', config.setting.supModule, position === 'maingrid' ? '' : BID)
    } else {
      this.loadData()
    }
@@ -319,8 +335,16 @@
    const { config, BID, BData } = this.state
    if (config.wrap.datatype === 'static') {
      let _data = {$$BID: BID || '', $$BData: BData, $$empty: true}
      if (BData) {
        Object.keys(BData).forEach(key => {
          if (/\$/.test(key)) return
          _data[key.toLowerCase()] = BData[key]
        })
      }
      this.setState({
        data: {$$BID: BID || '', $$BData: BData, $$empty: true}
        data: _data
      })
      return
    } else if (config.setting.supModule && !BID) { // BID 不存在时,不做查询
@@ -356,7 +380,7 @@
      this.loaded = true
      if (config.$cache && type === 'init') {
        Api.writeCacheConfig(config.uuid, result.data || [])
        Api.writeCacheConfig(config.uuid, result.data || [], BID)
      }
      if (!result.data || !result.data[0]) {
@@ -382,37 +406,15 @@
          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
          })
        }
      }
      UtilsDM.querySuccess(result)
    } else {
      this.setState({
        loading: false
      })
      this.timer && this.timer.stop()
      
      if (!result.message) return
      if (result.ErrCode === 'N') {
        Modal.error({
          title: result.message,
        })
      } else if (result.ErrCode !== '-2') {
        notification.error({
          top: 92,
          message: result.message,
          duration: 10
        })
      }
      UtilsDM.queryFail(result)
    }
  }