保誠-保戶業務員媒合平台
wayne
2022-02-17 4394e4248455637ab7836756058ac872fdf4af10
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<template>
    <div>
        <div class="interview__header">
            <div class="mdTxt">約訪紀錄</div>
            <div class="pam-link-button"
            @click="addInterview">+新增</div>
        </div>
 
        <InterviewCard :interviewList="displayAppointmentList"></InterviewCard>
 
        <section class="text--right mt-30 interview-check-more" v-if="interviewList.length > 3">
                <div class="pam-link-button" @click="readAllList = !readAllList">
                  {{ readAllList ?  '顯示較少' : '展開看更多' }}
                  <i :class="readAllList ? 'icon-top' : 'icon-down'"></i>
                  </div>
        </section>
    </div>
</template>
 
<script lang="ts">
import { Vue, Component, Prop, Watch, namespace } from 'nuxt-property-decorator';
 
import { InterviewRecord } from '~/shared/models/appointment.model';
 
@Component
export default class AppointmentInterviewList extends Vue {
 
  @Prop()
  interviewList!: InterviewRecord[];
 
  appointmentId!: string;
  displayList: InterviewRecord[] = [];
  readAllList = false;
 
  get displayAppointmentList(): InterviewRecord[] {
    return this.readAllList ? this.displayList : this.displayList.slice(0, 3);
  }
 
 
  //////////////////////////////////////////////////////////////////////
 
  mounted() {
      this.appointmentId = this.$route.params.appointmentId;
  }
 
  //////////////////////////////////////////////////////////////////////
 
  @Watch('interviewList', {immediate: true})
  updateInterviewList() {
      if (this.interviewList && this.interviewList.length > 0) {
          this.displayList = this.interviewList
            .map((i) => ({ ...i, sortDate: new Date(i.interviewDate)}))
            .sort((preItem, nextItem) => +nextItem.sortDate - +preItem.sortDate);
      }
  }
 
  //////////////////////////////////////////////////////////////////////
 
  addInterview(): void {
    this.$router.push(`/appointment/${this.appointmentId}/interview/new`);
  }
 
}
</script>
 
<style lang="scss" scoped>
.interview__header {
  display        : flex;
  justify-content: space-between;
  margin-bottom  : 10px;
}
.interview-check-more{
  display: flex;
  justify-content: center;
}
</style>