From a3716f72066d25d745f4d5103ff23a553c3e102b Mon Sep 17 00:00:00 2001
From: wayne <wayne8692wayne8692@gmail.com>
Date: 星期四, 17 二月 2022 11:41:19 +0800
Subject: [PATCH] Merge branch 'sit' into uat

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

diff --git a/PAMapp/components/Ui/UiPagination.vue b/PAMapp/components/Ui/UiPagination.vue
index 40f2709..2e13b2b 100644
--- a/PAMapp/components/Ui/UiPagination.vue
+++ b/PAMapp/components/Ui/UiPagination.vue
@@ -1,6 +1,6 @@
 <template>
     <el-pagination
-        :current-page.sync="currentPage"
+        :current-page.sync="syncCurrentPage"
         layout="prev, pager, next"
         :total="totalList.length"
         :page-size="pageSize"
@@ -11,23 +11,40 @@
 </template>
 
 <script lang="ts">
-import { Vue, Component, Prop, Emit, Watch } from 'nuxt-property-decorator';
-import { Consultant } from '~/assets/ts/models/consultant.model';
+import { Vue, Component, Prop, Emit, Watch, PropSync } from 'nuxt-property-decorator';
+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;
+    @PropSync('currentPage', {default: 1}) syncCurrentPage!: number;
+
     pageList: Consultant[] = [];
 
-    mounted() {
-        this.handleCurrentChange(this.currentPage);
-    }
+    //////////////////////////////////////////////////////////////////
 
-    @Emit('changePage') changePage(): Consultant[] {
+    @Emit('changePage')
+    changePage(): Consultant[] {
         return this.pageList
     }
+
+    @Watch('totalList')
+    watchTotalList(newValue: Consultant[]) {
+        if (newValue) {
+            this.handleCurrentChange(this.syncCurrentPage);
+        }
+    }
+
+    //////////////////////////////////////////////////////////////////
+
+    mounted() {
+        this.handleCurrentChange(this.syncCurrentPage);
+    }
+
+    //////////////////////////////////////////////////////////////////
 
     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