diff --git a/src/components/common/VnSelect.vue b/src/components/common/VnSelect.vue index d111780bd..121f8eaa1 100644 --- a/src/components/common/VnSelect.vue +++ b/src/components/common/VnSelect.vue @@ -54,6 +54,10 @@ const $props = defineProps({ type: [Array], default: () => [], }, + filterFn: { + type: Function, + default: null, + }, exprBuilder: { type: Function, default: null, @@ -62,10 +66,6 @@ const $props = defineProps({ type: Boolean, default: true, }, - defaultFilter: { - type: Boolean, - default: true, - }, fields: { type: Array, default: null, @@ -247,15 +247,11 @@ async function fetchFilter(val) { } async function filterHandler(val, update) { - if (!val && lastVal.value === val) { - lastVal.value = val; - return update(); - } - lastVal.value = val; let newOptions; - if (!$props.defaultFilter) return update(); - if ( + if ($props.filterFn) update($props.filterFn(val)); + else if (!val && lastVal.value === val) update(); + else if ( $props.url && ($props.limit || (!$props.limit && Object.keys(myOptions.value).length === 0)) ) { @@ -275,6 +271,8 @@ async function filterHandler(val, update) { } }, ); + + lastVal.value = val; } function nullishToTrue(value) { diff --git a/src/pages/Supplier/Card/SupplierAccounts.vue b/src/pages/Supplier/Card/SupplierAccounts.vue index 365eb67a1..2e3acdfb6 100644 --- a/src/pages/Supplier/Card/SupplierAccounts.vue +++ b/src/pages/Supplier/Card/SupplierAccounts.vue @@ -65,15 +65,13 @@ function findBankFk(value, row) { if (bankEntityFk) row.bankEntityFk = bankEntityFk.id; } -function bankEntityFilter(val, update) { - update(() => { - const needle = val.toLowerCase(); - filteredBankEntitiesOptions.value = bankEntitiesOptions.value.filter( - (bank) => - bank.bic.toLowerCase().startsWith(needle) || - bank.name.toLowerCase().includes(needle), - ); - }); +function bankEntityFilter(val) { + const needle = val.toLowerCase(); + filteredBankEntitiesOptions.value = bankEntitiesOptions.value.filter( + (bank) => + bank.bic.toLowerCase().startsWith(needle) || + bank.name.toLowerCase().includes(needle), + ); }