| | |
| | | <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'; |
| | |
| | | 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 : '', |
| | |
| | | |
| | | //////////////////////////////////////////////////////////////////////////// |
| | | |
| | | |
| | | async sentDemand() { |
| | | if (!this.isEditBtn) { |
| | | if (this.isEditBtn) { |
| | | await this.editAppointmentDemand(); |
| | | } else { |
| | | // 使用 async/await 來等待異步操作的回傳結果 |
| | | const addFavoriteAgentList = [{ agentNo: this.$route.params.agentNo, createdTime: new Date().toISOString() }]; |
| | | const response = await queryConsultantService.addFavoriteConsultant(addFavoriteAgentList); |
| | | |
| | | // 確保異步操作的回傳結果不為 null 或 undefined |
| | | if (!response) { |
| | | if (response !== null) { |
| | | await this.sentAppointmentDemand(); |
| | | } else { |
| | | throw new Error('queryConsultantService.addFavoriteConsultant returned null-like value.'); |
| | | } else { |
| | | if (typeof this.editAppointmentDemand === 'function') { |
| | | // 確保 this.editAppointmentDemand 是一個函數 |
| | | await this.editAppointmentDemand(); |
| | | } else { |
| | | // 處理 this.editAppointmentDemand 未定義的情況 |
| | | throw new Error('this.editAppointmentDemand is not defined or not a function.'); |
| | | } |
| | | } |
| | | } else { |
| | | await this.editAppointmentDemand(); |
| | | } |
| | | |
| | | const editSettingInfo: UserSetting = { |
| | |
| | | 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 |
| | |
| | | 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 |
| | | }; |
| | |
| | | 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; |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | get isDisabledSubmitBtn(): boolean { |
| | | return _.includes(this.myRequest.contactType,ContactType.PHONE) |
| | | return this.myRequest.contactType.includes(ContactType.PHONE) |
| | | ? !this.isHopeContactTimeDone() || !this.emailValid |
| | | : !this.phoneValid; |
| | | } |
| | |
| | | |
| | | |
| | | </style> |
| | | |