From a3716f72066d25d745f4d5103ff23a553c3e102b Mon Sep 17 00:00:00 2001 From: wayne <wayne8692wayne8692@gmail.com> Date: 星期四, 17 二月 2022 11:41:19 +0800 Subject: [PATCH] Merge branch 'sit' into uat --- PAMapp/pages/myConsultantList.vue | 100 ++++++++++++++++++++++++++++++++++---------------- 1 files changed, 68 insertions(+), 32 deletions(-) diff --git a/PAMapp/pages/myConsultantList.vue b/PAMapp/pages/myConsultantList.vue index 25fea68..33caf53 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> @@ -21,30 +21,33 @@ :contactedList="contactedList" :consultantList="consultantList" ></NuxtChild> + </div> </template> <script lang='ts'> import { Vue, Component, Watch, State, Action } from 'nuxt-property-decorator'; -import { Consultant } from '~/assets/ts/models/consultant.model'; + +import authService from '~/shared/services/auth.service'; +import { Consultant, ConsultantWithAppointmentId } from '~/shared/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; + @State('myConsultantList') + myConsultantList!: Consultant[]; - @Watch('myConsultantList') - onMyConsultantListChange() { - this.filterContactedList(); - } - + @Action + storeConsultantList!: any; + + activeTabName : string = 'consultantList'; + consultantList: Consultant[] = []; + contactedList : ConsultantWithAppointmentId[] = []; + + ////////////////////////////////////////////////////////////////////// + beforeRouteEnter(to: any, from: any, next: any) { - next(vm => { + next((vm: any) => { if (to.name === 'myConsultantList') { vm.$router.push('myConsultantList/consultantList'); return; @@ -53,29 +56,62 @@ } 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) { + ////////////////////////////////////////////////////////////////////// + + @Watch('myConsultantList') + onMyConsultantListChange() { + 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 ); + + if (authService.isUserLogin()) { + 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, + appointmentLastModifiedDate: appointment.lastModifiedDate + }; + this.contactedList.push(consultantWithAppointmentId); + }) + }); + + this.contactedList = this.contactedList + .filter((appointment) => appointment['appointmentStatus'] !== 'reserved') + .map((appointment) => ({ ...appointment, sortTime: new Date(appointment.appointmentLastModifiedDate)})) + .sort((preAppointment, nextAppointment) => +nextAppointment.sortTime - +preAppointment.sortTime); + } + + } + + ////////////////////////////////////////////////////////////////////// + + clickTab(path: string) { this.activeTabName = path; this.$router.push('/myConsultantList/' + this.activeTabName) } - filterContactedList() { - this.consultantList = (this.myConsultantList || []) - .filter(item => item.contactStatus !== 'contacted') - .map((item) => ({ ...item, formatDate: new Date(item.updateTime)})) - .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); - } - } -</script> \ No newline at end of file +</script> + -- Gitblit v1.8.0