pcpuma_unam_operador/components/crear/CrearModulo.vue

72 lines
1.8 KiB
Vue
Raw Normal View History

2022-07-26 05:44:07 +00:00
<template>
2022-07-26 13:35:38 +00:00
<section class="mb-6">
<h3 class="is-size-4 mb-3">Crear Módulo</h3>
2022-07-26 05:44:07 +00:00
2022-07-26 13:35:38 +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="Módulo">
<b-input
icon="storefront-outline"
placeholder="Nombre del módulo"
type="text"
@keyup.enter.native="warning()"
v-model="modulo"
rounded
/>
</b-field>
<BotonCrear :disabled="!modulo" :crear="warning" />
</div>
</div>
</section>
2022-07-26 05:44:07 +00:00
</template>
<script>
import axios from 'axios'
2022-07-26 13:35:38 +00:00
import BotonCrear from '@/components/botones/BotonCrear'
2022-07-26 05:44:07 +00:00
export default {
2022-07-26 13:35:38 +00:00
components: { BotonCrear },
2022-07-26 05:44:07 +00:00
props: {
updateActualizarTabla: { type: Function, required: true },
updateIsLoading: { type: Function, required: true },
2022-07-26 13:35:38 +00:00
idInstitucion: { type: Number, required: true, default: 0 },
2022-07-26 05:44:07 +00:00
},
data() {
return {
2022-07-26 13:35:38 +00:00
modulo: '',
2022-07-26 05:44:07 +00:00
}
},
methods: {
crearModulo() {
2022-07-26 13:35:38 +00:00
let data = {
id_institucion: this.idInstitucion,
modulo: this.modulo,
2022-07-26 05:44:07 +00:00
}
2022-07-26 13:35:38 +00:00
this.updateIsLoading(true)
axios
.post(`${process.env.api}/modulo`, data, this.$getToken.token())
.then((res) => {
this.modulo = ''
this.updateActualizarTabla(true)
this.updateIsLoading(false)
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
})
.catch((err) => {
this.updateIsLoading(false)
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
})
},
warning() {
if (this.modulo)
this.$alertsGenericos.imprimirWarning(
this.$buefy,
'¿Esta segur@ de querer crear este módulo?',
this.crearModulo
)
2022-07-26 05:44:07 +00:00
},
},
}
</script>