0
0
Fork 0
This commit is contained in:
Javier Segarra 2024-05-28 13:07:22 +02:00
parent 577c21e601
commit d3b93b710d
5 changed files with 38 additions and 102 deletions

View File

@ -111,7 +111,7 @@ const onDataSaved = async () => {
:filter="filterBanks" :filter="filterBanks"
@on-fetch="(data) => (bankOptions = data)" @on-fetch="(data) => (bankOptions = data)"
auto-load auto-load
url="dAccountings" url="Accountings"
/> />
<fetch-data <fetch-data
:filter="filterClientFindOne" :filter="filterClientFindOne"

View File

@ -216,6 +216,7 @@ const entriesTableColumns = computed(() => {
}); });
const copyOriginalRowsData = (rows) => { const copyOriginalRowsData = (rows) => {
// el objetivo de esto es guardar los valores iniciales de todas las rows para evitar guardar cambios si la data no cambió al disparar los eventos
originalRowDataCopy.value = JSON.parse(JSON.stringify(rows)); originalRowDataCopy.value = JSON.parse(JSON.stringify(rows));
}; };

View File

@ -76,7 +76,7 @@ async function insert() {
</script> </script>
<template> <template>
<FetchData <FetchData
url="Accountidngs" url="Accountings"
auto-load auto-load
limit="30" limit="30"
@on-fetch="(data) => (banks = data)" @on-fetch="(data) => (banks = data)"

View File

@ -8,7 +8,7 @@ import FetchData from 'components/FetchData.vue';
import VnPaginate from 'src/components/ui/VnPaginate.vue'; import VnPaginate from 'src/components/ui/VnPaginate.vue';
const { t } = useI18n(); const { t } = useI18n();
const showChangeStateDialog = ref(false); const showSplitDialog = ref(false);
const newState = ref(null); const newState = ref(null);
const resultSplit = ref([]); const resultSplit = ref([]);
const { dialogRef, onDialogHide } = useDialogPluginComponent(); const { dialogRef, onDialogHide } = useDialogPluginComponent();
@ -25,7 +25,7 @@ onMounted(() => {
const updateState = async () => { const updateState = async () => {
try { try {
showChangeStateDialog.value = true; showSplitDialog.value = true;
const rowsToUpdate = $props.tickets.map(({ ticketFk }) => const rowsToUpdate = $props.tickets.map(({ ticketFk }) =>
axios.post(`Tickets/state`, { axios.post(`Tickets/state`, {
ticketFk, ticketFk,
@ -39,47 +39,10 @@ const updateState = async () => {
dialogRef.value.hide({ type: 'refresh', refresh: true }); dialogRef.value.hide({ type: 'refresh', refresh: true });
} }
}; };
const step = ref(1);
const labelStepperBtn = (step) => {
switch (step) {
case 1:
return 'Split';
case 2:
return 'Finish';
default:
return 'Continue';
}
};
const clickStepperBtn = () => {
switch (stepperRef.value.modelValue) {
case 1:
split();
default:
stepperRef.value.next();
break;
}
};
const statusStepperBtn = () => {
switch (stepperRef.value.modelValue) {
case 1:
return ticketsSelected.value.length < 1;
default:
return true;
}
};
const split = async (data = ticketsSelected.value) => {
await axios.post(`Tickets/split`, data);
resultSplit.value = data;
};
const stepperRef = ref(null);
</script> </script>
<template> <template>
<QDialog ref="dialogRef" @hide="onDialogHide" v-model="showChangeStateDialog"> <QDialog ref="dialogRef" @hide="onDialogHide" v-model="showSplitDialog">
<QCard class="q-pa-sm"> <QCard class="q-pa-sm">
<QCardSection class="row items-center q-pb-none"> <QCardSection class="row items-center q-pb-none">
<QAvatar <QAvatar
@ -96,65 +59,26 @@ const stepperRef = ref(null);
<QBtn icon="close" flat round dense v-close-popup /> <QBtn icon="close" flat round dense v-close-popup />
</QCardSection> </QCardSection>
<QCardSection class="row items-center justify-center column items-stretch"> <QCardSection class="row items-center justify-center column items-stretch">
{{ tickets }} {{ tickets
<QStepper v-model="step" ref="stepperRef" color="primary" animated> }}<VnPaginate data-key="splitLack" :data="tickets">
<QStep :name="1" title="Confirm tickets to split" icon="settings"> <template #body="{ rows }">
{{ ticketsSelected }} <QTable :rows="rows" :columns="columns">
<div> <template #header="props">
<QCheckbox <QTr :props="props">
class="q-pa-md" <QTh
v-for="(ticket, index) in tickets" v-for="col in props.cols"
:key="index" :key="col.name"
v-model="ticketsSelected" :props="props"
:label="` Ticket: ${ticket.ticketFk}`" >
:val="ticket.ticketFk" {{ t(col.label) }}
> </QTh>
</QCheckbox> </QTr>
</div> </template>
</QStep> <template #body="props">
<QStep <QTr :props="props"></QTr
:name="2" ></template> </QTable
title="Handle tickets splitted" ></template>
icon="settings" </VnPaginate>
:done="step > 2"
><VnPaginate data-key="splitLack" :data="tickets">
<template #body="{ rows }">
<QTable :rows="rows" :columns="columns">
<template #header="props">
<QTr :props="props">
<QTh
v-for="col in props.cols"
:key="col.name"
:props="props"
>
{{ t(col.label) }}
</QTh>
</QTr>
</template>
<template #body="props">
<QTr :props="props"></QTr
></template> </QTable
></template> </VnPaginate
></QStep>
<template #navigation>
<QStepperNavigation>
<QBtn
@click="clickStepperBtn"
color="primary"
:label="labelStepperBtn(step)"
:disabled="statusStepperBtn()"
/>
<QBtn
v-if="step > 1"
flat
color="primary"
@click="stepperRef.previous()"
label="Back"
class="q-ml-sm"
/>
</QStepperNavigation>
</template>
</QStepper>
</QCardSection> </QCardSection>
<QCardActions align="right"> <QCardActions align="right">
<QBtn :label="t('globals.next')" color="primary" flat v-close-popup /> <QBtn :label="t('globals.next')" color="primary" flat v-close-popup />

View File

@ -315,6 +315,10 @@ const handleRows = (rows) => {
if (showFree.value) return rows.filter(({ alertLevel }) => alertLevel === 0); if (showFree.value) return rows.filter(({ alertLevel }) => alertLevel === 0);
return rows.sort(freeFirst); return rows.sort(freeFirst);
}; };
const split = async (data = selectedRows.value) => {
await axios.post(`Tickets/split`, data);
resultSplit.value = data;
};
</script> </script>
<template> <template>
@ -360,7 +364,14 @@ const handleRows = (rows) => {
</QBtn> </QBtn>
<QBtn <QBtn
color="primary" color="primary"
@click="showSplitDialog = true" @click="
openConfirmationModal(
t('negative.detail.split.title'),
t('negative.detail.split.subTitle'),
() => split,
() => (showSplitDialog = true)
)
"
:disable="selectedRows.length < 1" :disable="selectedRows.length < 1"
icon="call_split" icon="call_split"
> >