Files
servicio_social_front/components/admin/servicio/documento.vue
T

208 lines
5.1 KiB
Vue
Raw Normal View History

2020-12-28 04:24:00 -06:00
<template>
<div>
2021-08-04 18:25:24 -05:00
<span class="spanDoc">
<strong>{{ title }}</strong>
</span>
2020-12-28 04:24:00 -06:00
<a :href="link" target="_blank">
2021-05-13 14:22:56 -05:00
<b-button class="is-link is-light"> Ver </b-button>
2020-12-28 04:24:00 -06:00
</a>
2021-08-04 18:25:24 -05:00
2020-12-28 04:24:00 -06:00
<b-button
class="is-danger"
v-if="esRechazable()"
@click="mensajeBool = !mensajeBool"
>
Rechazar
</b-button>
2021-08-04 18:25:24 -05:00
2020-12-28 04:24:00 -06:00
<b-field label="Razón del rechazo: " v-if="mensajeBool">
2021-08-04 18:25:24 -05:00
<b-input maxlength="500" type="textarea" v-model="mensajeRech" />
2020-12-28 04:24:00 -06:00
</b-field>
2021-08-04 18:25:24 -05:00
2020-12-28 04:24:00 -06:00
<b-button
v-if="mensajeRech && mensajeBool"
class="is-danger"
@click="rechazarDialog()"
>
Rechazar documento
</b-button>
2021-08-04 18:25:24 -05:00
2021-05-13 14:22:56 -05:00
<b-button v-else-if="mensajeBool" disabled> Rechazar documento </b-button>
2021-06-09 13:44:18 -05:00
2021-08-04 18:25:24 -05:00
<b-loading :is-full-page="true" :can-cancel="false" v-model="isLoading" />
2020-12-28 04:24:00 -06:00
</div>
</template>
<script>
2021-05-13 14:22:56 -05:00
import axios from 'axios'
2021-08-04 18:25:24 -05:00
2020-12-28 04:24:00 -06:00
export default {
props: {
title: String,
link: String,
idDoc: Number,
2020-12-30 22:15:38 -06:00
doc: String,
2020-12-28 04:24:00 -06:00
status: Number,
},
data() {
return {
2021-05-13 14:22:56 -05:00
mensajeRech: '',
2020-12-28 04:24:00 -06:00
mensajeBool: false,
2021-05-13 14:22:56 -05:00
idServicio: localStorage.getItem('idServicio'),
2020-12-28 04:24:00 -06:00
isLoading: false,
2021-01-06 00:10:12 -06:00
token: {
headers: {
2021-05-16 22:14:27 -05:00
token: localStorage.getItem('token'),
2021-01-06 00:10:12 -06:00
},
},
2021-05-13 14:22:56 -05:00
}
2020-12-28 04:24:00 -06:00
},
methods: {
esRechazable() {
switch (this.idDoc) {
case 1:
2021-05-13 14:22:56 -05:00
if (this.status == 1) return true
else return false
2020-12-28 04:24:00 -06:00
case 2:
2021-05-13 14:22:56 -05:00
if (this.status == 5) return true
else return false
2020-12-28 04:24:00 -06:00
case 3:
2021-05-13 14:22:56 -05:00
if (this.status == 5) return true
else return false
2020-12-28 04:24:00 -06:00
}
},
rechazarDialog() {
this.$buefy.dialog.confirm({
2021-05-13 14:22:56 -05:00
title: 'Confimar servicio',
message: '¿Seguro(a) que quiere rechazar este documento?',
confirmText: 'Confirmar',
cancelText: 'Cancelar',
type: 'is-danger',
2020-12-28 04:24:00 -06:00
hasIcon: true,
onConfirm: () => {
switch (this.idDoc) {
case 1:
2021-05-13 14:22:56 -05:00
this.rechazarCartaAceptacion()
break
2020-12-28 04:24:00 -06:00
case 2:
2021-05-13 14:22:56 -05:00
this.rechazarCartaTermino()
break
2020-12-28 04:24:00 -06:00
case 3:
2021-05-13 14:22:56 -05:00
this.rechazarInformeGlobal()
2020-12-28 04:24:00 -06:00
}
},
2021-05-13 14:22:56 -05:00
})
2020-12-28 04:24:00 -06:00
},
rechazarCartaAceptacion() {
2021-05-13 14:22:56 -05:00
this.isLoading = true
2020-12-28 04:24:00 -06:00
const data = {
mensaje: this.mensajeRech,
idServicio: this.idServicio,
2021-05-13 14:22:56 -05:00
}
2020-12-28 04:24:00 -06:00
axios
2021-01-06 00:10:12 -06:00
.put(
`${process.env.api}/servicio/rechazar_aceptacion`,
data,
this.token
)
2020-12-28 04:24:00 -06:00
.then((res) => {
2021-05-13 14:22:56 -05:00
this.isLoading = false
this.$buefy.dialog.alert('Se ha rechazado el documento')
this.$router.push('/admin')
2020-12-28 04:24:00 -06:00
})
.catch((err) => {
2021-05-13 14:22:56 -05:00
this.isLoading = false
this.error(err.response.data.message)
this.errorDoc()
})
2020-12-28 04:24:00 -06:00
},
rechazarCartaTermino() {
2021-05-13 14:22:56 -05:00
this.isLoading = true
2020-12-28 04:24:00 -06:00
const data = {
mensaje: this.mensajeRech,
idServicio: this.idServicio,
2021-05-13 14:22:56 -05:00
}
2020-12-28 04:24:00 -06:00
axios
2021-01-06 00:10:12 -06:00
.put(`${process.env.api}/servicio/rechazar_termino`, data, this.token)
2020-12-28 04:24:00 -06:00
.then((res) => {
2021-05-13 14:22:56 -05:00
this.isLoading = false
this.$buefy.dialog.alert('Se ha rechazado el documento')
this.$router.push('/admin')
2020-12-28 04:24:00 -06:00
})
.catch((err) => {
2021-05-13 14:22:56 -05:00
this.isLoading = false
this.error(err.response.data.message)
this.errorDoc()
})
2020-12-28 04:24:00 -06:00
},
rechazarInformeGlobal() {
2021-05-13 14:22:56 -05:00
this.isLoading = true
2020-12-28 04:24:00 -06:00
const data = {
mensaje: this.mensajeRech,
idServicio: this.idServicio,
2021-05-13 14:22:56 -05:00
}
2020-12-28 04:24:00 -06:00
axios
2021-01-06 00:10:12 -06:00
.put(`${process.env.api}/servicio/rechazar_informe`, data, this.token)
2020-12-28 04:24:00 -06:00
.then((res) => {
2021-05-13 14:22:56 -05:00
this.isLoading = false
this.$buefy.dialog.alert('Se ha rechazado el documento')
this.$router.push('/admin')
2020-12-28 04:24:00 -06:00
})
.catch((err) => {
2021-05-13 14:22:56 -05:00
this.isLoading = false
this.error(err.response.data.message)
this.errorDoc()
})
2020-12-28 04:24:00 -06:00
},
2021-01-06 00:10:12 -06:00
error(msj) {
2021-05-13 14:22:56 -05:00
let salir = false
2021-01-06 00:10:12 -06:00
switch (msj) {
2021-05-13 14:22:56 -05:00
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
2021-01-06 00:10:12 -06:00
}
this.$buefy.dialog.alert({
2021-05-13 14:22:56 -05:00
title: 'Error',
2021-01-06 00:10:12 -06:00
message: msj,
2021-05-13 14:22:56 -05:00
type: 'is-danger',
2021-01-06 00:10:12 -06:00
hasIcon: true,
2021-05-13 14:22:56 -05:00
icon: 'alert-circle',
ariaRole: 'alertdialog',
2021-01-06 00:10:12 -06:00
ariaModal: true,
2021-05-13 14:22:56 -05:00
})
2021-01-06 15:27:23 -06:00
if (salir == true) {
2021-05-13 14:22:56 -05:00
localStorage.clear()
this.$router.push(`/`)
2021-01-06 00:10:12 -06:00
}
},
errorDoc() {
this.$buefy.dialog.alert({
2021-05-13 14:22:56 -05:00
title: 'Error',
message: 'Ha ocurrido un error al rechazar el documento',
type: 'is-danger',
2021-01-06 00:10:12 -06:00
hasIcon: true,
2021-05-13 14:22:56 -05:00
icon: 'times-circle',
iconPack: 'fa',
ariaRole: 'alertdialog',
2021-01-06 00:10:12 -06:00
ariaModal: true,
2021-05-13 14:22:56 -05:00
})
2021-01-06 00:10:12 -06:00
},
2020-12-28 04:24:00 -06:00
},
2021-05-13 14:22:56 -05:00
}
2020-12-28 04:24:00 -06:00
</script>