pcpuma_unam_operador/components/admin/CrearInfraccion.vue
2022-07-11 11:56:17 -05:00

74 lines
1.7 KiB
Vue

<template>
<div class="box">
<dir class="columns is-align-items-flex-end pl-0 pb-4">
<b-field class="column mb-0 pb-0" label="Infracción">
<b-input
type="text"
placeholder="Nombre de la infracción"
v-model="infraccion"
rounded
@keyup.enter.native="
$alertsGenericos.imprimirWarning(
$buefy,
'¿Está segur@ de querer crear esta infracción?',
crearInfraccion
)
"
/>
</b-field>
<b-button
type="is-info"
class="column is-4"
@click="
$alertsGenericos.imprimirWarning(
$buefy,
'¿Esta segur@ de querer crear este infracción?',
crearInfraccion
)
"
:disabled="!infraccion"
expanded
rounded
>
Crear
</b-button>
</dir>
</div>
</template>
<script>
import axios from 'axios'
export default {
props: {
admin: { type: Object, require: true },
updateIsLoading: { type: Function, required: true },
},
data() {
return {
infraccion: '',
}
},
methods: {
crearInfraccion() {
const data = {
infraccion: this.infraccion,
}
this.updateIsLoading(true)
axios
.post(`${process.env.api}/institucion-infraccion/`, data)
.then((res) => {
this.updateIsLoading(false)
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
this.infraccion = ''
})
.catch((err) => {
this.updateIsLoading(false)
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
})
},
},
created() {},
}
</script>