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