2022-01-11 18:45:00 -03:00
|
|
|
Vue.component('categorias-container', {
|
|
|
|
template: `
|
2022-01-13 20:15:46 -03:00
|
|
|
<div v-show="visible" class="container">
|
2022-01-11 18:45:00 -03:00
|
|
|
<div class="columns is-multiline is-mobile">
|
|
|
|
<div v-for="catego in categorias" class="block column is-one-quarter-desktop is-one-third-tablet is-half-mobile">
|
2022-01-13 20:15:46 -03:00
|
|
|
<div @click.capture="seleccionarCategoria(catego)" class="card" style="height:100%" >
|
2022-01-11 18:45:00 -03:00
|
|
|
<div class="card-content">
|
|
|
|
<div class="media">
|
|
|
|
<div class="media-content" style="overflow:hidden">
|
|
|
|
<p class="title is-6" v-text="catego"></p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-01-12 12:04:02 -03:00
|
|
|
</div><!-- END CARD -->
|
|
|
|
</div><!-- END BLOCK COLUMN -->
|
|
|
|
</div><!-- END COLUMNS -->
|
|
|
|
</div><!-- END CONTAINER -->`,
|
2022-01-11 18:45:00 -03:00
|
|
|
data() {
|
|
|
|
return {
|
2022-01-13 20:15:46 -03:00
|
|
|
categorias: null,
|
|
|
|
visible: true,
|
|
|
|
miga: {
|
|
|
|
nombre: "Categorías",
|
|
|
|
href: "/productos"
|
|
|
|
}
|
2022-01-11 18:45:00 -03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
|
|
|
axios.get("/api/categorias").then(response => {
|
|
|
|
this.categorias = response.data;
|
|
|
|
});
|
2022-01-13 20:15:46 -03:00
|
|
|
Event.$emit("migas-setear-como-inicio",this.miga);
|
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
seleccionarCategoria(categoria) {
|
|
|
|
this.visible = false;
|
|
|
|
Event.$emit("categoria-seleccionada",categoria);
|
|
|
|
}
|
2022-01-11 18:45:00 -03:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
Vue.component('productos-container', {
|
|
|
|
template: `
|
2022-01-13 20:15:46 -03:00
|
|
|
<div v-show="visible" class="container">
|
2022-01-12 12:04:02 -03:00
|
|
|
<div class="columns is-multiline is-mobile">
|
|
|
|
<div v-for="producto in productos" class="block column is-one-quarter-desktop is-one-third-tablet is-half-mobile">
|
|
|
|
<div class="card" style="height:100%">
|
|
|
|
<div class="card-image">
|
|
|
|
<figure class="image is-4by3">
|
2022-01-13 20:15:46 -03:00
|
|
|
<img v-bind:src="producto.imagen ? producto.imagen : 'https://bulma.io/images/placeholders/1280x960.png'">
|
2022-01-12 12:04:02 -03:00
|
|
|
</figure>
|
2022-01-11 18:45:00 -03:00
|
|
|
</div>
|
2022-01-12 12:04:02 -03:00
|
|
|
<div class="card-content">
|
|
|
|
<div class="media">
|
|
|
|
<div class="media-content">
|
|
|
|
<p class="title is-6" v-text="producto.nombre"></p>
|
2022-01-13 20:15:46 -03:00
|
|
|
<p class="subtitle is-7" v-text="producto.proveedor"></p>
|
|
|
|
<p class="subtitle is-7">$<span v-text="producto.precio"></span></p>
|
2022-01-12 12:04:02 -03:00
|
|
|
</div>
|
|
|
|
</div>
|
2022-01-11 18:45:00 -03:00
|
|
|
</div>
|
2022-01-12 12:04:02 -03:00
|
|
|
</div><!-- END CARD -->
|
|
|
|
</div><!-- END BLOCK COLUMN -->
|
|
|
|
</div><!-- END COLUMNS -->
|
|
|
|
</div><!-- END CONTAINER -->`,
|
2022-01-11 18:45:00 -03:00
|
|
|
data() {
|
|
|
|
return {
|
2022-01-13 20:15:46 -03:00
|
|
|
productos: [],
|
|
|
|
visible: false,
|
|
|
|
categoria: null,
|
|
|
|
paginar: 150
|
|
|
|
}
|
|
|
|
},
|
|
|
|
computed: {
|
|
|
|
miga: function(){
|
|
|
|
return {
|
|
|
|
nombre: this.categoria,
|
|
|
|
href: "#" + this.categoria
|
|
|
|
}
|
2022-01-11 18:45:00 -03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
mounted() {
|
2022-01-13 20:15:46 -03:00
|
|
|
Event.$on('categoria-seleccionada', (categoria) => {
|
|
|
|
this.categoria = categoria;
|
|
|
|
|
|
|
|
axios.get("/api/productos", {
|
|
|
|
params: {
|
|
|
|
categoria: this.categoria,
|
|
|
|
paginar: this.paginar
|
|
|
|
}
|
|
|
|
}).then(response => {
|
|
|
|
this.productos = response.data.data;
|
|
|
|
});
|
|
|
|
this.visible = true;
|
|
|
|
Event.$emit("migas-agregar",this.miga);
|
2022-01-12 12:04:02 -03:00
|
|
|
});
|
2022-01-11 18:45:00 -03:00
|
|
|
}
|
|
|
|
});
|