diff --git a/inventory-web/src/views/bom/BomManage.vue b/inventory-web/src/views/bom/BomManage.vue index c912bf1..bf36bed 100644 --- a/inventory-web/src/views/bom/BomManage.vue +++ b/inventory-web/src/views/bom/BomManage.vue @@ -69,6 +69,7 @@ class="beautified-select" popper-class="bom-loadmore-popper parent-popper" @visible-change="(visible: boolean) => handleVisibleChange(visible, 'parent')" + @change="onParentChange" > { const res = await getBomDetail(bomNo, version) if (res.code === 200) { const data = res.data - form.parent_id = data.parent_id - form.version = data.version - form.is_enabled = data.is_enabled + // 1. 映射子件基本数据 form.children = data.children.map((child: any) => ({ child_id: child.child_id, dosage: child.dosage, 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) { form.bom_no = (data.parent_spec || '').split('/')[0].trim() } else { diff --git a/inventory-web/src/views/outbound/Selection.vue b/inventory-web/src/views/outbound/Selection.vue index bf6f032..65c0b77 100644 --- a/inventory-web/src/views/outbound/Selection.vue +++ b/inventory-web/src/views/outbound/Selection.vue @@ -498,6 +498,7 @@ const openManualSelect = async () => { warehouse_location: i.warehouse_location || i.warehouse_loc || i.full_path || '', uniqueKey: `${i.type}_${i.id}`, available_quantity: parseFloat(i.available_quantity) || 0, + availableCount: parseFloat(i.available_quantity) || 0, export_quantity: 1 })) } catch (e) {