mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
fix(utils): 数据源条件解析空字符出错
This commit is contained in:
parent
455c696ff0
commit
33fcee66df
@ -283,32 +283,36 @@ export const compiledNode = (
|
|||||||
return node;
|
return node;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const compiledCond = (op: string, fieldValue: any, value: any, range: number[] = []): boolean => {
|
export const compiledCond = (op: string, fieldValue: any, inputValue: any, range: number[] = []): boolean => {
|
||||||
|
if (typeof fieldValue === 'string' && typeof inputValue === 'undefined') {
|
||||||
|
inputValue = '';
|
||||||
|
}
|
||||||
|
|
||||||
switch (op) {
|
switch (op) {
|
||||||
case 'is':
|
case 'is':
|
||||||
return fieldValue === value;
|
return fieldValue === inputValue;
|
||||||
case 'not':
|
case 'not':
|
||||||
return fieldValue !== value;
|
return fieldValue !== inputValue;
|
||||||
case '=':
|
case '=':
|
||||||
return fieldValue === value;
|
return fieldValue === inputValue;
|
||||||
case '!=':
|
case '!=':
|
||||||
return fieldValue !== value;
|
return fieldValue !== inputValue;
|
||||||
case '>':
|
case '>':
|
||||||
return fieldValue > value;
|
return fieldValue > inputValue;
|
||||||
case '>=':
|
case '>=':
|
||||||
return fieldValue >= value;
|
return fieldValue >= inputValue;
|
||||||
case '<':
|
case '<':
|
||||||
return fieldValue < value;
|
return fieldValue < inputValue;
|
||||||
case '<=':
|
case '<=':
|
||||||
return fieldValue <= value;
|
return fieldValue <= inputValue;
|
||||||
case 'between':
|
case 'between':
|
||||||
return range.length > 1 && fieldValue >= range[0] && fieldValue <= range[1];
|
return range.length > 1 && fieldValue >= range[0] && fieldValue <= range[1];
|
||||||
case 'not_between':
|
case 'not_between':
|
||||||
return range.length < 2 || fieldValue < range[0] || fieldValue > range[1];
|
return range.length < 2 || fieldValue < range[0] || fieldValue > range[1];
|
||||||
case 'include':
|
case 'include':
|
||||||
return fieldValue?.includes?.(value);
|
return fieldValue?.includes?.(inputValue);
|
||||||
case 'not_include':
|
case 'not_include':
|
||||||
return typeof fieldValue === 'undefined' || !fieldValue.includes?.(value);
|
return typeof fieldValue === 'undefined' || !fieldValue.includes?.(inputValue);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user