From dd843d7db8b7a3c713e82a828f687b1ade144bbb Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期三, 08 十二月 2021 11:29:17 +0800
Subject: [PATCH] fixed: cousultant-card 預約單 id 判斷錯誤

---
 PAMapp/components/Consultant/ConsultantCard.vue |   30 +++++++++++++++++++-----------
 1 files changed, 19 insertions(+), 11 deletions(-)

diff --git a/PAMapp/components/Consultant/ConsultantCard.vue b/PAMapp/components/Consultant/ConsultantCard.vue
index 994bd0d..20de228 100644
--- a/PAMapp/components/Consultant/ConsultantCard.vue
+++ b/PAMapp/components/Consultant/ConsultantCard.vue
@@ -72,14 +72,14 @@
                         :key="index"
                     >��蝯⊥�挾{{index + 1 | formatNumber}}嚗{ item | formatHopeContactTime }}</p>
                     <div v-if="appointmentDetail.satisfactionScore">
-                    <div class="mdTxt mt-10 mb-10">皛踵�漲</div>
-                        <el-rate
-                            :value="appointmentDetail.satisfactionScore"
-                            class="pam-myDemand-dialog__rate"
-                            disabled>
-                        </el-rate>
+                      <div class="mdTxt mt-10 mb-10">皛踵�漲</div>
+                          <el-rate
+                              :value="appointmentDetail.satisfactionScore"
+                              class="pam-myDemand-dialog__rate"
+                              disabled>
+                          </el-rate>
+                      </div>
                     </div>
-                </div>
 
                 <div v-if="agentInfo.contactStatus === 'contacted'
                         && !appointmentDetail.satisfactionScore" class="dialogInfo-btn">
@@ -168,7 +168,13 @@
     get latestReservedAppointment(): Appointment {
         return this.agentInfo.appointments!
                 .filter((appointment) => appointment.communicateStatus !== 'contacted')
-                .sort((preAppointment, nextAppointment) => +nextAppointment.appointmentDate - +preAppointment.appointmentDate)[0];
+                .map((reversedAppointment) => {
+                  return {
+                    ...reversedAppointment,
+                    sortDate: new Date(reversedAppointment.appointmentDate)
+                  }
+                })
+                .sort((preAppointment, nextAppointment) => +nextAppointment.sortDate - +preAppointment.sortDate)[0];
     }
 
     appointmentDetail: any = {
@@ -236,9 +242,11 @@
     }
 
     openPopUp() {
-        getAppointmentDetail(this.latestContactedAppointment
-                            ? this.latestContactedAppointment.id
-                            : this.latestReservedAppointment.id).then(res => {
+      const appointmentId = this.agentInfo.contactStatus === 'contacted'
+                          ? this.latestContactedAppointment?.id
+                          : this.latestReservedAppointment.id;
+
+        getAppointmentDetail(appointmentId!).then(res => {
             this.appointmentDetail = {
                 ...this.appointmentDetail,
                 ...res.data

--
Gitblit v1.8.0