From abfd26bb700d93a92da6a04703b0187d4acaaeb5 Mon Sep 17 00:00:00 2001 From: Tomas <tomasysh@gmail.com> Date: 星期三, 22 十二月 2021 10:13:02 +0800 Subject: [PATCH] refactor: move ts folder to shared folder --- PAMapp/pages/myAppointmentList/contactedList.vue | 41 +++++++++++++++++++++++++---------------- 1 files changed, 25 insertions(+), 16 deletions(-) diff --git a/PAMapp/pages/myAppointmentList/contactedList.vue b/PAMapp/pages/myAppointmentList/contactedList.vue index 15954b7..92ecd84 100644 --- a/PAMapp/pages/myAppointmentList/contactedList.vue +++ b/PAMapp/pages/myAppointmentList/contactedList.vue @@ -28,37 +28,46 @@ <script lang="ts"> import { Vue, Component, Watch, State } from 'nuxt-property-decorator'; -import { ClientInfo } from '~/assets/ts/api/appointment'; + +import { ClientInfo } from '~/shared/models/client.model'; @Component export default class ClientContactedList extends Vue { - @State('myAppointmentList') myAppointmentList!: ClientInfo[]; + + @State('myAppointmentList') + myAppointmentList!: ClientInfo[]; + + @Watch('myAppointmentList') + onMyAppointmentListChange() { + this.contactedList = (this.myAppointmentList || []) + .filter(item => item.communicateStatus === 'contacted') + .map((item) => ({...item, sortTime: new Date(item.contactTime)})) + .sort((prevItem, nextItem) => +nextItem - +prevItem); + this.filterList = this.contactedList; + } contactedList: ClientInfo[] = []; pageList: ClientInfo[] = []; keyWord: string = ''; filterList: ClientInfo[] = []; - @Watch('myAppointmentList') - onMyAppointmentListChange() { - this.contactedList = (this.myAppointmentList || []) - .filter(item => item.communicateStatus === 'contacted') - .sort((a, b) => a.contactTime > b.contactTime ? -1 : 1); - this.filterList = this.contactedList; - } + ////////////////////////////////////////////////////////////////////// mounted() { this.onMyAppointmentListChange(); } - changePage(pageList: ClientInfo[]) { + ////////////////////////////////////////////////////////////////////// + + search(): void { + this.filterList = this.contactedList.filter(item => { + return item?.name?.match(this.keyWord) || item?.requirement?.match(this.keyWord) + }) + } + + changePage(pageList: ClientInfo[]): void { this.pageList = pageList; } - search() { - this.filterList = this.contactedList.filter(item => { - return item.name.match(this.keyWord) || item.requirement.match(this.keyWord) - }) - } } -</script> \ No newline at end of file +</script> -- Gitblit v1.8.0