You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

158 lines
3.4 KiB

<template>
<div class="box">
<el-pagination
background
:current-page.sync="currentPage"
:page-size.sync="pageSize"
layout="prev, pager, next,jumper"
:page-sizes="pageSizes"
:pager-count="pagerCount"
:total="total"
@size-change="handleSizeChange"
@current-change="handleCurrentChange"
small
>
</el-pagination>
</div>
</template>
<script>
import { scrollTo } from "@/utils/scroll-to";
export default {
name: "Pagination",
props: {
total: {
type: Number,
default: 0,
},
page: {
type: Number,
default: 1,
},
limit: {
type: Number,
default: 20,
},
pageSizes: {
type: Array,
default() {
return [10, 20, 30, 50];
},
},
// 移动端页码按钮的数量端默认值5
pagerCount: {
type: Number,
default: document.body.clientWidth < 992 ? 5 : 7,
},
layout: {
type: String,
default: "total, sizes, prev, pager, next, jumper",
},
background: {
type: Boolean,
default: true,
},
autoScroll: {
type: Boolean,
default: true,
},
hidden: {
type: Boolean,
default: false,
},
},
data() {
return {};
},
computed: {
currentPage: {
get() {
return this.page;
},
set(val) {
this.$emit("update:page", val);
},
},
pageSize: {
get() {
return this.limit;
},
set(val) {
this.$emit("update:limit", val);
},
},
},
methods: {
handleSizeChange(val) {
if (this.currentPage * val > this.total) {
this.currentPage = 1;
}
this.$emit("pagination", { page: this.currentPage, limit: val });
if (this.autoScroll) {
scrollTo(0, 800);
}
},
handleCurrentChange(val) {
this.$emit("pagination", { page: val, limit: this.pageSize });
if (this.autoScroll) {
scrollTo(0, 800);
}
},
},
};
</script>
<style scoped lang='scss'>
::v-deep .el-pagination {
width: 100%;
display: flex;
justify-content: end;
padding: 8px 5px;
box-sizing: border-box;
overflow-y: auto;
}
.box {
background-color: transparent !important;
}
::v-deep .el-pagination.is-background .btn-prev {
background-color: transparent !important;
border: 1px solid #123864;
color: #579acf;
}
::v-deep .el-pagination.is-background .btn-next {
background-color: transparent !important;
border: 1px solid #123864;
color: #579acf;
}
::v-deep .el-pagination .el-pager li {
background-color: transparent !important;
border: 1px solid #123864;
color: #579acf;
}
// ::v-deep .el-pagination.is-background.el-pager li:not(.disabled).active {
// background: rgba(20, 131, 242, 0.2) !important;
// border: 1px solid #1483f2;
// border-radius: 4px;
// color: #fff;
// }
::v-deep .el-pagination__jump {
margin: 0;
color: #2668d6;
.el-input__inner {
background-color: transparent !important;
border: 1px solid #123864;
color: #2668d6;
}
}
::v-deep .el-pager li.active {
background: rgba(20, 131, 242, 0.52) !important;
border: 1px solid #1483f2;
border-radius: 4px;
}
// ::v-deep .el-pagination__total {
// color: #2668d6;
// }
</style>