Thermograph create form and general improvements
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
gitea/salix-front/pipeline/pr-dev There was a failure building this commit
Details
This commit is contained in:
parent
f24b9f5a75
commit
c67f4cf858
|
@ -0,0 +1,113 @@
|
||||||
|
<script setup>
|
||||||
|
import { reactive, ref } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
|
import FetchData from 'components/FetchData.vue';
|
||||||
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
|
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
|
||||||
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
import FormModelPopup from './FormModelPopup.vue';
|
||||||
|
|
||||||
|
const emit = defineEmits(['onDataSaved']);
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
const thermographFormData = reactive({
|
||||||
|
thermographId: null,
|
||||||
|
model: 'DISPOSABLE',
|
||||||
|
warehouseId: null,
|
||||||
|
temperatureFk: 'cool',
|
||||||
|
});
|
||||||
|
|
||||||
|
const thermographsModels = ref(null);
|
||||||
|
const warehousesOptions = ref([]);
|
||||||
|
const temperaturesOptions = ref([]);
|
||||||
|
|
||||||
|
const onDataSaved = (dataSaved) => {
|
||||||
|
emit('onDataSaved', dataSaved);
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<FetchData
|
||||||
|
@on-fetch="(data) => (thermographsModels = data)"
|
||||||
|
auto-load
|
||||||
|
url="Thermographs/getThermographModels"
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
@on-fetch="(data) => (warehousesOptions = data)"
|
||||||
|
auto-load
|
||||||
|
url="Warehouses"
|
||||||
|
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
@on-fetch="(data) => (temperaturesOptions = data)"
|
||||||
|
auto-load
|
||||||
|
url="Temperatures"
|
||||||
|
/>
|
||||||
|
<FormModelPopup
|
||||||
|
url-create="Thermographs/createThermograph"
|
||||||
|
model="thermograph"
|
||||||
|
:title="t('New thermograph')"
|
||||||
|
:form-initial-data="thermographFormData"
|
||||||
|
@on-data-saved="onDataSaved($event)"
|
||||||
|
>
|
||||||
|
<template #form-inputs="{ data, validate }">
|
||||||
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
|
<div class="col">
|
||||||
|
<VnInput
|
||||||
|
:label="t('Identifier')"
|
||||||
|
v-model="data.thermographId"
|
||||||
|
:required="true"
|
||||||
|
:rules="validate('thermograph.id')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col">
|
||||||
|
<VnSelectFilter
|
||||||
|
:label="t('Model')"
|
||||||
|
:options="thermographsModels"
|
||||||
|
hide-selected
|
||||||
|
option-label="value"
|
||||||
|
option-value="value"
|
||||||
|
v-model="data.model"
|
||||||
|
:required="true"
|
||||||
|
:rules="validate('thermograph.model')"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</VnRow>
|
||||||
|
<VnRow class="row q-gutter-md q-mb-xl">
|
||||||
|
<div class="col">
|
||||||
|
<VnSelectFilter
|
||||||
|
:label="t('Warehouse')"
|
||||||
|
:options="warehousesOptions"
|
||||||
|
hide-selected
|
||||||
|
option-label="name"
|
||||||
|
option-value="id"
|
||||||
|
v-model="data.warehouseId"
|
||||||
|
:required="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<VnSelectFilter
|
||||||
|
:label="t('Temperature')"
|
||||||
|
:options="temperaturesOptions"
|
||||||
|
hide-selected
|
||||||
|
option-label="name"
|
||||||
|
option-value="code"
|
||||||
|
v-model="data.temperatureFk"
|
||||||
|
:required="true"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</VnRow>
|
||||||
|
</template>
|
||||||
|
</FormModelPopup>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<i18n>
|
||||||
|
es:
|
||||||
|
Identifier: Identificador
|
||||||
|
Model: Modelo
|
||||||
|
Warehouse: Almacén
|
||||||
|
Temperature: Temperatura
|
||||||
|
</i18n>
|
|
@ -276,13 +276,9 @@ const makeRequest = async () => {
|
||||||
</QIcon>
|
</QIcon>
|
||||||
<QIcon name="info" class="cursor-pointer">
|
<QIcon name="info" class="cursor-pointer">
|
||||||
<QTooltip>{{
|
<QTooltip>{{
|
||||||
t(
|
t('globals.allowedFilesText', {
|
||||||
'components.editPictureForm.allowedFilesText',
|
allowedContentTypes: allowedContentTypes,
|
||||||
{
|
})
|
||||||
allowedContentTypes:
|
|
||||||
allowedContentTypes,
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}}</QTooltip>
|
}}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed } from 'vue';
|
import { computed } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
|
||||||
const emit = defineEmits(['update:modelValue', 'update:options', 'keyup.enter']);
|
const emit = defineEmits(['update:modelValue', 'update:options', 'keyup.enter']);
|
||||||
|
|
||||||
|
@ -14,6 +15,9 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const requiredFieldRule = (val) => !!val || t('globals.fieldRequired');
|
||||||
|
|
||||||
const value = computed({
|
const value = computed({
|
||||||
get() {
|
get() {
|
||||||
return $props.modelValue;
|
return $props.modelValue;
|
||||||
|
@ -46,6 +50,7 @@ const onEnterPress = () => {
|
||||||
type="text"
|
type="text"
|
||||||
:class="{ required: $attrs.required }"
|
:class="{ required: $attrs.required }"
|
||||||
@keyup.enter="onEnterPress()"
|
@keyup.enter="onEnterPress()"
|
||||||
|
:rules="$attrs.required ? [requiredFieldRule] : null"
|
||||||
>
|
>
|
||||||
<template v-if="$slots.prepend" #prepend>
|
<template v-if="$slots.prepend" #prepend>
|
||||||
<slot name="prepend" />
|
<slot name="prepend" />
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import FetchData from 'src/components/FetchData.vue';
|
|
||||||
import { onMounted } from 'vue';
|
|
||||||
import { ref, toRefs, computed, watch } from 'vue';
|
import { ref, toRefs, computed, watch } from 'vue';
|
||||||
|
import { onMounted } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import FetchData from 'src/components/FetchData.vue';
|
||||||
const emit = defineEmits(['update:modelValue', 'update:options']);
|
const emit = defineEmits(['update:modelValue', 'update:options']);
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
@ -55,6 +56,9 @@ const $props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const requiredFieldRule = (val) => !!val || t('globals.fieldRequired');
|
||||||
|
|
||||||
const { optionLabel, optionValue, options, modelValue } = toRefs($props);
|
const { optionLabel, optionValue, options, modelValue } = toRefs($props);
|
||||||
const myOptions = ref([]);
|
const myOptions = ref([]);
|
||||||
const myOptionsOriginal = ref([]);
|
const myOptionsOriginal = ref([]);
|
||||||
|
@ -164,6 +168,7 @@ watch(modelValue, (newValue) => {
|
||||||
fill-input
|
fill-input
|
||||||
ref="vnSelectRef"
|
ref="vnSelectRef"
|
||||||
:class="{ required: $attrs.required }"
|
:class="{ required: $attrs.required }"
|
||||||
|
:rules="$attrs.required ? [requiredFieldRule] : null"
|
||||||
>
|
>
|
||||||
<template v-if="isClearable" #append>
|
<template v-if="isClearable" #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
|
|
|
@ -64,6 +64,8 @@ export default {
|
||||||
markAll: 'Mark all',
|
markAll: 'Mark all',
|
||||||
noResults: 'No results',
|
noResults: 'No results',
|
||||||
system: 'System',
|
system: 'System',
|
||||||
|
fieldRequired: 'Field required',
|
||||||
|
allowedFilesText: 'Allowed file types: { allowedContentTypes }',
|
||||||
},
|
},
|
||||||
errors: {
|
errors: {
|
||||||
statusUnauthorized: 'Access denied',
|
statusUnauthorized: 'Access denied',
|
||||||
|
@ -1173,9 +1175,6 @@ export default {
|
||||||
addToPinned: 'Add to pinned',
|
addToPinned: 'Add to pinned',
|
||||||
removeFromPinned: 'Remove from pinned',
|
removeFromPinned: 'Remove from pinned',
|
||||||
},
|
},
|
||||||
editPictureForm: {
|
|
||||||
allowedFilesText: 'Allowed file types: { allowedContentTypes }',
|
|
||||||
},
|
|
||||||
VnLv: {
|
VnLv: {
|
||||||
copyText: '{copyValue} has been copied to the clipboard',
|
copyText: '{copyValue} has been copied to the clipboard',
|
||||||
},
|
},
|
||||||
|
|
|
@ -64,6 +64,8 @@ export default {
|
||||||
markAll: 'Marcar todo',
|
markAll: 'Marcar todo',
|
||||||
noResults: 'Sin resultados',
|
noResults: 'Sin resultados',
|
||||||
system: 'Sistema',
|
system: 'Sistema',
|
||||||
|
fieldRequired: 'Campo requerido',
|
||||||
|
allowedFilesText: 'Tipos de archivo permitidos: { allowedContentTypes }',
|
||||||
},
|
},
|
||||||
errors: {
|
errors: {
|
||||||
statusUnauthorized: 'Acceso denegado',
|
statusUnauthorized: 'Acceso denegado',
|
||||||
|
@ -1173,9 +1175,6 @@ export default {
|
||||||
addToPinned: 'Añadir a fijados',
|
addToPinned: 'Añadir a fijados',
|
||||||
removeFromPinned: 'Eliminar de fijados',
|
removeFromPinned: 'Eliminar de fijados',
|
||||||
},
|
},
|
||||||
editPictureForm: {
|
|
||||||
allowedFilesText: 'Tipos de archivo permitidos: { allowedContentTypes }',
|
|
||||||
},
|
|
||||||
VnLv: {
|
VnLv: {
|
||||||
copyText: '{copyValue} se ha copiado al portapepeles',
|
copyText: '{copyValue} se ha copiado al portapepeles',
|
||||||
},
|
},
|
||||||
|
|
|
@ -5,8 +5,10 @@ import { useRoute, useRouter } from 'vue-router';
|
||||||
|
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
|
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
|
||||||
|
import VnSelectDialog from 'components/common/VnSelectDialog.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 CreateThermographForm from 'src/components/CreateThermographForm.vue';
|
||||||
|
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
|
@ -34,8 +36,9 @@ const thermographFilter = {
|
||||||
},
|
},
|
||||||
order: 'thermographFk ASC',
|
order: 'thermographFk ASC',
|
||||||
};
|
};
|
||||||
|
const fetchTravelThermographsRef = ref(null);
|
||||||
|
const allowedContentTypes = ref('');
|
||||||
const user = state.getUser();
|
const user = state.getUser();
|
||||||
const allowedFileTypes = ref(null);
|
|
||||||
const thermographsOptions = ref([]);
|
const thermographsOptions = ref([]);
|
||||||
const dmsTypesOptions = ref([]);
|
const dmsTypesOptions = ref([]);
|
||||||
const companiesOptions = ref([]);
|
const companiesOptions = ref([]);
|
||||||
|
@ -54,8 +57,6 @@ const thermographForm = reactive({
|
||||||
});
|
});
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
await getAllowedFileTypes();
|
|
||||||
|
|
||||||
if (props.viewAction === 'create') {
|
if (props.viewAction === 'create') {
|
||||||
setCreateDefaultParams();
|
setCreateDefaultParams();
|
||||||
} else {
|
} else {
|
||||||
|
@ -70,16 +71,6 @@ onBeforeMount(async () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const getAllowedFileTypes = async () => {
|
|
||||||
try {
|
|
||||||
const { data } = await axios.get('DmsContainers/allowedContentTypes');
|
|
||||||
const contentTypes = data.join(', ');
|
|
||||||
allowedFileTypes.value = contentTypes;
|
|
||||||
} catch (err) {
|
|
||||||
console.error('Error fetching allowed content types');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
const fetchDmsTypes = async () => {
|
const fetchDmsTypes = async () => {
|
||||||
try {
|
try {
|
||||||
const params = {
|
const params = {
|
||||||
|
@ -175,10 +166,21 @@ const updateThermograph = async () => {
|
||||||
console.error('Error creating thermograph');
|
console.error('Error creating thermograph');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const onThermographCreated = async (data) => {
|
||||||
|
await fetchTravelThermographsRef.value.fetch();
|
||||||
|
thermographForm.thermographId = data.thermographId;
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
url="DmsContainers/allowedContentTypes"
|
||||||
|
@on-fetch="(data) => (allowedContentTypes = data.join(', '))"
|
||||||
|
auto-load
|
||||||
|
/>
|
||||||
|
<FetchData
|
||||||
|
ref="fetchTravelThermographsRef"
|
||||||
url="TravelThermographs"
|
url="TravelThermographs"
|
||||||
@on-fetch="(data) => (thermographsOptions = data)"
|
@on-fetch="(data) => (thermographsOptions = data)"
|
||||||
:filter="thermographFilter"
|
:filter="thermographFilter"
|
||||||
|
@ -235,14 +237,20 @@ const updateThermograph = async () => {
|
||||||
<QCard class="q-pa-lg">
|
<QCard class="q-pa-lg">
|
||||||
<VnRow class="row q-gutter-md q-mb-md">
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<VnSelectFilter
|
<VnSelectDialog
|
||||||
:label="t('travel.thermographs.thermograph')"
|
:label="t('travel.thermographs.thermograph')"
|
||||||
v-model="thermographForm.thermographId"
|
v-model="thermographForm.thermographId"
|
||||||
:options="thermographsOptions"
|
:options="thermographsOptions"
|
||||||
option-value="thermographFk"
|
option-value="thermographFk"
|
||||||
option-label="thermographFk"
|
option-label="thermographFk"
|
||||||
:disable="viewAction === 'edit'"
|
:disable="viewAction === 'edit'"
|
||||||
|
>
|
||||||
|
<template #form>
|
||||||
|
<CreateThermographForm
|
||||||
|
@on-data-saved="onThermographCreated($event, data)"
|
||||||
/>
|
/>
|
||||||
|
</template>
|
||||||
|
</VnSelectDialog>
|
||||||
</div>
|
</div>
|
||||||
<div class="col">
|
<div class="col">
|
||||||
<VnInput
|
<VnInput
|
||||||
|
@ -304,17 +312,24 @@ const updateThermograph = async () => {
|
||||||
ref="inputFileRef"
|
ref="inputFileRef"
|
||||||
:label="t('travel.thermographs.file')"
|
:label="t('travel.thermographs.file')"
|
||||||
multiple
|
multiple
|
||||||
:accept="allowedFileTypes"
|
:accept="allowedContentTypes"
|
||||||
v-model="thermographForm.files"
|
v-model="thermographForm.files"
|
||||||
>
|
>
|
||||||
<template #append>
|
<template #append>
|
||||||
<QIcon
|
<QIcon
|
||||||
name="vn:attach"
|
name="vn:attach"
|
||||||
class="cursor-pointer"
|
class="cursor-pointer q-mr-sm"
|
||||||
@click="inputFileRef.pickFiles()"
|
@click="inputFileRef.pickFiles()"
|
||||||
>
|
>
|
||||||
<QTooltip>{{ t('Select files') }}</QTooltip>
|
<QTooltip>{{ t('Select files') }}</QTooltip>
|
||||||
</QIcon>
|
</QIcon>
|
||||||
|
<QIcon name="info" class="cursor-pointer">
|
||||||
|
<QTooltip>{{
|
||||||
|
t('globals.allowedFilesText', {
|
||||||
|
allowedContentTypes: allowedContentTypes,
|
||||||
|
})
|
||||||
|
}}</QTooltip>
|
||||||
|
</QIcon>
|
||||||
</template>
|
</template>
|
||||||
</QFile>
|
</QFile>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue