From d5cbc3b4fde0a17c4f358926080ab4d9d63b7617 Mon Sep 17 00:00:00 2001
From: HelenHuang <LinHuang@pollex.com.tw>
Date: 星期四, 09 十二月 2021 16:34:19 +0800
Subject: [PATCH] fixed#132181: [我的顧問清單] 新增顧問後,最新一筆的顧問應顯示在列表中的第一個

---
 PAMapp/pages/index.vue              |    6 +++---
 PAMapp/assets/ts/api/appointment.ts |   14 +++++++-------
 PAMapp/pages/myConsultantList.vue   |    6 ++++--
 3 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/PAMapp/assets/ts/api/appointment.ts b/PAMapp/assets/ts/api/appointment.ts
index f27be9d..cfb1c6b 100644
--- a/PAMapp/assets/ts/api/appointment.ts
+++ b/PAMapp/assets/ts/api/appointment.ts
@@ -55,14 +55,14 @@
     job              : string,
     requirement      : string,
     communicateStatus: string,
-    hopeContactTime: string,
-    otherRequirement: string,
-    appointmentDate: Date,
-    agentNo: string,
-    customerId: number,
-    name: string,
+    hopeContactTime  : string,
+    otherRequirement : string,
+    appointmentDate  : Date,
+    agentNo          : string,
+    customerId       : number,
+    name             : string,
     consultantViewTime: Date,
     consultantReadTime: Date,
-    contactTime: Date,
+    contactTime      : Date,
     satisfactionScore: number
 }
\ No newline at end of file
diff --git a/PAMapp/pages/index.vue b/PAMapp/pages/index.vue
index 3be99fc..4bd0a61 100644
--- a/PAMapp/pages/index.vue
+++ b/PAMapp/pages/index.vue
@@ -52,7 +52,7 @@
   })
   export default class MainComponent extends Vue {
     consultantList: Consultant[] = [];
-    agents: Consultant[] = [];
+
     @State('recommendList') recommendList!: Consultant[];
     @Action storeRecommendList!: any;
 
@@ -66,7 +66,8 @@
     onMyConsultantListChange() {
       this.consultantList = (this.myConsultantList || [])
         .filter(item => item.contactStatus !== 'contacted')
-        .sort((a, b) => a.updateTime > b.updateTime ? -1 : 1)
+        .map((item) => ({ ...item, formatDate: new Date(item.updateTime)}))
+        .sort((preItem, nextItem) => +nextItem.formatDate - +preItem.formatDate)
     }
 
     mounted() {
@@ -75,7 +76,6 @@
       }
 
       this.storeConsultantList();
-
       this.storageClearQuickFilter();
       this.storageClearRecommendConsultant();
     }
diff --git a/PAMapp/pages/myConsultantList.vue b/PAMapp/pages/myConsultantList.vue
index ca2fb20..25fea68 100644
--- a/PAMapp/pages/myConsultantList.vue
+++ b/PAMapp/pages/myConsultantList.vue
@@ -69,10 +69,12 @@
     filterContactedList() {
         this.consultantList = (this.myConsultantList || [])
                 .filter(item => item.contactStatus !== 'contacted')
-                .sort((a, b) => a.updateTime > b.updateTime ? -1 : 1);
+                .map((item) => ({ ...item, formatDate: new Date(item.updateTime)}))
+                .sort((preItem, nextItem) => +nextItem.formatDate - +preItem.formatDate );
         this.contactedList = (this.myConsultantList || [])
                 .filter(item => item.contactStatus === 'contacted')
-                .sort((a, b) => a.updateTime > b.updateTime ? -1 : 1);
+                .map((item) => ({ ...item, formDate: new Date(item.updateTime)}))
+                .sort((preItem, nextItem) => +nextItem.formDate - +preItem.formDate);
     }
 
 }

--
Gitblit v1.8.0