diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index dca30516f..5187cd6be 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -168,10 +168,20 @@ function setUserParams(watchedParams, watchedOrder) { watchedParams = { ...watchedParams, ...where }; delete watchedParams.filter; delete params.value?.filter; - params.value = { ...params.value, ...watchedParams }; + params.value = { ...params.value, ...sanitizer(watchedParams) }; orders.value = parseOrder(order); } +function sanitizer(params) { + for (const [key, value] of Object.entries(params)) { + if (typeof value == 'object') { + const param = Object.values(value)[0]; + if (typeof param == 'string') params[key] = param.replaceAll('%', ''); + } + } + return params; +} + function splitColumns(columns) { splittedColumns.value = { columns: [], diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index 4fd511631..46a128334 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -92,16 +92,18 @@ function setUserParams(watchedParams) { const order = watchedParams.filter?.order; delete watchedParams.filter; - userParams.value = { ...userParams.value, ...sanitizer(watchedParams) }; + userParams.value = sanitizer(watchedParams); emit('setUserParams', userParams.value, order); } watch( - () => [route.query[$props.searchUrl], arrayData.store.userParams], - ([newSearchUrl, newUserParams], [oldSearchUrl, oldUserParams]) => { - if (newSearchUrl || oldSearchUrl) setUserParams(newSearchUrl); - if (newUserParams || oldUserParams) setUserParams(newUserParams); - } + () => route.query[$props.searchUrl], + (val, oldValue) => (val || oldValue) && setUserParams(val) +); + +watch( + () => arrayData.store.userParams, + (val, oldValue) => (val || oldValue) && setUserParams(val) ); watch( diff --git a/src/pages/Zone/Card/ZoneCard.vue b/src/pages/Zone/Card/ZoneCard.vue index 77ce79602..d61c61abf 100644 --- a/src/pages/Zone/Card/ZoneCard.vue +++ b/src/pages/Zone/Card/ZoneCard.vue @@ -28,8 +28,10 @@ function notIsLocations(ifIsFalse, ifIsTrue) { url: 'Zones', label: notIsLocations(t('list.searchZone'), t('list.searchLocation')), info: t('list.searchInfo'), - whereFilter: notIsLocations((text) => { - return { name: { like: `%${text}%` } }; + whereFilter: notIsLocations((value) => { + return /^\d+$/.test(value) + ? { id: value } + : { name: { like: `%${value}%` } }; }), }" /> diff --git a/src/pages/Zone/Card/ZoneSearchbar.vue b/src/pages/Zone/Card/ZoneSearchbar.vue index 607057d0b..06168eb62 100644 --- a/src/pages/Zone/Card/ZoneSearchbar.vue +++ b/src/pages/Zone/Card/ZoneSearchbar.vue @@ -19,24 +19,14 @@ const exprBuilder = (param, value) => { agencyModeFk: value, }; case 'search': - if (value) { - if (!isNaN(value)) { - return { id: value }; - } else { - return { - name: { - like: `%${value}%`, - }, - }; - } - } + return /^\d+$/.test(value) ? { id: value } : { name: { like: `%${value}%` } }; } };