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:
dxc
2026-03-02 16:47:49 +08:00
parent a5fcbd70f8
commit 71e763bcb6
2 changed files with 40 additions and 11 deletions

View File

@ -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