| | |
| | | |
| | | <UiPagination |
| | | :totalList="filterList" |
| | | :currentPage="currentPage" |
| | | @changePage="changePage" |
| | | ></UiPagination> |
| | | </div> |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component, Watch, State } from 'nuxt-property-decorator'; |
| | | import { Vue, Component, Watch, State, namespace } from 'nuxt-property-decorator'; |
| | | |
| | | import { ClientInfo } from '~/shared/models/client.model'; |
| | | import { Appointment } from '~/shared/models/appointment.model'; |
| | | |
| | | |
| | | const localStorage = namespace('localStorage'); |
| | | @Component |
| | | export default class ClientContactedList extends Vue { |
| | | |
| | | @State('myAppointmentList') |
| | | myAppointmentList!: ClientInfo[]; |
| | | myAppointmentList!: Appointment[]; |
| | | |
| | | @localStorage.Getter |
| | | currentAppointmentIdFromMsg!: string; |
| | | |
| | | contactedList: Appointment[] = []; |
| | | filterList : Appointment[] = []; |
| | | keyWord : string = ''; |
| | | pageList : Appointment[] = []; |
| | | currentPage : number = 1; |
| | | |
| | | ////////////////////////////////////////////////////////////////////// |
| | | |
| | | mounted() { |
| | | this.onMyAppointmentListChange(); |
| | | } |
| | | |
| | | ////////////////////////////////////////////////////////////////////// |
| | | |
| | | @Watch('myAppointmentList') |
| | | onMyAppointmentListChange() { |
| | |
| | | .map((item) => ({...item, sortTime: new Date(item.contactTime)})) |
| | | .sort((prevItem, nextItem) => +nextItem.sortTime - +prevItem.sortTime); |
| | | this.filterList = this.contactedList; |
| | | |
| | | this.getCurrentPage(); |
| | | } |
| | | |
| | | contactedList: ClientInfo[] = []; |
| | | filterList : ClientInfo[] = []; |
| | | keyWord : string = ''; |
| | | pageList : ClientInfo[] = []; |
| | | |
| | | ////////////////////////////////////////////////////////////////////// |
| | | |
| | | mounted() { |
| | | this.onMyAppointmentListChange(); |
| | | private getCurrentPage() { |
| | | const currentIndex = this.filterList.findIndex(item => item.id === +this.currentAppointmentIdFromMsg); |
| | | const pageSize = 5; |
| | | if (currentIndex > -1) { |
| | | this.currentPage = Math.ceil((currentIndex + 1) / pageSize); |
| | | } |
| | | } |
| | | |
| | | ////////////////////////////////////////////////////////////////////// |
| | |
| | | }) |
| | | } |
| | | |
| | | changePage(pageList: ClientInfo[]): void { |
| | | changePage(pageList: Appointment[]): void { |
| | | this.pageList = pageList; |
| | | } |
| | | |