0
0
Fork 0

feat: reload ticket detail when update state/qty

This commit is contained in:
Javier Segarra 2024-05-15 08:14:50 +02:00
parent e07e62abb4
commit fffd662cee
4 changed files with 31 additions and 24 deletions

View File

@ -15,20 +15,20 @@ const $props = defineProps({
default: () => [], default: () => [],
}, },
}); });
const updateQuantity = async (evt, rows) => { const updateQuantity = async () => {
showChangeQuantityDialog.value = true; showChangeQuantityDialog.value = true;
const rowsToUpdate = $props.selectedRows.map((row) => const rowsToUpdate = $props.selectedRows.map(({ saleFk }) =>
axios.post(`Sales//updateQuantity`, { axios.post(`Sales/${saleFk}/updateQuantity`, {
row, quantity: +newQuantity.value,
quantity: newQuantity.value,
}) })
); );
try { try {
await Promise.all(rowsToUpdate); await Promise.all(rowsToUpdate);
dialogRef.value.hide();
} catch (err) { } catch (err) {
return err; return err;
} finally {
dialogRef.value.hide({ type: 'refresh', refresh: true });
} }
}; };
</script> </script>

View File

@ -19,17 +19,18 @@ const $props = defineProps({
}); });
const updateState = async () => { const updateState = async () => {
try { try {
// showChangeStateDialog.value = true; showChangeStateDialog.value = true;
// const rowsToUpdate = $props.selectedRows.map((ticketFk) => const rowsToUpdate = $props.selectedRows.map(({ ticketFk }) =>
// axios.post(`Tickets/state`, { axios.post(`Tickets/state`, {
// ticketFk, ticketFk,
// code: newState.value, code: newState.value,
// }) })
// ); );
// await Promise.all(rowsToUpdate); await Promise.all(rowsToUpdate);
dialogRef.value.hide({ refresh: true });
} catch (err) { } catch (err) {
return err; return err;
} finally {
dialogRef.value.hide({ type: 'refresh', refresh: true });
} }
}; };
</script> </script>

View File

@ -223,11 +223,13 @@ const emit = defineEmits([...useDialogPluginComponent.emits, 'selection']);
function rowsHasSelected(selection) { function rowsHasSelected(selection) {
emit( emit(
'selection', 'selection',
selection.map(({ ticketFk }) => ticketFk) selection
//.map(({ ticketFk }) => ticketFk)
); );
} }
const resultSplit = ref([]); const resultSplit = ref([]);
const itemLackForm = ref();
const split = async ({ simple }, data = []) => { const split = async ({ simple }, data = []) => {
openConfirmationModal(t('Confirm split selected'), t('splitQuestion'), null, () => { openConfirmationModal(t('Confirm split selected'), t('splitQuestion'), null, () => {
const body = simple ? data : selectedRows.value; const body = simple ? data : selectedRows.value;
@ -236,7 +238,10 @@ const split = async ({ simple }, data = []) => {
}); });
}); });
}; };
defineExpose({ split }); const reload = async () => {
itemLackForm.value.fetch();
};
defineExpose({ split, reload });
function getIcon(key, prop) { function getIcon(key, prop) {
const ticket = resultSplit.value.find((val) => val.ticketFk === key); const ticket = resultSplit.value.find((val) => val.ticketFk === key);
@ -281,9 +286,6 @@ const handleRows = (rows) => {
@on-fetch="(data) => (editableStates = data)" @on-fetch="(data) => (editableStates = data)"
auto-load auto-load
/> />
<!-- <QPage class="column items-center q-pa-md">
<div class="vn-card-list"> -->
<VnPaginate <VnPaginate
:data-key="URL_KEY" :data-key="URL_KEY"
:url="`${URL_KEY}/${entityId}/detail`" :url="`${URL_KEY}/${entityId}/detail`"

View File

@ -100,12 +100,16 @@ const columns = computed(() => [
}, },
]); ]);
const vnPaginateRef = ref(); const vnPaginateRef = ref();
const ticketDetailRef = ref();
const handleWarehouses = async (data) => { const handleWarehouses = async (data) => {
negativeParams.warehouse = data.find((w) => w.name === DEFAULT_WAREHOUSE).id; negativeParams.warehouse = data.find((w) => w.name === DEFAULT_WAREHOUSE).id;
await vnPaginateRef.value.fetch(); await vnPaginateRef.value.fetch();
showFilterPanel.value = true; showFilterPanel.value = true;
}; };
const onDetailDialogHide = (evt) => {
if (evt?.type === 'refresh') ticketDetailRef.value.reload();
};
</script> </script>
<template> <template>
@ -277,6 +281,7 @@ const handleWarehouses = async (data) => {
</div> </div>
<div v-if="currentRow" class="list"> <div v-if="currentRow" class="list">
<TicketLackDetail <TicketLackDetail
ref="ticketDetailRef"
:id="currentRow?.itemFk" :id="currentRow?.itemFk"
:filter="{ showFree }" :filter="{ showFree }"
@selection="(values) => (selectedRowsDetail = values)" @selection="(values) => (selectedRowsDetail = values)"
@ -284,16 +289,15 @@ const handleWarehouses = async (data) => {
</div> </div>
<ChangeStateDialog <ChangeStateDialog
ref="changeStateDialogRef" ref="changeStateDialogRef"
@hide="(evt) => vnPaginateRef.fetch()" @hide="onDetailDialogHide"
v-model="showChangeStateDialog" v-model="showChangeStateDialog"
:selected-rows="{ selectedRowsDetail }" :selected-rows="selectedRowsDetail"
></ChangeStateDialog> ></ChangeStateDialog>
<ChangeQuantityDialog <ChangeQuantityDialog
ref="changeQuantityDialogRef" ref="changeQuantityDialogRef"
@hide="onDialogHide" @hide="onDetailDialogHide"
v-model="showChangeQuantityDialog" v-model="showChangeQuantityDialog"
:selected-rows="selectedRowsDetail" :selected-rows="selectedRowsDetail"
:rows=""
> >
</ChangeQuantityDialog> </ChangeQuantityDialog>
<ItemProposal <ItemProposal