Merge branch 'dev' into 8031_notify_dataSaved
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
gitea/salix-front/pipeline/pr-dev This commit looks good
Details
This commit is contained in:
commit
a0b3e933a8
|
@ -50,7 +50,7 @@ const onDataSaved = (dataSaved) => {
|
||||||
model="thermograph"
|
model="thermograph"
|
||||||
:title="t('New thermograph')"
|
:title="t('New thermograph')"
|
||||||
:form-initial-data="thermographFormData"
|
:form-initial-data="thermographFormData"
|
||||||
@on-data-saved="onDataSaved($event)"
|
@on-data-saved="(_, response) => onDataSaved(response)"
|
||||||
>
|
>
|
||||||
<template #form-inputs="{ data, validate }">
|
<template #form-inputs="{ data, validate }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
import { useRole } from 'src/composables/useRole';
|
import { useRole } from 'src/composables/useRole';
|
||||||
import { useAcl } from 'src/composables/useAcl';
|
import { useAcl } from 'src/composables/useAcl';
|
||||||
|
|
||||||
|
|
|
@ -288,6 +288,8 @@ globals:
|
||||||
createInvoiceIn: Create invoice in
|
createInvoiceIn: Create invoice in
|
||||||
myAccount: My account
|
myAccount: My account
|
||||||
noOne: No one
|
noOne: No one
|
||||||
|
maxTemperature: Maximum Temperature
|
||||||
|
minTemperature: Minimum Temperatura
|
||||||
params:
|
params:
|
||||||
clientFk: Client id
|
clientFk: Client id
|
||||||
salesPersonFk: Sales person
|
salesPersonFk: Sales person
|
||||||
|
|
|
@ -292,6 +292,8 @@ globals:
|
||||||
createInvoiceIn: Crear factura recibida
|
createInvoiceIn: Crear factura recibida
|
||||||
myAccount: Mi cuenta
|
myAccount: Mi cuenta
|
||||||
noOne: Nadie
|
noOne: Nadie
|
||||||
|
maxTemperature: Temperatura máxima
|
||||||
|
minTemperature: Temperatura mínima
|
||||||
params:
|
params:
|
||||||
clientFk: Id cliente
|
clientFk: Id cliente
|
||||||
salesPersonFk: Comercial
|
salesPersonFk: Comercial
|
||||||
|
|
|
@ -47,6 +47,18 @@ const TableColumns = computed(() => {
|
||||||
name: 'temperatureFk',
|
name: 'temperatureFk',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
label: t('globals.maxTemperature'),
|
||||||
|
field: 'maxTemperature',
|
||||||
|
name: 'maxTemperature',
|
||||||
|
align: 'left',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t('globals.minTemperature'),
|
||||||
|
field: 'minTemperature',
|
||||||
|
name: 'minTemperature',
|
||||||
|
align: 'left',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: t('travel.thermographs.state'),
|
label: t('travel.thermographs.state'),
|
||||||
field: 'result',
|
field: 'result',
|
||||||
|
@ -92,11 +104,7 @@ const openRemoveDialog = async (id) => {
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
.onOk(async () => {
|
.onOk(async () => {
|
||||||
try {
|
await removeThermograph(id);
|
||||||
await removeThermograph(id);
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error removing thermograph');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -106,9 +114,7 @@ const redirectToThermographForm = (action, id) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
if (action === 'edit' && id) {
|
if (action === 'edit' && id) {
|
||||||
const params = {};
|
routeDetails.query = { travelThermographFk: id };
|
||||||
params.thermographId = id;
|
|
||||||
routeDetails.params = params;
|
|
||||||
}
|
}
|
||||||
router.push(routeDetails);
|
router.push(routeDetails);
|
||||||
};
|
};
|
||||||
|
@ -213,4 +219,6 @@ es:
|
||||||
Thermograph removed: Termógrafo eliminado
|
Thermograph removed: Termógrafo eliminado
|
||||||
Are you sure you want to remove the thermograph?: ¿Seguro que quieres quitar el termógrafo?
|
Are you sure you want to remove the thermograph?: ¿Seguro que quieres quitar el termógrafo?
|
||||||
No results: Sin resultados
|
No results: Sin resultados
|
||||||
|
Max Temperature: Temperatura máxima
|
||||||
|
Min Temperature: Temperatura mínima
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { reactive, ref, onBeforeMount } from 'vue';
|
import { ref, onBeforeMount } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
|
@ -14,6 +14,7 @@ import { useState } from 'src/composables/useState';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
|
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
viewAction: {
|
viewAction: {
|
||||||
|
@ -28,24 +29,26 @@ const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const state = useState();
|
const state = useState();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
|
|
||||||
|
const thermographFilter = {
|
||||||
|
fields: ['id', 'thermographFk'],
|
||||||
|
where: {
|
||||||
|
or: [{ travelFk: null }, { travelFk: route.params.id }],
|
||||||
|
},
|
||||||
|
order: 'thermographFk ASC',
|
||||||
|
};
|
||||||
|
|
||||||
|
const fetchTravelThermographsRef = ref(null);
|
||||||
const allowedContentTypes = ref('');
|
const allowedContentTypes = ref('');
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
|
const thermographsOptions = ref([]);
|
||||||
const dmsTypesOptions = ref([]);
|
const dmsTypesOptions = ref([]);
|
||||||
const companiesOptions = ref([]);
|
const companiesOptions = ref([]);
|
||||||
const warehousesOptions = ref([]);
|
const warehousesOptions = ref([]);
|
||||||
|
const temperaturesOptions = ref([]);
|
||||||
|
const thermographForm = ref({});
|
||||||
const inputFileRef = ref(null);
|
const inputFileRef = ref(null);
|
||||||
|
|
||||||
const thermographForm = reactive({
|
|
||||||
thermographId: null,
|
|
||||||
state: null,
|
|
||||||
reference: null,
|
|
||||||
dmsTypeId: null,
|
|
||||||
companyId: null,
|
|
||||||
warehouseId: null,
|
|
||||||
files: [],
|
|
||||||
description: null,
|
|
||||||
});
|
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
if (props.viewAction === 'create') {
|
if (props.viewAction === 'create') {
|
||||||
setCreateDefaultParams();
|
setCreateDefaultParams();
|
||||||
|
@ -65,7 +68,7 @@ const fetchDmsTypes = async () => {
|
||||||
try {
|
try {
|
||||||
const params = {
|
const params = {
|
||||||
filter: {
|
filter: {
|
||||||
where: { code: 'miscellaneous' },
|
where: { code: 'thermograph' },
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
const { data } = await axios.get('DmsTypes/findOne', { params });
|
const { data } = await axios.get('DmsTypes/findOne', { params });
|
||||||
|
@ -77,88 +80,67 @@ const fetchDmsTypes = async () => {
|
||||||
|
|
||||||
const setCreateDefaultParams = async () => {
|
const setCreateDefaultParams = async () => {
|
||||||
const dataResponse = await fetchDmsTypes();
|
const dataResponse = await fetchDmsTypes();
|
||||||
thermographForm.companyId = user.value.companyFk;
|
thermographForm.value.companyId = user.value.companyFk;
|
||||||
thermographForm.warehouseId = user.value.warehouseFk;
|
thermographForm.value.warehouseId = user.value.warehouseFk;
|
||||||
thermographForm.reference = route.params.id;
|
thermographForm.value.reference = route.params.id;
|
||||||
thermographForm.dmsTypeId = dataResponse.id;
|
thermographForm.value.dmsTypeId = dataResponse.id;
|
||||||
thermographForm.state = 'Ok';
|
thermographForm.value.state = 'Ok';
|
||||||
thermographForm.description = t('travel.thermographs.travelFileDescription', {
|
thermographForm.value.description = t('travel.thermographs.travelFileDescription', {
|
||||||
travelId: route.params.id,
|
travelId: route.params.id,
|
||||||
}).toUpperCase();
|
}).toUpperCase();
|
||||||
};
|
};
|
||||||
|
|
||||||
const setEditDefaultParams = async () => {
|
const setEditDefaultParams = async () => {
|
||||||
try {
|
const filterObj = { include: { relation: 'dms' } };
|
||||||
const filterObj = { include: { relation: 'dms' } };
|
const filter = encodeURIComponent(JSON.stringify(filterObj));
|
||||||
const filter = encodeURIComponent(JSON.stringify(filterObj));
|
const { data } = await axios.get(
|
||||||
const { data } = await axios.get(
|
`TravelThermographs/${route.query.travelThermographFk}?filter=${filter}`
|
||||||
`TravelThermographs/${route.params.thermographId}?filter=${filter}`
|
);
|
||||||
);
|
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
thermographForm.thermographId = data.thermographFk;
|
thermographForm.value.thermographFk = data.thermographFk;
|
||||||
thermographForm.state = data.result;
|
thermographForm.value.state = data.result;
|
||||||
thermographForm.reference = data.dms?.reference;
|
thermographForm.value.reference = data.dms?.reference;
|
||||||
thermographForm.warehouseId = data.dms?.warehouseFk;
|
thermographForm.value.warehouseId = data.dms?.warehouseFk;
|
||||||
thermographForm.companyId = data.dms?.companyFk;
|
thermographForm.value.companyId = data.dms?.companyFk;
|
||||||
thermographForm.dmsTypeId = data.dms?.dmsTypeFk;
|
thermographForm.value.dmsTypeId = data.dms?.dmsTypeFk;
|
||||||
thermographForm.description = data.dms?.description || '';
|
thermographForm.value.description = data.dms?.description || '';
|
||||||
thermographForm.hasFile = data.dms?.hasFile;
|
thermographForm.value.hasFile = data.dms?.hasFile;
|
||||||
thermographForm.hasFileAttached = false;
|
thermographForm.value.hasFileAttached = false;
|
||||||
}
|
thermographForm.value.maxTemperature = data.maxTemperature;
|
||||||
} catch (err) {
|
thermographForm.value.minTemperature = data.minTemperature;
|
||||||
console.error('Error fetching termograph');
|
thermographForm.value.temperatureFk = data.temperatureFk;
|
||||||
|
thermographForm.value.travelThermographFk = data.id;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onSubmit = () => {
|
const onSubmit = async () => {
|
||||||
props.viewAction === 'create' ? createThermograph() : updateThermograph();
|
|
||||||
};
|
|
||||||
|
|
||||||
const createThermograph = async () => {
|
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
|
if (Array.isArray(thermographForm.value.files)) {
|
||||||
thermographForm.files.forEach((file) => {
|
thermographForm.value.hasFileAttached = true;
|
||||||
formData.append(file.name, file);
|
thermographForm.value.files.forEach((file) => {
|
||||||
});
|
formData.append(file.name, file);
|
||||||
|
|
||||||
try {
|
|
||||||
await axios.post(`/travels/${route.params.id}/createThermograph`, 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');
|
|
||||||
}
|
}
|
||||||
};
|
delete thermographForm.value.files;
|
||||||
|
await axios.post(`/travels/${route.params.id}/saveThermograph`, formData, {
|
||||||
const updateThermograph = async () => {
|
params: thermographForm.value,
|
||||||
const formData = new FormData();
|
headers: {
|
||||||
|
'Content-Type': 'multipart/form-data',
|
||||||
thermographForm.files.forEach((file) => {
|
},
|
||||||
formData.append(file.name, file);
|
|
||||||
});
|
});
|
||||||
|
router.push({ name: 'TravelThermographsIndex' });
|
||||||
try {
|
notify(t('Thermograph created'), 'positive');
|
||||||
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');
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onThermographCreated = async (data) => {
|
const onThermographCreated = async (data) => {
|
||||||
thermographForm.thermographId = data.id;
|
await fetchTravelThermographsRef.value.fetch();
|
||||||
|
thermographForm.value = {
|
||||||
|
...thermographForm.value,
|
||||||
|
...data,
|
||||||
|
travelThermographFk: data.id,
|
||||||
|
warehouseId: data.warehouseFk,
|
||||||
|
};
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
|
@ -185,6 +167,18 @@ const onThermographCreated = async (data) => {
|
||||||
:filter="{ order: 'name' }"
|
:filter="{ order: 'name' }"
|
||||||
auto-load
|
auto-load
|
||||||
/>
|
/>
|
||||||
|
<FetchData
|
||||||
|
@on-fetch="(data) => (temperaturesOptions = data)"
|
||||||
|
auto-load
|
||||||
|
url="Temperatures"
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
ref="fetchTravelThermographsRef"
|
||||||
|
url="TravelThermographs"
|
||||||
|
@on-fetch="(data) => (thermographsOptions = data)"
|
||||||
|
:filter="thermographFilter"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
<QPage class="column items-center full-width">
|
<QPage class="column items-center full-width">
|
||||||
<QForm
|
<QForm
|
||||||
model="travel"
|
model="travel"
|
||||||
|
@ -219,21 +213,15 @@ const onThermographCreated = async (data) => {
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnSelectDialog
|
<VnSelectDialog
|
||||||
:label="t('travel.thermographs.thermograph')"
|
:label="t('travel.thermographs.thermograph')"
|
||||||
v-model="thermographForm.thermographId"
|
v-model="thermographForm.travelThermographFk"
|
||||||
url="TravelThermographs"
|
:options="thermographsOptions"
|
||||||
option-value="thermographFk"
|
|
||||||
option-label="thermographFk"
|
option-label="thermographFk"
|
||||||
:fields="['thermographFk']"
|
|
||||||
:where="{ travelFk: null }"
|
|
||||||
sort-by="thermographFk ASC"
|
|
||||||
:disable="viewAction === 'edit'"
|
:disable="viewAction === 'edit'"
|
||||||
:tooltip="t('New thermograph')"
|
:tooltip="t('New thermograph')"
|
||||||
>
|
>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CreateThermographForm
|
<CreateThermographForm
|
||||||
@on-data-saved="
|
@on-data-saved="onThermographCreated"
|
||||||
(data) => (thermographForm.thermographId = data.id)
|
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
</VnSelectDialog>
|
</VnSelectDialog>
|
||||||
|
@ -271,6 +259,26 @@ const onThermographCreated = async (data) => {
|
||||||
option-label="name"
|
option-label="name"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
<VnRow>
|
||||||
|
<VnSelect
|
||||||
|
:label="t('travel.thermographs.temperature')"
|
||||||
|
:options="temperaturesOptions"
|
||||||
|
hide-selected
|
||||||
|
option-label="name"
|
||||||
|
option-value="code"
|
||||||
|
v-model="thermographForm.temperatureFk"
|
||||||
|
:required="true"
|
||||||
|
/>
|
||||||
|
<VnInputNumber
|
||||||
|
v-model="thermographForm.maxTemperature"
|
||||||
|
:label="t('globals.maxTemperature')"
|
||||||
|
/>
|
||||||
|
<VnInputNumber
|
||||||
|
v-model="thermographForm.minTemperature"
|
||||||
|
:label="t('globals.minTemperature')"
|
||||||
|
/>
|
||||||
|
</VnRow>
|
||||||
|
|
||||||
<VnRow v-if="viewAction === 'edit'" class="row q-gutter-md q-mb-md">
|
<VnRow v-if="viewAction === 'edit'" class="row q-gutter-md q-mb-md">
|
||||||
<QInput
|
<QInput
|
||||||
:label="t('globals.description')"
|
:label="t('globals.description')"
|
||||||
|
@ -310,8 +318,8 @@ const onThermographCreated = async (data) => {
|
||||||
</QPage>
|
</QPage>
|
||||||
</template>
|
</template>
|
||||||
<i18n>
|
<i18n>
|
||||||
es:
|
es:
|
||||||
Select files: Selecciona ficheros
|
Select files: Selecciona ficheros
|
||||||
Thermograph created: Termógrafo creado
|
Thermograph created: Termógrafo creado
|
||||||
New thermograph: Nuevo termógrafo
|
New thermograph: Nuevo termógrafo
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
Loading…
Reference in New Issue