perf: TransferSale and implementations

This commit is contained in:
Javier Segarra 2024-07-23 12:33:11 +02:00
parent a53f4bd957
commit 437d70d415
4 changed files with 72 additions and 33 deletions

View File

@ -507,6 +507,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
>
<QTooltip>{{ t('ticketSale.transferLines') }}</QTooltip>
<TicketTransfer
class="full-width"
:transfer="transfer"
:ticket="store.data"
@refresh-data="resetChanges()"

View File

@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import VnInput from 'src/components/common/VnInput.vue';
import TicketTransferForm from './TicketTransferForm.vue';
import { toDateFormat } from 'src/filters/date.js';
import axios from 'axios';
@ -26,15 +27,15 @@ const $props = defineProps({
default: () => {},
},
});
const _transfer = ref(null);
onMounted(() => (_transfer.value = $props.transfer));
const emit = defineEmits(['refreshData']);
const router = useRouter();
const { t } = useI18n();
const QPopupProxyRef = ref(null);
const _transfer = ref(null);
const transferLinesColumns = computed(() => [
{
label: t('ticketSale.id'),
@ -98,13 +99,11 @@ const transferSales = async (ticketId) => {
if (data && data.id === $props.ticket.id) emit('refreshData');
else router.push({ name: 'TicketSale', params: { id: data.id } });
};
onMounted(() => (_transfer.value = $props.transfer));
</script>
<template>
<QPopupProxy ref="QPopupProxyRef">
<QCard class="q-px-md" style="display: flex">
<QPopupProxy :breakpoint="600" ref="QPopupProxyRef">
<QCard class="full-width q-px-md" style="display: flex; width: 100vw">
<QTable
v-if="transfer.sales"
:rows="transfer.sales"
@ -135,9 +134,10 @@ onMounted(() => (_transfer.value = $props.transfer));
:columns="destinationTicketColumns"
:title="t('Destination ticket')"
row-key="id"
:pagination="{ rowsPerPage: 0 }"
class="full-width q-mt-md"
:no-data-label="t('globals.noResults')"
:pagination="{ rowsPerPage: 0 }"
@row-click="(_, row) => transferSales(row.id)"
>
<template #body-cell-address="{ row }">
<QTd @click.stop>
@ -158,35 +158,21 @@ onMounted(() => (_transfer.value = $props.transfer));
</QTd>
</template>
<template #no-data>
<TicketTransferForm @refresh-data="transferSales" />
</template>
<template #bottom>
<QForm class="q-mt-lg full-width">
<VnInput
v-model.number="_transfer.ticketId"
:label="t('Transfer to ticket')"
:clearable="false"
>
<template #append>
<QBtn
icon="keyboard_arrow_right"
color="primary"
@click="transferSales(_transfer.ticketId)"
style="width: 30px"
/>
</template>
</VnInput>
<QBtn
:label="t('New ticket')"
color="primary"
class="full-width q-my-lg"
@click="transferSales()"
/>
</QForm>
<TicketTransferForm @refresh-data="transferSales" />
</template>
</QTable>
</QCard>
</QPopupProxy>
</template>
<style lang="scss">
.q-table__bottom.row.items-center.q-table__bottom--nodata {
border-top: none;
}
</style>
<i18n>
es:
Sales to transfer: Líneas a transferir

View File

@ -0,0 +1,44 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import VnInput from 'src/components/common/VnInput.vue';
const emit = defineEmits(['refreshData']);
const { t } = useI18n();
const newTicket = ref(null);
</script>
<template>
<QForm class="q-mt-lg full-width">
<VnInput
v-model.number="newTicket"
:label="t('Transfer to ticket')"
:clearable="false"
>
<template #append>
<QBtn
icon="keyboard_arrow_right"
color="primary"
@click="emit('refreshData', newTicket)"
style="width: 30px"
/>
</template>
</VnInput>
<QBtn
:label="t('New ticket')"
color="primary"
class="full-width q-my-lg"
@click="emit('refreshData')"
/>
</QForm>
</template>
<i18n>
es:
Sales to transfer: Líneas a transferir
Destination ticket: Ticket destinatario
Transfer to ticket: Transferir a ticket
New ticket: Nuevo ticket
</i18n>

View File

@ -247,8 +247,10 @@ function freeFirst({ alertLevel: a }, { alertLevel: b }) {
}
const { store } = useArrayData(URL_KEY);
const handleRows = (rows) => {
rows.forEach((row) => (row.concept = item.value.name));
rows = rows.sort(freeFirst);
if (showFree.value) return rows.filter(({ alertLevel }) => alertLevel === 0);
return rows.sort(freeFirst);
return rows;
};
const itemProposalEvt = ({ itemProposal }) => {
@ -364,9 +366,15 @@ const replaceItem = () => {
{{ t('globals.split') }}
</QTooltip>
</QBtn> -->
<QBtn color="primary" icon="vn:splitline" @click="setTransferParams()">
<QBtn color="primary" icon="vn:splitline">
<QTooltip>{{ t('ticketSale.transferLines') }}</QTooltip>
<TicketTransfer></TicketTransfer
<TicketTransfer
class="full-width"
:transfer="{
sales: selectedRows,
lastActiveTickets: selectedRows.map((row) => row.ticketFk),
}"
></TicketTransfer
></QBtn>
<QBtn color="primary" @click="showProposalDialog = true">
<QIcon name="import_export" class="rotate-90"></QIcon>