forked from verdnatura/salix-front
Ticket volume
This commit is contained in:
parent
cc0eb77228
commit
91df35fcae
|
@ -443,6 +443,7 @@ ticket:
|
|||
sms: Sms
|
||||
notes: Notes
|
||||
sale: Sale
|
||||
volume: Volume
|
||||
list:
|
||||
nickname: Nickname
|
||||
state: State
|
||||
|
|
|
@ -441,6 +441,7 @@ ticket:
|
|||
sms: Sms
|
||||
notes: Notas
|
||||
sale: Lineas del pedido
|
||||
volume: Volumen
|
||||
list:
|
||||
nickname: Alias
|
||||
state: Estado
|
||||
|
|
|
@ -1,17 +1,29 @@
|
|||
<script setup>
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { computed } from 'vue';
|
||||
|
||||
import VnCard from 'components/common/VnCard.vue';
|
||||
import TicketDescriptor from './TicketDescriptor.vue';
|
||||
import TicketFilter from '../TicketFilter.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const route = useRoute();
|
||||
|
||||
const routeName = computed(() => route.name);
|
||||
const searchBarDataKeys = {
|
||||
TicketSummary: 'TicketSummary',
|
||||
TicketVolume: 'TicketVolume',
|
||||
};
|
||||
</script>
|
||||
<template>
|
||||
<VnCard
|
||||
data-key="Ticket"
|
||||
base-url="Tickets"
|
||||
:descriptor="TicketDescriptor"
|
||||
:filter-panel="TicketFilter"
|
||||
search-data-key="TicketList"
|
||||
search-url="Tickets/filter"
|
||||
searchbar-label="Search ticket"
|
||||
searchbar-info="You can search by ticket id or alias"
|
||||
:descriptor="TicketDescriptor"
|
||||
:search-data-key="searchBarDataKeys[routeName]"
|
||||
:search-custom-route-redirect="routeName"
|
||||
:searchbar-label="t('card.search')"
|
||||
:searchbar-info="t('card.searchInfo')"
|
||||
/>
|
||||
</template>
|
||||
|
|
|
@ -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>
|
|
@ -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
|
|
@ -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
|
||||
You can search by ticket id or alias: Puedes buscar por id o alias del ticket
|
||||
|
|
|
@ -12,7 +12,7 @@ export default {
|
|||
redirect: { name: 'TicketMain' },
|
||||
menus: {
|
||||
main: ['TicketList'],
|
||||
card: ['TicketBoxing', 'TicketSms', 'TicketSale'],
|
||||
card: ['TicketBoxing', 'TicketSms', 'TicketSale', 'TicketVolume', 'TicketVolume'],
|
||||
},
|
||||
children: [
|
||||
{
|
||||
|
@ -93,6 +93,15 @@ export default {
|
|||
},
|
||||
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'),
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
|
Loading…
Reference in New Issue