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