From c418899fb35d5e751619d5d3d308ecabf32c8997 Mon Sep 17 00:00:00 2001 From: jorgep Date: Mon, 26 Aug 2024 13:54:48 +0200 Subject: [PATCH] chore: refs #7323 improve vnselect --- src/components/common/VnSelect.vue | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/components/common/VnSelect.vue b/src/components/common/VnSelect.vue index 83d0ce845..b6dc226cc 100644 --- a/src/components/common/VnSelect.vue +++ b/src/components/common/VnSelect.vue @@ -161,11 +161,10 @@ async function fetchFilter(val) { if ($props.filterOptions.length) { defaultWhere = $props.filterOptions.reduce((obj, prop) => { if (!obj.or) obj.or = []; - obj.or.push({ [prop]: $props.useLike ? { like: `%${val}%` } : val }); + obj.or.push({ [prop]: getVal(val) }); return obj; }, {}); - } else - defaultWhere = $props.useLike ? { [key]: { like: `%${val}%` } } : { [key]: val }; + } else defaultWhere = { [key]: getVal(val) }; const where = { ...(val ? defaultWhere : {}), ...$props.where }; const fetchOptions = { where, include, limit }; if (fields) fetchOptions.fields = fields; @@ -204,6 +203,8 @@ async function filterHandler(val, update) { function nullishToTrue(value) { return value ?? true; } + +const getVal = (val) => ($props.useLike ? { like: `%${val}%` } : val);