add function handler filter from to and etc

This commit is contained in:
2025-01-02 19:29:16 +07:00
parent a520c262ca
commit d12b14c5d4

View File

@ -78,16 +78,32 @@ export default class CommonHelper {
for (let p in param.filter) {
let f = String(param.filter[p])
let fr = param.filter[p]
if (p != 'any') {
if (!validate(f)) {
whereAttrPre.push("LOWER(" + p + ") = :" + p);
f = f.toLowerCase();
} else {
whereAttrPre.push(p + " = :" + p);
}
let found = false;
if (fr['from']) {
whereAttrPre.push(p + " >= :" + p + '_from');
whereVal[p + '_from'] = fr['from'];
found = true;
}
if (fr['to']) {
whereAttrPre.push(p + " <= :" + p + '_to');
whereVal[p + '_to'] = fr['to'];
found = true;
}
whereVal[p] = f;
if (!found) {
whereAttrPre.push("LOWER(" + p + ") = :" + p);
f = f.toLowerCase();
whereVal[p] = f;
}
} else {//uuid only
whereAttrPre.push(p + " = :" + p);
whereVal[p] = f;
}
} else {
filter_any = true;
filter_any_val = f;
@ -121,10 +137,10 @@ export default class CommonHelper {
}
if (param.col_any_eq.length > 0) {
whereVal['filter_eq'] = filter_any_val.toLowerCase();
whereVal['filter_eq'] = filter_any_val;
}
if (param.col_any_like.length > 0) {
whereVal['filter_like'] = '%' + filter_any_val.toLowerCase() + '%';
whereVal['filter_like'] = '%' + filter_any_val + '%';
}
}
} catch (e: any) {
@ -158,7 +174,7 @@ export default class CommonHelper {
whereVal['filter_eq'] = param.filter.toLowerCase();
}
if (param.col_any_like.length > 0) {
whereVal['filter_like'] = '%' + param.filter.toLowerCase() + '%';
whereVal['filter_like'] = '%' + param.filter + '%';
}
}