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,
|
||||
getChanges,
|
||||
formData,
|
||||
originalData,
|
||||
vnPaginateRef,
|
||||
});
|
||||
|
||||
|
|
|
@ -183,18 +183,25 @@ const resetChanges = async () => {
|
|||
};
|
||||
|
||||
const updateQuantity = async (sale) => {
|
||||
const payload = { quantity: sale.quantity };
|
||||
await axios.post(`Sales/${sale.id}/updateQuantity`, payload);
|
||||
const params = { quantity: sale.quantity };
|
||||
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');
|
||||
};
|
||||
|
||||
const addSale = async (sale) => {
|
||||
const payload = {
|
||||
const params = {
|
||||
barcode: sale.itemFk,
|
||||
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;
|
||||
|
||||
|
|
Loading…
Reference in New Issue