diff --git a/src/components/common/VnSelect.vue b/src/components/common/VnSelect.vue index 662efcfe9..32dbbd641 100644 --- a/src/components/common/VnSelect.vue +++ b/src/components/common/VnSelect.vue @@ -119,7 +119,7 @@ watch(options, (newValue) => { }); watch(modelValue, async (newValue) => { - if (!myOptions.value.some((option) => option[optionValue.value] == newValue)) + if (!myOptions?.value?.some((option) => option[optionValue.value] == newValue)) await fetchFilter(newValue); if ($props.noOne) myOptions.value.unshift(noOneOpt.value); diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index 43d634ad9..a8aca49dd 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -57,7 +57,6 @@ const $props = defineProps({ }, }); -defineExpose({ search, sanitizer }); const emit = defineEmits([ 'update:modelValue', 'refresh', @@ -170,9 +169,29 @@ const tagsList = computed(() => { return tagList; }); +const formatTags = (tags) => { + const formattedTags = []; + tags.forEach((tag) => { + if (tag.label === 'and') { + tag.value.forEach((item) => { + for (const key in item) { + formattedTags.push({ label: key, value: item[key] }); + } + }); + } else { + formattedTags.push(tag); + } + }); + return formattedTags; +}; + const tags = computed(() => { - return tagsList.value.filter((tag) => !($props.customTags || []).includes(tag.label)); + const filteredTags = tagsList.value.filter( + (tag) => !($props.customTags || []).includes(tag.label) + ); + return formatTags(filteredTags); }); + const customTags = computed(() => tagsList.value.filter((tag) => ($props.customTags || []).includes(tag.label)) ); @@ -193,13 +212,20 @@ function formatValue(value) { function sanitizer(params) { for (const [key, value] of Object.entries(params)) { - if (value && typeof value === 'object') { + if (key === 'and' && Array.isArray(value)) { + value.forEach((item) => { + Object.assign(params, item); + }); + delete params[key]; + } else if (value && typeof value === 'object') { const param = Object.values(value)[0]; if (typeof param == 'string') params[key] = param.replaceAll('%', ''); } } return params; } + +defineExpose({ search, sanitizer, userParams });