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 destination: Destination
thermograph: Thermograph thermograph: Thermograph
travelFileDescription: 'Travel id { travelId }' travelFileDescription: 'Travel id { travelId }'
carrier: Carrier
item: item:
descriptor: descriptor:
buyer: Buyer buyer: Buyer

View File

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

View File

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

View File

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

View File

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