保誠-保戶業務員媒合平台
Tomas
2024-04-30 b4d6944076f1df6eedaae35c4c2a7072fe988e8a
PAMapp/components/Client/ClientCard.vue
@@ -54,7 +54,6 @@
                ></el-avatar>
                <div class="satisfaction" v-if="!hideReviews">
                    <template v-if="client.satisfactionScore">
                        TODO:隱藏滿意度
                        <i class="icon-star pam-icon icon--yellow satisfaction"></i>
                        <span>{{client.satisfactionScore}}</span>
                    </template>
@@ -78,12 +77,12 @@
                  v-else-if="client.communicateStatus === contactStatus.CONTACTED">
                  結案
                </div>
                <div
                <!-- <div
                  class="invite-msg smTxt_bold"
                  @click.stop="inviteReview"
                  v-else-if="!client.satisfactionScore">
                  發送滿意度
                </div>
                </div> -->
                <div
                    class="date xsTxt text--black"
@@ -119,7 +118,8 @@
                <p>性別:<span>{{gender}}</span></p>
                <p>年齡:<span>{{client.age | toAgeLabel }}</span></p>
                <p>職業:<span>{{client.job}}</span></p>
                <p>需求:<span>{{client.requirement.split(',').join('、')}}</span></p>
                <p>諮詢方式:<span>{{client.consultationMethod | toConsultationMethod }}</span></p>
                <p>需求:<span>{{ client.requirement ? client.requirement.split(',').join('、') : '--' }}</span></p>
                <p v-for="(item, index) in hopeContactTime"
                    :key="index"
                >連絡時段{{index + 1 | formatNumber}}:<span>{{ item | formatHopeContactTime}}</span></p>
@@ -170,17 +170,20 @@
</template>
<script lang="ts">
import { Vue, Component, Prop, Action, namespace, Watch } from 'nuxt-property-decorator';
import { Vue, Component, Prop, namespace, Watch } from 'nuxt-property-decorator';
import appointmentService from '~/shared/services/appointment.service';
import myConsultantService from '~/shared/services/my-consultant.service';
import UtilsService from '~/shared/services/utils.service';
import { hideReviews } from '~/shared/const/hide-reviews';
import { ElRow } from 'element-ui/types/row';
import { Appointment, AppointmentMemoInfo, ToInformAppointment } from '~/shared/models/appointment.model';
import { Appointment, AppointmentMemoInfo } from '~/shared/models/appointment.model';
import { ContactStatus } from '~/shared/models/enum/contact-status';
import reviewsService from '~/shared/services/reviews.service';
const localStorage = namespace('localStorage');
const appointmentStore = namespace('appointment.store');
const localStorage     = namespace('localStorage');
@Component({
    filters: {
        formatNumber(index: number) {
@@ -201,11 +204,20 @@
    }
})
export default class ClientList extends Vue {
    @Action
    updateMyAppointment!: (data: Appointment) => void;
    @Prop()
    client!: Appointment;
    @appointmentStore.Action
    updateMyAppointmentList!: (data: Appointment) => void;
    @appointmentStore.Action
    getAppointmentDetail!: (appointmentId: number) => Promise<Appointment>;
    @appointmentStore.Action
    updateAppointmentDetail!: (id: number) => Appointment;
    @appointmentStore.Getter
    appointmentProgress!: ContactStatus;
    @localStorage.Mutation
    storageClearAppointmentIdFromMsg!: () => void;
@@ -248,7 +260,13 @@
    //////////////////////////////////////////////////////////////////////
    viewAppointmentDetail(): void {
      this.$router.push(`/appointment/${this.client.id}`);
      this.getAppointmentDetail(this.client.id).then((_) => {
        const unread = !this.client.consultantReadTime;
        if (unread) {
          this.readAppointment();
        }
        this.$router.push(`/appointment/${this.client.id}`);
      });
    }
    showAddInterviewDialog(): void {
@@ -256,15 +274,15 @@
    }
    navigateToCloseAppointment(): void {
      this.$router.push(`/appointment/${this.client.id}/close`);
    }
    makeAppointment(): void {
      alert('MAKE AN APPOINTMENT!');
      this.getAppointmentDetail(this.client.id).then((_) => {
        this.$router.push(`/appointment/${this.client.id}/close`);
      });
    }
    inviteReview(): void {
      this.isShowInviteReviewDialog = true ;
        reviewsService.sendSatisfactionToClient(this.client.id).then(res => {
            this.isShowInviteReviewDialog = true ;
        })
    }
    openDetail() {
@@ -277,23 +295,35 @@
    markAppointment() {
        myConsultantService.markAsContact(this.client.id).then(data => {
            this.updateMyAppointment(data);
            this.updateMyAppointmentList(data);
            this.isShowInformDialog = false;
        })
    }
    closeInformDialog(): void {
      const unread = !this.client.consultantReadTime;
        if (unread) {
            appointmentService.recordRead(this.client.id).then((_) => {
                const updatedClient = {...this.client};
                updatedClient.consultantReadTime = new Date().toString();
                this.updateMyAppointment(updatedClient);
            });
        };
        this.readAppointment();
        this.isEdit = false;
        this.clearAppointmentIdFromMsg();
    }
  private async readAppointment(): Promise<void> {
    try {
      const response = await appointmentService.recordRead(this.client.id);
      if (response !== null) {
        const updatedClient = { ...this.client };
        updatedClient.consultantReadTime = new Date().toString();
        this.updateMyAppointmentList(updatedClient);
        this.updateAppointmentDetail(this.client.id);
      } else {
        throw new Error('appointmentService.recordRead returned null-like value.');
      }
    } catch (error) {
      console.error('An error occurred while reading appointment:', error);
      // 可以在此處處理錯誤或回傳預設值
      throw error;
    }
  }
    private clearAppointmentIdFromMsg() {
        this.storageClearAppointmentIdFromMsg();
@@ -349,7 +379,7 @@
        this.memo = this.memoInfo.content;
    }
      get newAppointment(): boolean {
    get newAppointment(): boolean {
      return !this.client.consultantViewTime
            && this.client.communicateStatus === 'reserved';
    }
@@ -363,7 +393,7 @@
    }
    get requirements() {
        return this.client.requirement.split(',');
        return this.client.requirement ? this.client.requirement.split(',') : [];
    }
    get gender() {
@@ -445,10 +475,14 @@
        .professionals {
            overflow     : hidden;
            text-overflow: ellipsis;
            white-space  : nowrap;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            .professionalsTxt {
                font-size   : 12px;
                margin-right: 5px;
            }
            .noProfessionalsTxt {
                color      : $PRUDENTIAL_GREY;
@@ -496,6 +530,7 @@
        display: flex;
    }
    .invite-msg{
      width: 96px;
      color: $PRIMARY_RED;
      @extend .text--underline;
    }