0
0
Fork 0

feat: added click and transfer tickets and deleted useless code

This commit is contained in:
Jon Elias 2024-10-04 12:34:37 +02:00
parent 7874db1647
commit 195747b5a0
2 changed files with 14 additions and 31 deletions

View File

@ -1,13 +1,11 @@
<script setup> <script setup>
import { ref, computed, onMounted } from 'vue'; import { ref, computed, onMounted } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import TicketTransferForm from './TicketTransferForm.vue'; import TicketTransferForm from './TicketTransferForm.vue';
import { toDateFormat } from 'src/filters/date.js'; import { toDateFormat } from 'src/filters/date.js';
import axios from 'axios';
const $props = defineProps({ const $props = defineProps({
mana: { mana: {
@ -28,13 +26,10 @@ const $props = defineProps({
}, },
}); });
const emit = defineEmits(['refreshData']);
const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const QPopupProxyRef = ref(null); const QPopupProxyRef = ref(null);
const transferFormRef = ref(null);
const _transfer = ref(null); const _transfer = ref();
const transferLinesColumns = computed(() => [ const transferLinesColumns = computed(() => [
{ {
@ -85,19 +80,11 @@ const destinationTicketColumns = computed(() => [
}, },
]); ]);
const transferSales = async (ticketId) => { const handleRowClick = (row) => {
const params = { const ticketId = row.id;
ticketId: ticketId, if (transferFormRef.value) {
sales: $props.transfer.sales, transferFormRef.value.transferSales(ticketId);
}; }
const { data } = await axios.post(
`tickets/${$props.ticket.id}/transferSales`,
params
);
if (data && data.id === $props.ticket.id) emit('refreshData');
else router.push({ name: 'TicketSale', params: { id: data.id } });
}; };
onMounted(() => (_transfer.value = $props.transfer)); onMounted(() => (_transfer.value = $props.transfer));
@ -105,9 +92,8 @@ onMounted(() => (_transfer.value = $props.transfer));
<template> <template>
<QPopupProxy ref="QPopupProxyRef"> <QPopupProxy ref="QPopupProxyRef">
<QCard class="q-px-md" style="display: flex"> <QCard class="q-px-md" style="display: flex; width: 80vw">
<QTable <QTable
v-if="transfer.sales"
:rows="transfer.sales" :rows="transfer.sales"
:columns="transferLinesColumns" :columns="transferLinesColumns"
:title="t('Sales to transfer')" :title="t('Sales to transfer')"
@ -121,9 +107,6 @@ onMounted(() => (_transfer.value = $props.transfer));
<VnInput <VnInput
v-model.number="row.quantity" v-model.number="row.quantity"
:clearable="false" :clearable="false"
@keyup.enter="changeQuantity(row)"
@blur="changeQuantity(row)"
@focus="edit.oldQuantity = row.quantity"
style="max-width: 60px" style="max-width: 60px"
/> />
</QTd> </QTd>
@ -137,6 +120,7 @@ onMounted(() => (_transfer.value = $props.transfer));
:title="t('Destination ticket')" :title="t('Destination ticket')"
row-key="id" row-key="id"
class="full-width q-mt-md" class="full-width q-mt-md"
@row-click="(_, row) => handleRowClick(row)"
> >
<template #body-cell-address="{ row }"> <template #body-cell-address="{ row }">
<QTd @click.stop> <QTd @click.stop>
@ -158,10 +142,10 @@ onMounted(() => (_transfer.value = $props.transfer));
</template> </template>
<template #no-data> <template #no-data>
<TicketTransferForm v-bind="$props" /> <TicketTransferForm ref="transferFormRef" v-bind="$props" />
</template> </template>
<template #bottom> <template #bottom>
<TicketTransferForm v-bind="$props" /> <TicketTransferForm ref="transferFormRef" v-bind="$props" />
</template> </template>
</QTable> </QTable>
</QCard> </QCard>

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, onMounted } from 'vue'; import { ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
@ -31,7 +31,7 @@ const emit = defineEmits(['refreshData']);
const router = useRouter(); const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const _transfer = ref(null); const _transfer = ref($props.transfer);
const transferSales = async (ticketId) => { const transferSales = async (ticketId) => {
const params = { const params = {
@ -48,11 +48,10 @@ const transferSales = async (ticketId) => {
else router.push({ name: 'TicketSale', params: { id: data.id } }); else router.push({ name: 'TicketSale', params: { id: data.id } });
}; };
onMounted(() => (_transfer.value = $props.transfer)); defineExpose({ transferSales });
</script> </script>
<template> <template>
{{ _transfer }}
<QForm class="q-mt-lg full-width"> <QForm class="q-mt-lg full-width">
<VnInput <VnInput
v-model.number="_transfer.ticketId" v-model.number="_transfer.ticketId"