pcpuma_unam_operador/components/crear/CrearModulo.vue

76 lines
1.9 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">
2022-07-29 14:16:12 +00:00
<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
2022-08-08 02:08:22 +00:00
icon="store"
2022-07-26 13:35:38 +00:00
placeholder="Nombre del módulo"
type="text"
@keyup.enter.native="warning()"
v-model="modulo"
rounded
/>
</b-field>
2022-07-29 05:08:49 +00:00
<BotonCrear columnSize="is-3" :disabled="!modulo" :crear="warning" />
2022-07-26 13:35:38 +00:00
</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-29 05:08:49 +00:00
const data = {
2022-07-26 13:35:38 +00:00
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)
2022-08-05 23:41:37 +00:00
this.$alertsGenericos.imprimirError(
this.$buefy,
this.$router,
err.response.data
)
2022-07-26 13:35:38 +00:00
})
},
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>