From ffcf1c449974fffad5e827ab0dd2d3bb21327d5f Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期六, 05 八月 2023 17:46:45 +0800
Subject: [PATCH] Fixed: [弱掃] p13.2 Bad use of null-like value

---
 PAMapp/components/AddAndReservedBtns.vue |   21 ++++++++++++++++++++-
 1 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/PAMapp/components/AddAndReservedBtns.vue b/PAMapp/components/AddAndReservedBtns.vue
index f2f3177..f2d5c2e 100644
--- a/PAMapp/components/AddAndReservedBtns.vue
+++ b/PAMapp/components/AddAndReservedBtns.vue
@@ -4,15 +4,18 @@
             <span> {{ isAdded ? '撌脣�憿批��' : '+ 憿批��' }}</span>
         </el-button>
         <el-button
+            :disabled="isDisableReserve"
             @click="navigateToReservationForm"
             type="primary"
-        >�脰����</el-button>
+        >{{ isDisableReserve ? '撌脰蝯�' : '�脰����'}}</el-button>
     </el-row>
 </template>
 
 <script lang="ts">
 import { Vue, Component, Prop, Emit, Action, State, namespace } from 'nuxt-property-decorator';
 import { Consultant } from '~/shared/models/consultant.model';
+
+const roleStorage = namespace('localStorage');
 
 @Component
 export default class AddAndReservedBtns extends Vue {
@@ -29,6 +32,9 @@
     @Prop()
     cusClass!: string;
 
+    @roleStorage.Getter
+    isUserLogin!: boolean;
+
     isVisiblePopUp = false;
 
     //////////////////////////////////////////////////////////////////////
@@ -41,6 +47,12 @@
     //////////////////////////////////////////////////////////////////////
 
     addConsultant(item: Consultant): void {
+        if (!this.isUserLogin) {
+          item = {
+            ...item,
+            updateTime: new Date().toISOString()
+          };
+        }
         this.addToMyConsultantList(item).then(addOk => {
             addOk && this.openPopUp();
         });
@@ -54,5 +66,12 @@
         return this.myConsultantList.find(item => item.agentNo === this.agentInfo.agentNo)
                 ? true : false
     }
+
+    get isDisableReserve(): boolean {
+      return this.myConsultantList.some((agent) => {
+        return agent.agentNo === this.agentInfo.agentNo
+            && agent.contactStatus === 'contacted';
+        });
+    }
 }
 </script>

--
Gitblit v1.8.0