保誠-保戶業務員媒合平台
Mila
2022-01-20 1d6d2d14200ed9432347ef8013e3fc117fa2161b
PAMapp/pages/index.vue
@@ -2,15 +2,15 @@
  <div>
    <Ui-Carousel></Ui-Carousel>
    <div class="page-container">
      <div class="mb-30">
      <div>
        <h5 class="mdTxt">預約保險顧問</h5>
        <div class="mt-10 pam-reserveBtn--block">
          <el-button class="reserveBtn recommendConsultant"
            @click="routerPush('/recommendConsultant')">
            @click="navigateToRoute('/recommendConsultant')">
            <p>嚴選配對</p>
          </el-button>
          <el-button class="reserveBtn quickFilter"
            @click="routerPush('/quickFilter')">
            @click="navigateToRoute('/quickFilter')">
            <p>快速篩選</p>
          </el-button>
        </div>
@@ -19,12 +19,12 @@
        <el-row class="rowStyle">
          <el-col :span="16">
            <span class="mdTxt">我的顧問清單</span>
            <span class="smTxt_bold amount">共 {{consultantList.length}} 筆</span>
            <span class="smTxt_bold amount">共 {{ consultantList.length }} 筆</span>
          </el-col>
          <el-col :span="8"
            class="mdTxt readMore fix-chrome-click--issue"
            v-if="consultantList.length > 3"
            @click.native="routerPush('/myConsultantList/consultantList')">查看更多</el-col>
            @click.native="navigateToRoute('/myConsultantList/consultantList')">查看更多</el-col>
        </el-row>
        <ConsultantList class="mt-10"
          :agents="consultantList.slice(0, 3)"></ConsultantList>
@@ -39,36 +39,157 @@
        <ConsultantSwiper :agents="recommendList"></ConsultantSwiper>
      </div>
    </div>
    <Ui-Dialog
        :isVisible.sync="isVisibleDialog"
        :width="width"
        class="pam-myDemand-dialog pam-dialog-reserved"
        @closeDialog="clearSatisfactionId"
      >
        <div v-if="appointmentDetail">
            <h5 class="subTitle text--center mb-30">預約成功</h5>
            <p class="smTxt">{{appointmentDetail.appointmentDate | formatDate}}</p>
            <div class="reserved-info">
                <p>姓名:{{appointmentDetail.name}}</p>
                <p>電話:{{appointmentDetail.phone}}</p>
                <p>Email:{{appointmentDetail.email}}</p>
                <p>性別:{{gender}}</p>
                <p>年齡:{{appointmentDetail.age | toAgeLabel }}</p>
                <p>職業:{{appointmentDetail.job}}</p>
                <p>需求:{{appointmentDetail.requirement.split(',').join('、')}}</p>
                <p
                    v-for="(item, index) in hopeContactTime"
                    :key="index"
                >連絡時段{{index + 1 | formatNumber}}:{{ item | formatHopeContactTime }}</p>
                <div v-if="appointmentDetail.satisfactionScore">
                    <div class="mdTxt mt-10 mb-10">滿意度</div>
                    <el-rate
                    :value="appointmentDetail.satisfactionScore"
                    class="pam-myDemand-dialog__rate"
                    disabled>
                    </el-rate>
                </div>
            </div>
            <div v-if="!appointmentDetail.satisfactionScore" class="reserved-btn">
                <el-button type="primary"
                    @click.native="reviewsBtn = true">給予滿意度評分</el-button>
            </div>
        </div>
      </Ui-Dialog>
      <PopUpFrame
        :isOpen.sync="reviewsBtn"
        @closePopUp="clearSatisfactionId"
      >
          <div class="mdTxt pam-dialog-review">
              保險顧問滿意度
              <span class="hint">選取星星</span>
              <div class="mt-30 review-content" v-if="agentInfo">
                  <UiAvatar :size="80" :agentNo="agentInfo.agentNo"></UiAvatar>
                  <div class="review-text">對於顧問
                      <span class="text--primary">{{agentInfo.name}}</span>
                      的整體服務,您給予幾顆星評價?
                  </div>
              </div>
              <div class="review-score">
                  <el-rate v-model="inputScore" class="pam-rate mt-30"></el-rate>
              </div>
              <div class="review-btn">
                  <el-button
                      type="primary"
                      :disabled="!inputScore"
                      @click="userReviewsConsultants">送出</el-button>
              </div>
          </div>
      </PopUpFrame>
  </div>
</template>
<script lang="ts">
  import { Vue, Component, State, Action, Watch, namespace } from 'nuxt-property-decorator';
  import { Consultant } from '~/assets/ts/models/consultant.model';
  import { Consultant } from '~/shared/models/consultant.model';
import { UserReviewsConsultantsParams } from '~/shared/models/reviews.model';
  import appointmentService from '~/shared/services/appointment.service';
import reviewsService from '~/shared/services/reviews.service';
  import UtilsService from '~/shared/services/utils.service';
  const localStorage = namespace('localStorage');
  @Component({
    layout: 'home'
  })
  export default class MainComponent extends Vue {
    consultantList: Consultant[] = [];
    @State('recommendList') recommendList!: Consultant[];
    @Action storeRecommendList!: any;
    @State('recommendList')
    recommendList!: Consultant[];
    @State('myConsultantList') myConsultantList!: Consultant[];
    @State('myConsultantList')
    myConsultantList!: Consultant[];
    @Action
    storeRecommendList!: any;
    @Action storeConsultantList!: any;
    @localStorage.Mutation storageClearQuickFilter!: () => void;
    @localStorage.Mutation storageClearRecommendConsultant!: () => void;
    @localStorage.Mutation
    storageClearQuickFilter!: () => void;
    @Watch('myConsultantList')
    onMyConsultantListChange() {
      this.consultantList = (this.myConsultantList || [])
        .filter(item => item.contactStatus !== 'contacted')
        .map((item) => ({ ...item, formatDate: new Date(item.updateTime || item.createTime)}))
        .sort((preItem, nextItem) => +nextItem.formatDate - +preItem.formatDate)
    }
    @localStorage.Mutation
    storageClearRecommendConsultant!: () => void;
    @localStorage.Getter
    currentSatisfactionIdFromMsg!: string;
    @localStorage.Mutation
    storageClearSatisfactionIdFromMsg!: () => void;
    consultantList: Consultant[] = [];
    appointmentDetail: any = {
        age               : '',
        agentNo           : '',
        appointmentDate   : '',
        communicateStatus : '',
        consultantReadTime: null,
        consultantViewTime: null,
        contactTime       : '',
        contactType       : '',
        customerId        : 0,
        email             : '',
        gender            : '',
        hopeContactTime   : "",
        id                : 0,
        job               : "",
        lastModifiedDate  : '',
        name              : '',
        otherRequirement  : null,
        phone             : "",
        requirement       : '',
        satisfactionScore : 0,
    };
    isVisibleDialog = false;
    width = '';
    reviewsBtn = false;
    inputScore = 0;
    agentInfo: Consultant = {
      agentNo            : '',
      name               : '',
      img                : '',
      expertise          : [],
      avgScore           : 0,
      contactStatus      : '',
      createTime         : '',
      updateTime         : '',
      customerViewTime   : '',
      role               : '',
      seniority          : '',
      appointments       : []
    };
    //////////////////////////////////////////////////////////////////////
    mounted() {
      if (!this.recommendList?.length) {
@@ -80,8 +201,82 @@
      this.storageClearRecommendConsultant();
    }
    routerPush(path: string) {
    destroyed() {
      this.clearSatisfactionId();
    }
    //////////////////////////////////////////////////////////////////////
    @Watch('myConsultantList')
    onMyConsultantListChange() {
      this.consultantList = (this.myConsultantList || [])
        .filter(item => item.contactStatus !== 'contacted')
        .map((item) => ({ ...item, formatDate: new Date(item.updateTime || item.createTime)}))
        .sort((preItem, nextItem) => +nextItem.formatDate - +preItem.formatDate);
      if (this.currentSatisfactionIdFromMsg) {
        this.agentInfo = this.myConsultantList.filter(item => {
          const satisfactionIdIndex = item.appointments?.findIndex(i => i.id === +this.currentSatisfactionIdFromMsg);
          return satisfactionIdIndex !== undefined && satisfactionIdIndex > -1;
        })[0];
        if (this.agentInfo) {
          this.openAppointmentInfo();
        }
      }
    }
    private openAppointmentInfo() {
        appointmentService.getAppointmentDetail(+this.currentSatisfactionIdFromMsg).then(res => {
            this.appointmentDetail = res;
            this.width = UtilsService.isMobileDevice() ? '80%' : '';
            this.isVisibleDialog = true;
            if (!this.appointmentDetail.satisfactionScore) {
              setTimeout(() => {
                this.reviewsBtn = true;
              }, 500)
            }
        });
    }
    //////////////////////////////////////////////////////////////////////
    navigateToRoute(path: string): void {
      this.$router.push(path);
    }
    userReviewsConsultants() {
      const reviewParams: UserReviewsConsultantsParams = {
            appointmentId: this.appointmentDetail.id,
            score: this.inputScore,
        }
        this.appointmentDetail.satisfactionScore = this.inputScore;
        reviewsService.userReviewsConsultants(reviewParams).then((res) => {
            this.reviewsBtn = false;
        });
    }
    clearSatisfactionId() {
        console.log('close');
        this.$router.push({query: {}});
        this.storageClearSatisfactionIdFromMsg();
    }
    ///////////////////////////////////////////////////////////////////////////////
    get gender() {
        if (this.appointmentDetail.gender) {
            return this.appointmentDetail.gender === 'male' ? '男性' : '女性';
        }
        return ''
    }
    get hopeContactTime() {
        const contactList = this.appointmentDetail.hopeContactTime
            .split("'").map((item: any) => item.slice(0, item.length));
        return contactList.filter((item: any) => !!item && item !== ",")
    }
  }
@@ -94,19 +289,19 @@
  }
  .reserveBtn.el-button--default {
    width: 100%;
    height: 110px;
    border-radius: 10px;
    margin-bottom: 15px;
    font-size: 32px;
    font-weight: 700;
    width              : 100%;
    height             : 110px;
    border-radius      : 10px;
    margin-bottom      : 15px;
    font-size          : 32px;
    font-weight        : 700;
    background-position: right;
    background-size: cover;
    color: #68737A;
    text-align: left;
    background-repeat: no-repeat;
    box-shadow: 0px 0px 6px #a79b9b29;
    border-width: 0;
    background-size    : cover;
    color              : #68737A;
    text-align         : left;
    background-repeat  : no-repeat;
    box-shadow         : 0px 0px 6px #a79b9b29;
    border-width       : 0;
    p {
      text-shadow: 1px 1px 5px $PRIMARY_WHITE;
@@ -166,5 +361,4 @@
      max-width: 335px;
    }
  }
</style>