From 31558bc14c970d96362b58ba4e833b7308d434ba Mon Sep 17 00:00:00 2001 From: lemuel Date: Thu, 12 Aug 2021 12:22:04 -0500 Subject: [PATCH] Proyectos CEDETEC --- components/admin/servicio/Archivo.vue | 57 +++++++-------------- components/admin/servicio/vistaServicio.vue | 18 +++---- 2 files changed, 25 insertions(+), 50 deletions(-) diff --git a/components/admin/servicio/Archivo.vue b/components/admin/servicio/Archivo.vue index 44130e8..ee1df08 100644 --- a/components/admin/servicio/Archivo.vue +++ b/components/admin/servicio/Archivo.vue @@ -27,7 +27,12 @@ Rechazar documento @@ -52,6 +57,8 @@ export default { imprimirWarning: { type: Function, required: true }, imprimirError: { type: Function, required: true }, updateIsLoading: { type: Function, required: true }, + catchError: { type: Function, required: true }, + regresar: { type: Function, required: true }, alumno: { type: Object, required: true }, title: { type: String, required: true }, }, @@ -77,32 +84,15 @@ export default { if (this.title === 'carta de termino') return this.alumno.cartaTermino if (this.title === 'informe global') return this.alumno.informeGlobal }, - rechazarDialog() { - this.$buefy.dialog.confirm({ - title: 'Confimar servicio', - message: '¿Seguro(a) que quiere rechazar este documento?', - confirmText: 'Confirmar', - cancelText: 'Cancelar', - type: 'is-danger', - hasIcon: true, - onConfirm: () => { - switch (this.idDoc) { - case 1: - this.rechazarCartaAceptacion() - break - case 2: - this.rechazarCartaTermino() - break - case 3: - this.rechazarInformeGlobal() - } - }, - }) + rechazarArchivo() { + if (this.title === 'carta de aceptación') this.rechazarCartaAceptacion() + if (this.title === 'carta de termino') this.rechazarCartaTermino() + if (this.title === 'informe global') this.rechazarInformeGlobal() }, rechazarCartaAceptacion() { const data = { - mensaje: this.mensajeRechazo, idServicio: this.alumno.idServicio, + mensaje: this.mensajeRechazo, } this.updateIsLoading(true) @@ -113,13 +103,10 @@ export default { this.admin.token ) .then((res) => { - this.updateIsLoading(false) - this.imprimirMensaje(res.data.message) - this.$router.push('/admin') + this.regresar(res.data.message) }) .catch((err) => { - this.updateIsLoading(false) - this.imprimirError(err.response.data) + this.catchError(err.response.data) }) }, rechazarCartaTermino() { @@ -136,13 +123,10 @@ export default { this.admin.token ) .then((res) => { - this.updateIsLoading(false) - this.imprimirMensaje(res.data.message) - this.$router.push('/admin') + this.regresar(res.data.message) }) .catch((err) => { - this.updateIsLoading(false) - this.imprimirError(err.response.data) + this.catchError(err.response.data) }) }, rechazarInformeGlobal() { @@ -159,13 +143,10 @@ export default { this.admin.token ) .then((res) => { - this.updateIsLoading(false) - this.imprimirMensaje(res.data.message) - this.$router.push('/admin') + this.regresar(res.data.message) }) .catch((err) => { - this.updateIsLoading(false) - this.imprimirError(err.response.data) + this.catchError(err.response.data) }) }, }, diff --git a/components/admin/servicio/vistaServicio.vue b/components/admin/servicio/vistaServicio.vue index 42a6c2a..063de1c 100644 --- a/components/admin/servicio/vistaServicio.vue +++ b/components/admin/servicio/vistaServicio.vue @@ -196,13 +196,10 @@ export default { axios .put(`${process.env.api}/servicio/cancelar`, data, this.admin.token) .then((res) => { - localStorage.removeItem('idServicio') - this.updateIsLoading(false) - this.imprimirMensaje(res.data.message) - this.$router.push('/admin') + this.regresar(res.data.message) }) .catch((err) => { - catchError(err.response.data) + this.catchError(err.response.data) }) }, confirmarRegistro() { @@ -212,13 +209,10 @@ export default { axios .put(`${process.env.api}/servicio/registro`, data, this.admin.token) .then((res) => { - localStorage.removeItem('idServicio') - this.updateIsLoading(false) - this.imprimirMensaje(res.data.message) - this.$router.push('/admin') + this.regresar(res.data.message) }) .catch((err) => { - catchError(err.response.data) + this.catchError(err.response.data) }) }, confirmarLiberacion() { @@ -233,7 +227,7 @@ export default { this.regresar(res.data.message) }) .catch((err) => { - catchError(err.response.data) + this.catchError(err.response.data) }) }, obtenerRegistro() { @@ -249,7 +243,7 @@ export default { this.updateIsLoading(false) }) .catch((err) => { - catchError(err.response.data) + this.catchError(err.response.data) }) }, catchError(errObj) {