保誠-保戶業務員媒合平台
wayne
2022-01-26 6fa4bba623713c396432ba8b863846883d6a1906
PAMapp/pages/myConsultantList.vue
@@ -21,25 +21,28 @@
            :contactedList="contactedList"
            :consultantList="consultantList"
        ></NuxtChild>
    </div>
</template>
<script lang='ts'>
import { Vue, Component, Watch, State, Action } from 'nuxt-property-decorator';
import authService from '~/shared/services/auth.service';
import { Consultant, ConsultantWithAppointmentId } from '~/shared/models/consultant.model';
@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,24 +70,17 @@
        this.setList();
    }
    clickTab(path: string) {
        this.activeTabName = path;
        this.$router.push('/myConsultantList/' + this.activeTabName)
    }
    //////////////////////////////////////////////////////////////////////
    private setList() {
      // reset contacted list
        this.contactedList = [];
    // 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 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
      if (authService.isUserLogin()) {
        this.myConsultantList.filter((consultant) => consultant.appointments!.length)
          .forEach((consultant) => {
            consultant.appointments!.forEach((appointment) => {
@@ -100,11 +96,21 @@
          });
        this.contactedList = this.contactedList
          .filter((appointment) => appointment['appointmentStatus'] === 'contacted')
          .filter((appointment) => appointment['appointmentStatus'] !== 'reserved')
          .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)
    }
}
</script>