<template>
|
<el-row type="flex" justify="center" :class="cusClass">
|
<el-button @click="addConsultant(agentInfo)" :disabled="isAdded">
|
<span> + 顧問清單</span>
|
</el-button>
|
<el-button
|
@click="reserveCommunication"
|
type="primary"
|
>進行預約</el-button>
|
</el-row>
|
</template>
|
|
<script lang="ts">
|
import { Vue, Component, Prop, Emit, Action, State } from 'nuxt-property-decorator';
|
import { Consultants } from '~/assets/ts/api/consultant';
|
import { isLogin } from '~/assets/ts/auth';
|
|
@Component
|
export default class AddAndReservedBtns extends Vue {
|
@Action addToMyConsultantList!: (consultantToAdd: Consultants) => Promise<boolean>
|
@State('myConsultantList') myConsultantList!: Consultants[];
|
|
@Prop() agentInfo!: Consultants;
|
@Prop() cusClass!: string;
|
isVisiblePopUp = false;
|
addConsultant(item: Consultants) {
|
this.addToMyConsultantList(item).then(addOk => {
|
addOk && this.openPopUp();
|
});
|
}
|
|
reserveCommunication() {
|
isLogin() ? this.$router.push(`/questionnaire/${this.agentInfo.agentNo}`) : this.$router.push('/login');
|
}
|
|
@Emit('openPopUp') openPopUp(popUpTxt: string = '成功加入顧問清單') {
|
return popUpTxt
|
}
|
|
get isAdded() {
|
return this.myConsultantList.find(item => item.agentNo === this.agentInfo.agentNo)
|
? true : false
|
}
|
}
|
</script>
|