pagination.vue 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <template>
  2. <div class="pagination-box">
  3. <el-pagination
  4. hide-on-single-page
  5. @current-change="handleCurrentChange"
  6. :current-page="currentPage"
  7. :page-size="pageSize"
  8. layout="total, prev, pager, next"
  9. :total="total">
  10. </el-pagination>
  11. </div>
  12. </template>
  13. <script>
  14. export default {
  15. components: {},
  16. props: {
  17. total: { type: Number, default: 0 },
  18. pageSize: { type: Number, default: 10 }
  19. },
  20. data() {
  21. return {
  22. currentPage: 1
  23. };
  24. },
  25. computed: {},
  26. mounted() {},
  27. methods: {
  28. handleCurrentChange(e) {
  29. this.currentPage = e > 0 ? e - 1 : 0;
  30. this.$emit('query', { paging: { page: this.currentPage, size: this.pageSize } });
  31. },
  32. resetPage(e) {
  33. if (e == -1) {
  34. this.currentPage = 0;
  35. } else {
  36. this.currentPage = Math.ceil(this.total / this.pageSize);
  37. }
  38. this.$emit('query', { page: this.currentPage, size: this.pageSize });
  39. }
  40. }
  41. };
  42. </script>
  43. <style lang="scss" scoped>
  44. .pagination-box {
  45. margin-top: 10px;
  46. }
  47. </style>