修改自定义条件判断逻辑

v1.3.0
于肖磊 2025-04-07 16:03:22 +08:00
parent 53ae62b903
commit 9e50f26bb5
1 changed files with 7 additions and 3 deletions

View File

@ -245,9 +245,9 @@ export const custom_condition_judg = (fieldValue: any, type: string, value: numb
case 'less-than':
case 'equal':
// 根据字段值的类型,进行数字间的比较
if (typeof fieldValue === 'number') {
return compare_numbers(fieldValue, numberValue, type);
} else if (Array.isArray(fieldValue) || typeof fieldValue === 'string') {
if (typeof fieldValue === 'number' || (typeof fieldValue === 'string' && isPureNumber(fieldValue))) {
return compare_numbers(Number(fieldValue), numberValue, type);
} else if (Array.isArray(fieldValue) || (typeof fieldValue === 'string' && !isPureNumber(fieldValue))) {
// 如果字段值是数组或字符串,比较数组长度和指定值
const valueLength = fieldValue?.length || 0;
return compare_numbers(valueLength, numberValue, type);
@ -260,6 +260,10 @@ export const custom_condition_judg = (fieldValue: any, type: string, value: numb
return true;
}
}
// 判断是否是纯数字
function isPureNumber(input: string) {
return /^\d+$/.test(input);
}
/**
*