index.vue 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <template>
  2. <div class="d-flex justify-center align-center pa-5">
  3. <v-pagination
  4. v-model="currentPage"
  5. :length="pageLength"
  6. @update:modelValue="handleCurrentChange"
  7. v-bind="$attrs"
  8. :total-visible="props.totalVisible"
  9. active-color="primary"
  10. color="primary"
  11. size="small"
  12. ></v-pagination>
  13. <!-- <span style="color: #666;">共{{ props.total }}条数据</span>
  14. <div class="search px-3">
  15. <v-text-field
  16. v-model="currentJump"
  17. type="number"
  18. hide-details
  19. variant="outlined"
  20. density="compact"
  21. label=""
  22. placeholder=""
  23. hide-spin-buttons
  24. ></v-text-field>
  25. </div>
  26. <div class="">
  27. <v-btn color="primary" rounded class="half-button" @click="handleCurrentJump">跳转</v-btn>
  28. </div> -->
  29. </div>
  30. </template>
  31. <script setup>
  32. import { computed, watch, ref, defineEmits } from 'vue'
  33. defineOptions({ name: 'components-ct-pagnation' })
  34. const props = defineProps({
  35. total: {
  36. type: [String, Number],
  37. default: 0
  38. },
  39. page: {
  40. type: Number,
  41. default: 1
  42. },
  43. limit: {
  44. type: Number,
  45. default: 10
  46. },
  47. pageSizes: {
  48. type: Array,
  49. default: () => [5, 10, 15, 20]
  50. },
  51. layout: {
  52. type: String,
  53. default: 'total, prev, pager, next, jumper'
  54. },
  55. autoScroll: {
  56. type: Boolean,
  57. default: true
  58. },
  59. hidden: {
  60. type: Boolean,
  61. default: false
  62. },
  63. totalVisible: {
  64. type: Number,
  65. default: 7
  66. }
  67. })
  68. const emit = defineEmits(['handleChange'])
  69. const currentPage = ref(1)
  70. // const currentJump = ref(null)
  71. currentPage.value = props.page
  72. watch(() => props.page, (newVal) => {
  73. currentPage.value = newVal
  74. })
  75. const pageLength = computed(() => {
  76. return Math.ceil(props.total / props.limit)
  77. })
  78. const handleCurrentChange = () => {
  79. emit('handleChange', currentPage.value)
  80. }
  81. // const handleCurrentJump = () => {
  82. // if (currentJump.value > pageLength.value) currentJump.value = pageLength.value
  83. // if (currentJump.value < 1) currentJump.value = 1
  84. // currentPage.value = +currentJump.value
  85. // emit('handleChange', currentPage.value)
  86. // }
  87. </script>
  88. <style lang="scss" scoped>
  89. .search {
  90. width: 80px;
  91. height: 50px;
  92. display: flex;
  93. align-items: center;
  94. }
  95. </style>