Merge pull request 'fix: refs #8227 warnfix' (!1385) from 8227-warmfixRoute into test
gitea/salix-front/pipeline/pr-dev There was a failure building this commit Details
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #1385
Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
Reviewed-by: Alex Moreno <alexm@verdnatura.es>
This commit is contained in:
Alex Moreno 2025-02-14 09:45:37 +00:00
commit bf08509b52
2 changed files with 36 additions and 9 deletions

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, computed } from 'vue'; import { ref, computed, onMounted } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import CardDescriptor from 'components/ui/CardDescriptor.vue'; import CardDescriptor from 'components/ui/CardDescriptor.vue';
@ -7,7 +7,7 @@ import VnLv from 'components/ui/VnLv.vue';
import useCardDescription from 'composables/useCardDescription'; import useCardDescription from 'composables/useCardDescription';
import { dashIfEmpty, toDate } from 'src/filters'; import { dashIfEmpty, toDate } from 'src/filters';
import RouteDescriptorMenu from 'pages/Route/Card/RouteDescriptorMenu.vue'; import RouteDescriptorMenu from 'pages/Route/Card/RouteDescriptorMenu.vue';
import axios from 'axios';
const $props = defineProps({ const $props = defineProps({
id: { id: {
type: Number, type: Number,
@ -18,10 +18,24 @@ const $props = defineProps({
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const zone = ref();
const zoneId = ref();
const entityId = computed(() => { const entityId = computed(() => {
return $props.id || route.params.id; return $props.id || route.params.id;
}); });
const getZone = async () => {
const filter = {
where: { routeFk: $props.id ? $props.id : route.params.id },
};
const { data } = await axios.get('Tickets/findOne', {
params: {
filter: JSON.stringify(filter),
},
});
zoneId.value = data.zoneFk;
const { data: zoneData } = await axios.get(`Zones/${zoneId.value}`);
zone.value = zoneData.name;
};
const filter = { const filter = {
fields: [ fields: [
@ -38,7 +52,6 @@ const filter = {
'started', 'started',
'finished', 'finished',
'cost', 'cost',
'zoneFk',
'isOk', 'isOk',
], ],
include: [ include: [
@ -47,7 +60,13 @@ const filter = {
relation: 'vehicle', relation: 'vehicle',
scope: { fields: ['id', 'm3'] }, scope: { fields: ['id', 'm3'] },
}, },
{ relation: 'zone', scope: { fields: ['id', 'name'] } }, {
relation: 'ticket',
scope: {
fields: ['id', 'name', 'zoneFk'],
include: { relation: 'zone', scope: { fields: ['id', 'name'] } },
},
},
{ {
relation: 'worker', relation: 'worker',
scope: { scope: {
@ -65,6 +84,9 @@ const filter = {
}; };
const data = ref(useCardDescription()); const data = ref(useCardDescription());
const setData = (entity) => (data.value = useCardDescription(entity.code, entity.id)); const setData = (entity) => (data.value = useCardDescription(entity.code, entity.id));
onMounted(async () => {
getZone();
});
</script> </script>
<template> <template>
@ -81,11 +103,11 @@ const setData = (entity) => (data.value = useCardDescription(entity.code, entity
<template #body="{ entity }"> <template #body="{ entity }">
<VnLv :label="t('Date')" :value="toDate(entity?.dated)" /> <VnLv :label="t('Date')" :value="toDate(entity?.dated)" />
<VnLv :label="t('Agency')" :value="entity?.agencyMode?.name" /> <VnLv :label="t('Agency')" :value="entity?.agencyMode?.name" />
<VnLv :label="t('Zone')" :value="entity?.zone?.name" /> <VnLv :label="t('Zone')" :value="zone" />
<VnLv <VnLv
:label="t('Volume')" :label="t('Volume')"
:value="`${dashIfEmpty(entity?.m3)} / ${dashIfEmpty( :value="`${dashIfEmpty(entity?.m3)} / ${dashIfEmpty(
entity?.vehicle?.m3 entity?.vehicle?.m3,
)} `" )} `"
/> />
<VnLv :label="t('Description')" :value="entity?.description" /> <VnLv :label="t('Description')" :value="entity?.description" />

View File

@ -43,7 +43,6 @@ const routeFilter = {
'started', 'started',
'finished', 'finished',
'cost', 'cost',
'zoneFk',
'isOk', 'isOk',
], ],
include: [ include: [
@ -52,7 +51,13 @@ const routeFilter = {
relation: 'vehicle', relation: 'vehicle',
scope: { fields: ['id', 'm3'] }, scope: { fields: ['id', 'm3'] },
}, },
{ relation: 'zone', scope: { fields: ['id', 'name'] } }, {
relation: 'ticket',
scope: {
fields: ['id', 'name', 'zoneFk'],
include: { relation: 'zone', scope: { fields: ['id', 'name'] } },
},
},
{ {
relation: 'worker', relation: 'worker',
scope: { scope: {