From b2379e779ea0beb08f83281d00136fe0ad6543e9 Mon Sep 17 00:00:00 2001 From: xXpuma99Xx <51341582+xXpuma99Xx@users.noreply.github.com> Date: Fri, 31 Dec 2021 21:26:39 -0600 Subject: [PATCH] antes de cambiar uploads --- components/admin/EditarCasoEspecial.vue | 3 +- components/admin/EditarServicio.vue | 438 ++++++++---------- .../alumno/CompletarDatosPersonales.vue | 3 +- components/casoEspecial/NuevoCasoEspecial.vue | 8 +- components/responsable/NuevoServicio.vue | 2 +- nuxt.config.js | 8 +- pages/admin/servicio/editar/index.vue | 20 +- pages/admin/servicio/index.vue | 2 +- 8 files changed, 229 insertions(+), 255 deletions(-) diff --git a/components/admin/EditarCasoEspecial.vue b/components/admin/EditarCasoEspecial.vue index 050a924..cd99cd6 100644 --- a/components/admin/EditarCasoEspecial.vue +++ b/components/admin/EditarCasoEspecial.vue @@ -12,8 +12,9 @@ diff --git a/components/admin/EditarServicio.vue b/components/admin/EditarServicio.vue index 2db1686..4a5b6a6 100644 --- a/components/admin/EditarServicio.vue +++ b/components/admin/EditarServicio.vue @@ -1,159 +1,170 @@ @@ -162,17 +173,20 @@ import axios from 'axios' import moment from 'moment' import validator from 'validator' -import botonRegresar from '../botonRegresar' export default { - components: { - botonRegresar, + props: { + admin: { type: Object, required: true }, + imprimirError: { type: Function, required: true }, + imprimirMensaje: { type: Function, required: true }, + imprimirWarning: { type: Function, required: true }, + updateIsLoading: { type: Function, required: true }, }, data() { return { - idServicio: localStorage.getItem('idServicio'), + idServicio: null, idStatus: Number(localStorage.getItem('idStatus')), - viejo: {}, + servicio: {}, nuevo: { correo: '', fechaInicioFinal: '', @@ -187,13 +201,7 @@ export default { fechaNacimiento: [], fechaInicio: [], fechaFin: [], - token: { - headers: { - token: localStorage.getItem('token'), - }, - }, minDate1: new Date('2020-01-01'), - isLoading: false, padding: false, } }, @@ -208,30 +216,6 @@ export default { } return '' }, - status6() { - if (this.idStatus === 6) { - this.padding = true - return false - } - return true - }, - obtenerRegistro() { - this.isLoading = true - return axios - .get( - `${process.env.api}/servicio/admin?idServicio=${this.idServicio}`, - this.token - ) - .then((res) => { - this.viejo = res.data - }) - .catch((err) => { - this.error(err.response.data.message) - }) - .finally(() => { - this.isLoading = false - }) - }, dangerToast() { this.$buefy.toast.open({ message: 'Asegurate de ingresar un PDF', @@ -288,11 +272,32 @@ export default { break } }, + obtenerRegistro() { + this.updateIsLoading(true) + axios + .get( + `${process.env.api}/servicio/admin?idServicio=${this.idServicio}`, + this.admin.token + ) + .then((res) => { + this.servicio = res.data + if ( + this.servicio.Status.idStatus === 6 || + this.servicio.Status.idStatus === 10 + ) + this.$router.push('/admin/servicio') + this.updateIsLoading(false) + }) + .catch((err) => { + this.updateIsLoading(false) + this.imprimirError(err.response.data) + }) + }, actualizar() { const formData = new FormData() const data = { idServicio: this.idServicio } - this.isLoading = true + this.updateIsLoading(true) if (this.nuevo.direccion) data.direccion = this.nuevo.direccion if (this.nuevo.correo) data.correo = this.nuevo.correo if (this.nuevo.telefono) data.telefono = this.nuevo.telefono @@ -308,100 +313,44 @@ export default { formData.append('cartaTermino', this.nuevo.cartaTermino) if (this.nuevo.informeGlobal) formData.append('informeGlobal', this.nuevo.informeGlobal) - axios - .put(`${process.env.api}/servicio/update`, formData, { - headers: { - 'Content-Type': 'multipart/form-data', - token: this.token.headers.token, - }, - }) + .put( + `${process.env.api}/servicio/update`, + formData, + this.admin.tokenArchivo + ) .then((res) => { this.toast() + this.updateIsLoading(false) this.$router.push('/admin/servicio') }) .catch((err) => { - this.error(err.response.data.message) + this.updateIsLoading(false) + this.imprimirError(err.response.data) }) - .finally(() => { - this.isLoading = false - }) - }, - actualizarDialog() { - this.$buefy.dialog.confirm({ - title: 'Actualizar datos', - message: '¿Seguro(a) que quiere actualizar estos datos?', - confirmText: 'Confirmar', - cancelText: 'Cancelar', - type: 'is-success', - hasIcon: true, - onConfirm: () => this.actualizar(), - }) - }, - passwordDialog() { - this.$buefy.dialog.confirm({ - title: 'Actualizar datos', - message: '¿Seguro(a) que quiere actualizar la contraseña?', - confirmText: 'Confirmar', - cancelText: 'Cancelar', - type: 'is-success', - hasIcon: true, - onConfirm: () => this.password(), - }) }, password() { - this.isLoading = true const data = { idServicio: this.idServicio } + + this.updateIsLoading(true) axios - .put(`${process.env.api}/usuario/new_password_alumno`, data, this.token) + .put( + `${process.env.api}/usuario/new_password_alumno`, + data, + this.admin.token + ) .then((res) => { this.$buefy.toast.open({ message: 'Se ha enviado el correo con la nueva contraseña', type: 'is-success', }) + this.updateIsLoading(false) this.$router.push('/admin') }) .catch((err) => { - this.error(err.response.data.message) + this.updateIsLoading(false) + this.imprimirError(err.response.data) }) - .finally(() => { - this.isLoading = false - }) - }, - error(msj) { - let salir = false - switch (msj) { - case 'invalid signature': - msj = 'Tu token no es valido, inicia sesión de nuevo.' - salir = true - break - case 'jwt expired': - msj = 'Tu sesión ha expirado, inicia sesión de nuevo.' - salir = true - break - case 'jwt malformed': - msj = 'No se encontro tu token, inicia sesión de nuevo.' - salir = true - break - case 'No hay token': - msj = 'Ocurrio un error al enviar tu token, inicia sesión de nuevo.' - salir = true - break - } - - this.$buefy.dialog.alert({ - title: 'Error', - message: msj, - type: 'is-danger', - hasIcon: true, - icon: 'alert-circle', - ariaRole: 'alertdialog', - ariaModal: true, - }) - if (salir == true) { - localStorage.clear() - this.$router.push(`/`) - } }, }, computed: { @@ -423,7 +372,9 @@ export default { }, }, created() { - this.obtenerRegistro() + this.idServicio = Number(localStorage.getItem('idServicio')) + if (!this.idServicio) this.$router.push('/admin') + else this.obtenerRegistro() }, } @@ -433,11 +384,8 @@ export default { .fade-leave-active { transition: opacity 0.5s; } -.fade-enter, .fade-leave-to /* .fade-leave-active below version 2.1.8 */ { +.fade-enter, +.fade-leave-to { opacity: 0; } -.pad { - padding-bottom: 5%; - padding-top: 5%; -} diff --git a/components/alumno/CompletarDatosPersonales.vue b/components/alumno/CompletarDatosPersonales.vue index 0bd594f..634b1fb 100644 --- a/components/alumno/CompletarDatosPersonales.vue +++ b/components/alumno/CompletarDatosPersonales.vue @@ -11,11 +11,12 @@ /> - + diff --git a/components/casoEspecial/NuevoCasoEspecial.vue b/components/casoEspecial/NuevoCasoEspecial.vue index a7bfed5..8fcea71 100644 --- a/components/casoEspecial/NuevoCasoEspecial.vue +++ b/components/casoEspecial/NuevoCasoEspecial.vue @@ -39,7 +39,13 @@ - + diff --git a/components/responsable/NuevoServicio.vue b/components/responsable/NuevoServicio.vue index d91d66a..f90cce8 100644 --- a/components/responsable/NuevoServicio.vue +++ b/components/responsable/NuevoServicio.vue @@ -80,7 +80,7 @@ /> - + diff --git a/nuxt.config.js b/nuxt.config.js index 1649399..c4ab8ff 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -1,7 +1,7 @@ export default { /* Server de pruebas */ - server: { port: 3016 }, - // server: { port: 8080 }, + // server: { port: 3016 }, + server: { port: 8080 }, ssr: false, target: 'static', head: { @@ -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/ss-pruebas', - api: "https://venus.acatlan.unam.mx/serviciosocial", + // api: 'https://venus.acatlan.unam.mx/serviciosocial', }, } diff --git a/pages/admin/servicio/editar/index.vue b/pages/admin/servicio/editar/index.vue index 7a54796..81bc9bb 100644 --- a/pages/admin/servicio/editar/index.vue +++ b/pages/admin/servicio/editar/index.vue @@ -1,27 +1,40 @@ diff --git a/pages/admin/servicio/index.vue b/pages/admin/servicio/index.vue index 5287010..a6d1bb9 100644 --- a/pages/admin/servicio/index.vue +++ b/pages/admin/servicio/index.vue @@ -99,7 +99,7 @@ export default { idServicio: null, admin: {}, alumno: { - Programa: {}, + Programa: { Usuario: {} }, Usuario: {}, Carrera: {}, Status: {},