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
65
66
67
68
69
70
71
72
73
| <template>
| <el-scrollbar>
| <!-- <div v-for="(item, index) in data" :key="index">
|
| </div> -->
| <slot></slot>
| </el-scrollbar>
| <el-pagination
| v-if="pageShow"
| ref="paginationRef"
| class="el-pagination"
| v-model:current-page="currentPage"
| v-model:page-size="pageSize"
| :page-sizes="pageSizes"
| :background="true"
| layout="total, sizes, prev, pager, next, jumper"
| :total="total"
| />
| </template>
|
| <script>
| import { usePagination } from '@/composables/pagination';
|
| export default {
| setup() {
| // 分页逻辑
| const { currentPage, pageSize, addPageEvent } = usePagination();
| return { currentPage, pageSize, addPageEvent };
| },
| props: {
| data: {
| type: Array,
| default: () => {
| return [];
| }
| },
| // 是否显示分页
| pageShow: {
| type: Boolean,
| default: true
| },
| // 每页可选数量
| pageSizes: {
| type: Array,
| default: () => {
| return [10, 20, 50, 100];
| }
| },
| // 总数据量
| total: {
| type: Number,
| default: 0
| }
| },
| emits: ['pageChange'],
| methods: {
| search() {
| this.$emit('pageChange', this.currentPage, this.pageSize);
| }
| },
| mounted() {
| this.addPageEvent(this.search);
| }
| };
| </script>
| <style scoped>
| .el-pagination {
| background-color: var(--el-color-white);
| padding-top: 20px;
| border-top: 1px solid rgba(0, 0, 0, 0.096);
| /* margin-top: 2px; */
| }
| </style>
|
|