From 30c810800159df369d75fc59637a15977c14ed7a Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期四, 16 十二月 2021 16:32:20 +0800
Subject: [PATCH] fixed: [顧問-預約單列表] 加入 viewTime 機制

---
 PAMapp/pages/myAppointmentList/appointmentList.vue |   12 ++++++------
 PAMapp/pages/myAppointmentList.vue                 |    7 ++++++-
 PAMapp/assets/ts/services/appointment.service.ts   |   12 +++++++++++-
 3 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/PAMapp/assets/ts/services/appointment.service.ts b/PAMapp/assets/ts/services/appointment.service.ts
index 68f8d82..b544948 100644
--- a/PAMapp/assets/ts/services/appointment.service.ts
+++ b/PAMapp/assets/ts/services/appointment.service.ts
@@ -6,7 +6,17 @@
 
   // ���������
   async getMyAppointmentList(): Promise<ClientInfo[]> {
-    return http.get('/consultant/getMyAppointment').then(res => res.data);
+    return http.get('/consultant/getMyAppointment').then((res) => {
+      const hasNewAppointment = res.data.find((appointment: ClientInfo) => !appointment.consultantViewTime);
+      if (hasNewAppointment) {
+        this.viewAllAppointment();
+      }
+      return res.data;
+    });
+  }
+
+  private viewAllAppointment(): void {
+    http.post('/consultant/record/allAppointmentsView').then();
   }
 
   // 璅�撌脰蝯�
diff --git a/PAMapp/pages/myAppointmentList.vue b/PAMapp/pages/myAppointmentList.vue
index ddc391e..6578ae8 100644
--- a/PAMapp/pages/myAppointmentList.vue
+++ b/PAMapp/pages/myAppointmentList.vue
@@ -20,6 +20,7 @@
             </div>
 
             <NuxtChild></NuxtChild>
+
         </div>
 
         <!-- DIALOG -->
@@ -67,6 +68,11 @@
     @State('myNewAppointmentSum')
     newAppointmentSum!: number;
 
+    @Watch('newAppointmentSum')
+    newAppointmentSumChange(): void {
+      this.showNewAppointmentHint = this.newAppointmentSum > 0;
+    }
+
     activeTabName = 'appointmentList';
     appointmentList: ClientInfo[] = [];
     contactedList: ClientInfo[] = [];
@@ -83,7 +89,6 @@
     mounted() {
       this.setActivatedTab();
       this.storeMyAppointmentList();
-      this.showNewAppointmentHint = this.newAppointmentSum > 0;
     }
 
     //////////////////////////////////////////////////////////////////////
diff --git a/PAMapp/pages/myAppointmentList/appointmentList.vue b/PAMapp/pages/myAppointmentList/appointmentList.vue
index 088a180..d3cd6c5 100644
--- a/PAMapp/pages/myAppointmentList/appointmentList.vue
+++ b/PAMapp/pages/myAppointmentList/appointmentList.vue
@@ -48,17 +48,17 @@
 
     @Watch('myAppointmentList')
     onMyAppointmentListChange(): void {
-      const unreadList = this.myAppointmentList
-          .filter((item) => item.communicateStatus !== 'contacted' && !item.consultantReadTime)
+      const unViewList = this.myAppointmentList
+          .filter((item) => item.communicateStatus !== 'contacted' && !item.consultantViewTime)
           .map((item) => ({ ...item, sortTime: new Date(item.appointmentDate)}))
           .sort((preItem, nextItem) => +nextItem.sortTime - +preItem.sortTime);
 
-      const readList = this.myAppointmentList
-          .filter(item => item.communicateStatus !== 'contacted' && item.consultantReadTime)
-          .map((item) => ({ ...item, sortTime: new Date(item.consultantReadTime)}))
+      const viewList = this.myAppointmentList
+          .filter(item => item.communicateStatus !== 'contacted' && item.consultantViewTime)
+          .map((item) => ({ ...item, sortTime: new Date(item.consultantViewTime)}))
           .sort((preItem, nextItem) => +nextItem.sortTime - +preItem.sortTime);
 
-      this.appointmentList = unreadList.concat(readList);
+      this.appointmentList = [...unViewList, ...viewList];
       this.filterList = this.appointmentList;
     }
 

--
Gitblit v1.8.0