diff --git a/pages/evaluate2/index.js b/pages/evaluate2/index.js index 2324627..8543ab6 100644 --- a/pages/evaluate2/index.js +++ b/pages/evaluate2/index.js @@ -211,11 +211,12 @@ Page({ // 解析规格,提取类型(净重/毛重)和数值范围 parseSpecification(spec) { - const weightMatch = spec.match(/(净重|毛重)(\d+)-(\d+)/); - if (weightMatch) { - const type = weightMatch[1]; // 净重或毛重 - const min = parseFloat(weightMatch[2]); - const max = parseFloat(weightMatch[3]); + // 匹配 "净重X-Y" 或 "毛重X-Y" 格式 + const rangeMatch = spec.match(/(净重|毛重)(\d+)-(\d+)/); + if (rangeMatch) { + const type = rangeMatch[1]; // 净重或毛重 + const min = parseFloat(rangeMatch[2]); + const max = parseFloat(rangeMatch[3]); const avg = (min + max) / 2; return { type: type, @@ -224,6 +225,33 @@ Page({ avg: avg }; } + + // 匹配 "净重X+" 或 "毛重X+" 格式 + const plusMatch = spec.match(/(净重|毛重)(\d+)\+/); + if (plusMatch) { + const type = plusMatch[1]; // 净重或毛重 + const value = parseFloat(plusMatch[2]); + return { + type: type, + min: value, + max: value, + avg: value + }; + } + + // 匹配 "净重X" 或 "毛重X" 格式 + const singleMatch = spec.match(/(净重|毛重)(\d+)/); + if (singleMatch) { + const type = singleMatch[1]; // 净重或毛重 + const value = parseFloat(singleMatch[2]); + return { + type: type, + min: value, + max: value, + avg: value + }; + } + return null; },