king
2021-07-28 137fb8ea6af2789b3238b22bac31d80bced41dfe
src/tabviews/custom/components/card/prop-card/index.jsx
@@ -2,7 +2,7 @@
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { connect } from 'react-redux'
import { Spin, notification, Col } from 'antd'
import { Spin, notification, Col, Row } from 'antd'
import moment from 'moment'
import Api from '@/api'
@@ -73,6 +73,13 @@
    let _width = 0
    _config.subcards.forEach(card => {
      card.setting.$click = ''
      if (card.setting.click === 'button') {
        if (card.elements.filter(ele => ele.eleType === 'button').length < 2) {
          card.setting.$click = ' trigger-button'
        }
        card.setting.click = ''
      }
      _width += card.setting.width
      card.elements = card.elements.map(item => {
        if (item.field && _cols.has(item.field)) {
@@ -113,7 +120,7 @@
  componentDidMount () {
    MKEmitter.addListener('reloadData', this.reloadData)
    MKEmitter.addListener('resetSelectLine', this.resetParentParam)
    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
    MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
    this.handleTimer()
  }
@@ -151,12 +158,10 @@
      }
      this.setState({sync: false, data: _data})
    } else if (nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
      if (config.wrap.datatype !== 'static' && config.setting.syncRefresh === 'true') {
        this.setState({}, () => {
          this.loadData()
        })
      }
    } else if ( config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
      this.setState({}, () => {
        this.loadData()
      })
    }
  }
@@ -165,16 +170,7 @@
    if (!config.timer) return
    const _change = {
      '15s': 15000,
      '30s': 30000,
      '1min': 60000,
      '5min': 300000,
      '10min': 600000,
      '15min': 900000,
      '30min': 1800000,
      '1hour': 3600000
    }
    const _change = { '15s': 15000, '30s': 30000, '1min': 60000, '5min': 300000, '10min': 600000, '15min': 900000, '30min': 1800000, '1hour': 3600000 }
    let timer = _change[config.timer]
@@ -270,25 +266,20 @@
    if (config.wrap.datatype === 'static') {
      this.setState({
        data: {$$BID: BID || ''},
        loading: false
      })
      return
    } else if (config.setting.supModule && !BID) { // BID 不存在时,不做查询
      this.setState({
        data: {$$BID: BID || ''},
        loading: false
      })
      return
    }
    let searches = []
    if (mainSearch && mainSearch.length > 0) { // 主表搜索条件
      let keys = searches.map(item => item.key)
      mainSearch.forEach(item => {
        if (!keys.includes(item.key)) {
          searches.push(item)
        }
      })
    let searches = config.setting.useMSearch && mainSearch ? mainSearch : []
    let requireFields = searches.filter(item => item.required && item.value === '')
    if (requireFields.length > 0) {
      return
    }
    if (!hastimer) {
@@ -417,7 +408,7 @@
    const { config, loading, data, activeKey } = this.state
    return (
      <div className="custom-prop-card-box" style={{...config.style, minHeight: config.wrap.minHeight}}>
      <div className="custom-prop-card-box" style={config.style}>
        {loading ?
          <div className="loading-mask">
            <div className="ant-spin-blur"></div>
@@ -425,13 +416,13 @@
          </div> : null
        }
        <NormalHeader config={config}/>
        <div className={`card-row-list ${config.wrap.cardType || ''} ${config.wrap.scale || ''}`}>
        <Row className={`card-row-list ${config.wrap.cardType || ''} ${config.wrap.scale || ''}`}>
          {config.subcards.map((item, index) => (
            <Col className={(activeKey === index ? 'active' : '') + (item.setting.click ? ' pointer' : '')} key={index} span={item.setting.width || 6} offset={item.offset || 0} onClick={() => {this.changeCard(index, item)}}>
            <Col className={(activeKey === index ? 'active' : '') + (item.setting.click ? ' pointer' : '') + item.setting.$click} key={index} span={item.setting.width || 6} offset={item.offset || 0} onClick={() => {this.changeCard(index, item)}}>
              <CardItem card={item} cards={config} data={data}/>
            </Col>
          ))}
        </div>
        </Row>
      </div>
    )
  }