From adac30f827fb9ea275c46bd3b22b8e770858cedf Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期四, 16 十二月 2021 15:36:59 +0800
Subject: [PATCH] refactor: [顧問] 客戶預約清單

---
 PAMapp/pages/myAppointmentList/appointmentList.vue |   42 +++++++++++++++++++++++++-----------------
 1 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/PAMapp/pages/myAppointmentList/appointmentList.vue b/PAMapp/pages/myAppointmentList/appointmentList.vue
index eef91d0..088a180 100644
--- a/PAMapp/pages/myAppointmentList/appointmentList.vue
+++ b/PAMapp/pages/myAppointmentList/appointmentList.vue
@@ -29,40 +29,48 @@
 
 @Component
 export default class ClientReservedList extends Vue {
-    @State('myAppointmentList') myAppointmentList!: ClientInfo[];
+
+    @State('myAppointmentList')
+    myAppointmentList!: ClientInfo[];
 
     appointmentList: ClientInfo[] = [];
     pageList: ClientInfo[] = [];
     keyWord: string = '';
     filterList: ClientInfo[] = [];
 
-    @Watch('myAppointmentList')
-    onMyAppointmentListChange() {
-        const unreadList = this.myAppointmentList
-            .filter(item => item.communicateStatus !== 'contacted' && !item.consultantReadTime)
-            .sort((a, b) => a.appointmentDate > b.appointmentDate ? -1 : 1);
-
-        const readList = this.myAppointmentList
-            .filter(item => item.communicateStatus !== 'contacted' && item.consultantReadTime)
-            .sort((a, b) => a.consultantReadTime > b.consultantReadTime ? -1 : 1)
-
-        this.appointmentList = unreadList.concat(readList);
-        this.filterList = this.appointmentList;
-    }
+    //////////////////////////////////////////////////////////////////////
 
     mounted() {
         this.onMyAppointmentListChange();
     }
 
-    changePage(pageList: ClientInfo[]) {
-        this.pageList = pageList;
+    //////////////////////////////////////////////////////////////////////
+
+    @Watch('myAppointmentList')
+    onMyAppointmentListChange(): void {
+      const unreadList = this.myAppointmentList
+          .filter((item) => item.communicateStatus !== 'contacted' && !item.consultantReadTime)
+          .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)}))
+          .sort((preItem, nextItem) => +nextItem.sortTime - +preItem.sortTime);
+
+      this.appointmentList = unreadList.concat(readList);
+      this.filterList = this.appointmentList;
     }
 
-    search() {
+    search(): void {
         this.filterList = this.appointmentList.filter(item => {
             return item.name.match(this.keyWord) || item.requirement.match(this.keyWord)
         })
     }
 
+    changePage(pageList: ClientInfo[]): void {
+        this.pageList = pageList;
+    }
+
 }
 </script>

--
Gitblit v1.8.0