From 46da7429ca192bf6a947d79437e8076b94676a05 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期四, 13 一月 2022 16:29:45 +0800
Subject: [PATCH] update: 刪除重複的 interface: clientInfo => appointment

---
 PAMapp/pages/myAppointmentList/appointmentList.vue |  101 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 101 insertions(+), 0 deletions(-)

diff --git a/PAMapp/pages/myAppointmentList/appointmentList.vue b/PAMapp/pages/myAppointmentList/appointmentList.vue
new file mode 100644
index 0000000..57e3080
--- /dev/null
+++ b/PAMapp/pages/myAppointmentList/appointmentList.vue
@@ -0,0 +1,101 @@
+<template>
+    <div>
+        <el-input
+            type="text"
+            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>
+
+        <ClientList
+            :clients="pageList"
+            :title="'reservedList'"
+        ></ClientList>
+
+        <UiPagination
+            :totalList="filterList"
+            :currentPage="currentPage"
+            @changePage="changePage"
+        ></UiPagination>
+    </div>
+</template>
+
+<script lang="ts">
+import { Vue, Component, State, Watch, namespace } from 'nuxt-property-decorator';
+
+import { Appointment } from '~/shared/models/appointment.model';
+
+
+const localStorage = namespace('localStorage');
+@Component
+export default class ClientReservedList extends Vue {
+
+    @State('myAppointmentList')
+    myAppointmentList!: Appointment[];
+
+    @localStorage.Getter
+    currentAppointmentIdFromMsg!: string;
+
+    appointmentList: Appointment[] = [];
+    filterList     : Appointment[] = [];
+    keyWord        : string       = '';
+    pageList       : Appointment[] = [];
+    currentPage    : number = 1;
+
+    //////////////////////////////////////////////////////////////////////
+
+    mounted() {
+        this.onMyAppointmentListChange();
+    }
+
+    //////////////////////////////////////////////////////////////////////
+
+    @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.sortTime - +preItem.sortTime);
+
+      this.appointmentList = [...unViewList, ...unreadList, ...readList];
+      this.filterList = this.appointmentList;
+
+      this.getCurrentPage();
+    }
+
+    private getCurrentPage() {
+        const currentIndex = this.filterList
+            .findIndex(item => item.id === +this.currentAppointmentIdFromMsg);
+        const pageSize = 5;
+        if (currentIndex > -1) {
+            this.currentPage = Math.ceil((currentIndex + 1) / pageSize);
+        }
+    }
+
+    //////////////////////////////////////////////////////////////////////
+    search(): void {
+        this.filterList = this.appointmentList.filter(item => {
+            return item.name.match(this.keyWord) || item.requirement.match(this.keyWord)
+        })
+    }
+
+    changePage(pageList: Appointment[]): void {
+        this.pageList = pageList;
+    }
+
+}
+</script>

--
Gitblit v1.8.0