保誠-保戶業務員媒合平台
Mila
2021-12-29 cc663139f6abd63f7deac4739b63db754baf595c
PAMapp/pages/myAppointmentList/appointmentList.vue
@@ -17,26 +17,32 @@
        <UiPagination
            :totalList="filterList"
            :currentPage="currentPage"
            @changePage="changePage"
        ></UiPagination>
    </div>
</template>
<script lang="ts">
import { Vue, Component, State, Watch } from 'nuxt-property-decorator';
import { Vue, Component, State, Watch, namespace } from 'nuxt-property-decorator';
import { ClientInfo } from '~/shared/models/client.model';
const localStorage = namespace('localStorage');
@Component
export default class ClientReservedList extends Vue {
    @State('myAppointmentList')
    myAppointmentList!: ClientInfo[];
    @localStorage.Getter
    currentAppointmentIdFromMsg!: string;
    appointmentList: ClientInfo[] = [];
    pageList: ClientInfo[] = [];
    keyWord: string = '';
    filterList: ClientInfo[] = [];
    filterList     : ClientInfo[] = [];
    keyWord        : string       = '';
    pageList       : ClientInfo[] = [];
    currentPage    : number = 1;
    //////////////////////////////////////////////////////////////////////
@@ -57,16 +63,29 @@
          .filter(item => item.communicateStatus !== 'contacted' && item.consultantViewTime);
      // TODO: 後續如需針對 unreadList 做更細緻的排序,則需請後端提供判斷依據(例如: createTime)。[Tomas, 2021/12/16];å
      const unreadList = tempViewList.filter((item) => !item.consultantReadTime);
      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);
                    .sort((preItem, nextItem) => +nextItem.sortTime - +preItem.sortTime);
      this.appointmentList = [...unViewList, ...unreadList, ...readList];
      this.filterList = this.appointmentList;
      this.getCurrentPage();
    }
    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);
        }
    }
    //////////////////////////////////////////////////////////////////////
    search(): void {
        this.filterList = this.appointmentList.filter(item => {
            return item.name.match(this.keyWord) || item.requirement.match(this.keyWord)