0
0
Fork 0

Merge branch 'master' into 245362-hotFixItemTags

This commit is contained in:
Robert Ferrús 2024-11-28 10:38:00 +00:00
commit 547455d976
1 changed files with 25 additions and 25 deletions

View File

@ -181,17 +181,34 @@ const resetChanges = async () => {
arrayData.fetch({ append: false });
tableRef.value.reload();
};
const rowToUpdate = ref(null);
const changeQuantity = async (sale) => {
canProceed.value = await isSalePrepared(sale);
if (!canProceed.value) return;
if (
!sale.itemFk ||
sale.quantity == null ||
edit.value?.oldQuantity === sale.quantity
)
return;
if (!sale.id) return addSale(sale);
const updateQuantity = async (sale) => {
const params = { quantity: sale.quantity };
try {
await axios.post(`Sales/${sale.id}/updateQuantity`, params);
if (!rowToUpdate.value) return;
rowToUpdate.value = null;
await updateQuantity(sale);
} catch (e) {
sale.quantity = tableRef.value.CrudModelRef.originalData.find(
const { quantity } = tableRef.value.CrudModelRef.originalData.find(
(s) => s.id === sale.id
).quantity;
);
sale.quantity = quantity;
throw e;
}
};
const updateQuantity = async ({ quantity, id }) => {
const params = { quantity: quantity };
await axios.post(`Sales/${id}/updateQuantity`, params);
notify('globals.dataSaved', 'positive');
};
@ -219,19 +236,6 @@ const addSale = async (sale) => {
window.location.reload();
};
const changeQuantity = async (sale) => {
canProceed.value = await isSalePrepared(sale);
if (!canProceed.value) return;
if (
!sale.itemFk ||
sale.quantity == null ||
edit.value?.oldQuantity === sale.quantity
)
return;
if (!sale.id) return addSale(sale);
await updateQuantity(sale);
};
const updateConcept = async (sale) => {
canProceed.value = await isSalePrepared(sale);
if (!canProceed.value) return;
@ -768,16 +772,12 @@ watch(
</template>
<template #column-quantity="{ row }">
<VnInput
v-if="row.isNew"
v-model.number="row.quantity"
v-if="row.isNew || isTicketEditable"
type="number"
@blur="changeQuantity(row)"
@focus="edit.oldQuantity = row.quantity"
/>
<VnInput
v-else-if="isTicketEditable"
v-model.number="row.quantity"
@blur="changeQuantity(row)"
@keyup.enter="changeQuantity(row)"
@update:model-value="() => (rowToUpdate = row)"
@focus="edit.oldQuantity = row.quantity"
/>
<span v-else>{{ row.quantity }}</span>