| | |
| | | placeholder="請輸入關鍵字" |
| | | class="mb-30 pam-clientReserved-input" |
| | | v-model="keyWord" |
| | | @keyup.enter.native="search" |
| | | > |
| | | <i |
| | | slot="suffix" |
| | |
| | | ></ClientList> |
| | | |
| | | <UiPagination |
| | | :totalList="contactedList" |
| | | :totalList="filterList" |
| | | :currentPage="currentPage" |
| | | @changePage="changePage" |
| | | ></UiPagination> |
| | | </div> |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component, Watch, State } from 'nuxt-property-decorator'; |
| | | import { ClientInfo } from '~/assets/ts/api/appointment'; |
| | | import { Vue, Component, Watch, State, namespace } from 'nuxt-property-decorator'; |
| | | |
| | | import { ClientInfo } from '~/shared/models/client.model'; |
| | | |
| | | const localStorage = namespace('localStorage'); |
| | | @Component |
| | | export default class ClientContactedList extends Vue { |
| | | @State('myAppointmentList') myAppointmentList!: ClientInfo[]; |
| | | |
| | | @State('myAppointmentList') |
| | | myAppointmentList!: ClientInfo[]; |
| | | |
| | | @localStorage.Getter |
| | | currentAppointmentIdFromMsg!: string; |
| | | |
| | | contactedList: ClientInfo[] = []; |
| | | pageList: ClientInfo[] = []; |
| | | keyWord: string = ''; |
| | | filterList: ClientInfo[] = []; |
| | | filterList : ClientInfo[] = []; |
| | | keyWord : string = ''; |
| | | pageList : ClientInfo[] = []; |
| | | currentPage : number = 1; |
| | | |
| | | ////////////////////////////////////////////////////////////////////// |
| | | |
| | | mounted() { |
| | | this.onMyAppointmentListChange(); |
| | | } |
| | | |
| | | ////////////////////////////////////////////////////////////////////// |
| | | |
| | | @Watch('myAppointmentList') |
| | | onMyAppointmentListChange() { |
| | | this.contactedList = (this.myAppointmentList || []) |
| | | .filter(item => item.communicateStatus === 'contacted') |
| | | .sort((a, b) => a.appointmentDate > b.appointmentDate ? -1 : 1); |
| | | .map((item) => ({...item, sortTime: new Date(item.contactTime)})) |
| | | .sort((prevItem, nextItem) => +nextItem.sortTime - +prevItem.sortTime); |
| | | this.filterList = this.contactedList; |
| | | |
| | | this.getCurrentPage(); |
| | | } |
| | | |
| | | mounted() { |
| | | console.log('ClientContactedList 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[]) { |
| | | ////////////////////////////////////////////////////////////////////// |
| | | |
| | | 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> |
| | | </script> |