Files
servicio_social_front/components/admin/servicio/Archivo.vue
T
2021-08-12 12:22:04 -05:00

155 lines
3.9 KiB
Vue

<template>
<div class="mb-4">
<div class="is-flex is-align-items-center">
<h6 class="pr-4">Ver {{ title }}</h6>
<a
:href="`https://drive.google.com/file/d/${this.archivo()}/view?usp=sharing`"
class="pr-3"
target="_blank"
>
<b-button class="is-link is-light"> Ver </b-button>
</a>
<b-button
type="is-danger"
@click="updateRechazar()"
v-if="esRechazable()"
>
Rechazar
</b-button>
</div>
<div v-if="rechazar">
<b-field label="Razón del rechazo:">
<b-input maxlength="500" type="textarea" v-model="mensajeRechazo" />
</b-field>
<b-button
class="is-link"
@click="
imprimirWarning(
'¿Seguro(a) que quiere rechazar este documento?',
rechazarArchivo
)
"
:disabled="!mensajeRechazo"
>
Rechazar documento
</b-button>
</div>
</div>
</template>
<script>
import axios from 'axios'
export default {
data() {
return {
mensajeRechazo: '',
rechazar: false,
}
},
props: {
admin: { type: Object, required: true },
imprimirMensaje: { type: Function, required: true },
imprimirWarning: { type: Function, required: true },
imprimirError: { type: Function, required: true },
updateIsLoading: { type: Function, required: true },
catchError: { type: Function, required: true },
regresar: { type: Function, required: true },
alumno: { type: Object, required: true },
title: { type: String, required: true },
},
methods: {
updateRechazar() {
if (this.rechazar) this.mensajeRechazo = ''
this.rechazar = !this.rechazar
},
esRechazable() {
if (
(this.alumno.Status.idStatus === 1 &&
this.title === 'carta de aceptación') ||
(this.alumno.Status.idStatus === 5 &&
(this.title === 'carta de termino' ||
this.title === 'informe global'))
)
return true
return false
},
archivo() {
if (this.title === 'carta de aceptación')
return this.alumno.cartaAceptacion
if (this.title === 'carta de termino') return this.alumno.cartaTermino
if (this.title === 'informe global') return this.alumno.informeGlobal
},
rechazarArchivo() {
if (this.title === 'carta de aceptación') this.rechazarCartaAceptacion()
if (this.title === 'carta de termino') this.rechazarCartaTermino()
if (this.title === 'informe global') this.rechazarInformeGlobal()
},
rechazarCartaAceptacion() {
const data = {
idServicio: this.alumno.idServicio,
mensaje: this.mensajeRechazo,
}
this.updateIsLoading(true)
axios
.put(
`${process.env.api}/servicio/rechazar_aceptacion`,
data,
this.admin.token
)
.then((res) => {
this.regresar(res.data.message)
})
.catch((err) => {
this.catchError(err.response.data)
})
},
rechazarCartaTermino() {
const data = {
idServicio: this.alumno.idServicio,
mensaje: this.mensajeRechazo,
}
this.updateIsLoading(true)
axios
.put(
`${process.env.api}/servicio/rechazar_termino`,
data,
this.admin.token
)
.then((res) => {
this.regresar(res.data.message)
})
.catch((err) => {
this.catchError(err.response.data)
})
},
rechazarInformeGlobal() {
const data = {
mensaje: this.mensajeRechazo,
idServicio: this.alumno.idServicio,
}
this.updateIsLoading(true)
axios
.put(
`${process.env.api}/servicio/rechazar_informe`,
data,
this.admin.token
)
.then((res) => {
this.regresar(res.data.message)
})
.catch((err) => {
this.catchError(err.response.data)
})
},
},
}
</script>