diff --git a/src/pages/Ticket/Negative/ChangeQuantityDialog.vue b/src/pages/Ticket/Negative/ChangeQuantityDialog.vue index 07be42245..116659bad 100644 --- a/src/pages/Ticket/Negative/ChangeQuantityDialog.vue +++ b/src/pages/Ticket/Negative/ChangeQuantityDialog.vue @@ -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 }); } }; diff --git a/src/pages/Ticket/Negative/ChangeStateDialog.vue b/src/pages/Ticket/Negative/ChangeStateDialog.vue index 0675c7a33..2102ddf1c 100644 --- a/src/pages/Ticket/Negative/ChangeStateDialog.vue +++ b/src/pages/Ticket/Negative/ChangeStateDialog.vue @@ -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 }); } }; diff --git a/src/pages/Ticket/Negative/TicketLackDetail.vue b/src/pages/Ticket/Negative/TicketLackDetail.vue index 8b5ae8213..31ba5ef69 100644 --- a/src/pages/Ticket/Negative/TicketLackDetail.vue +++ b/src/pages/Ticket/Negative/TicketLackDetail.vue @@ -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 /> - - [ }, ]); 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(); +};