| | |
| | | <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> |
| | |
| | | :contactedList="contactedList" |
| | | :consultantList="consultantList" |
| | | ></NuxtChild> |
| | | |
| | | </div> |
| | | </template> |
| | | |
| | | <script lang='ts'> |
| | | import { Vue, Component, Watch, State, Action } from 'nuxt-property-decorator'; |
| | | import { Consultants } 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: Consultants[] = []; |
| | | contactedList: Consultants[] = []; |
| | | consultantList: Consultants[] = []; |
| | | |
| | | @State('myConsultantList') myConsultantList!: Consultants[]; |
| | | @Action storeConsultantList!: any; |
| | | @State('myConsultantList') |
| | | myConsultantList!: Consultant[]; |
| | | |
| | | @State('myAppointmentGroupByConsultantList') |
| | | myAppointmentGroupByConsultantList!: ConsultantWithAppointmentId[]; |
| | | |
| | | @Action |
| | | storeConsultantList!: any; |
| | | |
| | | activeTabName : string = 'consultantList'; |
| | | consultantList: Consultant[] = []; |
| | | contactedList : ConsultantWithAppointmentId[] = []; |
| | | |
| | | ////////////////////////////////////////////////////////////////////// |
| | | |
| | | beforeRouteEnter(to: any, from: any, next: any) { |
| | | next((vm: any) => { |
| | | if (to.name === 'myConsultantList') { |
| | | vm.$router.push('myConsultantList/consultantList'); |
| | | return; |
| | | } |
| | | }) |
| | | } |
| | | |
| | | mounted() { |
| | | this.storeConsultantList(); |
| | | |
| | | if (this.$route.name) { |
| | | this.activeTabName = this.$route.name.split('-')[1] |
| | | } |
| | | } |
| | | |
| | | ////////////////////////////////////////////////////////////////////// |
| | | |
| | | @Watch('myConsultantList') |
| | | onMyConsultantListChange() { |
| | | this.filterContactedList(); |
| | | this.setList(); |
| | | } |
| | | |
| | | tabClick(path: string) { |
| | | @Watch('myAppointmentGroupByConsultantList') |
| | | omMyAppointmentGroupByConsultantList() { |
| | | this.setContactedList(); |
| | | } |
| | | |
| | | private setList() { |
| | | |
| | | // 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.myAppointmentGroupByConsultantList.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) |
| | | } |
| | | |
| | | mounted() { |
| | | this.storeConsultantList(); |
| | | |
| | | if (this.$route.name) { |
| | | this.activeTabName = this.$route.name.split('-')[1] |
| | | } |
| | | } |
| | | |
| | | filterContactedList() { |
| | | this.consultantList = (this.myConsultantList || []) |
| | | .filter(item => item.contactStatus !== 'contacted') |
| | | .sort((a, b) => a.updateTime > b.updateTime ? -1 : 1); |
| | | this.contactedList = (this.myConsultantList || []) |
| | | .filter(item => item.contactStatus === 'contacted') |
| | | .sort((a, b) => a.updateTime > b.updateTime ? -1 : 1); |
| | | } |
| | | |
| | | } |
| | | </script> |
| | | </script> |
| | | |