perf: refs #7553 removeSales function

This commit is contained in:
Jon Elias 2024-09-23 13:51:20 +02:00
parent f025b4361e
commit 3716507f93
1 changed files with 10 additions and 9 deletions

View File

@ -388,17 +388,18 @@ const removeSelectedSales = () => {
};
const removeSales = async () => {
let paramsOk = true;
try {
const params = { sales: selectedRows.value, ticketId: store.data.id };
params.sales.forEach((sale) => {
if (!sale.itemFk) {
tableRef.value.reload();
paramsOk = false;
}
});
const params = {
sales: selectedRows.value.filter((sale) => sale.id),
ticketId: store.data.id,
};
selectedRows.value
.filter((sale) => !sale.id)
.forEach((sale) =>
tableRef.value.CrudModelRef.formData.splice(sale.$index, 1)
);
if (!paramsOk) return;
if (params.sales.length == 0) return;
await axios.post('Sales/deleteSales', params);
removeSelectedSales();
notify('globals.dataSaved', 'positive');