forked from verdnatura/salix-front
fix(TicketSale): set old quantity when error
This commit is contained in:
parent
8fbf7fed43
commit
2076072eeb
|
@ -94,6 +94,7 @@ defineExpose({
|
||||||
saveChanges,
|
saveChanges,
|
||||||
getChanges,
|
getChanges,
|
||||||
formData,
|
formData,
|
||||||
|
originalData,
|
||||||
vnPaginateRef,
|
vnPaginateRef,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -183,18 +183,25 @@ const resetChanges = async () => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateQuantity = async (sale) => {
|
const updateQuantity = async (sale) => {
|
||||||
const payload = { quantity: sale.quantity };
|
const params = { quantity: sale.quantity };
|
||||||
await axios.post(`Sales/${sale.id}/updateQuantity`, payload);
|
try {
|
||||||
|
await axios.post(`Sales/${sale.id}/updateQuantity`, params);
|
||||||
|
} catch (e) {
|
||||||
|
sale.quantity = tableRef.value.CrudModelRef.originalData.find(
|
||||||
|
(s) => s.id === sale.id
|
||||||
|
).quantity;
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
notify('globals.dataSaved', 'positive');
|
notify('globals.dataSaved', 'positive');
|
||||||
};
|
};
|
||||||
|
|
||||||
const addSale = async (sale) => {
|
const addSale = async (sale) => {
|
||||||
const payload = {
|
const params = {
|
||||||
barcode: sale.itemFk,
|
barcode: sale.itemFk,
|
||||||
quantity: sale.quantity,
|
quantity: sale.quantity,
|
||||||
};
|
};
|
||||||
|
|
||||||
const { data } = await axios.post(`tickets/${route.params.id}/addSale`, payload);
|
const { data } = await axios.post(`tickets/${route.params.id}/addSale`, params);
|
||||||
|
|
||||||
if (!data) return;
|
if (!data) return;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue