置换默认一份旧料换多件新货,统一结算差重与寄存

This commit is contained in:
summer committed 2026-11-27 15:48:37 +08:00
1 parent b070da1e3d
commit 9186480118
5 files changed
+35 -14

No files matched your search

+1 -1
View File
@@ -24,7 +24,7 @@ function recoveryEditPanelHTML(data){
return `${data.status==='cancelled'?'<div class="note">本单已取消,原记录和更正历史保留。</div>':''}${data.permissions.reason?`<p class="small muted">${e(data.permissions.reason)}</p>`:''}${recoveryMaterialBatchHTML(data.record.materialBatch)}${recoveryBlockedHTML(data.blockedUsages)}${data.permissions.canCancel&&data.blockedUsages.length?recoveryCancellationMaterialHTML():''}${data.pending?`<section class="panel recovery-change-pending"><h3>待麦麦复核</h3><p class="small muted">原记录仍生效,申请尚未记账。</p>${recoveryChangeComparisonHTML(data.pending)}${button(state.user.role==='owner'?'查看并复核':'查看申请','recovery-change-open','',`data-id="${e(data.pending.id)}"`)}</section>`:''}${data.history.length?`<details><summary>更正与取消记录(${data.history.length})</summary><ul class="timeline">${data.history.map(row=>`<li>${e(recoveryChangeStatus(row))} · ${e(row.requesterName||'未提供')}${row.reviewerName?' · '+e(row.reviewerName)+'复核':''}${row.note?'<p>'+e(row.note)+'</p>':''}${button('查看前后内容','recovery-change-open','quiet',`data-id="${e(row.id)}"`)}</li>`).join('')}</ul></details>`:''}`;
}
function recoveryEditDraft(input){
if(input.exchange?.items){const rows=input.exchange.items.map(row=>recoveryEditDraft({...input,...row,exchange:row.exchange})),first=rows[0],x=input.exchange;return {...first,independent_products:true,extra_products:rows.slice(1),charges:x.charges,charge_name:x.charges[0]?.name||'其他收费',charge_amount:x.charges[0]?.amount||'0',fee_items:x.fee_items,fee_note:x.fee_items[0]?.note||'其他费用',fee_amount:x.fee_items[0]?.amount||'0',fee_payer:x.fee_items[0]?.payer||input.member,discount:x.discount,rounding_mode:x.rounding_mode};}
if(input.exchange?.items){const rows=input.exchange.items.map(row=>recoveryEditDraft({...input,...row,exchange:row.exchange})),first=rows[0],x=input.exchange;return {...first,independent_products:rows.length>1,extra_products:rows.slice(1),charges:x.charges,charge_name:x.charges[0]?.name||'其他收费',charge_amount:x.charges[0]?.amount||'0',fee_items:x.fee_items,fee_note:x.fee_items[0]?.note||'其他费用',fee_amount:x.fee_items[0]?.amount||'0',fee_payer:x.fee_items[0]?.payer||input.member,discount:x.discount,rounding_mode:x.rounding_mode};}
const first=input.old_lines[0],x=input.exchange||{},charge=x.charges?.[0],fee=x.fee_items?.[0],account=input.payment_account||'',recipient=account.startsWith('麦麦')?'麦麦':account.startsWith('助理2')?'助理2':'助理',method=account.replace(/^(麦麦|助理2|助理1|助理)/,'');
return {...recoveryDefaults(input.mode),mode:input.mode,surplus_mode:input.surplus_mode||'buy',surplus_memo:input.surplus_memo||'',old_source:input.old_source||'incoming',deposit_id:input.deposit_id||'',deposit_weight:input.deposit_weight||'',date:input.date,customer:input.customer,salesperson:input.salesperson,member:input.member,note:input.note||'',old_pocket:input.old_pocket??'回收旧料',old_stock_count:input.old_stock_count??'',old_name:first.name,incoming_weight:first.incoming_weight,melted_weight:first.melted_weight,purity:first.purity,old_lines:JSON.parse(JSON.stringify(input.old_lines)),buy_rate:input.buy_rate,buy_total:input.buy_total??'',buy_total_manual:Object.hasOwn(input,'buy_total'),melted_manual:true,depreciation_manual:Object.hasOwn(x,'depreciation_weight'),payer:input.payer,payment_method:method,payment_recipient:recipient,payout_method:method==='信用卡'?'微信':method,new_name:x.name||'足金999',new_quantity:x.quantity||'',pocket:x.pocket??state.pockets[0]??'',stockCount:x.stockCount??'',gold_price:x.gold_price||'0',labor_mode:x.labor_mode||'gram',labor_rate:x.labor_rate||'0',depreciation_weight:x.depreciation_weight??'',depreciation_rate:x.depreciation_rate||'0',charge_name:charge?.name||'其他收费',charge_amount:charge?.amount||'0',charges:JSON.parse(JSON.stringify(x.charges||[])),discount:x.discount||'0',rounding_mode:x.rounding_mode||'cent',material_source:x.cost_material?.mode==='pool'?'pool':'manual',material_pool_id:x.cost_material?.poolId||input.date,material_rate:x.cost_material?.rate||'',material_payer:x.cost_material_payer||input.member,cost_labor_mode:x.cost_labor?.mode||'total',cost_labor_value:x.cost_labor?.mode==='gram'?x.cost_labor.rate:x.cost_labor?.amount??'',cost_payer:x.cost_payer||input.member,labor_payer:x.cost_labor_payer||x.cost_payer||input.member,fee_note:fee?.note||'其他费用',fee_amount:fee?.amount||'0',fee_payer:fee?.payer||input.member,fee_items:JSON.parse(JSON.stringify(x.fee_items||[])),...(x.products?{...recoveryProductDraft(x.products[0]),extra_products:x.products.slice(1).map(recoveryProductDraft)}:{}),verified:false};
}