feat(bom): 出库/借库清单头部 BOM 号后显示父件物料名

- selectedBomLabel 追加父件名(优先候选列表 parent_name,回退最近详情 parent_name)
- 主清单与欠料待补清单两处头部同时生效;取不到名称时退回原格式
This commit is contained in:
yueli
2026-09-08 11:13:42 +08:00
parent 02f74278df
commit 9fc6ff00f9
2 changed files with 28 additions and 4 deletions

View File

@ -574,6 +574,7 @@ const selectedBomNo = ref('')
const bomSets = ref(1)
const currentBomDetail = ref<any[]>([]) // 当前选中的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

View File

@ -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