diff --git a/src/pages/Order/Card/OrderCatalog.vue b/src/pages/Order/Card/OrderCatalog.vue
index 9fee29d7d..a266fc3d4 100644
--- a/src/pages/Order/Card/OrderCatalog.vue
+++ b/src/pages/Order/Card/OrderCatalog.vue
@@ -1,7 +1,7 @@
@@ -95,7 +111,7 @@ const autoLoad = computed(() => !!catalogParams.categoryFk);
:info="t('You can search items by name or id')"
/>
-
+
!!catalogParams.categoryFk);
url="Orders/CatalogFilter"
:limit="50"
:user-params="catalogParams"
- @on-fetch="extractTags"
+ @on-fetch="showFilter = true"
:update-router="false"
:auto-load="autoLoad"
>
diff --git a/src/pages/Order/Card/OrderCatalogFilter.vue b/src/pages/Order/Card/OrderCatalogFilter.vue
index cc3f45391..5612399d7 100644
--- a/src/pages/Order/Card/OrderCatalogFilter.vue
+++ b/src/pages/Order/Card/OrderCatalogFilter.vue
@@ -26,11 +26,8 @@ const props = defineProps({
type: Array,
required: true,
},
- initialCatalogParams: {
- type: Object,
- default: () => ({}),
- },
});
+
const categoryList = ref(null);
const selectedCategoryFk = ref(null);
const typeList = ref([]);
@@ -52,14 +49,6 @@ const orderWayList = ref([
const orderBySelected = ref('relevancy DESC, name');
const orderWaySelected = ref('ASC');
-const createValue = (val, done) => {
- if (val.length > 2) {
- if (!tagOptions.value.includes(val)) {
- done(tagOptions.value, 'add-unique');
- }
- tagValues.value.push({ value: val });
- }
-};
const resetCategory = () => {
selectedCategoryFk.value = null;
typeList.value = null;
@@ -97,14 +86,7 @@ const selectedCategory = computed(() => {
(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(() => {
return (typeList.value || []).find((type) => type?.id === selectedTypeFk.value);
});
@@ -120,36 +102,36 @@ function exprBuilder(param, value) {
}
}
-const applyTagFilter = (params, search) => {
+const applyTags = (params, search) => {
if (!tagValues.value?.length) {
params.tagGroups = null;
search();
return;
}
- if (!params.tagGroups) {
- params.tagGroups = [];
- }
- 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,
- })
- );
+
+ const tagGroups = {
+ values: [...tagValues.value],
+ tagFk: selectedTag?.value?.id,
+ tagSelection: {
+ name: selectedTag?.value?.name,
+ },
+ };
+
+ params.tagGroups = tagGroups;
search();
- selectedTag.value = null;
- tagValues.value = [{}];
};
-const removeTagChip = (selection, params, search) => {
- if (params.tagGroups) {
- params.tagGroups = (params.tagGroups || []).filter(
- (value) => value !== selection
- );
+const removeTagGroupParam = (params, search, valIndex = null) => {
+ if (!params.tagGroups) return;
+
+ if (!valIndex) {
+ params.tagGroups = null;
+ tagValues.value = [{}];
+ } else {
+ (tagValues.value || []).splice(valIndex, 1);
+ params.tagGroups.values.splice(valIndex, 1);
}
+
search();
};
@@ -178,9 +160,37 @@ function addOrder(value, field, params) {
vnFilterPanelRef.value.search();
}
+const getSelectedTagValues = async (tag) => {
+ try {
+ if (!tag?.id) return;
+ const filter = {
+ fields: ['value'],
+ order: 'value ASC',
+ limit: 30,
+ };
+
+ const url = `Tags/${tag?.id}/filterValue`;
+ console.log('url', url);
+ const params = { filter: JSON.stringify(filter) };
+ const { data } = await axios.get(url, {
+ params,
+ });
+ tagOptions.value = data;
+ } catch (err) {
+ console.error('Error getting selected tag values');
+ }
+};
+
onMounted(() => {
selectedCategoryFk.value = getParamWhere(route, 'categoryFk');
selectedTypeFk.value = getParamWhere(route, 'typeFk');
+ if (route.query.params && JSON.parse(route.query.params).tagGroups) {
+ const tagGroups = JSON.parse(route.query.params).tagGroups;
+ tagValues.value = [...tagGroups.values];
+ selectedTag.value = (props.tags || []).find(
+ (tag) => tag.name === tagGroups.tagSelection.name
+ );
+ }
});
@@ -212,19 +222,19 @@ onMounted(() => {
- {{ chip }}
-
- {{ JSON.parse(chip).tagSelection?.name }}:
- {{
- (JSON.parse(chip).values || [])
- .map((item) => item.value)
- .join(' | ')
- }}
+
+ {{ tag.value?.tagSelection?.name }}:
+
+
+ {{
+ (tag.value?.values || [])
+ .map((item) => `"${item.value}"`)
+ .join(', ')
+ }}
+
@@ -323,6 +333,7 @@ onMounted(() => {
rounded
:emit-value="false"
use-input
+ @update:model-value="($event) => getSelectedTagValues($event)"
/>
@@ -331,16 +342,9 @@ onMounted(() => {
:key="value"
class="q-mt-md filter-value"
>
- (tagOptions = data)"
- />
{
rounded
emit-value
use-input
- class="filter-input"
- @new-value="createValue"
- @filter="filterFn"
- @update:model-value="applyTagFilter(params, searchFn)"
- />
-
@@ -393,11 +379,11 @@ onMounted(() => {
shortcut="+"
flat
class="filter-icon"
+ size="md"
@click="tagValues.push({})"
/>
- {{ params }}