fix: 修复 renderDispatchItem 除零问题
当 r.quantity 为 0 时,原代码 r.amount / r.quantity 会导致除零错误。 修复:优先使用 r.unit_price,仅在 unit_price 不存在时才计算,并添加防护。 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.6
parent
2ebac98f07
commit
a0466fda3b
@@ -77,9 +77,10 @@ function renderOtherIncomeItem(r) {
|
|||||||
|
|
||||||
function renderDispatchItem(r) {
|
function renderDispatchItem(r) {
|
||||||
const time = formatLocalTime(r.created_at);
|
const time = formatLocalTime(r.created_at);
|
||||||
|
const unitPrice = r.unit_price || (r.quantity ? r.amount / r.quantity : 0);
|
||||||
return '<div class="order-item" onclick=\'openEditModal(' + JSON.stringify(r).replace(/'/g, "'") + ')\'>' +
|
return '<div class="order-item" onclick=\'openEditModal(' + JSON.stringify(r).replace(/'/g, "'") + ')\'>' +
|
||||||
'<div class="order-item-top"><span class="order-item-boss">' + (r.boss || '-') + '</span><span class="order-item-amount">' + (r.amount || 0).toFixed(2) + '</span></div>' +
|
'<div class="order-item-top"><span class="order-item-boss">' + (r.boss || '-') + '</span><span class="order-item-amount">' + (r.amount || 0).toFixed(2) + '</span></div>' +
|
||||||
'<div class="order-item-bottom"><span>' + (r.quantity || 0) + '单 × ' + ((r.rebate || r.amount / r.quantity) || 0).toFixed(2) + '(单价' + (r.unit_price || 0).toFixed(2) + ')</span><span>' + time + (r.partner ? ' · ' + r.partner : '') + '</span></div></div>';
|
'<div class="order-item-bottom"><span>' + (r.quantity || 0) + '单 × ' + (r.rebate || 0).toFixed(2) + '(单价' + unitPrice.toFixed(2) + ')</span><span>' + time + (r.partner ? ' · ' + r.partner : '') + '</span></div></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderRedEnvelopeItem(r) {
|
function renderRedEnvelopeItem(r) {
|
||||||
|
|||||||
Reference in New Issue
Block a user