| | |
| | | <el-button type="primary" |
| | | :disabled="isDisabledSubmitBtn" |
| | | @click.native="sentDemand"> |
| | | 送出 |
| | | {{isEditBtn ? '更新' : '送出'}} |
| | | </el-button> |
| | | </div> |
| | | </div> |
| | |
| | | </el-button> |
| | | </div> |
| | | </PopUpFrame> |
| | | |
| | | <PopUpFrame :isOpen.sync="isEditPopup"> |
| | | <div class="text--middle mt-30 sendReserve-txt">是否繼續編輯預約單?</div> |
| | | <div class="text--center mdTxt"> |
| | | <el-button @click="$router.go(-1)">返回</el-button> |
| | | <el-button @click="isEditPopup = false" type="primary">編輯</el-button> |
| | | </div> |
| | | </PopUpFrame> |
| | | </div> |
| | | </template> |
| | | |
| | | <script lang="ts"> |
| | | import { Vue, Component } from 'nuxt-property-decorator'; |
| | | import { addFavoriteConsultant, appointmentDemand, AppointmentParams, AppointmentRequests ,RegisterInfo } from '~/assets/ts/api/consultant'; |
| | | import { getRequestsFromStorage, setRequestsToStorage, getRequestQuestionFromStorage, removeRequestQuestionFromStorage } from '~/assets/ts/storageRequests'; |
| | | import { Gender } from '~/assets/ts/models/enum/Gender'; |
| | | import { ContactType } from '~/assets/ts/models/enum/ContactType'; |
| | | import { Vue, Component, State, Action, Watch } from 'nuxt-property-decorator'; |
| | | import { addFavoriteConsultant, appointmentDemand, AppointmentParams, AppointmentRequests ,editAppointment,RegisterInfo } from '~/assets/ts/api/consultant'; |
| | | import { getRequestQuestionFromStorage, getRequestsFromStorage, removeRequestQuestionFromStorage, setRequestsToStorage } from '~/assets/ts/storageRequests'; |
| | | import _ from 'lodash'; |
| | | import { isLogin } from '~/assets/ts/auth'; |
| | | import { Consultant } from '~/assets/ts/models/consultant.model'; |
| | | import { ContactType } from '~/assets/ts/models/enum/ContactType'; |
| | | import { Gender } from '~/assets/ts/models/enum/Gender'; |
| | | |
| | | @Component |
| | | export default class Questionnaire extends Vue { |
| | | @State('myConsultantList') myConsultantList!: Consultant[]; |
| | | @Action storeConsultantList!: () => Promise<number>; |
| | | |
| | | genderOptions=[ |
| | | { |
| | | title:'男性', |
| | |
| | | |
| | | showDrawer= false; |
| | | sendReserve = false; |
| | | isEditPopup = false; |
| | | isEditBtn = false; |
| | | |
| | | appointmentId = 0; |
| | | |
| | | beforeRouteEnter(to: any, from: any, next: any) { |
| | | next(vm => { |
| | |
| | | vm.$router.push('/login'); |
| | | } |
| | | }) |
| | | } |
| | | |
| | | async fetch() { |
| | | if (isLogin()) { |
| | | await this.storeConsultantList(); |
| | | }; |
| | | } |
| | | |
| | | mounted(): void { |
| | |
| | | } |
| | | |
| | | sentDemand() { |
| | | if (this.isEditBtn) { |
| | | this.sentEditAppointmentDemand(); |
| | | } else { |
| | | addFavoriteConsultant([this.$route.params.agentNo]).then(res => this.sentAppointmentDemand()); |
| | | } |
| | | |
| | | } |
| | | |
| | | private sentAppointmentDemand() { |
| | |
| | | }; |
| | | |
| | | appointmentDemand(data).then(res => { |
| | | this.sendReserve = true; |
| | | this.myRequest.hopeContactTime = []; |
| | | setRequestsToStorage(this.myRequest); |
| | | }); |
| | | } |
| | | |
| | | private sentEditAppointmentDemand() { |
| | | const info = { |
| | | ...this.myRequest, |
| | | requirement: _.map(this.myRequest.requirement,o=>o).toString(), |
| | | hopeContactTime: this.myRequest.phone && this.phoneValid ? this.getHopeContactTime() :'', |
| | | id: this.appointmentId, |
| | | otherRequirement: null |
| | | } |
| | | editAppointment(info).then(res => { |
| | | this.sendReserve = true; |
| | | this.myRequest.hopeContactTime = []; |
| | | setRequestsToStorage(this.myRequest); |
| | |
| | | this.$router.push('/') |
| | | } |
| | | |
| | | private getLatestReserved(agentNo) { |
| | | const agentInfo = this.myConsultantList.filter(item => item.agentNo === agentNo); |
| | | |
| | | const appointmentInfo = agentInfo.length > 0 && agentInfo[0].appointments |
| | | ? agentInfo[0].appointments! |
| | | .filter((appointment) => appointment.communicateStatus !== 'contacted') |
| | | .sort((preAppointment, nextAppointment) => { |
| | | return +nextAppointment.appointmentDate - +preAppointment.appointmentDate |
| | | })[0] |
| | | : null; |
| | | |
| | | return this.getReservedData(appointmentInfo); |
| | | } |
| | | |
| | | private getReservedData(appointmentInfo) { |
| | | if (appointmentInfo) { |
| | | const hopeContactTime = appointmentInfo!.hopeContactTime.split("'") |
| | | .filter(item => item && item !== ','); |
| | | this.appointmentId = appointmentInfo.id; |
| | | return { |
| | | age: appointmentInfo.age, |
| | | agentNo: appointmentInfo.agentNo, |
| | | contactType: appointmentInfo.contactType, |
| | | email: appointmentInfo.email || '', |
| | | gender: appointmentInfo.gender, |
| | | hopeContactTime: hopeContactTime.map(item => { |
| | | const info = item.split('、'); |
| | | return { |
| | | selectWeekOptions: info[0].split(','), |
| | | selectTimesOptions: info[1].split(',') |
| | | } |
| | | }), |
| | | job: appointmentInfo.job, |
| | | phone: appointmentInfo.phone || '', |
| | | requirement: appointmentInfo.requirement.split(',') |
| | | } |
| | | } else { |
| | | return { |
| | | age: '', |
| | | agentNo: '', |
| | | contactType: '', |
| | | email: '', |
| | | gender: '', |
| | | hopeContactTime: [], |
| | | job: '', |
| | | phone: '', |
| | | requirement: [] |
| | | } |
| | | } |
| | | } |
| | | |
| | | @Watch('myConsultantList') onMyConsultantListChange() { |
| | | if (this.isLogin && this.myConsultantList.length > 0) { |
| | | const editAppointment = this.getLatestReserved(this.$route.params.agentNo); |
| | | |
| | | if (editAppointment.agentNo) { |
| | | this.myRequest = JSON.parse(JSON.stringify(editAppointment)); |
| | | if (!this.$route.query || this.$route.query.edit !== 'true') { |
| | | this.isEditPopup = true; |
| | | } |
| | | this.isEditBtn = true; |
| | | return; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | |
| | | margin-top:30px; |
| | | display: flex; |
| | | justify-content: center; |
| | | } |
| | | |
| | | .el-button+.el-button{ |
| | | margin-left: 0; |
| | | } |
| | | |
| | | .datepicker{ |