From abfa3cc46bfd161b6a474610f37a5243a6ca34e8 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期三, 16 二月 2022 16:38:17 +0800
Subject: [PATCH] fix#135492: [ 客戶端 ] 已聯絡清單 : 第一筆預約單非最新一筆的預約單

---
 PAMapp/pages/myConsultantList.vue |   49 ++++++++++++++++++++++++++++---------------------
 1 files changed, 28 insertions(+), 21 deletions(-)

diff --git a/PAMapp/pages/myConsultantList.vue b/PAMapp/pages/myConsultantList.vue
index 687547c..453f05e 100644
--- a/PAMapp/pages/myConsultantList.vue
+++ b/PAMapp/pages/myConsultantList.vue
@@ -21,25 +21,28 @@
             :contactedList="contactedList"
             :consultantList="consultantList"
         ></NuxtChild>
+
     </div>
 </template>
 
 <script lang='ts'>
 import { Vue, Component, Watch, State, Action } from 'nuxt-property-decorator';
+
+import authService from '~/shared/services/auth.service';
 import { Consultant, ConsultantWithAppointmentId } from '~/shared/models/consultant.model';
 
 @Component
 export default class myConsultantList extends Vue {
-
-    activeTabName = 'consultantList';
-    consultantList: Consultant[] = [];
-    contactedList: ConsultantWithAppointmentId[] = [];
 
     @State('myConsultantList')
     myConsultantList!: Consultant[];
 
     @Action
     storeConsultantList!: any;
+
+    activeTabName : string                        = 'consultantList';
+    consultantList: Consultant[]                  = [];
+    contactedList : ConsultantWithAppointmentId[] = [];
 
     //////////////////////////////////////////////////////////////////////
 
@@ -67,24 +70,17 @@
         this.setList();
     }
 
-    clickTab(path: string) {
-        this.activeTabName = path;
-        this.$router.push('/myConsultantList/' + this.activeTabName)
-    }
-
-    //////////////////////////////////////////////////////////////////////
-
     private setList() {
-      // reset contacted list
-        this.contactedList = [];
+    // reset contacted list
+      this.contactedList = [];
 
-      // format consultant list
-        this.consultantList = (this.myConsultantList || [])
-          .filter(item => item.contactStatus !== 'contacted')
-          .map((item) => ({ ...item, formatDate: new Date(item.updateTime || item.createTime)}))
-          .sort((preItem, nextItem) => +nextItem.formatDate - +preItem.formatDate );
+    // format consultant list
+      this.consultantList = (this.myConsultantList || [])
+        .filter(item => item.contactStatus !== 'contacted')
+        .map((item) => ({ ...item, formatDate: new Date(item.updateTime || item.createTime)}))
+        .sort((preItem, nextItem) => +nextItem.formatDate - +preItem.formatDate );
 
-      // format contacted list
+      if (authService.isUserLogin()) {
         this.myConsultantList.filter((consultant) => consultant.appointments!.length)
           .forEach((consultant) => {
             consultant.appointments!.forEach((appointment) => {
@@ -94,17 +90,28 @@
                 appointmentDate: appointment.appointmentDate,
                 appointmentScore: appointment.satisfactionScore,
                 appointmentStatus: appointment.communicateStatus,
+                appointmentLastModifiedDate: appointment.lastModifiedDate
               };
               this.contactedList.push(consultantWithAppointmentId);
             })
           });
 
         this.contactedList = this.contactedList
-          .filter((appointment) => appointment['appointmentStatus'] === 'contacted')
-          .map((appointment) => ({ ...appointment, sortTime: new Date(appointment.appointmentDate)}))
+          .filter((appointment) => appointment['appointmentStatus'] !== 'reserved')
+          .map((appointment) => ({ ...appointment, sortTime: new Date(appointment.updateTime)}))
           .sort((preAppointment, nextAppointment) => +nextAppointment.sortTime - +preAppointment.sortTime);
+      }
+
     }
 
+    //////////////////////////////////////////////////////////////////////
+
+    clickTab(path: string) {
+        this.activeTabName = path;
+        this.$router.push('/myConsultantList/' + this.activeTabName)
+    }
+
+
 }
 </script>
 

--
Gitblit v1.8.0