diff --git a/components/admin/tableTickets.vue b/components/admin/tableTickets.vue index 99a3654..995e4d0 100644 --- a/components/admin/tableTickets.vue +++ b/components/admin/tableTickets.vue @@ -57,7 +57,11 @@ export default { console.log(value) this.$router.push({ path: '/admin/ticket/', - query: { folio: value.folio }, + query: { + folio: value.folio, + monto: value.monto, + fecha: value.fechaTicket, + }, }) }, }, diff --git a/components/admin/ticket.vue b/components/admin/ticket.vue index 8a44feb..ac32bc3 100644 --- a/components/admin/ticket.vue +++ b/components/admin/ticket.vue @@ -1,10 +1,49 @@ @@ -12,9 +51,16 @@ import axios from 'axios' export default { + props: { + imprimirMensaje: { type: Function, require: true }, + imprimirError: { type: Function, require: true }, + imprimirWarning: { type: Function, required: true }, + updateIsLoading: { type: Function, require: true }, + }, data() { return { urlTicket: '', + validado: null, } }, methods: { @@ -22,15 +68,39 @@ export default { axios .get(`${process.env.api}/admin/ticket?folio=${this.$route.query.folio}`) .then((res) => { - console.log(res.config.url) this.urlTicket = res.config.url - console.log(res) }) .catch((err) => { console.log(err) // this.imprimirError(err.response.data) }) }, + validacion(value) { + this.validado = value + }, + validar() { + const data = { + folio: this.$route.query.folio, + validacion: this.validado, + } + + this.updateIsLoading(true) + axios + .put(`${process.env.api}/admin/validar`, data) + .then((res) => { + this.updateIsLoading(false) + this.imprimirMensaje(res.data.message) + // this.$router.go(-1) + }) + .catch((err) => { + console.log(err) + this.updateIsLoading(false) + this.imprimirError(err.response.data) + }) + }, + regresar() { + this.$router.go(-1) + }, }, created() { this.traerTicket() @@ -39,7 +109,8 @@ export default { diff --git a/pages/admin/ticket.vue b/pages/admin/ticket.vue index 8bc58e9..fdd5c11 100644 --- a/pages/admin/ticket.vue +++ b/pages/admin/ticket.vue @@ -1,6 +1,11 @@ @@ -14,6 +19,65 @@ export default { data() { return {} }, + methods: { + updateIsLoading(booleanValue) { + this.isLoading = booleanValue + }, + 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(), + }) + }, + }, }