Compare commits
9 Commits
350c28eef0
...
0c3581f3dc
Author | SHA1 | Date |
---|---|---|
Alex Moreno | 0c3581f3dc | |
Javier Segarra | 0434332ec4 | |
Alex Moreno | 44f2ecca28 | |
Alex Moreno | c5acde22a3 | |
Alex Moreno | 42d24359cd | |
Alex Moreno | abd79283ff | |
Alex Moreno | 32fdc836f9 | |
Alex Moreno | e032d5988b | |
Alex Moreno | c2db7be8cd |
|
@ -1,6 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { defineProps } from 'vue';
|
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
routeName: {
|
routeName: {
|
||||||
|
|
|
@ -0,0 +1,145 @@
|
||||||
|
<script setup>
|
||||||
|
import { ref } from 'vue';
|
||||||
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import axios from 'axios';
|
||||||
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
|
|
||||||
|
const props = defineProps({
|
||||||
|
tags: {
|
||||||
|
type: Array,
|
||||||
|
default: () => [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
const emit = defineEmits(['applyTags']);
|
||||||
|
const { t } = useI18n();
|
||||||
|
|
||||||
|
const tagValues = ref([{}]);
|
||||||
|
const tagOptions = ref([]);
|
||||||
|
const selectedTag = ref(null);
|
||||||
|
|
||||||
|
const applyTags = () => {
|
||||||
|
if (tagValues.value.some((tag) => !tag.value)) return;
|
||||||
|
const tagInfo = {
|
||||||
|
values: [...tagValues.value],
|
||||||
|
tagFk: selectedTag?.value?.id,
|
||||||
|
tagSelection: {
|
||||||
|
name: selectedTag?.value?.name,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
emit('applyTags', tagInfo);
|
||||||
|
};
|
||||||
|
|
||||||
|
const getSelectedTagValues = async (tag) => {
|
||||||
|
if (!tag?.id) return;
|
||||||
|
const filter = {
|
||||||
|
fields: ['value'],
|
||||||
|
order: 'value ASC',
|
||||||
|
limit: 30,
|
||||||
|
};
|
||||||
|
|
||||||
|
const url = `Tags/${tag?.id}/filterValue`;
|
||||||
|
const params = { filter: JSON.stringify(filter) };
|
||||||
|
const { data } = await axios.get(url, {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
tagOptions.value = data;
|
||||||
|
};
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<template>
|
||||||
|
<QForm @submit="applyTags()" class="all-pointer-events">
|
||||||
|
<QCard class="q-pa-sm column q-pa-lg">
|
||||||
|
<VnSelect
|
||||||
|
:label="t('params.tag')"
|
||||||
|
v-model="selectedTag"
|
||||||
|
:options="props.tags"
|
||||||
|
option-value="id"
|
||||||
|
option-label="name"
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
class="q-mb-md"
|
||||||
|
rounded
|
||||||
|
:emit-value="false"
|
||||||
|
use-input
|
||||||
|
@update:model-value="getSelectedTagValues"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
v-for="(value, index) in tagValues"
|
||||||
|
:key="value"
|
||||||
|
class="filter-value column align-left"
|
||||||
|
>
|
||||||
|
<div class="col row q-mb-md">
|
||||||
|
<VnSelect
|
||||||
|
v-if="!selectedTag?.isFree && tagOptions"
|
||||||
|
:label="t('components.itemsFilterPanel.value')"
|
||||||
|
v-model="value.value"
|
||||||
|
:options="tagOptions"
|
||||||
|
option-value="value"
|
||||||
|
option-label="value"
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
rounded
|
||||||
|
emit-value
|
||||||
|
use-input
|
||||||
|
:disable="!value || !selectedTag"
|
||||||
|
:is-clearable="false"
|
||||||
|
class="col"
|
||||||
|
/>
|
||||||
|
<VnInput
|
||||||
|
v-else
|
||||||
|
v-model="value.value"
|
||||||
|
:label="t('components.itemsFilterPanel.value')"
|
||||||
|
:disable="!value"
|
||||||
|
is-outlined
|
||||||
|
class="col"
|
||||||
|
/>
|
||||||
|
<QBtn
|
||||||
|
icon="delete"
|
||||||
|
size="md"
|
||||||
|
outlined
|
||||||
|
dense
|
||||||
|
rounded
|
||||||
|
flat
|
||||||
|
class="filter-icon col-2"
|
||||||
|
@click="tagValues.splice(index, 1)"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<QBtn
|
||||||
|
icon="add_circle"
|
||||||
|
shortcut="+"
|
||||||
|
flat
|
||||||
|
class="filter-icon q-mb-md"
|
||||||
|
size="md"
|
||||||
|
dense
|
||||||
|
@click="tagValues.push({})"
|
||||||
|
/>
|
||||||
|
<QBtn
|
||||||
|
color="primary"
|
||||||
|
icon="search"
|
||||||
|
type="submit"
|
||||||
|
:label="$t('globals.search')"
|
||||||
|
/>
|
||||||
|
</QCard>
|
||||||
|
</QForm>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<style scoped lang="scss">
|
||||||
|
.filter-icon {
|
||||||
|
font-size: 24px;
|
||||||
|
color: $primary;
|
||||||
|
padding: 0 4px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<i18n>
|
||||||
|
en:
|
||||||
|
params:
|
||||||
|
tag: Tag
|
||||||
|
es:
|
||||||
|
params:
|
||||||
|
tag: Etiqueta
|
||||||
|
</i18n>
|
|
@ -1,30 +1,58 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute, useRouter } from 'vue-router';
|
||||||
import { onMounted, onUnmounted, ref } from 'vue';
|
import { onBeforeMount, onMounted, onUnmounted, ref, computed, watch } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||||
import CatalogItem from 'components/ui/CatalogItem.vue';
|
import CatalogItem from 'src/components/ui/CatalogItem.vue';
|
||||||
import OrderCatalogFilter from 'pages/Order/Card/OrderCatalogFilter.vue';
|
import OrderCatalogFilter from 'src/pages/Order/Card/OrderCatalogFilter.vue';
|
||||||
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
|
||||||
|
import getParamWhere from 'src/filters/getParamWhere';
|
||||||
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const stateStore = useStateStore();
|
const stateStore = useStateStore();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const dataKey = 'OrderCatalogList';
|
||||||
|
const arrayData = useArrayData(dataKey);
|
||||||
|
const store = arrayData.store;
|
||||||
|
const showFilter = ref(null);
|
||||||
const tags = ref([]);
|
const tags = ref([]);
|
||||||
|
|
||||||
|
let catalogParams = {
|
||||||
|
orderFk: route.params.id,
|
||||||
|
orderBy: JSON.stringify({ field: 'relevancy DESC, name', way: 'ASC', isTag: false }),
|
||||||
|
};
|
||||||
|
|
||||||
|
onBeforeMount(() => {
|
||||||
|
const whereParams = getParamWhere(route);
|
||||||
|
if (whereParams) {
|
||||||
|
const formattedWhereParams = {};
|
||||||
|
if (whereParams.and) {
|
||||||
|
whereParams.and.forEach((item) => {
|
||||||
|
Object.assign(formattedWhereParams, item);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
Object.assign(formattedWhereParams, whereParams);
|
||||||
|
}
|
||||||
|
|
||||||
|
catalogParams = {
|
||||||
|
...catalogParams,
|
||||||
|
...formattedWhereParams,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
showFilter.value = true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
stateStore.rightDrawer = true;
|
stateStore.rightDrawer = true;
|
||||||
checkOrderConfirmation();
|
checkOrderConfirmation();
|
||||||
});
|
});
|
||||||
onUnmounted(() => (stateStore.rightDrawer = false));
|
|
||||||
|
|
||||||
const catalogParams = {
|
onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
orderFk: route.params.id,
|
|
||||||
orderBy: JSON.stringify({ field: 'relevancy DESC, name', way: 'ASC', isTag: false }),
|
|
||||||
};
|
|
||||||
|
|
||||||
async function checkOrderConfirmation() {
|
async function checkOrderConfirmation() {
|
||||||
const response = await axios.get(`Orders/${route.params.id}`);
|
const response = await axios.get(`Orders/${route.params.id}`);
|
||||||
|
@ -34,6 +62,7 @@ async function checkOrderConfirmation() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function extractTags(items) {
|
function extractTags(items) {
|
||||||
|
if (!items || !items.length) return;
|
||||||
const resultTags = [];
|
const resultTags = [];
|
||||||
(items || []).forEach((item) => {
|
(items || []).forEach((item) => {
|
||||||
(item.tags || []).forEach((tag) => {
|
(item.tags || []).forEach((tag) => {
|
||||||
|
@ -61,11 +90,20 @@ function extractValueTags(items) {
|
||||||
);
|
);
|
||||||
tagValue.value = resultValueTags;
|
tagValue.value = resultValueTags;
|
||||||
}
|
}
|
||||||
|
const autoLoad = computed(() => !!catalogParams.categoryFk);
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => store.data,
|
||||||
|
(val) => {
|
||||||
|
extractTags(val);
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnSearchbar
|
<VnSearchbar
|
||||||
data-key="OrderCatalogList"
|
:data-key="dataKey"
|
||||||
:user-params="catalogParams"
|
:user-params="catalogParams"
|
||||||
:static-params="['orderFk', 'orderBy']"
|
:static-params="['orderFk', 'orderBy']"
|
||||||
:redirect="false"
|
:redirect="false"
|
||||||
|
@ -74,23 +112,25 @@ function extractValueTags(items) {
|
||||||
:info="t('You can search items by name or id')"
|
:info="t('You can search items by name or id')"
|
||||||
/>
|
/>
|
||||||
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
|
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
|
||||||
<QScrollArea class="fit text-grey-8">
|
<QScrollArea v-if="showFilter" class="fit text-grey-8">
|
||||||
<OrderCatalogFilter
|
<OrderCatalogFilter
|
||||||
data-key="OrderCatalogList"
|
:data-key="dataKey"
|
||||||
:tag-value="tagValue"
|
:tag-value="tagValue"
|
||||||
:tags="tags"
|
:tags="tags"
|
||||||
|
:initial-catalog-params="catalogParams"
|
||||||
/>
|
/>
|
||||||
</QScrollArea>
|
</QScrollArea>
|
||||||
</QDrawer>
|
</QDrawer>
|
||||||
<QPage class="column items-center q-pa-md">
|
<QPage class="column items-center q-pa-md">
|
||||||
<div class="full-width">
|
<div class="full-width">
|
||||||
<VnPaginate
|
<VnPaginate
|
||||||
data-key="OrderCatalogList"
|
:data-key="dataKey"
|
||||||
url="Orders/CatalogFilter"
|
url="Orders/CatalogFilter"
|
||||||
:limit="50"
|
:limit="50"
|
||||||
:user-params="catalogParams"
|
:user-params="catalogParams"
|
||||||
@on-fetch="extractTags"
|
@on-fetch="showFilter = true"
|
||||||
:update-router="false"
|
:update-router="false"
|
||||||
|
:auto-load="autoLoad"
|
||||||
>
|
>
|
||||||
<template #body="{ rows }">
|
<template #body="{ rows }">
|
||||||
<div class="catalog-list">
|
<div class="catalog-list">
|
||||||
|
@ -102,6 +142,7 @@ function extractValueTags(items) {
|
||||||
:key="row.id"
|
:key="row.id"
|
||||||
:item="row"
|
:item="row"
|
||||||
is-catalog
|
is-catalog
|
||||||
|
class="fill-icon"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref } from 'vue';
|
import { computed, ref, onMounted } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
@ -9,10 +9,9 @@ import VnSelect from 'components/common/VnSelect.vue';
|
||||||
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
|
import VnFilterPanelChip from 'components/ui/VnFilterPanelChip.vue';
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
import VnInput from 'src/components/common/VnInput.vue';
|
||||||
import getParamWhere from 'src/filters/getParamWhere';
|
import getParamWhere from 'src/filters/getParamWhere';
|
||||||
|
import CatalogFilterValueDialog from 'src/pages/Order/Card/CatalogFilterValueDialog.vue';
|
||||||
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
|
|
||||||
const route = useRoute();
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
dataKey: {
|
dataKey: {
|
||||||
type: String,
|
type: String,
|
||||||
|
@ -27,13 +26,19 @@ const props = defineProps({
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const { t } = useI18n();
|
||||||
|
const route = useRoute();
|
||||||
|
|
||||||
|
const arrayData = useArrayData(props.dataKey);
|
||||||
|
|
||||||
|
const currentParams = ref({});
|
||||||
const categoryList = ref(null);
|
const categoryList = ref(null);
|
||||||
const selectedCategoryFk = ref(getParamWhere(route, 'categoryFk'));
|
const selectedCategoryFk = ref(null);
|
||||||
const typeList = ref([]);
|
const typeList = ref([]);
|
||||||
const selectedTypeFk = ref(null);
|
const selectedTypeFk = ref(null);
|
||||||
const selectedTag = ref(null);
|
const searchByTag = ref(null);
|
||||||
const tagValues = ref([{}]);
|
|
||||||
const tagOptions = ref([]);
|
|
||||||
const vnFilterPanelRef = ref();
|
const vnFilterPanelRef = ref();
|
||||||
const orderByList = ref([
|
const orderByList = ref([
|
||||||
{ id: 'relevancy DESC, name', name: t('params.relevancy'), priority: 999 },
|
{ id: 'relevancy DESC, name', name: t('params.relevancy'), priority: 999 },
|
||||||
|
@ -48,34 +53,30 @@ const orderWayList = ref([
|
||||||
const orderBySelected = ref('relevancy DESC, name');
|
const orderBySelected = ref('relevancy DESC, name');
|
||||||
const orderWaySelected = ref('ASC');
|
const orderWaySelected = ref('ASC');
|
||||||
|
|
||||||
const createValue = (val, done) => {
|
onMounted(() => {
|
||||||
if (val.length > 2) {
|
selectedCategoryFk.value = getParamWhere(route, 'categoryFk');
|
||||||
if (!tagOptions.value.includes(val)) {
|
selectedTypeFk.value = getParamWhere(route, 'typeFk');
|
||||||
done(tagOptions.value, 'add-unique');
|
});
|
||||||
}
|
|
||||||
tagValues.value.push({ value: val });
|
const resetCategory = (params, search) => {
|
||||||
}
|
|
||||||
};
|
|
||||||
const resetCategory = () => {
|
|
||||||
selectedCategoryFk.value = null;
|
selectedCategoryFk.value = null;
|
||||||
typeList.value = null;
|
typeList.value = null;
|
||||||
};
|
params.categoryFk = null;
|
||||||
|
params.typeFk = null;
|
||||||
const clearFilter = (key) => {
|
arrayData.store.userFilter = null;
|
||||||
if (key === 'categoryFk') {
|
removeTagGroupParam(search);
|
||||||
resetCategory();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectCategory = (params, category, search) => {
|
const selectCategory = (params, category, search) => {
|
||||||
if (params.categoryFk === category?.id) {
|
if (params.categoryFk === category?.id) {
|
||||||
resetCategory();
|
resetCategory(params, search);
|
||||||
params.categoryFk = null;
|
return;
|
||||||
} else {
|
}
|
||||||
selectedCategoryFk.value = category?.id;
|
selectedCategoryFk.value = category?.id;
|
||||||
params.categoryFk = category?.id;
|
params.categoryFk = category?.id;
|
||||||
|
params.typeFk = null;
|
||||||
|
selectedTypeFk.value = null;
|
||||||
loadTypes(category?.id);
|
loadTypes(category?.id);
|
||||||
}
|
|
||||||
search();
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -86,19 +87,12 @@ const loadTypes = async (categoryFk = selectedCategoryFk.value) => {
|
||||||
typeList.value = data;
|
typeList.value = data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectedCategory = computed(() =>
|
const selectedCategory = computed(() => {
|
||||||
(categoryList.value || []).find(
|
return (categoryList.value || []).find(
|
||||||
(category) => category?.id === selectedCategoryFk.value
|
(category) => category?.id === selectedCategoryFk.value
|
||||||
)
|
|
||||||
);
|
|
||||||
function filterFn(val, update) {
|
|
||||||
update(() => {
|
|
||||||
const needle = val.toLowerCase();
|
|
||||||
tagOptions.value = props.tagValue.filter(
|
|
||||||
(v) => v.toLowerCase().indexOf(needle) > -1
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
const selectedType = computed(() => {
|
const selectedType = computed(() => {
|
||||||
return (typeList.value || []).find((type) => type?.id === selectedTypeFk.value);
|
return (typeList.value || []).find((type) => type?.id === selectedTypeFk.value);
|
||||||
});
|
});
|
||||||
|
@ -114,35 +108,35 @@ function exprBuilder(param, value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const applyTagFilter = (params, search) => {
|
const applyTags = (tagInfo, params, search) => {
|
||||||
if (!tagValues.value?.length) {
|
if (!tagInfo || !tagInfo.values.length) {
|
||||||
params.tagGroups = null;
|
params.tagGroups = null;
|
||||||
search();
|
search();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!params.tagGroups) {
|
|
||||||
params.tagGroups = [];
|
if (!params.tagGroups) params.tagGroups = [];
|
||||||
}
|
params.tagGroups.push(tagInfo);
|
||||||
params.tagGroups.push(
|
|
||||||
JSON.stringify({
|
|
||||||
values: tagValues.value.filter((obj) => Object.keys(obj).length > 0),
|
|
||||||
tagSelection: {
|
|
||||||
...selectedTag.value,
|
|
||||||
orgShowField: selectedTag?.value?.name,
|
|
||||||
},
|
|
||||||
tagFk: selectedTag?.value?.tagFk,
|
|
||||||
})
|
|
||||||
);
|
|
||||||
search();
|
search();
|
||||||
selectedTag.value = null;
|
|
||||||
tagValues.value = [{}];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const removeTagChip = (selection, params, search) => {
|
async function onSearchByTag(value) {
|
||||||
if (params.tagGroups) {
|
if (!value.target.value) return;
|
||||||
params.tagGroups = (params.tagGroups || []).filter(
|
if (!currentParams.value?.tagGroups) {
|
||||||
(value) => value !== selection
|
currentParams.value.tagGroups = [];
|
||||||
);
|
}
|
||||||
|
|
||||||
|
currentParams.value.tagGroups.push({
|
||||||
|
values: [{ value: value.target.value }],
|
||||||
|
});
|
||||||
|
searchByTag.value = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const removeTagGroupParam = (search, valIndex) => {
|
||||||
|
if (!valIndex && valIndex !== 0) {
|
||||||
|
currentParams.value.tagGroups = null;
|
||||||
|
} else {
|
||||||
|
currentParams.value.tagGroups.splice(valIndex, 1);
|
||||||
}
|
}
|
||||||
search();
|
search();
|
||||||
};
|
};
|
||||||
|
@ -164,6 +158,12 @@ const getCategoryClass = (category, params) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const clearFilter = (key) => {
|
||||||
|
if (key === 'categoryFk') {
|
||||||
|
resetCategory();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
function addOrder(value, field, params) {
|
function addOrder(value, field, params) {
|
||||||
let { orderBy } = params;
|
let { orderBy } = params;
|
||||||
orderBy = JSON.parse(orderBy);
|
orderBy = JSON.parse(orderBy);
|
||||||
|
@ -174,23 +174,20 @@ function addOrder(value, field, params) {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData url="ItemCategories" limit="30" auto-load @on-fetch="setCategoryList" />
|
<FetchData url="ItemCategories" auto-load @on-fetch="setCategoryList" />
|
||||||
<VnFilterPanel
|
<VnFilterPanel
|
||||||
ref="vnFilterPanelRef"
|
ref="vnFilterPanelRef"
|
||||||
:data-key="props.dataKey"
|
:data-key="props.dataKey"
|
||||||
:hidden-tags="['orderFk', 'orderBy']"
|
:hidden-tags="['orderFk', 'orderBy']"
|
||||||
:un-removable-params="['orderFk', 'orderBy']"
|
:un-removable-params="['orderFk', 'orderBy']"
|
||||||
:expr-builder="exprBuilder"
|
:expr-builder="exprBuilder"
|
||||||
:custom-tags="['tagGroups']"
|
:custom-tags="['tagGroups', 'categoryFk']"
|
||||||
@remove="clearFilter"
|
|
||||||
:redirect="false"
|
:redirect="false"
|
||||||
search-url="params"
|
@remove="clearFilter"
|
||||||
|
v-model="currentParams"
|
||||||
>
|
>
|
||||||
<template #tags="{ tag, formatFn }">
|
<template #tags="{ tag, formatFn }">
|
||||||
<strong v-if="tag.label === 'categoryFk'">
|
<strong v-if="tag.label === 'typeFk'">
|
||||||
{{ t(selectedCategory?.name || '') }}
|
|
||||||
</strong>
|
|
||||||
<strong v-else-if="tag.label === 'typeFk'">
|
|
||||||
{{ t(selectedType?.name || '') }}
|
{{ t(selectedType?.name || '') }}
|
||||||
</strong>
|
</strong>
|
||||||
<div v-else class="q-gutter-x-xs">
|
<div v-else class="q-gutter-x-xs">
|
||||||
|
@ -199,24 +196,35 @@ function addOrder(value, field, params) {
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #customTags="{ tags: customTags, params, searchFn }">
|
<template #customTags="{ tags: customTags, params, searchFn }">
|
||||||
<template v-for="tag in customTags" :key="tag.label">
|
<template v-for="customTag in customTags" :key="customTag.label">
|
||||||
<template v-if="tag.label === 'tagGroups'">
|
|
||||||
<VnFilterPanelChip
|
<VnFilterPanelChip
|
||||||
v-for="chip in tag.value"
|
v-for="(tag, valIndex) in Array.isArray(customTag.value)
|
||||||
:key="chip"
|
? customTag.value
|
||||||
|
: 1"
|
||||||
|
:key="valIndex"
|
||||||
removable
|
removable
|
||||||
@remove="removeTagChip(chip, params, searchFn)"
|
@remove="
|
||||||
|
customTag.label === 'categoryFk'
|
||||||
|
? resetCategory(params, searchFn)
|
||||||
|
: removeTagGroupParam(searchFn, valIndex)
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<strong> {{ JSON.parse(chip).tagSelection?.name }}: </strong>
|
<strong v-if="customTag.label === 'categoryFk'">
|
||||||
<span>{{
|
{{ t(selectedCategory?.name || '') }}
|
||||||
(JSON.parse(chip).values || [])
|
</strong>
|
||||||
.map((item) => item.value)
|
<strong v-if="tag?.tagSelection?.name" class="q-mr-xs">
|
||||||
.join(' | ')
|
{{ tag.tagSelection.name }}:
|
||||||
}}</span>
|
</strong>
|
||||||
|
<span>
|
||||||
|
{{
|
||||||
|
(tag?.values || [])
|
||||||
|
.map((item) => `"${item.value}"`)
|
||||||
|
.join(', ')
|
||||||
|
}}
|
||||||
|
</span>
|
||||||
</VnFilterPanelChip>
|
</VnFilterPanelChip>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
</template>
|
||||||
</template>
|
|
||||||
<template #body="{ params, searchFn }">
|
<template #body="{ params, searchFn }">
|
||||||
<QItem class="category-filter q-mt-md">
|
<QItem class="category-filter q-mt-md">
|
||||||
<div
|
<div
|
||||||
|
@ -298,91 +306,39 @@ function addOrder(value, field, params) {
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QSeparator />
|
<QSeparator />
|
||||||
<QItem class="q-mt-md">
|
<QItem class="q-mt-lg q-pa-none">
|
||||||
<QItemSection>
|
|
||||||
<VnSelect
|
|
||||||
:label="t('params.tag')"
|
|
||||||
v-model="selectedTag"
|
|
||||||
:options="props.tags || []"
|
|
||||||
option-value="id"
|
|
||||||
option-label="name"
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
rounded
|
|
||||||
:emit-value="false"
|
|
||||||
use-input
|
|
||||||
/>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
<QItem
|
|
||||||
v-for="(value, index) in tagValues"
|
|
||||||
:key="value"
|
|
||||||
class="q-mt-md filter-value"
|
|
||||||
>
|
|
||||||
<FetchData
|
|
||||||
v-if="selectedTag"
|
|
||||||
:url="`Tags/${selectedTag}/filterValue`"
|
|
||||||
limit="30"
|
|
||||||
auto-load
|
|
||||||
@on-fetch="(data) => (tagOptions = data)"
|
|
||||||
/>
|
|
||||||
<VnSelect
|
|
||||||
v-if="!selectedTag"
|
|
||||||
:label="t('params.value')"
|
|
||||||
v-model="value.value"
|
|
||||||
:options="tagOptions || []"
|
|
||||||
option-value="value"
|
|
||||||
option-label="value"
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
rounded
|
|
||||||
emit-value
|
|
||||||
use-input
|
|
||||||
class="filter-input"
|
|
||||||
@new-value="createValue"
|
|
||||||
@filter="filterFn"
|
|
||||||
@update:model-value="applyTagFilter(params, searchFn)"
|
|
||||||
/>
|
|
||||||
<VnSelect
|
|
||||||
v-else-if="selectedTag === 1"
|
|
||||||
:label="t('params.value')"
|
|
||||||
v-model="value.value"
|
|
||||||
:options="tagOptions || []"
|
|
||||||
option-value="value"
|
|
||||||
option-label="value"
|
|
||||||
dense
|
|
||||||
outlined
|
|
||||||
rounded
|
|
||||||
emit-value
|
|
||||||
use-input
|
|
||||||
class="filter-input"
|
|
||||||
@new-value="createValue"
|
|
||||||
@update:model-value="applyTagFilter(params, searchFn)"
|
|
||||||
/>
|
|
||||||
<VnInput
|
<VnInput
|
||||||
v-else
|
:label="t('components.itemsFilterPanel.value')"
|
||||||
:label="t('params.value')"
|
|
||||||
v-model="value.value"
|
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
rounded
|
rounded
|
||||||
class="filter-input"
|
:is-clearable="false"
|
||||||
@keyup.enter="applyTagFilter(params, searchFn)"
|
v-model="searchByTag"
|
||||||
/>
|
@keyup.enter="(val) => onSearchByTag(val, params)"
|
||||||
<QIcon
|
>
|
||||||
name="delete"
|
<template #prepend>
|
||||||
class="filter-icon"
|
<QIcon name="search" />
|
||||||
@click="(tagValues || []).splice(index, 1)"
|
</template>
|
||||||
/>
|
<template #append>
|
||||||
</QItem>
|
|
||||||
<QItem class="q-mt-lg">
|
|
||||||
<QBtn
|
<QBtn
|
||||||
icon="add_circle"
|
icon="add_circle"
|
||||||
shortcut="+"
|
shortcut="+"
|
||||||
flat
|
flat
|
||||||
class="filter-icon"
|
color="primary"
|
||||||
@click="tagValues.push({})"
|
size="md"
|
||||||
|
dense
|
||||||
/>
|
/>
|
||||||
|
<QPopupProxy>
|
||||||
|
<CatalogFilterValueDialog
|
||||||
|
style="display: inline-block"
|
||||||
|
:tags="tags"
|
||||||
|
@apply-tags="
|
||||||
|
($event) => applyTags($event, currentParams, searchFn)
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</QPopupProxy>
|
||||||
|
</template>
|
||||||
|
</VnInput>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QSeparator />
|
<QSeparator />
|
||||||
</template>
|
</template>
|
||||||
|
@ -417,23 +373,6 @@ function addOrder(value, field, params) {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.filter-icon {
|
|
||||||
font-size: 24px;
|
|
||||||
color: $primary;
|
|
||||||
padding: 0 4px;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-input {
|
|
||||||
flex-shrink: 1;
|
|
||||||
min-width: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.filter-value {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<i18n>
|
<i18n>
|
||||||
|
|
Loading…
Reference in New Issue