From 5df578ff69f6b02e821d59a8883bc75d78695a62 Mon Sep 17 00:00:00 2001 From: king <18310653075@163.com> Date: 星期二, 10 十一月 2020 11:07:31 +0800 Subject: [PATCH] 2020-11-10 --- src/tabviews/custom/components/card/table-card/index.jsx | 47 +++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 39 insertions(+), 8 deletions(-) diff --git a/src/tabviews/custom/components/card/table-card/index.jsx b/src/tabviews/custom/components/card/table-card/index.jsx index 4f76e24..abbc960 100644 --- a/src/tabviews/custom/components/card/table-card/index.jsx +++ b/src/tabviews/custom/components/card/table-card/index.jsx @@ -1,7 +1,7 @@ import React, {Component} from 'react' import PropTypes from 'prop-types' import { is, fromJS } from 'immutable' -import { Spin, notification, Col, Empty } from 'antd' +import { Spin, notification, Col, Empty, Pagination } from 'antd' import asyncComponent from '@/utils/asyncComponent' import Api from '@/api' @@ -24,6 +24,9 @@ state = { config: null, // 鍥捐〃閰嶇疆淇℃伅 loading: false, // 鏁版嵁鍔犺浇鐘舵�� + preIndex: 0, // 寮�濮嬬储寮� + pageIndex: 1, // 椤电爜 + total: 0, // 鎬绘暟 sync: false, // 鏄惁缁熶竴璇锋眰鏁版嵁 data: null, // 鏁版嵁 title: '', // 鏍囬 @@ -46,6 +49,12 @@ let showHeader = false if (_config.wrap.title || _config.search.length > 0) { showHeader = true + } + + if (_config.setting.laypage) { + _config.wrap.contentHeight = _config.wrap.height - (showHeader ? 85 : 40) + } else { + _config.wrap.contentHeight = _config.wrap.height - (showHeader ? 45 : 0) } _config.columns.forEach(item => { @@ -121,12 +130,16 @@ if (syncId && syncId !== config.uuid) return - this.loadData() + this.setState({ + pageIndex: 1 + }, () => { + this.loadData() + }) } async loadData () { const { mainSearch, BID, menuType, dataManager } = this.props - const { config, arr_field } = this.state + const { config, arr_field, pageIndex } = this.state let searches = [] if (mainSearch && mainSearch.length > 0) { // 涓昏〃鎼滅储鏉′欢 @@ -143,12 +156,19 @@ }) let _orderBy = config.setting.order || '' - let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, 1, 1, BID, menuType, dataManager) + let param = UtilsDM.getQueryDataParams(config.setting, arr_field, searches, _orderBy, pageIndex, config.setting.pageSize, BID, menuType, dataManager) let result = await Api.genericInterface(param) if (result.status) { + let _preIndex = 0 + if (config.setting.laypage) { + _preIndex = config.setting.pageSize * (pageIndex - 1) + } + this.setState({ data: result.data, + total: result.total, + preIndex: _preIndex, loading: false }) } else { @@ -175,6 +195,14 @@ } } } + } + + changePageIndex = (page) => { + this.setState({ + pageIndex: page + }, () => { + this.loadData() + }) } getLines = (data, seq) => { @@ -219,7 +247,7 @@ } render() { - const { config, loading, data, title, showHeader } = this.state + const { config, loading, data, title, showHeader, pageIndex, preIndex, total } = this.state return ( <div className="custom-table-card-box" style={{...config.style, height: config.wrap.height}}> @@ -233,10 +261,13 @@ <span className="table-title">{title}</span> {/* <searchLine /> */} </div> : null} - {data && data.length > 0 ? <div className="card-row-list" style={{height: config.wrap.height - (showHeader ? 45 : 0)}}> - {data.map((item, index) => this.getLines(item, index + 1))} + {data && data.length > 0 ? <div className="card-row-list" style={{height: config.wrap.contentHeight}}> + {data.map((item, index) => this.getLines(item, preIndex + index + 1))} </div> : null} - {data && data.length === 0 ? <Empty description={false}/> : null} + {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} </div> ) } -- Gitblit v1.8.0