| | |
| | | @State('myConsultantList') |
| | | myConsultantList!: Consultant[]; |
| | | |
| | | @State('myAppointmentGroupByConsultantList') |
| | | myAppointmentGroupByConsultantList!: ConsultantWithAppointmentId[]; |
| | | |
| | | @Action |
| | | storeConsultantList!: any; |
| | | |
| | |
| | | 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 === 'picked' || item.contactStatus === 'reserved') |
| | | .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 = { |
| | |
| | | appointmentDate: appointment.appointmentDate, |
| | | appointmentScore: appointment.satisfactionScore, |
| | | appointmentStatus: appointment.communicateStatus, |
| | | appointmentLastModifiedDate: appointment.lastModifiedDate |
| | | }; |
| | | this.contactedList.push(consultantWithAppointmentId); |
| | | }) |
| | | }); |
| | | |
| | | this.contactedList = this.contactedList |
| | | .filter((appointment) => appointment['appointmentStatus'] === 'contacted' || appointment['appointmentStatus'] === 'closed' || appointment['appointmentStatus'] === 'done') |
| | | .map((appointment) => ({ ...appointment, sortTime: new Date(appointment.appointmentDate)})) |
| | | .filter((appointment) => appointment['appointmentStatus'] !== 'reserved') |
| | | .map((appointment) => ({ ...appointment, sortTime: new Date(appointment.appointmentLastModifiedDate)})) |
| | | .sort((preAppointment, nextAppointment) => +nextAppointment.sortTime - +preAppointment.sortTime); |
| | | } |
| | | |
| | | } |
| | | |
| | | ////////////////////////////////////////////////////////////////////// |