king
2022-08-16 cc836600db6b4adecaaeb383a09e6ff89a2f0553
src/tabviews/custom/components/card/table-card/index.jsx
@@ -3,6 +3,7 @@
import { connect } from 'react-redux'
import { is, fromJS } from 'immutable'
import { Spin, notification, Row, Col, Empty, Pagination } from 'antd'
import { DownOutlined } from '@ant-design/icons'
import Api from '@/api'
import Utils from '@/utils/utils.js'
@@ -100,6 +101,8 @@
        return item
      })
    })
    _config.wrap.pagestyle = _config.wrap.pagestyle || 'page'
    this.setState({
      sync: _sync,
@@ -236,7 +239,7 @@
    })
  }
  async loadData () {
  async loadData (type) {
    const { mainSearch } = this.props
    const { config, arr_field, pageIndex, search, BID, BData } = this.state
@@ -277,15 +280,31 @@
        start = config.setting.pageSize * (pageIndex - 1) + 1
      }
      this.setState({
        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 + ''
          return item
        })
      } else {
        data = result.data.map((item, index) => {
          item.key = index
          item.$$uuid = item[config.setting.primaryKey] || ''
          item.$$BID = BID || ''
          item.$$BData = BData || ''
          item.$Index = index + start + ''
          return item
        }),
        })
      }
      this.setState({
        data: data,
        total: result.total,
        loading: false
      })
@@ -416,6 +435,20 @@
    })
  }
  loadMore = () => {
    const { total, pageIndex, loading, config } = this.state
    if (loading || config.setting.pageSize * pageIndex >= total) {
      return
    }
    this.setState({
      pageIndex: pageIndex + 1
    }, () => {
      this.loadData('plus')
    })
  }
  render() {
    const { config, loading, data, BID, pageIndex, total } = this.state
@@ -436,7 +469,8 @@
        {data && data.length === 0 ? <div className="card-row-list" style={{height: config.wrap.contentHeight}}>
          <Empty description={false}/>
        </div> : null}
        {config.setting.laypage ? <Pagination size="small" current={pageIndex} total={total} onChange={this.changePageIndex} /> : null}
        {config.setting.laypage && config.wrap.pagestyle === 'page' ? <Pagination size="small" current={pageIndex} total={total} onChange={this.changePageIndex} /> : null}
        {config.setting.laypage && config.wrap.pagestyle === 'more' && data && data.length > 0 ? <div className={'mk-more' + (config.setting.pageSize * pageIndex >= total ? ' disabled' : '')} onClick={this.loadMore}>查看更多<DownOutlined/></div> : null}
      </div>
    )
  }