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);
|
state.set(modelValue, val);
|
||||||
if (!$props.url) arrayData.store.data = 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) {
|
function trimData(data) {
|
||||||
|
|
|
@ -8,10 +8,9 @@ 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';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
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([]);
|
||||||
|
@ -20,11 +19,10 @@ const maritalStatus = [
|
||||||
{ code: 'M', name: t('Married') },
|
{ code: 'M', name: t('Married') },
|
||||||
{ code: 'S', name: t('Single') },
|
{ code: 'S', name: t('Single') },
|
||||||
];
|
];
|
||||||
|
const route = useRoute();
|
||||||
async function addAdvancedData(id) {
|
async function addAdvancedData(data) {
|
||||||
const data = state.get(model);
|
const advanced = await useAdvancedSummary('Workers', route.params.id);
|
||||||
const advanced = await useAdvancedSummary('Workers', id);
|
data.value = { ...data.value, ...advanced };
|
||||||
state.set(model, Object.assign(data, advanced));
|
|
||||||
nextTick(() => (form.value.hasChanges = false));
|
nextTick(() => (form.value.hasChanges = false));
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -46,7 +44,7 @@ async function addAdvancedData(id) {
|
||||||
:url-update="`Workers/${$route.params.id}`"
|
:url-update="`Workers/${$route.params.id}`"
|
||||||
auto-load
|
auto-load
|
||||||
:model
|
:model
|
||||||
@on-fetch="() => addAdvancedData($route.params.id)"
|
@on-fetch="(data, res, old, formData) => addAdvancedData(formData)"
|
||||||
>
|
>
|
||||||
<template #form="{ data }">
|
<template #form="{ data }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
|
Loading…
Reference in New Issue