fix: 出库备注欠料改用实时库存计算,不再自动填历史欠料
- buildRemarkWithShortage 改用 bomDetailList 实时 shortage(需量-当前库存) - 库存补足后,欠料不再自动拼进出库备注(原 localStorage 历史记录一直带出)
This commit is contained in:
@ -937,23 +937,16 @@ const confirmBomAdd = async () => {
|
||||
const BOM_SHORTAGE_KEY = 'MOM_BOM_SHORTAGE_RECORDS'
|
||||
const bomShortageRecords = ref<Record<string, any>>(JSON.parse(localStorage.getItem(BOM_SHORTAGE_KEY) || '{}'))
|
||||
|
||||
// ★ 将缺货清单拼接进备注(借鸡生蛋:历史缺货记录永久留存在出库申请单备注)
|
||||
// ★ 将缺货清单拼接进备注(仅拼当前实际缺货的物料,库存补足后不再出现)
|
||||
const buildRemarkWithShortage = (baseRemark: string): string => {
|
||||
const parts: string[] = []
|
||||
if (baseRemark) parts.push(baseRemark)
|
||||
|
||||
const shortageBoms = Object.keys(bomShortageRecords.value)
|
||||
if (shortageBoms.length > 0) {
|
||||
const detail: string[] = []
|
||||
for (const no of shortageBoms) {
|
||||
const rec = bomShortageRecords.value[no]
|
||||
if (!rec?.items?.length) continue
|
||||
const items = rec.items.map((i: any) => `${i.name}(${i.shortage}个)`).join('、')
|
||||
detail.push(`${no}: ${items}`)
|
||||
}
|
||||
if (detail.length > 0) {
|
||||
parts.push(`[BOM欠料待补] ${detail.join(';')}`)
|
||||
}
|
||||
// ★ 用当前实时计算的缺货清单(需量 - 当前库存),而非 localStorage 历史记录
|
||||
const shortageItems = bomDetailList.value.filter((i: any) => i.shortage > 0)
|
||||
if (shortageItems.length > 0) {
|
||||
const items = shortageItems.map((i: any) => `${i.name}(${i.shortage}个)`).join('、')
|
||||
parts.push(`[BOM欠料待补] ${items}`)
|
||||
}
|
||||
|
||||
return parts.join(' | ')
|
||||
|
||||
Reference in New Issue
Block a user