210 lines
5.3 KiB
Vue
210 lines
5.3 KiB
Vue
<template>
|
|
<div>
|
|
<span class="spanDoc"
|
|
><strong>{{ title }}</strong></span
|
|
>
|
|
<a :href="link" target="_blank">
|
|
<b-button class="is-info">
|
|
Ver
|
|
</b-button>
|
|
</a>
|
|
<b-button
|
|
class="is-danger"
|
|
v-if="esRechazable()"
|
|
@click="mensajeBool = !mensajeBool"
|
|
>
|
|
Rechazar
|
|
</b-button>
|
|
<b-field label="Razón del rechazo: " v-if="mensajeBool">
|
|
<b-input maxlength="500" type="textarea" v-model="mensajeRech"></b-input>
|
|
</b-field>
|
|
<b-button
|
|
v-if="mensajeRech && mensajeBool"
|
|
class="is-danger"
|
|
@click="rechazarDialog()"
|
|
>
|
|
Rechazar documento
|
|
</b-button>
|
|
<b-button v-else-if="mensajeBool" disabled>
|
|
Rechazar documento
|
|
</b-button>
|
|
<b-loading
|
|
:is-full-page="true"
|
|
v-model="isLoading"
|
|
:can-cancel="false"
|
|
></b-loading>
|
|
</div>
|
|
</template>
|
|
|
|
<script>
|
|
import axios from "axios";
|
|
export default {
|
|
props: {
|
|
title: String,
|
|
link: String,
|
|
idDoc: Number,
|
|
doc: String,
|
|
status: Number,
|
|
},
|
|
data() {
|
|
return {
|
|
mensajeRech: "",
|
|
mensajeBool: false,
|
|
idServicio: localStorage.getItem("idServicio"),
|
|
isLoading: false,
|
|
token: {
|
|
headers: {
|
|
token: window.localStorage.getItem("token"),
|
|
},
|
|
},
|
|
};
|
|
},
|
|
methods: {
|
|
esRechazable() {
|
|
switch (this.idDoc) {
|
|
case 1:
|
|
if (this.status == 1) return true;
|
|
else return false;
|
|
case 2:
|
|
if (this.status == 5) return true;
|
|
else return false;
|
|
case 3:
|
|
if (this.status == 5) return true;
|
|
else return false;
|
|
}
|
|
},
|
|
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();
|
|
}
|
|
},
|
|
});
|
|
},
|
|
rechazarCartaAceptacion() {
|
|
this.isLoading = true;
|
|
const data = {
|
|
mensaje: this.mensajeRech,
|
|
idServicio: this.idServicio,
|
|
};
|
|
axios
|
|
.put(
|
|
`${process.env.api}/servicio/rechazar_aceptacion`,
|
|
data,
|
|
this.token
|
|
)
|
|
.then((res) => {
|
|
this.isLoading = false;
|
|
this.$buefy.dialog.alert("Se ha rechazado el documento");
|
|
this.$router.push("/admin");
|
|
})
|
|
.catch((err) => {
|
|
this.isLoading = false;
|
|
this.error(err.response.data.message);
|
|
this.errorDoc();
|
|
});
|
|
},
|
|
rechazarCartaTermino() {
|
|
this.isLoading = true;
|
|
const data = {
|
|
mensaje: this.mensajeRech,
|
|
idServicio: this.idServicio,
|
|
};
|
|
axios
|
|
.put(`${process.env.api}/servicio/rechazar_termino`, data, this.token)
|
|
.then((res) => {
|
|
this.isLoading = false;
|
|
this.$buefy.dialog.alert("Se ha rechazado el documento");
|
|
this.$router.push("/admin");
|
|
})
|
|
.catch((err) => {
|
|
this.isLoading = false;
|
|
this.error(err.response.data.message);
|
|
this.errorDoc();
|
|
});
|
|
},
|
|
rechazarInformeGlobal() {
|
|
this.isLoading = true;
|
|
const data = {
|
|
mensaje: this.mensajeRech,
|
|
idServicio: this.idServicio,
|
|
};
|
|
axios
|
|
.put(`${process.env.api}/servicio/rechazar_informe`, data, this.token)
|
|
.then((res) => {
|
|
this.isLoading = false;
|
|
this.$buefy.dialog.alert("Se ha rechazado el documento");
|
|
this.$router.push("/admin");
|
|
})
|
|
.catch((err) => {
|
|
this.isLoading = false;
|
|
this.error(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 = "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",
|
|
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>
|