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/appointmentList.vue | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 36 insertions(+), 14 deletions(-) diff --git a/PAMapp/pages/myAppointmentList/appointmentList.vue b/PAMapp/pages/myAppointmentList/appointmentList.vue index 370dad2..617b4fb 100644 --- a/PAMapp/pages/myAppointmentList/appointmentList.vue +++ b/PAMapp/pages/myAppointmentList/appointmentList.vue @@ -5,6 +5,7 @@ placeholder="隢撓���摮�" class="mb-30 pam-clientReserved-input" v-model="keyWord" + @keyup.enter.native="search" > <i slot="suffix" class="icon-search search cursor--pointer" @click="search"></i> </el-input> @@ -15,45 +16,66 @@ ></ClientList> <UiPagination - :totalList="appointmentList" + :totalList="filterList" @changePage="changePage" ></UiPagination> </div> </template> <script lang="ts"> -import { Vue, Component, Prop, State, Watch } from 'nuxt-property-decorator'; -import { ClientInfo } from '~/assets/ts/api/appointment'; +import { Vue, Component, State, Watch } from 'nuxt-property-decorator'; + +import { ClientInfo } from '~/shared/models/client.model'; @Component export default class ClientReservedList extends Vue { - @State('myAppointmentList') myAppointmentList!: ClientInfo[]; + + @State('myAppointmentList') + myAppointmentList!: ClientInfo[]; appointmentList: ClientInfo[] = []; pageList: ClientInfo[] = []; keyWord: string = ''; filterList: ClientInfo[] = []; - @Watch('myAppointmentList') - onMyAppointmentListChange() { - this.appointmentList = this.myAppointmentList - .filter(item => item.communicateStatus !== 'contacted') - .sort((a, b) => a.appointmentDate > b.appointmentDate ? -1 : 1);; - } + ////////////////////////////////////////////////////////////////////// mounted() { this.onMyAppointmentListChange(); } - changePage(pageList: ClientInfo[]) { - this.pageList = pageList; + ////////////////////////////////////////////////////////////////////// + + @Watch('myAppointmentList') + onMyAppointmentListChange(): void { + const unViewList = this.myAppointmentList + .filter((item) => item.communicateStatus !== 'contacted' && !item.consultantViewTime) + .map((item) => ({ ...item, sortTime: new Date(item.appointmentDate)})) + .sort((preItem, nextItem) => +nextItem.sortTime - +preItem.sortTime); + + const tempViewList = this.myAppointmentList + .filter(item => item.communicateStatus !== 'contacted' && item.consultantViewTime); + + // TODO: 敺������� unreadList ��蝝啁溶�������隢�垢����靘������ createTime嚗�Tomas, 2021/12/16];疇 + const unreadList = tempViewList.filter((item) => !item.consultantReadTime); + const readList = tempViewList + .filter((item) => item.consultantReadTime) + .map((item) => ({ ...item, sortTime: new Date(item.consultantReadTime)})) + .sort((preItem, nextItem) => +nextItem - +preItem); + + this.appointmentList = [...unViewList, ...unreadList, ...readList]; + this.filterList = this.appointmentList; } - search() { + search(): void { this.filterList = this.appointmentList.filter(item => { return item.name.match(this.keyWord) || item.requirement.match(this.keyWord) }) } + changePage(pageList: ClientInfo[]): void { + this.pageList = pageList; + } + } -</script> \ No newline at end of file +</script> -- Gitblit v1.8.0