From 614f4074a7dfca7a5c887c54a10c649595e51358 Mon Sep 17 00:00:00 2001 From: Tomas <tomasysh@gmail.com> Date: 星期一, 27 十二月 2021 10:15:25 +0800 Subject: [PATCH] page refactor: my-consultant-list --- PAMapp/pages/myConsultantList.vue | 74 +++++++++++++++++++------------------ 1 files changed, 38 insertions(+), 36 deletions(-) diff --git a/PAMapp/pages/myConsultantList.vue b/PAMapp/pages/myConsultantList.vue index 687547c..ad2efeb 100644 --- a/PAMapp/pages/myConsultantList.vue +++ b/PAMapp/pages/myConsultantList.vue @@ -21,6 +21,7 @@ :contactedList="contactedList" :consultantList="consultantList" ></NuxtChild> + </div> </template> @@ -31,15 +32,15 @@ @Component export default class myConsultantList extends Vue { - activeTabName = 'consultantList'; - consultantList: Consultant[] = []; - contactedList: ConsultantWithAppointmentId[] = []; - @State('myConsultantList') myConsultantList!: Consultant[]; @Action storeConsultantList!: any; + + activeTabName : string = 'consultantList'; + consultantList: Consultant[] = []; + contactedList : ConsultantWithAppointmentId[] = []; ////////////////////////////////////////////////////////////////////// @@ -67,43 +68,44 @@ this.setList(); } + 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 ); + + // format contacted list + this.myConsultantList.filter((consultant) => consultant.appointments!.length) + .forEach((consultant) => { + consultant.appointments!.forEach((appointment) => { + const consultantWithAppointmentId: ConsultantWithAppointmentId = { + ...consultant, + appointmentId: appointment.id, + appointmentDate: appointment.appointmentDate, + appointmentScore: appointment.satisfactionScore, + appointmentStatus: appointment.communicateStatus, + }; + this.contactedList.push(consultantWithAppointmentId); + }) + }); + + this.contactedList = this.contactedList + .filter((appointment) => appointment['appointmentStatus'] === 'contacted') + .map((appointment) => ({ ...appointment, sortTime: new Date(appointment.appointmentDate)})) + .sort((preAppointment, nextAppointment) => +nextAppointment.sortTime - +preAppointment.sortTime); + } + + ////////////////////////////////////////////////////////////////////// + clickTab(path: string) { this.activeTabName = path; this.$router.push('/myConsultantList/' + this.activeTabName) } - ////////////////////////////////////////////////////////////////////// - - 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 ); - - // format contacted list - this.myConsultantList.filter((consultant) => consultant.appointments!.length) - .forEach((consultant) => { - consultant.appointments!.forEach((appointment) => { - const consultantWithAppointmentId: ConsultantWithAppointmentId = { - ...consultant, - appointmentId: appointment.id, - appointmentDate: appointment.appointmentDate, - appointmentScore: appointment.satisfactionScore, - appointmentStatus: appointment.communicateStatus, - }; - this.contactedList.push(consultantWithAppointmentId); - }) - }); - - this.contactedList = this.contactedList - .filter((appointment) => appointment['appointmentStatus'] === 'contacted') - .map((appointment) => ({ ...appointment, sortTime: new Date(appointment.appointmentDate)})) - .sort((preAppointment, nextAppointment) => +nextAppointment.sortTime - +preAppointment.sortTime); - } } </script> -- Gitblit v1.8.0