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
58
59
60
61
62
63
64
| <template>
| <div class="pagination-container" v-show="total > 0">
| <el-pagination
| v-model:current-page="currentPage"
| v-model:page-size="pageSize"
| :total="total"
| :layout="layout"
| :page-sizes="pageSizes"
| background
| @size-change="handleSizeChange"
| @current-change="handleCurrentChange"
| />
| </div>
| </template>
|
| <script setup>
| import { computed } from "vue";
|
| const props = defineProps({
| total: { type: Number, default: 0 },
| page: { type: Number, default: 1 },
| limit: { type: Number, default: 10 },
| pageSizes: {
| type: Array,
| default: () => [10, 20, 50, 100],
| },
| layout: {
| type: String,
| default: "total, sizes, prev, pager, next, jumper",
| },
| });
|
| const emit = defineEmits(["pagination"]);
|
| const currentPage = computed({
| get: () => props.page,
| set: val => {
| emit("pagination", { page: val, limit: props.limit });
| },
| });
|
| const pageSize = computed({
| get: () => props.limit,
| set: val => {
| emit("pagination", { page: 1, limit: val });
| },
| });
|
| const handleSizeChange = val => {
| emit("pagination", { page: 1, limit: val });
| };
|
| const handleCurrentChange = val => {
| emit("pagination", { page: val, limit: props.limit });
| };
| </script>
|
| <style scoped>
| .pagination-container {
| display: flex;
| justify-content: flex-end;
| padding-top: 12px;
| }
| </style>
|
|