diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index 6f6183224..a138e0b64 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -41,7 +41,7 @@ const props = defineProps({ }, }); -const emit = defineEmits(['refresh', 'clear', 'search', 'init']); +const emit = defineEmits(['refresh', 'clear', 'search', 'init', 'remove']); const arrayData = useArrayData(props.dataKey, { exprBuilder: props.exprBuilder, @@ -116,6 +116,7 @@ const tags = computed(() => { async function remove(key) { userParams.value[key] = null; await search(); + emit('remove', key) } function formatValue(value) { diff --git a/src/pages/Order/Card/OrderCatalogFilter.vue b/src/pages/Order/Card/OrderCatalogFilter.vue index 23accb680..0859e14a6 100644 --- a/src/pages/Order/Card/OrderCatalogFilter.vue +++ b/src/pages/Order/Card/OrderCatalogFilter.vue @@ -21,16 +21,27 @@ const selectedCategoryFk = ref(null); const typeList = ref(null); const selectedTypeFk = ref(null); -const selectCategory = (params, category) => { +const resetCategory = () => { + selectedCategoryFk.value = null; + typeList.value = null; +}; + +const clearFilter = (key) => { + if (key === 'categoryFk') { + resetCategory(); + } +}; + +const selectCategory = (params, category, search) => { if (params.categoryFk === category?.id) { - selectedCategoryFk.value = null; + resetCategory(); params.categoryFk = null; - typeList.value = null; } else { selectedCategoryFk.value = category?.id; params.categoryFk = category?.id; loadTypes(category?.id); } + search(); }; const loadTypes = async (categoryFk) => { @@ -65,6 +76,8 @@ function exprBuilder(param, value) { case 'categoryFk': case 'typeFk': return { [param]: value }; + case 'search': + return { 'i.name': { like: `%${value}%` } }; } } @@ -88,10 +101,10 @@ const getCategoryClass = (category, params) => { -