mirror of
https://github.com/bufanyun/hotgo.git
synced 2025-01-23 02:40:23 +08:00
表格组件增加数据总行数显示
This commit is contained in:
parent
4069411156
commit
7fcf8fb73c
@ -33,11 +33,13 @@ func (req *PageReq) GetPerPage() int {
|
||||
// PageRes 分页响应
|
||||
type PageRes struct {
|
||||
PageReq
|
||||
PageCount int `json:"pageCount" example:"0" dc:"全部数据量"`
|
||||
PageCount int `json:"pageCount" example:"0" dc:"分页个数"`
|
||||
TotalCount int `json:"totalCount" example:"0" dc:"数据总行数"`
|
||||
}
|
||||
|
||||
// Pack 打包分页数据
|
||||
func (res *PageRes) Pack(req ReqPageFunc, totalCount int) {
|
||||
res.TotalCount = totalCount
|
||||
res.PageCount = CalPageCount(totalCount, req.GetPerPage())
|
||||
res.Page = req.GetPage()
|
||||
res.PerPage = req.GetPerPage()
|
||||
|
@ -53,6 +53,7 @@ export function useDataSource(
|
||||
const sizeField = APISETTING.sizeField;
|
||||
const totalField = APISETTING.totalField;
|
||||
const listField = APISETTING.listField;
|
||||
const itemCountField = APISETTING.itemCountField;
|
||||
|
||||
let pageParams = {};
|
||||
const { page = 1, pageSize = 10 } = unref(getPaginationInfo) as PaginationProps;
|
||||
@ -75,6 +76,7 @@ export function useDataSource(
|
||||
|
||||
const resultTotal = res[totalField] || 0;
|
||||
const currentPage = res[pageField];
|
||||
const itemCount = res[itemCountField] || 0;
|
||||
|
||||
// 如果数据异常,需获取正确的页码再次执行
|
||||
if (resultTotal) {
|
||||
@ -108,6 +110,9 @@ export function useDataSource(
|
||||
setPagination({
|
||||
[pageField]: currentPage,
|
||||
[totalField]: resultTotal,
|
||||
prefix: () => {
|
||||
return `共 ${itemCount} 条`;
|
||||
},
|
||||
});
|
||||
if (opt && opt[pageField]) {
|
||||
setPagination({
|
||||
|
@ -9,6 +9,8 @@ export default {
|
||||
listField: 'list',
|
||||
// 接口返回总页数字段名
|
||||
totalField: 'pageCount',
|
||||
// 接口返回总行数字段名
|
||||
itemCountField: 'totalCount',
|
||||
},
|
||||
//默认分页数量
|
||||
defaultPageSize: 10,
|
||||
|
Loading…
Reference in New Issue
Block a user