2022-07-26 05:44:07 +00:00
|
|
|
<template>
|
|
|
|
<section class="mb-6">
|
|
|
|
<h3 class="is-size-4 mb-3">Crear Administradores</h3>
|
|
|
|
|
|
|
|
<div class="box">
|
|
|
|
<div class="columns is-align-items-flex-end pl-0 pb-4">
|
|
|
|
<SelectInstitucion
|
|
|
|
:institucionPadre="institucion"
|
|
|
|
@institucion-seleccionada="
|
|
|
|
(nuevaInstitucion) => (institucion = nuevaInstitucion)
|
|
|
|
"
|
|
|
|
/>
|
|
|
|
|
|
|
|
<b-field class="column mb-0 pb-0" label="Nombre completo">
|
|
|
|
<b-input
|
|
|
|
icon="account"
|
|
|
|
placeholder="Nombres/Apellidos"
|
|
|
|
type="text"
|
|
|
|
@keyup.enter.native="warning()"
|
|
|
|
v-model="nombre"
|
|
|
|
rounded
|
|
|
|
/>
|
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<b-field class="column mb-0 pb-0" label="Usuario">
|
|
|
|
<b-input
|
|
|
|
icon="account"
|
|
|
|
placeholder="Usuario"
|
|
|
|
type="text"
|
|
|
|
@keyup.enter.native="warning()"
|
|
|
|
v-model="admin"
|
|
|
|
rounded
|
|
|
|
/>
|
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<b-field class="column mb-0 pb-0" label="Correo">
|
|
|
|
<b-input
|
|
|
|
icon="mail"
|
|
|
|
placeholder="Correo"
|
|
|
|
type="email"
|
|
|
|
@keyup.enter.native="warning()"
|
|
|
|
v-model="correo"
|
|
|
|
rounded
|
|
|
|
/>
|
|
|
|
</b-field>
|
|
|
|
|
|
|
|
<BotonCrear
|
|
|
|
:disabled="
|
2022-07-29 01:04:17 +00:00
|
|
|
!institucion.id_institucion || !admin || !correo || !nombre
|
2022-07-26 05:44:07 +00:00
|
|
|
"
|
|
|
|
:crear="warning"
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
import axios from 'axios'
|
|
|
|
import BotonCrear from '@/components/botones/BotonCrear'
|
2022-07-26 13:35:38 +00:00
|
|
|
import SelectInstitucion from '@/components/selects/SelectInstitucion'
|
2022-07-26 05:44:07 +00:00
|
|
|
|
|
|
|
export default {
|
|
|
|
components: { BotonCrear, SelectInstitucion },
|
|
|
|
props: {
|
|
|
|
updateActualizarTabla: { type: Function, required: true },
|
|
|
|
updateIsLoading: { type: Function, required: true },
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
institucion: {},
|
|
|
|
correo: '',
|
|
|
|
nombre: '',
|
|
|
|
admin: '',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
crearAdmin() {
|
|
|
|
const data = {
|
|
|
|
correo: this.correo,
|
|
|
|
id_institucion: this.institucion.id_institucion,
|
|
|
|
id_tipo_usuario: 3,
|
|
|
|
nombre: this.nombre,
|
|
|
|
operador: this.admin,
|
|
|
|
}
|
|
|
|
|
|
|
|
this.updateIsLoading(true)
|
|
|
|
axios
|
|
|
|
.post(`${process.env.api}/operador`, data, this.$getToken.token())
|
|
|
|
.then((res) => {
|
|
|
|
this.institucion = {}
|
|
|
|
this.admin = ''
|
|
|
|
this.correo = ''
|
|
|
|
this.nombre = ''
|
2022-07-29 01:04:17 +00:00
|
|
|
this.updateActualizarTabla(true)
|
2022-07-26 05:44:07 +00:00
|
|
|
this.updateIsLoading(false)
|
|
|
|
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
this.updateIsLoading(false)
|
|
|
|
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
|
|
|
|
})
|
|
|
|
},
|
2022-07-26 13:35:38 +00:00
|
|
|
warning() {
|
|
|
|
if (
|
|
|
|
this.institucion.id_institucion &&
|
|
|
|
this.admin &&
|
|
|
|
this.correo &&
|
|
|
|
this.nombre
|
|
|
|
)
|
|
|
|
this.$alertsGenericos.imprimirWarning(
|
|
|
|
this.$buefy,
|
|
|
|
'¿Esta segur@ de querer crear este admin?',
|
|
|
|
this.crearAdmin
|
|
|
|
)
|
|
|
|
},
|
2022-07-26 05:44:07 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style></style>
|