refactor(workerBasicData): fix useAdvancedSummary
gitea/salix-front/pipeline/head This commit looks good
Details
gitea/salix-front/pipeline/head This commit looks good
Details
This commit is contained in:
parent
ba2ab0f300
commit
312677964e
|
@ -1,6 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, nextTick, onMounted } from 'vue';
|
import { ref, nextTick } 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';
|
||||||
|
@ -9,21 +8,25 @@ import VnRow from 'components/ui/VnRow.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
import { useAdvancedSummary } from 'src/composables/useAdvancedSummary';
|
import { useAdvancedSummary } from 'src/composables/useAdvancedSummary';
|
||||||
|
import { useState } from 'src/composables/useState';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const state = useState();
|
||||||
const form = ref();
|
const form = ref();
|
||||||
const educationLevels = ref([]);
|
const educationLevels = ref([]);
|
||||||
const countries = ref([]);
|
const countries = ref([]);
|
||||||
|
const model = 'Worker';
|
||||||
const maritalStatus = [
|
const maritalStatus = [
|
||||||
{ code: 'M', name: t('Married') },
|
{ code: 'M', name: t('Married') },
|
||||||
{ code: 'S', name: t('Single') },
|
{ code: 'S', name: t('Single') },
|
||||||
];
|
];
|
||||||
|
|
||||||
onMounted(async () => {
|
async function addAdvancedData(id) {
|
||||||
const advanced = await useAdvancedSummary('Workers', useRoute().params.id);
|
const data = state.get(model);
|
||||||
Object.assign(form.value.formData, advanced);
|
const advanced = await useAdvancedSummary('Workers', id);
|
||||||
|
state.set(model, Object.assign(data, advanced));
|
||||||
nextTick(() => (form.value.hasChanges = false));
|
nextTick(() => (form.value.hasChanges = false));
|
||||||
});
|
}
|
||||||
</script>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -42,7 +45,8 @@ onMounted(async () => {
|
||||||
ref="form"
|
ref="form"
|
||||||
:url-update="`Workers/${$route.params.id}`"
|
:url-update="`Workers/${$route.params.id}`"
|
||||||
auto-load
|
auto-load
|
||||||
model="Worker"
|
:model
|
||||||
|
@on-fetch="() => addAdvancedData($route.params.id)"
|
||||||
>
|
>
|
||||||
<template #form="{ data }">
|
<template #form="{ data }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
|
Loading…
Reference in New Issue