fix(TicketSale): refs #6696 pass componentId to updateDiscount functions
This commit is contained in:
parent
bd8747e1fd
commit
b521aa86f3
|
@ -327,28 +327,31 @@ const changeDiscount = async (sale) => {
|
||||||
const newDiscount = edit.value.discount;
|
const newDiscount = edit.value.discount;
|
||||||
if (newDiscount != null && newDiscount != sale.discount) {
|
if (newDiscount != null && newDiscount != sale.discount) {
|
||||||
if (await isSalePrepared(sale))
|
if (await isSalePrepared(sale))
|
||||||
await confirmUpdate(() => updateDiscount([sale], newDiscount));
|
await confirmUpdate(() =>
|
||||||
else await updateDiscount([sale], newDiscount);
|
updateDiscount([sale], newDiscount, componentId.value),
|
||||||
|
);
|
||||||
|
else await updateDiscount([sale], newDiscount, componentId.value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateDiscounts = async (sales, newDiscount) => {
|
const updateDiscounts = async (sales, newDiscount, componentId) => {
|
||||||
const salesTracking = await fetchSalesTracking();
|
const salesTracking = await fetchSalesTracking();
|
||||||
|
|
||||||
const someSaleIsPrepared = salesTracking.some((sale) =>
|
const someSaleIsPrepared = salesTracking.some((sale) =>
|
||||||
matchSale(salesTracking, sale),
|
matchSale(salesTracking, sale),
|
||||||
);
|
);
|
||||||
if (someSaleIsPrepared) await confirmUpdate(() => updateDiscount(sales, newDiscount));
|
if (someSaleIsPrepared)
|
||||||
else updateDiscount(sales, newDiscount);
|
await confirmUpdate(() => updateDiscount(sales, newDiscount, componentId));
|
||||||
|
else updateDiscount(sales, newDiscount, componentId);
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateDiscount = async (sales, newDiscount = 0) => {
|
const updateDiscount = async (sales, newDiscount, componentId) => {
|
||||||
try {
|
try {
|
||||||
const salesIds = sales.map(({ id }) => id);
|
const salesIds = sales.map(({ id }) => id);
|
||||||
const params = {
|
const params = {
|
||||||
salesIds,
|
salesIds,
|
||||||
newDiscount,
|
newDiscount: newDiscount ?? 0,
|
||||||
componentId: componentId.value,
|
componentId,
|
||||||
};
|
};
|
||||||
await axios.post(`Tickets/${route.params.id}/updateDiscount`, params);
|
await axios.post(`Tickets/${route.params.id}/updateDiscount`, params);
|
||||||
notify('globals.dataSaved', 'positive');
|
notify('globals.dataSaved', 'positive');
|
||||||
|
|
|
@ -47,6 +47,7 @@ const { notify } = useNotify();
|
||||||
const acl = useAcl();
|
const acl = useAcl();
|
||||||
const btnDropdownRef = ref(null);
|
const btnDropdownRef = ref(null);
|
||||||
const editManaProxyRef = ref(null);
|
const editManaProxyRef = ref(null);
|
||||||
|
const componentId = ref(null);
|
||||||
const { openConfirmationModal } = useVnConfirm();
|
const { openConfirmationModal } = useVnConfirm();
|
||||||
|
|
||||||
const newDiscount = ref(null);
|
const newDiscount = ref(null);
|
||||||
|
@ -112,7 +113,7 @@ const changeMultipleDiscount = () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (newDiscount.value != null && hasChanges)
|
if (newDiscount.value != null && hasChanges)
|
||||||
emit('updateDiscounts', props.sales, newDiscount.value);
|
emit('updateDiscounts', props.sales, newDiscount.value, componentId.value);
|
||||||
btnDropdownRef.value.hide();
|
btnDropdownRef.value.hide();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -206,6 +207,7 @@ const createRefund = async (withWarehouse) => {
|
||||||
ref="editManaProxyRef"
|
ref="editManaProxyRef"
|
||||||
:sale="row"
|
:sale="row"
|
||||||
@save="changeMultipleDiscount"
|
@save="changeMultipleDiscount"
|
||||||
|
v-model:component-id="componentId"
|
||||||
>
|
>
|
||||||
<VnInput
|
<VnInput
|
||||||
autofocus
|
autofocus
|
||||||
|
|
Loading…
Reference in New Issue