chore: requested changes
gitea/salix-front/pipeline/pr-master This commit looks good Details

This commit is contained in:
Alex Moreno 2024-11-21 07:42:00 +01:00
parent 42d24359cd
commit c5acde22a3
3 changed files with 19 additions and 28 deletions

View File

@ -2,7 +2,7 @@
import { ref } from 'vue'; import { ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import axios from 'axios'; import axios from 'axios';
import VnSelect from 'components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
const props = defineProps({ const props = defineProps({
@ -31,14 +31,6 @@ const applyTags = () => {
emit('applyTags', tagInfo); emit('applyTags', tagInfo);
}; };
const removeTagGroupParam = (valIndex = null) => {
if (!valIndex) {
tagValues.value = [{}];
} else {
(tagValues.value || []).splice(valIndex, 1);
}
};
const getSelectedTagValues = async (tag) => { const getSelectedTagValues = async (tag) => {
if (!tag?.id) return; if (!tag?.id) return;
const filter = { const filter = {
@ -57,7 +49,7 @@ const getSelectedTagValues = async (tag) => {
</script> </script>
<template> <template>
<QForm @submit="applyTags(tagValues)" class="all-pointer-events"> <QForm @submit="applyTags()" class="all-pointer-events">
<QCard class="q-pa-sm column q-pa-lg"> <QCard class="q-pa-sm column q-pa-lg">
<VnSelect <VnSelect
:label="t('params.tag')" :label="t('params.tag')"
@ -71,7 +63,7 @@ const getSelectedTagValues = async (tag) => {
rounded rounded
:emit-value="false" :emit-value="false"
use-input use-input
@update:model-value="($event) => getSelectedTagValues($event)" @update:model-value="getSelectedTagValues"
/> />
<div <div
v-for="(value, index) in tagValues" v-for="(value, index) in tagValues"
@ -83,7 +75,7 @@ const getSelectedTagValues = async (tag) => {
v-if="!selectedTag?.isFree && tagOptions" v-if="!selectedTag?.isFree && tagOptions"
:label="t('components.itemsFilterPanel.value')" :label="t('components.itemsFilterPanel.value')"
v-model="value.value" v-model="value.value"
:options="tagOptions || []" :options="tagOptions"
option-value="value" option-value="value"
option-label="value" option-label="value"
dense dense

View File

@ -4,18 +4,19 @@ import { useRoute, useRouter } from 'vue-router';
import { onBeforeMount, onMounted, onUnmounted, ref, computed, watch } 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 getParamWhere from 'src/filters/getParamWhere';
import { useArrayData } from 'composables/useArrayData'; 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 arrayData = useArrayData('OrderCatalogList'); const dataKey = 'OrderCatalogList';
const arrayData = useArrayData('dataKey');
const store = arrayData.store; const store = arrayData.store;
const showFilter = ref(null); const showFilter = ref(null);
const tags = ref([]); const tags = ref([]);
@ -102,7 +103,7 @@ watch(
<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"
@ -113,7 +114,7 @@ watch(
<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 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" :initial-catalog-params="catalogParams"
@ -123,7 +124,7 @@ watch(
<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"

View File

@ -53,6 +53,11 @@ 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; selectedCategoryFk.value = null;
typeList.value = null; typeList.value = null;
@ -65,7 +70,6 @@ const resetCategory = (params, search) => {
const selectCategory = (params, category, search) => { const selectCategory = (params, category, search) => {
if (params.categoryFk === category?.id) { if (params.categoryFk === category?.id) {
resetCategory(params, search); resetCategory(params, search);
params.categoryFk = null;
return; return;
} }
selectedCategoryFk.value = category?.id; selectedCategoryFk.value = category?.id;
@ -131,11 +135,10 @@ async function onSearchByTag(value) {
const removeTagGroupParam = (search, valIndex) => { const removeTagGroupParam = (search, valIndex) => {
if (!valIndex && valIndex !== 0) { if (!valIndex && valIndex !== 0) {
currentParams.value.tagGroups = null; currentParams.value.tagGroups = null;
search();
} else { } else {
currentParams.value.tagGroups.splice(valIndex, 1); currentParams.value.tagGroups.splice(valIndex, 1);
search();
} }
search();
}; };
const setCategoryList = (data) => { const setCategoryList = (data) => {
@ -168,11 +171,6 @@ function addOrder(value, field, params) {
params.orderBy = JSON.stringify(orderBy); params.orderBy = JSON.stringify(orderBy);
vnFilterPanelRef.value.search(); vnFilterPanelRef.value.search();
} }
onMounted(() => {
selectedCategoryFk.value = getParamWhere(route, 'categoryFk');
selectedTypeFk.value = getParamWhere(route, 'typeFk');
});
</script> </script>
<template> <template>