diff --git a/src/components/common/VnLocation.vue b/src/components/common/VnLocation.vue index 17dd3d37b..2b8dc8450 100644 --- a/src/components/common/VnLocation.vue +++ b/src/components/common/VnLocation.vue @@ -55,7 +55,7 @@ const value = computed({ }); onMounted(() => { - locationFilter() + locationFilter($props.modelValue); }); function setOptions(data) { @@ -69,34 +69,39 @@ watch(options, (newValue) => { }); function showLabel(data) { - return `${data.code} - ${data.town}(${data.province}), ${data.country}`; + return `${data.code} - ${data.town}(${data.province}), ${data.country}`; } -function locationFilter(search) { +function locationFilter(search = '') { + if ( + search && + (search.includes('undefined') || search.startsWith(`${$props.modelValue} - `)) + ) + return; let where = { search }; - postcodesRef.value.fetch({filter:{ where}, limit: 30}); + postcodesRef.value.fetch({ filter: { where }, limit: 30 }); } -function handleFetch( data) { +function handleFetch(data) { postcodesOptions.value = data; } - -