pcpuma_unam_operador/components/panel_admin/AdminInstitucionSA.vue

107 lines
3.0 KiB
Vue
Raw Normal View History

2022-07-28 23:32:41 +00:00
<template>
<div class="column is-4">
<h3 class="is-size-4 mb-4">Alta del responsable de PC-Puma</h3>
2022-08-01 18:48:51 +00:00
<b-field label="Nombre del responsable" v-show="admin.tipoUsuario.id_tipo_usuario === 2">
2022-07-29 03:54:06 +00:00
<b-input
type="text"
:disabled="!institucion.id_institucion"
2022-08-01 18:48:51 +00:00
:has-counter="false"
:maxlength="60"
:placeholder="institucion.responsable"
2022-07-29 03:54:06 +00:00
v-model="responsable"
/>
</b-field>
2022-07-28 23:32:41 +00:00
2022-07-29 03:54:06 +00:00
<b-field label="Correo" v-show="admin.tipoUsuario.id_tipo_usuario === 2">
<b-input
type="email"
:disabled="!institucion.id_institucion"
2022-08-01 18:48:51 +00:00
:has-counter="false"
:maxlength="60"
:placeholder="institucion.correo"
2022-07-29 03:54:06 +00:00
v-model="correo"
/>
</b-field>
2022-07-28 23:32:41 +00:00
2022-07-29 03:54:06 +00:00
<b-field label="Teléfono" v-show="admin.tipoUsuario.id_tipo_usuario === 2">
<b-input
type="tel"
:disabled="!institucion.id_institucion"
2022-08-01 18:48:51 +00:00
:has-counter="false"
:maxlength="10"
:placeholder="institucion.telefono"
2022-07-29 03:54:06 +00:00
v-model="telefono"
/>
</b-field>
2022-07-28 23:32:41 +00:00
2022-07-29 03:54:06 +00:00
<b-field label="Ubicación" v-show="admin.tipoUsuario.id_tipo_usuario === 2">
<b-input
type="text"
:disabled="!institucion.id_institucion"
2022-08-01 18:48:51 +00:00
:has-counter="false"
:maxlength="100"
:placeholder="institucion.ubicacion"
2022-07-29 03:54:06 +00:00
v-model="ubicacion"
/>
</b-field>
2022-07-28 23:32:41 +00:00
2022-07-29 03:54:06 +00:00
<BotonGuardar
:disabled="responsable || correo || telefono || ubicacion ? false : true"
:guardar="actualizarDatos"
msjWarning="¿Estas segur@ de querer guardar estos cambios?"
/>
2022-07-28 23:32:41 +00:00
</div>
</template>
<script>
import axios from 'axios'
import BotonGuardar from '@/components/botones/BotonGuardar'
export default {
components: { BotonGuardar },
props: {
buscar: { type: Function, required: true },
updateIsLoading: { type: Function, required: true },
admin: { type: Object, required: true },
institucion: { type: Object, required: true },
},
data() {
return {
correo: '',
responsable: '',
telefono: '',
ubicacion: '',
}
},
methods: {
actualizarDatos() {
const data = { id_institucion: this.institucion.id_institucion }
this.updateIsLoading(true)
if (this.correo) data.correo = this.correo
if (this.responsable) data.responsable = this.responsable
if (this.telefono) data.telefono = this.telefono
if (this.ubicacion) data.ubicacion = this.ubicacion
axios
.put(`${process.env.api}/institucion`, data, this.$getToken.token())
.then((res) => {
this.correo = ''
this.responsable = ''
this.telefono = ''
this.ubicacion = ''
this.buscar()
this.updateIsLoading(false)
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
})
.catch((err) => {
this.updateIsLoading(false)
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
})
},
},
}
</script>
<style></style>