contains和overlaps增加了对单个对象的判定

This commit is contained in:
Xu Chang 2023-05-04 20:40:22 +08:00
parent 7d6456ac8e
commit 6005e9aacd
2 changed files with 8 additions and 8 deletions

View File

@ -455,18 +455,18 @@ var TreeStore = /** @class */ (function (_super) {
}
case '$contains': {
// json中的多值查询
(0, assert_1.assert)(value instanceof Array);
var array_1 = value instanceof Array ? value : [value];
return function (row) {
var data = (0, lodash_1.get)(row, path);
return (0, lodash_1.difference)(value, data).length === 0 || obscurePass(data, option);
return (0, lodash_1.difference)(array_1, data).length === 0 || obscurePass(data, option);
};
}
case '$overlaps': {
// json中的多值查询
(0, assert_1.assert)(value instanceof Array);
var array_2 = value instanceof Array ? value : [value];
return function (row) {
var data = (0, lodash_1.get)(row, path);
return (0, lodash_1.intersection)(value, data).length > 0 || obscurePass(data, option);
return (0, lodash_1.intersection)(array_2, data).length > 0 || obscurePass(data, option);
};
}
default: {

View File

@ -509,18 +509,18 @@ export default class TreeStore<ED extends EntityDict & BaseEntityDict> extends C
}
case '$contains': {
// json中的多值查询
assert(value instanceof Array);
const array = value instanceof Array ? value : [value];
return (row) => {
const data = get(row, path);
return difference(value, data).length === 0 || obscurePass(data, option);
return difference(array, data).length === 0 || obscurePass(data, option);
};
}
case '$overlaps': {
// json中的多值查询
assert(value instanceof Array);
const array = value instanceof Array ? value : [value];
return (row) => {
const data = get(row, path);
return intersection(value, data).length > 0 || obscurePass(data, option);
return intersection(array, data).length > 0 || obscurePass(data, option);
};
}
default: {