pcpuma_unam_operador/components/crear/CrearAdmin.vue

126 lines
3.2 KiB
Vue
Raw Normal View History

2022-07-26 05:44:07 +00:00
<template>
<section class="mb-6">
2022-07-29 05:08:49 +00:00
<h3 class="is-size-4 mb-3">Crear Administrador</h3>
2022-07-26 05:44:07 +00:00
<div class="box">
<div class="columns is-align-items-flex-end pl-0 pb-4">
<SelectInstitucion
2022-08-03 18:12:27 +00:00
columnSize="is-3"
:idInstitucionPadre="idInstitucion"
2022-07-26 05:44:07 +00:00
@institucion-seleccionada="
2022-08-03 18:12:27 +00:00
(nuevaInstitucion) => (idInstitucion = nuevaInstitucion)
2022-07-26 05:44:07 +00:00
"
/>
<b-field class="column mb-0 pb-0" label="Nombre completo">
<b-input
icon="account"
placeholder="Nombres/Apellidos"
type="text"
2022-08-01 18:48:51 +00:00
:has-counter="false"
:maxlength="100"
2022-07-26 05:44:07 +00:00
@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"
2022-08-01 18:48:51 +00:00
:has-counter="false"
:maxlength="40"
2022-07-26 05:44:07 +00:00
@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"
2022-08-01 18:48:51 +00:00
:has-counter="false"
:maxlength="80"
2022-07-26 05:44:07 +00:00
@keyup.enter.native="warning()"
v-model="correo"
rounded
/>
</b-field>
<BotonCrear
2022-08-03 18:12:27 +00:00
columnSize="is-2"
:disabled="!idInstitucion || !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 {
2022-08-03 18:12:27 +00:00
idInstitucion: 0,
admin: '',
2022-07-26 05:44:07 +00:00
correo: '',
nombre: '',
}
},
methods: {
crearAdmin() {
const data = {
correo: this.correo,
2022-08-03 18:12:27 +00:00
id_institucion: this.idInstitucion,
2022-07-26 05:44:07 +00:00
nombre: this.nombre,
operador: this.admin,
}
this.updateIsLoading(true)
axios
2022-08-01 18:48:51 +00:00
.post(`${process.env.api}/operador/admin`, data, this.$getToken.token())
2022-07-26 05:44:07 +00:00
.then((res) => {
2022-08-03 18:12:27 +00:00
this.idInstitucion = 0
2022-07-26 05:44:07 +00:00
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)
2022-08-05 23:41:37 +00:00
this.$alertsGenericos.imprimirError(
this.$buefy,
this.$router,
err.response.data
)
2022-07-26 05:44:07 +00:00
})
},
2022-07-26 13:35:38 +00:00
warning() {
2022-08-03 18:12:27 +00:00
if (this.idInstitucion && this.admin && this.correo && this.nombre)
2022-07-26 13:35:38 +00:00
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>