feat: refs #8087 reactive data
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-11-12 16:37:59 +01:00
parent b460a0be2f
commit 4572817699
4 changed files with 35 additions and 68 deletions

View File

@ -21,12 +21,7 @@ const agenciesOptions = ref([]);
@on-fetch="(data) => (agenciesOptions = data)" @on-fetch="(data) => (agenciesOptions = data)"
auto-load auto-load
/> />
<FormModel <FormModel :url-update="`Travels/${route.params.id}`" model="Travel" auto-load>
:url="`Travels/${route.params.id}`"
:url-update="`Travels/${route.params.id}`"
model="Travel"
auto-load
>
<template #form="{ data }"> <template #form="{ data }">
<VnRow> <VnRow>
<VnInput v-model="data.ref" :label="t('travel.basicData.reference')" /> <VnInput v-model="data.ref" :label="t('travel.basicData.reference')" />

View File

@ -1,34 +1,7 @@
<script setup> <script setup>
import VnCard from 'components/common/VnCard.vue'; import VnCard from 'components/common/VnCard.vue';
import TravelDescriptor from './TravelDescriptor.vue'; import TravelDescriptor from './TravelDescriptor.vue';
import filter from './TravelFilter.js';
const filter = {
fields: [
'id',
'ref',
'shipped',
'landed',
'totalEntries',
'warehouseInFk',
'warehouseOutFk',
'cargoSupplierFk',
'agencyModeFk',
],
include: [
{
relation: 'warehouseIn',
scope: {
fields: ['name'],
},
},
{
relation: 'warehouseOut',
scope: {
fields: ['name'],
},
},
],
};
</script> </script>
<template> <template>
<VnCard <VnCard

View File

@ -7,7 +7,7 @@ import CardDescriptor from 'components/ui/CardDescriptor.vue';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
import useCardDescription from 'src/composables/useCardDescription'; import useCardDescription from 'src/composables/useCardDescription';
import TravelDescriptorMenuItems from './TravelDescriptorMenuItems.vue'; import TravelDescriptorMenuItems from './TravelDescriptorMenuItems.vue';
import filter from './TravelFilter.js';
import { toDate } from 'src/filters'; import { toDate } from 'src/filters';
const $props = defineProps({ const $props = defineProps({
@ -21,36 +21,6 @@ const $props = defineProps({
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const filter = {
fields: [
'id',
'ref',
'shipped',
'landed',
'totalEntries',
'warehouseInFk',
'warehouseOutFk',
'cargoSupplierFk',
'agencyModeFk',
'isRaid',
'daysInForward',
],
include: [
{
relation: 'warehouseIn',
scope: {
fields: ['name'],
},
},
{
relation: 'warehouseOut',
scope: {
fields: ['name'],
},
},
],
};
const entityId = computed(() => { const entityId = computed(() => {
return $props.id || route.params.id; return $props.id || route.params.id;
}); });
@ -66,15 +36,15 @@ const setData = (entity) => (data.value = useCardDescription(entity.ref, entity.
:title="data.title" :title="data.title"
:subtitle="data.subtitle" :subtitle="data.subtitle"
:filter="filter" :filter="filter"
data-key="travelData" data-key="Travel"
@on-fetch="setData" @on-fetch="setData"
> >
<template #menu="{ entity }"> <template #menu="{ entity }">
<TravelDescriptorMenuItems :travel="entity" /> <TravelDescriptorMenuItems :travel="entity" />
</template> </template>
<template #body="{ entity }"> <template #body="{ entity }">
<VnLv :label="t('globals.wareHouseIn')" :value="entity.warehouseIn.name" /> <VnLv :label="t('globals.wareHouseIn')" :value="entity.warehouseIn?.name" />
<VnLv :label="t('globals.wareHouseOut')" :value="entity.warehouseOut.name" /> <VnLv :label="t('globals.wareHouseOut')" :value="entity.warehouseOut?.name" />
<VnLv :label="t('globals.shipped')" :value="toDate(entity.shipped)" /> <VnLv :label="t('globals.shipped')" :value="toDate(entity.shipped)" />
<VnLv :label="t('globals.landed')" :value="toDate(entity.landed)" /> <VnLv :label="t('globals.landed')" :value="toDate(entity.landed)" />
<VnLv :label="t('globals.totalEntries')" :value="entity.totalEntries" /> <VnLv :label="t('globals.totalEntries')" :value="entity.totalEntries" />

View File

@ -0,0 +1,29 @@
export default {
fields: [
'id',
'ref',
'shipped',
'landed',
'totalEntries',
'warehouseInFk',
'warehouseOutFk',
'cargoSupplierFk',
'agencyModeFk',
'isRaid',
'daysInForward',
],
include: [
{
relation: 'warehouseIn',
scope: {
fields: ['name'],
},
},
{
relation: 'warehouseOut',
scope: {
fields: ['name'],
},
},
],
};