From f5473038c8f51f2a39e764b20f23d82526248c84 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BE=90=E9=A3=9E=E6=B4=8B?= <15778543+xufeiyang6017@user.noreply.gitee.com> Date: Tue, 27 Jan 2026 11:26:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DparseSpecification=E5=87=BD?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E6=94=AF=E6=8C=81=E5=87=80=E9=87=8DX+?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E7=9A=84=E8=A7=84=E6=A0=BC=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/evaluate2/index.js | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) 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; },