forked from verdnatura/salix-front
fix(zone): zoneLocation and the others searchbar
This commit is contained in:
parent
1512801f02
commit
3ee7692bbc
|
@ -363,7 +363,7 @@ defineExpose({
|
||||||
@update:selected="emit('update:selected', $event)"
|
@update:selected="emit('update:selected', $event)"
|
||||||
>
|
>
|
||||||
<template #top-left v-if="!$props.withoutHeader">
|
<template #top-left v-if="!$props.withoutHeader">
|
||||||
<slot name="top-left"></slot>
|
<slot name="top-left"> </slot>
|
||||||
</template>
|
</template>
|
||||||
<template #top-right v-if="!$props.withoutHeader">
|
<template #top-right v-if="!$props.withoutHeader">
|
||||||
<VnVisibleColumn
|
<VnVisibleColumn
|
||||||
|
|
|
@ -81,24 +81,27 @@ onMounted(() => {
|
||||||
emit('init', { params: userParams.value });
|
emit('init', { params: userParams.value });
|
||||||
});
|
});
|
||||||
|
|
||||||
function setUserParams(watchedParams) {
|
function setUserParams(watchedParams, quien) {
|
||||||
if (!watchedParams) return;
|
if (!watchedParams) return;
|
||||||
|
|
||||||
if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams);
|
if (typeof watchedParams == 'string') watchedParams = JSON.parse(watchedParams);
|
||||||
|
if (typeof watchedParams?.filter == 'string')
|
||||||
|
watchedParams.filter = JSON.parse(watchedParams.filter);
|
||||||
|
|
||||||
watchedParams = { ...watchedParams, ...watchedParams.filter?.where };
|
watchedParams = { ...watchedParams, ...watchedParams.filter?.where };
|
||||||
delete watchedParams.filter;
|
delete watchedParams.filter;
|
||||||
userParams.value = { ...userParams.value, ...watchedParams };
|
userParams.value = { ...userParams.value, ...sanitizer(watchedParams) };
|
||||||
emit('setUserParams', userParams.value);
|
emit('setUserParams', userParams.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => route.query[$props.searchUrl],
|
() => route.query[$props.searchUrl],
|
||||||
(val) => setUserParams(val)
|
(val, oldValue) => (val || oldValue) && setUserParams(val)
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => arrayData.store.userParams,
|
() => arrayData.store.userParams,
|
||||||
(val) => setUserParams(val)
|
(val, oldValue) => (val || oldValue) && setUserParams(val)
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
|
@ -61,15 +61,11 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
customRouteRedirectName: {
|
customRouteRedirectName: {
|
||||||
type: String,
|
type: String,
|
||||||
default: null,
|
default: '',
|
||||||
},
|
},
|
||||||
makeFetch: {
|
whereFilter: {
|
||||||
type: Boolean,
|
type: Function,
|
||||||
default: true,
|
default: undefined,
|
||||||
},
|
|
||||||
isQueryFilter: {
|
|
||||||
type: Boolean,
|
|
||||||
default: false,
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -109,18 +105,18 @@ async function search() {
|
||||||
);
|
);
|
||||||
arrayData.reset(['skip', 'page']);
|
arrayData.reset(['skip', 'page']);
|
||||||
|
|
||||||
if (!props.makeFetch) return;
|
|
||||||
const filter = {
|
const filter = {
|
||||||
params: {
|
params: {
|
||||||
...Object.fromEntries(staticParams),
|
...Object.fromEntries(staticParams),
|
||||||
|
search: searchText.value,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
if (props.isQueryFilter) {
|
|
||||||
|
if (props.whereFilter) {
|
||||||
filter.filter = {
|
filter.filter = {
|
||||||
where: {
|
where: props.whereFilter(searchText.value),
|
||||||
name: searchText.value == '' ? undefined : searchText.value,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
delete filter.params.search;
|
||||||
}
|
}
|
||||||
await arrayData.applyFilter(filter);
|
await arrayData.applyFilter(filter);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +1,20 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
|
import { useRoute } from 'vue-router';
|
||||||
|
import { computed } from 'vue';
|
||||||
|
|
||||||
import VnCard from 'components/common/VnCard.vue';
|
import VnCard from 'components/common/VnCard.vue';
|
||||||
import ZoneDescriptor from './ZoneDescriptor.vue';
|
import ZoneDescriptor from './ZoneDescriptor.vue';
|
||||||
import ZoneFilterPanel from '../ZoneFilterPanel.vue';
|
import ZoneFilterPanel from '../ZoneFilterPanel.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
const route = useRoute();
|
||||||
|
const routeName = computed(() => route.name);
|
||||||
|
|
||||||
|
function notIsLocations(ifIsFalse, ifIsTrue) {
|
||||||
|
if (routeName.value != 'ZoneLocations') return ifIsFalse;
|
||||||
|
return ifIsTrue;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
@ -14,18 +23,14 @@ const { t } = useI18n();
|
||||||
base-url="Zones"
|
base-url="Zones"
|
||||||
:descriptor="ZoneDescriptor"
|
:descriptor="ZoneDescriptor"
|
||||||
:filter-panel="ZoneFilterPanel"
|
:filter-panel="ZoneFilterPanel"
|
||||||
search-data-key="ZoneList"
|
:search-data-key="notIsLocations('ZoneList', 'ZoneLocations')"
|
||||||
search-url="Zones"
|
|
||||||
:searchbar-label="t('list.searchZone')"
|
|
||||||
:searchbar-info="t('list.searchInfo')"
|
|
||||||
:searchbar-props="{
|
:searchbar-props="{
|
||||||
url: 'Zones',
|
url: 'Zones',
|
||||||
label: t('list.searchZone'),
|
label: notIsLocations(t('list.searchZone'), t('list.searchLocation')),
|
||||||
info: t('list.searchInfo'),
|
info: t('list.searchInfo'),
|
||||||
|
whereFilter: notIsLocations((text) => {
|
||||||
|
return { name: { like: `%${text}%` } };
|
||||||
|
}),
|
||||||
}"
|
}"
|
||||||
>
|
/>
|
||||||
<template #searchbar>
|
|
||||||
<ZoneSearchbar />
|
|
||||||
</template>
|
|
||||||
</VnCard>
|
|
||||||
</template>
|
</template>
|
||||||
|
|
|
@ -44,25 +44,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<template v-if="stateStore.isHeaderMounted()">
|
<Teleport to="#right-panel" v-if="useStateStore().isHeaderMounted()">
|
||||||
<Teleport to="#actions-append">
|
|
||||||
<div class="row q-gutter-x-sm">
|
|
||||||
<QBtn
|
|
||||||
flat
|
|
||||||
@click="stateStore.toggleRightDrawer()"
|
|
||||||
round
|
|
||||||
dense
|
|
||||||
icon="menu"
|
|
||||||
>
|
|
||||||
<QTooltip bottom anchor="bottom right">
|
|
||||||
{{ t('globals.collapseMenu') }}
|
|
||||||
</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</div>
|
|
||||||
</Teleport>
|
|
||||||
</template>
|
|
||||||
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
|
|
||||||
<QScrollArea class="fit text-grey-8">
|
|
||||||
<ZoneEventsPanel
|
<ZoneEventsPanel
|
||||||
:first-day="firstDay"
|
:first-day="firstDay"
|
||||||
:last-day="lastDay"
|
:last-day="lastDay"
|
||||||
|
@ -70,8 +52,7 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
v-model:formModeName="formModeName"
|
v-model:formModeName="formModeName"
|
||||||
@open-zone-form="openForm"
|
@open-zone-form="openForm"
|
||||||
/>
|
/>
|
||||||
</QScrollArea>
|
</Teleport>
|
||||||
</QDrawer>
|
|
||||||
<QPage class="q-pa-md flex justify-center">
|
<QPage class="q-pa-md flex justify-center">
|
||||||
<ZoneCalendarGrid
|
<ZoneCalendarGrid
|
||||||
v-model:events="events"
|
v-model:events="events"
|
||||||
|
|
|
@ -1,10 +1,7 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref, computed, watch, onUnmounted } from 'vue';
|
import { onMounted, ref, computed, watch, onUnmounted } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
|
||||||
import { useRoute } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
|
|
||||||
import VnInput from 'src/components/common/VnInput.vue';
|
|
||||||
|
|
||||||
import { useState } from 'src/composables/useState';
|
import { useState } from 'src/composables/useState';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { useArrayData } from 'composables/useArrayData';
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
|
@ -30,7 +27,6 @@ const props = defineProps({
|
||||||
|
|
||||||
const emit = defineEmits(['update:tickedNodes']);
|
const emit = defineEmits(['update:tickedNodes']);
|
||||||
|
|
||||||
const { t } = useI18n();
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const state = useState();
|
const state = useState();
|
||||||
|
|
||||||
|
@ -186,16 +182,6 @@ onUnmounted(() => {
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<VnInput
|
|
||||||
v-if="showSearchBar"
|
|
||||||
v-model="store.userParams.search"
|
|
||||||
:placeholder="t('globals.search')"
|
|
||||||
@keydown.enter.prevent="reFetch()"
|
|
||||||
>
|
|
||||||
<template #prepend>
|
|
||||||
<QIcon class="cursor-pointer" name="search" />
|
|
||||||
</template>
|
|
||||||
</VnInput>
|
|
||||||
<QTree
|
<QTree
|
||||||
ref="treeRef"
|
ref="treeRef"
|
||||||
:nodes="nodes"
|
:nodes="nodes"
|
||||||
|
|
|
@ -132,7 +132,11 @@ const handleClone = (id) => {
|
||||||
data-key="Zones"
|
data-key="Zones"
|
||||||
:label="t('Search zone')"
|
:label="t('Search zone')"
|
||||||
:info="t('You can search zones by id or name')"
|
:info="t('You can search zones by id or name')"
|
||||||
:is-query-filter="true"
|
:where-filter="
|
||||||
|
(text) => {
|
||||||
|
return { name: { like: `%${text}%` } };
|
||||||
|
}
|
||||||
|
"
|
||||||
/>
|
/>
|
||||||
<VnTable
|
<VnTable
|
||||||
ref="tableRef"
|
ref="tableRef"
|
||||||
|
|
|
@ -18,6 +18,7 @@ list:
|
||||||
create: Create zone
|
create: Create zone
|
||||||
openSummary: Details
|
openSummary: Details
|
||||||
searchZone: Search zones
|
searchZone: Search zones
|
||||||
|
searchLocation: Search locations
|
||||||
searchInfo: Search zone by id or name
|
searchInfo: Search zone by id or name
|
||||||
confirmCloneTitle: All it's properties will be copied
|
confirmCloneTitle: All it's properties will be copied
|
||||||
confirmCloneSubtitle: Do you want to clone this zone?
|
confirmCloneSubtitle: Do you want to clone this zone?
|
||||||
|
|
|
@ -18,6 +18,7 @@ list:
|
||||||
create: Crear zona
|
create: Crear zona
|
||||||
openSummary: Detalles
|
openSummary: Detalles
|
||||||
searchZone: Buscar zonas
|
searchZone: Buscar zonas
|
||||||
|
searchLocation: Buscar localizaciones
|
||||||
searchInfo: Buscar zonas por identificador o nombre
|
searchInfo: Buscar zonas por identificador o nombre
|
||||||
confirmCloneTitle: Todas sus propiedades serán copiadas
|
confirmCloneTitle: Todas sus propiedades serán copiadas
|
||||||
confirmCloneSubtitle: ¿Seguro que quieres clonar esta zona?
|
confirmCloneSubtitle: ¿Seguro que quieres clonar esta zona?
|
||||||
|
|
|
@ -68,15 +68,6 @@ export default {
|
||||||
},
|
},
|
||||||
component: () => import('src/pages/Zone/ZoneCreate.vue'),
|
component: () => import('src/pages/Zone/ZoneCreate.vue'),
|
||||||
},
|
},
|
||||||
// {
|
|
||||||
// path: 'counter',
|
|
||||||
// name: 'ZoneCounter',
|
|
||||||
// meta: {
|
|
||||||
// title: 'zoneCounter',
|
|
||||||
// icon: 'add_circle',
|
|
||||||
// },
|
|
||||||
// component: () => import('src/pages/Zone/ZoneCounter.vue'),
|
|
||||||
// },
|
|
||||||
{
|
{
|
||||||
name: 'ZoneUpcomingDeliveries',
|
name: 'ZoneUpcomingDeliveries',
|
||||||
path: 'upcoming-deliveries',
|
path: 'upcoming-deliveries',
|
||||||
|
|
Loading…
Reference in New Issue