refactor: refs #6919 simplify WorkerBasicData component by removing unused imports and optimizing data fetching
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2025-01-09 12:41:24 +01:00
parent d23eb052f4
commit 39f0873fb8
1 changed files with 6 additions and 8 deletions

View File

@ -1,6 +1,5 @@
<script setup>
import { ref, onBeforeMount } from 'vue';
import { useRoute } from 'vue-router';
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import VnInputDate from 'src/components/common/VnInputDate.vue';
import FetchData from 'components/FetchData.vue';
@ -11,17 +10,13 @@ import VnSelect from 'src/components/common/VnSelect.vue';
import { useAdvancedSummary } from 'src/composables/useAdvancedSummary';
const { t } = useI18n();
const form = ref();
const educationLevels = ref([]);
const countries = ref([]);
const maritalStatus = [
{ code: 'M', name: t('Married') },
{ code: 'S', name: t('Single') },
];
const advancedSummary = ref({});
const route = useRoute();
onBeforeMount(async () => {
advancedSummary.value = (await useAdvancedSummary('Workers', route.params.id)) ?? {};
});
</script>
<template>
<FetchData
@ -37,12 +32,15 @@ onBeforeMount(async () => {
auto-load
/>
<FormModel
ref="form"
:url-update="`Workers/${$route.params.id}`"
auto-load
model="Worker"
@on-fetch="
async (data) => {
Object.assign(data, advancedSummary);
Object.assign(data, (await useAdvancedSummary('Workers', data.id)) ?? {});
await $nextTick();
if (form) form.hasChanges = false;
}
"
>