保誠-保戶業務員媒合平台
Tomas
2021-12-14 497f54b264eba626b77e79fec2ca6947ccae19e4
PAMapp/store/index.ts
@@ -1,12 +1,15 @@
import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators'
import { ClientInfo, getMyAppointmentList, getMyReviewLog } from '~/assets/ts/api/appointment';
import { getMyReviewLog } from '~/assets/ts/api/appointment';
import { recommend, AgentOfStrictQuery, addFavoriteConsultant, deleteConsultant, strictQuery } from '~/assets/ts/api/consultant';
import { getFavoriteFromStorage, setFavoriteToStorage } from '~/assets/ts/storageConsultant';
import  myConsultantService from '~/assets/ts/services/my-consultant.service';
import myConsultantService from '~/assets/ts/services/my-consultant.service';
import appointmentService from '~/assets/ts/services/appointment.service';
import { Consultant } from '~/assets/ts/models/consultant.model';
import { AppointmentLog } from '~/assets/ts/models/appointment.model';
import { ClientInfo } from '~/assets/ts/models/client.model';
@Module
export default class Store extends VuexModule {
    recommendList: Consultant[] = [];
@@ -14,6 +17,7 @@
    myConsultantList: Consultant[] = [];
    myAppointmentList: ClientInfo[] = [];
    myNewAppointmentSum: number = 0;
    myAppointmentReviewLogList: AppointmentLog[] = [];
@@ -21,27 +25,38 @@
        return this.context.getters['localStorage/isUserLogin'];
    }
    @Mutation updateRecommend(data: Consultant[]) {
    @Mutation
    updateRecommend(data: Consultant[]) {
        this.recommendList = data;
    }
    @Mutation updateConsultantList(data: Consultant[]) {
    @Mutation
    updateConsultantList(data: Consultant[]) {
        this.myConsultantList = data;
    }
    @Mutation updateStrictQueryList(data: AgentOfStrictQuery[]) {
    @Mutation
    updateStrictQueryList(data: AgentOfStrictQuery[]) {
        this.strictQueryList = data;
    }
    @Mutation updateMyAppointmentList(data: ClientInfo[]) {
    @Mutation
    updateMyAppointmentList(data: ClientInfo[]) {
        this.myAppointmentList = data;
    }
    @Mutation updateMyAppointmentReviewLog(data: AppointmentLog[]) {
    @Mutation
    updateMyNewAppointmentSum(newAppointmentSum: number) {
      this.myNewAppointmentSum = newAppointmentSum;
    }
    @Mutation
    updateMyAppointmentReviewLog(data: AppointmentLog[]) {
        this.myAppointmentReviewLogList = data;
    }
    @Action storeRecommendList() {
    @Action
    storeRecommendList() {
        recommend().then(data => {
            this.context.commit('updateRecommend', data)
        })
@@ -109,10 +124,11 @@
    }
    @Action
    async storeMyAppointmentList() {
        return await getMyAppointmentList().then((data) => {
    storeMyAppointmentList(): void {
      appointmentService.getMyAppointmentList().then((data) => {
            const newAppointmentSum = data.filter(item => !item.consultantViewTime || item.consultantViewTime === null).length;
            this.context.commit('updateMyAppointmentList', data);
            return data.filter(item => !item.consultantViewTime || item.consultantViewTime === null).length
            this.context.commit('updateMyNewAppointmentSum', newAppointmentSum);
        });
    }
@@ -130,7 +146,8 @@
        });
    }
    @Action updateMyAppointment(myAppointment: ClientInfo) {
    @Action
    updateMyAppointment(myAppointment: ClientInfo) {
        const data = this.myAppointmentList.filter(item => item.id !== myAppointment.id);
        data.unshift(myAppointment);
        this.context.commit('updateMyAppointmentList', data)