|
|
@@ -411,31 +411,82 @@ const GoodPickExecutionRecord: React.FC<Props> = ({ filterArgs }) => { |
|
|
|
|
|
|
|
|
// ✅ 转换为平铺格式 |
|
|
// ✅ 转换为平铺格式 |
|
|
const flatLotData: any[] = []; |
|
|
const flatLotData: any[] = []; |
|
|
|
|
|
|
|
|
if (hierarchicalData.pickOrders && hierarchicalData.pickOrders.length > 0) { |
|
|
|
|
|
hierarchicalData.pickOrders.forEach((po: any) => { |
|
|
|
|
|
po.pickOrderLines?.forEach((line: any) => { |
|
|
|
|
|
if (line.lots && line.lots.length > 0) { |
|
|
|
|
|
line.lots.forEach((lot: any) => { |
|
|
|
|
|
flatLotData.push({ |
|
|
|
|
|
pickOrderCode: po.pickOrderCode, |
|
|
|
|
|
itemCode: line.item.code, |
|
|
|
|
|
itemName: line.item.name, |
|
|
|
|
|
lotNo: lot.lotNo, |
|
|
|
|
|
location: lot.location, |
|
|
|
|
|
deliveryOrderCode: po.deliveryOrderCode, |
|
|
|
|
|
requiredQty: lot.requiredQty, |
|
|
|
|
|
actualPickQty: lot.actualPickQty, |
|
|
|
|
|
processingStatus: lot.processingStatus, |
|
|
|
|
|
stockOutLineStatus: lot.stockOutLineStatus |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (hierarchicalData.pickOrders && hierarchicalData.pickOrders.length > 0) { |
|
|
|
|
|
const toProc = (s?: string) => { |
|
|
|
|
|
if (!s) return 'pending'; |
|
|
|
|
|
const v = s.toLowerCase(); |
|
|
|
|
|
if (v === 'completed' || v === 'complete') return 'completed'; |
|
|
|
|
|
if (v === 'rejected') return 'rejected'; |
|
|
|
|
|
if (v === 'partially_completed') return 'pending'; |
|
|
|
|
|
return 'pending'; |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
hierarchicalData.pickOrders.forEach((po: any) => { |
|
|
|
|
|
po.pickOrderLines?.forEach((line: any) => { |
|
|
|
|
|
const lineStockouts = line.stockouts || []; // ← 用“行级” stockouts |
|
|
|
|
|
const lots = line.lots || []; |
|
|
|
|
|
|
|
|
|
|
|
if (lots.length > 0) { |
|
|
|
|
|
lots.forEach((lot: any) => { |
|
|
|
|
|
// 先按该 lot 过滤出匹配的 stockouts(同 lotId) |
|
|
|
|
|
const sos = lineStockouts.filter((so: any) => (so.lotId ?? null) === (lot.id ?? null)); |
|
|
|
|
|
if (sos.length > 0) { |
|
|
|
|
|
sos.forEach((so: any) => { |
|
|
|
|
|
flatLotData.push({ |
|
|
|
|
|
pickOrderCode: po.pickOrderCode, |
|
|
|
|
|
itemCode: line.item?.code, |
|
|
|
|
|
itemName: line.item?.name, |
|
|
|
|
|
lotNo: so.lotNo || lot.lotNo, |
|
|
|
|
|
location: so.location || lot.location, |
|
|
|
|
|
deliveryOrderCode: po.deliveryOrderCode, |
|
|
|
|
|
requiredQty: lot.requiredQty, |
|
|
|
|
|
actualPickQty: (so.qty ?? lot.actualPickQty ?? 0), |
|
|
|
|
|
processingStatus: toProc(so.status), // ← 用 stockouts.status |
|
|
|
|
|
stockOutLineStatus: so.status, // 可选保留 |
|
|
|
|
|
noLot: so.noLot === true |
|
|
}); |
|
|
}); |
|
|
} |
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
} else { |
|
|
|
|
|
// 没有匹配的 stockouts,也要显示 lot |
|
|
|
|
|
flatLotData.push({ |
|
|
|
|
|
pickOrderCode: po.pickOrderCode, |
|
|
|
|
|
itemCode: line.item?.code, |
|
|
|
|
|
itemName: line.item?.name, |
|
|
|
|
|
lotNo: lot.lotNo, |
|
|
|
|
|
location: lot.location, |
|
|
|
|
|
deliveryOrderCode: po.deliveryOrderCode, |
|
|
|
|
|
requiredQty: lot.requiredQty, |
|
|
|
|
|
actualPickQty: lot.actualPickQty ?? 0, |
|
|
|
|
|
processingStatus: lot.processingStatus || 'pending', |
|
|
|
|
|
stockOutLineStatus: lot.stockOutLineStatus || 'pending', |
|
|
|
|
|
noLot: false |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
} else if (lineStockouts.length > 0) { |
|
|
|
|
|
// ✅ lots 为空但有 stockouts(如「雞絲碗仔翅」),也要显示 |
|
|
|
|
|
lineStockouts.forEach((so: any) => { |
|
|
|
|
|
flatLotData.push({ |
|
|
|
|
|
pickOrderCode: po.pickOrderCode, |
|
|
|
|
|
itemCode: line.item?.code, |
|
|
|
|
|
itemName: line.item?.name, |
|
|
|
|
|
lotNo: so.lotNo || '', |
|
|
|
|
|
location: so.location || '', |
|
|
|
|
|
deliveryOrderCode: po.deliveryOrderCode, |
|
|
|
|
|
requiredQty: line.requiredQty ?? 0, // 行级没有 lot 时,用行的 requiredQty |
|
|
|
|
|
actualPickQty: (so.qty ?? 0), |
|
|
|
|
|
processingStatus: toProc(so.status), |
|
|
|
|
|
stockOutLineStatus: so.status, |
|
|
|
|
|
noLot: so.noLot === true |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
setDetailLotData(flatLotData); |
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
setDetailLotData(flatLotData); |
|
|
|
|
|
|
|
|
// ✅ 计算完成状态 |
|
|
// ✅ 计算完成状态 |
|
|
const allCompleted = flatLotData.length > 0 && flatLotData.every(lot => |
|
|
const allCompleted = flatLotData.length > 0 && flatLotData.every(lot => |
|
|
@@ -593,8 +644,8 @@ if (showDetailView && selectedDoPickOrder) { |
|
|
<TableCell align="right">{lot.requiredQty || 0}</TableCell> |
|
|
<TableCell align="right">{lot.requiredQty || 0}</TableCell> |
|
|
<TableCell align="right">{lot.actualPickQty || 0}</TableCell> |
|
|
<TableCell align="right">{lot.actualPickQty || 0}</TableCell> |
|
|
<TableCell align="center"> |
|
|
<TableCell align="center"> |
|
|
<Chip |
|
|
|
|
|
label={t(lot.processingStatus || 'unknown')} |
|
|
|
|
|
|
|
|
<Chip |
|
|
|
|
|
label={t(lot.processingStatus || 'unknown')} |
|
|
color={lot.processingStatus === 'completed' ? 'success' : 'default'} |
|
|
color={lot.processingStatus === 'completed' ? 'success' : 'default'} |
|
|
size="small" |
|
|
size="small" |
|
|
/> |
|
|
/> |
|
|
|