diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index c3611c464..bf1fcfdb9 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -75,6 +75,9 @@ const arrayData = useArrayData($props.dataKey, { const route = useRoute(); const store = arrayData.store; const userParams = ref({}); + +defineExpose({ search, sanitizer, params: userParams }); + onMounted(() => { userParams.value = $props.modelValue ?? {}; emit('init', { params: userParams.value }); @@ -198,7 +201,7 @@ const customTags = computed(() => async function remove(key) { userParams.value[key] = undefined; - search(); + await search(); emit('remove', key); emit('update:modelValue', userParams.value); } diff --git a/src/composables/useArrayData.js b/src/composables/useArrayData.js index 269231797..da62eee3e 100644 --- a/src/composables/useArrayData.js +++ b/src/composables/useArrayData.js @@ -75,18 +75,10 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) { limit: store.limit, }; - let exprFilter; 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; if (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 }; Object.assign(params, userParams); - params.filter.skip = store.skip; - if (store.order && store.order.length) params.filter.order = store.order; + if (params.filter) params.filter.skip = store.skip; + 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; + 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); - store.currentFilter = params; + store.isLoading = true; const response = await axios.get(store.url, { signal: canceller.signal, diff --git a/src/pages/Order/Card/OrderCatalog.vue b/src/pages/Order/Card/OrderCatalog.vue index 66a1a132d..90bce38fd 100644 --- a/src/pages/Order/Card/OrderCatalog.vue +++ b/src/pages/Order/Card/OrderCatalog.vue @@ -1,14 +1,13 @@