king
2021-09-09 e5fc2d92b1036aabf9ffc2c9706ed401bd9735c8
src/tabviews/custom/components/card/data-card/index.jsx
@@ -43,6 +43,7 @@
    total: null,
    precards: [],
    nextcards: [],
    selected: 'false'
  }
  UNSAFE_componentWillMount () {
@@ -100,6 +101,11 @@
      _config.wrap.cardFloat = null
    }
    let selected = 'false'
    if (_config.wrap.selected === 'always' || _config.wrap.selected === 'init') {
      selected = _config.wrap.selected
    }
    if (_data) {
      _data = _data.map((item, index) => {
        item.key = index
@@ -108,6 +114,15 @@
        item.$Index = index + 1 + ''
        return item
      })
      if (selected !== 'false') {
        setTimeout(() => {
          this.checkTopLine()
        }, 200)
        if (selected === 'init') {
          selected = 'false'
        }
      }
    }
    _config.columns.forEach(item => {
@@ -128,6 +143,7 @@
    })
    this.setState({
      selected,
      precards,
      nextcards,
      sync: _sync,
@@ -157,21 +173,29 @@
  }
  UNSAFE_componentWillReceiveProps (nextProps) {
    const { sync, config, BID } = this.state
    const { sync, config, BID, selected } = this.state
    if (sync && !is(fromJS(this.props.data), fromJS(nextProps.data))) {
      let _data = []
      if (nextProps.data && nextProps.data[config.dataName]) {
        _data = nextProps.data[config.dataName] || []
      }
        _data = _data.map((item, index) => {
          item.key = index
          item.$$uuid = item[config.setting.primaryKey] || ''
          item.$$BID = BID || ''
          item.$Index = index + 1 + ''
          return item
        })
      _data = _data.map((item, index) => {
        item.key = index
        item.$$uuid = item[config.setting.primaryKey] || ''
        item.$$BID = BID || ''
        item.$Index = index + 1 + ''
        return item
      })
        if (selected !== 'false') {
          setTimeout(() => {
            this.checkTopLine()
          }, 200)
          if (selected === 'init') {
            this.setState({selected: 'false'})
          }
        }
      }
      this.setState({sync: false, data: _data})
    } else if (config.setting.syncRefresh && nextProps.mainSearch && !is(fromJS(this.props.mainSearch), fromJS(nextProps.mainSearch))) {
@@ -222,6 +246,23 @@
    } else if (position === 'popclose') {                                      // 标签关闭刷新
      config.setting.supModule && MKEmitter.emit('reloadData', config.setting.supModule, (BID || 'empty'))
      btn.$tabId && MKEmitter.emit('refreshPopButton', btn.$tabId)
    }
  }
  checkTopLine = () => {
    const { config, data } = this.state
    if (!data || data.length === 0) return
    this.setState({
      activeKey: 0,
      selectKeys: [0],
      selectedData: [data[0]]
    })
    MKEmitter.emit('resetSelectLine', config.uuid, data[0].$$uuid, data[0])
    if (config.setting.$hasSyncModule) {
      MKEmitter.emit('syncBalconyData', config.uuid, [data[0]], data.length === 1)
    }
  }
@@ -307,7 +348,7 @@
  async loadData () {
    const { mainSearch, menuType } = this.props
    const { config, arr_field, pageIndex, search, BID, BData } = this.state
    const { config, arr_field, pageIndex, search, BID, BData, selected } = this.state
    if (config.setting.supModule && !BID) { // BID 不存在时,不做查询
      this.setState({
@@ -355,6 +396,20 @@
        start = config.setting.pageSize * (pageIndex - 1) + 1
      }
      if (selected !== 'false') {
        setTimeout(() => {
          this.checkTopLine()
        }, 200)
        if (selected === 'init') {
          this.setState({selected: 'false'})
        }
      } else {
        MKEmitter.emit('resetSelectLine', config.uuid, '', '')
      }
      if (config.setting.$hasSyncModule) {
        MKEmitter.emit('syncBalconyData', config.uuid, [], false)
      }
      this.setState({
        activeKey: '',
        selectKeys: [],
@@ -370,10 +425,6 @@
        total: result.total,
        loading: false
      })
      MKEmitter.emit('resetSelectLine', config.uuid, '', '')
      if (config.setting.$hasSyncModule) {
        MKEmitter.emit('syncBalconyData', config.uuid, [], false)
      }
    } else {
      this.setState({
        loading: false