From 2eea9fe0eac0dd2edb717591f372d160296bed0f Mon Sep 17 00:00:00 2001 From: Tomas <tomasysh@gmail.com> Date: 星期三, 19 一月 2022 16:09:47 +0800 Subject: [PATCH] update: 顧問-登入後將顧問細節設定到 store, 供預約單的發送約訪通知時使用 --- PAMapp/store/login.store.ts | 28 ++++++++++++++ PAMapp/pages/consultantLogin/index.vue | 9 ++++ PAMapp/components/Interview/InterviewMsg.vue | 12 ++++- PAMapp/shared/models/agent-info.model.ts | 37 +++++++++--------- PAMapp/store/localStorage.ts | 1 5 files changed, 65 insertions(+), 22 deletions(-) diff --git a/PAMapp/components/Interview/InterviewMsg.vue b/PAMapp/components/Interview/InterviewMsg.vue index 420a292..caa71b6 100644 --- a/PAMapp/components/Interview/InterviewMsg.vue +++ b/PAMapp/components/Interview/InterviewMsg.vue @@ -14,7 +14,7 @@ <el-input type="textarea" - autosize="true" + :autosize="true" placeholder="蝝赤�" resize="none" v-model="isInterviewTxt"> @@ -41,10 +41,13 @@ </div> </template> <script lang="ts"> -import { Vue, Component, Prop, PropSync, Emit, Action } from 'nuxt-property-decorator'; +import { Vue, Component, Prop, PropSync, Emit, Action, namespace } from 'nuxt-property-decorator'; import appointmentService from '~/shared/services/appointment.service'; import { Appointment, ToInformAppointment } from '~/shared/models/appointment.model'; +import { AgentInfo } from '~/shared/models/agent-info.model'; + +const loginStore = namespace('login.store'); @Component export default class InterviewMsg extends Vue { @@ -65,6 +68,9 @@ closeDialog() { return; } + + @loginStore.State + loginConsultant!: AgentInfo; isShowSuccessAlert = false; @@ -92,7 +98,7 @@ } get isInterviewTxt() : string{ - return this.interviewTxt = "�憟踝��靽���像����憿批��" + "agentName"+"嚗�����������銝膩������蝜�"+"\n"+"隞乩����閰梯�Ⅳ/Email嚗�"+"\n"+"agentPhone"+"\n"+"agentEmail"+"\n"+"�甇斗���靘選����蝜恬�����" + return this.interviewTxt = "�憟踝��靽���像����憿批��" + this.loginConsultant.name + "嚗�����������銝膩������蝜�"+"\n"+"隞乩����閰梯�Ⅳ/Email嚗�"+"\n" + this.loginConsultant.phoneNumber + "\n" + this.loginConsultant.email + "\n"+"�甇斗���靘選����蝜恬�����" } } diff --git a/PAMapp/pages/consultantLogin/index.vue b/PAMapp/pages/consultantLogin/index.vue index 2358123..dcebb79 100644 --- a/PAMapp/pages/consultantLogin/index.vue +++ b/PAMapp/pages/consultantLogin/index.vue @@ -61,8 +61,11 @@ import { Role } from '~/shared/models/enum/Role'; import messageBoxService from '~/shared/services/message-box.service'; import loginService from '~/shared/services/login.service' +import { AgentInfo } from '~/shared/models/agent-info.model'; + const loginStore = namespace('login.store'); const roleStorage = namespace('localStorage'); + @Component({ layout: 'home' }) @@ -75,6 +78,9 @@ @roleStorage.Mutation storageConsultantId!:(id:string) => void; + + @loginStore.Action + getLoginConsultantDetail!: (agentNo: string) => Promise<AgentInfo>; consultantDto = { password: '', @@ -130,7 +136,7 @@ private verify():void{ loginService.getVerificationStatus(this.verificationCode).then( verifySuccess => { if(verifySuccess.data){ - this.loginWithConsultant() + this.loginWithConsultant(); }else{ this.clearValue(); this.regenerateImgOfVerification(); @@ -141,6 +147,7 @@ private loginWithConsultant(): void { loginService.logInToConsultant(this.consultantDto).then(res => { + this.getLoginConsultantDetail(this.consultantDto.username); this.storageIdToken(res.data.id_token); this.storageRole(Role.ADMIN); this.storageConsultantId(this.consultantDto.username) diff --git a/PAMapp/shared/models/agent-info.model.ts b/PAMapp/shared/models/agent-info.model.ts index b91054d..e6af754 100644 --- a/PAMapp/shared/models/agent-info.model.ts +++ b/PAMapp/shared/models/agent-info.model.ts @@ -1,21 +1,22 @@ export interface AgentInfo { - name : string; - agentNo : string; - role : string; - img : string; - avgScore : number; - title : string; - phoneNumber : string; - serveArea : string; - companyAddress : string; - latestLoginTime : Date ; - seniority : string; - suitability : number; - evaluation : number; - expertise : string[]; - concept : string; - experiences : string; - awards : string; - gender : string, + agentNo : string; + avgScore : number; + awards : string; communicationStyle: string; + companyAddress : string; + concept : string; + email? : string; + evaluation : number; + experiences : string; + expertise : string[]; + gender : string, + img : string; + latestLoginTime : Date ; + name : string; + phoneNumber : string; + role : string; + seniority : string; + serveArea : string; + suitability : number; + title : string; } diff --git a/PAMapp/store/localStorage.ts b/PAMapp/store/localStorage.ts index 17c0a95..4c6a959 100644 --- a/PAMapp/store/localStorage.ts +++ b/PAMapp/store/localStorage.ts @@ -75,6 +75,7 @@ localStorage.removeItem('current_role'); localStorage.removeItem('consultant_id'); localStorage.removeItem('appointment'); + localStorage.removeItem('login_consultant'); this.id_token = localStorage.getItem('id_token'); this.current_role = localStorage.getItem('current_role'); this.consultant_id = localStorage.getItem('consultant_id'); diff --git a/PAMapp/store/login.store.ts b/PAMapp/store/login.store.ts new file mode 100644 index 0000000..a26fc2f --- /dev/null +++ b/PAMapp/store/login.store.ts @@ -0,0 +1,28 @@ +import { Module, VuexModule, Mutation, Action } from 'vuex-module-decorators' + +import myConsultantService from '~/shared/services/my-consultant.service'; +import { AgentInfo } from '~/shared/models/agent-info.model'; + +@Module +export default class AppointmentStore extends VuexModule { + + loginConsultant?: AgentInfo = JSON.parse(localStorage.getItem('login_consultant')!); + + ////////////////////////////////////////////////////////////////////// + + ////////////////////////////////////////////////////////////////////// + + @Mutation + SET_LOGIN_CONSULTANT(agentInfo: AgentInfo): void { + this.loginConsultant = agentInfo; + localStorage.setItem('login_consultant', JSON.stringify(agentInfo)); + } + + ////////////////////////////////////////////////////////////////////// + + @Action({ commit: 'SET_LOGIN_CONSULTANT' }) + async getLoginConsultantDetail(agentNo: string): Promise<AgentInfo> { + return await myConsultantService.getConsultantDetail(agentNo).then((res) => res); + } + +} -- Gitblit v1.8.0