fix(inventory): 修复 BOM 编辑回显显示 ID 及出库齐套分析库存为 0 的问题
This commit is contained in:
@ -69,6 +69,7 @@
|
|||||||
class="beautified-select"
|
class="beautified-select"
|
||||||
popper-class="bom-loadmore-popper parent-popper"
|
popper-class="bom-loadmore-popper parent-popper"
|
||||||
@visible-change="(visible: boolean) => handleVisibleChange(visible, 'parent')"
|
@visible-change="(visible: boolean) => handleVisibleChange(visible, 'parent')"
|
||||||
|
@change="onParentChange"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
v-for="item in parentOptions"
|
v-for="item in parentOptions"
|
||||||
@ -603,16 +604,40 @@ const loadDetail = async (bomNo: string, version: string) => {
|
|||||||
const res = await getBomDetail(bomNo, version)
|
const res = await getBomDetail(bomNo, version)
|
||||||
if (res.code === 200) {
|
if (res.code === 200) {
|
||||||
const data = res.data
|
const data = res.data
|
||||||
form.parent_id = data.parent_id
|
// 1. 映射子件基本数据
|
||||||
form.version = data.version
|
|
||||||
form.is_enabled = data.is_enabled
|
|
||||||
form.children = data.children.map((child: any) => ({
|
form.children = data.children.map((child: any) => ({
|
||||||
child_id: child.child_id,
|
child_id: child.child_id,
|
||||||
dosage: child.dosage,
|
dosage: child.dosage,
|
||||||
remark: child.remark || ''
|
remark: child.remark || ''
|
||||||
}))
|
}))
|
||||||
// 为每个子件行初始化下拉状态
|
|
||||||
form.children.forEach((_, idx) => initChildDropdownState(idx))
|
// 2. 初始化子件下拉状态,并预填充 options 解决回显显示 ID 的问题
|
||||||
|
form.children.forEach((child, idx) => {
|
||||||
|
initChildDropdownState(idx)
|
||||||
|
|
||||||
|
if (child.child_id) {
|
||||||
|
const state = childDropdownStates.value.get(idx)!
|
||||||
|
// 从原始 data.children 中取对应的名称和规格注入 options
|
||||||
|
const rawChildData = data.children[idx]
|
||||||
|
state.options = [{
|
||||||
|
id: rawChildData.child_id,
|
||||||
|
name: rawChildData.child_name || '未知物料', // 依赖后端返回 child_name
|
||||||
|
spec: rawChildData.child_spec || '' // 依赖后端返回 child_spec
|
||||||
|
}]
|
||||||
|
state.hasMore = false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 3. 处理父件回显,预填充 parentOptions
|
||||||
|
if (data.parent_id) {
|
||||||
|
form.parent_id = data.parent_id
|
||||||
|
parentOptions.value = [{
|
||||||
|
id: data.parent_id,
|
||||||
|
name: data.parent_name || '未知产品', // 依赖后端返回 parent_name
|
||||||
|
spec: data.parent_spec || '' // 依赖后端返回 parent_spec
|
||||||
|
}]
|
||||||
|
}
|
||||||
|
|
||||||
if (data.parent_spec) {
|
if (data.parent_spec) {
|
||||||
form.bom_no = (data.parent_spec || '').split('/')[0].trim()
|
form.bom_no = (data.parent_spec || '').split('/')[0].trim()
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@ -498,6 +498,7 @@ const openManualSelect = async () => {
|
|||||||
warehouse_location: i.warehouse_location || i.warehouse_loc || i.full_path || '',
|
warehouse_location: i.warehouse_location || i.warehouse_loc || i.full_path || '',
|
||||||
uniqueKey: `${i.type}_${i.id}`,
|
uniqueKey: `${i.type}_${i.id}`,
|
||||||
available_quantity: parseFloat(i.available_quantity) || 0,
|
available_quantity: parseFloat(i.available_quantity) || 0,
|
||||||
|
availableCount: parseFloat(i.available_quantity) || 0,
|
||||||
export_quantity: 1
|
export_quantity: 1
|
||||||
}))
|
}))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|||||||
Reference in New Issue
Block a user