From bdae23a40c461c2c6b6ee614f661eac731c949c8 Mon Sep 17 00:00:00 2001
From: Mila <Mila@pollex.com.tw>
Date: 星期三, 22 十二月 2021 14:12:05 +0800
Subject: [PATCH] Merge branch 'master' of https://192.168.0.10:8443/r/pcalife/PAM

---
 PAMapp/pages/myAppointmentList/appointmentList.vue |   47 +++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 39 insertions(+), 8 deletions(-)

diff --git a/PAMapp/pages/myAppointmentList/appointmentList.vue b/PAMapp/pages/myAppointmentList/appointmentList.vue
index 39a357c..617b4fb 100644
--- a/PAMapp/pages/myAppointmentList/appointmentList.vue
+++ b/PAMapp/pages/myAppointmentList/appointmentList.vue
@@ -5,6 +5,7 @@
             placeholder="隢撓���摮�"
             class="mb-30 pam-clientReserved-input"
             v-model="keyWord"
+            @keyup.enter.native="search"
         >
             <i slot="suffix" class="icon-search search cursor--pointer" @click="search"></i>
         </el-input>
@@ -22,29 +23,59 @@
 </template>
 
 <script lang="ts">
-import { Vue, Component, Prop } from 'nuxt-property-decorator';
-import { ClientInfo } from '~/assets/ts/api/appointment';
+import { Vue, Component, State, Watch } from 'nuxt-property-decorator';
+
+import { ClientInfo } from '~/shared/models/client.model';
 
 @Component
 export default class ClientReservedList extends Vue {
-    @Prop({default: []}) appointmentList!: ClientInfo[];
+
+    @State('myAppointmentList')
+    myAppointmentList!: ClientInfo[];
+
+    appointmentList: ClientInfo[] = [];
     pageList: ClientInfo[] = [];
     keyWord: string = '';
     filterList: ClientInfo[] = [];
 
+    //////////////////////////////////////////////////////////////////////
+
     mounted() {
-        this.filterList = JSON.parse(JSON.stringify(this.appointmentList))
+        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>
\ No newline at end of file
+</script>

--
Gitblit v1.8.0