fix: refs #8227 fix front descriptor, Form
gitea/salix-front/pipeline/pr-test This commit looks good Details

This commit is contained in:
Carlos Satorres 2025-02-13 13:17:49 +01:00
parent da295685a3
commit d8559f9b18
2 changed files with 33 additions and 8 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,27 @@ 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),
},
});
console.log(data);
zoneId.value = data.zoneFk;
console.log('zone: ', zoneId.value);
const { data: zoneData } = await axios.get(`Zones/${zoneId.value}`);
zone.value = zoneData.name;
console.log('zone: ', zone.value);
};
const filter = { const filter = {
fields: [ fields: [
@ -49,8 +66,8 @@ const filter = {
{ {
relation: 'ticket', relation: 'ticket',
scope: { scope: {
fields: ['id', 'name', 'routeFk'], fields: ['id', 'name', 'zoneFk'],
include: { relation: 'route', scope: { fields: ['id', 'name'] } }, include: { relation: 'zone', scope: { fields: ['id', 'name'] } },
}, },
}, },
{ {
@ -70,6 +87,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>
@ -86,7 +106,7 @@ 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?.ticket?.route?.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(

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: {