feat: reload ticket detail when update state/qty
This commit is contained in:
parent
e07e62abb4
commit
fffd662cee
|
@ -15,20 +15,20 @@ const $props = defineProps({
|
|||
default: () => [],
|
||||
},
|
||||
});
|
||||
const updateQuantity = async (evt, rows) => {
|
||||
const updateQuantity = async () => {
|
||||
showChangeQuantityDialog.value = true;
|
||||
const rowsToUpdate = $props.selectedRows.map((row) =>
|
||||
axios.post(`Sales//updateQuantity`, {
|
||||
row,
|
||||
quantity: newQuantity.value,
|
||||
const rowsToUpdate = $props.selectedRows.map(({ saleFk }) =>
|
||||
axios.post(`Sales/${saleFk}/updateQuantity`, {
|
||||
quantity: +newQuantity.value,
|
||||
})
|
||||
);
|
||||
|
||||
try {
|
||||
await Promise.all(rowsToUpdate);
|
||||
dialogRef.value.hide();
|
||||
} catch (err) {
|
||||
return err;
|
||||
} finally {
|
||||
dialogRef.value.hide({ type: 'refresh', refresh: true });
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -19,17 +19,18 @@ const $props = defineProps({
|
|||
});
|
||||
const updateState = async () => {
|
||||
try {
|
||||
// showChangeStateDialog.value = true;
|
||||
// const rowsToUpdate = $props.selectedRows.map((ticketFk) =>
|
||||
// axios.post(`Tickets/state`, {
|
||||
// ticketFk,
|
||||
// code: newState.value,
|
||||
// })
|
||||
// );
|
||||
// await Promise.all(rowsToUpdate);
|
||||
dialogRef.value.hide({ refresh: true });
|
||||
showChangeStateDialog.value = true;
|
||||
const rowsToUpdate = $props.selectedRows.map(({ ticketFk }) =>
|
||||
axios.post(`Tickets/state`, {
|
||||
ticketFk,
|
||||
code: newState.value,
|
||||
})
|
||||
);
|
||||
await Promise.all(rowsToUpdate);
|
||||
} catch (err) {
|
||||
return err;
|
||||
} finally {
|
||||
dialogRef.value.hide({ type: 'refresh', refresh: true });
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
@ -223,11 +223,13 @@ const emit = defineEmits([...useDialogPluginComponent.emits, 'selection']);
|
|||
function rowsHasSelected(selection) {
|
||||
emit(
|
||||
'selection',
|
||||
selection.map(({ ticketFk }) => ticketFk)
|
||||
selection
|
||||
//.map(({ ticketFk }) => ticketFk)
|
||||
);
|
||||
}
|
||||
|
||||
const resultSplit = ref([]);
|
||||
const itemLackForm = ref();
|
||||
const split = async ({ simple }, data = []) => {
|
||||
openConfirmationModal(t('Confirm split selected'), t('splitQuestion'), null, () => {
|
||||
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) {
|
||||
const ticket = resultSplit.value.find((val) => val.ticketFk === key);
|
||||
|
@ -281,9 +286,6 @@ const handleRows = (rows) => {
|
|||
@on-fetch="(data) => (editableStates = data)"
|
||||
auto-load
|
||||
/>
|
||||
|
||||
<!-- <QPage class="column items-center q-pa-md">
|
||||
<div class="vn-card-list"> -->
|
||||
<VnPaginate
|
||||
:data-key="URL_KEY"
|
||||
:url="`${URL_KEY}/${entityId}/detail`"
|
||||
|
|
|
@ -100,12 +100,16 @@ const columns = computed(() => [
|
|||
},
|
||||
]);
|
||||
const vnPaginateRef = ref();
|
||||
const ticketDetailRef = ref();
|
||||
|
||||
const handleWarehouses = async (data) => {
|
||||
negativeParams.warehouse = data.find((w) => w.name === DEFAULT_WAREHOUSE).id;
|
||||
await vnPaginateRef.value.fetch();
|
||||
showFilterPanel.value = true;
|
||||
};
|
||||
const onDetailDialogHide = (evt) => {
|
||||
if (evt?.type === 'refresh') ticketDetailRef.value.reload();
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
@ -277,6 +281,7 @@ const handleWarehouses = async (data) => {
|
|||
</div>
|
||||
<div v-if="currentRow" class="list">
|
||||
<TicketLackDetail
|
||||
ref="ticketDetailRef"
|
||||
:id="currentRow?.itemFk"
|
||||
:filter="{ showFree }"
|
||||
@selection="(values) => (selectedRowsDetail = values)"
|
||||
|
@ -284,16 +289,15 @@ const handleWarehouses = async (data) => {
|
|||
</div>
|
||||
<ChangeStateDialog
|
||||
ref="changeStateDialogRef"
|
||||
@hide="(evt) => vnPaginateRef.fetch()"
|
||||
@hide="onDetailDialogHide"
|
||||
v-model="showChangeStateDialog"
|
||||
:selected-rows="{ selectedRowsDetail }"
|
||||
:selected-rows="selectedRowsDetail"
|
||||
></ChangeStateDialog>
|
||||
<ChangeQuantityDialog
|
||||
ref="changeQuantityDialogRef"
|
||||
@hide="onDialogHide"
|
||||
@hide="onDetailDialogHide"
|
||||
v-model="showChangeQuantityDialog"
|
||||
:selected-rows="selectedRowsDetail"
|
||||
:rows=""
|
||||
>
|
||||
</ChangeQuantityDialog>
|
||||
<ItemProposal
|
||||
|
|
Loading…
Reference in New Issue