king
2022-08-16 cc836600db6b4adecaaeb383a09e6ff89a2f0553
src/tabviews/custom/components/card/data-card/index.jsx
@@ -2,6 +2,7 @@
import PropTypes from 'prop-types'
import { is, fromJS } from 'immutable'
import { Spin, Empty, notification, message, Row, Col, Pagination } from 'antd'
import { DownOutlined } from '@ant-design/icons'
import Api from '@/api'
import Utils from '@/utils/utils.js'
@@ -165,6 +166,7 @@
    }
    _config.wrap.selStyle = _config.wrap.selStyle || 'active'
    _config.wrap.pagestyle = _config.wrap.pagestyle || 'page'
    _config.wrap.scale = _config.wrap.scale === 'true' ? 'scale' : ''
    _config.wrap.layout = (_config.wrap.layout || 'grid') + '-layout float-' + (_config.wrap.cardFloat || 'left')
@@ -462,7 +464,7 @@
    })
  }
  async loadData (id) {
  async loadData (id, type) {
    const { mainSearch } = this.props
    const { config, arr_field, pageIndex, search, BID, BData, selected } = this.state
@@ -536,11 +538,26 @@
        }
      }
      this.setState({
        activeKey: '',
        selectKeys: [],
        selectedData: [],
        data: result.data.map((item, index) => {
      let data = []
      if (type === 'plus') {
        let _data = (this.state.data || []).concat(result.data || [])
        data = _data.map((item, index) => {
          item.key = index
          item.$$uuid = item[config.setting.primaryKey] || ''
          item.$$BID = BID || ''
          item.$$BData = BData || ''
          item.$Index = index + 1 + ''
          if (config.wrap.controlField) {
            if (config.wrap.controlVal.includes(item[config.wrap.controlField])) {
              item.$disabled = true
            }
          }
          return item
        })
      } else {
        data = result.data.map((item, index) => {
          item.key = index
          item.$$uuid = item[config.setting.primaryKey] || ''
          item.$$BID = BID || ''
@@ -552,9 +569,15 @@
              item.$disabled = true
            }
          }
          return item
        }),
        })
      }
      this.setState({
        activeKey: '',
        selectKeys: [],
        selectedData: [],
        data: data,
        total: result.total,
        loading: false
      })
@@ -634,6 +657,20 @@
        duration: 10
      })
    }
  }
  loadMore = () => {
    const { total, pageIndex, loading, config } = this.state
    if (loading || config.setting.pageSize * pageIndex >= total) {
      return
    }
    this.setState({
      pageIndex: pageIndex + 1
    }, () => {
      this.loadData('', 'plus')
    })
  }
  prevPage = () => {
@@ -793,7 +830,8 @@
          {switchable ? <div className={'prev-page ' + (total <= _total ? 'disabled' : '')} onClick={this.nextPage}><div><div><img src={nextImg} alt=""/></div></div></div> : null}
          {precards.length === 0 && nextcards.length === 0 && (!data || data.length === 0) ? <Empty description={false}/> : null}
        </div>
        {config.wrap.pagestyle !== 'switch' && config.setting.laypage && data ? <Pagination size="small" total={total} showTotal={t => `共 ${t} 条`} pageSize={config.setting.pageSize} onChange={this.changePageIndex} current={pageIndex}/> : null}
        {config.wrap.pagestyle === 'page' && config.setting.laypage && data ? <Pagination size="small" total={total} showTotal={t => `共 ${t} 条`} pageSize={config.setting.pageSize} onChange={this.changePageIndex} current={pageIndex}/> : null}
        {config.wrap.pagestyle === 'more' && config.setting.laypage && data && data.length > 0 ? <div className={'mk-more' + (config.setting.pageSize * pageIndex >= total ? ' disabled' : '')} onClick={this.loadMore}>查看更多<DownOutlined/></div> : null}
      </div>
    )
  }