From 114a0d8e4d0bf9017e8b3e3b19065e2ce5ac9e80 Mon Sep 17 00:00:00 2001 From: Mila <Mila@pollex.com.tw> Date: 星期四, 16 十二月 2021 11:25:00 +0800 Subject: [PATCH] Merge branch 'master' of https://192.168.0.10:8443/r/pcalife/PAM --- PAMapp/pages/myConsultantList.vue | 83 ++++++++++++++++++++++++++++------------- 1 files changed, 57 insertions(+), 26 deletions(-) diff --git a/PAMapp/pages/myConsultantList.vue b/PAMapp/pages/myConsultantList.vue index cbe8844..7aa2014 100644 --- a/PAMapp/pages/myConsultantList.vue +++ b/PAMapp/pages/myConsultantList.vue @@ -4,14 +4,14 @@ <div class="cus-tab-item" :class="{'is-active': activeTabName === 'consultantList'}" - @click="tabClick('consultantList')" + @click="clickTab('consultantList')" >憿批�� <span class="p">({{consultantList.length}})</span> </div> <div class="cus-tab-item" :class="{'is-active': activeTabName === 'contactedList'}" - @click="tabClick('contactedList')" + @click="clickTab('contactedList')" >撌脰蝯� <span class="p">({{contactedList.length}})</span> </div> @@ -26,25 +26,30 @@ <script lang='ts'> import { Vue, Component, Watch, State, Action } from 'nuxt-property-decorator'; -import { Consultant } from '~/assets/ts/models/consultant.model'; +import { Consultant, ConsultantWithAppointmentId } from '~/assets/ts/models/consultant.model'; @Component export default class myConsultantList extends Vue { - activeTabName = 'consultantList'; - agents: Consultant[] = []; - contactedList: Consultant[] = []; - consultantList: Consultant[] = []; - @State('myConsultantList') myConsultantList!: Consultant[]; - @Action storeConsultantList!: any; + activeTabName = 'consultantList'; + consultantList: Consultant[] = []; + contactedList: ConsultantWithAppointmentId[] = []; + + @State('myConsultantList') + myConsultantList!: Consultant[]; + + @Action + storeConsultantList!: any; @Watch('myConsultantList') onMyConsultantListChange() { - this.filterContactedList(); + this.setList(); } - + + ////////////////////////////////////////////////////////////////////// + beforeRouteEnter(to: any, from: any, next: any) { - next(vm => { + next((vm: any) => { if (to.name === 'myConsultantList') { vm.$router.push('myConsultantList/consultantList'); return; @@ -53,29 +58,55 @@ } mounted() { - this.storeConsultantList(); + this.storeConsultantList(); - if (this.$route.name) { - this.activeTabName = this.$route.name.split('-')[1] - } + if (this.$route.name) { + this.activeTabName = this.$route.name.split('-')[1] + } } - tabClick(path: string) { + ////////////////////////////////////////////////////////////////////// + + clickTab(path: string) { this.activeTabName = path; this.$router.push('/myConsultantList/' + this.activeTabName) } + ////////////////////////////////////////////////////////////////////// - filterContactedList() { + 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 ); - this.contactedList = (this.myConsultantList || []) - .filter(item => item.contactStatus === 'contacted') - .map((item) => ({ ...item, formDate: new Date(item.updateTime)})) - .sort((preItem, nextItem) => +nextItem.formDate - +preItem.formDate); + .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) => { + const hasAppointment = consultant.appointments?.length; + if (hasAppointment) { + consultant.appointments!.forEach((appointment) => { + const consultantWithAppointmentId: ConsultantWithAppointmentId = { + ...consultant, + appointmentId: appointment.id, + appointmentDate: appointment.appointmentDate, + appointmentScore: appointment.satisfactionScore + }; + this.contactedList.push(consultantWithAppointmentId); + }) + } + }); + + this.contactedList = this.contactedList + .filter((appointment) => appointment['contactStatus'] === 'contacted') + .map((appointment) => ({ ...appointment, sortTime: new Date(appointment.appointmentDate)})) + .sort((preAppointment, nextAppointment) => +nextAppointment.sortTime - +preAppointment.sortTime); } } -</script> \ No newline at end of file +</script> + -- Gitblit v1.8.0