保誠-保戶業務員媒合平台
Tomas
2023-09-07 8f60f9800584d6918d7bcda66ed18f8773a25f25
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" >
@@ -198,6 +204,17 @@
      {
        title:'女性',
        label:Gender.FEMALE,
      }
    ];
    consultationMethodOptions = [
      {
        title: '線上',
        label: 'online'
      },
      {
        title: '線下',
        label: 'offline'
      }
    ];
@@ -300,6 +317,7 @@
        selectTimesOptions: [],
      }],
      agentNo: '',
      consultationMethod: '',
    };
    showDrawer= false;
@@ -336,7 +354,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 +375,15 @@
        removeRequestQuestionFromStorage();
      }
      contactTypePromise.then((contactTypeDetail) => {
            this.myRequest = {
              ...this.myRequest,
              ...contactTypeDetail
            }
      })
      if (authService.isUserLogin()) {
        accountSettingService.getUserAccountSetting().then((contactTypeDetail) => {
              this.myRequest = {
                ...this.myRequest,
                ...contactTypeDetail
              }
        })
      }
    }
@@ -400,20 +420,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,21 +452,36 @@
    ////////////////////////////////////////////////////////////////////////////
    sentDemand() {
      if (this.isEditBtn) {
        this.editAppointmentDemand();
    async sentDemand() {
      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) {
          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 {
        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,
        await this.editAppointmentDemand();
      }
      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() {