Hotfix: fixed filter when searching by id #1063
|
@ -51,10 +51,6 @@ const props = defineProps({
|
|||
type: Object,
|
||||
default: null,
|
||||
},
|
||||
staticParams: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
exprBuilder: {
|
||||
type: Function,
|
||||
default: null,
|
||||
|
@ -102,20 +98,25 @@ onMounted(() => {
|
|||
async function search() {
|
||||
const staticParams = Object.entries(store.userParams);
|
||||
arrayData.reset(['skip', 'page']);
|
||||
|
||||
const filter = {
|
||||
let filter = {
|
||||
params: {
|
||||
...Object.fromEntries(staticParams),
|
||||
search: searchText.value,
|
||||
},
|
||||
...{ filter: props.filter },
|
||||
};
|
||||
|
||||
if (props.whereFilter) {
|
||||
filter.filter = {
|
||||
where: props.whereFilter(searchText.value),
|
||||
if (!searchText.value) {
|
||||
filter = {
|
||||
params: {
|
||||
...Object.fromEntries(staticParams),
|
||||
},
|
||||
...{ filter: props.filter },
|
||||
};
|
||||
delete filter.params.search;
|
||||
|
||||
if (props.whereFilter) {
|
||||
filter.filter = {
|
||||
where: props.whereFilter(searchText.value),
|
||||
};
|
||||
delete filter.params.search;
|
||||
}
|
||||
}
|
||||
await arrayData.applyFilter(filter);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<script setup>
|
||||
import axios from 'axios';
|
||||
import { computed, ref, onMounted } from 'vue';
|
||||
import { computed, ref, onBeforeMount } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
@ -46,7 +46,7 @@ const userParams = {
|
|||
from: null,
|
||||
to: null,
|
||||
};
|
||||
onMounted(() => {
|
||||
onBeforeMount(() => {
|
||||
initializeFromQuery();
|
||||
stateStore.rightDrawer = true;
|
||||
if (!route.query.createForm) return;
|
||||
|
|
Loading…
Reference in New Issue