carta aceptación

This commit is contained in:
xXpuma99Xx
2021-11-27 12:55:07 -06:00
parent c14cc0f860
commit de98b7a1b3
2 changed files with 81 additions and 196 deletions
+5 -10
View File
@@ -204,13 +204,9 @@ export default {
},
methods: {
fecha(date) {
if (date) {
const fecha = moment(date)
const fecha = moment(date)
return `${fecha.date() < 10 ? '0' + fecha.date() : fecha.date()}/${
fecha.month() < 9 ? '0' + (fecha.month() + 1) : fecha.month() + 1
}/${fecha.year()}`
}
if (date) return `${fecha.date()}/${fecha.month() + 1}/${fecha.year()}`
return ''
},
types(idStatus) {
@@ -255,8 +251,7 @@ export default {
return style
},
addPointer() {
if (this.idTipoUsuario === 1) return 'pointer'
return ''
return this.idTipoUsuario === 1 ? 'pointer' : ''
},
responsableUpdate(servicio, path) {
/*pendiente*/
@@ -272,9 +267,9 @@ export default {
watch: {
servicioSelected() {
if (this.idTipoUsuario === 1) {
if (this.path === '/admin/servicio')
if (this.servicioSelected.idServicio)
localStorage.setItem('idServicio', this.servicioSelected.idServicio)
if (this.path === '/admin/casos_especiales/caso_especial')
if (this.servicioSelected.idCasoEspecial)
localStorage.setItem(
'idCasoEspecial',
this.servicioSelected.idCasoEspecial
+76 -186
View File
@@ -1,231 +1,121 @@
<template>
<section class="container section">
<div class="container px-2 pb-6">
<BotonRegresar
path="/responsable"
:deleteFromLocalStorage="['idServicio']"
/>
<h3 class="title is-4 mt-4">
Carta de aceptación (en formato .PDF. No se aceptan fotos).
</h3>
<UploadArchivo
path="carta_aceptacion"
tipoCarta="aceptación"
variableName="cartaAceptacion"
:responsable="responsable"
:imprimirMensaje="imprimirMensaje"
:imprimirWarning="imprimirWarning"
:imprimirError="imprimirError"
:updateIsLoading="updateIsLoading"
/>
<b-field>
<b-upload
v-model="file"
type="is-black"
accept="application/pdf"
drag-drop
expanded
>
<div class="section content has-text-centered">
<p>
<b-icon icon="upload" size="is-large"></b-icon>
</p>
<p>
{{ file.name || 'Arrastra aquí tu archivo o da click para buscar' }}
</p>
<p>Tamaño máximo para el archivo: 20MB</p>
</div>
</b-upload>
</b-field>
<b-field class="has-text-centered">
<b-button
:disabled="!file.size"
class="border-success my-5"
type="is-success"
@click="subir()"
>Enviar</b-button
>
</b-field>
<b-loading :is-full-page="true" :can-cancel="false" v-model="isLoading">
</b-loading>
</section>
<b-loading :is-full-page="true" :can-cancel="false" v-model="isLoading" />
</div>
</template>
<script>
import axios from 'axios'
import BotonRegresar from '@/components/botonRegresar'
import UploadArchivo from '@/components/responsable/UploadArchivo'
export default {
components: { BotonRegresar, UploadArchivo },
data() {
return {
responsable: {},
file: {},
idServicio: '',
isLoading: false,
token: {},
responsable: {},
}
},
components: { BotonRegresar },
methods: {
subir() {
const formData = new FormData()
const data = { idServicio: this.idServicio }
this.isLoading = true
formData.append('data', JSON.stringify(data))
formData.append('cartaAceptacion', this.file)
axios
.put(
`${process.env.api}/servicio/carta_aceptacion`,
formData,
this.token
)
.then((res) => {
this.isLoading = false
this.$buefy.dialog.alert({
title: 'Success',
message: 'Se subio el archivo correctamente.',
type: 'is-success',
hasIcon: true,
icon: 'checkbox-marked-circle',
ariaRole: 'alertdialog',
ariaModal: true,
})
localStorage.removeItem('idServicio')
this.$router.push('/responsable')
})
.catch((err) => {
this.isLoading = false
this.imprimirerr(err.response.data)
})
updateIsLoading(booleanValue) {
this.isLoading = booleanValue
},
imprimirError(err) {
imprimirError(err = {}, title = '¡Hubo un error!', onConfirm = () => {}) {
this.$buefy.dialog.alert({
title: 'Error',
message: err.message,
type: 'is-danger',
hasIcon: true,
icon: 'alert-circle',
ariaRole: 'alertdialog',
ariaModal: true,
type: 'is-danger',
title,
message: err.message,
confirmText: 'Entendido',
hasIcon: true,
iconPack: 'mdi',
icon: 'alert-octagon',
onConfirm: () => onConfirm(),
})
if (err.err === 'token error') {
if (err.err && err.err === 'token error') {
localStorage.clear()
this.$router.push('/')
}
},
imprimirMensaje(message, title = '¡Felicidades!', onConfirm = () => {}) {
this.$buefy.dialog.alert({
ariaRole: 'alertdialog',
ariaModal: true,
type: 'is-success',
title,
message,
confirmText: 'Ok',
hasIcon: true,
iconPack: 'mdi',
icon: 'check-circle',
onConfirm: () => onConfirm(),
})
},
imprimirWarning(
message,
onConfirm = () => {},
title = '¡Espera un minuto!',
onCancel = () => {}
) {
this.$buefy.dialog.alert({
ariaRole: 'alertdialog',
ariaModal: true,
type: 'is-warning',
title,
message,
confirmText: 'Confirmar',
canCancel: true,
cancelText: 'Cancelar',
hasIcon: true,
iconPack: 'mdi',
icon: 'help-circle',
onConfirm: () => onConfirm(),
onCancel: () => onCancel(),
})
},
getLocalhostInfo() {
this.responsable.idUsuario = localStorage.getItem('idUsuario')
this.responsable.idUsuario = Number(localStorage.getItem('idUsuario'))
this.responsable.idTipoUsuario = Number(
localStorage.getItem('idTipoUsuario')
)
this.responsable.tipoUsuario = localStorage.getItem('tipoUsuario')
this.token = {
// this.responsable.token = {
// headers: {
// token: localStorage.getItem('token'),
// },
// }
this.responsable.tokenArchivo = {
headers: {
'Content-Type': 'multipart/form-data',
token: localStorage.getItem('token'),
},
}
this.idServicio = localStorage.getItem('idServicio')
},
},
watch: {
file() {
const TamMax = 20000000
if (this.file.size > TamMax) {
this.$buefy.toast.open({
message: 'El archivo excede el tamaño permitido',
type: 'is-danger',
})
this.file = {}
}
},
},
created() {
if (localStorage.getItem('idServicio')) this.getLocalhostInfo()
else this.$router.push('/responsable')
this.getLocalhostInfo()
if (this.responsable.idTipoUsuario === 1) this.$router.push('/admin')
if (this.responsable.idTipoUsuario === 3) this.$router.push('/alumno')
if (this.responsable.idTipoUsuario === 4) this.$router.push('/casoEspecial')
},
beforeCreate() {
const idTipoUsuario = Number(localStorage.getItem('idTipoUsuario'))
if (idTipoUsuario === 1) this.$router.push('/admin')
if (idTipoUsuario === 3) this.$router.push('/alumno')
if (idTipoUsuario === 4) this.$router.push('/casoEspecial')
},
// data() {
// return {
// admin: {},
// }
// },
// methods: {
// imprimirError(err = {}, title = '¡Hubo un error!', onConfirm = () => {}) {
// this.$buefy.dialog.alert({
// ariaRole: 'alertdialog',
// ariaModal: true,
// type: 'is-danger',
// title,
// message: err.message,
// confirmText: 'Entendido',
// hasIcon: true,
// iconPack: 'mdi',
// icon: 'alert-octagon',
// onConfirm: () => onConfirm(),
// })
// if (err.err && err.err === 'token error') {
// localStorage.clear()
// this.$router.push('/')
// }
// },
// imprimirMensaje(message, title = '¡Felicidades!', onConfirm = () => {}) {
// this.$buefy.dialog.alert({
// ariaRole: 'alertdialog',
// ariaModal: true,
// type: 'is-success',
// title,
// message,
// confirmText: 'Ok',
// hasIcon: true,
// iconPack: 'mdi',
// icon: 'check-circle',
// onConfirm: () => onConfirm(),
// })
// },
// imprimirWarning(
// message,
// onConfirm = () => {},
// title = '¡Espera un minuto!',
// onCancel = () => {}
// ) {
// this.$buefy.dialog.alert({
// ariaRole: 'alertdialog',
// ariaModal: true,
// type: 'is-warning',
// title,
// message,
// confirmText: 'Confirmar',
// canCancel: true,
// cancelText: 'Cancelar',
// hasIcon: true,
// iconPack: 'mdi',
// icon: 'help-circle',
// onConfirm: () => onConfirm(),
// onCancel: () => onCancel(),
// })
// },
// getLocalhostInfo() {
// this.admin.idUsuario = Number(localStorage.getItem('idUsuario'))
// this.admin.idTipoUsuario = Number(localStorage.getItem('idTipoUsuario'))
// this.admin.tipoUsuario = localStorage.getItem('tipoUsuario')
// this.admin.token = {
// headers: {
// token: localStorage.getItem('token'),
// },
// }
// },
// },
// created() {
// this.getLocalhostInfo()
// if (this.admin.idTipoUsuario === 1) this.$router.push('/admin')
// if (this.admin.idTipoUsuario === 3) this.$router.push('/alumno')
// if (this.admin.idTipoUsuario === 4) this.$router.push('/casoEspecial')
// },
}
</script>
<style></style>
<style scoped></style>