#6321 - Negative ticket #158
|
@ -189,6 +189,8 @@ const isSelectionAvailable = (itemProposal) => {
|
|||
(100 * itemProposal.available) / Math.abs($props.itemLack.lack) < 30;
|
||||
return byQuantity;
|
||||
};
|
||||
|
||||
const isDisabled = (row) => !isSelectionAvailable(row.value);
|
||||
</script>
|
||||
<template>
|
||||
<VnTable
|
||||
|
@ -214,22 +216,6 @@ const isSelectionAvailable = (itemProposal) => {
|
|||
'row-key': 'id',
|
||||
}"
|
||||
>
|
||||
<template #body-selection="props">
|
||||
<QCheckbox
|
||||
class="q-ma-xs"
|
||||
flat
|
||||
:disable="isSelectionAvailable(props.row)"
|
||||
v-model="props.selected"
|
||||
@update:model-value="(evt, _) => handleSelection(props.row, null)"
|
||||
>
|
||||
<QTooltip>
|
||||
<span v-if="isSelectionAvailable(props.row)">{{
|
||||
t('proposal.available')
|
||||
}}</span>
|
||||
<span v-else>{{ t('proposal.available') }}</span>
|
||||
</QTooltip>
|
||||
</QCheckbox>
|
||||
</template>
|
||||
<template #column-longName="{ row }">
|
||||
<QTd
|
||||
class="flex"
|
||||
|
@ -244,13 +230,13 @@ const isSelectionAvailable = (itemProposal) => {
|
|||
color="primary"
|
||||
flat
|
||||
dense
|
||||
:disable="isDisabled(row)"
|
||||
@click="change(row)"
|
||||
:class="{
|
||||
'fill-icon': isSelected(row),
|
||||
}"
|
||||
@click="change(row)"
|
||||
:disable="!isSelectionAvailable(row)"
|
||||
>
|
||||
<QTooltip> {{ t('Open_details') }}</QTooltip>
|
||||
<QTooltip> {{ isDisabled ? t('Disabled') : t('Enabled') }} </QTooltip>
|
||||
</QBtn>
|
||||
<div
|
||||
class="middle compatibility"
|
||||
|
|
|
@ -134,6 +134,43 @@ const filterTable = { stateFk: 0, warehouseFk: useState().getUser().value.wareho
|
|||
/>
|
||||
<VnSubToolbar>
|
||||
<template #st-data>
|
||||
<QBtn
|
||||
data-cy="transferLines"
|
||||
color="primary"
|
||||
icon="vn:splitline"
|
||||
:disable="selectedRows.length < 1"
|
||||
>
|
||||
<QTooltip>{{ t('ticketSale.transferLines') }} </QTooltip>
|
||||
<TicketTransfer
|
||||
ref="transferFormRef"
|
||||
split="true"
|
||||
class="full-width"
|
||||
:transfer="{
|
||||
sales: selectedRows,
|
||||
lastActiveTickets: selectedRows.map((row) => row.ticketFk),
|
||||
}"
|
||||
></TicketTransfer>
|
||||
</QBtn>
|
||||
<QBtn
|
||||
data-cy="itemProposal"
|
||||
color="primary"
|
||||
@click="showProposalDialog = true"
|
||||
:disable="selectedRows.length < 1"
|
||||
>
|
||||
<QIcon name="import_export" class="rotate-90"></QIcon>
|
||||
<ItemProposalProxy
|
||||
ref="proposalDialogRef"
|
||||
:item-lack="itemLack"
|
||||
:replace-action="true"
|
||||
:sales="selectedRows"
|
||||
@item-replaced="itemProposalEvt"
|
||||
></ItemProposalProxy>
|
||||
<QTooltip bottom anchor="bottom right">
|
||||
{{ t('itemProposal') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
</template>
|
||||
<template #st-actions>
|
||||
<QBtnGroup push style="column-gap: 1px">
|
||||
<VnPopupProxy
|
||||
data-cy="changeItem"
|
||||
|
@ -178,41 +215,6 @@ const filterTable = { stateFk: 0, warehouseFk: useState().getUser().value.wareho
|
|||
:selected-rows="selectedRows"
|
||||
/></template>
|
||||
</VnPopupProxy>
|
||||
<QBtn
|
||||
data-cy="transferLines"
|
||||
color="primary"
|
||||
icon="vn:splitline"
|
||||
:disable="selectedRows.length < 1"
|
||||
>
|
||||
<QTooltip>{{ t('ticketSale.transferLines') }} </QTooltip>
|
||||
<TicketTransfer
|
||||
ref="transferFormRef"
|
||||
split="true"
|
||||
class="full-width"
|
||||
:transfer="{
|
||||
sales: selectedRows,
|
||||
lastActiveTickets: selectedRows.map((row) => row.ticketFk),
|
||||
}"
|
||||
></TicketTransfer>
|
||||
</QBtn>
|
||||
<QBtn
|
||||
data-cy="itemProposal"
|
||||
color="primary"
|
||||
@click="showProposalDialog = true"
|
||||
:disable="selectedRows.length < 1"
|
||||
>
|
||||
<QIcon name="import_export" class="rotate-90"></QIcon>
|
||||
<ItemProposalProxy
|
||||
ref="proposalDialogRef"
|
||||
:item-lack="itemLack"
|
||||
:replace-action="true"
|
||||
:sales="selectedRows"
|
||||
@item-replaced="itemProposalEvt"
|
||||
></ItemProposalProxy>
|
||||
<QTooltip bottom anchor="bottom right">
|
||||
{{ t('itemProposal') }}
|
||||
</QTooltip>
|
||||
</QBtn>
|
||||
</QBtnGroup>
|
||||
</template>
|
||||
</VnSubToolbar>
|
||||
|
|
|
@ -3,6 +3,7 @@ import { ref } from 'vue';
|
|||
import { useI18n } from 'vue-i18n';
|
||||
import axios from 'axios';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import handlePromiseResults from './notifyResults';
|
||||
const emit = defineEmits(['update-item']);
|
||||
|
||||
const { t } = useI18n();
|
||||
|
@ -18,13 +19,15 @@ const $props = defineProps({
|
|||
const updateItem = async () => {
|
||||
try {
|
||||
showChangeItemDialog.value = true;
|
||||
const rowsToUpdate = $props.selectedRows.map(({ saleFk }) =>
|
||||
axios.post(`Sales/${saleFk}/updateConcept`, {
|
||||
newConcept: newItem.value,
|
||||
const rowsToUpdate = $props.selectedRows.map(({ saleFk, quantity }) =>
|
||||
axios.post(`Sales/replaceItem`, {
|
||||
saleFk,
|
||||
substitutionFk: newItem.value,
|
||||
quantity,
|
||||
}),
|
||||
);
|
||||
await Promise.allSettled(rowsToUpdate);
|
||||
|
||||
const result = await Promise.allSettled(rowsToUpdate);
|
||||
handlePromiseResults(result, 'saleFk');
|
||||
emit('update-item', newItem.value);
|
||||
} catch (err) {
|
||||
console.error('Error updating item:', err);
|
||||
|
|
|
@ -3,6 +3,7 @@ import { ref, defineEmits } from 'vue';
|
|||
import { useI18n } from 'vue-i18n';
|
||||
import axios from 'axios';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import handlePromiseResults from './notifyResults';
|
||||
|
||||
const { t } = useI18n();
|
||||
const showChangeQuantityDialog = ref(false);
|
||||
|
@ -19,11 +20,14 @@ const updateQuantity = async () => {
|
|||
showChangeQuantityDialog.value = true;
|
||||
const rowsToUpdate = $props.selectedRows.map(({ saleFk }) =>
|
||||
axios.post(`Sales/${saleFk}/updateQuantity`, {
|
||||
saleFk,
|
||||
quantity: +newQuantity.value,
|
||||
}),
|
||||
);
|
||||
|
||||
await Promise.allSettled(rowsToUpdate);
|
||||
const result = await Promise.allSettled(rowsToUpdate);
|
||||
handlePromiseResults(result, 'saleFk');
|
||||
|
||||
emit('update-quantity', newQuantity.value);
|
||||
} catch (err) {
|
||||
return err;
|
||||
|
|
|
@ -4,8 +4,9 @@ import { useI18n } from 'vue-i18n';
|
|||
import axios from 'axios';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
const emit = defineEmits(['update-state']);
|
||||
import handlePromiseResults from './notifyResults';
|
||||
|
||||
const emit = defineEmits(['update-state']);
|
||||
const editableStates = ref([]);
|
||||
const { t } = useI18n();
|
||||
const showChangeStateDialog = ref(false);
|
||||
|
@ -19,13 +20,14 @@ const $props = defineProps({
|
|||
const updateState = async () => {
|
||||
try {
|
||||
showChangeStateDialog.value = true;
|
||||
const rowsToUpdate = $props.selectedRows.map(({ ticketFk }) =>
|
||||
const rowsToUpdate = $props.selectedRows.map(({ id }) =>
|
||||
axios.post(`Tickets/state`, {
|
||||
ticketFk,
|
||||
ticketFk: id,
|
||||
code: newState.value,
|
||||
}),
|
||||
);
|
||||
await Promise.allSettled(rowsToUpdate);
|
||||
const result = await Promise.allSettled(rowsToUpdate);
|
||||
handlePromiseResults(result, 'ticketFk');
|
||||
|
||||
emit('update-state', newState.value);
|
||||
} catch (err) {
|
||||
|
|
|
@ -0,0 +1,23 @@
|
|||
import { Notify } from 'quasar';
|
||||
|
||||
export default function (results, key) {
|
||||
results.forEach((result, index) => {
|
||||
if (result.status === 'fulfilled') {
|
||||
const data = JSON.parse(result.value.config.data);
|
||||
console.log(`Promise ${index + 1} fulfilled:`, result.value);
|
||||
// Mostrar notificación de éxito
|
||||
Notify.create({
|
||||
type: 'positive',
|
||||
message: `Operación (${index + 1}) ${data[key]} completada con éxito.`,
|
||||
});
|
||||
} else {
|
||||
const data = JSON.parse(result.reason.config.data);
|
||||
console.error(`Promise ${index + 1} rejected:`, result.reason);
|
||||
// Mostrar notificación de error
|
||||
Notify.create({
|
||||
type: 'negative',
|
||||
message: `Operación (${index + 1}) ${data[key]} fallida: ${result.reason.message}`,
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
Loading…
Reference in New Issue