8381-thermographTravel #1244

Open
jgallego wants to merge 5 commits from 8381-thermographTravel into dev
5 changed files with 82 additions and 19 deletions
Showing only changes of commit 94c0fa2aa7 - Show all commits

View File

@ -799,6 +799,7 @@ travel:
destination: Destination
thermograph: Thermograph
travelFileDescription: 'Travel id { travelId }'
carrier: Carrier
item:
descriptor:
buyer: Buyer

View File

@ -795,6 +795,7 @@ travel:
destination: Destino
thermograph: Termógrafo
travelFileDescription: 'Id envío { travelId }'
carrier: Transportista
item:
descriptor:
buyer: Comprador

View File

@ -122,6 +122,12 @@ const thermographsTableColumns = computed(() => {
name: 'temperatureFk',
align: 'left',
},
{
label: t('travel.thermographs.carrier'),
field: (row) => row.agencyMode?.name,
name: 'agencyModeFk',
align: 'left',
},
{
label: t('globals.maxTemperature'),
field: 'maxTemperature',
@ -200,17 +206,25 @@ const getTravelEntries = async (id) => {
const getTravelThermographs = async (id) => {
const filter = {
include: {
relation: 'warehouse',
scope: {
fields: ['id', 'name'],
include: [
{
relation: 'agencyMode',
scope: {
fields: ['id', 'name'],
},
},
},
{
relation: 'warehouse',
scope: {
fields: ['id', 'name'],
},
},
],
where: { travelFk: id },
};
const { data } = await axios.get('TravelThermographs', {
params: { filter: JSON.parse(JSON.stringify(filter)) },
params: { filter },
});
thermographs.value = data;
};

View File

@ -1,5 +1,5 @@
<script setup>
import { computed, ref } from 'vue';
import { computed, ref, onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar';
@ -12,23 +12,40 @@ import axios from 'axios';
import useNotify from 'src/composables/useNotify.js';
import { toDate } from 'src/filters';
import { downloadFile } from 'src/composables/downloadFile';
import { useArrayData } from 'src/composables/useArrayData';
const route = useRoute();
const quasar = useQuasar();
const router = useRouter();
const { t } = useI18n();
const { notify } = useNotify();
const { store: travelStore, fetch: fetchTravel } = useArrayData('SingleTravel', {
url: 'Travel',
limit: 1,
filter: {
where: { id: route.params.id },
},
// Si quisieras guardar en la URL, podrías usar searchUrl: 'travelSearch'
});
const travelItem = computed(() => travelStore.data?.[0] ?? null);
const thermographPaginateRef = ref();
const warehouses = ref([]);
const thermographFilter = {
include: {
relation: 'warehouse',
scope: {
fields: ['id', 'name'],
include: [
{
relation: 'agencyMode',
scope: {
fields: ['id', 'name'],
},
},
},
{
relation: 'warehouse',
scope: {
fields: ['id', 'name'],
},
},
],
where: { travelFk: route.params.id },
order: ['created'],
};
@ -47,6 +64,12 @@ const TableColumns = computed(() => {
name: 'temperatureFk',
align: 'left',
},
{
label: t('travel.thermographs.carrier'),
field: (row) => row.agencyMode?.name,
name: 'agencyModeFk',
align: 'left',
},
{
label: t('globals.maxTemperature'),
field: 'maxTemperature',
@ -117,6 +140,8 @@ const redirectToThermographForm = (action, id) => {
if (action === 'edit' && id) {
routeDetails.query = { travelThermographFk: id };
} else if (action === 'create') {
routeDetails.query = { agencyModeFk: travelItem.value?.agencyModeFk };
}
router.push(routeDetails);
};
@ -126,6 +151,9 @@ const removeThermograph = async (id) => {
await thermographPaginateRef.value.fetch();
notify(t('Thermograph removed'), 'positive');
};
onMounted(() => {
fetchTravel();
});
</script>
<template>

View File

@ -39,6 +39,7 @@ const warehousesOptions = ref([]);
const temperaturesOptions = ref([]);
const thermographForm = ref({});
const inputFileRef = ref(null);
const agencyModeOptions = ref([]);
onBeforeMount(async () => {
if (props.viewAction === 'create') {
@ -49,8 +50,8 @@ onBeforeMount(async () => {
if (route.query.thermographData) {
const thermographData = JSON.parse(route.query.thermographData);
for (let key in thermographForm) {
thermographForm[key] = thermographData[key];
for (let key in thermographForm.value) {
thermographForm.value[key] = thermographData[key];
}
}
});
@ -72,6 +73,7 @@ const setCreateDefaultParams = async () => {
thermographForm.value.reference = route.params.id;
thermographForm.value.dmsTypeId = dataResponse.id;
thermographForm.value.state = 'Ok';
thermographForm.value.agencyModeFk = +route.query.agencyModeFk;
thermographForm.value.description = t('travel.thermographs.travelFileDescription', {
travelId: route.params.id,
}).toUpperCase();
@ -98,6 +100,7 @@ const setEditDefaultParams = async () => {
thermographForm.value.minTemperature = data.minTemperature;
thermographForm.value.temperatureFk = data.temperatureFk;
thermographForm.value.travelThermographFk = data.id;
thermographForm.value.agencyModeFk = data.agencyModeFk;
}
};
@ -159,6 +162,12 @@ const onThermographCreated = async (data) => {
auto-load
url="Temperatures"
/>
<FetchData
@on-fetch="(data) => (agencyModeOptions = data)"
auto-load
url="AgencyModeIncomings"
/>
<QPage class="column items-center full-width">
<QForm
model="travel"
@ -218,10 +227,20 @@ const onThermographCreated = async (data) => {
/>
</VnRow>
<VnRow>
<VnSelect
:label="t('travel.thermographs.carrier')"
v-model="thermographForm.agencyModeFk"
:options="agencyModeOptions"
option-value="id"
option-label="name"
/>
<VnInput
v-model="thermographForm.reference"
:label="t('globals.reference')"
/>
</VnRow>
<VnRow>
<VnSelect
:label="t('globals.type')"
v-model="thermographForm.dmsTypeId"
@ -229,8 +248,6 @@ const onThermographCreated = async (data) => {
option-value="id"
option-label="name"
/>
</VnRow>
<VnRow>
<VnSelect
:label="t('globals.company')"
v-model="thermographForm.companyId"
@ -238,6 +255,8 @@ const onThermographCreated = async (data) => {
option-value="id"
option-label="code"
/>
</VnRow>
<VnRow>
<VnSelect
:label="t('globals.warehouse')"
v-model="thermographForm.warehouseId"
@ -245,8 +264,6 @@ const onThermographCreated = async (data) => {
option-value="id"
option-label="name"
/>
</VnRow>
<VnRow>
<VnSelect
:label="t('travel.thermographs.temperature')"
:options="temperaturesOptions"
@ -256,6 +273,8 @@ const onThermographCreated = async (data) => {
v-model="thermographForm.temperatureFk"
:required="true"
/>
</VnRow>
<VnRow>
<VnInputNumber
v-model="thermographForm.maxTemperature"
:label="t('globals.maxTemperature')"