保誠-保戶業務員媒合平台
Tomas
2021-12-09 26dbfaafa064ee79fd4d07aed8e8fa15ec737c46
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
import { Vue, Component, Watch, State, Action } from 'nuxt-property-decorator';
import { Consultant } from '~/assets/ts/models/consultant.model';
 
@Component
export default class myConsultantList extends Vue {
    activeTabName = 'consultantList';
    contactedList: Consultant[] = [];
    consultantList: Consultant[] = [];
 
    @State('myConsultantList') myConsultantList!: Consultant[];
    @Action storeConsultantList!: any;
 
    @Watch('myConsultantList')
    onMyConsultantListChange() {
      this.filterContactedList();
    }
 
    beforeRouteEnter(to: any, from: any, next: any) {
      next((vm: any) => {
        if (to.name === 'myConsultantList') {
            vm.$router.push('/myConsultantList/consultantList');
          return;
        }
      })
    }
 
    mounted() {
        this.storeConsultantList();
 
        if (this.$route.name) {
         this.activeTabName = this.$route.name.split('-')[1]
        }
    }
 
    tabClick(path: string) {
      this.activeTabName = path;
      this.$router.push('/myConsultantList/' + this.activeTabName)
    }
 
    filterContactedList() {
 
        this.consultantList = (this.myConsultantList || [])
                .filter((item) => item.contactStatus !== 'contacted')
                .map((item) => {
                  return {
                    ...item,
                    formatDate: new Date(item.updateTime)
                  }
                })
                .sort((previousItem, nextItem) => +nextItem.formatDate - +previousItem.formatDate);
 
        this.contactedList = (this.myConsultantList || [])
                .filter(item => item.contactStatus === 'contacted')
                .map((item) => {
                  return {
                    ...item,
                    formatDate: new Date(item.updateTime)
                  }
                })
                .sort((a, b) => +a.formatDate - +b.formatDate);
    }
 
}