From 6eee05249d3e9c7cd168d085ea0393fa122a8885 Mon Sep 17 00:00:00 2001 From: wbuezas Date: Mon, 4 Mar 2024 22:08:44 -0300 Subject: [PATCH] Entry latest buys side filter panel --- src/pages/Entry/EntryLatestBuys.vue | 9 +--- src/pages/Entry/EntryLatestBuysFilter.vue | 61 ++++++++++++++++++----- 2 files changed, 50 insertions(+), 20 deletions(-) diff --git a/src/pages/Entry/EntryLatestBuys.vue b/src/pages/Entry/EntryLatestBuys.vue index 65747d2e2..8672f9445 100644 --- a/src/pages/Entry/EntryLatestBuys.vue +++ b/src/pages/Entry/EntryLatestBuys.vue @@ -587,13 +587,8 @@ const redirectToEntryBuys = (entryFk) => { const applyColumnFilter = async (col) => { try { - if (!col.columnFilter.filterValue) { - delete params[col.field]; - } else { - params[col.field] = col.columnFilter.filterValue; - } - - await arrayData.applyFilter({ params }); + params[col.field] = col.columnFilter.filterValue; + await arrayData.addFilter({ params }); } catch (err) { console.error('Error applying column filter', err); } diff --git a/src/pages/Entry/EntryLatestBuysFilter.vue b/src/pages/Entry/EntryLatestBuysFilter.vue index 55f75d0c5..23361ffb3 100644 --- a/src/pages/Entry/EntryLatestBuysFilter.vue +++ b/src/pages/Entry/EntryLatestBuysFilter.vue @@ -7,6 +7,7 @@ import FetchData from 'components/FetchData.vue'; import VnInputDate from 'src/components/common/VnInputDate.vue'; import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue'; import VnSelectFilter from 'components/common/VnSelectFilter.vue'; +import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue'; import axios from 'axios'; @@ -50,8 +51,8 @@ const selectedType = computed(() => { const selectCategory = async (params, categoryId, search) => { if (params.categoryFk === categoryId) { - resetCategory(); - params.categoryFk = null; + resetCategory(params); + search(); return; } selectedCategoryFk.value = categoryId; @@ -60,12 +61,25 @@ const selectCategory = async (params, categoryId, search) => { search(); }; -const resetCategory = () => { +const resetCategory = (params) => { selectedCategoryFk.value = null; itemTypesOptions.value = null; + if (params) { + params.categoryFk = null; + params.typeFk = null; + } }; -const applyTags = () => {}; +const applyTags = (params, search) => { + params.tags = tagValues.value + .filter((tag) => tag.selectedTag && tag.value) + .map((tag) => ({ + tagFk: tag.selectedTag.id, + tagName: tag.selectedTag.name, + value: tag.value, + })); + search(); +}; const fetchItemTypes = async (id) => { try { @@ -92,7 +106,7 @@ const getCategoryClass = (category, params) => { const getSelectedTagValues = async (tag) => { try { - console.log('tag:: ', tag); + tag.value = null; const filter = { fields: ['value'], order: 'value ASC', @@ -104,11 +118,15 @@ const getSelectedTagValues = async (tag) => { params, }); tag.valueOptions = data; - console.log('tag.valueOptions:: ', tag.valueOptions); } catch (err) { console.error('Error getting selected tag values'); } }; + +const removeTag = (index, params, search) => { + (tagValues.value || []).splice(index, 1); + applyTags(params, search); +}; +