From ac235850a9287dae6977c964213176fa7c86b140 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期四, 09 十二月 2021 14:42:20 +0800
Subject: [PATCH] Merge branch 'refactor/separate-vue' of ssh://192.168.0.10:29418/pcalife/PAM into refactor/separate-vue

---
 PAMapp/store/index.ts |   39 ++++++++++++++++++++++++++++++---------
 1 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/PAMapp/store/index.ts b/PAMapp/store/index.ts
index 1f7af2a..e7bcff8 100644
--- a/PAMapp/store/index.ts
+++ b/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 @@
         });
     }
 
-}
\ No newline at end of file
+}

--
Gitblit v1.8.0