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/contactedList.vue |   36 ++++++++++++++++++++++--------------
 1 files changed, 22 insertions(+), 14 deletions(-)

diff --git a/PAMapp/pages/myAppointmentList/contactedList.vue b/PAMapp/pages/myAppointmentList/contactedList.vue
index 88a24a5..dbd8232 100644
--- a/PAMapp/pages/myAppointmentList/contactedList.vue
+++ b/PAMapp/pages/myAppointmentList/contactedList.vue
@@ -33,33 +33,41 @@
 
 @Component
 export default class ClientContactedList extends Vue {
-    @State('myAppointmentList') myAppointmentList!: ClientInfo[];
+
+    @State('myAppointmentList')
+    myAppointmentList!: ClientInfo[];
+
+    @Watch('myAppointmentList')
+    onMyAppointmentListChange() {
+        this.contactedList = (this.myAppointmentList || [])
+            .filter(item => item.communicateStatus === 'contacted')
+            .map((item) => ({...item, sortTime: new Date(item.contactTime)}))
+            .sort((prevItem, nextItem) => +nextItem - +prevItem);
+        this.filterList = this.contactedList;
+    }
 
     contactedList: ClientInfo[] = [];
     pageList: ClientInfo[] = [];
     keyWord: string = '';
     filterList: ClientInfo[] = [];
 
-    @Watch('myAppointmentList')
-    onMyAppointmentListChange() {
-        this.contactedList = (this.myAppointmentList || [])
-            .filter(item => item.communicateStatus === 'contacted')
-            .sort((a, b) => a.contactTime > b.contactTime ? -1 : 1);
-        this.filterList = this.contactedList;
-    }
+    //////////////////////////////////////////////////////////////////////
 
     mounted() {
         this.onMyAppointmentListChange();
     }
 
-    changePage(pageList: ClientInfo[]) {
+    //////////////////////////////////////////////////////////////////////
+
+    search(): void {
+        this.filterList = this.contactedList.filter(item => {
+            return item?.name?.match(this.keyWord) || item?.requirement?.match(this.keyWord)
+        })
+    }
+
+    changePage(pageList: ClientInfo[]): void {
         this.pageList = pageList;
     }
 
-    search() {
-        this.filterList = this.contactedList.filter(item => {
-            return item.name.match(this.keyWord) || item.requirement.match(this.keyWord)
-        })
-    }
 }
 </script>

--
Gitblit v1.9.3