0
0
Fork 0

fix: bug when save

This commit is contained in:
Javier Segarra 2024-04-26 09:28:32 +02:00
parent 3c033458d3
commit 36e99e2c6c
1 changed files with 7 additions and 4 deletions

View File

@ -1,5 +1,5 @@
<script setup>
import { ref, onMounted, reactive } from 'vue';
import { ref, onMounted, reactive, computed } from 'vue';
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
@ -17,7 +17,7 @@ const itemBotanicalsRef = ref(null);
const itemGenusOptions = ref([]);
const itemSpeciesOptions = ref([]);
const itemBotanicals = ref([]);
let itemBotanicalsForm = reactive({});
let itemBotanicalsForm = reactive({ itemFk: null });
const onGenusCreated = (response, formData) => {
itemGenusOptions.value = [...itemGenusOptions.value, response];
@ -28,8 +28,11 @@ const onSpecieCreated = (response, formData) => {
itemSpeciesOptions.value = [...itemSpeciesOptions.value, response];
formData.specieFk = response.id;
};
const entityId = computed(() => {
return route.params.id;
});
onMounted(async () => {
itemBotanicalsForm.itemFk = entityId.value;
itemBotanicals.value = await itemBotanicalsRef.value.fetch();
if (itemBotanicals.value.length > 0)
Object.assign(itemBotanicalsForm, itemBotanicals.value[0]);
@ -40,7 +43,7 @@ onMounted(async () => {
ref="itemBotanicalsRef"
url="ItemBotanicals"
:filter="{
where: { itemFk: route.params.id },
where: { itemFk: entityId },
}"
@on-fetch="(data) => (itemBotanicals = data)"
/>