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