From 3e8c86ebf61df1ac5c9dfd96c7a829a2cd9ec4a2 Mon Sep 17 00:00:00 2001 From: Mila <Mila@pollex.com.tw> Date: 星期一, 15 十一月 2021 17:55:59 +0800 Subject: [PATCH] TODO#130023 客戶預約清單: 串接標註已聯絡 api --- PAMapp/components/Ui/UiPagination.vue | 17 ++++++++++++----- 1 files changed, 12 insertions(+), 5 deletions(-) diff --git a/PAMapp/components/Ui/UiPagination.vue b/PAMapp/components/Ui/UiPagination.vue index b2128a7..d157b14 100644 --- a/PAMapp/components/Ui/UiPagination.vue +++ b/PAMapp/components/Ui/UiPagination.vue @@ -1,40 +1,47 @@ <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 { Consultants } from '~/assets/ts/api/consultant'; @Component export default class UiPagination extends Vue { - @Prop() totalList!: Agents[]; + @Prop() totalList!: Consultants[]; pageSize = 5; currentPage = 1; - pageList: Agents[] = []; + pageList: Consultants[] = []; mounted() { this.handleCurrentChange(this.currentPage); } - @Emit('changePage') chagnePage(): Agents[] { + @Emit('changePage') chagnePage(): Consultants[] { 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(); } } - @Watch('totalList') watchtotalList(newValue: Agents[]) { + @Watch('totalList') watchtotalList(newValue: Consultants[]) { if (newValue) { this.handleCurrentChange(this.currentPage); } -- Gitblit v1.8.0