From 81b9a78ff1dbb5f6592c6bd97c5f79341b468ab6 Mon Sep 17 00:00:00 2001 From: From-wh Date: Tue, 20 Oct 2026 11:05:12 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E5=95=86=E5=93=81):=20=E5=A4=9A=E8=A7=84?= =?UTF-8?q?=E6=A0=BC=E5=9B=9E=E6=98=BE=E6=95=B0=E5=80=BC=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E8=A7=84=E8=8C=83=E5=8C=96=EF=BC=8C=E7=A9=BA=E4=B8=B2=E8=BD=AC?= =?UTF-8?q?=20null=20=E9=98=B2=E8=BE=93=E5=85=A5=E6=A1=86=E5=BC=82?= =?UTF-8?q?=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/pages/plugin/normal/add/index.vue | 32 +++++++++++-------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/frontend/admin/src/pages/plugin/normal/add/index.vue b/frontend/admin/src/pages/plugin/normal/add/index.vue index e20f32623..a6d2307d2 100644 --- a/frontend/admin/src/pages/plugin/normal/add/index.vue +++ b/frontend/admin/src/pages/plugin/normal/add/index.vue @@ -1387,6 +1387,13 @@ function generateAttr(data, val) { manyFormValidate.value = [...oneFormBatch.value, ...rows]; } } + +function normalizeNumber(value, fallback = null) { + if (value === '' || value === undefined || value === null) return fallback; + const number = Number(value); + return Number.isFinite(number) ? number : fallback; +} + // 生成属性批次 function generateAttrBatch(data, combinations, val) { const existingItems = manyFormValidate.value.slice(1); // 排除第一项默认数据 @@ -1405,8 +1412,8 @@ function generateAttrBatch(data, combinations, val) { is_show: 1, is_default_select: 0, unique: '', - weight: '', - volume: '', + weight: null, + volume: null, brokerage: 0, brokerage_two: 0, vip_price: 0, @@ -1426,22 +1433,21 @@ function generateAttrBatch(data, combinations, val) { if (matchedItem) { Object.assign(row, { - price: matchedItem.price, - cost: matchedItem.cost, - original_price: matchedItem.original_price, - stock: matchedItem.stock, + price: normalizeNumber(matchedItem.price, 0), + cost: normalizeNumber(matchedItem.cost, 0), + original_price: normalizeNumber(matchedItem.original_price, 0), + stock: normalizeNumber(matchedItem.stock, 0), pic: matchedItem.pic, unique: matchedItem.unique || '', - weight: matchedItem.weight || '', - volume: matchedItem.volume || '', + weight: normalizeNumber(matchedItem.weight), + volume: normalizeNumber(matchedItem.volume), is_show: matchedItem.is_show || 1, is_default_select: matchedItem.is_default_select || 0, - volume: matchedItem.volume || 0, bar_code_number: matchedItem.bar_code_number || 0, - brokerage: matchedItem.brokerage, - brokerage_two: matchedItem.brokerage_two, - vip_price: matchedItem.vip_price, - vip_proportion: matchedItem.vip_proportion, + brokerage: normalizeNumber(matchedItem.brokerage, 0), + brokerage_two: normalizeNumber(matchedItem.brokerage_two, 0), + vip_price: normalizeNumber(matchedItem.vip_price), + vip_proportion: normalizeNumber(matchedItem.vip_proportion), }); } else if (item.add_pic && combination.includes(val)) { const picItem = item.detail.find((e) => combination.includes(e.value));