65 lines
1.5 KiB
Vue
65 lines
1.5 KiB
Vue
<template>
|
|
<div>
|
|
<b-button
|
|
:type="operador.activo ? 'is-success' : 'is-danger'"
|
|
@click="
|
|
$alertsGenericos.imprimirWarning(
|
|
$buefy,
|
|
mensajeWarning,
|
|
activarDesactivar
|
|
)
|
|
"
|
|
>
|
|
{{ 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 },
|
|
},
|
|
data() {
|
|
return {
|
|
mensajeWarning: '',
|
|
}
|
|
},
|
|
methods: {
|
|
activarDesactivar() {
|
|
const data = {
|
|
id_operador: this.operador.id_operador,
|
|
activo: this.operador.activo ? false : true,
|
|
}
|
|
|
|
this.updateIsLoading(true)
|
|
axios
|
|
.put(`${process.env.api}/operador`, data)
|
|
.then((res) => {
|
|
this.updateIsLoading(false)
|
|
this.$alertsGenericos.imprimirMensaje(this.$buefy, res.data.message)
|
|
this.updateActualizarTabla(true)
|
|
})
|
|
.catch((err) => {
|
|
this.updateIsLoading(false)
|
|
this.$alertsGenericos.imprimirError(this.$buefy, err.response.data)
|
|
})
|
|
},
|
|
},
|
|
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?')
|
|
},
|
|
}
|
|
</script>
|
|
|
|
<style></style>
|