From aaab6e8e0bc119513ad1d9e939a8bbd7d1823af9 Mon Sep 17 00:00:00 2001
From: Mila <Mila@pollex.com.tw>
Date: 星期二, 21 十二月 2021 12:27:22 +0800
Subject: [PATCH] add: TODO#132491 [F&Q] 前端畫面

---
 PAMapp/components/Client/ClientCard.vue |   83 +++++++++++++++++++++++------------------
 1 files changed, 46 insertions(+), 37 deletions(-)

diff --git a/PAMapp/components/Client/ClientCard.vue b/PAMapp/components/Client/ClientCard.vue
index 76e6f2b..4fca204 100644
--- a/PAMapp/components/Client/ClientCard.vue
+++ b/PAMapp/components/Client/ClientCard.vue
@@ -4,7 +4,7 @@
             type="flex"
             class="rowStyle cursor--pointer"
             justify="space-between"
-            :class="{'new': !isView && isReserved}"
+            :class="{'new': newAppointment }"
             @click.native="openDetail"
         >
             <el-col :xs="1" :sm="1" class="unread" align="middle" v-if="isReserved">
@@ -13,7 +13,6 @@
             <el-col :xs="5" :sm="3" align="middle">
                 <el-avatar
                     :size="50"
-                    src=""
                 ></el-avatar>
                 <div class="satisfaction" v-if="!hideReviews">
                     <template v-if="client.satisfactionScore">
@@ -27,7 +26,7 @@
                 </div>
             </el-col>
             <el-col :xs="14" :sm="14" class="pl-10">
-                <div class="smTxt_bold name">{{client.name}}</div>
+                <div class="smTxt_bold name">{{ client.name }}</div>
                 <div class="message">������</div>
                 <div class="professionals">
                     <template v-if="client.requirement">
@@ -47,20 +46,20 @@
                 <div
                     class="smTxt_bold fix-chrome-click--issue"
                     :class="{'unread-txt': reservedTxt === '�霈�', 'read-txt': reservedTxt !== '�霈�'}"
-                >{{reservedTxt}}</div>
+                >{{ reservedTxt }}</div>
                 <div
                     class="date xsTxt text--mid_grey"
-                >{{date}}</div>
+                >{{ date }}</div>
                 <div
                     class="xsTxt text--mid_grey"
-                >{{time}}</div>
+                >{{ time }}</div>
             </el-col>
         </el-row>
 
         <Ui-Dialog
             :isVisible.sync="isVisibleDialog"
-            :width="width"
-            @closeDialog="close"
+            :width="dialogWidth"
+            @closeDialog="closeDialog"
             class="pam-myDemand-dialog"
         >
             <h5 class="subTitle text--center mb-30"
@@ -96,9 +95,13 @@
 
 <script lang="ts">
 import { Vue, Component, Prop, Action } from 'nuxt-property-decorator';
+
+import appointmentService from '~/assets/ts/services/appointment.service';
 import { isMobileDevice } from '~/assets/ts/device';
-import { ClientInfo, markAsContact, recordRead } from '~/assets/ts/api/appointment';
 import { hideReviews } from '~/assets/ts/const/hide-reviews';
+import { ClientInfo } from '~/assets/ts/models/client.model';
+
+
 @Component({
     filters: {
         formatNumber(index: number) {
@@ -119,13 +122,33 @@
     }
 })
 export default class ClientList extends Vue {
-    @Action updateMyAppointment!: (data: ClientInfo) => void
-    @Action storeConsultantList!: () => void;
+    @Action
+    updateMyAppointment!: (data: ClientInfo) => void
 
-    @Prop() client!: ClientInfo;
+    @Action
+    storeConsultantList!: () => void;
+
+    @Prop()
+    client!: ClientInfo;
+
     isVisibleDialog = false;
-    width = '';
+    dialogWidth = '';
     hideReviews = hideReviews;
+
+    //////////////////////////////////////////////////////////////////////
+
+    get newAppointment(): boolean {
+      return !this.client.consultantViewTime
+            && this.client.communicateStatus === 'reserved';
+    }
+
+    get isReserved() {
+      return this.client.communicateStatus === 'reserved';
+    }
+
+    get isRead() {
+      return !!this.client.consultantReadTime;
+    }
 
     get requirements() {
         return this.client.requirement.split(',');
@@ -135,7 +158,7 @@
         if (this.client.gender) {
             return this.client.gender === 'male' ? '���' : '憟單��';
         }
-        return ''
+        return '';
     }
 
     get hopeContactTime() {
@@ -143,19 +166,7 @@
         return contactList.filter(item => !!item && item !== ",")
     }
 
-    get isReserved() {
-        return this.client.communicateStatus === 'reserved';
-    }
-
-    get isRead() {
-        return !!this.client.consultantReadTime;
-    }
-
-    get isView() {
-        return !!this.client.consultantViewTime;
-    }
-
-    get reservedTxt() {
+    get reservedTxt(): string {
         if (this.isReserved) {
             return this.client.consultantReadTime ? '撌脰�' : '�霈�';
         } else {
@@ -182,30 +193,28 @@
     }
 
     openDetail() {
-        this.width = isMobileDevice() ? '80%' : '';
+        this.dialogWidth = isMobileDevice() ? '80%' : '';
         this.isVisibleDialog = true;
     }
 
     markAppointment() {
-        markAsContact(this.client.id).then(data => {
+        appointmentService.markAsContact(this.client.id).then(data => {
             // TODO: 閬敺����� updated client 鞈�� - Ben 2021/11/16
-
             const updatedClient = {...this.client};
             updatedClient.communicateStatus = 'contacted';
-            updatedClient.contactTime = new Date();
+            updatedClient.contactTime = new Date().toString();
 
             this.updateMyAppointment(updatedClient);
             this.isVisibleDialog = false;
-
         })
     }
 
-    close() {
-        if (!this.client.consultantReadTime) {
-            recordRead(this.client.id).then(res => {
+    closeDialog(): void {
+      const unread = !this.client.consultantReadTime;
+        if (unread) {
+            appointmentService.recordRead(this.client.id).then((_) => {
                 const updatedClient = {...this.client};
-                updatedClient.consultantReadTime = new Date();
-
+                updatedClient.consultantReadTime = new Date().toString();
                 this.updateMyAppointment(updatedClient);
             });
         }

--
Gitblit v1.8.0