pcpuma_unam_operador/components/crear/CrearOperador.vue

133 lines
3.3 KiB
Vue
Raw Normal View History

2022-07-26 05:44:07 +00:00
<template>
<section class="mb-6">
2022-07-29 14:16:12 +00:00
<h3 class="is-size-4 mb-3">Crear operador</h3>
2022-07-26 05:44:07 +00:00
<div class="box">
<div class="columns is-align-items-flex-end pl-0 pb-4">
<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
2022-08-08 02:08:22 +00:00
icon="account-circle"
2022-07-26 05:44:07 +00:00
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="operador"
rounded
/>
</b-field>
<b-field class="column mb-0 pb-0" label="Correo">
<b-input
2022-08-08 02:08:22 +00:00
icon="email"
2022-07-26 05:44:07 +00:00
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>
<b-field class="column mb-0 pb-0" label="Contraseña">
<b-input
icon="lock"
placeholder="Contraseña"
type="password"
@keyup.enter.native="warning()"
v-model="password"
2022-08-08 02:08:22 +00:00
password-reveal
2022-07-26 05:44:07 +00:00
rounded
/>
</b-field>
<BotonCrear
2022-08-01 18:48:51 +00:00
:disabled="!operador || !correo || !nombre || !password"
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'
export default {
components: { BotonCrear },
props: {
updateActualizarTabla: { type: Function, required: true },
updateIsLoading: { type: Function, required: true },
idInstitucion: { type: Number, required: true, default: 0 },
},
data() {
return {
correo: '',
nombre: '',
operador: '',
password: '',
}
},
methods: {
2022-08-01 18:48:51 +00:00
crearOperador() {
2022-07-26 05:44:07 +00:00
const data = {
correo: this.correo,
nombre: this.nombre,
operador: this.operador,
2022-08-01 18:48:51 +00:00
password: this.password,
2022-07-26 05:44:07 +00:00
}
this.updateIsLoading(true)
axios
2022-08-01 18:48:51 +00:00
.post(
`${process.env.api}/operador/operador`,
data,
this.$getToken.token()
)
2022-07-26 05:44:07 +00:00
.then((res) => {
this.correo = ''
this.nombre = ''
this.operador = ''
this.password = ''
2022-07-26 13:35:38 +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() {
if (this.correo && this.nombre && this.operador && this.password)
this.$alertsGenericos.imprimirWarning(
this.$buefy,
'¿Esta segur@ de querer crear este operador?',
2022-08-01 18:48:51 +00:00
this.crearOperador
2022-07-26 13:35:38 +00:00
)
},
2022-07-26 05:44:07 +00:00
},
}
</script>
<style></style>