0
0
Fork 0

Merge branch 'master' into hotfix_8217_updateCustomerCredit

This commit is contained in:
Javier Segarra 2024-11-28 12:33:07 +00:00
commit 07274002cf
4 changed files with 32 additions and 30 deletions

View File

@ -133,7 +133,7 @@ const addFilter = async (filter, params) => {
async function fetch(params) { async function fetch(params) {
useArrayData(props.dataKey, params); useArrayData(props.dataKey, params);
arrayData.reset(['filter.skip', 'skip', 'page']); arrayData.reset(['filter.skip', 'skip', 'page']);
await arrayData.fetch({ append: false }); await arrayData.fetch({ append: false, updateRouter: mounted.value });
return emitStoreData(); return emitStoreData();
} }

View File

@ -82,11 +82,11 @@ const entriesTableColumns = computed(() => [
</QCardSection> </QCardSection>
<QCardActions align="right"> <QCardActions align="right">
<QBtn <QBtn
:label="t('printLabels')" :label="t('myEntries.printLabels')"
color="primary" color="primary"
icon="print" icon="print"
:loading="isLoading" :loading="isLoading"
@click="openReport(`Entries/${entityId}/print`)" @click="openReport(`Entries/${entityId}/labelSupplier`)"
unelevated unelevated
autofocus autofocus
/> />
@ -126,7 +126,9 @@ const entriesTableColumns = computed(() => [
" "
unelevated unelevated
> >
<QTooltip>{{ t('viewLabel') }}</QTooltip> <QTooltip>{{
t('myEntries.viewLabel')
}}</QTooltip>
</QBtn> </QBtn>
</QTr> </QTr>
</template> </template>

View File

@ -101,7 +101,7 @@ const columns = computed(() => [
name: 'tableActions', name: 'tableActions',
actions: [ actions: [
{ {
title: t('printLabels'), title: t('myEntries.printLabels'),
icon: 'print', icon: 'print',
isPrimary: true, isPrimary: true,
action: (row) => printBuys(row.id), action: (row) => printBuys(row.id),

View File

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