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);
|
}
|
|
}
|