Merge branch '7010-AddPackingField' of https://gitea.verdnatura.es/verdnatura/salix-front into 7010-AddPackingField
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
9386d648d0
|
@ -21,7 +21,7 @@ const customer = computed(() => state.get('customer'));
|
||||||
const bankEntityFormData = reactive({
|
const bankEntityFormData = reactive({
|
||||||
name: null,
|
name: null,
|
||||||
bic: null,
|
bic: null,
|
||||||
countryFk: customer.value.countryFk,
|
countryFk: customer.value?.countryFk,
|
||||||
id: null,
|
id: null,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -10,8 +10,6 @@ import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
import VnInputTime from 'components/common/VnInputTime.vue';
|
import VnInputTime from 'components/common/VnInputTime.vue';
|
||||||
import VnTableColumn from 'components/VnTable/VnColumn.vue';
|
import VnTableColumn from 'components/VnTable/VnColumn.vue';
|
||||||
|
|
||||||
defineExpose({ addFilter });
|
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
column: {
|
column: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
@ -30,6 +28,9 @@ const $props = defineProps({
|
||||||
default: 'params',
|
default: 'params',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
defineExpose({ addFilter, props: $props });
|
||||||
|
|
||||||
const model = defineModel(undefined, { required: true });
|
const model = defineModel(undefined, { required: true });
|
||||||
const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl });
|
const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl });
|
||||||
const columnFilter = computed(() => $props.column?.columnFilter);
|
const columnFilter = computed(() => $props.column?.columnFilter);
|
||||||
|
@ -115,11 +116,11 @@ const components = {
|
||||||
rawSelect: selectComponent,
|
rawSelect: selectComponent,
|
||||||
};
|
};
|
||||||
|
|
||||||
async function addFilter(value) {
|
async function addFilter(value, name) {
|
||||||
value ??= undefined;
|
value ??= undefined;
|
||||||
if (value && typeof value === 'object') value = model.value;
|
if (value && typeof value === 'object') value = model.value;
|
||||||
value = value === '' ? undefined : value;
|
value = value === '' ? undefined : value;
|
||||||
let field = columnFilter.value?.name ?? $props.column.name;
|
let field = columnFilter.value?.name ?? $props.column.name ?? name;
|
||||||
|
|
||||||
if (columnFilter.value?.inWhere) {
|
if (columnFilter.value?.inWhere) {
|
||||||
if (columnFilter.value.alias) field = columnFilter.value.alias + '.' + field;
|
if (columnFilter.value.alias) field = columnFilter.value.alias + '.' + field;
|
||||||
|
|
|
@ -102,6 +102,10 @@ const $props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: '90vh',
|
default: '90vh',
|
||||||
},
|
},
|
||||||
|
chipLocale: {
|
||||||
|
type: String,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
footer: {
|
footer: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
@ -130,6 +134,7 @@ const showForm = ref(false);
|
||||||
const splittedColumns = ref({ columns: [] });
|
const splittedColumns = ref({ columns: [] });
|
||||||
const columnsVisibilitySkipped = ref();
|
const columnsVisibilitySkipped = ref();
|
||||||
const createForm = ref();
|
const createForm = ref();
|
||||||
|
const tableFilterRef = ref([]);
|
||||||
|
|
||||||
const tableModes = [
|
const tableModes = [
|
||||||
{
|
{
|
||||||
|
@ -232,7 +237,7 @@ function splitColumns(columns) {
|
||||||
if (col.cardVisible) splittedColumns.value.cardVisible.push(col);
|
if (col.cardVisible) splittedColumns.value.cardVisible.push(col);
|
||||||
if ($props.isEditable && col.disable == null) col.disable = false;
|
if ($props.isEditable && col.disable == null) col.disable = false;
|
||||||
if ($props.useModel && col.columnFilter != false)
|
if ($props.useModel && col.columnFilter != false)
|
||||||
col.columnFilter = { ...col.columnFilter, inWhere: true };
|
col.columnFilter = { inWhere: true, ...col.columnFilter };
|
||||||
splittedColumns.value.columns.push(col);
|
splittedColumns.value.columns.push(col);
|
||||||
}
|
}
|
||||||
// Status column
|
// Status column
|
||||||
|
@ -334,6 +339,13 @@ function handleOnDataSaved(_) {
|
||||||
:search-url="searchUrl"
|
:search-url="searchUrl"
|
||||||
:redirect="!!redirect"
|
:redirect="!!redirect"
|
||||||
@set-user-params="setUserParams"
|
@set-user-params="setUserParams"
|
||||||
|
:disable-submit-event="true"
|
||||||
|
@remove="
|
||||||
|
(key) =>
|
||||||
|
tableFilterRef
|
||||||
|
.find((f) => f.props?.column.name == key)
|
||||||
|
?.addFilter()
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<template #body>
|
<template #body>
|
||||||
<div
|
<div
|
||||||
|
@ -344,6 +356,7 @@ function handleOnDataSaved(_) {
|
||||||
:key="col.id"
|
:key="col.id"
|
||||||
>
|
>
|
||||||
<VnTableFilter
|
<VnTableFilter
|
||||||
|
ref="tableFilterRef"
|
||||||
:column="col"
|
:column="col"
|
||||||
:data-key="$attrs['data-key']"
|
:data-key="$attrs['data-key']"
|
||||||
v-model="params[columnName(col)]"
|
v-model="params[columnName(col)]"
|
||||||
|
@ -367,10 +380,15 @@ function handleOnDataSaved(_) {
|
||||||
:columns="splittedColumns.columns"
|
:columns="splittedColumns.columns"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
<template #tags="{ tag, formatFn }" v-if="chipLocale">
|
||||||
|
<div class="q-gutter-x-xs">
|
||||||
|
<strong>{{ t(`${chipLocale}.${tag.label}`) }}: </strong>
|
||||||
|
<span>{{ formatFn(tag.value) }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</VnFilterPanel>
|
</VnFilterPanel>
|
||||||
</QScrollArea>
|
</QScrollArea>
|
||||||
</QDrawer>
|
</QDrawer>
|
||||||
<!-- class in div to fix warn-->
|
|
||||||
<CrudModel
|
<CrudModel
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
:class="$attrs['class'] ?? 'q-px-md'"
|
:class="$attrs['class'] ?? 'q-px-md'"
|
||||||
|
|
|
@ -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';
|
||||||
|
|
||||||
|
|
|
@ -114,9 +114,9 @@ watch(
|
||||||
);
|
);
|
||||||
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
async function search(evt) {
|
async function search() {
|
||||||
try {
|
try {
|
||||||
if (evt && $props.disableSubmitEvent) return;
|
if ($props.disableSubmitEvent) return;
|
||||||
|
|
||||||
store.filter.where = {};
|
store.filter.where = {};
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
|
@ -167,7 +167,7 @@ const tagsList = computed(() => {
|
||||||
for (const key of Object.keys(userParams.value)) {
|
for (const key of Object.keys(userParams.value)) {
|
||||||
const value = userParams.value[key];
|
const value = userParams.value[key];
|
||||||
if (value == null || ($props.hiddenTags || []).includes(key)) continue;
|
if (value == null || ($props.hiddenTags || []).includes(key)) continue;
|
||||||
tagList.push({ label: key, value });
|
tagList.push({ label: aliasField(key), value });
|
||||||
}
|
}
|
||||||
return tagList;
|
return tagList;
|
||||||
});
|
});
|
||||||
|
@ -203,6 +203,11 @@ function sanitizer(params) {
|
||||||
}
|
}
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function aliasField(field) {
|
||||||
|
const split = field.split('.');
|
||||||
|
return split[1] ?? split[0];
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -119,10 +119,9 @@ watch(
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [props.url, props.filter, props.userParams],
|
() => [props.url, props.filter],
|
||||||
([url, filter, userParams]) => mounted.value && fetch({ url, filter, userParams })
|
([url, filter]) => mounted.value && fetch({ url, filter })
|
||||||
);
|
);
|
||||||
|
|
||||||
const addFilter = async (filter, params) => {
|
const addFilter = async (filter, params) => {
|
||||||
await arrayData.addFilter({ filter, params });
|
await arrayData.addFilter({ filter, params });
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,7 +26,8 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
const params = JSON.parse(query[searchUrl]);
|
const params = JSON.parse(query[searchUrl]);
|
||||||
const filter = params?.filter && JSON.parse(params?.filter ?? '{}');
|
const filter = params?.filter && JSON.parse(params?.filter ?? '{}');
|
||||||
delete params.filter;
|
delete params.filter;
|
||||||
store.userParams = { ...params, ...store.userParams };
|
|
||||||
|
store.userParams = { ...store.userParams, ...params };
|
||||||
store.userFilter = { ...filter, ...store.userFilter };
|
store.userFilter = { ...filter, ...store.userFilter };
|
||||||
if (filter?.order) store.order = filter.order;
|
if (filter?.order) store.order = filter.order;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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
|
||||||
|
@ -1007,6 +1009,7 @@ travel:
|
||||||
warehouseOut: Warehouse out
|
warehouseOut: Warehouse out
|
||||||
totalEntries: Total entries
|
totalEntries: Total entries
|
||||||
totalEntriesTooltip: Total entries
|
totalEntriesTooltip: Total entries
|
||||||
|
daysOnward: Landed days onwards
|
||||||
summary:
|
summary:
|
||||||
confirmed: Confirmed
|
confirmed: Confirmed
|
||||||
entryId: Entry Id
|
entryId: Entry Id
|
||||||
|
|
|
@ -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
|
||||||
|
@ -992,6 +994,7 @@ travel:
|
||||||
warehouseOut: Alm.entrada
|
warehouseOut: Alm.entrada
|
||||||
totalEntries: ∑
|
totalEntries: ∑
|
||||||
totalEntriesTooltip: Entradas totales
|
totalEntriesTooltip: Entradas totales
|
||||||
|
daysOnward: Días de llegada en adelante
|
||||||
summary:
|
summary:
|
||||||
confirmed: Confirmado
|
confirmed: Confirmado
|
||||||
entryId: Id entrada
|
entryId: Id entrada
|
||||||
|
|
|
@ -113,6 +113,7 @@ const setWireTransfer = async () => {
|
||||||
option-label="bic"
|
option-label="bic"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
hide-selected
|
hide-selected
|
||||||
|
:roles-allowed-to-create="['financial']"
|
||||||
>
|
>
|
||||||
<template #form>
|
<template #form>
|
||||||
<CreateBankEntityForm
|
<CreateBankEntityForm
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref, computed } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter, useRoute } from 'vue-router';
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import VnTable from 'components/VnTable/VnTable.vue';
|
import VnTable from 'components/VnTable/VnTable.vue';
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
import { computed } from 'vue';
|
|
||||||
import TravelSummary from './Card/TravelSummary.vue';
|
import TravelSummary from './Card/TravelSummary.vue';
|
||||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||||
import { toDate } from 'src/filters';
|
import { toDate } from 'src/filters';
|
||||||
import { getDateQBadgeColor } from 'src/composables/getDateQBadgeColor.js';
|
import { getDateQBadgeColor } from 'src/composables/getDateQBadgeColor.js';
|
||||||
import { dateRange } from 'src/filters';
|
|
||||||
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
|
||||||
|
|
||||||
const { viewSummary } = useSummaryDialog();
|
const { viewSummary } = useSummaryDialog();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
@ -30,7 +26,6 @@ const entityId = computed(() => $props.id || route.params.id);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
stateStore.rightDrawer = true;
|
stateStore.rightDrawer = true;
|
||||||
handleScopeDays();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const cloneTravel = (travelData) => {
|
const cloneTravel = (travelData) => {
|
||||||
|
@ -38,16 +33,6 @@ const cloneTravel = (travelData) => {
|
||||||
redirectToCreateView(stringifiedTravelData);
|
redirectToCreateView(stringifiedTravelData);
|
||||||
};
|
};
|
||||||
|
|
||||||
function handleScopeDays(days = 7) {
|
|
||||||
days = +days;
|
|
||||||
tableRef.value.params.scopeDays = days;
|
|
||||||
const [landedFrom, landedTo] = dateRange(Date.vnNew());
|
|
||||||
landedTo.setDate(landedTo.getDate() + days);
|
|
||||||
|
|
||||||
tableRef.value.params.landedFrom = landedFrom;
|
|
||||||
tableRef.value.params.landedTo = landedTo;
|
|
||||||
}
|
|
||||||
|
|
||||||
const redirectToCreateView = (queryParams) => {
|
const redirectToCreateView = (queryParams) => {
|
||||||
router.push({ name: 'TravelCreate', query: { travelData: queryParams } });
|
router.push({ name: 'TravelCreate', query: { travelData: queryParams } });
|
||||||
};
|
};
|
||||||
|
@ -173,6 +158,15 @@ const columns = computed(() => [
|
||||||
cardVisible: true,
|
cardVisible: true,
|
||||||
create: true,
|
create: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
align: 'left',
|
||||||
|
name: 'daysOnward',
|
||||||
|
label: t('travel.travelList.tableVisibleColumns.daysOnward'),
|
||||||
|
visible: false,
|
||||||
|
columnFilter: {
|
||||||
|
inWhere: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
align: 'right',
|
align: 'right',
|
||||||
label: '',
|
label: '',
|
||||||
|
@ -219,12 +213,14 @@ const columns = computed(() => [
|
||||||
editorFk: entityId,
|
editorFk: entityId,
|
||||||
},
|
},
|
||||||
}"
|
}"
|
||||||
|
:user-params="{ daysOnward: 7 }"
|
||||||
order="landed DESC"
|
order="landed DESC"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
auto-load
|
auto-load
|
||||||
redirect="travel"
|
redirect="travel"
|
||||||
:is-editable="false"
|
:is-editable="false"
|
||||||
:use-model="true"
|
:use-model="true"
|
||||||
|
chip-locale="travel.travelList.tableVisibleColumns"
|
||||||
>
|
>
|
||||||
<template #column-shipped="{ row }">
|
<template #column-shipped="{ row }">
|
||||||
<QBadge
|
<QBadge
|
||||||
|
|
Loading…
Reference in New Issue