From 52ad7e79ec7cfbd8163172b4934981e92a4d39bd Mon Sep 17 00:00:00 2001 From: Ls <2391972606@qq.com> Date: Wed, 29 Apr 2026 14:19:25 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=86=E9=A1=B5=20=E7=BB=84=E4=BB=B6=20?= =?UTF-8?q?=E6=8C=89=E9=92=AE=20=E7=BB=84=E4=BB=B6=20=E5=BF=AB=E9=80=9F?= =?UTF-8?q?=E5=9B=9E=E5=88=B0=20=E9=A1=B6=E9=83=A8=20=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Web/src/components/Abutton.vue | 16 +++++- Web/src/components/Pagination.vue | 88 +++++++++++++------------------ Web/src/extends/PageExtend.ts | 24 +++++---- Web/src/pages/customer/index.vue | 15 ++---- 4 files changed, 71 insertions(+), 72 deletions(-) diff --git a/Web/src/components/Abutton.vue b/Web/src/components/Abutton.vue index fbb06c8..224355b 100644 --- a/Web/src/components/Abutton.vue +++ b/Web/src/components/Abutton.vue @@ -1,5 +1,5 @@ \ No newline at end of file + + + + diff --git a/Web/src/components/Pagination.vue b/Web/src/components/Pagination.vue index 8845e01..133b617 100644 --- a/Web/src/components/Pagination.vue +++ b/Web/src/components/Pagination.vue @@ -2,17 +2,17 @@ @@ -28,75 +28,61 @@ const props = withDefaults(defineProps(), { totalPages: 1, }); -const emit = defineEmits<{ - (e: 'pageChange', page: number): void; -}>(); +let currentPage = ref(props.currentPage) +let totalPages = ref(props.totalPages) -const inputPage = ref(props.currentPage); +const emit = defineEmits(['pageChange']) -watch(() => props.currentPage, (newVal: number) => { - inputPage.value = newVal; -}); -const goFirst = (): void => { - if (props.currentPage > 1) { - emit('pageChange', 1); +const changePage = (type: any) => { + if (type == 'input' && currentPage.value < 1) { + currentPage.value = 1 + } + if (type == 'input' && currentPage.value > totalPages.value) { + currentPage.value = totalPages.value } -}; -const goPrev = (): void => { - if (props.currentPage > 1) { - emit('pageChange', props.currentPage - 1); + if (type == 'prev' && currentPage.value == 1) { + return + } + if (type == 'next' && currentPage.value == totalPages.value) { + return } -}; -const goNext = (): void => { - if (props.currentPage < props.totalPages) { - emit('pageChange', props.currentPage + 1); - } -}; -const goLast = (): void => { - if (props.currentPage < props.totalPages) { - emit('pageChange', props.totalPages); + if (type == 'first') { + currentPage.value = 1 + } else if (type == 'prev') { + currentPage.value-- + } else if (type == 'next') { + currentPage.value++ + } else if (type == 'last') { + currentPage.value = totalPages.value } -}; + emit('pageChange', currentPage.value) +} + -const goToPage = (): void => { - let page: number = inputPage.value; - if (isNaN(page) || page < 1) { - page = 1; - } else if (page > props.totalPages) { - page = props.totalPages; - } - if (page !== props.currentPage) { - emit('pageChange', page); - } - inputPage.value = page; -};