From 741f1e1919adfa5745d945ce50beb1a317881f8e Mon Sep 17 00:00:00 2001
From: Mila <Mila@pollex.com.tw>
Date: 星期一, 24 一月 2022 16:34:55 +0800
Subject: [PATCH] Merge branch 'Phase3' of https://192.168.0.10:8443/r/pcalife/PAM into Phase3

---
 PAMapp/components/Client/ClientCard.vue |   38 ++++++++++++++++++++++++++------------
 1 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/PAMapp/components/Client/ClientCard.vue b/PAMapp/components/Client/ClientCard.vue
index 6afbe92..0ff9748 100644
--- a/PAMapp/components/Client/ClientCard.vue
+++ b/PAMapp/components/Client/ClientCard.vue
@@ -179,6 +179,7 @@
 import { ElRow } from 'element-ui/types/row';
 import { Appointment, AppointmentMemoInfo } from '~/shared/models/appointment.model';
 import { ContactStatus } from '~/shared/models/enum/contact-status';
+import reviewsService from '~/shared/services/reviews.service';
 
 const appointmentStore = namespace('appointment.store');
 const localStorage     = namespace('localStorage');
@@ -210,7 +211,10 @@
     updateMyAppointmentList!: (data: Appointment) => void;
 
     @appointmentStore.Action
-    setAppointmentDetail!: (appointmentId: number) => Promise<Appointment>;
+    getAppointmentDetail!: (appointmentId: number) => Promise<Appointment>;
+
+    @appointmentStore.Action
+    updateAppointmentDetail!: (id: number) => Appointment;
 
     @appointmentStore.Getter
     appointmentProgress!: ContactStatus;
@@ -256,7 +260,11 @@
     //////////////////////////////////////////////////////////////////////
 
     viewAppointmentDetail(): void {
-      this.setAppointmentDetail(this.client.id).then((_) => {
+      this.getAppointmentDetail(this.client.id).then((_) => {
+        const unread = !this.client.consultantReadTime;
+        if (unread) {
+          this.readAppointment();
+        }
         this.$router.push(`/appointment/${this.client.id}`);
       });
     }
@@ -266,11 +274,15 @@
     }
 
     navigateToCloseAppointment(): void {
-      this.$router.push(`/appointment/${this.client.id}/close`);
+      this.getAppointmentDetail(this.client.id).then((_) => {
+        this.$router.push(`/appointment/${this.client.id}/close`);
+      });
     }
 
     inviteReview(): void {
-      this.isShowInviteReviewDialog = true ;
+        reviewsService.sendSatisfactionToClient(this.client.id).then(res => {
+            this.isShowInviteReviewDialog = true ;
+        })
     }
 
     openDetail() {
@@ -289,18 +301,20 @@
     }
 
     closeInformDialog(): void {
-      const unread = !this.client.consultantReadTime;
-        if (unread) {
-            appointmentService.recordRead(this.client.id).then((_) => {
-                const updatedClient = {...this.client};
-                updatedClient.consultantReadTime = new Date().toString();
-                this.updateMyAppointmentList(updatedClient);
-            });
-        };
+        this.readAppointment();
         this.isEdit = false;
         this.clearAppointmentIdFromMsg();
     }
 
+    private readAppointment(): void {
+      appointmentService.recordRead(this.client.id).then((_) => {
+          const updatedClient = {...this.client};
+          updatedClient.consultantReadTime = new Date().toString();
+          this.updateMyAppointmentList(updatedClient);
+          this.updateAppointmentDetail(this.client.id);
+      });
+    }
+
     private clearAppointmentIdFromMsg() {
         this.storageClearAppointmentIdFromMsg();
         this.$router.push({query: {}});

--
Gitblit v1.8.0