pcpuma_unam_operador/components/panel_admin/AdminInstitucionA.vue

178 lines
4.8 KiB
Vue
Raw Normal View History

2022-07-11 08:23:33 +00:00
<template>
<div class="column is-4">
2022-07-28 23:32:41 +00:00
<h3 class="is-size-4 mb-4">Configuración</h3>
2022-07-11 08:23:33 +00:00
2022-07-29 03:54:06 +00:00
<b-field label="Dominio">
<b-input
type="text"
:placeholder="institucion.dominio"
:disabled="!institucion.id_institucion"
v-model="dominio"
/>
</b-field>
2022-07-11 08:23:33 +00:00
2022-07-29 03:54:06 +00:00
<b-field label="Días de multa por retraso">
<b-input
type="number"
:placeholder="institucion.dias_multa_retraso"
:disabled="!institucion.id_institucion"
v-model="diasMultaRetraso"
/>
</b-field>
2022-07-13 19:10:31 +00:00
2022-07-29 03:54:06 +00:00
<b-field label="Tiempo para recoger equipo">
<b-input
type="number"
:placeholder="institucion.tiempo_recoger"
:disabled="!institucion.id_institucion"
v-model="tiempoRecoger"
/>
</b-field>
2022-07-13 19:10:31 +00:00
2022-07-29 03:54:06 +00:00
<b-field label="Tiempo para entregar equipo">
<b-input
type="number"
:placeholder="institucion.tiempo_entrega"
:disabled="!institucion.id_institucion"
v-model="tiempoEntrega"
/>
</b-field>
2022-07-13 23:30:48 +00:00
2022-07-29 03:54:06 +00:00
<b-field label="Tiempo de préstamo">
<b-input
type="number"
:placeholder="institucion.tiempo_prestamo"
:disabled="!institucion.id_institucion"
v-model="tiempoPrestamo"
/>
</b-field>
2022-07-13 19:10:31 +00:00
2022-08-14 22:23:01 +00:00
<!-- <b-field class="file">
2022-07-29 03:54:06 +00:00
<b-upload v-model="logo" expanded accept=".png,.jpeg,.jpg">
<a class="button is-primary is-fullwidth">
<b-icon icon="upload" />
2022-07-28 23:32:41 +00:00
2022-07-29 03:54:06 +00:00
<span>{{ logo.name || 'Click para subir el logo' }}</span>
</a>
</b-upload>
2022-08-14 22:23:01 +00:00
</b-field> -->
2022-07-26 03:21:42 +00:00
2022-07-29 03:54:06 +00:00
<BotonGuardar
:disabled="
2022-08-14 22:23:01 +00:00
!dominio &&
!diasMultaRetraso &&
!tiempoPrestamo &&
!tiempoRecoger &&
!tiempoEntrega &&
!logo.name
2022-07-29 03:54:06 +00:00
"
:guardar="actualizarDatos"
msjWarning="¿Estas segur@ de querer guardar estos cambios?"
/>
2022-08-14 22:23:01 +00:00
<!-- <BotonFinSemestre :updateIsLoading="updateIsLoading" :admin="admin" /> -->
2022-07-11 08:23:33 +00:00
</div>
</template>
<script>
import axios from 'axios'
import BotonFinSemestre from '@/components/botones/BotonFinSemestre'
2022-07-28 23:32:41 +00:00
import BotonGuardar from '@/components/botones/BotonGuardar'
2022-07-11 08:23:33 +00:00
export default {
components: {
2022-07-28 23:32:41 +00:00
BotonGuardar,
BotonFinSemestre,
},
2022-07-11 08:23:33 +00:00
props: {
buscar: { type: Function, required: true },
updateIsLoading: { type: Function, required: true },
admin: { type: Object, required: true },
institucion: { type: Object, required: true },
},
data() {
return {
2022-07-11 20:58:10 +00:00
dominio: '',
2022-07-13 23:30:48 +00:00
diasMultaRetraso: '',
tiempoRecoger: '',
tiempoEntrega: '',
tiempoPrestamo: '',
2022-07-26 03:21:42 +00:00
logo: {},
2022-07-11 08:23:33 +00:00
}
},
methods: {
actualizarDatos() {
const data = { id_institucion: this.institucion.id_institucion }
this.updateIsLoading(true)
2022-08-14 22:23:01 +00:00
if (Object.entries(this.logo).length != 0) this.subirLogo()
if (
this.dominio ||
this.diasMultaRetraso ||
this.tiempoRecoger ||
this.tiempoEntrega ||
this.tiempoPrestamo
) {
if (this.dominio) {
data.email_institucional = true
data.dominio = this.dominio
}
if (this.diasMultaRetraso)
data.dias_multa_retraso = Number(this.diasMultaRetraso)
if (this.tiempoRecoger) data.tiempo_recoger = Number(this.tiempoRecoger)
if (this.tiempoEntrega) data.tiempo_entrega = Number(this.tiempoEntrega)
if (this.tiempoPrestamo)
data.tiempo_prestamo = Number(this.tiempoPrestamo)
axios
.put(`${process.env.api}/institucion`, data, this.$getToken.token())
.then((res) => {
this.dominio = ''
this.diasMultaRetraso = ''
this.tiempoRecoger = ''
this.tiempoEntrega = ''
this.tiempoPrestamo = ''
this.buscar()
this.updateIsLoading(false)
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
})
.catch((err) => {
this.updateIsLoading(false)
this.$alertsGenericos.imprimirError(
this.$buefy,
this.$router,
err.response.data
)
})
2022-07-13 19:10:31 +00:00
}
2022-07-11 08:23:33 +00:00
},
2022-07-26 03:21:42 +00:00
subirLogo() {
const formData = new FormData()
this.updateIsLoading(true)
formData.append('logo', this.logo)
axios
.post(
`${process.env.api}/upload-file/upload-logo?id_institucion=${this.admin.institucion.id_institucion}`,
formData,
this.$getToken.token()
)
.then((res) => {
this.logo = {}
this.updateIsLoading(false)
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
})
.catch((err) => {
this.updateIsLoading(false)
2022-08-05 23:41:37 +00:00
this.$alertsGenericos.imprimirError(
this.$buefy,
this.$router,
err.response.data
)
2022-07-26 03:21:42 +00:00
})
},
2022-07-11 08:23:33 +00:00
},
}
</script>
<style></style>