1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
const DEFAULT_PAGE_NO = 1;
const DEFAULT_PAGE_SIZE = 10;
class PaginationHelper {
static defaultPaginationConfig = {
defaultCurrent: DEFAULT_PAGE_NO,
defaultPageSize: DEFAULT_PAGE_SIZE,
current: DEFAULT_PAGE_NO,
total: 0,
pageSize: DEFAULT_PAGE_SIZE,
showSizeChanger: true,
showQuickJumper: true,
showTotal: total => `共 ${total} 条`
};
static formatPagination(data) {
return {
defaultCurrent: DEFAULT_PAGE_NO,
defaultPageSize: DEFAULT_PAGE_SIZE,
current: data.current,
total: data.total,
pageSize: data.size,
showSizeChanger: true,
showQuickJumper: true,
showTotal: total => `共 ${total} 条`,
};
};
/**
* data.total 数据总数
* payload.pageNo 页码
* payload.pageSize 每页总数
*/
static formatPagination(data, payload) {
return {
defaultCurrent: DEFAULT_PAGE_NO,
defaultPageSize: DEFAULT_PAGE_SIZE,
current: payload.pageNo,
pageSize: payload.pageSize,
total: data.total,
showSizeChanger: true,
showQuickJumper: true,
showTotal: total => `共 ${total} 条`,
};
};
//获取初始页码
static defaultPayload = {
pageNo: DEFAULT_PAGE_NO,
pageSize: DEFAULT_PAGE_SIZE
}
}
export default PaginationHelper;
export {PaginationHelper};