refs #5673 feat(formModel): global qselect filter
gitea/salix-front/pipeline/head This commit looks good Details

This commit is contained in:
Alex Moreno 2023-08-01 15:17:48 +02:00
parent 6b3a09887f
commit 92e914adad
2 changed files with 34 additions and 7 deletions

View File

@ -99,9 +99,9 @@ function reset() {
function filter(value, update, filterOptions) { function filter(value, update, filterOptions) {
update( update(
() => { () => {
const { options, filterFn } = filterOptions; const { options, filterFn, field } = filterOptions;
options.value = filterFn(options, value); options.value = filterFn(options, value, field);
}, },
(ref) => { (ref) => {
ref.setOptionIndex(-1); ref.setOptionIndex(-1);

View File

@ -102,10 +102,34 @@ const columns = computed(() => [
// }); // });
// } // }
const basicFilter = (options) => { // const basicFilter = () => {
// return {
// options: claimReasons,
// filterFn: (options, value) => {
// console.log('ENTRY', value);
// const search = value.toLowerCase();
// if (value === '') return claimReasons.value;
// const arr = options.value.filter((row) => {
// const id = row.id;
// const name = row.description.toLowerCase();
// console.log('SEARCH', search, id);
// const idMatches = id == search;
// const nameMatches = name.indexOf(search) > -1;
// return idMatches || nameMatches;
// });
// console.log(arr);
// return arr;
// },
// };
// };
const basicFilter = (options, field) => {
console.log(options, field);
return { return {
options, options,
filterFn: (options, value) => { field,
filterFn: (options, value, field) => {
const search = value.toLowerCase(); const search = value.toLowerCase();
if (value === '') return options; if (value === '') return options;
@ -113,7 +137,7 @@ const basicFilter = (options) => {
return options.value.filter((row) => { return options.value.filter((row) => {
console.log(row); console.log(row);
const id = row.id; const id = row.id;
const name = row.name.toLowerCase(); const name = row[field ?? 'name'].toLowerCase();
const idMatches = id == search; const idMatches = id == search;
const nameMatches = name.indexOf(search) > -1; const nameMatches = name.indexOf(search) > -1;
@ -192,7 +216,7 @@ const basicFilter = (options) => {
filter( filter(
value, value,
update, update,
basicFilter(col.options) basicFilter(col.options, col.optionLabel)
) )
" "
/> />
@ -223,7 +247,10 @@ const basicFilter = (options) => {
filter( filter(
value, value,
update, update,
basicFilter(col.options) basicFilter(
col.options,
col.optionLabel
)
) )
" "
/> />