0
0
Fork 0

Ticket volume

This commit is contained in:
William Buezas 2024-06-24 11:12:49 -03:00
parent cc0eb77228
commit 91df35fcae
7 changed files with 205 additions and 7 deletions

View File

@ -443,6 +443,7 @@ ticket:
sms: Sms sms: Sms
notes: Notes notes: Notes
sale: Sale sale: Sale
volume: Volume
list: list:
nickname: Nickname nickname: Nickname
state: State state: State

View File

@ -441,6 +441,7 @@ ticket:
sms: Sms sms: Sms
notes: Notas notes: Notas
sale: Lineas del pedido sale: Lineas del pedido
volume: Volumen
list: list:
nickname: Alias nickname: Alias
state: Estado state: Estado

View File

@ -1,17 +1,29 @@
<script setup> <script setup>
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import { computed } from 'vue';
import VnCard from 'components/common/VnCard.vue'; import VnCard from 'components/common/VnCard.vue';
import TicketDescriptor from './TicketDescriptor.vue'; import TicketDescriptor from './TicketDescriptor.vue';
import TicketFilter from '../TicketFilter.vue'; import TicketFilter from '../TicketFilter.vue';
const { t } = useI18n();
const route = useRoute();
const routeName = computed(() => route.name);
const searchBarDataKeys = {
TicketSummary: 'TicketSummary',
TicketVolume: 'TicketVolume',
};
</script> </script>
<template> <template>
<VnCard <VnCard
data-key="Ticket" data-key="Ticket"
base-url="Tickets"
:descriptor="TicketDescriptor"
:filter-panel="TicketFilter" :filter-panel="TicketFilter"
search-data-key="TicketList" :descriptor="TicketDescriptor"
search-url="Tickets/filter" :search-data-key="searchBarDataKeys[routeName]"
searchbar-label="Search ticket" :search-custom-route-redirect="routeName"
searchbar-info="You can search by ticket id or alias" :searchbar-label="t('card.search')"
:searchbar-info="t('card.searchInfo')"
/> />
</template> </template>

View File

@ -0,0 +1,153 @@
<script setup>
import { ref, computed, onMounted, onUnmounted, watch, nextTick } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
import FetchedTags from 'components/ui/FetchedTags.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import FetchData from 'components/FetchData.vue';
import { useStateStore } from 'stores/useStateStore';
import { dashIfEmpty } from 'src/filters';
import axios from 'axios';
const route = useRoute();
const stateStore = useStateStore();
const { t } = useI18n();
const salesRef = ref(null);
watch(
() => route.params.id,
async () => {
await nextTick();
salesRef.value?.fetch();
}
);
const salesFilter = computed(() => ({
include: { relation: 'item' },
order: 'concept',
where: { ticketFk: route.params.id },
limit: 20,
}));
const sales = ref([]);
const packingTypeVolume = ref([]);
const rows = computed(() => sales.value);
const columns = computed(() => [
{
label: t('volume.item'),
name: 'item',
align: 'left',
},
{
label: t('volume.description'),
name: 'description',
align: 'left',
},
{
label: t('volume.packingType'),
name: 'quantity',
field: (row) => row.item.itemPackingTypeFk,
align: 'left',
format: (val) => dashIfEmpty(val),
},
{
label: t('volume.quantity'),
name: 'quantity',
field: 'quantity',
align: 'left',
},
{
label: t('volume.volumeQuantity'),
name: 'quantity',
field: (row) => row.saleVolume?.volume,
align: 'left',
},
]);
const applyVolumes = async (salesData) => {
try {
if (!salesData.length) return;
sales.value = salesData;
const ticket = sales.value[0].ticketFk;
const { data } = await axios.get(`Tickets/${ticket}/getVolume`);
const volumes = new Map(data.saleVolume.map((volume) => [volume.saleFk, volume]));
sales.value.forEach((sale) => {
sale.saleVolume = volumes.get(sale.id);
});
packingTypeVolume.value = data.packingTypeVolume;
} catch (error) {
console.error(error);
}
};
onMounted(() => {
stateStore.rightDrawer = true;
});
onUnmounted(() => (stateStore.rightDrawer = false));
</script>
<template>
<FetchData
ref="salesRef"
url="sales"
:filter="salesFilter"
@on-fetch="(data) => applyVolumes(data)"
auto-load
/>
<RightMenu v-if="packingTypeVolume.length">
<template #right-panel>
<QCard
v-for="(packingType, index) in packingTypeVolume"
:key="index"
class="q-pa-md q-mb-md q-ma-md color-vn-text"
bordered
flat
style="border-color: black"
>
<QCardSection class="column items-center" horizontal>
<span>
{{ t('volume.type') }}:
{{ dashIfEmpty(packingType.description) }}
</span>
</QCardSection>
<QCardSection class="column items-center" horizontal>
<span> {{ t('volume.volume') }}: {{ packingType.volume }} </span>
</QCardSection>
</QCard>
</template>
</RightMenu>
<QTable
:rows="rows"
:columns="columns"
row-key="id"
:pagination="{ rowsPerPage: 0 }"
class="full-width q-mt-md"
:no-data-label="t('globals.noResults')"
>
<template #body-cell-item="{ row }">
<QTd>
<QBtn flat color="primary">
{{ row.itemFk }}
<ItemDescriptorProxy :id="row.itemFk" />
</QBtn>
</QTd>
</template>
<template #body-cell-description="{ row }">
<QTd>
<div class="column">
<span>{{ row.item.name }}</span>
<span class="color-vn-label">{{ row.item.subName }}</span>
<FetchedTags :item="row.item" :max-length="6" />
</div>
</QTd>
</template>
</QTable>
</template>

View File

@ -0,0 +1,11 @@
card:
search: Search tickets
searchInfo: You can search by ticket id or alias
volume:
item: Item
description: Description
packingType: Packing Type
quantity: Quantity
volumeQuantity: m³ per quantity
type: Type
volume: Volume

View File

@ -1,2 +1,13 @@
card:
search: Buscar tickets
searchInfo: Buscar tickets por identificador o alias
volume:
item: Artículo
description: Descripción
packingType: Encajado
quantity: Cantidad
volumeQuantity: m³ por cantidad
type: Tipo
volume: Volumen
Search ticket: Buscar ticket Search ticket: Buscar ticket
You can search by ticket id or alias: Puedes buscar por id o alias del ticket You can search by ticket id or alias: Puedes buscar por id o alias del ticket

View File

@ -12,7 +12,7 @@ export default {
redirect: { name: 'TicketMain' }, redirect: { name: 'TicketMain' },
menus: { menus: {
main: ['TicketList'], main: ['TicketList'],
card: ['TicketBoxing', 'TicketSms', 'TicketSale'], card: ['TicketBoxing', 'TicketSms', 'TicketSale', 'TicketVolume', 'TicketVolume'],
}, },
children: [ children: [
{ {
@ -93,6 +93,15 @@ export default {
}, },
component: () => import('src/pages/Ticket/Card/TicketSms.vue'), component: () => import('src/pages/Ticket/Card/TicketSms.vue'),
}, },
{
path: 'volume',
name: 'TicketVolume',
meta: {
title: 'volume',
icon: 'vn:volume',
},
component: () => import('src/pages/Ticket/Card/TicketVolume.vue'),
},
], ],
}, },
], ],