diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index 576440539..b93af77cd 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -85,6 +85,21 @@ if (props.redirect) }; let arrayData = useArrayData(props.dataKey, arrayDataProps); let store = arrayData.store; +const to = computed(() => { + const { params } = arrayData.getCurrentFilter(); + params.search = searchText.value || undefined; + const url = { path: route.path, query: { ...(route.query ?? {}) } }; + const searchUrl = arrayData.store.searchUrl; + + for (const key in params) { + const val = params[key]; + if (typeof val === 'object' && !Array.isArray(val) && !(val instanceof Date)) + params[key] = JSON.stringify(val); + } + + if (searchUrl) url.query[searchUrl] = JSON.stringify(params); + return url; +}); watch( () => props.dataKey, @@ -121,27 +136,17 @@ async function search() { } await arrayData.applyFilter(filter); } - -const to = computed(() => { - const { params } = arrayData.getCurrentFilter(); - params.search = searchText.value || undefined; - const url = { path: route.path, query: { ...(route.query ?? {}) } }; - const searchUrl = arrayData.store.searchUrl; - - for (const key in params) { - const val = params[key]; - if (typeof val === 'object' && !Array.isArray(val) && !(val instanceof Date)) - params[key] = JSON.stringify(val); - } - - if (searchUrl) url.query[searchUrl] = JSON.stringify(params); - return url; -});