From 466e94c4ddf8522235da0d7fe1aefc6c04a5932a Mon Sep 17 00:00:00 2001 From: DXC Date: Mon, 20 Apr 2026 18:30:51 +0800 Subject: [PATCH] =?UTF-8?q?fix(inventory):=20=E4=BF=AE=E5=A4=8D=20BOM=20?= =?UTF-8?q?=E7=BC=96=E8=BE=91=E5=9B=9E=E6=98=BE=E6=98=BE=E7=A4=BA=20ID=20?= =?UTF-8?q?=E5=8F=8A=E5=87=BA=E5=BA=93=E9=BD=90=E5=A5=97=E5=88=86=E6=9E=90?= =?UTF-8?q?=E5=BA=93=E5=AD=98=E4=B8=BA=200=20=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inventory-web/src/views/bom/BomManage.vue | 35 ++++++++++++++++--- .../src/views/outbound/Selection.vue | 1 + 2 files changed, 31 insertions(+), 5 deletions(-) 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) {