Merge branch 'master' of https://gitea.verdnatura.es/verdnatura/salix-front into test
gitea/salix-front/pipeline/head There was a failure building this commit
Details
gitea/salix-front/pipeline/head There was a failure building this commit
Details
This commit is contained in:
commit
4913cf2c29
|
@ -75,6 +75,9 @@ const arrayData = useArrayData($props.dataKey, {
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const store = arrayData.store;
|
const store = arrayData.store;
|
||||||
const userParams = ref({});
|
const userParams = ref({});
|
||||||
|
|
||||||
|
defineExpose({ search, sanitizer, params: userParams });
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
userParams.value = $props.modelValue ?? {};
|
userParams.value = $props.modelValue ?? {};
|
||||||
emit('init', { params: userParams.value });
|
emit('init', { params: userParams.value });
|
||||||
|
@ -198,7 +201,7 @@ const customTags = computed(() =>
|
||||||
|
|
||||||
async function remove(key) {
|
async function remove(key) {
|
||||||
userParams.value[key] = undefined;
|
userParams.value[key] = undefined;
|
||||||
search();
|
await search();
|
||||||
emit('remove', key);
|
emit('remove', key);
|
||||||
emit('update:modelValue', userParams.value);
|
emit('update:modelValue', userParams.value);
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,18 +75,10 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
limit: store.limit,
|
limit: store.limit,
|
||||||
};
|
};
|
||||||
|
|
||||||
let exprFilter;
|
|
||||||
let userParams = { ...store.userParams };
|
let userParams = { ...store.userParams };
|
||||||
if (store?.exprBuilder) {
|
|
||||||
const where = buildFilter(userParams, (param, value) => {
|
|
||||||
const res = store.exprBuilder(param, value);
|
|
||||||
if (res) delete userParams[param];
|
|
||||||
return res;
|
|
||||||
});
|
|
||||||
exprFilter = where ? { where } : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
Object.assign(filter, store.userFilter, exprFilter);
|
Object.assign(filter, store.userFilter);
|
||||||
|
|
||||||
let where;
|
let where;
|
||||||
if (filter?.where || store.filter?.where)
|
if (filter?.where || store.filter?.where)
|
||||||
where = Object.assign(filter?.where ?? {}, store.filter?.where ?? {});
|
where = Object.assign(filter?.where ?? {}, store.filter?.where ?? {});
|
||||||
|
@ -95,12 +87,29 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
const params = { filter };
|
const params = { filter };
|
||||||
|
|
||||||
Object.assign(params, userParams);
|
Object.assign(params, userParams);
|
||||||
params.filter.skip = store.skip;
|
if (params.filter) params.filter.skip = store.skip;
|
||||||
if (store.order && store.order.length) params.filter.order = store.order;
|
if (store?.order && typeof store?.order == 'string') store.order = [store.order];
|
||||||
|
if (store.order?.length) params.filter.order = [...store.order];
|
||||||
else delete params.filter.order;
|
else delete params.filter.order;
|
||||||
|
|
||||||
|
store.currentFilter = JSON.parse(JSON.stringify(params));
|
||||||
|
delete store.currentFilter.filter.include;
|
||||||
|
store.currentFilter.filter = JSON.stringify(store.currentFilter.filter);
|
||||||
|
|
||||||
|
let exprFilter;
|
||||||
|
if (store?.exprBuilder) {
|
||||||
|
exprFilter = buildFilter(params, (param, value) => {
|
||||||
|
if (param == 'filter') return;
|
||||||
|
const res = store.exprBuilder(param, value);
|
||||||
|
if (res) delete params[param];
|
||||||
|
return res;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (params.filter.where || exprFilter)
|
||||||
|
params.filter.where = { ...params.filter.where, ...exprFilter };
|
||||||
params.filter = JSON.stringify(params.filter);
|
params.filter = JSON.stringify(params.filter);
|
||||||
store.currentFilter = params;
|
|
||||||
store.isLoading = true;
|
store.isLoading = true;
|
||||||
const response = await axios.get(store.url, {
|
const response = await axios.get(store.url, {
|
||||||
signal: canceller.signal,
|
signal: canceller.signal,
|
||||||
|
|
|
@ -1,14 +1,13 @@
|
||||||
<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, 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 'src/components/ui/VnPaginate.vue';
|
import VnPaginate from 'src/components/ui/VnPaginate.vue';
|
||||||
import CatalogItem from 'src/components/ui/CatalogItem.vue';
|
import CatalogItem from 'src/components/ui/CatalogItem.vue';
|
||||||
import OrderCatalogFilter from 'src/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';
|
import { useArrayData } from 'src/composables/useArrayData';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
|
@ -18,7 +17,6 @@ const { t } = useI18n();
|
||||||
const dataKey = 'OrderCatalogList';
|
const dataKey = 'OrderCatalogList';
|
||||||
const arrayData = useArrayData(dataKey);
|
const arrayData = useArrayData(dataKey);
|
||||||
const store = arrayData.store;
|
const store = arrayData.store;
|
||||||
const showFilter = ref(null);
|
|
||||||
const tags = ref([]);
|
const tags = ref([]);
|
||||||
|
|
||||||
let catalogParams = {
|
let catalogParams = {
|
||||||
|
@ -26,27 +24,6 @@ let catalogParams = {
|
||||||
orderBy: JSON.stringify({ field: 'relevancy DESC, name', way: 'ASC', isTag: false }),
|
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();
|
||||||
|
@ -90,7 +67,7 @@ function extractValueTags(items) {
|
||||||
);
|
);
|
||||||
tagValue.value = resultValueTags;
|
tagValue.value = resultValueTags;
|
||||||
}
|
}
|
||||||
const autoLoad = computed(() => !!catalogParams.categoryFk);
|
const autoLoad = computed(() => !!JSON.parse(route?.query.table ?? '{}')?.categoryFk);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => store.data,
|
() => store.data,
|
||||||
|
@ -112,7 +89,7 @@ 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="dataKey"
|
||||||
:tag-value="tagValue"
|
:tag-value="tagValue"
|
||||||
|
@ -128,8 +105,6 @@ watch(
|
||||||
url="Orders/CatalogFilter"
|
url="Orders/CatalogFilter"
|
||||||
:limit="50"
|
:limit="50"
|
||||||
:user-params="catalogParams"
|
:user-params="catalogParams"
|
||||||
@on-fetch="showFilter = true"
|
|
||||||
:update-router="false"
|
|
||||||
:auto-load="autoLoad"
|
:auto-load="autoLoad"
|
||||||
>
|
>
|
||||||
<template #body="{ rows }">
|
<template #body="{ rows }">
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { computed, ref, onMounted } from 'vue';
|
import { 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';
|
||||||
|
@ -8,7 +8,6 @@ import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
|
||||||
import VnSelect from 'components/common/VnSelect.vue';
|
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 CatalogFilterValueDialog from 'src/pages/Order/Card/CatalogFilterValueDialog.vue';
|
import CatalogFilterValueDialog from 'src/pages/Order/Card/CatalogFilterValueDialog.vue';
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
|
|
||||||
|
@ -32,11 +31,8 @@ const route = useRoute();
|
||||||
|
|
||||||
const arrayData = useArrayData(props.dataKey);
|
const arrayData = useArrayData(props.dataKey);
|
||||||
|
|
||||||
const currentParams = ref({});
|
|
||||||
const categoryList = ref(null);
|
const categoryList = ref(null);
|
||||||
const selectedCategoryFk = ref(null);
|
|
||||||
const typeList = ref([]);
|
const typeList = ref([]);
|
||||||
const selectedTypeFk = ref(null);
|
|
||||||
const searchByTag = ref(null);
|
const searchByTag = ref(null);
|
||||||
|
|
||||||
const vnFilterPanelRef = ref();
|
const vnFilterPanelRef = ref();
|
||||||
|
@ -53,50 +49,32 @@ const orderWayList = ref([
|
||||||
const orderBySelected = ref('relevancy DESC, name');
|
const orderBySelected = ref('relevancy DESC, name');
|
||||||
const orderWaySelected = ref('ASC');
|
const orderWaySelected = ref('ASC');
|
||||||
|
|
||||||
onMounted(() => {
|
|
||||||
selectedCategoryFk.value = getParamWhere(route, 'categoryFk');
|
|
||||||
selectedTypeFk.value = getParamWhere(route, 'typeFk');
|
|
||||||
});
|
|
||||||
|
|
||||||
const resetCategory = (params, search) => {
|
const resetCategory = (params, search) => {
|
||||||
selectedCategoryFk.value = null;
|
|
||||||
typeList.value = null;
|
typeList.value = null;
|
||||||
params.categoryFk = null;
|
params.categoryFk = null;
|
||||||
params.typeFk = null;
|
params.typeFk = null;
|
||||||
arrayData.store.userFilter = null;
|
arrayData.store.userFilter = null;
|
||||||
removeTagGroupParam(search);
|
|
||||||
};
|
|
||||||
|
|
||||||
const selectCategory = (params, category, search) => {
|
|
||||||
if (params.categoryFk === category?.id) {
|
|
||||||
resetCategory(params, search);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
selectedCategoryFk.value = category?.id;
|
|
||||||
params.categoryFk = category?.id;
|
|
||||||
params.typeFk = null;
|
|
||||||
selectedTypeFk.value = null;
|
|
||||||
loadTypes(category?.id);
|
|
||||||
search();
|
search();
|
||||||
};
|
};
|
||||||
|
|
||||||
const loadTypes = async (categoryFk = selectedCategoryFk.value) => {
|
const selectCategory = async (params, category, search) => {
|
||||||
|
if (vnFilterPanelRef.value.params.categoryFk === category?.id) {
|
||||||
|
resetCategory(params, search);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
params.typeFk = null;
|
||||||
|
params.categoryFk = category.id;
|
||||||
|
await loadTypes(category?.id);
|
||||||
|
await search();
|
||||||
|
};
|
||||||
|
|
||||||
|
const loadTypes = async (id) => {
|
||||||
const { data } = await axios.get(`Orders/${route.params.id}/getItemTypeAvailable`, {
|
const { data } = await axios.get(`Orders/${route.params.id}/getItemTypeAvailable`, {
|
||||||
params: { itemCategoryId: categoryFk },
|
params: { itemCategoryId: id },
|
||||||
});
|
});
|
||||||
typeList.value = data;
|
typeList.value = data;
|
||||||
};
|
};
|
||||||
|
|
||||||
const selectedCategory = computed(() => {
|
|
||||||
return (categoryList.value || []).find(
|
|
||||||
(category) => category?.id === selectedCategoryFk.value
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
const selectedType = computed(() => {
|
|
||||||
return (typeList.value || []).find((type) => type?.id === selectedTypeFk.value);
|
|
||||||
});
|
|
||||||
|
|
||||||
function exprBuilder(param, value) {
|
function exprBuilder(param, value) {
|
||||||
switch (param) {
|
switch (param) {
|
||||||
case 'categoryFk':
|
case 'categoryFk':
|
||||||
|
@ -122,21 +100,21 @@ const applyTags = (tagInfo, params, search) => {
|
||||||
|
|
||||||
async function onSearchByTag(value) {
|
async function onSearchByTag(value) {
|
||||||
if (!value.target.value) return;
|
if (!value.target.value) return;
|
||||||
if (!currentParams.value?.tagGroups) {
|
if (!vnFilterPanelRef.value.params?.tagGroups) {
|
||||||
currentParams.value.tagGroups = [];
|
vnFilterPanelRef.value.params.tagGroups = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
currentParams.value.tagGroups.push({
|
vnFilterPanelRef.value.params.tagGroups.push({
|
||||||
values: [{ value: value.target.value }],
|
values: [{ value: value.target.value }],
|
||||||
});
|
});
|
||||||
searchByTag.value = null;
|
searchByTag.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeTagGroupParam = (search, valIndex) => {
|
const removeTagGroupParam = (params, search, valIndex) => {
|
||||||
if (!valIndex && valIndex !== 0) {
|
if (!valIndex && valIndex !== 0) {
|
||||||
currentParams.value.tagGroups = null;
|
params.tagGroups = null;
|
||||||
} else {
|
} else {
|
||||||
currentParams.value.tagGroups.splice(valIndex, 1);
|
params.tagGroups.splice(valIndex, 1);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -148,7 +126,8 @@ const setCategoryList = (data) => {
|
||||||
icon: `vn:${(category.icon || '').split('-')[1]}`,
|
icon: `vn:${(category.icon || '').split('-')[1]}`,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
selectedCategoryFk.value && loadTypes();
|
vnFilterPanelRef.value.params.categoryFk &&
|
||||||
|
loadTypes(vnFilterPanelRef.value.params.categoryFk);
|
||||||
};
|
};
|
||||||
|
|
||||||
const getCategoryClass = (category, params) => {
|
const getCategoryClass = (category, params) => {
|
||||||
|
@ -157,12 +136,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);
|
||||||
|
@ -182,24 +155,22 @@ onMounted(() => {
|
||||||
<VnFilterPanel
|
<VnFilterPanel
|
||||||
ref="vnFilterPanelRef"
|
ref="vnFilterPanelRef"
|
||||||
:data-key="props.dataKey"
|
:data-key="props.dataKey"
|
||||||
:hidden-tags="['orderFk', 'orderBy']"
|
:hidden-tags="['filter', 'orderFk', 'orderBy']"
|
||||||
:un-removable-params="['orderFk', 'orderBy']"
|
:unremovable-params="['orderFk', 'orderBy']"
|
||||||
:expr-builder="exprBuilder"
|
:expr-builder="exprBuilder"
|
||||||
:custom-tags="['tagGroups', 'categoryFk']"
|
:custom-tags="['tagGroups', 'categoryFk']"
|
||||||
:redirect="false"
|
:redirect="false"
|
||||||
@remove="clearFilter"
|
|
||||||
v-model="currentParams"
|
|
||||||
>
|
>
|
||||||
<template #tags="{ tag, formatFn }">
|
<template #tags="{ tag, formatFn }">
|
||||||
<strong v-if="tag.label === 'typeFk'">
|
<strong v-if="tag.label === 'typeFk' && typeList">
|
||||||
{{ t(selectedType?.name || '') }}
|
{{ t(typeList.find((t) => t.id == tag.value)?.name || '') }}
|
||||||
</strong>
|
</strong>
|
||||||
<div v-else class="q-gutter-x-xs">
|
<div v-else class="q-gutter-x-xs">
|
||||||
<strong>{{ t(`params.${tag.label}`) }}: </strong>
|
<strong>{{ t(`params.${tag.label}`) }}: </strong>
|
||||||
<span>{{ formatFn(tag.value) }}</span>
|
<span>{{ formatFn(tag.value) }}</span>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<template #customTags="{ tags: customTags, params, searchFn }">
|
<template #customTags="{ params, tags: customTags, searchFn }">
|
||||||
<template v-for="customTag in customTags" :key="customTag.label">
|
<template v-for="customTag in customTags" :key="customTag.label">
|
||||||
<VnFilterPanelChip
|
<VnFilterPanelChip
|
||||||
v-for="(tag, valIndex) in Array.isArray(customTag.value)
|
v-for="(tag, valIndex) in Array.isArray(customTag.value)
|
||||||
|
@ -210,11 +181,16 @@ onMounted(() => {
|
||||||
@remove="
|
@remove="
|
||||||
customTag.label === 'categoryFk'
|
customTag.label === 'categoryFk'
|
||||||
? resetCategory(params, searchFn)
|
? resetCategory(params, searchFn)
|
||||||
: removeTagGroupParam(searchFn, valIndex)
|
: removeTagGroupParam(params, searchFn, valIndex)
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
<strong v-if="customTag.label === 'categoryFk'">
|
<strong v-if="customTag.label === 'categoryFk' && categoryList">
|
||||||
{{ t(selectedCategory?.name || '') }}
|
{{
|
||||||
|
t(
|
||||||
|
categoryList.find((c) => c.id == customTag.value)?.name ||
|
||||||
|
''
|
||||||
|
)
|
||||||
|
}}
|
||||||
</strong>
|
</strong>
|
||||||
<strong v-if="tag?.tagSelection?.name" class="q-mr-xs">
|
<strong v-if="tag?.tagSelection?.name" class="q-mr-xs">
|
||||||
{{ tag.tagSelection.name }}:
|
{{ tag.tagSelection.name }}:
|
||||||
|
@ -261,13 +237,8 @@ onMounted(() => {
|
||||||
emit-value
|
emit-value
|
||||||
use-input
|
use-input
|
||||||
sort-by="name ASC"
|
sort-by="name ASC"
|
||||||
:disable="!selectedCategoryFk"
|
:disable="!params.categoryFk"
|
||||||
@update:model-value="
|
@update:model-value="searchFn()"
|
||||||
(value) => {
|
|
||||||
selectedTypeFk = value;
|
|
||||||
searchFn();
|
|
||||||
}
|
|
||||||
"
|
|
||||||
>
|
>
|
||||||
<template #option="{ itemProps, opt }">
|
<template #option="{ itemProps, opt }">
|
||||||
<QItem v-bind="itemProps">
|
<QItem v-bind="itemProps">
|
||||||
|
@ -337,7 +308,7 @@ onMounted(() => {
|
||||||
style="display: inline-block"
|
style="display: inline-block"
|
||||||
:tags="tags"
|
:tags="tags"
|
||||||
@apply-tags="
|
@apply-tags="
|
||||||
($event) => applyTags($event, currentParams, searchFn)
|
($event) => applyTags($event, params, searchFn)
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
</QPopupProxy>
|
</QPopupProxy>
|
||||||
|
|
Loading…
Reference in New Issue