feat: refs #8237 #8237 modified fetch to find default select value by "code"

This commit is contained in:
PAU ROVIRA ROSALENY 2025-03-24 14:06:38 +01:00
parent 933736e06b
commit 293d51b741
1 changed files with 15 additions and 3 deletions

View File

@ -40,6 +40,11 @@ const quasar = useQuasar();
const newNote = reactive({ text: null, observationTypeFk: null });
const observationTypes = ref([]);
const vnPaginateRef = ref();
const defaultObservationType = computed(() =>
observationTypes.value.find(ot => ot.code === 'salesPerson')?.id
);
let originalText;
function handleClick(e) {
@ -111,14 +116,22 @@ function fetchData([data]) {
originalText = data?.notes;
emit('onFetch', data);
}
const handleObservationTypes = (data) => {
observationTypes.value = data;
if(defaultObservationType.value) {
newNote.observationTypeFk = defaultObservationType.value;
}
};
</script>
<template>
<FetchData
v-if="selectType"
url="ObservationTypes"
:filter="{ fields: ['id', 'description'] }"
:filter="{ fields: ['id', 'description', 'code'] }"
auto-load
@on-fetch="(data) => (observationTypes = data)"
@on-fetch="handleObservationTypes"
/>
<FetchData
v-if="justInput"
@ -190,7 +203,6 @@ function fetchData([data]) {
:search-url="false"
@on-fetch="
newNote.text = '';
newNote.observationTypeFk = 4;
"
>
<template #body="{ rows }">