fix: 出库选单 BOM 下拉唯一值修复,打印模板补齐欠料待补区与借库对齐
This commit is contained in:
@ -268,7 +268,7 @@
|
|||||||
<div id="bom-print-area" class="print-bom-area" style="display:none;">
|
<div id="bom-print-area" class="print-bom-area" style="display:none;">
|
||||||
<h2 style="text-align:center; margin:0 0 8px;">BOM 出库清单</h2>
|
<h2 style="text-align:center; margin:0 0 8px;">BOM 出库清单</h2>
|
||||||
<p style="text-align:center; margin:0 0 16px; font-size:13px;">
|
<p style="text-align:center; margin:0 0 16px; font-size:13px;">
|
||||||
BOM: <b>{{ selectedBomNo }}</b> | 套数: <b>{{ bomSets }}</b> 套 | 生成时间: {{ bomPrintTime }}
|
BOM: <b>{{ selectedBomLabel }}</b> | 套数: <b>{{ bomSets }}</b> 套 | 生成时间: {{ bomPrintTime }}
|
||||||
</p>
|
</p>
|
||||||
<table class="print-table">
|
<table class="print-table">
|
||||||
<thead>
|
<thead>
|
||||||
@ -296,6 +296,9 @@
|
|||||||
|
|
||||||
<!-- ★ 欠料待补签收区(仅当有缺货时打印此联) -->
|
<!-- ★ 欠料待补签收区(仅当有缺货时打印此联) -->
|
||||||
<div v-if="bomShortageCount > 0" style="margin-top: 20px; border-top: 2px dashed #000; padding-top: 10px;">
|
<div v-if="bomShortageCount > 0" style="margin-top: 20px; border-top: 2px dashed #000; padding-top: 10px;">
|
||||||
|
<p style="text-align:center; margin:0 0 8px; font-size:13px;">
|
||||||
|
BOM: <b>{{ selectedBomLabel }}</b> | 套数: <b>{{ bomSets }}</b> 套 | 生成时间: {{ bomPrintTime }}
|
||||||
|
</p>
|
||||||
<p style="font-weight: bold; font-size: 14px;">⚠️ 欠料待补清单(请补料后在此签字)</p>
|
<p style="font-weight: bold; font-size: 14px;">⚠️ 欠料待补清单(请补料后在此签字)</p>
|
||||||
<table class="print-table" style="margin-top: 6px;">
|
<table class="print-table" style="margin-top: 6px;">
|
||||||
<thead>
|
<thead>
|
||||||
@ -560,7 +563,8 @@ const treeData = computed(() => {
|
|||||||
label: `${group.category} (${group.count})`,
|
label: `${group.category} (${group.count})`,
|
||||||
disabled: true, // 禁止选中分类本身
|
disabled: true, // 禁止选中分类本身
|
||||||
children: (group.items || []).map((b: any) => ({
|
children: (group.items || []).map((b: any) => ({
|
||||||
value: b.bom_no,
|
// ★ 用 bom_no + version 组合作为唯一 value,避免同一产品多版本时回显错乱
|
||||||
|
value: `${b.bom_no}###${b.version}`,
|
||||||
label: `${b.bom_no} - ${b.parent_name} - ${b.version}`
|
label: `${b.bom_no} - ${b.parent_name} - ${b.version}`
|
||||||
}))
|
}))
|
||||||
}))
|
}))
|
||||||
@ -635,6 +639,12 @@ const bomPrintTime = ref('')
|
|||||||
const bomAvailableCount = computed(() => bomDetailList.value.filter(i => i.shortage === 0).length)
|
const bomAvailableCount = computed(() => bomDetailList.value.filter(i => i.shortage === 0).length)
|
||||||
const bomShortageCount = 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)")
|
||||||
|
const selectedBomLabel = computed(() => {
|
||||||
|
const [no, ver] = (selectedBomNo.value || '').split('###')
|
||||||
|
return ver ? `${no} (${ver})` : no
|
||||||
|
})
|
||||||
|
|
||||||
// --- 辅助方法 ---
|
// --- 辅助方法 ---
|
||||||
const getTypeTag = (type: string) => {
|
const getTypeTag = (type: string) => {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
@ -808,35 +818,21 @@ const openBomSelect = async () => {
|
|||||||
category, count: items.length, items
|
category, count: items.length, items
|
||||||
}))
|
}))
|
||||||
|
|
||||||
// ★ 提示有历史缺货记录的 BOM,防止下次重复出/漏出
|
|
||||||
const pendingBoms = Object.keys(bomShortageRecords.value).filter(no =>
|
|
||||||
flatItems.some(i => i.bom_no === no)
|
|
||||||
)
|
|
||||||
if (pendingBoms.length > 0) {
|
|
||||||
ElMessageBox.confirm(
|
|
||||||
`检测到以下 BOM 存在未完成的缺货记录(上次按 BOM 出库时缺货):\n\n` +
|
|
||||||
pendingBoms.map(no => {
|
|
||||||
const rec = bomShortageRecords.value[no]
|
|
||||||
return `• ${no}(${rec.items.length} 种缺货,${rec.time})`
|
|
||||||
}).join('\n') +
|
|
||||||
`\n\n建议先补货后再出库,避免漏出。`,
|
|
||||||
'存在未完成出库',
|
|
||||||
{ confirmButtonText: '知道了', cancelButtonText: '忽略', type: 'warning' }
|
|
||||||
).catch(() => {})
|
|
||||||
}
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ElMessage.error('加载 BOM 列表失败')
|
ElMessage.error('加载 BOM 列表失败')
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 监听 BOM 选择变化,自动加载明细(含库存)并计算齐套性
|
// 监听 BOM 选择变化,自动加载明细(含库存)并计算齐套性
|
||||||
watch(selectedBomNo, async (newBomNo) => {
|
watch(selectedBomNo, async (newKey) => {
|
||||||
if (!newBomNo) {
|
if (!newKey) {
|
||||||
currentBomDetail.value = []
|
currentBomDetail.value = []
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
// ★ 组合 key 拆解为 bom_no + version,按选中版本精确拉取明细
|
||||||
|
const [bomNo, version] = newKey.split('###')
|
||||||
try {
|
try {
|
||||||
const detailRes: any = await getBomWithStock(newBomNo)
|
const detailRes: any = await getBomWithStock(bomNo, version)
|
||||||
currentBomDetail.value = detailRes.data?.children || []
|
currentBomDetail.value = detailRes.data?.children || []
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ElMessage.error('加载 BOM 明细失败')
|
ElMessage.error('加载 BOM 明细失败')
|
||||||
@ -849,7 +845,9 @@ const confirmBomAdd = async () => {
|
|||||||
|
|
||||||
if (currentBomDetail.value.length === 0) {
|
if (currentBomDetail.value.length === 0) {
|
||||||
try {
|
try {
|
||||||
const detailRes: any = await getBomWithStock(selectedBomNo.value)
|
// ★ 组合 key 拆解为 bom_no + version,按选中版本精确拉取明细
|
||||||
|
const [bomNo, version] = (selectedBomNo.value || '').split('###')
|
||||||
|
const detailRes: any = await getBomWithStock(bomNo, version)
|
||||||
currentBomDetail.value = detailRes.data?.children || []
|
currentBomDetail.value = detailRes.data?.children || []
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ElMessage.error('获取 BOM 详情失败')
|
ElMessage.error('获取 BOM 详情失败')
|
||||||
|
|||||||
Reference in New Issue
Block a user