king
2021-09-01 31ec63f0419895876cbaba99637a884a32d33d0d
src/tabviews/custom/components/card/data-card/index.jsx
@@ -2,7 +2,7 @@
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { connect } from 'react-redux'
import { Spin, Empty, notification, Row, Col, Pagination } from 'antd'
import { Spin, Empty, notification, message, Row, Col, Pagination } from 'antd'
import Api from '@/api'
import Utils from '@/utils/utils.js'
@@ -146,6 +146,7 @@
  componentDidMount () {
    MKEmitter.addListener('reloadData', this.reloadData)
    MKEmitter.addListener('mkCheckAll', this.mkCheckAll)
    MKEmitter.addListener('resetSelectLine', this.resetParentParam)
    MKEmitter.addListener('queryModuleParam', this.queryModuleParam)
    MKEmitter.addListener('refreshByButtonResult', this.refreshByButtonResult)
@@ -185,6 +186,7 @@
      return
    }
    MKEmitter.removeListener('reloadData', this.reloadData)
    MKEmitter.removeListener('mkCheckAll', this.mkCheckAll)
    MKEmitter.removeListener('resetSelectLine', this.resetParentParam)
    MKEmitter.removeListener('queryModuleParam', this.queryModuleParam)
    MKEmitter.removeListener('refreshByButtonResult', this.refreshByButtonResult)
@@ -223,17 +225,32 @@
    }
  }
  reloadData = (btn) => {
    if (!btn || btn.resetPageIndex !== 'false') {
  mkCheckAll = (menuId, checked) => {
    const { config, data } = this.state
    if (config.uuid !== menuId) return
    if (checked) {
      this.setState({
        pageIndex: 1
      }, () => {
        this.loadmaindata(true, 'true')
        this.getStatFieldsValue()
        activeKey: '',
        selectKeys: data.map((item, index) => index),
        selectedData: data
      })
      MKEmitter.emit('resetSelectLine', config.uuid, '', '')
      MKEmitter.emit('syncBalconyData', config.uuid, data, data.length > 0)
      if (data.length === 0) {
        message.warning('未获取到数据!')
      }
    } else {
      this.loadmaindata(true, 'false')
      this.getStatFieldsValue()
      this.setState({
        activeKey: '',
        selectKeys: [],
        selectedData: []
      })
      MKEmitter.emit('resetSelectLine', config.uuid, '', '')
      MKEmitter.emit('syncBalconyData', config.uuid, [], false)
    }
  }
@@ -290,7 +307,7 @@
  async loadData () {
    const { mainSearch, menuType } = this.props
    const { config, arr_field, pageIndex, search, BID } = this.state
    const { config, arr_field, pageIndex, search, BID, BData } = this.state
    if (config.setting.supModule && !BID) { // BID 不存在时,不做查询
      this.setState({
@@ -302,6 +319,10 @@
        total: 0,
        loading: false
      })
      MKEmitter.emit('resetSelectLine', config.uuid, '', '')
      if (config.setting.$hasSyncModule) {
        MKEmitter.emit('syncBalconyData', config.uuid, [], false)
      }
      return
    }
@@ -342,12 +363,17 @@
          item.key = index
          item.$$uuid = item[config.setting.primaryKey] || ''
          item.$$BID = BID || ''
          item.$$BData = BData || ''
          item.$Index = index + start + ''
          return item
        }),
        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
@@ -365,7 +391,7 @@
   */ 
  async loadLinedata (id) {
    const { mainSearch, menuType } = this.props
    const { config, arr_field, pageIndex, search, BID } = this.state
    const { config, arr_field, pageIndex, search, BID, BData } = this.state
    let searches = fromJS(search).toJS()
    if (config.setting.useMSearch && mainSearch && mainSearch.length > 0) { // 主表搜索条件
@@ -384,10 +410,6 @@
    let _orderBy = config.setting.order || ''
    let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, pageIndex, config.setting.pageSize, BID, menuType, id)
    if (param.func === 'sPC_Get_TableData') {
      param.menuname = config.name || ''
    }
    let result = await Api.genericInterface(param)
    if (result.status) {
      let data = fromJS(this.state.data).toJS()
@@ -400,13 +422,14 @@
              _data.key = item.key
              _data.$$uuid = _data[config.setting.primaryKey] || ''
              _data.$$BID = BID || ''
              item.$$BData = BData || ''
              _data.$Index = item.$Index
              return _data
            } else {
              return item
            }
          })
        } catch {
        } catch (e) {
          console.warn('数据查询错误')
        }
      }
@@ -470,7 +493,7 @@
  }
  
  changeCard = (index, item) => {
    const { config, selectKeys, selectedData, activeKey } = this.state
    const { config, selectKeys, selectedData, activeKey, data } = this.state
    this.openView(item)
@@ -510,6 +533,9 @@
    })
    MKEmitter.emit('resetSelectLine', config.uuid, (_item ? _item.$$uuid : ''), _item)
    if (config.setting.$hasSyncModule) {
      MKEmitter.emit('syncBalconyData', config.uuid, _selectedData, data.length === _selectedData.length)
    }
  }
  openView = (item) => {
@@ -542,7 +568,7 @@
        newtab.param.$BID = item.$$uuid
      }
      if (['linkage_navigation', 'linkage'].includes(window.GLOB.navBar)) {
      if (['linkage_navigation', 'linkage', 'menu_board'].includes(window.GLOB.navBar)) {
        this.props.modifyTabview([newtab])
      } else {
        let tabs = this.props.tabviews.filter((tab, i) => {
@@ -572,7 +598,7 @@
          _param.User_Name = sessionStorage.getItem('User_Name')
          _param.param = { BID: item.$$uuid }
          src = _url + window.btoa(window.encodeURIComponent(JSON.stringify(_param)))
        } catch {
        } catch (e) {
          console.warn('菜单参数解析错误!')
        }
      } else if (card.setting.joint === 'true') {
@@ -634,7 +660,7 @@
          <Row className="card-row-list">
            {offset ? <Col span={offset} style={{height: '10px'}}> </Col> : null}
            {precards.map((item, index) => (
              <Col key={'pre' + index} className={item.setting.$click} span={item.setting.width || 6}>
              <Col key={'pre' + index} className={'extend-card ' + item.setting.$click} span={item.setting.width || 6}>
                <CardItem card={item} cards={config} data={{$$BID: BID, $$type: 'extendCard'}}/>
              </Col>
            ))}
@@ -644,7 +670,7 @@
              </Col>
            ))}
            {nextcards.map((item, index) => (
              <Col key={'next' + index} className={item.setting.$click} span={item.setting.width || 6}>
              <Col key={'next' + index} className={'extend-card ' + item.setting.$click} span={item.setting.width || 6}>
                <CardItem card={item} cards={config} data={{$$BID: BID, $$type: 'extendCard'}}/>
              </Col>
            ))}