From abfd26bb700d93a92da6a04703b0187d4acaaeb5 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期三, 22 十二月 2021 10:13:02 +0800
Subject: [PATCH] refactor: move ts folder to shared folder

---
 PAMapp/pages/myAppointmentList/appointmentList.vue |   49 +++++++++++++++++++++++++++++++------------------
 1 files changed, 31 insertions(+), 18 deletions(-)

diff --git a/PAMapp/pages/myAppointmentList/appointmentList.vue b/PAMapp/pages/myAppointmentList/appointmentList.vue
index eef91d0..617b4fb 100644
--- a/PAMapp/pages/myAppointmentList/appointmentList.vue
+++ b/PAMapp/pages/myAppointmentList/appointmentList.vue
@@ -25,44 +25,57 @@
 <script lang="ts">
 import { Vue, Component, State, Watch } from 'nuxt-property-decorator';
 
-import { ClientInfo } from '~/assets/ts/models/client.model';
+import { ClientInfo } from '~/shared/models/client.model';
 
 @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 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 tempViewList = this.myAppointmentList
+          .filter(item => item.communicateStatus !== 'contacted' && item.consultantViewTime);
+
+      // TODO: 敺������� unreadList ��蝝啁溶�������隢�垢����靘������ createTime嚗�Tomas, 2021/12/16];疇
+      const unreadList = tempViewList.filter((item) => !item.consultantReadTime);
+      const readList = tempViewList
+                    .filter((item) => item.consultantReadTime)
+                    .map((item) => ({ ...item, sortTime: new Date(item.consultantReadTime)}))
+                    .sort((preItem, nextItem) => +nextItem - +preItem);
+
+      this.appointmentList = [...unViewList, ...unreadList, ...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