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"> <VnLv :label="t('total')" :value="`${volumeSummary?.totalVolume} m³`" />
<div <VnLv
v-if="!volumeSummary?.totalVolume && !volumeSummary?.totalBoxes" :label="t('boxes')"
class="no-result" :value="`${dashIfEmpty(volumeSummary?.totalBoxes)} U`"
> />
{{ t('globals.noResults') }} </QCard>
</div> <VnTable
<QCard v-else class="order-volume-summary q-pa-lg"> ref="volumeRef"
<VnLv :label="t('total')" :value="`${volumeSummary?.totalVolume} m³`" /> data-key="OrderCatalogVolume"
<VnLv url="OrderRows"
:label="t('boxes')" :columns="columns"
:value="`${dashIfEmpty(volumeSummary?.totalBoxes)} U`" auto-load
/> :user-filter="volumeFilter"
</QCard> order="itemFk"
<VnPaginate @on-fetch="(data) => loadVolumes(data)"
data-key="OrderCatalogVolume" :right-search="false"
ref="volumeRef" :column-search="false"
url="OrderRows" >
:limit="20" <template #column-itemFk="{ row }">
auto-load <span class="link">
:user-filter="volumeFilter" {{ row.itemFk }}
order="itemFk" <ItemDescriptorProxy :id="row.itemFk" />
@on-fetch="(data) => loadVolumes(data)" </span>
> </template>
<template #body="{ rows }"> <template #column-description="{ row }">
<div class="catalog-list q-mt-xl"> <FetchedTags :item="row.item" :max-length="5" />
<CardList </template>
v-for="row in rows" <template #column-volume="{ rowIndex }">
:key="row.id" {{ volumes?.[rowIndex]?.volume }}
:id="row.id" </template>
:title="row?.item?.name" </VnTable>
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>
</template>
</VnLv>
<VnLv :label="t('quantity')" :value="row.quantity" />
<VnLv :label="t('volume')" :value="row.volume" />
</template>
</CardList>
</div>
</template>
</VnPaginate>
</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>