king
2024-04-08 37e28da53f6d4d7d8abe7626ba28ba7dbe16e7bb
src/tabviews/custom/components/card/double-data-card/index.jsx
@@ -1,7 +1,7 @@
import React, {Component} from 'react'
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Spin, Empty, notification, Row, Col, Pagination, Modal, Switch } from 'antd'
import { Spin, Empty, Row, Col, Pagination, Switch } from 'antd'
import { DownOutlined, UpOutlined, PlusSquareOutlined, MinusSquareOutlined } from '@ant-design/icons'
import Api from '@/api'
@@ -36,7 +36,7 @@
    loading: false,            // 数据加载状态
    card: null,                // 卡片设置
    data: [],                // 数据
    total: null,
    total: 0,
    precards: [],
    nextcards: [],
    selected: 'false',
@@ -170,6 +170,9 @@
        pageOptions.push(size)
        pageOptions = pageOptions.sort((a, b) => a - b)
      }
      if (_config.wrap.maxPageSize) {
        pageOptions = pageOptions.filter(item => item <= _config.wrap.maxPageSize)
      }
    }
    if (_config.wrap.zHeight) {
@@ -229,6 +232,8 @@
    if (config.setting.onload === 'true') {
      this.initExec()
    }
    this.autoExec()
  }
  shouldComponentUpdate (nextProps, nextState) {
@@ -319,6 +324,25 @@
      setTimeout(() => {
        this.loadData()
      }, config.setting.delay || 0)
    }
  }
  autoExec = (times) => {
    const { config } = this.state
    if (!config.wrap.autoExec) return
    let btn = document.getElementById('button' + config.wrap.autoExec)
    this.autoTimer && clearTimeout(this.autoTimer)
    if (btn) {
      MKEmitter.emit('triggerBtnId', config.wrap.autoExec, [])
    } else if (!times || times < 20) {
      times = times ? times + 1 : 1
      this.autoTimer = setTimeout(() => {
        this.autoExec(times)
      }, 1000)
    }
  }
@@ -522,7 +546,9 @@
    if (!config.setting.supModule || config.setting.supModule !== MenuID) return
    if (id !== this.state.BID || id !== '') {
      this.setState({ BID: id, BData: data, pageIndex: 1 }, () => {
        this.loadData()
        if (!config.checkBid) {
          this.loadData()
        }
      })
    }
  }
@@ -557,6 +583,7 @@
    if (config.setting.supModule && !BID && config.wrap.supKey !== 'false') { // BID 不存在时,不做查询
      this.loaded = true
      this.requestId = ''
      this.setState({
        activeKey: '',
@@ -568,17 +595,8 @@
        total: 0,
        loading: false
      })
      if (selected !== 'false' || (id && config.wrap.selected !== 'false')) {
        setTimeout(() => {
          this.checkTopLine(id)
        }, 10)
        if (selected === 'init') {
          this.setState({selected: 'false'})
        }
      } else {
        MKEmitter.emit('resetSelectLine', config.uuid, '', '')
      }
      MKEmitter.emit('resetSelectLine', config.uuid, '', '')
      return
    }
@@ -606,8 +624,12 @@
    let _orderBy = orderBy || config.setting.order || ''
    let param = UtilsDM.getQueryDataParams(config.setting, searches, _orderBy, pageIndex, pageSize, BID)
    let result = await Api.genericInterface(param)
    this.requestId = config.uuid + new Date().getTime()
    let result = await Api.genericInterface(param, '', '', this.requestId)
    if (result.status) {
      if (result.$requestId && this.requestId !== result.$requestId) return
      let start = 1
      if (config.setting.laypage) {
        start = pageSize * (pageIndex - 1) + 1
@@ -740,37 +762,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)
    }
  }
@@ -928,11 +928,8 @@
      this.setState({
        loading: false
      })
      notification.error({
        top: 92,
        message: result.message,
        duration: 10
      })
      UtilsDM.queryFail(result)
    }
  }
@@ -1193,6 +1190,20 @@
                    subClass = opens.indexOf(item.key) > -1 ? 'mk-unfold' : 'mk-collapse'
                    unfold = opens.indexOf(item.key) > -1
                  }
                  if (!unfold && item.children.length > 5) {
                    return (
                      <Col key={index} span={card.setting.width} style={card.wStyle}>
                        <div className={className} style={wrapStyle}>
                          <CardItem card={card} cards={config} data={item} onDoubleClick={() => this.onDoubleClick(item.key, subClass)} onClick={() => {this.changeCard(item.key, item, subClass)}}>
                            <span className="circle-select"></span>
                            {card.setting.controlIcon === 'left' ? <PlusSquareOutlined className={subClass} onClick={(e) => this.changeUnfold(e, item.key, subClass)}/> : null}
                            {card.setting.controlIcon === 'right' ? <UpOutlined className={subClass} onClick={(e) => this.changeUnfold(e, item.key, subClass)}/> : null}
                          </CardItem>
                        </div>
                      </Col>
                    )
                  }
                }
                return (