2024-08-29 22:51:13 -03:00
|
|
|
<script>
|
|
|
|
export default {
|
|
|
|
name: "ProductoCard",
|
|
|
|
props: {
|
|
|
|
producto: Object
|
|
|
|
},
|
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
cantidad: this.producto.cantidad,
|
|
|
|
enChismosa: this.producto.cantidad,
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2024-08-29 22:54:05 -03:00
|
|
|
Event.$on('sync-subpedido', (cantidad,productoId) => {
|
|
|
|
if (this.producto.id === productoId)
|
|
|
|
this.sincronizar(cantidad);
|
|
|
|
});
|
2024-08-29 22:51:13 -03:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
decrementar() {
|
|
|
|
this.cantidad -= 1;
|
|
|
|
},
|
|
|
|
incrementar() {
|
|
|
|
this.cantidad += 1;
|
|
|
|
},
|
|
|
|
confirmar() {
|
|
|
|
Event.$emit('sync-subpedido', this.cantidad, this.producto.id);
|
|
|
|
},
|
|
|
|
borrar() {
|
|
|
|
this.cantidad = 0;
|
|
|
|
this.confirmar();
|
|
|
|
},
|
|
|
|
sincronizar(cantidad) {
|
|
|
|
this.cantidad = cantidad;
|
|
|
|
this.producto.cantidad = cantidad;
|
|
|
|
this.enChismosa = cantidad;
|
|
|
|
},
|
2024-08-31 23:03:09 -03:00
|
|
|
hayCambios() {
|
|
|
|
return this.cantidad != this.enChismosa;
|
|
|
|
},
|
|
|
|
puedeBorrar() {
|
|
|
|
return this.enChismosa > 0;
|
|
|
|
},
|
2024-08-29 22:51:13 -03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
2024-09-09 00:14:29 -03:00
|
|
|
<div class="block column is-one-quarter-desktop is-full-mobile is-half-tablet min-width-from-desktop">
|
2024-08-29 22:51:13 -03:00
|
|
|
<div class="box" style="height:100%">
|
|
|
|
<div class="columns">
|
2024-09-09 00:14:29 -03:00
|
|
|
<div class="column">
|
2024-08-29 22:51:13 -03:00
|
|
|
<p class="title is-6">
|
|
|
|
{{ producto.nombre }}
|
|
|
|
</p>
|
|
|
|
<p class="subtitle is-7" v-text="producto.proveedor"></p>
|
|
|
|
</div>
|
|
|
|
<div class="column is-one-quarter has-text-right">
|
|
|
|
<p class="has-text-weight-bold has-text-primary">$<span v-text="producto.precio"></span></p>
|
|
|
|
<p class="subtitle is-7" v-if="enChismosa !== 0">{{ enChismosa }} en chismosa</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<footer class="columns">
|
|
|
|
<div class="column is-three-quarters">
|
|
|
|
<div class="field has-addons">
|
|
|
|
<div class="control">
|
|
|
|
<button class="button is-small" @click.capture="decrementar();">
|
|
|
|
<i class="fa fa-solid fa-minus"></i>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
<div class="control">
|
|
|
|
<input id="cantidad" v-model="cantidad" class="input is-small" type="number" style="text-align: center">
|
|
|
|
</div>
|
|
|
|
<div class="control" @click="incrementar();">
|
|
|
|
<button class="button is-small">
|
|
|
|
<i class="fa fa-solid fa-plus"></i>
|
|
|
|
</button>
|
|
|
|
</div>
|
2024-08-31 23:03:09 -03:00
|
|
|
<button :disabled="!hayCambios()" class="button is-small is-success ml-3" @click="confirmar()">
|
2024-08-29 22:51:13 -03:00
|
|
|
<span class="icon">
|
|
|
|
<i class="fas fa-check"></i>
|
|
|
|
</span>
|
|
|
|
</button>
|
2024-08-31 23:03:09 -03:00
|
|
|
<button :disabled="!puedeBorrar()" class="button is-small is-danger ml-3" @click="borrar()">
|
2024-08-29 22:51:13 -03:00
|
|
|
<span class="icon">
|
|
|
|
<i class="fas fa-trash-alt"></i>
|
|
|
|
</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="column is-one-quarter has-text-right">
|
|
|
|
<p>
|
|
|
|
<img v-show="producto.economia_solidaria" height="30px" width="30px" src="/assets/solidaria.png" alt="proveedor de economía solidaria">
|
|
|
|
<img v-show="producto.nacional" height="30px" width="30px" src="/assets/uruguay.png" alt="proveedor nacional"/>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</footer>
|
|
|
|
</div><!-- END BOX -->
|
2024-08-29 23:01:31 -03:00
|
|
|
</div>
|
2024-08-29 22:51:13 -03:00
|
|
|
</template>
|
|
|
|
|
2024-08-30 00:10:50 -03:00
|
|
|
<style lang="scss" scoped>
|
|
|
|
@use "bulma/sass/utilities/mixins";
|
2024-08-29 22:51:13 -03:00
|
|
|
|
2024-09-09 00:14:29 -03:00
|
|
|
@include mixins.until(mixins.$desktop) {
|
|
|
|
.hidden-until-desktop {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@include mixins.from(mixins.$desktop) {
|
|
|
|
.min-width-from-desktop {
|
2024-08-30 00:10:50 -03:00
|
|
|
min-width: 25rem;
|
|
|
|
}
|
2024-09-09 00:14:29 -03:00
|
|
|
.hidden-from-desktop {
|
|
|
|
display: none;
|
|
|
|
}
|
2024-08-30 00:10:50 -03:00
|
|
|
}
|
2024-08-29 22:51:13 -03:00
|
|
|
</style>
|