Compare commits
No commits in common. "518ed40c910910a75f7ff71efc80365f336cd619" and "8a972507a430e05e901e87d6c72f897591dfeb88" have entirely different histories.
518ed40c91
...
8a972507a4
|
@ -1,5 +1,6 @@
|
||||||
<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: {
|
||||||
|
|
|
@ -1,145 +0,0 @@
|
||||||
<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,59 +1,31 @@
|
||||||
<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 { onBeforeMount, onMounted, onUnmounted, ref, computed, watch } from 'vue';
|
import { onMounted, onUnmounted, ref } from 'vue';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||||
import CatalogItem from 'src/components/ui/CatalogItem.vue';
|
import CatalogItem from 'components/ui/CatalogItem.vue';
|
||||||
import OrderCatalogFilter from 'src/pages/Order/Card/OrderCatalogFilter.vue';
|
import OrderCatalogFilter from '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));
|
onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
|
|
||||||
|
const catalogParams = {
|
||||||
|
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}`);
|
||||||
if (response.data.isConfirmed === 1) {
|
if (response.data.isConfirmed === 1) {
|
||||||
|
@ -62,7 +34,6 @@ 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) => {
|
||||||
|
@ -90,20 +61,11 @@ 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="dataKey"
|
data-key="OrderCatalogList"
|
||||||
:user-params="catalogParams"
|
:user-params="catalogParams"
|
||||||
:static-params="['orderFk', 'orderBy']"
|
:static-params="['orderFk', 'orderBy']"
|
||||||
:redirect="false"
|
:redirect="false"
|
||||||
|
@ -112,25 +74,23 @@ watch(
|
||||||
: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 v-if="showFilter" class="fit text-grey-8">
|
<QScrollArea class="fit text-grey-8">
|
||||||
<OrderCatalogFilter
|
<OrderCatalogFilter
|
||||||
:data-key="dataKey"
|
data-key="OrderCatalogList"
|
||||||
: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="dataKey"
|
data-key="OrderCatalogList"
|
||||||
url="Orders/CatalogFilter"
|
url="Orders/CatalogFilter"
|
||||||
:limit="50"
|
:limit="50"
|
||||||
:user-params="catalogParams"
|
:user-params="catalogParams"
|
||||||
@on-fetch="showFilter = true"
|
@on-fetch="extractTags"
|
||||||
:update-router="false"
|
:update-router="false"
|
||||||
:auto-load="autoLoad"
|
|
||||||
>
|
>
|
||||||
<template #body="{ rows }">
|
<template #body="{ rows }">
|
||||||
<div class="catalog-list">
|
<div class="catalog-list">
|
||||||
|
@ -142,7 +102,6 @@ watch(
|
||||||
: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, onMounted } from 'vue';
|
import { computed, ref } 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,9 +9,10 @@ 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,
|
||||||
|
@ -26,19 +27,13 @@ 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(null);
|
const selectedCategoryFk = ref(getParamWhere(route, 'categoryFk'));
|
||||||
const typeList = ref([]);
|
const typeList = ref([]);
|
||||||
const selectedTypeFk = ref(null);
|
const selectedTypeFk = ref(null);
|
||||||
const searchByTag = ref(null);
|
const selectedTag = 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 },
|
||||||
|
@ -53,30 +48,34 @@ const orderWayList = ref([
|
||||||
const orderBySelected = ref('relevancy DESC, name');
|
const orderBySelected = ref('relevancy DESC, name');
|
||||||
const orderWaySelected = ref('ASC');
|
const orderWaySelected = ref('ASC');
|
||||||
|
|
||||||
onMounted(() => {
|
const createValue = (val, done) => {
|
||||||
selectedCategoryFk.value = getParamWhere(route, 'categoryFk');
|
if (val.length > 2) {
|
||||||
selectedTypeFk.value = getParamWhere(route, 'typeFk');
|
if (!tagOptions.value.includes(val)) {
|
||||||
});
|
done(tagOptions.value, 'add-unique');
|
||||||
|
}
|
||||||
const resetCategory = (params, search) => {
|
tagValues.value.push({ value: val });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const resetCategory = () => {
|
||||||
selectedCategoryFk.value = null;
|
selectedCategoryFk.value = null;
|
||||||
typeList.value = null;
|
typeList.value = null;
|
||||||
params.categoryFk = null;
|
};
|
||||||
params.typeFk = null;
|
|
||||||
arrayData.store.userFilter = null;
|
const clearFilter = (key) => {
|
||||||
removeTagGroupParam(search);
|
if (key === 'categoryFk') {
|
||||||
|
resetCategory();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectCategory = (params, category, search) => {
|
const selectCategory = (params, category, search) => {
|
||||||
if (params.categoryFk === category?.id) {
|
if (params.categoryFk === category?.id) {
|
||||||
resetCategory(params, search);
|
resetCategory();
|
||||||
return;
|
params.categoryFk = null;
|
||||||
}
|
} 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();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -87,12 +86,19 @@ const loadTypes = async (categoryFk = selectedCategoryFk.value) => {
|
||||||
typeList.value = data;
|
typeList.value = data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectedCategory = computed(() => {
|
const selectedCategory = computed(() =>
|
||||||
return (categoryList.value || []).find(
|
(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);
|
||||||
});
|
});
|
||||||
|
@ -108,35 +114,35 @@ function exprBuilder(param, value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const applyTags = (tagInfo, params, search) => {
|
const applyTagFilter = (params, search) => {
|
||||||
if (!tagInfo || !tagInfo.values.length) {
|
if (!tagValues.value?.length) {
|
||||||
params.tagGroups = null;
|
params.tagGroups = null;
|
||||||
search();
|
search();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!params.tagGroups) {
|
||||||
if (!params.tagGroups) 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 = [{}];
|
||||||
};
|
};
|
||||||
|
|
||||||
async function onSearchByTag(value) {
|
const removeTagChip = (selection, params, search) => {
|
||||||
if (!value.target.value) return;
|
if (params.tagGroups) {
|
||||||
if (!currentParams.value?.tagGroups) {
|
params.tagGroups = (params.tagGroups || []).filter(
|
||||||
currentParams.value.tagGroups = [];
|
(value) => value !== selection
|
||||||
}
|
);
|
||||||
|
|
||||||
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();
|
||||||
};
|
};
|
||||||
|
@ -158,12 +164,6 @@ 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,20 +174,23 @@ function addOrder(value, field, params) {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData url="ItemCategories" auto-load @on-fetch="setCategoryList" />
|
<FetchData url="ItemCategories" limit="30" 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', 'categoryFk']"
|
:custom-tags="['tagGroups']"
|
||||||
:redirect="false"
|
|
||||||
@remove="clearFilter"
|
@remove="clearFilter"
|
||||||
v-model="currentParams"
|
:redirect="false"
|
||||||
|
search-url="params"
|
||||||
>
|
>
|
||||||
<template #tags="{ tag, formatFn }">
|
<template #tags="{ tag, formatFn }">
|
||||||
<strong v-if="tag.label === 'typeFk'">
|
<strong v-if="tag.label === 'categoryFk'">
|
||||||
|
{{ 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">
|
||||||
|
@ -196,35 +199,24 @@ function addOrder(value, field, params) {
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #customTags="{ tags: customTags, params, searchFn }">
|
<template #customTags="{ tags: customTags, params, searchFn }">
|
||||||
<template v-for="customTag in customTags" :key="customTag.label">
|
<template v-for="tag in customTags" :key="tag.label">
|
||||||
|
<template v-if="tag.label === 'tagGroups'">
|
||||||
<VnFilterPanelChip
|
<VnFilterPanelChip
|
||||||
v-for="(tag, valIndex) in Array.isArray(customTag.value)
|
v-for="chip in tag.value"
|
||||||
? customTag.value
|
:key="chip"
|
||||||
: 1"
|
|
||||||
:key="valIndex"
|
|
||||||
removable
|
removable
|
||||||
@remove="
|
@remove="removeTagChip(chip, params, searchFn)"
|
||||||
customTag.label === 'categoryFk'
|
|
||||||
? resetCategory(params, searchFn)
|
|
||||||
: removeTagGroupParam(searchFn, valIndex)
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<strong v-if="customTag.label === 'categoryFk'">
|
<strong> {{ JSON.parse(chip).tagSelection?.name }}: </strong>
|
||||||
{{ t(selectedCategory?.name || '') }}
|
<span>{{
|
||||||
</strong>
|
(JSON.parse(chip).values || [])
|
||||||
<strong v-if="tag?.tagSelection?.name" class="q-mr-xs">
|
.map((item) => item.value)
|
||||||
{{ tag.tagSelection.name }}:
|
.join(' | ')
|
||||||
</strong>
|
}}</span>
|
||||||
<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
|
||||||
|
@ -306,39 +298,91 @@ function addOrder(value, field, params) {
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QSeparator />
|
<QSeparator />
|
||||||
<QItem class="q-mt-lg q-pa-none">
|
<QItem class="q-mt-md">
|
||||||
<VnInput
|
<QItemSection>
|
||||||
:label="t('components.itemsFilterPanel.value')"
|
<VnSelect
|
||||||
|
:label="t('params.tag')"
|
||||||
|
v-model="selectedTag"
|
||||||
|
:options="props.tags || []"
|
||||||
|
option-value="id"
|
||||||
|
option-label="name"
|
||||||
dense
|
dense
|
||||||
outlined
|
outlined
|
||||||
rounded
|
rounded
|
||||||
:is-clearable="false"
|
:emit-value="false"
|
||||||
v-model="searchByTag"
|
use-input
|
||||||
@keyup.enter="(val) => onSearchByTag(val, params)"
|
/>
|
||||||
|
</QItemSection>
|
||||||
|
</QItem>
|
||||||
|
<QItem
|
||||||
|
v-for="(value, index) in tagValues"
|
||||||
|
:key="value"
|
||||||
|
class="q-mt-md filter-value"
|
||||||
>
|
>
|
||||||
<template #prepend>
|
<FetchData
|
||||||
<QIcon name="search" />
|
v-if="selectedTag"
|
||||||
</template>
|
:url="`Tags/${selectedTag}/filterValue`"
|
||||||
<template #append>
|
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
|
||||||
|
v-else
|
||||||
|
:label="t('params.value')"
|
||||||
|
v-model="value.value"
|
||||||
|
dense
|
||||||
|
outlined
|
||||||
|
rounded
|
||||||
|
class="filter-input"
|
||||||
|
@keyup.enter="applyTagFilter(params, searchFn)"
|
||||||
|
/>
|
||||||
|
<QIcon
|
||||||
|
name="delete"
|
||||||
|
class="filter-icon"
|
||||||
|
@click="(tagValues || []).splice(index, 1)"
|
||||||
|
/>
|
||||||
|
</QItem>
|
||||||
|
<QItem class="q-mt-lg">
|
||||||
<QBtn
|
<QBtn
|
||||||
icon="add_circle"
|
icon="add_circle"
|
||||||
shortcut="+"
|
shortcut="+"
|
||||||
flat
|
flat
|
||||||
color="primary"
|
class="filter-icon"
|
||||||
size="md"
|
@click="tagValues.push({})"
|
||||||
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>
|
||||||
|
@ -373,6 +417,23 @@ 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>
|
||||||
|
|
|
@ -24,6 +24,7 @@ function notIsLocations(ifIsFalse, ifIsTrue) {
|
||||||
:descriptor="ZoneDescriptor"
|
:descriptor="ZoneDescriptor"
|
||||||
:filter-panel="notIsLocations(ZoneFilterPanel, undefined)"
|
:filter-panel="notIsLocations(ZoneFilterPanel, undefined)"
|
||||||
:search-data-key="notIsLocations('ZoneList', undefined)"
|
:search-data-key="notIsLocations('ZoneList', undefined)"
|
||||||
|
:custom-url="`Zones/${route.params?.id}/getLeaves`"
|
||||||
:searchbar-props="{
|
:searchbar-props="{
|
||||||
url: notIsLocations('Zones', 'ZoneLocations'),
|
url: notIsLocations('Zones', 'ZoneLocations'),
|
||||||
label: notIsLocations(t('list.searchZone'), t('list.searchLocation')),
|
label: notIsLocations(t('list.searchZone'), t('list.searchLocation')),
|
||||||
|
|
|
@ -39,7 +39,8 @@ const url = computed(() => `Zones/${route.params.id}/getLeaves`);
|
||||||
const arrayData = useArrayData(datakey, {
|
const arrayData = useArrayData(datakey, {
|
||||||
url: url.value,
|
url: url.value,
|
||||||
});
|
});
|
||||||
const store = arrayData.store;
|
const { store } = arrayData;
|
||||||
|
const storeData = computed(() => store.data);
|
||||||
|
|
||||||
const defaultNode = {
|
const defaultNode = {
|
||||||
id: null,
|
id: null,
|
||||||
|
@ -65,20 +66,8 @@ const onNodeExpanded = async (nodeKeysArray) => {
|
||||||
if (!nodeKeysSet.has(null)) return;
|
if (!nodeKeysSet.has(null)) return;
|
||||||
|
|
||||||
const wasExpanded = !previousExpandedNodes.value.has(lastNodeKey);
|
const wasExpanded = !previousExpandedNodes.value.has(lastNodeKey);
|
||||||
if (wasExpanded && treeRef.value) {
|
if (wasExpanded) await fetchNodeLeaves(lastNodeKey);
|
||||||
const node = treeRef.value?.getNodeByKey(lastNodeKey);
|
else {
|
||||||
const params = { parentId: node.id };
|
|
||||||
const response = await axios.get(`Zones/${route.params.id}/getLeaves`, {
|
|
||||||
params,
|
|
||||||
});
|
|
||||||
if (response.data) {
|
|
||||||
node.childs = response.data.map((n) => {
|
|
||||||
if (n.sons > 0) n.childs = [{}];
|
|
||||||
return n;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
await fetchNodeLeaves(lastNodeKey, true);
|
|
||||||
} else {
|
|
||||||
const difference = new Set(
|
const difference = new Set(
|
||||||
[...previousExpandedNodes.value].filter((x) => !nodeKeysSet.has(x))
|
[...previousExpandedNodes.value].filter((x) => !nodeKeysSet.has(x))
|
||||||
);
|
);
|
||||||
|
@ -94,21 +83,41 @@ const formatNodeSelected = (node) => {
|
||||||
if (node.selected === 1) node.selected = true;
|
if (node.selected === 1) node.selected = true;
|
||||||
else if (node.selected === 0) node.selected = false;
|
else if (node.selected === 0) node.selected = false;
|
||||||
|
|
||||||
|
if (node.childs && node.childs.length > 0) {
|
||||||
|
expanded.value.push(node.id);
|
||||||
|
|
||||||
|
node.childs.forEach((childNode) => {
|
||||||
|
formatNodeSelected(childNode);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (node.sons > 0 && !node.childs) node.childs = [{}];
|
if (node.sons > 0 && !node.childs) node.childs = [{}];
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchNodeLeaves = async (nodeKey) => {
|
const fetchNodeLeaves = async (nodeKey) => {
|
||||||
if (!treeRef.value) return;
|
try {
|
||||||
const node = treeRef.value?.getNodeByKey(nodeKey);
|
const node = treeRef.value?.getNodeByKey(nodeKey);
|
||||||
if (node.selected === 1) node.selected = true;
|
|
||||||
else if (node.selected === 0) node.selected = false;
|
|
||||||
if (!node || node.sons === 0) return;
|
if (!node || node.sons === 0) return;
|
||||||
|
|
||||||
|
const params = { parentId: node.id };
|
||||||
|
const response = await axios.get(`Zones/${route.params.id}/getLeaves`, {
|
||||||
|
params,
|
||||||
|
});
|
||||||
|
if (response.data) {
|
||||||
|
node.childs = response.data.map((n) => {
|
||||||
|
formatNodeSelected(n);
|
||||||
|
return n;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
state.set('Tree', node);
|
state.set('Tree', node);
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching department leaves', err);
|
||||||
|
throw new Error();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
function getNodeIds(node) {
|
function getNodeIds(node) {
|
||||||
if (!node) return [];
|
|
||||||
let ids = [];
|
let ids = [];
|
||||||
if (node.id) ids.push(node.id);
|
if (node.id) ids.push(node.id);
|
||||||
|
|
||||||
|
@ -119,46 +128,60 @@ function getNodeIds(node) {
|
||||||
return ids;
|
return ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(storeData, async (val) => {
|
||||||
() => store.data,
|
// Se triggerea cuando se actualiza el store.data, el cual es el resultado del fetch de la searchbar
|
||||||
async (val) => {
|
|
||||||
if (!val) return;
|
|
||||||
// // Se triggerea cuando se actualiza el store.data, el cual es el resultado del fetch de la searchbar
|
|
||||||
if (!nodes.value[0]) nodes.value = [defaultNode];
|
if (!nodes.value[0]) nodes.value = [defaultNode];
|
||||||
nodes.value[0].childs = [...val];
|
nodes.value[0].childs = [...val];
|
||||||
const fetchedNodeKeys = val.flatMap(getNodeIds);
|
const fetchedNodeKeys = val.flatMap(getNodeIds);
|
||||||
state.set('Tree', [...fetchedNodeKeys]);
|
state.set('Tree', [...fetchedNodeKeys]);
|
||||||
|
|
||||||
if (!store.userParams?.search) {
|
if (store.userParams?.search === '') {
|
||||||
val.forEach((n) => {
|
val.forEach((n) => {
|
||||||
formatNodeSelected(n);
|
formatNodeSelected(n);
|
||||||
});
|
});
|
||||||
store.data = null;
|
|
||||||
expanded.value = [null];
|
|
||||||
} else {
|
} else {
|
||||||
for (let n of state.get('Tree')) {
|
for (let n of state.get('Tree')) await fetchNodeLeaves(n);
|
||||||
await fetchNodeLeaves(n);
|
|
||||||
}
|
|
||||||
expanded.value = [null, ...fetchedNodeKeys];
|
expanded.value = [null, ...fetchedNodeKeys];
|
||||||
}
|
}
|
||||||
previousExpandedNodes.value = new Set(expanded.value);
|
previousExpandedNodes.value = new Set(expanded.value);
|
||||||
},
|
});
|
||||||
{ immediate: true }
|
|
||||||
);
|
|
||||||
|
|
||||||
const reFetch = async () => {
|
const reFetch = async () => {
|
||||||
const { data } = await arrayData.fetch({ append: false });
|
const { data } = await arrayData.fetch({ append: false });
|
||||||
nodes.value = data;
|
nodes.value = data;
|
||||||
expanded.value = [null];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
if (store.userParams?.search) await arrayData.fetch({});
|
if (store.userParams?.search && !props.showSearchBar) {
|
||||||
|
await reFetch();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const stateTree = state.get('Tree');
|
||||||
|
const tree = stateTree ? [...state.get('Tree')] : [null];
|
||||||
|
const lastStateTree = state.get('TreeState');
|
||||||
|
if (tree) {
|
||||||
|
for (let n of tree) {
|
||||||
|
await fetchNodeLeaves(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lastStateTree) {
|
||||||
|
tree.push(lastStateTree);
|
||||||
|
await fetchNodeLeaves(lastStateTree);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
if (lastStateTree) {
|
||||||
|
document.getElementById(lastStateTree).scrollIntoView();
|
||||||
|
}
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
expanded.value.unshift(null);
|
||||||
|
previousExpandedNodes.value = new Set(expanded.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
onUnmounted(() => {
|
onUnmounted(() => {
|
||||||
state.set('Tree', undefined);
|
state.set('Tree', undefined);
|
||||||
arrayData.destroy();
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue