| | |
| | | //////////////////////////////////////////////////////////////////////////// |
| | | |
| | | async sentDemand() { |
| | | if (this.isEditBtn) { |
| | | await this.editAppointmentDemand(); |
| | | } else { |
| | | if (!this.isEditBtn) { |
| | | // 使用 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 { |
| | | if (!response) { |
| | | 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 = { |