保誠-保戶業務員媒合平台
Tomas
2021-12-08 b6661a090e8bcf8f45be24a01b6a7bb08e3aaff1
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
import { Vue, Component, State, Watch } from 'nuxt-property-decorator';
import { ClientInfo } from '~/assets/ts/api/appointment';
 
@Component
export default class ClientReservedList extends Vue {
    @State('myAppointmentList') myAppointmentList!: ClientInfo[];
 
    appointmentList: ClientInfo[] = [];
    pageList: ClientInfo[] = [];
    keyWord: string = '';
    filterList: ClientInfo[] = [];
 
    @Watch('myAppointmentList')
    onMyAppointmentListChange() {
        const unreadList = this.myAppointmentList
            .filter(item => item.communicateStatus !== 'contacted' && !item.consultantReadTime)
            .sort((a, b) => a.appointmentDate > b.appointmentDate ? -1 : 1);
 
        const readList = this.myAppointmentList
            .filter(item => item.communicateStatus !== 'contacted' && item.consultantReadTime)
            .sort((a, b) => a.consultantReadTime > b.consultantReadTime ? -1 : 1)
 
        this.appointmentList = unreadList.concat(readList);
        this.filterList = this.appointmentList;
    }
 
    mounted() {
        this.onMyAppointmentListChange();
    }
 
    changePage(pageList: ClientInfo[]) {
        this.pageList = pageList;
    }
 
    search() {
        this.filterList = this.appointmentList.filter(item => {
            return item.name.match(this.keyWord) || item.requirement.match(this.keyWord)
        })
    }
 
}