Add order orderBy filter
This commit is contained in:
parent
606f4f0892
commit
b622f9cca7
|
@ -31,6 +31,12 @@ const resetCategory = () => {
|
||||||
typeList.value = null;
|
typeList.value = null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const selectedOrder = ref(null);
|
||||||
|
const orderList = [
|
||||||
|
{ way: 'ASC', name: 'Ascendant' },
|
||||||
|
{ way: 'DESC', name: 'Descendant' },
|
||||||
|
];
|
||||||
|
|
||||||
const clearFilter = (key) => {
|
const clearFilter = (key) => {
|
||||||
if (key === 'categoryFk') {
|
if (key === 'categoryFk') {
|
||||||
resetCategory();
|
resetCategory();
|
||||||
|
@ -64,6 +70,10 @@ const onFilterInit = async ({ params }) => {
|
||||||
await loadTypes(params.categoryFk);
|
await loadTypes(params.categoryFk);
|
||||||
selectedCategoryFk.value = params.categoryFk;
|
selectedCategoryFk.value = params.categoryFk;
|
||||||
}
|
}
|
||||||
|
if (params.orderBy) {
|
||||||
|
selectedOrder.value = JSON.parse(params.orderBy).way;
|
||||||
|
orderByParam.value = JSON.parse(params.orderBy);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectedCategory = computed(() =>
|
const selectedCategory = computed(() =>
|
||||||
|
@ -104,6 +114,14 @@ const applyTagFilter = (params, search) => {
|
||||||
});
|
});
|
||||||
search();
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const orderByParam = ref(null);
|
||||||
|
|
||||||
|
const onOrderChange = (value, params, search) => {
|
||||||
|
const orderBy = Object.assign({}, orderByParam.value, { way: value.way });
|
||||||
|
params.orderBy = JSON.stringify(orderBy);
|
||||||
|
search();
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -131,10 +149,12 @@ const applyTagFilter = (params, search) => {
|
||||||
>
|
>
|
||||||
<template #tags="{ tag, formatFn }">
|
<template #tags="{ tag, formatFn }">
|
||||||
<div v-if="tag.label === 'tagGroups'">
|
<div v-if="tag.label === 'tagGroups'">
|
||||||
<strong>
|
<strong> {{ JSON.parse(tag?.value).tagSelection?.name }}: </strong>
|
||||||
{{ JSON.parse(tag?.value).tagSelection?.name }}:
|
<span>{{
|
||||||
</strong>
|
(JSON.parse(tag?.value).values || [])
|
||||||
<span>{{ (JSON.parse(tag?.value).values || []).map(item => item.value).join(' | ') }}</span>
|
.map((item) => item.value)
|
||||||
|
.join(' | ')
|
||||||
|
}}</span>
|
||||||
</div>
|
</div>
|
||||||
<strong v-else-if="tag.label === 'categoryFk'">
|
<strong v-else-if="tag.label === 'categoryFk'">
|
||||||
{{ t(selectedCategory?.name || '') }}
|
{{ t(selectedCategory?.name || '') }}
|
||||||
|
@ -204,6 +224,26 @@ const applyTagFilter = (params, search) => {
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QSeparator />
|
<QSeparator />
|
||||||
|
<QItem class="q-my-md">
|
||||||
|
<QItemSection>
|
||||||
|
<VnSelectFilter
|
||||||
|
:label="t('params.order')"
|
||||||
|
v-model="selectedOrder"
|
||||||
|
:options="orderList || []"
|
||||||
|
option-value="way"
|
||||||
|
option-label="name"
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
rounded
|
||||||
|
:emit-value="false"
|
||||||
|
use-input
|
||||||
|
@update:model-value="
|
||||||
|
(value) => onOrderChange(value, params, searchFn)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
|
<QSeparator />
|
||||||
<QItem class="q-mt-md">
|
<QItem class="q-mt-md">
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<VnSelectFilter
|
<VnSelectFilter
|
||||||
|
@ -344,12 +384,14 @@ en:
|
||||||
orderBy: Order By
|
orderBy: Order By
|
||||||
tag: Tag
|
tag: Tag
|
||||||
value: Value
|
value: Value
|
||||||
|
order: Order
|
||||||
es:
|
es:
|
||||||
params:
|
params:
|
||||||
type: Tipo
|
type: Tipo
|
||||||
orderBy: Ordenar por
|
orderBy: Ordenar por
|
||||||
tag: Etiqueta
|
tag: Etiqueta
|
||||||
value: Valor
|
value: Valor
|
||||||
|
order: Orden
|
||||||
Plant: Planta
|
Plant: Planta
|
||||||
Flower: Flor
|
Flower: Flor
|
||||||
Handmade: Confección
|
Handmade: Confección
|
||||||
|
|
Loading…
Reference in New Issue