pcpuma_unam_operador/components/admin/ActivarDesactivar.vue

65 lines
1.6 KiB
Vue
Raw Normal View History

2022-06-07 18:50:55 +00:00
<template>
<div>
<b-button
:type="operador.activo ? 'is-success' : 'is-danger'"
2022-07-11 14:15:10 +00:00
@click="
$alertsGenericos.imprimirWarning(
$buefy,
mensajeWarning,
activarDesactivar
)
"
2022-06-07 18:50:55 +00:00
>
{{ operador.activo ? 'Activo' : 'Inactivo' }}
</b-button>
</div>
</template>
<script>
import axios from 'axios'
export default {
props: {
admin: { type: Object, required: true },
operador: { type: Object, required: true },
updateActualizarTabla: { type: Function, required: true },
updateIsLoading: { type: Function, required: true },
},
2022-06-23 04:49:02 +00:00
data() {
return {
mensajeWarning: '',
}
},
2022-06-07 18:50:55 +00:00
methods: {
activarDesactivar() {
const data = {
2022-06-18 04:03:18 +00:00
id_operador: this.operador.id_operador,
activo: this.operador.activo ? false : true,
2022-06-07 18:50:55 +00:00
}
this.updateIsLoading(true)
axios
2022-07-19 16:41:33 +00:00
.put(`${process.env.api}/operador`, data, this.$getToken.token())
2022-06-07 18:50:55 +00:00
.then((res) => {
this.updateIsLoading(false)
2022-07-11 14:15:10 +00:00
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
2022-06-07 18:50:55 +00:00
this.updateActualizarTabla(true)
})
.catch((err) => {
this.updateIsLoading(false)
2022-07-11 14:15:10 +00:00
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
2022-06-07 18:50:55 +00:00
})
},
},
2022-06-23 04:49:02 +00:00
created() {
this.operador.activo === true
? (this.mensajeWarning =
'¿Estás segur@ de querer desactivar a este operador?')
: (this.mensajeWarning =
'¿Estás segur@ de querer activar a este operador?')
},
2022-06-07 18:50:55 +00:00
}
</script>
<style></style>