保誠-保戶業務員媒合平台
Tomas
2021-12-09 ac235850a9287dae6977c964213176fa7c86b140
PAMapp/store/index.ts
@@ -1,23 +1,27 @@
import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators'
import { allAppointmentsView, ClientInfo, getMyAppointmentList } from '~/assets/ts/api/appointment';
import { ClientInfo, getMyAppointmentList, getMyReviewLog, allAppointmentsView } from '~/assets/ts/api/appointment';
// import * as consultant from '~/assets/ts/api/consultant';
import { Consultants,recommend,AgentOfStrictQuery, getFavoriteConsultant, addFavoriteConsultant, deleteConsultant, strictQuery } from '~/assets/ts/api/consultant';
import { recommend, AgentOfStrictQuery, getFavoriteConsultant, addFavoriteConsultant, deleteConsultant, strictQuery } from '~/assets/ts/api/consultant';
import { Consultant } from '~/assets/ts/models/consultant.model';
import { isLogin } from '~/assets/ts/auth';
import { AppointmentLog } from '~/assets/ts/models/appointment.model';
import { getFavoriteFromStorage, setFavoriteToStorage } from '~/assets/ts/storageConsultant';
@Module
export default class Store extends VuexModule {
    recommendList: Consultants[] = [];
    recommendList: Consultant[] = [];
    strictQueryList: AgentOfStrictQuery[] = [];
    myConsultantList: Consultants[] = [];
    myConsultantList: Consultant[] = [];
    myAppointmentList: ClientInfo[] = [];
    @Mutation updateRecommend(data: Consultants[]) {
    myAppointmentReviewLogList: AppointmentLog[] = [];
    @Mutation updateRecommend(data: Consultant[]) {
        this.recommendList = data;
    }
    @Mutation updateConsultantList(data: Consultants[]) {
    @Mutation updateConsultantList(data: Consultant[]) {
        this.myConsultantList = data;
    }
@@ -27,6 +31,10 @@
    @Mutation updateMyAppointmentList(data: ClientInfo[]) {
        this.myAppointmentList = data;
    }
    @Mutation updateMyAppointmentReviewLog(data: AppointmentLog[]) {
        this.myAppointmentReviewLogList = data;
    }
    @Action storeRecommendList() {
@@ -42,7 +50,6 @@
            this.context.commit('updateConsultantList', localData)
            return;
        };
        if (localData?.length) {
            const agentNoList = localData.map(i => i.agentNo)
@@ -75,7 +82,7 @@
    }
    @Action
    async addToMyConsultantList(consultantToAdd: Consultants) {
    async addToMyConsultantList(consultantToAdd: Consultant) {
        if (consultantToAdd) {
            const found = this.myConsultantList.find(item => item.agentNo === consultantToAdd.agentNo);
            if (!found) {
@@ -104,6 +111,20 @@
        });
    }
    @Action
    storeMyAppointmentReviewLog() {
        getMyReviewLog().then((data) => {
            const dataWithLatestDate = data.map((item) => {
                return {
                    ...item,
                    compareDate: new Date(item.lastModifiedDate)
                }
            });
            const sortedData = dataWithLatestDate.sort((a, b) => +b.compareDate - +a.compareDate);
            this.context.commit('updateMyAppointmentReviewLog', sortedData);
        });
    }
    @Action updateMyAppointment(myAppointment: ClientInfo) {
        const data = this.myAppointmentList.filter(item => item.id !== myAppointment.id);
        data.unshift(myAppointment);
@@ -119,4 +140,4 @@
        });
    }
}
}