Usando vuex para el modal de devoluciones

This commit is contained in:
Alejandro Tasistro 2025-05-23 00:56:48 -03:00
parent fb0e13089f
commit 5023032ac2
3 changed files with 52 additions and 44 deletions

View file

@ -19,7 +19,7 @@
<th><p>Devoluciones</p></th> <th><p>Devoluciones</p></th>
<td> <td>
<abbr :title="devoluciones_notas">{{ notas_abreviadas }}</abbr> <abbr :title="devoluciones_notas">{{ notas_abreviadas }}</abbr>
<button @click.capture="modificarDevoluciones()" class="button is-warning is-small"> <button @click.capture="toggleDevoluciones()" class="button is-warning is-small">
<span class="icon"> <span class="icon">
<i class="fas fa-edit"></i> <i class="fas fa-edit"></i>
</span> </span>
@ -46,7 +46,7 @@
<script> <script>
import ProductoRow from "./ProductoRow.vue"; import ProductoRow from "./ProductoRow.vue";
import { mapState } from "vuex"; import { mapMutations, mapState } from "vuex";
export default { export default {
components: { ProductoRow }, components: { ProductoRow },
@ -68,9 +68,7 @@ export default {
}, },
}, },
methods: { methods: {
modificarDevoluciones() { ...mapMutations('ui',["toggleDevoluciones"]),
Event.$emit("modificar-devoluciones");
},
}, },
} }
</script> </script>

View file

@ -1,67 +1,71 @@
<template> <template>
<div v-bind:class="visible ? 'is-active modal' : 'modal'"> <div :class="show_devoluciones ? 'is-active modal' : 'modal'">
<div class="modal-background"></div> <div class="modal-background"></div>
<div class="modal-card"> <div class="modal-card">
<header class="modal-card-head"> <header class="modal-card-head">
<p class="modal-card-title">Devoluciones</p> <p class="modal-card-title">Devoluciones</p>
<button class="delete" aria-label="close" @click.capture="cerrar"></button> <button class="delete" aria-label="close" @click.capture="toggleDevoluciones()"></button>
</header> </header>
<section class="modal-card-body"> <section class="modal-card-body">
<div class="field has-addons is-centered is-thin-centered"> <div class="field has-addons is-centered is-thin-centered">
<p class="control"> <p class="control">
Total: Total:
<input id="total" class="input" type="number" v-model="total" style="text-align: center"> <input id="totalControl" class="input" type="number" v-model="totalControl"
style="text-align: center">
</p> </p>
</div> </div>
<div class="field has-addons is-centered is-thin-centered"> <div class="field has-addons is-centered is-thin-centered">
<p class="control"> <p class="control">
Notas: Notas:
<input id="notas" class="input" type="text" v-model.text="notas"> <input id="notasControl" class="input" type="text" v-model.text="notasControl">
</p> </p>
</div> </div>
</section> </section>
<footer class="modal-card-foot"> <footer class="modal-card-foot">
<button class="button is-success" @click="modificar">Aceptar</button> <button class="button is-success" @click="modificar">Aceptar</button>
<button class="button" @click.capture="cerrar">Cancelar</button> <button class="button" @click.capture="toggleDevoluciones()">Cancelar</button>
</footer> </footer>
</div> </div>
</div> </div>
</template> </template>
<script> <script>
export default { import { mapActions, mapMutations, mapState } from "vuex";
data() {
return { export default {
visible: false, name: 'DevolucionesModal',
total: 0, data() {
notas: "", return {
} totalControl: 0,
notasControl: "",
}
},
mounted() {
this.actualizar();
},
watch: {
cantidadEnChismosa() {
this.actualizar();
}, },
computed: { notasEnChismosa() {
miga: function() { this.actualizar();
return { }
nombre: "Devoluciones", },
href: "#devoluciones", computed: {
} ...mapState('ui', ["show_devoluciones"]),
}, ...mapState('pedido', ["devoluciones_total", "devoluciones_notas"])
},
methods: {
...mapMutations('ui', ["toggleDevoluciones"]),
...mapActions('pedido', ["modificarDevoluciones"]),
modificar() {
this.modificarDevoluciones({ monto: this.totalControl, notas: this.notasControl });
this.toggleDevoluciones();
}, },
methods: { actualizar() {
cerrar() { this.totalControl = this.devoluciones_total;
this.visible = false; this.notasControl = this.devoluciones_notas;
Event.$emit("migas-pop");
},
modificar() {
Event.$emit('sync-devoluciones', this.total, this.notas);
this.cerrar();
}
}, },
mounted() { },
Event.$on('modificar-devoluciones', () => { }
this.visible = true; </script>
this.total = this.$root.pedido.devoluciones_total;
this.notas = this.$root.pedido.devoluciones_notas;
Event.$emit("migas-agregar", this.miga);
});
},
}
</script>

View file

@ -50,7 +50,13 @@ const actions = {
}); });
commit('setState', response.data.data); commit('setState', response.data.data);
}, },
async modificarDevoluciones({ commit }, monto, notas) {} async modificarDevoluciones({ commit }, { monto, notas }) {
const response = await axios.post("api/subpedidos/" + state.pedido_id + "/sync_devoluciones", {
total: monto,
notas: notas,
});
commit('setState', response.data.data);
},
}; };
const getters = { const getters = {