From ae4db5435180c44b37f521c463b17f2023ac1d8c Mon Sep 17 00:00:00 2001 From: wayne <wayne8692wayne8692@gmail.com> Date: 星期五, 18 二月 2022 09:25:50 +0800 Subject: [PATCH] [update] 若顧問停用時,將無法登入 (文案待確認) --- PAMapp/pages/myAppointmentList/appointmentList.vue | 72 ++++++++++++++++++++++++----------- 1 files changed, 49 insertions(+), 23 deletions(-) diff --git a/PAMapp/pages/myAppointmentList/appointmentList.vue b/PAMapp/pages/myAppointmentList/appointmentList.vue index 088a180..e623916 100644 --- a/PAMapp/pages/myAppointmentList/appointmentList.vue +++ b/PAMapp/pages/myAppointmentList/appointmentList.vue @@ -5,9 +5,9 @@ placeholder="隢撓���摮�" class="mb-30 pam-clientReserved-input" v-model="keyWord" - @keyup.enter.native="search" + @input="search" > - <i slot="suffix" class="icon-search search cursor--pointer" @click="search"></i> + <i slot="suffix" class="icon-search search cursor--pointer"></i> </el-input> <ClientList @@ -17,26 +17,40 @@ <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, Watch, namespace } from 'nuxt-property-decorator'; -import { ClientInfo } from '~/assets/ts/models/client.model'; +import { Appointment } from '~/shared/models/appointment.model'; +import { ContactStatus } from '~/shared/models/enum/contact-status'; + +const localStorage = namespace('localStorage'); +const appointmentStore = namespace('appointment.store'); @Component export default class ClientReservedList extends Vue { - @State('myAppointmentList') - myAppointmentList!: ClientInfo[]; + @appointmentStore.State('myAppointmentList') + myAppointmentList!: Appointment[]; - appointmentList: ClientInfo[] = []; - pageList: ClientInfo[] = []; - keyWord: string = ''; - filterList: ClientInfo[] = []; + @localStorage.Getter + currentAppointmentIdFromMsg!: string; + + @appointmentStore.Action + getAppointmentDetail!: () => Promise<Appointment>; + + appointmentList: Appointment[] = []; + currentPage : number = 1; + filterList : Appointment[] = []; + keyWord : string = ''; + pageList : Appointment[] = []; + + contactStatus = ContactStatus; ////////////////////////////////////////////////////////////////////// @@ -48,27 +62,39 @@ @Watch('myAppointmentList') onMyAppointmentListChange(): void { - const unreadList = this.myAppointmentList - .filter((item) => item.communicateStatus !== 'contacted' && !item.consultantReadTime) - .map((item) => ({ ...item, sortTime: new Date(item.appointmentDate)})) + this.appointmentList = this.myAppointmentList + .filter(item => item.communicateStatus === this.contactStatus.RESERVED) + .map((item) => ({ ...item, sortTime: new Date(item.lastModifiedDate)})) .sort((preItem, nextItem) => +nextItem.sortTime - +preItem.sortTime); - const readList = this.myAppointmentList - .filter(item => item.communicateStatus !== 'contacted' && item.consultantReadTime) - .map((item) => ({ ...item, sortTime: new Date(item.consultantReadTime)})) - .sort((preItem, nextItem) => +nextItem.sortTime - +preItem.sortTime); - - this.appointmentList = unreadList.concat(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) - }) + if (this.keyWord) { + this.filterList = this.appointmentList.filter(item => { + return item.name.match(this.keyWord) || item.requirement.match(this.keyWord); + }) + } else { + this.filterList = this.appointmentList; + } + } - changePage(pageList: ClientInfo[]): void { + changePage(pageList: Appointment[]): void { this.pageList = pageList; } -- Gitblit v1.8.0