forked from verdnatura/salix-front
Merge branch 'branch-PR-2' of https://gitea.verdnatura.es/hyervoni/salix-front-mindshore into branch-PR-2
This commit is contained in:
commit
aee4696bb2
|
@ -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, {
|
const arrayData = useArrayData(props.dataKey, {
|
||||||
exprBuilder: props.exprBuilder,
|
exprBuilder: props.exprBuilder,
|
||||||
|
@ -116,6 +116,7 @@ const tags = computed(() => {
|
||||||
async function remove(key) {
|
async function remove(key) {
|
||||||
userParams.value[key] = null;
|
userParams.value[key] = null;
|
||||||
await search();
|
await search();
|
||||||
|
emit('remove', key)
|
||||||
}
|
}
|
||||||
|
|
||||||
function formatValue(value) {
|
function formatValue(value) {
|
||||||
|
|
|
@ -21,16 +21,27 @@ const selectedCategoryFk = ref(null);
|
||||||
const typeList = ref(null);
|
const typeList = ref(null);
|
||||||
const selectedTypeFk = 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) {
|
if (params.categoryFk === category?.id) {
|
||||||
selectedCategoryFk.value = null;
|
resetCategory();
|
||||||
params.categoryFk = null;
|
params.categoryFk = null;
|
||||||
typeList.value = null;
|
|
||||||
} else {
|
} else {
|
||||||
selectedCategoryFk.value = category?.id;
|
selectedCategoryFk.value = category?.id;
|
||||||
params.categoryFk = category?.id;
|
params.categoryFk = category?.id;
|
||||||
loadTypes(category?.id);
|
loadTypes(category?.id);
|
||||||
}
|
}
|
||||||
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadTypes = async (categoryFk) => {
|
const loadTypes = async (categoryFk) => {
|
||||||
|
@ -65,6 +76,8 @@ function exprBuilder(param, value) {
|
||||||
case 'categoryFk':
|
case 'categoryFk':
|
||||||
case 'typeFk':
|
case 'typeFk':
|
||||||
return { [param]: value };
|
return { [param]: value };
|
||||||
|
case 'search':
|
||||||
|
return { 'i.name': { like: `%${value}%` } };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,10 +101,10 @@ const getCategoryClass = (category, params) => {
|
||||||
<FetchData url="ItemCategories" limit="30" auto-load @on-fetch="setCategoryList" />
|
<FetchData url="ItemCategories" limit="30" auto-load @on-fetch="setCategoryList" />
|
||||||
<VnFilterPanel
|
<VnFilterPanel
|
||||||
:data-key="props.dataKey"
|
:data-key="props.dataKey"
|
||||||
:search-button="true"
|
|
||||||
:hidden-tags="['orderFk', 'orderBy']"
|
:hidden-tags="['orderFk', 'orderBy']"
|
||||||
:expr-builder="exprBuilder"
|
:expr-builder="exprBuilder"
|
||||||
@init="onFilterInit"
|
@init="onFilterInit"
|
||||||
|
@remove="clearFilter"
|
||||||
>
|
>
|
||||||
<template #tags="{ tag, formatFn }">
|
<template #tags="{ tag, formatFn }">
|
||||||
<strong v-if="tag.label === 'categoryFk'">
|
<strong v-if="tag.label === 'categoryFk'">
|
||||||
|
@ -105,7 +118,7 @@ const getCategoryClass = (category, params) => {
|
||||||
<span>{{ formatFn(tag.value) }}</span>
|
<span>{{ formatFn(tag.value) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #body="{ params }">
|
<template #body="{ params, searchFn }">
|
||||||
<QList dense>
|
<QList dense>
|
||||||
<QItem class="category-filter q-mt-md">
|
<QItem class="category-filter q-mt-md">
|
||||||
<div
|
<div
|
||||||
|
@ -116,7 +129,7 @@ const getCategoryClass = (category, params) => {
|
||||||
<QIcon
|
<QIcon
|
||||||
:name="category.icon"
|
:name="category.icon"
|
||||||
class="category-icon"
|
class="category-icon"
|
||||||
@click="selectCategory(params, category)"
|
@click="selectCategory(params, category, searchFn)"
|
||||||
>
|
>
|
||||||
<QTooltip>
|
<QTooltip>
|
||||||
{{ t(category.name) }}
|
{{ t(category.name) }}
|
||||||
|
@ -138,7 +151,12 @@ const getCategoryClass = (category, params) => {
|
||||||
emit-value
|
emit-value
|
||||||
use-input
|
use-input
|
||||||
:disable="!selectedCategoryFk"
|
:disable="!selectedCategoryFk"
|
||||||
@update:model-value="(value) => (selectedTypeFk = value)"
|
@update:model-value="
|
||||||
|
(value) => {
|
||||||
|
selectedTypeFk = value;
|
||||||
|
searchFn();
|
||||||
|
}
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<template #option="{ itemProps, opt }">
|
<template #option="{ itemProps, opt }">
|
||||||
<QItem v-bind="itemProps">
|
<QItem v-bind="itemProps">
|
||||||
|
|
|
@ -20,12 +20,6 @@ const catalogParams = {
|
||||||
orderBy: JSON.stringify({ field: 'relevancy DESC, name', way: 'ASC', isTag: false }),
|
orderBy: JSON.stringify({ field: 'relevancy DESC, name', way: 'ASC', isTag: false }),
|
||||||
};
|
};
|
||||||
|
|
||||||
function exprBuilder(param, value) {
|
|
||||||
switch (param) {
|
|
||||||
case 'search':
|
|
||||||
return { 'i.name': { like: `%${value}%` } };
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -35,8 +29,8 @@ function exprBuilder(param, value) {
|
||||||
url="Orders/CatalogFilter"
|
url="Orders/CatalogFilter"
|
||||||
:limit="50"
|
:limit="50"
|
||||||
:user-params="catalogParams"
|
:user-params="catalogParams"
|
||||||
:expr-builder="exprBuilder"
|
|
||||||
:static-params="['orderFk', 'orderBy']"
|
:static-params="['orderFk', 'orderBy']"
|
||||||
|
:redirect="false"
|
||||||
/>
|
/>
|
||||||
</Teleport>
|
</Teleport>
|
||||||
<Teleport v-if="stateStore.isHeaderMounted()" to="#actions-append">
|
<Teleport v-if="stateStore.isHeaderMounted()" to="#actions-append">
|
||||||
|
|
Loading…
Reference in New Issue