From c1ed4ab03280b8125c92e8587e9a8bd4ca626abd Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Fri, 26 Apr 2024 14:49:54 +0200 Subject: [PATCH] fix: add exprBuilder --- src/components/ui/VnFilterPanel.vue | 3 ++- src/components/ui/VnSearchbar.vue | 2 ++ src/pages/Item/ItemTypeList.vue | 17 +++++++++++++++-- src/pages/ItemType/ItemTypeFilter.vue | 8 +++++++- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index 96d097191..cde48e9b3 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -145,7 +145,8 @@ const customTags = computed(() => ); async function remove(key) { - userParams.value[key] = null; + // userParams.value[key] = null; + if (userParams.value[key]) delete userParams.value[key]; await search(); emit('remove', key); } diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index fc8475ace..da8d43c95 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -81,8 +81,10 @@ async function search() { const staticParams = Object.entries(store.userParams).filter( ([key, value]) => value && (props.staticParams || []).includes(key) ); + // const filter =props?.where? { where: JSON.parse(props.where) }: {} await arrayData.applyFilter({ params: { + // filter , ...Object.fromEntries(staticParams), search: searchText.value, }, diff --git a/src/pages/Item/ItemTypeList.vue b/src/pages/Item/ItemTypeList.vue index 5b106916d..1e21c1719 100644 --- a/src/pages/Item/ItemTypeList.vue +++ b/src/pages/Item/ItemTypeList.vue @@ -24,6 +24,17 @@ const redirectToItemTypeSummary = (id) => { const redirectToCreateView = () => { router.push({ name: 'ItemTypeCreate' }); }; +const exprBuilder = (param, value) => { + switch (param) { + case 'name': + case 'code': + case 'search': + return { + name: { like: `%${value}%` }, + code: { like: `%${value}%` }, + }; + } +}; - + diff --git a/src/pages/ItemType/ItemTypeFilter.vue b/src/pages/ItemType/ItemTypeFilter.vue index 33238545f..2a86795c2 100644 --- a/src/pages/ItemType/ItemTypeFilter.vue +++ b/src/pages/ItemType/ItemTypeFilter.vue @@ -10,10 +10,16 @@ const props = defineProps({ required: true, }, }); + +const emit = defineEmits(['search']);