2022-06-08 20:32:50 -03:00
|
|
|
<template>
|
2022-10-21 19:17:52 -03:00
|
|
|
<div class="field">
|
|
|
|
<input :id="'switch'+this.pedido.id" type="checkbox" name="switchRoundedSuccess" class="switch is-rounded is-success" :checked="pedido.aprobado" @change="toggleAprobacion">
|
|
|
|
<label :for="'switch'+this.pedido.id"><span class="is-hidden-mobile">{{ mensaje }}</span></label>
|
|
|
|
</div>
|
2022-06-08 20:32:50 -03:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: "BotonAdminSubpedidoRow",
|
|
|
|
props: {'subpedido': Object},
|
|
|
|
data() {
|
|
|
|
return {
|
2022-06-08 22:19:44 -03:00
|
|
|
pedido: this.subpedido
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
mensaje: function () {
|
2022-10-21 19:17:52 -03:00
|
|
|
return this.pedido.aprobado ? "Aprobado" : "No aprobado"
|
2022-06-08 20:32:50 -03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
toggleAprobacion() {
|
2022-06-08 22:19:44 -03:00
|
|
|
this.aprobado = !this.aprobado;
|
|
|
|
Event.$emit('aprobacion-subpedido', this.pedido.id, this.aprobado);
|
2022-06-08 20:32:50 -03:00
|
|
|
}
|
2022-06-08 22:19:44 -03:00
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
Event.$on('sync-aprobacion', (unSubpedido) => {
|
|
|
|
if (this.pedido.id === unSubpedido.id) {
|
|
|
|
this.pedido = unSubpedido
|
|
|
|
}
|
|
|
|
})
|
2022-06-08 20:32:50 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style scoped>
|
|
|
|
|
|
|
|
</style>
|