From 4310ebf9bccd89cb077f6adc1b6bcc7f18dc3c68 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期三, 08 十二月 2021 16:56:43 +0800
Subject: [PATCH] fixed: method spelling error

---
 PAMapp/components/Ui/UiPagination.vue |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/PAMapp/components/Ui/UiPagination.vue b/PAMapp/components/Ui/UiPagination.vue
index b2128a7..40f2709 100644
--- a/PAMapp/components/Ui/UiPagination.vue
+++ b/PAMapp/components/Ui/UiPagination.vue
@@ -1,43 +1,50 @@
 <template>
     <el-pagination
+        :current-page.sync="currentPage"
         layout="prev, pager, next"
         :total="totalList.length"
         :page-size="pageSize"
         @current-change="handleCurrentChange"
+        class="mt-10"
     >
     </el-pagination>
 </template>
 
 <script lang="ts">
 import { Vue, Component, Prop, Emit, Watch } from 'nuxt-property-decorator';
-import { Agents } from '~/plugins/api/home';
+import { Consultant } from '~/assets/ts/models/consultant.model';
 
 @Component
 export default class UiPagination extends Vue {
-    @Prop() totalList!: Agents[];
-    pageSize = 5;
+    @Prop() totalList!: Consultant[];
+    @Prop({default: 5}) pageSize!: number;
     currentPage = 1;
-    pageList: Agents[] = [];
+    pageList: Consultant[] = [];
 
     mounted() {
         this.handleCurrentChange(this.currentPage);
     }
 
-    @Emit('changePage') chagnePage(): Agents[] {
+    @Emit('changePage') changePage(): Consultant[] {
         return this.pageList
     }
 
     handleCurrentChange(currentPage: number) {
+
+        if (this.totalList.length <= this.pageSize && currentPage !== 1) {
+            currentPage -= 1;
+        }
+
         if (this.totalList) {
             this.pageList = this.totalList.slice(this.pageSize * currentPage - this.pageSize, this.pageSize * currentPage)
-            this.chagnePage();
+            this.changePage();
         }
     }
 
-    @Watch('totalList') watchtotalList(newValue: Agents[]) {
+    @Watch('totalList') watchTotalList(newValue: Consultant[]) {
         if (newValue) {
             this.handleCurrentChange(this.currentPage);
         }
     }
 }
-</script>
\ No newline at end of file
+</script>

--
Gitblit v1.8.0