修改自定义条件处理

master
于肖磊 2025-04-07 16:03:16 +08:00
parent 1780699219
commit 2dd9b7872a
1 changed files with 7 additions and 2 deletions

View File

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