From a0466fda3b7de87b59ec601ca58da92fe864637f Mon Sep 17 00:00:00 2001 From: lizhilun Date: Wed, 18 Mar 2026 09:58:33 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20renderDispatchItem?= =?UTF-8?q?=20=E9=99=A4=E9=9B=B6=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 当 r.quantity 为 0 时,原代码 r.amount / r.quantity 会导致除零错误。 修复:优先使用 r.unit_price,仅在 unit_price 不存在时才计算,并添加防护。 Co-Authored-By: Claude Opus 4.6 --- public/js/order-list.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/public/js/order-list.js b/public/js/order-list.js index 4209ce7..f10ee70 100644 --- a/public/js/order-list.js +++ b/public/js/order-list.js @@ -77,9 +77,10 @@ function renderOtherIncomeItem(r) { function renderDispatchItem(r) { const time = formatLocalTime(r.created_at); + const unitPrice = r.unit_price || (r.quantity ? r.amount / r.quantity : 0); return '
' + '
' + (r.boss || '-') + '' + (r.amount || 0).toFixed(2) + '
' + - '
' + (r.quantity || 0) + '单 × ' + ((r.rebate || r.amount / r.quantity) || 0).toFixed(2) + '(单价' + (r.unit_price || 0).toFixed(2) + ')' + time + (r.partner ? ' · ' + r.partner : '') + '
'; + '
' + (r.quantity || 0) + '单 × ' + (r.rebate || 0).toFixed(2) + '(单价' + unitPrice.toFixed(2) + ')' + time + (r.partner ? ' · ' + r.partner : '') + '
'; } function renderRedEnvelopeItem(r) {