diff --git a/src/components/common/VnSelect.vue b/src/components/common/VnSelect.vue index 63a3f088fa..b6dc226cc6 100644 --- a/src/components/common/VnSelect.vue +++ b/src/components/common/VnSelect.vue @@ -73,6 +73,10 @@ const $props = defineProps({ type: Boolean, default: true, }, + params: { + type: Object, + default: null, + }, }); const { t } = useI18n(); @@ -153,9 +157,14 @@ async function fetchFilter(val) { ? optionValue.value : optionFilter.value ?? optionLabel.value); - const defaultWhere = $props.useLike - ? { [key]: { like: `%${val}%` } } - : { [key]: val }; + let defaultWhere = {}; + if ($props.filterOptions.length) { + defaultWhere = $props.filterOptions.reduce((obj, prop) => { + if (!obj.or) obj.or = []; + obj.or.push({ [prop]: getVal(val) }); + return obj; + }, {}); + } else defaultWhere = { [key]: getVal(val) }; const where = { ...(val ? defaultWhere : {}), ...$props.where }; const fetchOptions = { where, include, limit }; if (fields) fetchOptions.fields = fields; @@ -194,6 +203,8 @@ async function filterHandler(val, update) { function nullishToTrue(value) { return value ?? true; } + +const getVal = (val) => ($props.useLike ? { like: `%${val}%` } : val);