0
0
Fork 0

fix: order description to vnTable

This commit is contained in:
Alex Moreno 2024-08-12 09:17:51 +02:00
parent 37244cdbc7
commit e11e51f432
1 changed files with 67 additions and 99 deletions

View File

@ -2,24 +2,20 @@
import axios from 'axios'; import axios from 'axios';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { ref, watch } from 'vue'; import { ref } from 'vue';
import { useRouter } from 'vue-router';
import VnPaginate from 'components/ui/VnPaginate.vue';
import FetchData from 'components/FetchData.vue';
import VnLv from 'components/ui/VnLv.vue';
import CardList from 'components/ui/CardList.vue';
import FetchedTags from 'components/ui/FetchedTags.vue';
import { useStateStore } from 'stores/useStateStore';
import { dashIfEmpty } from 'src/filters'; import { dashIfEmpty } from 'src/filters';
import { onMounted } from 'vue';
const router = useRouter(); import FetchData from 'components/FetchData.vue';
import FetchedTags from 'components/ui/FetchedTags.vue';
import ItemDescriptorProxy from 'pages/Item/Card/ItemDescriptorProxy.vue';
import VnLv from 'components/ui/VnLv.vue';
import VnTable from 'components/VnTable/VnTable.vue';
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const volumeSummary = ref(null); const volumeSummary = ref(null);
const volumeRef = ref(); const volumeRef = ref();
const stateStore = useStateStore(); const volumes = ref([]);
const volumeFilter = ref({ const volumeFilter = ref({
include: [ include: [
{ {
@ -29,26 +25,39 @@ const volumeFilter = ref({
where: { orderFk: route.params.id }, where: { orderFk: route.params.id },
}); });
const columns = [
{
name: 'itemFk',
label: t('item'),
align: 'left',
},
{
name: 'description',
label: t('globals.description'),
align: 'left',
},
{
name: 'quantity',
label: t('quantity'),
align: 'left',
},
{
name: 'volume',
label: t('volume'),
align: 'left',
},
];
const loadVolumes = async (rows) => { const loadVolumes = async (rows) => {
if (!rows) return;
const { data } = await axios.get(`Orders/${route.params.id}/getVolumes`); const { data } = await axios.get(`Orders/${route.params.id}/getVolumes`);
(rows || []).forEach((order) => { rows.forEach((order) => {
(data.volumes || []).forEach((volume) => { (data.volumes || []).forEach((volume) => {
if (order.itemFk === volume.itemFk) { if (order.itemFk === volume.itemFk) order.volume = volume.volume;
order.volume = volume.volume;
}
}); });
}); });
volumes.value = rows;
}; };
watch(
() => router.currentRoute.value.params.id,
() => {
volumeFilter.value.where.orderFk = router.currentRoute.value.params.id;
volumeRef.value.fetch();
}
);
onMounted(() => (stateStore.rightDrawer = false));
</script> </script>
<template> <template>
@ -57,61 +66,38 @@ onMounted(() => (stateStore.rightDrawer = false));
@on-fetch="(data) => (volumeSummary = data)" @on-fetch="(data) => (volumeSummary = data)"
auto-load auto-load
/> />
<QPage class="column items-center q-pa-md"> <QCard v-if="volumeSummary" class="order-volume-summary q-pa-lg">
<div class="vn-card-list">
<div
v-if="!volumeSummary?.totalVolume && !volumeSummary?.totalBoxes"
class="no-result"
>
{{ t('globals.noResults') }}
</div>
<QCard v-else class="order-volume-summary q-pa-lg">
<VnLv :label="t('total')" :value="`${volumeSummary?.totalVolume} m³`" /> <VnLv :label="t('total')" :value="`${volumeSummary?.totalVolume} m³`" />
<VnLv <VnLv
:label="t('boxes')" :label="t('boxes')"
:value="`${dashIfEmpty(volumeSummary?.totalBoxes)} U`" :value="`${dashIfEmpty(volumeSummary?.totalBoxes)} U`"
/> />
</QCard> </QCard>
<VnPaginate <VnTable
data-key="OrderCatalogVolume"
ref="volumeRef" ref="volumeRef"
data-key="OrderCatalogVolume"
url="OrderRows" url="OrderRows"
:limit="20" :columns="columns"
auto-load auto-load
:user-filter="volumeFilter" :user-filter="volumeFilter"
order="itemFk" order="itemFk"
@on-fetch="(data) => loadVolumes(data)" @on-fetch="(data) => loadVolumes(data)"
:right-search="false"
:column-search="false"
> >
<template #body="{ rows }"> <template #column-itemFk="{ row }">
<div class="catalog-list q-mt-xl"> <span class="link">
<CardList {{ row.itemFk }}
v-for="row in rows" <ItemDescriptorProxy :id="row.itemFk" />
:key="row.id"
:id="row.id"
:title="row?.item?.name"
class="cursor-inherit"
>
<template #list-items>
<div class="q-mb-sm">
<FetchedTags :item="row.item" :max-length="5" />
</div>
<VnLv :label="t('item')" :value="row.item.id" />
<VnLv :label="t('subName')">
<template #value>
<span class="text-uppercase">
{{ row.item.subName }}
</span> </span>
</template> </template>
</VnLv> <template #column-description="{ row }">
<VnLv :label="t('quantity')" :value="row.quantity" /> <FetchedTags :item="row.item" :max-length="5" />
<VnLv :label="t('volume')" :value="row.volume" />
</template> </template>
</CardList> <template #column-volume="{ rowIndex }">
</div> {{ volumes?.[rowIndex]?.volume }}
</template> </template>
</VnPaginate> </VnTable>
</div>
</QPage>
</template> </template>
<style lang="scss"> <style lang="scss">
@ -136,29 +122,12 @@ onMounted(() => (stateStore.rightDrawer = false));
} }
} }
</style> </style>
<style lang="scss" scoped>
.header {
color: $primary;
font-weight: bold;
margin-bottom: 25px;
font-size: 20px;
display: inline-block;
}
.no-result {
font-size: 24px;
font-weight: bold;
color: var(--vn-label-color);
text-align: center;
}
</style>
<i18n> <i18n>
en: en:
summary: Summary summary: Summary
total: Total total: Total
boxes: Boxes boxes: Boxes
item: Item item: Item
subName: Subname
quantity: Quantity quantity: Quantity
volume: per quantity volume: per quantity
es: es:
@ -166,7 +135,6 @@ es:
total: Total total: Total
boxes: Cajas boxes: Cajas
item: Artículo item: Artículo
subName: Subnombre
quantity: Cantidad quantity: Cantidad
volume: por cantidad volume: por cantidad
</i18n> </i18n>