From 46da7429ca192bf6a947d79437e8076b94676a05 Mon Sep 17 00:00:00 2001 From: Tomas <tomasysh@gmail.com> Date: 星期四, 13 一月 2022 16:29:45 +0800 Subject: [PATCH] update: 刪除重複的 interface: clientInfo => appointment --- PAMapp/pages/myAppointmentList/appointmentList.vue | 40 ++++++++++++++++++++++++++++++---------- 1 files changed, 30 insertions(+), 10 deletions(-) diff --git a/PAMapp/pages/myAppointmentList/appointmentList.vue b/PAMapp/pages/myAppointmentList/appointmentList.vue index 617b4fb..57e3080 100644 --- a/PAMapp/pages/myAppointmentList/appointmentList.vue +++ b/PAMapp/pages/myAppointmentList/appointmentList.vue @@ -17,26 +17,33 @@ <UiPagination :totalList="filterList" + :currentPage="currentPage" @changePage="changePage" ></UiPagination> </div> </template> <script lang="ts"> -import { Vue, Component, State, Watch } from 'nuxt-property-decorator'; +import { Vue, Component, State, Watch, namespace } from 'nuxt-property-decorator'; -import { ClientInfo } from '~/shared/models/client.model'; +import { Appointment } from '~/shared/models/appointment.model'; + +const localStorage = namespace('localStorage'); @Component export default class ClientReservedList extends Vue { @State('myAppointmentList') - myAppointmentList!: ClientInfo[]; + myAppointmentList!: Appointment[]; - appointmentList: ClientInfo[] = []; - pageList: ClientInfo[] = []; - keyWord: string = ''; - filterList: ClientInfo[] = []; + @localStorage.Getter + currentAppointmentIdFromMsg!: string; + + appointmentList: Appointment[] = []; + filterList : Appointment[] = []; + keyWord : string = ''; + pageList : Appointment[] = []; + currentPage : number = 1; ////////////////////////////////////////////////////////////////////// @@ -57,23 +64,36 @@ .filter(item => item.communicateStatus !== 'contacted' && item.consultantViewTime); // TODO: 敺������� unreadList ��蝝啁溶�������隢�垢����靘������ createTime嚗�Tomas, 2021/12/16];疇 - const unreadList = tempViewList.filter((item) => !item.consultantReadTime); + const unreadList = tempViewList + .filter((item) => !item.consultantReadTime); const readList = tempViewList .filter((item) => item.consultantReadTime) .map((item) => ({ ...item, sortTime: new Date(item.consultantReadTime)})) - .sort((preItem, nextItem) => +nextItem - +preItem); + .sort((preItem, nextItem) => +nextItem.sortTime - +preItem.sortTime); this.appointmentList = [...unViewList, ...unreadList, ...readList]; this.filterList = this.appointmentList; + + this.getCurrentPage(); } + private getCurrentPage() { + const currentIndex = this.filterList + .findIndex(item => item.id === +this.currentAppointmentIdFromMsg); + const pageSize = 5; + if (currentIndex > -1) { + this.currentPage = Math.ceil((currentIndex + 1) / pageSize); + } + } + + ////////////////////////////////////////////////////////////////////// search(): void { this.filterList = this.appointmentList.filter(item => { return item.name.match(this.keyWord) || item.requirement.match(this.keyWord) }) } - changePage(pageList: ClientInfo[]): void { + changePage(pageList: Appointment[]): void { this.pageList = pageList; } -- Gitblit v1.8.0