diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index d7ef92df9..31731b8b0 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -33,16 +33,15 @@ const store = arrayData.store; const userParams = ref({}); onMounted(() => { - if (props.params) userParams.value = props.params; - const params = store.userParams; - if (Object.keys(params).length > 0) { - userParams.value = Object.assign({}, params); + if (props.params) userParams.value = JSON.parse(JSON.stringify(props.params)); + if (Object.keys(store.userParams).length > 0) { + userParams.value = JSON.parse(JSON.stringify(store.userParams)); } }); const isLoading = ref(false); async function search() { - const params = userParams.value; + const params = JSON.parse(JSON.stringify(userParams.value)); for (const param in params) { if (params[param] === '' || params[param] === null) { delete userParams.value[param]; @@ -51,16 +50,17 @@ async function search() { } isLoading.value = true; await arrayData.addFilter({ params }); - if (!props.showAll && !Object.values(store.userParams).length) store.data = []; + if (!props.showAll && !Object.values(params).length) store.data = []; isLoading.value = false; } async function reload() { isLoading.value = true; + const params = Object.values(userParams.value).filter((param) => param); await arrayData.fetch({ append: false }); - if (!props.showAll && !Object.values(store.userParams).length) store.data = []; + if (!props.showAll && !params.length) store.data = []; isLoading.value = false; emit('refresh'); }