![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/vreg/mixins/ |
import InputField from "@/components/Forms/InputField"; import FormErrorMsg from "@/components/Forms/FormErrorMsg"; import {toPng} from 'html-to-image'; export default { components: { InputField, FormErrorMsg }, data() { return { formErrorMsg: '' } }, methods: { frontendFormSubmitHandler() { if (!this.$refs.form) { return this.submit(); } this.$refs.form.validate().then(success => { //submit the form if not errors occurs if (success) { return this.submit(); } let firstErrorFieldName = this.getFirstFieldErrorName(); //focus on the input if found! if (firstErrorFieldName) { this.focusOnElement(firstErrorFieldName); } }); }, getFirstFieldErrorName() { let errorsKeys = Object.keys(this.$refs.form.errors), firstErrorFieldName; while (errorsKeys.length) { firstErrorFieldName = errorsKeys.shift(); if (this.$refs.form.errors[firstErrorFieldName].length) { return firstErrorFieldName; } } }, focusOnElement(fieldName) { let [el] = document.getElementsByName(fieldName); //try with id if (!el) { el = document.getElementById(fieldName); } el.scrollIntoView({behavior: 'smooth'}); el.focus(); }, catchError(err) { if (err.response) { this.form.onFail(err.response.data.data); this.formErrorMsg = err.response.data.message; } else { this.formErrorMsg = err.message; } }, storeSavedSession(step, redirectTo, payload) { let storedOrderId = this.$store.state.orderId; if (storedOrderId) { this.$axios.post(`orders/${storedOrderId}/${step}/store-saved-session`, { payload: payload }); } if (redirectTo) { this.$router.push({path: redirectTo}); } }, saveElectronicSignature() { const {isEmpty, data} = this.$refs.signaturePad.saveSignature(); if (isEmpty) { this.form.electronic_signature = ''; } else { this.form.electronic_signature = data; } }, clearElectronicSignature() { this.$refs.signaturePad.clearSignature(); this.saveElectronicSignature(); }, async htmlToPNG() { const el = this.$refs.screenShotSection; this.form.signature_sc = await toPng(el); }, async screenshot() { await this.htmlToPNG(); this.ipVisible = false; }, onBeginSignature() { }, onEndSignature() { this.saveElectronicSignature(); }, } }