From 17c4bad56fd902184f7c037dbdb22fd63289d1e7 Mon Sep 17 00:00:00 2001
From: Mila <Mila@pollex.com.tw>
Date: 星期二, 25 一月 2022 16:21:42 +0800
Subject: [PATCH] fixed: TODO#134613 [顧問管理流程] 搜尋欄位清空 , 未顯示原本的約訪中列表

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

diff --git a/PAMapp/pages/myAppointmentList/appointmentList.vue b/PAMapp/pages/myAppointmentList/appointmentList.vue
new file mode 100644
index 0000000..e623916
--- /dev/null
+++ b/PAMapp/pages/myAppointmentList/appointmentList.vue
@@ -0,0 +1,102 @@
+<template>
+    <div>
+        <el-input
+            type="text"
+            placeholder="隢撓���摮�"
+            class="mb-30 pam-clientReserved-input"
+            v-model="keyWord"
+            @input="search"
+        >
+            <i slot="suffix" class="icon-search search cursor--pointer"></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, Watch, namespace } from 'nuxt-property-decorator';
+
+import { Appointment } from '~/shared/models/appointment.model';
+import { ContactStatus } from '~/shared/models/enum/contact-status';
+
+
+const localStorage     = namespace('localStorage');
+const appointmentStore = namespace('appointment.store');
+@Component
+export default class ClientReservedList extends Vue {
+
+    @appointmentStore.State('myAppointmentList')
+    myAppointmentList!: Appointment[];
+
+    @localStorage.Getter
+    currentAppointmentIdFromMsg!: string;
+
+    @appointmentStore.Action
+    getAppointmentDetail!: () => Promise<Appointment>;
+
+    appointmentList: Appointment[]  = [];
+    currentPage     : number        = 1;
+    filterList      : Appointment[] = [];
+    keyWord         : string        = '';
+    pageList        : Appointment[] = [];
+
+    contactStatus  = ContactStatus;
+
+    //////////////////////////////////////////////////////////////////////
+
+    mounted() {
+        this.onMyAppointmentListChange();
+    }
+
+    //////////////////////////////////////////////////////////////////////
+
+    @Watch('myAppointmentList')
+    onMyAppointmentListChange(): void {
+      this.appointmentList = this.myAppointmentList
+          .filter(item => item.communicateStatus === this.contactStatus.RESERVED)
+          .map((item) => ({ ...item, sortTime: new Date(item.lastModifiedDate)}))
+          .sort((preItem, nextItem) => +nextItem.sortTime - +preItem.sortTime);
+
+      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 {
+        if (this.keyWord) {
+            this.filterList = this.appointmentList.filter(item => {
+                return item.name.match(this.keyWord) || item.requirement.match(this.keyWord);
+            })
+        } else {
+            this.filterList = this.appointmentList;
+        }
+
+    }
+
+    changePage(pageList: Appointment[]): void {
+        this.pageList = pageList;
+    }
+
+}
+</script>

--
Gitblit v1.8.0