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); +}; @@ -142,6 +160,7 @@ const getSelectedTagValues = async (tag) => { @@ -157,6 +176,21 @@ const getSelectedTagValues = async (tag) => { {{ formatFn(tag.value) }} + + + + + {{ chip.tagName }}: + "{{ chip.value }}" + + + + { { rounded :emit-value="false" use-input + :is-clearable="false" @update:model-value="getSelectedTagValues(value)" /> { emit-value use-input :disable="!value" + :is-clearable="false" class="filter-input" - @update:model-value="applyTags()" + @update:model-value="applyTags(params, searchFn)" /> { :disable="!value" is-outlined class="filter-input" + :is-clearable="false" + @keyup.enter="applyTags(params, searchFn)" /> @@ -427,13 +465,10 @@ es: typeFk: Tipo tag: Etiqueta value: Valor - Plant: Planta Flower: Flor Handmade: Confección Green: Verde Accessories: Complemento Fruit: Fruta - -