king
2021-12-29 2245384d97d69e36d09cd6baa877e50a81d9aff9
src/tabviews/custom/components/card/prop-card/index.jsx
@@ -31,7 +31,8 @@
    sync: false,               // 是否统一请求数据
    data: {},                  // 数据
    timer: null,               // 定时器时间间隔
    BData: ''
    BData: '',
    selected: 'false',
  }
  UNSAFE_componentWillMount () {
@@ -63,6 +64,9 @@
    if (_data) {
      _data.$$BID = BID || ''
      _data.$$BData = BData || ''
      if (_config.setting && _config.setting.primaryKey) {
        _data.$$uuid = _data[_config.setting.primaryKey] || ''
      }
    }
    _config.columns.forEach(item => {
@@ -105,15 +109,12 @@
      _config.subcards[0].offset = offset
    }
    if (_config.subcards[0] && (_config.wrap.selected === 'always' || _config.wrap.selected === 'init')) {
      setTimeout(() => {
        this.checkTopLine()
      }, 200)
    }
    _config.wrap.selStyle = _config.wrap.selStyle || 'active'
    _config.wrap.priKeyType = _config.wrap.priKeyType || 'static'
    let selected = _config.wrap.selected || 'false'
    this.setState({
      selected,
      sync: _sync,
      data: _data,
      BID: BID || '',
@@ -123,6 +124,10 @@
    }, () => {
      if (_config.wrap.datatype !== 'static' && _config.setting && _config.setting.sync !== 'true' && _config.setting.onload === 'true') {
        this.loadData()
      } else if ((!_sync || _config.wrap.priKeyType === 'static') && selected !== 'false') {
        setTimeout(() => {
          this.checkTopLine()
        }, 200)
      }
    })
  }
@@ -152,23 +157,28 @@
   * @description 图表数据更新,刷新内容
   */
  UNSAFE_componentWillReceiveProps (nextProps) {
    const { sync, config, BID, BData } = this.state
    const { sync, config, BID, BData, selected } = this.state
    if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) {
      let _data = { $$empty: true }
      if (nextProps.data && nextProps.data[config.dataName]) {
        _data = nextProps.data[config.dataName]
        if (_data && Array.isArray(_data)) {
          _data = _data[0]
        _data = nextProps.data[config.dataName] || {}
        if (Array.isArray(_data)) {
          _data = _data[0] || {}
        }
      }
      if (_data) {
        _data.$$BID = BID || ''
        _data.$$BData = BData || ''
      }
      _data.$$uuid = _data[config.setting.primaryKey] || ''
      this.setState({sync: false, data: _data})
      this.setState({sync: false, data: _data}, () => {
        if (config.wrap.priKeyType !== 'static' && selected !== 'false') {
          setTimeout(() => {
            this.checkTopLine()
          }, 200)
        }
      })
    } else if ( config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
      this.setState({}, () => {
        this.loadData()
@@ -177,13 +187,23 @@
  }
  checkTopLine = () => {
    const { config, data } = this.state
    const { config, data, selected } = this.state
    if (!config.subcards[0]) return
    this.setState({
      activeKey: 0
      activeKey: 0,
      selected: selected === 'init' ? 'false' : selected
    })
    MKEmitter.emit('resetSelectLine', config.uuid, (config.subcards[0].setting.primaryId || ''), data)
    let primaryId = config.subcards[0].setting.primaryId || ''
    if (config.wrap.priKeyType === 'dynamic') {
      primaryId = data.$$uuid || ''
    } else if (config.wrap.priKeyType === 'joint') {
      primaryId = (data.$$uuid || '') + ',' + primaryId
    }
    MKEmitter.emit('resetSelectLine', config.uuid, primaryId, data)
  }
  handleTimer = () => {
@@ -282,7 +302,7 @@
  async loadData (hastimer) {
    const { mainSearch, menuType } = this.props
    const { config, arr_field, BID, BData } = this.state
    const { config, arr_field, BID, BData, selected } = this.state
    if (config.wrap.datatype === 'static') {
      this.setState({
@@ -324,10 +344,15 @@
      _data.$$BID = BID || ''
      _data.$$BData = BData
      _data.$$uuid = _data[config.setting.primaryKey] || ''
      this.setState({
        data: _data,
        loading: false
      }, () => {
        if (config.wrap.priKeyType !== 'static' && selected !== 'false') {
          this.checkTopLine()
        }
      })
      if (config.timer && config.clearField) {
@@ -358,7 +383,14 @@
      activeKey: index
    })
    MKEmitter.emit('resetSelectLine', config.uuid, (item.setting.primaryId || ''), data)
    let primaryId = item.setting.primaryId || ''
    if (config.wrap.priKeyType === 'dynamic') {
      primaryId = data.$$uuid || ''
    } else if (config.wrap.priKeyType === 'joint') {
      primaryId = (data.$$uuid || '') + ',' + primaryId
    }
    MKEmitter.emit('resetSelectLine', config.uuid, primaryId, data)
  }
  render() {