diff --git a/components/admin/servicio/documento.vue b/components/admin/servicio/documento.vue index 47cf331..5f9a950 100644 --- a/components/admin/servicio/documento.vue +++ b/components/admin/servicio/documento.vue @@ -52,6 +52,11 @@ export default { mensajeBool: false, idServicio: localStorage.getItem("idServicio"), isLoading: false, + token: { + headers: { + token: window.localStorage.getItem("token"), + }, + }, }; }, methods: { @@ -97,7 +102,11 @@ export default { idServicio: this.idServicio, }; axios - .put(`${process.env.api}/servicio/rechazar_aceptacion`, data) + .put( + `${process.env.api}/servicio/rechazar_aceptacion`, + data, + this.token + ) .then((res) => { this.isLoading = false; this.$buefy.dialog.alert("Se ha rechazado el documento"); @@ -105,8 +114,9 @@ export default { }) .catch((err) => { this.isLoading = false; - this.error(); - console.log(err); + this.error(err.response.data.message); + console.log(err.response.data.message); + this.errorDoc(); }); }, rechazarCartaTermino() { @@ -116,7 +126,7 @@ export default { idServicio: this.idServicio, }; axios - .put(`${process.env.api}/servicio/rechazar_termino`, data) + .put(`${process.env.api}/servicio/rechazar_termino`, data, this.token) .then((res) => { this.isLoading = false; this.$buefy.dialog.alert("Se ha rechazado el documento"); @@ -124,8 +134,9 @@ export default { }) .catch((err) => { this.isLoading = false; - this.error(); - console.log(err); + this.error(err.response.data.message); + console.log(err.response.data.message); + this.errorDoc(); }); }, rechazarInformeGlobal() { @@ -135,7 +146,7 @@ export default { idServicio: this.idServicio, }; axios - .put(`${process.env.api}/servicio/rechazar_informe`, data) + .put(`${process.env.api}/servicio/rechazar_informe`, data, this.token) .then((res) => { this.isLoading = false; this.$buefy.dialog.alert("Se ha rechazado el documento"); @@ -143,10 +154,59 @@ export default { }) .catch((err) => { this.isLoading = false; - this.error(); - console.log(err); + this.error(err.response.data.message); + console.log(err.response.data.message); + this.errorDoc(); }); }, + 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 = "tu token esta mal formado, inicia sesión de nuevo"; + salir = true; + break; + case "No hay token": + msj = "no has enviado 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", + iconPack: "mdi", + ariaRole: "alertdialog", + ariaModal: true, + }); + if (salir == true) { + localStorage.clear(); + this.$router.push(`/`); + } + }, + errorDoc() { + this.$buefy.dialog.alert({ + title: "Error", + message: "Ha ocurrido un error al rechazar el documento", + type: "is-danger", + hasIcon: true, + icon: "times-circle", + iconPack: "fa", + ariaRole: "alertdialog", + ariaModal: true, + }); + }, }, }; diff --git a/components/admin/servicio/modificar/form.vue b/components/admin/servicio/modificar/form.vue index 4680302..94e6727 100644 --- a/components/admin/servicio/modificar/form.vue +++ b/components/admin/servicio/modificar/form.vue @@ -179,6 +179,11 @@ export default { fechaNacimiento: [], fechaInicio: [], fechaFin: [], + token: { + headers: { + token: window.localStorage.getItem("token"), + }, + }, minDate1: new Date("2020-01-01"), isLoading: false, }; @@ -291,14 +296,20 @@ export default { formData.append("data", JSON.stringify(data)); } axios - .put(`${process.env.api}/servicio/update`, formData) + .put(`${process.env.api}/servicio/update`, formData, { + headers: { + "Content-Type": "multipart/form-data", + token: this.token.headers.token, + }, + }) .then((res) => { this.isLoading = false; - this.$router.push("./"); this.toast(); + this.$router.push("/admin/servicio/modificar"); }) .catch((err) => { this.isLoading = false; + this.error(err.response.data.message); console.log(err.response.data.message); }); }, @@ -313,6 +324,42 @@ export default { onConfirm: () => this.actualizar(), }); }, + 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 = "tu token esta mal formado, inicia sesión de nuevo"; + salir = true; + break; + case "No hay token": + msj = "no has enviado 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", + iconPack: "mdi", + ariaRole: "alertdialog", + ariaModal: true, + }); + if (salir == true) { + localStorage.clear(); + this.$router.push(`/`); + } + }, fecha(date) { if (date) { const fecha = moment(date.substr(0, 10)); diff --git a/components/admin/servicio/programa/cargaMasiva.vue b/components/admin/servicio/programa/cargaMasiva.vue index 1e55ebb..9fda34f 100644 --- a/components/admin/servicio/programa/cargaMasiva.vue +++ b/components/admin/servicio/programa/cargaMasiva.vue @@ -36,10 +36,16 @@ diff --git a/components/admin/servicio/programa/tablaResponsables.vue b/components/admin/servicio/programa/tablaResponsables.vue index 2e32e92..8f6e247 100644 --- a/components/admin/servicio/programa/tablaResponsables.vue +++ b/components/admin/servicio/programa/tablaResponsables.vue @@ -74,6 +74,11 @@ export default { correo: "", nombre: "", idStatus: 1, + token: { + headers: { + token: window.localStorage.getItem("token"), + }, + }, }; }, methods: { @@ -87,7 +92,8 @@ export default { this.data = []; axios .get( - `${process.env.api}/usuario/responsable?pagina=${this.page}&nombre=${this.nombre}&correo=${this.correo}` + `${process.env.api}/usuario/responsable?pagina=${this.page}&nombre=${this.nombre}&correo=${this.correo}`, + this.token ) .then((res) => { const servicios = res.data.servicios; @@ -110,10 +116,47 @@ export default { this.loading = false; }) .catch((err) => { - console.log(err.response.data.message); this.loading = false; + this.error(err.response.data.message); + console.log(err.response.data.message); }); }, + 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 = "tu token esta mal formado, inicia sesión de nuevo"; + salir = true; + break; + case "No hay token": + msj = "no has enviado 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", + iconPack: "mdi", + ariaRole: "alertdialog", + ariaModal: true, + }); + if (salir == true) { + localStorage.clear(); + this.$router.push(`/`); + } + }, insertIdLocal() { this.idUsuario = localStorage.getItem("idUsuario"); }, diff --git a/components/admin/servicio/vistaServicio.vue b/components/admin/servicio/vistaServicio.vue index 76a75d4..64f5e08 100644 --- a/components/admin/servicio/vistaServicio.vue +++ b/components/admin/servicio/vistaServicio.vue @@ -65,22 +65,20 @@

-
- - Confirmar - - - Confirmar - -
+ + Confirmar + + + Confirmar + Cancelar @@ -175,8 +173,8 @@ export default { this.isLoading = true; return axios .get( - `${process.env.api}/servicio/admin?idServicio=${this.idServicio}` //, - // this.token + `${process.env.api}/servicio/admin?idServicio=${this.idServicio}`, + this.token ) .then((res) => { this.isLoading = false; @@ -194,7 +192,8 @@ export default { }) .catch((err) => { this.isLoading = false; - console.log(err.response); + this.error(err.response.data.message); + console.log(err.response.data.message); }); }, cancelarDialog() { @@ -235,17 +234,17 @@ export default { mensaje: this.mensajeCancel, }; axios - .put(`${process.env.api}/servicio/cancelar`, data) + .put(`${process.env.api}/servicio/cancelar`, data, this.token) .then((res) => { this.isLoading = false; this.$buefy.dialog.alert("El servicio ha sido cancelado con éxito"); localStorage.removeItem("idServicio"); - this.$router.push("./"); + this.$router.push("/admin"); }) .catch((err) => { this.isLoading = false; - this.error(); - console.log(err); + this.error(err.response.data.message); + console.log(err.response.data.message); }); }, confirmarRegistro() { @@ -254,17 +253,17 @@ export default { idServicio: this.idServicio, }; axios - .put(`${process.env.api}/servicio/registro`, data) + .put(`${process.env.api}/servicio/registro`, data, this.token) .then((res) => { this.isLoading = false; this.$buefy.dialog.alert("El servicio ha sido aprobado"); localStorage.removeItem("idServicio"); this.$router.push("/admin"); }) - .catch((e) => { + .catch((err) => { this.isLoading = false; - console.log(e); - this.error(); + this.error(err.response.data.message); + console.log(err.response.data.message); }); }, confirmarLiberacion() { @@ -276,30 +275,54 @@ export default { data.vistoBueno = this.alumno.vistoBueno; } axios - .put(`${process.env.api}/servicio/liberacion`, data) + .put(`${process.env.api}/servicio/liberacion`, data, this.token) .then((res) => { this.isLoading = false; this.$buefy.dialog.alert("El servicio ha sido liberado"); localStorage.removeItem("idServicio"); this.$router.push("/admin"); }) - .catch((e) => { + .catch((err) => { this.isLoading = false; - console.log(e); - this.error(); + this.error(err.response.data.message); + console.log(err.response.data.message); }); }, - error() { + 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 = "tu token esta mal formado, inicia sesión de nuevo"; + salir = true; + break; + case "No hay token": + msj = "no has enviado tu token, inicia sesión de nuevo"; + salir = true; + break; + } + this.$buefy.dialog.alert({ title: "Error", - message: "Ha ocurrido un error, inténtalo de nuevo más tarde", + message: msj, type: "is-danger", hasIcon: true, - icon: "times-circle", - iconPack: "fa", + icon: "alert-circle", + iconPack: "mdi", ariaRole: "alertdialog", ariaModal: true, }); + if (salir == true) { + localStorage.clear(); + this.$router.push(`/`); + } }, }, async created() { diff --git a/components/alumno/DataAlumno.vue b/components/alumno/DataAlumno.vue deleted file mode 100644 index 3789d88..0000000 --- a/components/alumno/DataAlumno.vue +++ /dev/null @@ -1,495 +0,0 @@ - - - - - diff --git a/nuxt.config.js b/nuxt.config.js index a816ad8..19be8eb 100644 --- a/nuxt.config.js +++ b/nuxt.config.js @@ -46,7 +46,7 @@ export default { // Build Configuration (https://go.nuxtjs.dev/config-build) build: {}, env: { - // api: "http://localhost:3000", + // api: "http://localhost:3000", api: "https://venus.acatlan.unam.mx/ss-pruebas", // api: "https://890af9d598a4.ngrok.io" // api: 'https//venus.acatlan.unam.mx/pruebas_pcpuma' diff --git a/pages/admin/programa/infoResponsable/index.vue b/pages/admin/programa/infoResponsable/index.vue index bbd1c2a..17f8797 100644 --- a/pages/admin/programa/infoResponsable/index.vue +++ b/pages/admin/programa/infoResponsable/index.vue @@ -65,33 +65,63 @@ export default { nombre: localStorage.getItem("nombre"), programas: [], selected: {}, + token: { + headers: { + token: window.localStorage.getItem("token"), + }, + }, }; }, methods: { obtenerProgramas() { return axios .get( - `${process.env.api}/programa?idUsuario=${this.idResponsable}` //,this.token + `${process.env.api}/programa?idUsuario=${this.idResponsable}`, + this.token ) .then((res) => { this.programas = res.data; }) .catch((err) => { - this.error(); - console.log(err.response); + this.errorToken(err.response.data.message); + console.log(err.response.data.message); }); }, - error() { + errorToken(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 = "tu token esta mal formado, inicia sesión de nuevo"; + salir = true; + break; + case "No hay token": + msj = "no has enviado tu token, inicia sesión de nuevo"; + salir = true; + break; + } + this.$buefy.dialog.alert({ title: "Error", - message: "Ha ocurrido un error, inténtalo de nuevo más tarde", + message: msj, type: "is-danger", hasIcon: true, - icon: "times-circle", - iconPack: "fa", + icon: "alert-circle", + iconPack: "mdi", ariaRole: "alertdialog", ariaModal: true, }); + if (salir == true) { + localStorage.clear(); + this.$router.push(`/`); + } }, }, created() { diff --git a/pages/admin/programa/infoResponsable/modificar/index.vue b/pages/admin/programa/infoResponsable/modificar/index.vue index 0d4a43d..6a188c0 100644 --- a/pages/admin/programa/infoResponsable/modificar/index.vue +++ b/pages/admin/programa/infoResponsable/modificar/index.vue @@ -24,7 +24,7 @@
@@ -32,7 +32,7 @@ + diff --git a/pages/index.vue b/pages/index.vue index 4decf5d..11a8412 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -84,14 +84,8 @@ export default { window.localStorage.setItem("idUsuario", resp.data.Usuario.idUsuario); window.localStorage.setItem("token", resp.data.token); window.localStorage.setItem("nombre", resp.data.Usuario.nombre); - window.localStorage.setItem( - "idTipoUsuario", - resp.data.Usuario.TipoUsuario.idTipoUsuario - ); - window.localStorage.setItem( - "tipoUsuario", - resp.data.Usuario.TipoUsuario.tipoUsuario - ); + window.localStorage.setItem("idTipoUsuario", resp.data.Usuario.TipoUsuario.idTipoUsuario); + window.localStorage.setItem("tipoUsuario", resp.data.Usuario.TipoUsuario.tipoUsuario); window.localStorage.setItem("usuario", resp.data.Usuario.usuario); this.$router.push(`/${resp.data.Usuario.TipoUsuario.tipoUsuario}`); }) diff --git a/pages/responsable/nuevo/index.vue b/pages/responsable/nuevo/index.vue index dbe61e7..5c0c35e 100644 --- a/pages/responsable/nuevo/index.vue +++ b/pages/responsable/nuevo/index.vue @@ -213,6 +213,7 @@ + @@ -225,7 +226,12 @@ import moment from "moment"; export default { data() { return { - isFullPage: true, + token: { + headers:{ + token: window.localStorage.getItem('token') + } + }, + isLoading:false, noCuenta: "", sizeOk: "", searched: false, @@ -330,19 +336,48 @@ export default { return ""; } }, - buscarAlumno() { - const loadingComponent = this.$buefy.loading.open({ - container: this.isFullPage ? null : this.$refs.element.$el, - }); - axios - .get(`${process.env.api}/usuario/escolares`, { - params: { - numeroCuenta: this.noCuenta, - }, - }) - .then((resp) => { - loadingComponent.close(); + 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= "tu token esta mal formado, inicia sesión de nuevo" + salir=true + break; + case 'No hay token': + msj= "no has enviado 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", + iconPack: "mdi", + ariaRole: "alertdialog", + ariaModal: true, + }); + if (salir == true) { + localStorage.clear() + this.$router.push(`/`) + } + + }, + buscarAlumno() { + this.isLoading=true + axios + .get(`${process.env.api}/usuario/escolares?numeroCuenta=${this.noCuenta}`,this.token) + .then((resp) => { console.log(resp.data); this.alumno.cuenta = this.noCuenta; this.alumno.nombre = resp.data.nombre; @@ -350,27 +385,17 @@ export default { this.alumno.creditos = parseInt(resp.data.creditos, 10); this.alumno.idCarrera = resp.data.idCarrera; this.alumno.idAlumno = resp.data.idUsuario; - this.searched = true; }) .catch((error) => { - loadingComponent.close(); - this.$buefy.dialog.alert({ - title: "Error", - message: error.response.data.message, - type: "is-danger", - hasIcon: true, - icon: "alert-circle", - iconPack: "mdi", - ariaRole: "alertdialog", - ariaModal: true, - }); + this.error(error.response.data.message) + }) + .finally(()=>{ + this.isLoading = false }); }, Enviar() { - const loadingComponent = this.$buefy.loading.open({ - container: this.isFullPage ? null : this.$refs.element.$el, - }); + this.isLoading=true const data = { idUsuario: this.alumno.idAlumno, idPrograma: this.programaSelected.idPrograma, @@ -382,20 +407,20 @@ export default { profesor: this.programaSelected.profesor, fechaInicio: moment(this.alumno.inicio), fechaFin: moment(this.alumno.fin), - }; - const formData = new FormData(); - console.log(data); - formData.append("alumno", JSON.stringify(data)); - formData.append("cartaAceptacion", this.file); + }; + const formData = new FormData(); + console.log(data); + formData.append("alumno", JSON.stringify(data)); + formData.append("cartaAceptacion", this.file); axios .post(`${process.env.api}/servicio/nuevo`, formData, { headers: { "Content-Type": "multipart/form-data", + token:this.token.headers.token }, }) .then((res) => { - loadingComponent.close(); this.$buefy.dialog.alert({ title: "Success", message: "Se enviaron los datos correctamente", @@ -409,17 +434,10 @@ export default { this.reset(); }) .catch((error) => { - loadingComponent.close(); - this.$buefy.dialog.alert({ - title: "Error", - message: error.response.data.message, - type: "is-danger", - hasIcon: true, - icon: "alert-circle", - iconPack: "mdi", - ariaRole: "alertdialog", - ariaModal: true, - }); + this.error(error.response.data.message) + }) + .finally(()=>{ + this.isLoading = false }); }, }, @@ -451,6 +469,20 @@ export default { } } } + else{ + + this.programaSelected.institucion = ""; + this.programaSelected.dependencia = ""; + this.programaSelected.programa = ""; + this.programaSelected.clavePrograma = ""; + this.programaSelected.acatlan = ""; + this.programaSelected.activo = ""; + //this.programaSelected.idUsuario = ""; + this.programaSelected.programaInterno = ""; + this.programaSelected.profesor = ""; + + + } }, file() { console.log(this.file.size); @@ -475,18 +507,14 @@ export default { mounted() { console.log(localStorage.getItem("idUsuario")); axios - .get(`${process.env.api}/programa`, { - params: { - idUsuario: localStorage.getItem("idUsuario"), - }, - }) + .get(`${process.env.api}/programa?idUsuario=${localStorage.getItem("idUsuario")}`, this.token) .then((resp) => { console.log(resp.data); this.programas = resp.data; console.log(this.programas); }) .catch((error) => { - console.log(error.response.data.message); + this.error(error.response.data.message) }); }, computed: {