From f1c88aa1b2c67f3bb1575431cad5091989d54853 Mon Sep 17 00:00:00 2001
From: Tomas <tomasysh@gmail.com>
Date: 星期四, 10 三月 2022 12:20:50 +0800
Subject: [PATCH] fix#136510: 顧問後台更新資料後,前端客戶點選重新整理,並沒有重新更新頁面資訊

---
 PAMapp/pages/agentInfo/edit/_agentNo.vue |   63 ++++++++++++++++++++++++-------
 1 files changed, 48 insertions(+), 15 deletions(-)

diff --git a/PAMapp/pages/agentInfo/edit/_agentNo.vue b/PAMapp/pages/agentInfo/edit/_agentNo.vue
index 1ed9e6c..0d961b4 100644
--- a/PAMapp/pages/agentInfo/edit/_agentNo.vue
+++ b/PAMapp/pages/agentInfo/edit/_agentNo.vue
@@ -1,5 +1,5 @@
 <template>
-    <div class="edit-agent-info-page">
+    <div class="edit-agent-info-page" v-if="!!agentInfo">
 
       <el-row
         type="flex"
@@ -64,6 +64,27 @@
             :class="{'is-invalid': !phoneValid}"
             maxlength="10"
             minlength="10"></el-input>
+          </div>
+        </el-col>
+      </el-row>
+
+      <el-row
+        type="flex"
+        class="pam-paragraph">
+        <el-col :span="24" class="pam-field">
+          <div class="pam-field__label pam-progress__label">
+            <div>
+              <div class="pam-field__title mb-10">
+                <i class="pam-icon icon-comment"
+                  ></i>靽∠拳
+                  <span class="hint text--bold" v-show="!emailValid">靽∠拳�撘�炊</span>
+                  <span class="hint text--bold" v-show="editInfoValue.email.length === 0">靽∠拳�敹‵</span>
+              </div>
+            </div>
+            <el-input
+            v-model="editInfoValue.email"
+            :class="{'is-invalid': !emailValid}"
+            ></el-input>
           </div>
         </el-col>
       </el-row>
@@ -263,14 +284,15 @@
 const loginStore = namespace('login.store');
 
 @Component
-export default class AgentInfoComponent extends Vue {
+export default class AgentInfoEditComponent extends Vue {
 
-  @localStorageTest.State('current_role')
+  @localStorageTest.State
+  current_role: any;
 
   @loginStore.Action
-  updateConsultantDetail!: (agentInfo: AgentInfo) => AgentInfo;
+  updateConsultantDetail!: (agentNo: string) => Promise<AgentInfo>;
 
-  _agentInfoSetting!: AgentInfoSetting;
+  defaultAgentInfoSetting!: AgentInfoSetting;
   agentInfo!      : AgentInfo
   fieldInfoDesc   : string = '';
   fieldInfoTitle  : string = '';
@@ -293,7 +315,8 @@
     awards            : '',
     communicationStyle: [] as string[],
     photoBase64       : '',
-    phoneNumber       : ''
+    phoneNumber       : '',
+    email             : '',
   };
 
   communicationStyleList: string[] = agentCommunicationStyleList;
@@ -358,7 +381,7 @@
 
   private setAgentInfo(agentInfo: AgentInfo): void {
     const [agentYear, _yearUnit , agentMonth, _monthUnit] =  agentInfo.seniority.split(" ");
-    this._agentInfoSetting = {
+    this.defaultAgentInfoSetting = {
       agentNo           : agentInfo.agentNo||'',
       name              : agentInfo.name || '',
       expertise         : agentInfo.expertise || [],
@@ -374,28 +397,32 @@
       experiences       : agentInfo.experiences  || '',
       awards            : agentInfo.awards || '',
       communicationStyle: agentInfo.communicationStyle || '',
-      photoBase64       : ''
+      photoBase64       : '',
+      email             : agentInfo.email || ''
     };
 
     this.editInfoValue = {
-      ...this._agentInfoSetting,
-      expertise          : _.cloneDeep(this._agentInfoSetting.expertise),
+      ...this.defaultAgentInfoSetting,
+      expertise          : _.cloneDeep(this.defaultAgentInfoSetting.expertise),
       // TODO: 蝣箄��垢甇斗���垢���隞�" , "���� [Tomas, 2021/12/28]
-      communicationStyle : this._agentInfoSetting.communicationStyle.split('��'),
+      communicationStyle : this.defaultAgentInfoSetting.communicationStyle.split('��'),
     }
   }
+
 
   //////////////////////////////////////////////////////////////////////
 
   editAgentInfoSetting(): void {
+    console.log('???', this.editInfoValue)
     const editSettingInfo: any = {
       ...this.editInfoValue,
       communicationStyle: this.editInfoValue.communicationStyle.join('��'),
       serveArea: this.editInfoValue.serveArea.join('��'),
-    }
+    };
+    console.log('!!!', editSettingInfo);
     accountSettingService.editAgentInfoSetting(editSettingInfo).then((res: AgentInfoSetting) => {
-      this.updateConsultantDetail(editSettingInfo.agentNo);
       this.isInfoUpdate = true;
+      this.updateConsultantDetail(editSettingInfo.agentNo);
     });
   }
 
@@ -426,7 +453,7 @@
 
   ////////////////////////////////////////////////////////////
   get nameValid(): boolean {
-    return !!this.editAgentInfoSetting.name;
+    return !!this.defaultAgentInfoSetting?.name;
   }
 
   get phoneValid(): boolean {
@@ -435,6 +462,11 @@
             ? rule.test(this.editInfoValue.phoneNumber) && _.isEqual(this.editInfoValue.phoneNumber.length,10)
             : true;
         }
+
+  get emailValid() {
+      const rule = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
+      return this.editInfoValue.email ? rule.test(this.editInfoValue.email) : true;
+    }
 
   get isSubmitBtnDisabled(): boolean {
       const isFormValid =  this.editInfoValue.name
@@ -446,7 +478,8 @@
                         && this.editInfoValue.phoneNumber.length
                         && this.editInfoValue.seniorityYear
                         && this.editInfoValue.expertise.length
-                        && this.editInfoValue.communicationStyle.length;
+                        && this.editInfoValue.communicationStyle.length
+                        && this.editInfoValue.email.length;
       return !isFormValid
   }
 }

--
Gitblit v1.9.3