refactor(WorkerBasicData): update addAdvancedData to use formData and remove state dependency
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
312677964e
commit
92b3ea126f
|
@ -279,7 +279,7 @@ function updateAndEmit(evt, { val, res, old } = { val: null, res: null, old: nul
|
|||
state.set(modelValue, val);
|
||||
if (!$props.url) arrayData.store.data = val;
|
||||
|
||||
emit(evt, state.get(modelValue), res, old);
|
||||
emit(evt, state.get(modelValue), res, old, formData);
|
||||
}
|
||||
|
||||
function trimData(data) {
|
||||
|
|
|
@ -8,10 +8,9 @@ import VnRow from 'components/ui/VnRow.vue';
|
|||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import { useAdvancedSummary } from 'src/composables/useAdvancedSummary';
|
||||
import { useState } from 'src/composables/useState';
|
||||
import { useRoute } from 'vue-router';
|
||||
|
||||
const { t } = useI18n();
|
||||
const state = useState();
|
||||
const form = ref();
|
||||
const educationLevels = ref([]);
|
||||
const countries = ref([]);
|
||||
|
@ -20,11 +19,10 @@ const maritalStatus = [
|
|||
{ code: 'M', name: t('Married') },
|
||||
{ code: 'S', name: t('Single') },
|
||||
];
|
||||
|
||||
async function addAdvancedData(id) {
|
||||
const data = state.get(model);
|
||||
const advanced = await useAdvancedSummary('Workers', id);
|
||||
state.set(model, Object.assign(data, advanced));
|
||||
const route = useRoute();
|
||||
async function addAdvancedData(data) {
|
||||
const advanced = await useAdvancedSummary('Workers', route.params.id);
|
||||
data.value = { ...data.value, ...advanced };
|
||||
nextTick(() => (form.value.hasChanges = false));
|
||||
}
|
||||
</script>
|
||||
|
@ -46,7 +44,7 @@ async function addAdvancedData(id) {
|
|||
:url-update="`Workers/${$route.params.id}`"
|
||||
auto-load
|
||||
:model
|
||||
@on-fetch="() => addAdvancedData($route.params.id)"
|
||||
@on-fetch="(data, res, old, formData) => addAdvancedData(formData)"
|
||||
>
|
||||
<template #form="{ data }">
|
||||
<VnRow>
|
||||
|
|
Loading…
Reference in New Issue