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 |   33 ++++++++++++++++++++++-----------
 1 files changed, 22 insertions(+), 11 deletions(-)

diff --git a/PAMapp/components/Ui/UiPagination.vue b/PAMapp/components/Ui/UiPagination.vue
index 40f2709..80f1075 100644
--- a/PAMapp/components/Ui/UiPagination.vue
+++ b/PAMapp/components/Ui/UiPagination.vue
@@ -12,22 +12,39 @@
 
 <script lang="ts">
 import { Vue, Component, Prop, Emit, Watch } from 'nuxt-property-decorator';
-import { Consultant } from '~/assets/ts/models/consultant.model';
+import { Consultant } from '~/shared/models/consultant.model';
 
 @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