From 83757a31e7b1593d2cce267061722c259c0d5800 Mon Sep 17 00:00:00 2001 From: Tomas <tomasysh@gmail.com> Date: 星期四, 24 三月 2022 23:20:40 +0800 Subject: [PATCH] update: [客戶端] 我的顧問清單 refactoring (已聯絡清單使用新 api) --- PAMapp/pages/myConsultantList.vue | 20 +++++++++++++++----- 1 files changed, 15 insertions(+), 5 deletions(-) diff --git a/PAMapp/pages/myConsultantList.vue b/PAMapp/pages/myConsultantList.vue index afa5d20..6914ee7 100644 --- a/PAMapp/pages/myConsultantList.vue +++ b/PAMapp/pages/myConsultantList.vue @@ -37,6 +37,9 @@ @State('myConsultantList') myConsultantList!: Consultant[]; + @State('myAppointmentGroupByConsultantList') + myAppointmentGroupByConsultantList!: ConsultantWithAppointmentId[]; + @Action storeConsultantList!: any; @@ -70,18 +73,26 @@ this.setList(); } + @Watch('myAppointmentGroupByConsultantList') + omMyAppointmentGroupByConsultantList() { + this.setContactedList(); + } + private setList() { - // reset contacted list - this.contactedList = []; // format consultant list this.consultantList = (this.myConsultantList || []) .filter(item => item.contactStatus !== 'contacted') .map((item) => ({ ...item, formatDate: new Date(item.updateTime || item.createTime)})) .sort((preItem, nextItem) => +nextItem.formatDate - +preItem.formatDate ); + } + + private setContactedList() { + // reset contacted list + this.contactedList = []; if (authService.isUserLogin()) { - this.myConsultantList.filter((consultant) => consultant.appointments!.length) + this.myAppointmentGroupByConsultantList.filter((consultant) => consultant.appointments!.length) .forEach((consultant) => { consultant.appointments!.forEach((appointment) => { const consultantWithAppointmentId: ConsultantWithAppointmentId = { @@ -98,10 +109,9 @@ this.contactedList = this.contactedList .filter((appointment) => appointment['appointmentStatus'] !== 'reserved') - .map((appointment) => ({ ...appointment, sortTime: new Date(appointment.appointmentDate)})) + .map((appointment) => ({ ...appointment, sortTime: new Date(appointment.appointmentLastModifiedDate)})) .sort((preAppointment, nextAppointment) => +nextAppointment.sortTime - +preAppointment.sortTime); } - } ////////////////////////////////////////////////////////////////////// -- Gitblit v1.9.3