保誠-保戶業務員媒合平台
HelenHuang
2021-12-06 20b87b7eab9c600e2445548c4306ea1b8b37b275
PAMapp/pages/myConsultantList.vue
@@ -1,6 +1,6 @@
<template>
    <div>
        <div class="flex mb-30">
        <div class="pam-cus-tabs mb-30">
            <div
                class="cus-tab-item"
                :class="{'is-active': activeTabName === 'consultantList'}"
@@ -20,51 +20,46 @@
        <NuxtChild
            :contactedList="contactedList"
            :consultantList="consultantList"
            @remove="removeAgent"
        ></NuxtChild>
    </div>
</template>
<script lang='ts'>
import { Context } from '@nuxt/types';
import { Vue, Component, Watch } from 'vue-property-decorator';
import { Route } from 'vue-router/types/router.d'
import { Agents } from '~/plugins/api/home';
import { Vue, Component, Watch, State, Action } from 'nuxt-property-decorator';
import { Route } from 'vue-router/types/router.d';
import { Consultants } from '~/assets/ts/models/consultant.model';
@Component
export default class myConsultantList extends Vue {
    activeTabName = 'consultantList';
    agents: Agents[] = [];
    contactedList: Agents[] = [];
    consultantList: Agents[] = [];
    agents: Consultants[] = [];
    contactedList: Consultants[] = [];
    consultantList: Consultants[] = [];
    @State('myConsultantList') myConsultantList!: Consultants[];
    @Action storeConsultantList!: any;
    @Watch('myConsultantList')
    onMyConsultantListChange() {
        this.filterContactedList();
    }
    tabClick(path: string) {
        this.activeTabName = path;
        this.$router.push('/myConsultantList/' + this.activeTabName)
    }
    async asyncData(context: Context) {
        let agents: Agents[] = [];
        let contactedList: Agents[] = [];
        let consultantList: Agents[] = [];
        await context.$service.home.recommendConsultantList().then((result: Agents[]) => {
            agents = result;
        })
        contactedList = agents.filter(item => item.contactStatus === 'contacted');
        consultantList = agents.filter(item => item.contactStatus !== 'contacted');
        return {
            agents,
            contactedList,
            consultantList
        }
    mounted() {
        this.storeConsultantList();
    }
    removeAgent(agentNo: number) {
        const fintIndex = this.consultantList.findIndex(item => item.agentNo === agentNo);
        this.consultantList.splice(fintIndex, 1);
    filterContactedList() {
        this.consultantList = (this.myConsultantList || [])
                .filter(item => item.contactStatus !== 'contacted')
                .sort((a, b) => a.updateTime > b.updateTime ? -1 : 1);
        this.contactedList = (this.myConsultantList || [])
                .filter(item => item.contactStatus === 'contacted')
                .sort((a, b) => a.updateTime > b.updateTime ? -1 : 1);
    }
    @Watch('$route') watchRouter(currentRoute: Route) {
@@ -73,27 +68,4 @@
    }
}
</script>
<style lang="scss" scoped>
    .flex {
        display: flex;
        width: 100%;
        height: 45px;
        .cus-tab-item {
            width: 50%;
            text-align: center;
            font-size: 24px;
            border-bottom: solid 3px $LIGHT_GREY;
            cursor: pointer;
        }
        .is-active {
            font-weight: bold;
            border-bottom: solid 3px $PRIMARY_BLACK;
        }
    }
</style>
</script>