保誠-保戶業務員媒合平台
Mila
2021-12-08 eda85197a4a979d33815481d07eebbc67df078b2
PAMapp/components/Consultant/ConsultantCard.vue
@@ -82,6 +82,11 @@
                    <el-button type="primary" 
                        @click.native="reviewsBtn = true">給予滿意度評分</el-button>
                </div>
                <div v-if="agentInfo.contactStatus === 'reserved'" class="text--center mt-10">
                    <el-button @click="isCancelPopup = true">取消預約</el-button>
                    <el-button @click="edit" type="primary">編輯</el-button>
                </div>
            </div>
        </Ui-Dialog>
        <PopUpFrame :isOpen.sync="reviewsBtn" drawerSize='30%'>
@@ -99,12 +104,20 @@
                </div>
            </div>
        </PopUpFrame>
        <PopUpFrame :isOpen.sync="isCancelPopup">
            <div class="text--center mdTxt">是否取消此筆預約?</div>
            <div class="text--center mt-30">
                <el-button @click="isCancelPopup = false">取消</el-button>
                <el-button @click="cancel" type="primary">確定</el-button>
            </div>
        </PopUpFrame>
    </div>
</template>
<script lang="ts">
import { Vue, Component, Prop, Emit, Action, State } from 'nuxt-property-decorator';
import { getAppointmentDetail, UserReviewsConsultantsParams, userReviewsConsultants  } from '~/assets/ts/api/consultant';
import { Vue, Component, Prop, Action } from 'nuxt-property-decorator';
import { getAppointmentDetail, UserReviewsConsultantsParams, userReviewsConsultants, cancelAppointment, AppointmentRequests  } from '~/assets/ts/api/consultant';
import { Consultant, Appointment } from '~/assets/ts/models/consultant.model';
import { isLogin } from '~/assets/ts/auth';
import { isMobileDevice } from '~/assets/ts/device';
@@ -138,6 +151,7 @@
    status = false;
    width: string = '';
    inputScore = 0;
    isCancelPopup = false;
    
    get latestContactedAppointment(): Appointment | null {
        if (!(this.agentInfo && this.agentInfo.appointments && this.agentInfo.appointments.length)) return null;
@@ -145,6 +159,12 @@
                                                        .filter((appointment) => appointment.communicateStatus === 'contacted')
                                                        .sort((preAppointment, nextAppointment) => +nextAppointment.appointmentDate - +preAppointment.appointmentDate);
        return contactedAppointments[0];
    }
    get latestReservedAppointment(): Appointment {
        return this.agentInfo.appointments!
                .filter((appointment) => appointment.communicateStatus !== 'contacted')
                .sort((preAppointment, nextAppointment) => +nextAppointment.appointmentDate - +preAppointment.appointmentDate)[0];
    }
    
    appointmentDetail: any = {
@@ -215,12 +235,9 @@
    }
    openPopUp() {
    const latestReservedAppointment = this.agentInfo.appointments!
                                        .filter((appointment) => appointment.communicateStatus !== 'contacted')
                                        .sort((preAppointment, nextAppointment) => +nextAppointment.appointmentDate - +preAppointment.appointmentDate)[0];
        getAppointmentDetail(this.latestContactedAppointment 
                            ? this.latestContactedAppointment.id 
                            : latestReservedAppointment.id).then(res => {
                            : this.latestReservedAppointment.id).then(res => {
            this.appointmentDetail = {
                ...this.appointmentDetail,
                ...res.data
@@ -252,6 +269,19 @@
            this.storeConsultantList();
        });
    }
    cancel() {
        cancelAppointment(this.latestReservedAppointment.id).then(res => {
            this.storeConsultantList();
            this.isVisibleDialog = false;
            this.isCancelPopup = false;
        });
    }
    edit() {
        this.isVisibleDialog = false;
        this.$router.push({path: `/questionnaire/${this.agentInfo.agentNo}`, query: {'edit': 'true'}});
    }
}
</script>