保誠-保戶業務員媒合平台
Tomas
2021-12-22 f36e617e9e534a4b05f2029724d678bbd6c655b3
PAMapp/store/index.ts
@@ -1,15 +1,17 @@
import { StrictQueryParams } from '~/shared/models/strict-query.model';
import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators'
import { getMyReviewLog } from '~/shared/api/appointment';
import { recommend, AgentOfStrictQuery, addFavoriteConsultant, deleteConsultant, strictQuery } from '~/shared/api/consultant';
import { getFavoriteFromStorage, setFavoriteToStorage } from '~/shared/storageConsultant';
import myConsultantService from '~/shared/services/my-consultant.service';
import queryConsultantService from '~/shared/services/query-consultant.service';
import appointmentService from '~/shared/services/appointment.service';
import { Consultant } from '~/shared/models/consultant.model';
import { AppointmentLog } from '~/shared/models/appointment.model';
import { ClientInfo } from '~/shared/models/client.model';
import { AgentOfStrictQuery } from '~/shared/models/strict-query.model';
@Module
export default class Store extends VuexModule {
    recommendList: Consultant[] = [];
@@ -57,7 +59,7 @@
    @Action
    storeRecommendList() {
        recommend().then(data => {
        queryConsultantService.getRecommendConsultantList().then(data => {
            this.context.commit('updateRecommend', data)
        })
    }
@@ -74,7 +76,7 @@
        if (localData?.length) {
            const agentNoList = localData.map(i => i.agentNo)
            await addFavoriteConsultant(agentNoList).then(res => {
            await queryConsultantService.addFavoriteConsultant(agentNoList).then(res => {
                localStorage.removeItem('favoriteConsultant')
            })
        }
@@ -94,7 +96,7 @@
        if (!this.isUserLogin) {
            setFavoriteToStorage(left);
        } else {
            await deleteConsultant(agentNo)
            await myConsultantService.deleteConsultant(agentNo)
        }
        this.context.commit('updateConsultantList', left)
@@ -109,7 +111,7 @@
            if (!found) {
                const newData = [consultantToAdd].concat(this.myConsultantList);
                if (this.isUserLogin) {
                    await addFavoriteConsultant([consultantToAdd.agentNo])
                    await queryConsultantService.addFavoriteConsultant([consultantToAdd.agentNo])
                } else {
                    setFavoriteToStorage(newData);
                }
@@ -154,11 +156,11 @@
    }
    @Action
    async storeStrictQueryList(strictQueryDto) {
        return await strictQuery(strictQueryDto).then(res=>{
    async storeStrictQueryList(strictQueryDto: StrictQueryParams) {
        return await queryConsultantService.strictQuery(strictQueryDto).then(res=>{
            this.context.commit('localStorage/storageRecommendConsultant', JSON.stringify(strictQueryDto));
            this.context.commit('updateStrictQueryList', res.data)
            return res.data.length;
            this.context.commit('updateStrictQueryList', res)
            return res.length;
        });
    }