0
0
Fork 0

fix: itemBotanical

This commit is contained in:
Javier Segarra 2024-08-22 10:38:15 +02:00
parent 12a5d6cec0
commit bae0b4de35
1 changed files with 17 additions and 18 deletions

View File

@ -13,7 +13,6 @@ import CreateSpecieForm from './CreateSpecieForm.vue';
const route = useRoute();
const { t } = useI18n();
const itemBotanicalsRef = ref(null);
const itemGenusOptions = ref([]);
const itemSpeciesOptions = ref([]);
const itemBotanicals = ref([]);
@ -31,22 +30,19 @@ const onSpecieCreated = (response, formData) => {
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]);
});
// onMounted(async () => {
// itemBotanicalsForm.itemFk = entityId.value;
// // itemBotanicals.value = await itemBotanicalsRef.value.fetch();
// if (itemBotanicals.value.length > 0)
// Object.assign(itemBotanicalsForm, itemBotanicals.value[0]);
// });
async function handleItemBotanical(data) {
itemBotanicalsForm = data;
// if (data.length > 0) Object.assign(itemBotanicalsForm, itemBotanicals.value[0]);
}
</script>
<template>
<FetchData
ref="itemBotanicalsRef"
url="ItemBotanicals"
:filter="{
where: { itemFk: entityId },
}"
@on-fetch="(data) => (itemBotanicals = data)"
/>
<!-- <FetchData ref="itemBotanicalsRef" @on-fetch="(data) => (itemBotanicals = data)" /> -->
<FetchData
url="Genera"
:filter="{ fields: ['id', 'name'], order: 'name ASC' }"
@ -60,11 +56,14 @@ onMounted(async () => {
auto-load
/>
<FormModel
url="ItemBotanicals"
url-update="ItemBotanicals"
model="entry"
model="item"
auto-load
:form-initial-data="itemBotanicalsForm"
:clear-store-on-unmount="false"
:filter="{
where: { itemFk: entityId },
}"
@on-fetch="handleItemBotanical"
>
<template #form="{ data }">
<VnRow>