token
This commit is contained in:
@@ -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,55 @@ 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";
|
||||
break;
|
||||
case "jwt expired":
|
||||
msj = "tu sesión ha expirado, inicia sesión de nuevo";
|
||||
break;
|
||||
case "no hay token":
|
||||
msj = "no has enviado tu token, inicia sesión de nuevo";
|
||||
break;
|
||||
default:
|
||||
salir = true;
|
||||
}
|
||||
|
||||
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,
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -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,37 @@ 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";
|
||||
break;
|
||||
case "jwt expired":
|
||||
msj = "tu sesión ha expirado, inicia sesión de nuevo";
|
||||
break;
|
||||
case "no hay token":
|
||||
msj = "no has enviado tu token, inicia sesión de nuevo";
|
||||
break;
|
||||
default:
|
||||
salir = true;
|
||||
}
|
||||
|
||||
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));
|
||||
|
||||
@@ -36,10 +36,16 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import axios from 'axios';
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
csv: {},
|
||||
token: {
|
||||
headers: {
|
||||
token: window.localStorage.getItem("token"),
|
||||
},
|
||||
},
|
||||
isLoading: false,
|
||||
toastType: null,
|
||||
toastMessage: null,
|
||||
@@ -49,8 +55,8 @@ export default {
|
||||
validarExt() {
|
||||
const extPermitidas = /(.csv)$/i;
|
||||
if (!extPermitidas.exec(this.csv.name)) {
|
||||
this.toastType = 'is-danger'
|
||||
this.toastMessage = 'Asegurate de ingresar un archivo .CSV'
|
||||
this.toastType = "is-danger";
|
||||
this.toastMessage = "Asegurate de ingresar un archivo .CSV";
|
||||
this.toast();
|
||||
this.csv = {};
|
||||
}
|
||||
@@ -72,27 +78,62 @@ export default {
|
||||
onConfirm: () => this.enviarCargaMasiva(),
|
||||
});
|
||||
},
|
||||
enviarCargaMasiva () {
|
||||
enviarCargaMasiva() {
|
||||
this.isLoading = true;
|
||||
const formData = new FormData();
|
||||
if (this.cartaAceptacion) {
|
||||
formData.append("cartaAceptacion", this.cartaAceptacion);
|
||||
}
|
||||
axios
|
||||
.put(`${process.env.api}/programa/carga_masiva`, formData)
|
||||
.put(`${process.env.api}/programa/carga_masiva`, formData, {
|
||||
headers: {
|
||||
"Content-Type": "multipart/form-data",
|
||||
token: this.token.headers.token,
|
||||
},
|
||||
})
|
||||
.then((res) => {
|
||||
this.isLoading = false;
|
||||
this.toastType = 'is-success'
|
||||
this.toastMessage = 'Se ha enviado la carga masiva con éxito'
|
||||
this.toastType = "is-success";
|
||||
this.toastMessage = "Se ha enviado la carga masiva con éxito";
|
||||
this.toast();
|
||||
})
|
||||
.catch((err) => {
|
||||
this.isLoading = false;
|
||||
this.toastType = 'is-danger'
|
||||
this.toastMessage = err.response.data.message
|
||||
this.toast()
|
||||
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"
|
||||
break;
|
||||
case 'jwt expired':
|
||||
msj= "tu sesión ha expirado, inicia sesión de nuevo"
|
||||
break;
|
||||
case 'no hay token':
|
||||
msj= "no has enviado tu token, inicia sesión de nuevo"
|
||||
break;
|
||||
default:
|
||||
salir=true
|
||||
}
|
||||
|
||||
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(`/`)
|
||||
}
|
||||
},
|
||||
},
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -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,42 @@ 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"
|
||||
break;
|
||||
case 'jwt expired':
|
||||
msj= "tu sesión ha expirado, inicia sesión de nuevo"
|
||||
break;
|
||||
case 'no hay token':
|
||||
msj= "no has enviado tu token, inicia sesión de nuevo"
|
||||
break;
|
||||
default:
|
||||
salir=true
|
||||
}
|
||||
|
||||
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");
|
||||
},
|
||||
|
||||
@@ -65,22 +65,20 @@
|
||||
</p>
|
||||
</div>
|
||||
<div id="acciones" class="my-5">
|
||||
<div class="confimar mb-5">
|
||||
<b-button
|
||||
class="is-success"
|
||||
@click="confirmarDialog(1)"
|
||||
v-if="mostrarConfirmar1()"
|
||||
>
|
||||
Confirmar
|
||||
</b-button>
|
||||
<b-button
|
||||
class="is-success"
|
||||
@click="confirmarDialog(2)"
|
||||
v-if="mostrarConfirmar2()"
|
||||
>
|
||||
Confirmar
|
||||
</b-button>
|
||||
</div>
|
||||
<b-button
|
||||
class="is-success"
|
||||
@click="confirmarDialog(1)"
|
||||
v-if="mostrarConfirmar1()"
|
||||
>
|
||||
Confirmar
|
||||
</b-button>
|
||||
<b-button
|
||||
class="is-success"
|
||||
@click="confirmarDialog(2)"
|
||||
v-if="mostrarConfirmar2()"
|
||||
>
|
||||
Confirmar
|
||||
</b-button>
|
||||
<b-button class="is-danger" @click="enviarCancel = !enviarCancel">
|
||||
Cancelar
|
||||
</b-button>
|
||||
@@ -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,21 @@ 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 +257,21 @@ 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 aprovado");
|
||||
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,31 +283,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";
|
||||
break;
|
||||
case "jwt expired":
|
||||
msj = "tu sesión ha expirado, inicia sesión de nuevo";
|
||||
break;
|
||||
case "no hay token":
|
||||
msj = "no has enviado tu token, inicia sesión de nuevo";
|
||||
break;
|
||||
default:
|
||||
salir = true;
|
||||
}
|
||||
|
||||
this.$buefy.dialog.alert({
|
||||
title: "Error",
|
||||
message: "Ha ocurrido un <b>error</b>, 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() {
|
||||
await this.obtenerRegistro();
|
||||
|
||||
@@ -53,34 +53,58 @@ 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"
|
||||
break;
|
||||
case 'jwt expired':
|
||||
msj= "tu sesión ha expirado, inicia sesión de nuevo"
|
||||
break;
|
||||
case 'no hay token':
|
||||
msj= "no has enviado tu token, inicia sesión de nuevo"
|
||||
break;
|
||||
default:
|
||||
salir=true
|
||||
}
|
||||
|
||||
this.$buefy.dialog.alert({
|
||||
title: "Error",
|
||||
message: "Ha ocurrido un <b>error</b>, 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 () {
|
||||
this.obtenerProgramas()
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
<template>
|
||||
<div class="container">
|
||||
<BotonRegresar
|
||||
:path="'/admin/programa/infoResponsable'"
|
||||
/>
|
||||
<BotonRegresar :path="'/admin/programa/infoResponsable'" />
|
||||
<p class="is-size-2">Editar información del responsable</p>
|
||||
<b-field label="Nombre">
|
||||
<b-input type="text" v-model="nuevo.nombre" :placeholder="viejo.nombre">
|
||||
@@ -12,10 +10,12 @@
|
||||
<b-input type="email" v-model="nuevo.correo" :placeholder="viejo.correo">
|
||||
</b-input>
|
||||
</b-field>
|
||||
<BotonRegresar
|
||||
:path="'/admin/programa/infoResponsable'"
|
||||
/>
|
||||
<b-button class="boton is-info my-5" v-if="mostrar()" @click="editarResponsable()">
|
||||
<BotonRegresar :path="'/admin/programa/infoResponsable'" />
|
||||
<b-button
|
||||
class="boton is-info my-5"
|
||||
v-if="mostrar()"
|
||||
@click="editarResponsable()"
|
||||
>
|
||||
Editar responsable
|
||||
</b-button>
|
||||
<b-button class="boton is-info my-5" v-else disabled>
|
||||
@@ -24,42 +24,43 @@
|
||||
<b-loading
|
||||
:is-full-page="true"
|
||||
v-model="isLoading"
|
||||
:can-cancel="true"
|
||||
:can-cancel="false"
|
||||
></b-loading>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import validator from 'validator'
|
||||
import botonRegresar from '../../../../../components/botonRegresar'
|
||||
//import axios from 'axios'
|
||||
import validator from "validator";
|
||||
import botonRegresar from "../../../../../components/botonRegresar";
|
||||
import axios from "axios";
|
||||
|
||||
export default {
|
||||
components: {
|
||||
botonRegresar
|
||||
botonRegresar,
|
||||
},
|
||||
data () {
|
||||
data() {
|
||||
return {
|
||||
viejo: {
|
||||
idResponsable: localStorage.getItem("idResponsable"),
|
||||
nombre: localStorage.getItem('nombre'),
|
||||
correo: localStorage.getItem('correo'),
|
||||
nombre: localStorage.getItem("nombre"),
|
||||
correo: localStorage.getItem("correo"),
|
||||
},
|
||||
nuevo: {
|
||||
nombre: "",
|
||||
correo: ""
|
||||
correo: "",
|
||||
},
|
||||
idServicio: localStorage.getItem('idServicio'),
|
||||
token: localStorage.getItem('token'),
|
||||
isLoading: false
|
||||
}
|
||||
idServicio: localStorage.getItem("idServicio"),
|
||||
token: {
|
||||
headers: {
|
||||
token: window.localStorage.getItem("token"),
|
||||
},
|
||||
},
|
||||
isLoading: false,
|
||||
};
|
||||
},
|
||||
methods: {
|
||||
mostrar() {
|
||||
if (
|
||||
validator.isEmail(this.nuevo.correo) ||
|
||||
this.nuevo.nombre
|
||||
) {
|
||||
if (validator.isEmail(this.nuevo.correo) || this.nuevo.nombre) {
|
||||
if (this.nuevo.correo) {
|
||||
if (validator.isEmail(this.nuevo.correo)) {
|
||||
return true;
|
||||
@@ -69,12 +70,71 @@ export default {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
},
|
||||
actualizar() {
|
||||
this.isLoading = true;
|
||||
const data = {};
|
||||
if (this.nuevo.correo) {
|
||||
data.correoUpdate = this.nuevo.correo;
|
||||
}
|
||||
if (this.nuevo.nombre) {
|
||||
data.nombreUpdate = this.nuevo.nombre;
|
||||
}
|
||||
axios
|
||||
.put(`${process.env.api}/usuario/responsable/update`, data, this.token)
|
||||
.then((res) => {
|
||||
this.isLoading = false;
|
||||
this.toast();
|
||||
this.$router.push("/admin/programa/infoResponsable");
|
||||
})
|
||||
.catch((err) => {
|
||||
this.isLoading = false;
|
||||
this.error(err.response.data.message);
|
||||
console.log(err.response.data.message);
|
||||
});
|
||||
},
|
||||
toast() {
|
||||
this.$buefy.toast.open({
|
||||
message: "Se han actualizado los datos del responsable",
|
||||
type: "is-success",
|
||||
});
|
||||
},
|
||||
error(msj) {
|
||||
let salir = false;
|
||||
switch (msj) {
|
||||
case "invalid signature":
|
||||
msj = "tu token no es valido, inicia sesión de nuevo";
|
||||
break;
|
||||
case "jwt expired":
|
||||
msj = "tu sesión ha expirado, inicia sesión de nuevo";
|
||||
break;
|
||||
case "no hay token":
|
||||
msj = "no has enviado tu token, inicia sesión de nuevo";
|
||||
break;
|
||||
default:
|
||||
salir = true;
|
||||
}
|
||||
|
||||
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(`/`);
|
||||
}
|
||||
},
|
||||
},
|
||||
beforeCreate() {
|
||||
if (!localStorage.getItem("idResponsable")) {
|
||||
this.$router.push("/admin/programa");
|
||||
}
|
||||
},
|
||||
beforeCreate(){
|
||||
if(!localStorage.getItem("idResponsable")){
|
||||
this.$router.push("/admin/programa")
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user