funcion/pedido-ollas #47
4 changed files with 57 additions and 16 deletions
|
@ -1,18 +1,13 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { mapMutations, mapState } from "vuex";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: "CantidadOllas",
|
name: "CantidadOllas",
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
cantidadControl: 0,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
methods: {
|
||||||
decrementar() {
|
...mapMutations("ollas", ["incrementar", "decrementar"]),
|
||||||
this.cantidadControl -= 1;
|
},
|
||||||
},
|
computed: {
|
||||||
incrementar() {
|
...mapState("ollas", ["cantidad_de_ollas"])
|
||||||
this.cantidadControl += 1;
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -23,14 +18,14 @@ export default {
|
||||||
<div class="field has-addons is-justify-content-center contador">
|
<div class="field has-addons is-justify-content-center contador">
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<button class="button is-small"
|
<button class="button is-small"
|
||||||
:disabled="cantidadControl < 1"
|
:disabled="cantidad_de_ollas < 1"
|
||||||
@click.capture="decrementar">
|
@click.capture="decrementar">
|
||||||
<i class="fa fa-solid fa-minus"></i>
|
<i class="fa fa-solid fa-minus"></i>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<input id="cantidad"
|
<input id="cantidad"
|
||||||
v-model="cantidadControl"
|
v-model="cantidad_de_ollas"
|
||||||
class="input is-small"
|
class="input is-small"
|
||||||
type="number"
|
type="number"
|
||||||
style="text-align: center">
|
style="text-align: center">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { mapGetters, mapMutations, mapState } from "vuex";
|
import { mapActions, mapGetters, mapMutations, mapState } from "vuex";
|
||||||
import ChismosaDropdown from "../pedidos/ChismosaDropdown.vue";
|
import ChismosaDropdown from "../pedidos/ChismosaDropdown.vue";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
@ -7,18 +7,23 @@ export default {
|
||||||
components: { ChismosaDropdown },
|
components: { ChismosaDropdown },
|
||||||
computed: {
|
computed: {
|
||||||
...mapGetters('pedido', ["pedidoDefinido"]),
|
...mapGetters('pedido', ["pedidoDefinido"]),
|
||||||
|
...mapGetters('ollas', ["montoTotal"]),
|
||||||
|
...mapState('ui', ["burger_activa"]),
|
||||||
...mapState('pedido', ["nombre"]),
|
...mapState('pedido', ["nombre"]),
|
||||||
...mapState('ui', ["burger_activa"])
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
...mapActions('ollas', ["getMontoPorOlla"]),
|
||||||
...mapMutations('ui', ["toggleBurger"]),
|
...mapMutations('ui', ["toggleBurger"]),
|
||||||
},
|
},
|
||||||
|
async mounted() {
|
||||||
|
await this.getMontoPorOlla();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div class="navbar-item hide-below-1024">
|
<div class="navbar-item hide-below-1024">
|
||||||
<p v-if="pedidoDefinido">{{ nombre }}</p>
|
<p v-if="pedidoDefinido">{{ `${nombre} - Monto total: ${montoTotal}` }}</p>
|
||||||
<chismosa-dropdown
|
<chismosa-dropdown
|
||||||
v-if="pedidoDefinido"
|
v-if="pedidoDefinido"
|
||||||
class="hide-above-1023"
|
class="hide-above-1023"
|
||||||
|
|
2
resources/js/store/index.js
vendored
2
resources/js/store/index.js
vendored
|
@ -6,6 +6,7 @@ import login from "./modules/login";
|
||||||
import pedido from "./modules/pedido";
|
import pedido from "./modules/pedido";
|
||||||
import productos from "./modules/productos";
|
import productos from "./modules/productos";
|
||||||
import ui from "./modules/ui";
|
import ui from "./modules/ui";
|
||||||
|
import ollas from "./modules/ollas";
|
||||||
|
|
||||||
Vue.use(Vuex);
|
Vue.use(Vuex);
|
||||||
|
|
||||||
|
@ -17,5 +18,6 @@ export default new Vuex.Store({
|
||||||
pedido,
|
pedido,
|
||||||
productos,
|
productos,
|
||||||
ui,
|
ui,
|
||||||
|
ollas,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
39
resources/js/store/modules/ollas.js
vendored
Normal file
39
resources/js/store/modules/ollas.js
vendored
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
|
const state = {
|
||||||
|
monto_por_olla: undefined,
|
||||||
|
cantidad_de_ollas: 0,
|
||||||
|
};
|
||||||
|
|
||||||
|
const mutations = {
|
||||||
|
setMontoPorOlla(state, parametros) {
|
||||||
|
state.monto_por_olla = Number.parseInt(parametros.find(p => p.id === 'monto-olla').valor);
|
||||||
|
},
|
||||||
|
incrementar(state) {
|
||||||
|
state.cantidad_de_ollas += 1;
|
||||||
|
},
|
||||||
|
decrementar(state) {
|
||||||
|
state.cantidad_de_ollas -= 1;
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const actions = {
|
||||||
|
async getMontoPorOlla({ commit }) {
|
||||||
|
const response = await axios.get('/api/parametros');
|
||||||
|
commit('setMontoPorOlla', response.data);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const getters = {
|
||||||
|
montoTotal() {
|
||||||
|
return state.monto_por_olla * state.cantidad_de_ollas;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export default {
|
||||||
|
namespaced: true,
|
||||||
|
state,
|
||||||
|
mutations,
|
||||||
|
actions,
|
||||||
|
getters,
|
||||||
|
};
|
Loading…
Add table
Reference in a new issue