From 32b40ec0722e3b0df055b0a85f7d68a14720d3fc Mon Sep 17 00:00:00 2001
From: HelenHuang <LinHuang@pollex.com.tw>
Date: 星期一, 03 一月 2022 15:28:23 +0800
Subject: [PATCH] Update:[multiSelectBtn] add maxOption setting

---
 PAMapp/components/Client/ClientCard.vue |  153 ++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 102 insertions(+), 51 deletions(-)

diff --git a/PAMapp/components/Client/ClientCard.vue b/PAMapp/components/Client/ClientCard.vue
index 0110136..a91788f 100644
--- a/PAMapp/components/Client/ClientCard.vue
+++ b/PAMapp/components/Client/ClientCard.vue
@@ -2,28 +2,32 @@
     <div>
         <el-row
             type="flex"
+            ref="clientCardRef"
             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">
-                <div class="circle" v-if="isReserved && !isRead"></div>
+            <el-col :xs="1" :sm="1" class="unread" align="middle" v-if="isReserved">
+                <div class="circle" v-if="!isRead"></div>
             </el-col>
-            <el-col :xs="4" :sm="2" align="middle">
+            <el-col :xs="5" :sm="3" align="middle">
                 <el-avatar
                     :size="50"
-                    src=""
                 ></el-avatar>
-                <div class="satisfaction">
+                <div class="satisfaction" v-if="!hideReviews">
                     <template v-if="client.satisfactionScore">
+                        TODO:���遛��漲
                         <i class="icon-star pam-icon icon--yellow satisfaction"></i>
                         <span>{{client.satisfactionScore}}</span>
                     </template>
+                    <template v-else>
+                        <div class="unfilled">�憛急遛��漲</div>
+                    </template>
                 </div>
             </el-col>
-            <el-col :xs="15" :sm="15" class="pl-10">
-                <div class="smTxt_bold name">{{client.name}}</div>
+            <el-col :xs="14" :sm="14" class="pl-10">
+                <div class="smTxt_bold name">{{ client.name }}</div>
                 <div class="message">������</div>
                 <div class="professionals">
                     <template v-if="client.requirement">
@@ -43,24 +47,24 @@
                 <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"
-            >{{isReserved ? '������' : '撌脰蝯∟���'}}</h5>
+            >{{isReserved ? '������' : '撌脰蝯∟���'}}</h5>
 
             <p v-if='isReserved'
                 class="smTxt text-right"
@@ -91,10 +95,16 @@
 </template>
 
 <script lang="ts">
-import { Vue, Component, Prop, Mutation, Action } from 'nuxt-property-decorator';
-import { isMobileDevice } from '~/assets/ts/device';
-import { ClientInfo, markAsContact, recordRead } from '~/assets/ts/api/appointment';
+import { Vue, Component, Prop, Action, namespace, Watch } from 'nuxt-property-decorator';
 
+import appointmentService from '~/shared/services/appointment.service';
+import UtilsService from '~/shared/services/utils.service';
+import { hideReviews } from '~/shared/const/hide-reviews';
+import { ClientInfo } from '~/shared/models/client.model';
+import myConsultantService from '~/shared/services/my-consultant.service';
+import { ElRow } from 'element-ui/types/row';
+
+const localStorage = namespace('localStorage');
 @Component({
     filters: {
         formatNumber(index: number) {
@@ -115,12 +125,43 @@
     }
 })
 export default class ClientList extends Vue {
-    @Action updateMyAppointment!: (data: ClientInfo) => void
-    @Action storeConsultantList!: () => void;
+    @Action
+    updateMyAppointment!: (data: ClientInfo) => void;
 
-    @Prop() client!: ClientInfo;
+    @Prop()
+    client!: ClientInfo;
+
+    @localStorage.Mutation
+    storageClearAppointmentIdFromMsg!: () => void;
+
     isVisibleDialog = false;
-    width = '';
+    dialogWidth = '';
+    hideReviews = hideReviews;
+
+    //////////////////////////////////////////////////////////////////////
+
+    @Watch('$route', {immediate: true})
+    onRouteChange() {
+        const appointmentIdFromMsg = this.$route.query.appointmentId;
+        if (appointmentIdFromMsg && +appointmentIdFromMsg === this.client.id) {
+            this.openDetail();
+        }
+    }
+
+    //////////////////////////////////////////////////////////////////////
+
+    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(',');
@@ -130,7 +171,7 @@
         if (this.client.gender) {
             return this.client.gender === 'male' ? '���' : '憟單��';
         }
-        return ''
+        return '';
     }
 
     get hopeContactTime() {
@@ -138,19 +179,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 {
@@ -158,52 +187,63 @@
         }
     }
 
-    get latestUpdateTime() {
+    get displayTime(): string {
         if (this.isReserved) {
-            return this.client.consultantReadTime ? this.client.consultantReadTime : this.client.appointmentDate;
+            return this.client.appointmentDate;
         } else {
-            return this.client.contactTime;
+            return this.client.lastModifiedDate;
         }
     }
 
     get time() {
-        const formatDate = (this.$options.filters as any).formatDate(this.latestUpdateTime);
+        const formatDate = (this.$options.filters as any).formatDate(this.displayTime);
         return formatDate.split(' ')[1]
     }
 
     get date() {
-        const formatDate = (this.$options.filters as any).formatDate(this.latestUpdateTime);
+        const formatDate = (this.$options.filters as any).formatDate(this.displayTime);
         return formatDate.split(' ')[0];
     }
 
     openDetail() {
-        this.width = isMobileDevice() ? '80%' : '';
+        setTimeout(() => {
+            (this.$refs.clientCardRef as any).$el.classList.add('currentShowStyle');
+        }, 0)
+
+        this.dialogWidth = UtilsService.isMobileDevice() ? '80%' : '';
         this.isVisibleDialog = true;
     }
 
     markAppointment() {
-        markAsContact(this.client.id).then(data => {
+        myConsultantService.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);
             });
-        }
+        };
+        this.clearAppointmentIdFromMsg();
+    }
+
+    private clearAppointmentIdFromMsg() {
+        this.storageClearAppointmentIdFromMsg();
+        this.$router.push({query: {}});
+        setTimeout(() => {
+            (this.$refs.clientCardRef as ElRow).$el.classList.remove('currentShowStyle')
+        },1000)
     }
 
 }
@@ -216,9 +256,15 @@
         margin-bottom: 10px;
         display: flex;
         justify-content: space-between;
+        transition: background-color 0.5s;
 
         &.new {
             border-left: solid 4px $YELLOW;
+        }
+
+        &.currentShowStyle {
+            background-color: rgba(236, 195, 178, 0.5);
+            transition: background-color 0.5s;
         }
 
         .unread {
@@ -237,6 +283,11 @@
             font-size: 12px;
             font-weight: bold;
             margin-top: 5px;
+
+            .unfilled {
+                font-weight: lighter;
+                color: $MID_GREY;
+            }
         }
 
         .message {

--
Gitblit v1.8.0