pcpuma_unam_operador/components/admin/CrearInfraccion.vue

74 lines
1.7 KiB
Vue
Raw Normal View History

2022-07-01 05:42:16 +00:00
<template>
2022-07-04 06:25:48 +00:00
<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="
2022-07-11 14:15:10 +00:00
$alertsGenericos.imprimirWarning(
$buefy,
2022-07-04 06:25:48 +00:00
'¿Está segur@ de querer crear esta infracción?',
2022-07-01 05:42:16 +00:00
crearInfraccion
)
"
2022-07-04 06:25:48 +00:00
/>
</b-field>
<b-button
type="is-info"
2022-07-11 16:56:17 +00:00
class="column is-4"
2022-07-04 06:25:48 +00:00
@click="
2022-07-11 14:15:10 +00:00
$alertsGenericos.imprimirWarning(
$buefy,
2022-07-04 06:25:48 +00:00
'¿Esta segur@ de querer crear este infracción?',
crearInfraccion
)
"
:disabled="!infraccion"
expanded
rounded
>
Crear
</b-button>
</dir>
2022-07-01 05:42:16 +00:00
</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)
2022-07-11 14:15:10 +00:00
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
2022-07-04 06:06:28 +00:00
this.infraccion = ''
2022-07-01 05:42:16 +00:00
})
.catch((err) => {
this.updateIsLoading(false)
2022-07-11 14:15:10 +00:00
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
2022-07-01 05:42:16 +00:00
})
},
},
created() {},
}
</script>