Metodo para resetear pedido
This commit is contained in:
parent
4f74bf38f9
commit
ae1f8673e7
1 changed files with 23 additions and 6 deletions
29
resources/js/store/modules/pedido.js
vendored
29
resources/js/store/modules/pedido.js
vendored
|
@ -15,7 +15,7 @@ const state = {
|
|||
};
|
||||
|
||||
const mutations = {
|
||||
setState(state, pedido) {
|
||||
setPedido(state, pedido) {
|
||||
state.lastFetch = new Date();
|
||||
state.pedido_id = pedido.id;
|
||||
state.nombre = pedido.nombre;
|
||||
|
@ -28,6 +28,19 @@ const mutations = {
|
|||
state.devoluciones_total = pedido.devoluciones_total;
|
||||
state.devoluciones_notas = pedido.devoluciones_notas;
|
||||
},
|
||||
reset(state) {
|
||||
state.lastFetch = null;
|
||||
state.pedido_id = null;
|
||||
state.nombre = null;
|
||||
state.productos = null;
|
||||
state.aprobado = null;
|
||||
state.total = null;
|
||||
state.total_transporte = null;
|
||||
state.cantidad_transporte = null;
|
||||
state.total_sin_devoluciones = null;
|
||||
state.devoluciones_total = null;
|
||||
state.devoluciones_notas = null;
|
||||
}
|
||||
};
|
||||
|
||||
const actions = {
|
||||
|
@ -38,7 +51,7 @@ const actions = {
|
|||
const sesion = await axios.get("/pedido/sesion");
|
||||
if (sesion.data) {
|
||||
const response = await axios.get(`/api/subpedidos/${sesion.data}`);
|
||||
commit('setState', response.data.data);
|
||||
commit('setPedido', response.data.data);
|
||||
}
|
||||
},
|
||||
async crearPedido({ commit, dispatch }, { nombre, grupo_de_compra_id }) {
|
||||
|
@ -47,12 +60,12 @@ const actions = {
|
|||
grupo_de_compra_id: grupo_de_compra_id
|
||||
});
|
||||
dispatch("guardarSesion", { pedido_id: response.data.data.id});
|
||||
commit('setState', response.data.data);
|
||||
commit('setPedido', response.data.data);
|
||||
},
|
||||
async elegirPedido({ commit, dispatch }, { pedido }) {
|
||||
const response = await axios.get(`/api/subpedidos/${pedido.id}`);
|
||||
dispatch("guardarSesion", { pedido_id: response.data.data.id})
|
||||
commit('setState', response.data.data);
|
||||
commit('setPedido', response.data.data);
|
||||
},
|
||||
async modificarChismosa({ commit, dispatch }, { producto_id, cantidad, notas }) {
|
||||
try {
|
||||
|
@ -61,7 +74,7 @@ const actions = {
|
|||
producto_id: producto_id,
|
||||
notas: notas,
|
||||
});
|
||||
commit('setState', response.data.data);
|
||||
commit('setPedido', response.data.data);
|
||||
dispatch("ui/toast", { mensaje: 'Pedido modificado con éxito' }, { root: true });
|
||||
} catch (error) {
|
||||
dispatch("ui/error", { error: error }, { root: true });
|
||||
|
@ -73,12 +86,16 @@ const actions = {
|
|||
total: monto,
|
||||
notas: notas,
|
||||
});
|
||||
commit('setState', response.data.data);
|
||||
commit('setPedido', response.data.data);
|
||||
dispatch("ui/toast", { mensaje: 'Devoluciones modificadas con éxito' }, { root: true });
|
||||
} catch (error) {
|
||||
dispatch("ui/error", { error: error }, { root: true });
|
||||
}
|
||||
},
|
||||
async resetear({ commit }) {
|
||||
await axios.delete("/pedido/sesion")
|
||||
commit('reset');
|
||||
},
|
||||
};
|
||||
|
||||
const getters = {
|
||||
|
|
Loading…
Add table
Reference in a new issue