From 6bbef91c402eaa58b8a4d8f11c466a39802ca0ca Mon Sep 17 00:00:00 2001
From: 劉鈞霖 <benson@gmail.com>
Date: 星期二, 28 十二月 2021 14:50:13 +0800
Subject: [PATCH] [ Ref ] : 重構 共用資料夾 相關元件

---
 PAMapp/components/Ui/UiPagination.vue |   31 +++++++++++++++++++++----------
 1 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/PAMapp/components/Ui/UiPagination.vue b/PAMapp/components/Ui/UiPagination.vue
index abb27a9..80f1075 100644
--- a/PAMapp/components/Ui/UiPagination.vue
+++ b/PAMapp/components/Ui/UiPagination.vue
@@ -16,18 +16,35 @@
 
 @Component
 export default class UiPagination extends Vue {
-    @Prop() totalList!: Consultant[];
+    @Prop()
+    totalList!: Consultant[];
+
     @Prop({default: 5}) pageSize!: number;
     currentPage = 1;
+
     pageList: Consultant[] = [];
+
+    //////////////////////////////////////////////////////////////////
+
+    @Emit('changePage')
+    changePage(): Consultant[] {
+        return this.pageList
+    }
+
+    @Watch('totalList')
+    watchTotalList(newValue: Consultant[]) {
+        if (newValue) {
+            this.handleCurrentChange(this.currentPage);
+        }
+    }
+
+    //////////////////////////////////////////////////////////////////
 
     mounted() {
         this.handleCurrentChange(this.currentPage);
     }
 
-    @Emit('changePage') changePage(): Consultant[] {
-        return this.pageList
-    }
+    //////////////////////////////////////////////////////////////////
 
     handleCurrentChange(currentPage: number) {
 
@@ -38,12 +55,6 @@
         if (this.totalList) {
             this.pageList = this.totalList.slice(this.pageSize * currentPage - this.pageSize, this.pageSize * currentPage)
             this.changePage();
-        }
-    }
-
-    @Watch('totalList') watchTotalList(newValue: Consultant[]) {
-        if (newValue) {
-            this.handleCurrentChange(this.currentPage);
         }
     }
 }

--
Gitblit v1.8.0