From 6d8f7f44abcead3e5bb7c0b1694f52537b1022fa Mon Sep 17 00:00:00 2001 From: Andres2908 Date: Sun, 6 Mar 2022 18:40:35 -0600 Subject: [PATCH] validaciones y validacion de la inscripcion sin ticket --- components/admin/tableTickets.vue | 96 +++++++++++++++++++++++++++- components/registro/CapturaDatos.vue | 23 +++++-- nuxt.config.js | 4 +- 3 files changed, 115 insertions(+), 8 deletions(-) diff --git a/components/admin/tableTickets.vue b/components/admin/tableTickets.vue index 19e0947..441f698 100644 --- a/components/admin/tableTickets.vue +++ b/components/admin/tableTickets.vue @@ -54,6 +54,24 @@ @click="verTicket(props.row)" >Ver ticket + + Validar @@ -75,6 +93,7 @@ export default { currentPage: 1, perPage: 5, + noCuenta: '', validacion: '2', numeroCuenta: '', } @@ -90,13 +109,13 @@ export default { .then((res) => { this.updateIsLoading(false) this.inscripciones = res.data + console.log(this.inscripciones) }) .catch((err) => { this.updateIsLoading(false) }) }, verTicket(value) { - console.log(value) this.$router.push({ path: '/admin/ticket/', query: { @@ -106,6 +125,81 @@ export default { }, }) }, + validarSinTicket() { + const data = { + numeroCuenta: this.noCuenta, + } + + this.updateIsLoading(true) + axios + .put(`${process.env.api}/admin/validar_sin_ticket`, data, this.token) + .then((res) => { + this.imprimirMensaje(res.data.message) + this.updateIsLoading(false) + }) + .catch((err) => { + this.imprimirError(err.response.data) + this.updateIsLoading(false) + }) + }, + cuenta(value) { + this.noCuenta = value + }, + + imprimirError(err = {}, title = '¡Hubo un error!', onConfirm = () => {}) { + this.$buefy.dialog.alert({ + ariaRole: 'alertdialog', + ariaModal: true, + type: 'is-danger', + title, + message: err.message, + confirmText: 'Entendido', + hasIcon: true, + iconPack: 'mdi', + icon: 'alert-octagon', + onConfirm: () => onConfirm(), + }) + if (err.err && err.err === 'token error') { + localStorage.clear() + this.$router.push('/') + } + }, + imprimirMensaje(message, title = '¡Felicidades!', onConfirm = () => {}) { + this.$buefy.dialog.alert({ + ariaRole: 'alertdialog', + ariaModal: true, + type: 'is-success', + title, + message, + confirmText: 'Ok', + hasIcon: true, + iconPack: 'mdi', + icon: 'check-circle', + onConfirm: () => onConfirm(), + }) + }, + imprimirWarning( + message, + onConfirm = () => {}, + title = '¡Espera un minuto!', + onCancel = () => {} + ) { + this.$buefy.dialog.alert({ + ariaRole: 'alertdialog', + ariaModal: true, + type: 'is-warning', + title, + message, + confirmText: 'Confirmar', + canCancel: true, + cancelText: 'Cancelar', + hasIcon: true, + iconPack: 'mdi', + icon: 'help-circle', + onConfirm: () => onConfirm(), + onCancel: () => onCancel(), + }) + }, }, watch: { validacion() { diff --git a/components/registro/CapturaDatos.vue b/components/registro/CapturaDatos.vue index b3cde6a..1709fde 100644 --- a/components/registro/CapturaDatos.vue +++ b/components/registro/CapturaDatos.vue @@ -143,7 +143,6 @@ export default { terminos: false, fechaTicket: '', - dia: 10, minDate: this.diaMin(today), maxDate: new Date(), @@ -152,7 +151,19 @@ export default { }, methods: { async inscribir() { - let formData = new FormData() + if (this.dropFiles.length > 0 && !this.folio) { + if (!this.fechaTicket) { + return this.imprimirError({ + message: + 'Por favor ingresa el campo de ticket y la fecha del ticket.', + }) + } else { + return this.imprimirError({ + message: 'Por favor ingresa el campo de ticket.', + }) + } + } + if ( this.monto && this.monto <= 20 && @@ -160,6 +171,8 @@ export default { ) this.error = true else this.error = false + + let formData = new FormData() if (this.error === false) { formData.append('idUsuario', this.datosUsuario.idUsuario) formData.append('folio', this.folio) @@ -183,7 +196,6 @@ export default { this.clear() }) .catch((err) => { - console.log(err) this.updateIsLoading(false) this.imprimirError(err.response.data) }) @@ -242,9 +254,10 @@ export default { }, }, watch: { - inscripcionesUsuario() { - this.areaPermitida() + inscripcionesUsuario(value) { + if (value.length > 0) this.idArea = '' }, + dropFiles(value) { if (value.length > 1) this.deleteDropFile(0) }, diff --git a/nuxt.config.js b/nuxt.config.js index 81e7202..8d1e330 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -24,9 +24,9 @@ export default { axios: {}, build: {}, env: { - // api: 'http://localhost:3000', + api: 'http://localhost:3000', // api: "https://890af9d598a4.ngrok.io" - api: 'https://venus.acatlan.unam.mx/inscripciones_test', + // api: 'https://venus.acatlan.unam.mx/inscripciones_test', // api: "https://venus.acatlan.unam.mx/produccion", }, }