保誠-保戶業務員媒合平台
wayne
2022-02-17 4394e4248455637ab7836756058ac872fdf4af10
PAMapp/pages/satisfactionList.vue
@@ -4,46 +4,116 @@
    <div class="pam-container">
      <div class="satisfaction-title">
        <span class="mdTxt">滿意度調查</span>
        <span class="ml-10 text--prudential_grey smTxt_bold">共 {{satisfactionList.length}} 筆</span>
        <span class="ml-10 text--prudential_grey smTxt_bold">共 {{mapUnReviewLogList.length}} 筆</span>
      </div>
      <div class="satisfaction-card" v-for="(item, index) in satisfactionList" :key="index">
        <div class="satisfaction-card-content">
          <UiAvatar :size="80" :agentNo="''"></UiAvatar>
          <div class="satisfaction-card-text">對於顧問
              <span class="text--primary text--bold">{{item.agentName}}</span>
              的整體服務,您給予幾顆星評價?
      <template v-if="mapUnReviewLogList.length">
        <div class="satisfaction-card" v-for="(item, index) in mapUnReviewLogList" :key="index">
          <div class="satisfaction-card-content"  v-if="item.agentName">
            <UiAvatar :size="80" :agentNo="item.agentNo"></UiAvatar>
            <div class="satisfaction-card-text">對於顧問
                <span class="text--primary text--bold">{{item.agentName}}</span>
                的整體服務,您給予幾顆星評價?
            </div>
          </div>
           <div class="satisfaction-card-content"  v-else>
            <div class="pam-satisfaction-avatar">
              <span class="pam-satisfaction-avatar-txt">平台</span>
              </div>
            <div class="satisfaction-card-text" >對於
                <span class="text--primary text--bold">服務媒合</span>
                平台的整體服務,您給予幾顆星評價?
            </div>
          </div>
          <el-rate
            v-model="item.satisfaction"
            class="pam-satisfaction-rate mt-10 fix-chrome-click--issue"
            @change="isBtnDisabled = false"
          ></el-rate>
        </div>
        <el-rate v-model="item.score" class="pam-satisfaction-rate mt-10"></el-rate>
      </div>
      <div class="text--center mt-30">
        <el-button type="primary" :disabled="isBtnDisabled">送出</el-button>
      </div>
        <div class="text--center mt-30" v-if="mapUnReviewLogList.length">
          <el-button type="primary" :disabled="isBtnDisabled" @click="sent">送出</el-button>
        </div>
      </template>
      <template v-else>
         <div class="satisfaction-card">
          <div class="satisfaction-card-content">
            目前暫無需要您填寫的滿意度調查
          </div>
         </div>
      </template>
    </div>
    <PopUpFrame :isOpen.sync="showConfirmPopup"
        @closePopUp="closePopup">
        <div class="text--center mdTxt">發送成功</div>
        <div class="text--center mt-30">
            <el-button @click="closePopup" type="primary">確定</el-button>
        </div>
      </PopUpFrame>
  </div>
</template>
<script>
import { Vue, Component } from 'nuxt-property-decorator';
<script lang="ts">
import { Vue, Component, Action, State, Watch } from 'nuxt-property-decorator';
import reviewsService from '~/shared/services/reviews.service';
import { AppointmentLog } from '~/shared/models/appointment.model';
import { UserReviewParams } from '~/shared/models/reviews.model';
@Component({
  layout: 'home'
})
export default class MySatisfactionList extends Vue {
  satisfactionList = [
    {
      agentName: '蔡美眉',
      score: 0
    },
    {
      agentName: '蔡美眉',
      score: 0
    }
  ]
  get isBtnDisabled() {
    return this.satisfactionList.findIndex(item => item.score > 0) === -1;
  @State
  unReviewLogList!: AppointmentLog[];
  @Action
  storeMyAppointmentReviewLog!: () => void;
  mapUnReviewLogList: AppointmentReviewLog[] = [];
  showConfirmPopup = false;
  isBtnDisabled = true;
  ///////////////////////////////////////////////////////
  @Watch('unReviewLogList')
  onUnReviewLogListChange() {
      this.mapUnReviewLogList = this.unReviewLogList.map(item => {
        return {
          ...item,
          satisfaction: 0
        }
      })
  }
  ///////////////////////////////////////////////////////
  sent() {
    const reviewParams: UserReviewParams[] = this.mapUnReviewLogList
                .filter(item => item.satisfaction > 0)
                .map(item => {
                  return {
                    appointmentId: item.appointmentId,
                    score: item.satisfaction,
                    type: item.type
                  }
                })
        reviewsService.allUserReviewsConsultants(reviewParams).then((res) => {
            this.showConfirmPopup = true;
        });
  }
  closePopup() {
    this.showConfirmPopup = false;
    this.storeMyAppointmentReviewLog();
  }
}
interface AppointmentReviewLog extends AppointmentLog {
  satisfaction: number;
}
</script>
@@ -88,6 +158,19 @@
      font-size: 20px;
      padding-left: 10px;
    }
    .pam-satisfaction-avatar{
      height: 80px;
      width: 80px;
      border-radius: 50%;
      background-color:#F09491;
      justify-content: center;
      align-items: center;
      display: flex;
      .pam-satisfaction-avatar-txt{
        font-size: 18px;
        color: #fff;
      }
    }
    @include desktop {
        justify-content: flex-start;
@@ -99,4 +182,4 @@
  }
}
</style>
</style>