fix: refs #7323 auto fill bic #642
|
@ -161,11 +161,10 @@ async function fetchFilter(val) {
|
|||
if ($props.filterOptions.length) {
|
||||
|
||||
defaultWhere = $props.filterOptions.reduce((obj, prop) => {
|
||||
jorgep marked this conversation as resolved
jsegarra
commented
Porque la logica de $props.useLike no se puede usar en el reduce? Porque la logica de $props.useLike no se puede usar en el reduce?
|
||||
if (!obj.or) obj.or = [];
|
||||
obj.or.push({ [prop]: $props.useLike ? { like: `%${val}%` } : val });
|
||||
obj.or.push({ [prop]: getVal(val) });
|
||||
jorgep marked this conversation as resolved
Outdated
jsegarra
commented
Okey, pero ahora tenemos la misma logica 2 veces. La unica diferencia es como gestionas la variable key. Mas limpio, o que te parece? Okey, pero ahora tenemos la misma logica 2 veces. La unica diferencia es como gestionas la variable key.
Porque no sacas el operador ternario a una funcion y luego lo asignas como valor a esa Key
Mas limpio, o que te parece?
|
||||
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);
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
Loading…
Reference in New Issue
Permite filtrar por varias opciones. Antes, si era un digito, solo filtraba por id.