保誠-保戶業務員媒合平台
HelenHuang
2021-12-30 7cfc771d3ace8f057ef7f534b9ee7c9649ac7d8f
PAMapp/pages/myAppointmentList.vue
@@ -19,7 +19,7 @@
                </div>
            </div>
            <NuxtChild></NuxtChild>
            <NuxtChild keep-alive></NuxtChild>
        </div>
@@ -28,7 +28,7 @@
             :isOpen.sync="showNewAppointmentHint"
        >
            <div class="text--center mdTxt">
                <p class="mb-50">你有 <span class="text--primary">{{ newAppointmentSum }}</span> 則新的預約</p>
                <p class="mb-50">您有 <span class="text--primary">{{ newAppointmentSum }}</span> 則新的預約</p>
                <div class="text--center">
                    <el-button
                        type="primary"
@@ -41,15 +41,17 @@
</template>
<script lang="ts">
import { Vue, Component, State, Action, Watch } from 'nuxt-property-decorator';
import { Vue, Component, State, Action, Watch, namespace } from 'nuxt-property-decorator';
import * as _ from 'lodash';
import { ClientInfo } from '~/shared/models/client.model';
const localStorage = namespace('localStorage');
@Component({
    layout: 'home',
    middleware: 'myAppointmentMiddleware'
    middleware: 'myAppointment'
})
export default class ClientReservedList extends Vue {
@@ -62,6 +64,12 @@
    @Action
    storeMyAppointmentList!: () => Promise<number>;
    @localStorage.Mutation
    storageClearAppointmentIdFromMsg!: () => void;
    @localStorage.Getter
    currentAppointmentIdFromMsg!: string;
    activeTabName         : string       = 'appointmentList';
    appointmentList       : ClientInfo[] = [];
    clients               : ClientInfo[] = [];
@@ -71,15 +79,11 @@
    //////////////////////////////////////////////////////////////////////
    mounted() {
      this.setActivatedTab();
      this.storeMyAppointmentList();
    }
    private setActivatedTab(): void {
      const routeFullName = this.$route.name;
      if (routeFullName) {
        this.activeTabName = routeFullName.split('-')[1];
      }
    destroyed() {
        this.storageClearAppointmentIdFromMsg();
    }
    //////////////////////////////////////////////////////////////////////
@@ -91,13 +95,40 @@
        this.appointmentList = this.myAppointmentList
            .filter(item => item.communicateStatus !== 'contacted');
        if (this.currentAppointmentIdFromMsg) {
            this.redirectAppointmentStatus();
        }
    }
    private redirectAppointmentStatus() {
        const currentAppointmentIndex = this.myAppointmentList
            .findIndex(item => item.id === +this.currentAppointmentIdFromMsg);
        if (currentAppointmentIndex > -1) {
            const communicateStatus = this.myAppointmentList[currentAppointmentIndex].communicateStatus;
            const pathName = communicateStatus === 'reserved' ? 'appointmentList' : 'contactedList';
            this.$router.push(
                {
                    path: '/myAppointmentList/' + pathName,
                    query: {appointmentId: this.currentAppointmentIdFromMsg}
                }
            );
        }
    };
    @Watch('newAppointmentSum')
    newAppointmentSumChange(): void {
      this.showNewAppointmentHint = this.newAppointmentSum > 0;
    }
    @Watch('$route')
    onRouteChange() {
        const routeFullName = this.$route.name;
        if (routeFullName) {
            this.activeTabName = routeFullName.split('-')[1];
        }
    }
    //////////////////////////////////////////////////////////////////////
    clickTab(path: string): void {