forked from verdnatura/salix-front
feat: added click and transfer tickets and deleted useless code
This commit is contained in:
parent
7874db1647
commit
195747b5a0
|
@ -1,13 +1,11 @@
|
|||
<script setup>
|
||||
import { ref, computed, onMounted } from 'vue';
|
||||
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';
|
||||
|
||||
const $props = defineProps({
|
||||
mana: {
|
||||
|
@ -28,13 +26,10 @@ const $props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
const emit = defineEmits(['refreshData']);
|
||||
|
||||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
const QPopupProxyRef = ref(null);
|
||||
|
||||
const _transfer = ref(null);
|
||||
const transferFormRef = ref(null);
|
||||
const _transfer = ref();
|
||||
|
||||
const transferLinesColumns = computed(() => [
|
||||
{
|
||||
|
@ -85,19 +80,11 @@ const destinationTicketColumns = computed(() => [
|
|||
},
|
||||
]);
|
||||
|
||||
const transferSales = async (ticketId) => {
|
||||
const params = {
|
||||
ticketId: ticketId,
|
||||
sales: $props.transfer.sales,
|
||||
};
|
||||
|
||||
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 } });
|
||||
const handleRowClick = (row) => {
|
||||
const ticketId = row.id;
|
||||
if (transferFormRef.value) {
|
||||
transferFormRef.value.transferSales(ticketId);
|
||||
}
|
||||
};
|
||||
|
||||
onMounted(() => (_transfer.value = $props.transfer));
|
||||
|
@ -105,9 +92,8 @@ onMounted(() => (_transfer.value = $props.transfer));
|
|||
|
||||
<template>
|
||||
<QPopupProxy ref="QPopupProxyRef">
|
||||
<QCard class="q-px-md" style="display: flex">
|
||||
<QCard class="q-px-md" style="display: flex; width: 80vw">
|
||||
<QTable
|
||||
v-if="transfer.sales"
|
||||
:rows="transfer.sales"
|
||||
:columns="transferLinesColumns"
|
||||
:title="t('Sales to transfer')"
|
||||
|
@ -121,9 +107,6 @@ onMounted(() => (_transfer.value = $props.transfer));
|
|||
<VnInput
|
||||
v-model.number="row.quantity"
|
||||
:clearable="false"
|
||||
@keyup.enter="changeQuantity(row)"
|
||||
@blur="changeQuantity(row)"
|
||||
@focus="edit.oldQuantity = row.quantity"
|
||||
style="max-width: 60px"
|
||||
/>
|
||||
</QTd>
|
||||
|
@ -137,6 +120,7 @@ onMounted(() => (_transfer.value = $props.transfer));
|
|||
:title="t('Destination ticket')"
|
||||
row-key="id"
|
||||
class="full-width q-mt-md"
|
||||
@row-click="(_, row) => handleRowClick(row)"
|
||||
>
|
||||
<template #body-cell-address="{ row }">
|
||||
<QTd @click.stop>
|
||||
|
@ -158,10 +142,10 @@ onMounted(() => (_transfer.value = $props.transfer));
|
|||
</template>
|
||||
|
||||
<template #no-data>
|
||||
<TicketTransferForm v-bind="$props" />
|
||||
<TicketTransferForm ref="transferFormRef" v-bind="$props" />
|
||||
</template>
|
||||
<template #bottom>
|
||||
<TicketTransferForm v-bind="$props" />
|
||||
<TicketTransferForm ref="transferFormRef" v-bind="$props" />
|
||||
</template>
|
||||
</QTable>
|
||||
</QCard>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script setup>
|
||||
import { ref, onMounted } from 'vue';
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRouter } from 'vue-router';
|
||||
|
||||
|
@ -31,7 +31,7 @@ const emit = defineEmits(['refreshData']);
|
|||
const router = useRouter();
|
||||
const { t } = useI18n();
|
||||
|
||||
const _transfer = ref(null);
|
||||
const _transfer = ref($props.transfer);
|
||||
|
||||
const transferSales = async (ticketId) => {
|
||||
const params = {
|
||||
|
@ -48,11 +48,10 @@ const transferSales = async (ticketId) => {
|
|||
else router.push({ name: 'TicketSale', params: { id: data.id } });
|
||||
};
|
||||
|
||||
onMounted(() => (_transfer.value = $props.transfer));
|
||||
defineExpose({ transferSales });
|
||||
</script>
|
||||
|
||||
<template>
|
||||
{{ _transfer }}
|
||||
<QForm class="q-mt-lg full-width">
|
||||
<VnInput
|
||||
v-model.number="_transfer.ticketId"
|
||||
|
|
Loading…
Reference in New Issue