From f065760fa7df1f88747395ab4b55349ce8b2faf0 Mon Sep 17 00:00:00 2001 From: Tomas <tomasysh@gmail.com> Date: 星期一, 25 十二月 2023 13:35:43 +0800 Subject: [PATCH] Update#178944: 移除 lodash 套件 --- PAMapp/pages/questionnaire/_agentNo.vue | 156 +++++++++++++++++++++++++++++++-------------------- 1 files changed, 94 insertions(+), 62 deletions(-) diff --git a/PAMapp/pages/questionnaire/_agentNo.vue b/PAMapp/pages/questionnaire/_agentNo.vue index d81c21e..a2552b9 100644 --- a/PAMapp/pages/questionnaire/_agentNo.vue +++ b/PAMapp/pages/questionnaire/_agentNo.vue @@ -67,7 +67,7 @@ <div class="ques-container"> <div class="pam-paragraph"> <div class="mdTxt"> - �閬岷������ + �鈭圾����� <span class="hint text--bold"> (�銴) </span> @@ -76,6 +76,12 @@ <MultiSelectBtn class="mt-10" :mutiSelect.sync="myRequest.requirement" :options="requirementOptions" /> + </div> + <div class="pam-paragraph"> + <div class="mdTxt">隢株岷�撘�</div> + <SingleSelectBtn class="mt-10" + :singleSelected.sync="myRequest.consultationMethod" + :options="consultationMethodOptions" /> </div> <div class="pam-paragraph"> <div class="mdTxt">����批</div> @@ -103,7 +109,7 @@ <PopUpFrame :isOpen.sync="showDrawer"> <div class="qaTextTitle mdTxt"> - <strong>�閬岷������</strong> + <strong>�鈭圾�����</strong> </div> <div class="qa-dialog"> <div v-for="(qaText,index) in quesAboutList" :key="index" > @@ -154,7 +160,6 @@ <script lang="ts"> import { Vue, Component, State, Action, Watch, namespace } from 'nuxt-property-decorator'; import { getRequestsFromStorage, removeRequestQuestionFromStorage, setRequestsToStorage } from '~/shared/storageRequests'; -import _ from 'lodash'; import accountSettingService from '~/shared/services/account-setting.service'; import appointmentService from '~/shared/services/appointment.service'; @@ -198,6 +203,17 @@ { title:'憟單��', label:Gender.FEMALE, + } + ]; + + consultationMethodOptions = [ + { + title: '蝺��', + label: 'online' + }, + { + title: '蝺��', + label: 'offline' } ]; @@ -260,37 +276,37 @@ ]; quesAboutList = [ - { - title:'�摨瑁����', - content:'����澈擃憿批末嚗�靽�兢蝳�嚗��������嚗��飩������摮拙��粥銝��頝荔�犖����迤閬����' - }, - { - title:'摮戊��', - content:'摮拙���������葦銋摮貊��撠靘�蒂�雿嚗飛���������������瓷嚗��楝銝���韏瑕飛��' - }, - { - title:'鞈閬��', - content:'��迤��瓷撖��雓寡�����嚗鈭箇�����蝳西瓷��◢�����Ⅱ靽�蝛拙��嚗�摰嗆��靘�末��皞���' - }, - { - title:'璅暑��隡�', - content:'�銝�頛拙����隡��摮���翰瘣鳴�停敺�����������隡瓷����撌勗�帘摰�嚗蝎曉蔗���僑鈭箇�������' - }, - { - title:'靽�瑼�/閬��', - content:'��瑼Z�撌梁������蝚血����靘�◢�蝘餉��瘙��' - }, - { - title:'����', - content:'���������憸券�����鈭怒�����嚗���摰帘摰漲嚗��隞亙��澈��ˊ�靽���嚗�' - } + { + title:'�摨瑁����', + content:'����澈擃憿批末嚗�靽�兢蝳�嚗��������嚗��飩������摮拙��粥銝��頝荔�犖����迤閬����' + }, + { + title:'摮戊��', + content:'摮拙���������葦銋摮貊��撠靘�蒂�雿嚗飛���������������瓷嚗��楝銝���韏瑕飛��' + }, + { + title:'鞈閬��', + content:'��迤��瓷撖��雓寡�����嚗鈭箇�����蝳西瓷��◢�����Ⅱ靽�蝛拙��嚗�摰嗆��靘�末��皞���' + }, + { + title:'璅暑��隡�', + content:'�銝�頛拙����隡��摮���翰瘣鳴�停敺�����������隡瓷����撌勗�帘摰�嚗蝎曉蔗���僑鈭箇�������' + }, + { + title:'靽�瑼�/閬��', + content:'��瑼Z�撌梁������蝚血����靘�◢�蝘餉��瘙��' + }, + { + title:'����', + content:'���������憸券�����鈭怒�����嚗���摰帘摰漲嚗��隞亙��澈��ˊ�靽���嚗�' + } ]; myRequest: AppointmentRequests = { name : '', phone : '', email : '', - contactType : _.isEqual(this.userInfo?.contactType,ContactType.SMS) ? ContactType.PHONE: ContactType.EMAIL, + contactType : this.userInfo?.contactType === ContactType.SMS ? ContactType.PHONE: ContactType.EMAIL, gender : '', age : '', job : '', @@ -300,6 +316,7 @@ selectTimesOptions: [], }], agentNo: '', + consultationMethod: '', }; showDrawer= false; @@ -336,7 +353,6 @@ private setMyRequest(): void { const storageMyRequest = getRequestsFromStorage(); const storageMyRequirement = this.recommendConsultantItem ? JSON.parse(this.recommendConsultantItem).requirements:[]; - const contactTypePromise = accountSettingService.getUserAccountSetting(); if (storageMyRequest) { this.myRequest = { @@ -358,12 +374,15 @@ removeRequestQuestionFromStorage(); } - contactTypePromise.then((contactTypeDetail) => { - this.myRequest = { - ...this.myRequest, - ...contactTypeDetail - } - }) + if (authService.isUserLogin()) { + accountSettingService.getUserAccountSetting().then((contactTypeDetail) => { + this.myRequest = { + ...this.myRequest, + ...contactTypeDetail + } + }) + } + } @@ -400,20 +419,23 @@ private getReservedData(appointmentInfo) { if (appointmentInfo) { - const hopeContactTime = appointmentInfo!.hopeContactTime.split("'") - .filter(item => item && item !== ','); - this.getAppointmentId(appointmentInfo); - - return { - ...appointmentInfo, - hopeContactTime: hopeContactTime.map(item => { + const hopeContactTime = appointmentInfo!.hopeContactTime + ? appointmentInfo!.hopeContactTime.split("'").filter(item => item && item !== ',').map(item => { const info = item.split('��'); return { selectWeekOptions: info[0].split(','), selectTimesOptions: info[1].split(',') } - }), - requirement: appointmentInfo.requirement.split(',') + }) + :[{selectWeekOptions : [],selectTimesOptions: []}]; + this.getAppointmentId(appointmentInfo); + + return { + ...appointmentInfo, + hopeContactTime: hopeContactTime, + requirement: appointmentInfo.requirement + ? appointmentInfo.requirement.split(',') + : [] } } else { return null; @@ -429,27 +451,38 @@ //////////////////////////////////////////////////////////////////////////// - sentDemand() { + + async sentDemand() { if (this.isEditBtn) { - this.editAppointmentDemand(); + await this.editAppointmentDemand(); } else { - queryConsultantService.addFavoriteConsultant([{ agentNo: this.$route.params.agentNo, createdTime: new Date().toISOString()}]).then(res => this.sentAppointmentDemand()); - } - const editSettingInfo: UserSetting = { - name: this.myRequest.name, - phone: this.myRequest.phone, - email: this.myRequest.email, + // 雿輻 async/await 靘��甇交����蝯�� + const addFavoriteAgentList = [{ agentNo: this.$route.params.agentNo, createdTime: new Date().toISOString() }]; + const response = await queryConsultantService.addFavoriteConsultant(addFavoriteAgentList); + + // 蝣箔�甇交����蝯�� null ��� undefined + if (response !== null) { + await this.sentAppointmentDemand(); + } else { + throw new Error('queryConsultantService.addFavoriteConsultant returned null-like value.'); + } } - accountSettingService.updateAccountSetting(editSettingInfo).then((_) => { - this.storageUserInfo(this.userInfo); - }); + const editSettingInfo: UserSetting = { + name: this.myRequest.name, + phone: this.myRequest.phone, + email: this.myRequest.email, + }; + + await accountSettingService.updateAccountSetting(editSettingInfo); + this.storageUserInfo(this.userInfo); } + private editAppointmentDemand() { const info = { ...this.myRequest, - requirement: _.map(this.myRequest.requirement,o=>o).toString(), + requirement: this.myRequest.requirement.map(o => o).toString(), hopeContactTime: this.myRequest.phone && this.phoneValid ? this.getHopeContactTime() :'', id: this.appointmentId, otherRequirement: null @@ -464,7 +497,7 @@ private sentAppointmentDemand() { const data: AppointmentParams = { ...this.myRequest, - requirement: _.map(this.myRequest.requirement,o=>o).toString(), + requirement: this.myRequest.requirement.map(o => o).toString(), hopeContactTime: this.myRequest.phone && this.phoneValid ? this.getHopeContactTime() :'', agentNo: this.$route.params.agentNo }; @@ -505,7 +538,7 @@ get phoneValid(): boolean { const rule = /^09[0-9]{8}$/; return this.myRequest.phone - ? rule.test(this.myRequest.phone) && _.isEqual(this.myRequest.phone.length,10) + ? rule.test(this.myRequest.phone) && this.myRequest.phone.length === 10 : true; } @@ -520,9 +553,9 @@ } get isDisabledSubmitBtn(): boolean { - return _.includes(this.myRequest.contactType,ContactType.PHONE) - ? !this.isHopeContactTimeDone() || !this.emailValid - : !this.phoneValid; + return this.myRequest.contactType.includes(ContactType.PHONE) + ? !this.isHopeContactTimeDone() || !this.emailValid + : !this.phoneValid; } private isHopeContactTimeDone():boolean{ @@ -707,4 +740,3 @@ </style> - -- Gitblit v1.9.3