king
2022-09-06 fa381753ef2a2b25b1c0722549ac17e333da79be
src/tabviews/custom/components/card/balcony/index.jsx
@@ -15,10 +15,8 @@
class BalconyComponent extends Component {
  static propTpyes = {
    BID: PropTypes.any,
    data: PropTypes.array,
    config: PropTypes.object,
    menuType: PropTypes.any,
  }
  state = {
@@ -35,13 +33,25 @@
  }
  UNSAFE_componentWillMount () {
    const { data, BID, initdata } = this.props
    const { data, initdata } = this.props
    let _config = fromJS(this.props.config).toJS()
    let _data = { $$empty: true }
    let _sync = false
    
    if (_config.setting && _config.wrap.datatype !== 'static') {
    let BID = ''
    let BData = ''
    if (_config.setting.supModule) {
      BData = window.GLOB.CacheData.get(_config.setting.supModule)
    } else {
      BData = window.GLOB.CacheData.get(_config.$pageId)
    }
    if (BData) {
      BID = BData.$BID || ''
    }
    if (_config.wrap.datatype !== 'static') {
      _sync = _config.setting.sync === 'true'
      if (_sync && data) {
@@ -65,7 +75,7 @@
    if (_config.wrap.position === 'fixed' || _config.wrap.position === 'absolute') {
      _config.style.position = _config.wrap.position
      _config.style.zIndex = 2
      _config.style.zIndex = 3
      _config.style.left = _config.wrap.left || ''
      _config.style.right = _config.wrap.right || ''
      _config.style.top = _config.wrap.top || ''
@@ -73,7 +83,7 @@
      _config.style.transform = _config.wrap.transform || ''
      _config.style.width = _config.wrap.realwidth || ''
    } else {
      _config.style.zIndex = 2
      _config.style.zIndex = 3
      _config.style.left = _config.wrap.left || ''
      _config.style.right = _config.wrap.right || ''
      _config.style.top = _config.wrap.top || ''
@@ -91,11 +101,8 @@
        }
        return item
      })
    } else if (_config.wrap.linkType === 'sup') {
      _config.wrap.supModule = _config.wrap.supModule.pop()
      if (_config.wrap.supControl === 'hidden') {
    } else if (_config.wrap.linkType === 'sup' && _config.wrap.supControl === 'hidden') {
        show = false
      }
    }
    this.setState({
@@ -168,11 +175,20 @@
    if (!config.timer) return
    const _change = { '5s': 5000, '15s': 15000, '30s': 30000, '1min': 60000, '5min': 300000, '10min': 600000, '15min': 900000, '30min': 1800000, '1hour': 3600000 }
    const _change = { '2s': 2000, '5s': 5000, '15s': 15000, '30s': 30000, '1min': 60000, '5min': 300000, '10min': 600000, '15min': 900000, '30min': 1800000, '1hour': 3600000 }
    let timer = _change[config.timer]
    let repeats = config.timerRepeats || 0
    if (!timer) return
    if (repeats > 0 && repeats <=3) {
      this.setState({timer, repeats})
      this.timer = setTimeout(() => {
        this.timerTask(repeats)
      }, timer)
      return
    }
    let _param = {
      func: 's_get_timers_role',
@@ -194,22 +210,29 @@
        })
        return
      } else if (result.run_type) {
        this.setState({timer})
        this.setState({timer, repeats})
        this.timer = setTimeout(() => {
          this.timerTask()
          this.timerTask(repeats)
        }, timer)
      }
    })
  }
  timerTask = () => {
    const { timer } = this.state
  timerTask = (times) => {
    const { timer, repeats } = this.state
    if (!timer) return
    
    this.loadData(true)
    if (repeats) {
      times = times - 1
      if (times <= 0) {
        clearTimeout(this.timer)
        return
      }
    }
    this.timer = setTimeout(() => {
      this.timerTask()
      this.timerTask(times)
    }, timer)
  }
@@ -229,20 +252,10 @@
      this.loadData()
    } else {
      let supModule = config.wrap.supModule
      btn.syncComponentId && MKEmitter.emit('reloadData', btn.syncComponentId)
      if (!btn.syncComponentId || btn.syncComponentId !== supModule) {
        if (position === 'mainline' || position === 'popclose') { // 刷新源组件时,附带刷新上级行与当前组件
          if (supModule && BID) {
            MKEmitter.emit('reloadData', supModule, BID)
      if ((position === 'mainline' || position === 'popclose') && config.wrap.supModule && BID) { // 刷新源组件时,附带刷新上级行与当前组件
        MKEmitter.emit('reloadData', config.wrap.supModule, BID)
          } else {
            this.loadData()
          }
        } else {
          this.loadData()
        }
      }
      
      if (position === 'popclose') {                                      // 标签关闭刷新
@@ -288,12 +301,12 @@
  /**
   * @description 导出Excel时,获取页面搜索排序等参数
   */
  queryModuleParam = (menuId, btnId) => {
  queryModuleParam = (menuId, callback) => {
    const { config } = this.state
    if (config.uuid !== menuId) return
    MKEmitter.emit('returnModuleParam', config.uuid, btnId, {
    callback({
      arr_field: '',
      orderBy: '',
      search: [],
@@ -310,7 +323,6 @@
  }
  async loadData (hastimer) {
    const { menuType } = this.props
    const { config, arr_field, BID, BData } = this.state
    if (config.wrap.datatype === 'static') {
@@ -334,7 +346,7 @@
    }
    let _orderBy = config.setting.order || ''
    let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, 1, 1, BID, menuType)
    let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, 1, 1, BID)
    let result = await Api.genericInterface(param)
    if (result.status) {
@@ -382,6 +394,8 @@
  render() {
    const { config, loading, data, show, syncConfig, syncData, checked } = this.state
    if (config.wrap.empty === 'hidden' && (!data || data.$$empty)) return null
    return (
      <div className={'custom-balcony-box' + (!show ? ' hidden' : '')} style={config.style}>
        {loading ?