From f90c94f20b5f11d3b3ce0164d619c0112d5158c9 Mon Sep 17 00:00:00 2001 From: Mila <Mila@pollex.com.tw> Date: 星期四, 20 一月 2022 18:23:56 +0800 Subject: [PATCH] update: TODO#133100 顧問端:header增加顧問頭像圖示 --- PAMapp/pages/myAppointmentList/contactedList.vue | 86 ++++++++++++++++++++++++++++++++++-------- 1 files changed, 69 insertions(+), 17 deletions(-) diff --git a/PAMapp/pages/myAppointmentList/contactedList.vue b/PAMapp/pages/myAppointmentList/contactedList.vue index 79e7fbf..5c4cd59 100644 --- a/PAMapp/pages/myAppointmentList/contactedList.vue +++ b/PAMapp/pages/myAppointmentList/contactedList.vue @@ -14,47 +14,91 @@ ></i> </el-input> + <div class="sort-indicator mb-10 text--primary text--underline cursor--pointer" @click="changeSortType"> + {{ this.sortType === 'DESC' ? '�->���' : '���->�' }} + </div> + <ClientList :clients="pageList" :title="'contactedList'" ></ClientList> <UiPagination + v-if="togglePagination" :totalList="filterList" + :currentPage="currentPage" @changePage="changePage" ></UiPagination> </div> </template> <script lang="ts"> -import { Vue, Component, Watch, State } from 'nuxt-property-decorator'; +import { Vue, Component, Watch, namespace } from 'nuxt-property-decorator'; -import { ClientInfo } from '~/shared/models/client.model'; +import { Appointment } from '~/shared/models/appointment.model'; + + +const appointmentStore = namespace('appointment.store'); +const localStorage = namespace('localStorage'); @Component export default class ClientContactedList extends Vue { - @State('myAppointmentList') - myAppointmentList!: ClientInfo[]; + @appointmentStore.State('myAppointmentList') + myAppointmentList!: Appointment[]; - @Watch('myAppointmentList') - onMyAppointmentListChange() { - this.contactedList = (this.myAppointmentList || []) - .filter(item => item.communicateStatus === 'contacted') - .map((item) => ({...item, sortTime: new Date(item.contactTime)})) - .sort((prevItem, nextItem) => +nextItem.sortTime - +prevItem.sortTime); - this.filterList = this.contactedList; - } + @localStorage.Getter + currentAppointmentIdFromMsg!: string; - contactedList: ClientInfo[] = []; - filterList : ClientInfo[] = []; - keyWord : string = ''; - pageList : ClientInfo[] = []; + contactedList : Appointment[] = []; + currentPage : number = 1; + filterList : Appointment[] = []; + keyWord : string = ''; + pageList : Appointment[] = []; + sortType : 'ASC' | 'DESC' = 'DESC'; + togglePagination: boolean = true; ////////////////////////////////////////////////////////////////////// mounted() { this.onMyAppointmentListChange(); + } + + ////////////////////////////////////////////////////////////////////// + + @Watch('myAppointmentList') + onMyAppointmentListChange() { + this.setContactedList(); + } + + @Watch('sortType') + onSortTypeChange() { + this.togglePagination = false; + setTimeout(() => { + this.togglePagination = true; + this.currentPage = 1; + this.setContactedList(); + }, 0) + } + + private setContactedList(): void { + this.contactedList = (this.myAppointmentList || []) + .filter(item => item.communicateStatus === 'contacted') + .map((item) => ({...item, sortTime: new Date(item.lastModifiedDate)})) + .sort((prevItem, nextItem) => { + return this.sortType === 'DESC' ? +nextItem.sortTime - +prevItem.sortTime : +prevItem.sortTime - +nextItem.sortTime + }); + this.filterList = this.contactedList; + + this.getCurrentPage(); + } + + private getCurrentPage(): void { + const currentIndex = this.filterList.findIndex(item => item.id === +this.currentAppointmentIdFromMsg); + const pageSize = 5; + if (currentIndex > -1) { + this.currentPage = Math.ceil((currentIndex + 1) / pageSize); + } } ////////////////////////////////////////////////////////////////////// @@ -65,9 +109,17 @@ }) } - changePage(pageList: ClientInfo[]): void { + changePage(pageList: Appointment[]): void { this.pageList = pageList; } + changeSortType(): void { + if (this.sortType === 'DESC') { + this.sortType = 'ASC'; + } else { + this.sortType = 'DESC'; + } + } + } </script> -- Gitblit v1.8.0