forked from verdnatura/salix-front
Travel termographs and general improvements
This commit is contained in:
parent
91cd4c35e8
commit
9757fdf70a
|
@ -128,14 +128,14 @@ async function save() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const body = $props.mapper ? $props.mapper(formData.value) : formData.value;
|
const body = $props.mapper ? $props.mapper(formData.value) : formData.value;
|
||||||
let response
|
let response;
|
||||||
if ($props.urlCreate) {
|
if ($props.urlCreate) {
|
||||||
response = await axios.post($props.urlCreate, body);
|
response = await axios.post($props.urlCreate, body);
|
||||||
notify('globals.dataCreated', 'positive');
|
notify('globals.dataCreated', 'positive');
|
||||||
} else {
|
} else {
|
||||||
response = await axios.patch($props.urlUpdate || $props.url, body);
|
response = await axios.patch($props.urlUpdate || $props.url, body);
|
||||||
}
|
}
|
||||||
emit('onDataSaved', formData.value, response);
|
emit('onDataSaved', formData.value, response.data);
|
||||||
originalData.value = JSON.parse(JSON.stringify(formData.value));
|
originalData.value = JSON.parse(JSON.stringify(formData.value));
|
||||||
hasChanges.value = false;
|
hasChanges.value = false;
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
|
|
@ -1080,6 +1080,7 @@ export default {
|
||||||
warehouse: 'Warehouse',
|
warehouse: 'Warehouse',
|
||||||
travelFileDescription: 'Travel id { travelId }',
|
travelFileDescription: 'Travel id { travelId }',
|
||||||
file: 'File',
|
file: 'File',
|
||||||
|
description: 'Description',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
|
@ -1080,6 +1080,7 @@ export default {
|
||||||
warehouse: 'Almacén',
|
warehouse: 'Almacén',
|
||||||
travelFileDescription: 'Id envío { travelId }',
|
travelFileDescription: 'Id envío { travelId }',
|
||||||
file: 'Fichero',
|
file: 'Fichero',
|
||||||
|
description: 'Descripción',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
|
|
|
@ -170,11 +170,10 @@ const redirectToCreateView = (queryParams) => {
|
||||||
/>
|
/>
|
||||||
<VnLv :label="t('travel.summary.delivered')" class="q-mb-xs">
|
<VnLv :label="t('travel.summary.delivered')" class="q-mb-xs">
|
||||||
<template #value>
|
<template #value>
|
||||||
<QCheckbox
|
<QIcon
|
||||||
v-model="travel.isDelivered"
|
:name="travel.isDelivered ? 'check' : 'close'"
|
||||||
disable
|
:color="travel.isDelivered ? 'positive' : 'negative'"
|
||||||
dense
|
size="sm"
|
||||||
class="full-width q-my-xs"
|
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</VnLv>
|
</VnLv>
|
||||||
|
@ -187,11 +186,10 @@ const redirectToCreateView = (queryParams) => {
|
||||||
/>
|
/>
|
||||||
<VnLv :label="t('travel.summary.received')" class="q-mb-xs">
|
<VnLv :label="t('travel.summary.received')" class="q-mb-xs">
|
||||||
<template #value>
|
<template #value>
|
||||||
<QCheckbox
|
<QIcon
|
||||||
v-model="travel.isReceived"
|
:name="travel.isReceived ? 'check' : 'close'"
|
||||||
disable
|
:color="travel.isReceived ? 'positive' : 'negative'"
|
||||||
dense
|
size="sm"
|
||||||
class="full-width q-mb-xs"
|
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</VnLv>
|
</VnLv>
|
||||||
|
|
|
@ -1,11 +1,12 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from 'vue';
|
import { computed, ref } 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';
|
||||||
|
|
||||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||||
import VnConfirm from 'components/ui/VnConfirm.vue';
|
import VnConfirm from 'components/ui/VnConfirm.vue';
|
||||||
|
import FetchData from 'src/components/FetchData.vue';
|
||||||
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
|
@ -18,6 +19,8 @@ const router = useRouter();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
|
||||||
|
const warehouses = ref([]);
|
||||||
|
|
||||||
const thermographFilter = {
|
const thermographFilter = {
|
||||||
include: {
|
include: {
|
||||||
relation: 'warehouse',
|
relation: 'warehouse',
|
||||||
|
@ -54,6 +57,8 @@ const TableColumns = computed(() => {
|
||||||
field: 'warehouseFk',
|
field: 'warehouseFk',
|
||||||
name: 'destination',
|
name: 'destination',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
format: (val) =>
|
||||||
|
warehouses.value.find((warehouse) => warehouse.id === val).name,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('travel.thermographs.created'),
|
label: t('travel.thermographs.created'),
|
||||||
|
@ -95,10 +100,17 @@ const openRemoveDialog = async (id) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const redirectToThermographForm = (action) => {
|
const redirectToThermographForm = (action, { id = null }) => {
|
||||||
router.push({
|
const routeDetails = {
|
||||||
name: action === 'create' ? 'TravelThermographsCreate' : 'TravelThermographsEdit',
|
name: action === 'create' ? 'TravelThermographsCreate' : 'TravelThermographsEdit',
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if (action === 'edit' && id) {
|
||||||
|
const params = {};
|
||||||
|
params.thermographId = id;
|
||||||
|
routeDetails.params = params;
|
||||||
|
}
|
||||||
|
router.push(routeDetails);
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeThermograph = async (id) => {
|
const removeThermograph = async (id) => {
|
||||||
|
@ -107,6 +119,13 @@ const removeThermograph = async (id) => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
<FetchData
|
||||||
|
url="Warehouses"
|
||||||
|
:filter="{ fields: ['id', 'name'] }"
|
||||||
|
order="name"
|
||||||
|
@on-fetch="(data) => (warehouses = data)"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
data-key="TravelThermographs"
|
data-key="TravelThermographs"
|
||||||
url="TravelThermographs"
|
url="TravelThermographs"
|
||||||
|
@ -135,14 +154,14 @@ const removeThermograph = async (id) => {
|
||||||
</QIcon>
|
</QIcon>
|
||||||
</QTd>
|
</QTd>
|
||||||
</template>
|
</template>
|
||||||
<template #body-cell-editFile>
|
<template #body-cell-editFile="{ row }">
|
||||||
<QTd auto-width>
|
<QTd auto-width>
|
||||||
<QIcon
|
<QIcon
|
||||||
name="edit"
|
name="edit"
|
||||||
color="primary"
|
color="primary"
|
||||||
size="sm"
|
size="sm"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer"
|
||||||
@click="redirectToThermographForm('edit')"
|
@click="redirectToThermographForm('edit', row)"
|
||||||
>
|
>
|
||||||
<QTooltip>{{ t('Edit file') }}</QTooltip>
|
<QTooltip>{{ t('Edit file') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
|
|
|
@ -52,11 +52,13 @@ const thermographForm = reactive({
|
||||||
description: null,
|
description: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeMount(() => {
|
onBeforeMount(async () => {
|
||||||
getAllowedFileTypes();
|
await getAllowedFileTypes();
|
||||||
|
|
||||||
if (props.viewAction === 'create') {
|
if (props.viewAction === 'create') {
|
||||||
setCreateDefaultParams();
|
setCreateDefaultParams();
|
||||||
|
} else {
|
||||||
|
await setEditDefaultParams();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (route.query.thermographData) {
|
if (route.query.thermographData) {
|
||||||
|
@ -103,6 +105,30 @@ const setCreateDefaultParams = async () => {
|
||||||
}).toUpperCase();
|
}).toUpperCase();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const setEditDefaultParams = async () => {
|
||||||
|
try {
|
||||||
|
const filterObj = { include: { relation: 'dms' } };
|
||||||
|
const filter = encodeURIComponent(JSON.stringify(filterObj));
|
||||||
|
const { data } = await axios.get(
|
||||||
|
`TravelThermographs/${route.params.thermographId}?filter=${filter}`
|
||||||
|
);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
thermographForm.thermographId = data.thermographFk;
|
||||||
|
thermographForm.state = data.result;
|
||||||
|
thermographForm.reference = data.dms?.reference;
|
||||||
|
thermographForm.warehouseId = data.dms?.warehouseFk;
|
||||||
|
thermographForm.companyId = data.dms?.companyFk;
|
||||||
|
thermographForm.dmsTypeId = data.dms?.dmsTypeFk;
|
||||||
|
thermographForm.description = data.dms?.description || '';
|
||||||
|
thermographForm.hasFile = data.dms?.hasFile;
|
||||||
|
thermographForm.hasFileAttached = false;
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching termograph');
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = () => {
|
||||||
props.viewAction === 'create' ? createThermograph() : updateThermograph();
|
props.viewAction === 'create' ? createThermograph() : updateThermograph();
|
||||||
};
|
};
|
||||||
|
@ -128,8 +154,25 @@ const createThermograph = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateThermograph = () => {
|
const updateThermograph = async () => {
|
||||||
// `travels/${route.params.id}/updateThermograph`;
|
const formData = new FormData();
|
||||||
|
|
||||||
|
thermographForm.files.forEach((file) => {
|
||||||
|
formData.append(file.name, file);
|
||||||
|
});
|
||||||
|
|
||||||
|
try {
|
||||||
|
await axios.post(`travels/${route.params.id}/updateThermograph`, formData, {
|
||||||
|
params: thermographForm,
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
router.push({ name: 'TravelThermographsIndex' });
|
||||||
|
notify(t('Thermograph created'), 'positive');
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error creating thermograph');
|
||||||
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -197,6 +240,7 @@ const updateThermograph = () => {
|
||||||
:options="thermographsOptions"
|
:options="thermographsOptions"
|
||||||
option-value="thermographFk"
|
option-value="thermographFk"
|
||||||
option-label="thermographFk"
|
option-label="thermographFk"
|
||||||
|
:disable="viewAction === 'edit'"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
|
@ -243,6 +287,16 @@ const updateThermograph = () => {
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
<VnRow v-if="viewAction === 'edit'" class="row q-gutter-md q-mb-md">
|
||||||
|
<div class="col">
|
||||||
|
<QInput
|
||||||
|
:label="t('travel.thermographs.description')"
|
||||||
|
type="textarea"
|
||||||
|
v-model="thermographForm.description"
|
||||||
|
fill-input
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</VnRow>
|
||||||
<VnRow class="row q-gutter-md q-mb-md">
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<QFile
|
<QFile
|
||||||
|
|
|
@ -9,7 +9,7 @@ import FormModel from 'components/FormModel.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
|
||||||
import { toDate } from 'src/filters';
|
import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
@ -88,62 +88,13 @@ const redirectToTravelBasicData = (_, { id }) => {
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow class="row q-gutter-md q-mb-md">
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<QInput
|
<VnInputDate
|
||||||
rounded
|
v-model="data.shipped"
|
||||||
placeholder="dd-mm-aaa"
|
|
||||||
:label="t('globals.shipped')"
|
:label="t('globals.shipped')"
|
||||||
:model-value="toDate(data.shipped)"
|
|
||||||
>
|
|
||||||
<template #append>
|
|
||||||
<QIcon name="event" class="cursor-pointer">
|
|
||||||
<QPopupProxy
|
|
||||||
cover
|
|
||||||
transition-show="scale"
|
|
||||||
transition-hide="scale"
|
|
||||||
>
|
|
||||||
<QDate v-model="data.shipped">
|
|
||||||
<div class="row items-center justify-end">
|
|
||||||
<QBtn
|
|
||||||
v-close-popup
|
|
||||||
:label="t('globals.close')"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</QDate>
|
|
||||||
</QPopupProxy>
|
|
||||||
</QIcon>
|
|
||||||
</template>
|
|
||||||
</QInput>
|
|
||||||
</div>
|
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<QInput
|
<VnInputDate :label="t('globals.landed')" v-model="data.landed" />
|
||||||
rounded
|
|
||||||
placeholder="dd-mm-aaa"
|
|
||||||
:label="t('globals.landed')"
|
|
||||||
:model-value="toDate(data.landed)"
|
|
||||||
>
|
|
||||||
<template #append>
|
|
||||||
<QIcon name="event" class="cursor-pointer">
|
|
||||||
<QPopupProxy
|
|
||||||
cover
|
|
||||||
transition-show="scale"
|
|
||||||
transition-hide="scale"
|
|
||||||
>
|
|
||||||
<QDate v-model="data.landed">
|
|
||||||
<div class="row items-center justify-end">
|
|
||||||
<QBtn
|
|
||||||
v-close-popup
|
|
||||||
:label="t('globals.close')"
|
|
||||||
color="primary"
|
|
||||||
flat
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</QDate>
|
|
||||||
</QPopupProxy>
|
|
||||||
</QIcon>
|
|
||||||
</template>
|
|
||||||
</QInput>
|
|
||||||
</div>
|
</div>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow class="row q-gutter-md q-mb-md">
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
|
|
|
@ -83,7 +83,7 @@ export default {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: 'TravelThermographs',
|
name: 'TravelThermographs',
|
||||||
path: 'thermographs',
|
path: 'thermographs/:thermographId?',
|
||||||
meta: {
|
meta: {
|
||||||
title: 'thermographs',
|
title: 'thermographs',
|
||||||
icon: 'vn:thermometer',
|
icon: 'vn:thermometer',
|
||||||
|
|
Loading…
Reference in New Issue