Entry latest buys side filter panel
This commit is contained in:
parent
2774c68f19
commit
6eee05249d
|
@ -587,13 +587,8 @@ const redirectToEntryBuys = (entryFk) => {
|
||||||
|
|
||||||
const applyColumnFilter = async (col) => {
|
const applyColumnFilter = async (col) => {
|
||||||
try {
|
try {
|
||||||
if (!col.columnFilter.filterValue) {
|
|
||||||
delete params[col.field];
|
|
||||||
} else {
|
|
||||||
params[col.field] = col.columnFilter.filterValue;
|
params[col.field] = col.columnFilter.filterValue;
|
||||||
}
|
await arrayData.addFilter({ params });
|
||||||
|
|
||||||
await arrayData.applyFilter({ params });
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error applying column filter', err);
|
console.error('Error applying column filter', err);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@ import FetchData from 'components/FetchData.vue';
|
||||||
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
import VnInputDate from 'src/components/common/VnInputDate.vue';
|
||||||
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
|
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
|
||||||
import VnSelectFilter from 'components/common/VnSelectFilter.vue';
|
import VnSelectFilter from 'components/common/VnSelectFilter.vue';
|
||||||
|
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
|
||||||
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
|
@ -50,8 +51,8 @@ const selectedType = computed(() => {
|
||||||
|
|
||||||
const selectCategory = async (params, categoryId, search) => {
|
const selectCategory = async (params, categoryId, search) => {
|
||||||
if (params.categoryFk === categoryId) {
|
if (params.categoryFk === categoryId) {
|
||||||
resetCategory();
|
resetCategory(params);
|
||||||
params.categoryFk = null;
|
search();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
selectedCategoryFk.value = categoryId;
|
selectedCategoryFk.value = categoryId;
|
||||||
|
@ -60,12 +61,25 @@ const selectCategory = async (params, categoryId, search) => {
|
||||||
search();
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
const resetCategory = () => {
|
const resetCategory = (params) => {
|
||||||
selectedCategoryFk.value = null;
|
selectedCategoryFk.value = null;
|
||||||
itemTypesOptions.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) => {
|
const fetchItemTypes = async (id) => {
|
||||||
try {
|
try {
|
||||||
|
@ -92,7 +106,7 @@ const getCategoryClass = (category, params) => {
|
||||||
|
|
||||||
const getSelectedTagValues = async (tag) => {
|
const getSelectedTagValues = async (tag) => {
|
||||||
try {
|
try {
|
||||||
console.log('tag:: ', tag);
|
tag.value = null;
|
||||||
const filter = {
|
const filter = {
|
||||||
fields: ['value'],
|
fields: ['value'],
|
||||||
order: 'value ASC',
|
order: 'value ASC',
|
||||||
|
@ -104,11 +118,15 @@ const getSelectedTagValues = async (tag) => {
|
||||||
params,
|
params,
|
||||||
});
|
});
|
||||||
tag.valueOptions = data;
|
tag.valueOptions = data;
|
||||||
console.log('tag.valueOptions:: ', tag.valueOptions);
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('Error getting selected tag values');
|
console.error('Error getting selected tag values');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const removeTag = (index, params, search) => {
|
||||||
|
(tagValues.value || []).splice(index, 1);
|
||||||
|
applyTags(params, search);
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -142,6 +160,7 @@ const getSelectedTagValues = async (tag) => {
|
||||||
<VnFilterPanel
|
<VnFilterPanel
|
||||||
:data-key="props.dataKey"
|
:data-key="props.dataKey"
|
||||||
:expr-builder="exprBuilder"
|
:expr-builder="exprBuilder"
|
||||||
|
:custom-tags="['tags']"
|
||||||
@init="onFilterInit"
|
@init="onFilterInit"
|
||||||
@remove="clearFilter"
|
@remove="clearFilter"
|
||||||
>
|
>
|
||||||
|
@ -157,6 +176,21 @@ const getSelectedTagValues = async (tag) => {
|
||||||
<span>{{ formatFn(tag.value) }}</span>
|
<span>{{ formatFn(tag.value) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<template #customTags="{ tags: customTags, params }">
|
||||||
|
<template v-for="tag in customTags" :key="tag.label">
|
||||||
|
<VnFilterPanelChip
|
||||||
|
v-for="chip in tag.value"
|
||||||
|
:key="chip"
|
||||||
|
removable
|
||||||
|
@remove="removeTagChip(chip, params, searchFn)"
|
||||||
|
>
|
||||||
|
<div class="q-gutter-x-xs">
|
||||||
|
<strong>{{ chip.tagName }}: </strong>
|
||||||
|
<span>"{{ chip.value }}"</span>
|
||||||
|
</div>
|
||||||
|
</VnFilterPanelChip>
|
||||||
|
</template>
|
||||||
|
</template>
|
||||||
<template #body="{ params, searchFn }">
|
<template #body="{ params, searchFn }">
|
||||||
<QItem class="category-filter q-mt-md">
|
<QItem class="category-filter q-mt-md">
|
||||||
<QBtn
|
<QBtn
|
||||||
|
@ -303,7 +337,7 @@ const getSelectedTagValues = async (tag) => {
|
||||||
<QItem
|
<QItem
|
||||||
v-for="(value, index) in tagValues"
|
v-for="(value, index) in tagValues"
|
||||||
:key="value"
|
:key="value"
|
||||||
class="q-mt-md filter-value bg-red"
|
class="q-mt-md filter-value"
|
||||||
>
|
>
|
||||||
<QItemSection class="col">
|
<QItemSection class="col">
|
||||||
<VnSelectFilter
|
<VnSelectFilter
|
||||||
|
@ -316,12 +350,13 @@ const getSelectedTagValues = async (tag) => {
|
||||||
rounded
|
rounded
|
||||||
:emit-value="false"
|
:emit-value="false"
|
||||||
use-input
|
use-input
|
||||||
|
:is-clearable="false"
|
||||||
@update:model-value="getSelectedTagValues(value)"
|
@update:model-value="getSelectedTagValues(value)"
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QItemSection class="col">
|
<QItemSection class="col">
|
||||||
<VnSelectFilter
|
<VnSelectFilter
|
||||||
v-if="!value?.isFree && value.valueOptions"
|
v-if="!value?.selectedTag?.isFree && value.valueOptions"
|
||||||
:label="t('params.value')"
|
:label="t('params.value')"
|
||||||
v-model="value.value"
|
v-model="value.value"
|
||||||
:options="value.valueOptions || []"
|
:options="value.valueOptions || []"
|
||||||
|
@ -333,8 +368,9 @@ const getSelectedTagValues = async (tag) => {
|
||||||
emit-value
|
emit-value
|
||||||
use-input
|
use-input
|
||||||
:disable="!value"
|
:disable="!value"
|
||||||
|
:is-clearable="false"
|
||||||
class="filter-input"
|
class="filter-input"
|
||||||
@update:model-value="applyTags()"
|
@update:model-value="applyTags(params, searchFn)"
|
||||||
/>
|
/>
|
||||||
<VnInput
|
<VnInput
|
||||||
v-else
|
v-else
|
||||||
|
@ -343,12 +379,14 @@ const getSelectedTagValues = async (tag) => {
|
||||||
:disable="!value"
|
:disable="!value"
|
||||||
is-outlined
|
is-outlined
|
||||||
class="filter-input"
|
class="filter-input"
|
||||||
|
:is-clearable="false"
|
||||||
|
@keyup.enter="applyTags(params, searchFn)"
|
||||||
/>
|
/>
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
<QIcon
|
<QIcon
|
||||||
name="delete"
|
name="delete"
|
||||||
class="filter-icon"
|
class="filter-icon"
|
||||||
@click="(tagValues || []).splice(index, 1)"
|
@click="removeTag(index, params, searchFn)"
|
||||||
/>
|
/>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem class="q-mt-lg">
|
<QItem class="q-mt-lg">
|
||||||
|
@ -427,13 +465,10 @@ es:
|
||||||
typeFk: Tipo
|
typeFk: Tipo
|
||||||
tag: Etiqueta
|
tag: Etiqueta
|
||||||
value: Valor
|
value: Valor
|
||||||
|
|
||||||
Plant: Planta
|
Plant: Planta
|
||||||
Flower: Flor
|
Flower: Flor
|
||||||
Handmade: Confección
|
Handmade: Confección
|
||||||
Green: Verde
|
Green: Verde
|
||||||
Accessories: Complemento
|
Accessories: Complemento
|
||||||
Fruit: Fruta
|
Fruit: Fruta
|
||||||
|
|
||||||
|
|
||||||
</i18n>
|
</i18n>
|
||||||
|
|
Loading…
Reference in New Issue