diff --git a/src/components/common/VnSelect.vue b/src/components/common/VnSelect.vue index 23cec4be6..fe7d8963a 100644 --- a/src/components/common/VnSelect.vue +++ b/src/components/common/VnSelect.vue @@ -127,7 +127,7 @@ const arrayData = useArrayData(arrayDataKey, { url: $props.url }); onMounted(async () => { if ($props.focusOnMount) setTimeout(() => vnSelectRef.value.showPopup(), 300); setOptions(options.value); - if (useURL.value) await fetchFilter($props.modelValue); + if (useURL.value && $props.modelValue) await fetchFilter($props.modelValue); }); watch(options, (newValue) => { setOptions(newValue); @@ -140,18 +140,6 @@ watch(modelValue, async (newValue) => { if ($props.noOne) myOptions.value.unshift(noOneOpt.value); }); -onMounted(async () => { - setOptions(options.value); - if ($props.url && $props.modelValue && !findKeyInOptions()) - await fetchFilter($props.modelValue); - if ($props.focusOnMount) setTimeout(() => vnSelectRef.value.showPopup(), 300); -}); - -function findKeyInOptions() { - if (!$props.options) return; - return filter($props.modelValue, $props.options)?.length; -} - function setOptions(data, append = true) { myOptions.value = JSON.parse(JSON.stringify(data)); if (append) myOptionsOriginal.value = JSON.parse(JSON.stringify(data)); @@ -209,7 +197,7 @@ async function fetchFilter(val) { arrayData.store.filter.skip = 0; const { data } = await arrayData.fetch({ append: true, updateRouter: false }); setOptions(data); - // return data; + return data; } async function filterHandler(val, update) {