Commit d502d22e authored by 田翔's avatar 田翔

fix: 增加分页

parent 08aaf5c5
import React, { useEffect, useMemo, useState } from 'react' import React, { useEffect, useMemo, useState } from 'react'
import styles from './index.less' import styles from './index.less'
import { Table, Tooltip, message, Button } from 'antd' import { Table, Tooltip, message, Button, Pagination } from 'antd'
import SearchGroup from './components/SearchGroup' import SearchGroup from './components/SearchGroup'
import TablePack from './components/TablePack' import TablePack from './components/TablePack'
import { GetAccountConfigInfo, GetAccountPageList, getStationListByUserID, GetTableJson } from '../../apis/process' import { GetAccountConfigInfo, GetAccountPageList, getStationListByUserID, GetTableJson } from '../../apis/process'
...@@ -30,7 +30,7 @@ const TableRender = (props) => { ...@@ -30,7 +30,7 @@ const TableRender = (props) => {
const userID = window?.globalConfig?.userInfo?.OID || 1 const userID = window?.globalConfig?.userInfo?.OID || 1
const { accountName } = props const { accountName } = props
const [detailShow, setDetailShow] = useState(false) const [detailShow, setDetailShow] = useState(false)
const [params, setParams] = useState({ userID: userID, accountName, direction: 'desc', timeField: '录入时间', pageIndex: 1, pageSize: 100 }) const [params, setParams] = useState({ userID: userID, accountName, direction: 'desc', timeField: '录入时间', total: 0, pageIndex: 1, pageSize: 100 })
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const [config, setConfig] = useState({ webShowFieldGroup: '', formJson: '', values: [] }) const [config, setConfig] = useState({ webShowFieldGroup: '', formJson: '', values: [] })
const [dataSource, setDataSource] = useState([]) const [dataSource, setDataSource] = useState([])
...@@ -135,6 +135,7 @@ const TableRender = (props) => { ...@@ -135,6 +135,7 @@ const TableRender = (props) => {
const { code, data, msg } = await GetAccountPageList({ ...params, ...param }) const { code, data, msg } = await GetAccountPageList({ ...params, ...param })
if (code === 0) { if (code === 0) {
setDataSource(JSON.parse(data.jsonData)) setDataSource(JSON.parse(data.jsonData))
setParams({ ...params, total: data.totalCount, pageIndex: data.pageIndex, pageSize: data.pageSize })
} else { } else {
setDataSource([]) setDataSource([])
message.error(msg) message.error(msg)
...@@ -142,6 +143,10 @@ const TableRender = (props) => { ...@@ -142,6 +143,10 @@ const TableRender = (props) => {
setLoading(false) setLoading(false)
} }
const pageChange = (pageIndex, pageSize) => {
getDataSource({ pageIndex, pageSize })
}
const getData = () => { const getData = () => {
getConfig() getConfig()
getDataSource() getDataSource()
...@@ -175,7 +180,16 @@ const TableRender = (props) => { ...@@ -175,7 +180,16 @@ const TableRender = (props) => {
</div> </div>
</div> </div>
<div className={styles.footer}> <div className={styles.footer}>
<div className={styles.total}>共计{params.total}条数据</div>
<div className={styles.pagination}>
<Pagination
showQuickJumper
pageSize={params.pageSize}
current={params.pageIndex}
total={params.total}
onChange={pageChange}
/>
</div>
</div> </div>
</div> </div>
<div className={styles.tableDetail} style={{ display: detailShow ? 'block' : 'none' }}> <div className={styles.tableDetail} style={{ display: detailShow ? 'block' : 'none' }}>
......
...@@ -66,7 +66,7 @@ ...@@ -66,7 +66,7 @@
} }
&:hover:not(.ant-table-expanded-row):not(.ant-table-row-selected) { &:hover:not(.ant-table-expanded-row):not(.ant-table-row-selected) {
td { td {
background: rgb(237,242,255)!important; background: rgb(237, 242, 255)!important;
} }
} }
} // .ant-table-tbody > tr > td:last-child { } // .ant-table-tbody > tr > td:last-child {
...@@ -97,8 +97,12 @@ ...@@ -97,8 +97,12 @@
position: absolute; position: absolute;
bottom: 0; bottom: 0;
left: 0; left: 0;
padding: 0 20px;
width: 100%; width: 100%;
height: 50px; height: 50px;
display: flex;
align-items: center;
justify-content: space-between;
} }
} }
.tableDetail { .tableDetail {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment