refactor: simplify cost calculation to 3 fields, drop manual_cost

Co-authored-by: aider (openai/DeepSeek-V3.2-Thinking) <aider@aider.chat>
This commit is contained in:
dxc
2026-03-02 10:24:51 +08:00
parent b688480892
commit 545cd86632
4 changed files with 65 additions and 32 deletions

View File

@ -467,7 +467,8 @@ import {
searchMaterialBase,
searchBom,
getFilterOptions,
getManagerHistory // [新增]
getManagerHistory, // [新增]
calculateBomCost
} from '@/api/inbound/product'
import { uploadFile, deleteFile } from '@/api/inbound/buy'
import WebRtcCamera from '@/components/Camera/WebRtcCamera.vue'
@ -657,7 +658,7 @@ const handleSearchBom = async (query: string) => {
bomOptions.value = res.data || []
} finally { bomSearchLoading.value = false }
}
const handleBomSelect = (val: string) => {
const handleBomSelect = async (val: string) => {
if (!val) {
form.bom_code = ''
form.bom_version = ''
@ -666,6 +667,17 @@ const handleBomSelect = (val: string) => {
const [code, version] = val.split('###')
form.bom_code = code
form.bom_version = version
// 自动计算 BOM 成本并填入 raw_material_cost 和 unit_total_cost
try {
const res: any = await calculateBomCost({ bom_code: code, bom_version: version })
if (res.code === 200 && typeof res.data === 'number') {
form.raw_material_cost = res.data
form.unit_total_cost = res.data
}
} catch (e) {
// 计算失败不影响现有输入
console.warn('BOM 成本计算失败', e)
}
}
// ------------------------------------
@ -1087,4 +1099,4 @@ onMounted(() => {
.product-dropdown { width: 580px !important; }
.product-dropdown .el-select-dropdown__wrap { max-height: 320px !important; }
.product-dropdown .el-input__suffix { z-index: 10; }
</style>
</style>