From 47571868ecd073bdd76f238ed6a2aa86760f6c92 Mon Sep 17 00:00:00 2001 From: HelenHuang <LinHuang@pollex.com.tw> Date: 星期一, 15 十一月 2021 17:41:14 +0800 Subject: [PATCH] [update]:嚴選顧問跑版修正 --- PAMapp/components/Ui/UiPagination.vue | 19 +++++++++++++------ 1 files changed, 13 insertions(+), 6 deletions(-) diff --git a/PAMapp/components/Ui/UiPagination.vue b/PAMapp/components/Ui/UiPagination.vue index b2128a7..4e795bf 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[]; - pageSize = 5; + @Prop() totalList!: Consultants[]; + @Prop({default: 5}) pageSize!: number; 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