From 9fc6ff00f9ec71951a0aa0fe148aec88ffd8c36a Mon Sep 17 00:00:00 2001 From: yueli Date: Tue, 8 Sep 2026 11:13:42 +0800 Subject: [PATCH] =?UTF-8?q?feat(bom):=20=E5=87=BA=E5=BA=93/=E5=80=9F?= =?UTF-8?q?=E5=BA=93=E6=B8=85=E5=8D=95=E5=A4=B4=E9=83=A8=20BOM=20=E5=8F=B7?= =?UTF-8?q?=E5=90=8E=E6=98=BE=E7=A4=BA=E7=88=B6=E4=BB=B6=E7=89=A9=E6=96=99?= =?UTF-8?q?=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - selectedBomLabel 追加父件名(优先候选列表 parent_name,回退最近详情 parent_name) - 主清单与欠料待补清单两处头部同时生效;取不到名称时退回原格式 --- inventory-web/src/views/borrow/apply/index.vue | 16 ++++++++++++++-- inventory-web/src/views/outbound/Selection.vue | 16 ++++++++++++++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/inventory-web/src/views/borrow/apply/index.vue b/inventory-web/src/views/borrow/apply/index.vue index c58df26..d390d0a 100644 --- a/inventory-web/src/views/borrow/apply/index.vue +++ b/inventory-web/src/views/borrow/apply/index.vue @@ -574,6 +574,7 @@ const selectedBomNo = ref('') const bomSets = ref(1) const currentBomDetail = ref([]) // 当前选中的BOM明细 const bomPrintTime = ref('') +const bomParentName = ref('') // 最近一次 BOM 详情的父件物料名(打印头部兜底) // BOM 树形数据(将分组数据映射为 el-tree-select 需要的结构) const treeData = computed(() => { @@ -630,10 +631,19 @@ const hasShortage = computed(() => bomDetailList.value.some((item: any) => item. const bomAvailableCount = computed(() => bomDetailList.value.filter(i => i.shortage === 0).length) const bomShortageCount = computed(() => bomDetailList.value.filter(i => i.shortage > 0).length) -// BOM 选择显示标签(bom_no###version → "bom_no (version)") +// BOM 选择显示标签:bom_no###version → "bom_no (version) · 父件物料名" const selectedBomLabel = computed(() => { const [no, ver] = (selectedBomNo.value || '').split('###') - return ver ? `${no} (${ver})` : no + if (!no) return '' + // 先从候选 BOM 列表匹配父件物料名,匹配不到再回退到最近一次详情加载到的名称 + let parentName = '' + for (const grp of bomOptions.value || []) { + const hit = (grp.items || []).find((i: any) => i.bom_no === no && i.version === (ver || i.version)) + if (hit) { parentName = hit.parent_name || ''; break } + } + if (!parentName) parentName = bomParentName.value || '' + const verText = ver ? ` (${ver})` : '' + return parentName ? `${no}${verText} · ${parentName}` : `${no}${verText}` }) // 打印相关 @@ -814,6 +824,7 @@ watch(selectedBomNo, async (newKey) => { try { const detailRes: any = await getBomWithStock(bomNo, version) currentBomDetail.value = detailRes.data?.children || [] + bomParentName.value = detailRes.data?.parent_name || '' } catch (e) { ElMessage.error('加载 BOM 明细失败') currentBomDetail.value = [] @@ -829,6 +840,7 @@ const confirmBomAdd = async () => { const [bomNo, version] = (selectedBomNo.value || '').split('###') const detailRes: any = await getBomWithStock(bomNo, version) currentBomDetail.value = detailRes.data?.children || [] + bomParentName.value = detailRes.data?.parent_name || '' } catch (e) { ElMessage.error('获取 BOM 详情失败') return diff --git a/inventory-web/src/views/outbound/Selection.vue b/inventory-web/src/views/outbound/Selection.vue index ffe9f47..7af1ea7 100644 --- a/inventory-web/src/views/outbound/Selection.vue +++ b/inventory-web/src/views/outbound/Selection.vue @@ -652,13 +652,23 @@ const hasShortage = computed(() => bomDetailList.value.some((item: any) => item. // ★ BOM 打印统计 const bomPrintTime = ref('') +const bomParentName = ref('') // 最近一次 BOM 详情的父件物料名(打印头部兜底) const bomAvailableCount = computed(() => bomDetailList.value.filter(i => i.shortage === 0).length) const bomShortageCount = computed(() => bomDetailList.value.filter(i => i.shortage > 0).length) -// BOM 选择显示标签(bom_no###version → "bom_no (version)") +// BOM 选择显示标签:bom_no###version → "bom_no (version) · 父件物料名" const selectedBomLabel = computed(() => { const [no, ver] = (selectedBomNo.value || '').split('###') - return ver ? `${no} (${ver})` : no + if (!no) return '' + // 先从候选 BOM 列表匹配父件物料名,匹配不到再回退到最近一次详情加载到的名称 + let parentName = '' + for (const grp of bomOptions.value || []) { + const hit = (grp.items || []).find((i: any) => i.bom_no === no && i.version === (ver || i.version)) + if (hit) { parentName = hit.parent_name || ''; break } + } + if (!parentName) parentName = bomParentName.value || '' + const verText = ver ? ` (${ver})` : '' + return parentName ? `${no}${verText} · ${parentName}` : `${no}${verText}` }) // --- 辅助方法 --- @@ -850,6 +860,7 @@ watch(selectedBomNo, async (newKey) => { try { const detailRes: any = await getBomWithStock(bomNo, version) currentBomDetail.value = detailRes.data?.children || [] + bomParentName.value = detailRes.data?.parent_name || '' } catch (e) { ElMessage.error('加载 BOM 明细失败') currentBomDetail.value = [] @@ -865,6 +876,7 @@ const confirmBomAdd = async () => { const [bomNo, version] = (selectedBomNo.value || '').split('###') const detailRes: any = await getBomWithStock(bomNo, version) currentBomDetail.value = detailRes.data?.children || [] + bomParentName.value = detailRes.data?.parent_name || '' } catch (e) { ElMessage.error('获取 BOM 详情失败') return