feat: calculate semi-inbound cost based on BOM code
Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
This commit is contained in:
@ -807,11 +807,24 @@ const form = reactive({
|
||||
})
|
||||
|
||||
// === 监听计算总成本 ===
|
||||
watch([() => form.unit_total_cost, () => form.in_quantity], ([unit, qty]) => {
|
||||
const unitNum = Number(unit || 0)
|
||||
const qtyNum = Number(qty || 1)
|
||||
form.total_price = Number((unitNum * qtyNum).toFixed(2))
|
||||
})
|
||||
const computeTotalPrice = () => {
|
||||
let unitCost = 0
|
||||
if (form.bom_code) {
|
||||
// 如果BOM编号有值,则单价采用基于BOM成本 (unit_total_cost)
|
||||
unitCost = Number(form.unit_total_cost || 0)
|
||||
} else {
|
||||
// 如果BOM编号为空,则单价采用估算成本 (raw_material_cost)
|
||||
unitCost = Number(form.raw_material_cost || 0)
|
||||
}
|
||||
const qty = Number(form.in_quantity || 1)
|
||||
form.total_price = Number((unitCost * qty).toFixed(2))
|
||||
}
|
||||
|
||||
watch(
|
||||
() => [form.bom_code, form.unit_total_cost, form.raw_material_cost, form.in_quantity],
|
||||
() => computeTotalPrice(),
|
||||
{ immediate: true, deep: false }
|
||||
)
|
||||
|
||||
// ------------------------------------
|
||||
// BOM Search Logic
|
||||
|
||||
Reference in New Issue
Block a user