StdPagination.vue 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <script setup lang="ts">
  2. import type { Pagination } from '@/api/curd'
  3. const props = defineProps<{
  4. pagination: Pagination
  5. size?: 'default' | 'small'
  6. loading: boolean
  7. }>()
  8. const emit = defineEmits(['change', 'changePageSize', 'update:pagination'])
  9. function change(num: number, pageSize: number) {
  10. emit('change', num, pageSize)
  11. }
  12. const pageSize = computed({
  13. get() {
  14. return props.pagination.per_page
  15. },
  16. set(v) {
  17. emit('changePageSize', v)
  18. emit('update:pagination', { ...props.pagination, per_page: v })
  19. },
  20. })
  21. </script>
  22. <template>
  23. <div
  24. v-if="pagination.total > pagination.per_page"
  25. class="pagination-container"
  26. >
  27. <APagination
  28. v-model:pageSize="pageSize"
  29. :disabled="loading"
  30. :current="pagination.current_page"
  31. show-size-changer
  32. :size="size"
  33. :total="pagination.total"
  34. @change="change"
  35. />
  36. </div>
  37. </template>
  38. <style lang="less">
  39. .ant-pagination-total-text {
  40. @media (max-width: 450px) {
  41. display: block;
  42. }
  43. }
  44. </style>
  45. <style lang="less" scoped>
  46. .pagination-container {
  47. padding: 10px 0 0 0;
  48. display: flex;
  49. justify-content: right;
  50. @media (max-width: 450px) {
  51. justify-content: center;
  52. }
  53. }
  54. </style>