feat: API調整訂單與販賣機訂單同步強制使用warehouse_code,更新API對接文件,及優化生產與配方模組UI顯示
All checks were successful
ERP-Deploy-Demo / deploy-demo (push) Successful in 55s

This commit is contained in:
2026-03-03 14:28:15 +08:00
parent 58bd995cd8
commit 183583c739
19 changed files with 486 additions and 89 deletions

View File

@@ -36,6 +36,7 @@ interface ProductionOrderItem {
origin_country: string | null;
product: { id: number; name: string; code: string } | null;
warehouse?: { id: number; name: string } | null;
unit_cost?: number;
source_purchase_order?: {
id: number;
code: string;
@@ -109,6 +110,13 @@ export default function ProductionShow({ productionOrder, warehouses, auth }: Pr
const canCancel = hasPermission('production_orders.cancel');
const canEdit = hasPermission('production_orders.edit');
// 計算總預估成本
const totalEstimatedCost = productionOrder.items.reduce((sum, item) => {
const qty = Number(item.quantity_used) || 0;
const cost = Number(item.inventory?.unit_cost) || 0;
return sum + (qty * cost);
}, 0);
return (
<AuthenticatedLayout breadcrumbs={getBreadcrumbs("productionOrdersShow")}>
<Head title={`生產單 ${productionOrder.code}`} />
@@ -368,6 +376,8 @@ export default function ProductionShow({ productionOrder, warehouses, auth }: Pr
<TableHead className="px-6 py-4 text-xs font-bold text-grey-2 uppercase tracking-widest leading-none">使</TableHead>
<TableHead className="px-6 py-4 text-xs font-bold text-grey-2 uppercase tracking-widest leading-none text-center"></TableHead>
<TableHead className="px-6 py-4 text-xs font-bold text-grey-2 uppercase tracking-widest leading-none">使</TableHead>
<TableHead className="px-6 py-4 text-xs font-bold text-grey-2 uppercase tracking-widest leading-none text-right"></TableHead>
<TableHead className="px-6 py-4 text-xs font-bold text-grey-2 uppercase tracking-widest leading-none text-right"></TableHead>
<TableHead className="px-6 py-4 text-xs font-bold text-grey-2 uppercase tracking-widest leading-none"></TableHead>
</TableRow>
</TableHeader>
@@ -404,6 +414,16 @@ export default function ProductionShow({ productionOrder, warehouses, auth }: Pr
)}
</div>
</TableCell>
<TableCell className="px-6 py-5 text-right">
<div className="text-grey-0 font-medium">
{Number(item.inventory?.unit_cost || 0).toLocaleString(undefined, { maximumFractionDigits: 2 })}
</div>
</TableCell>
<TableCell className="px-6 py-5 text-right">
<div className="font-bold text-grey-900">
{(Number(item.quantity_used) * Number(item.inventory?.unit_cost || 0)).toLocaleString(undefined, { maximumFractionDigits: 2 })}
</div>
</TableCell>
<TableCell className="px-6 py-5">
{item.inventory?.source_purchase_order ? (
<div className="group flex flex-col">
@@ -428,6 +448,22 @@ export default function ProductionShow({ productionOrder, warehouses, auth }: Pr
))}
</TableBody>
</Table>
<div className="bg-gray-50 p-6 border-t border-grey-4 flex justify-end">
<div className="min-w-[300px]">
<div className="flex justify-between items-center mb-2">
<span className="text-sm text-gray-600"></span>
<span className="text-lg font-bold text-gray-900">{totalEstimatedCost.toLocaleString(undefined, { maximumFractionDigits: 2 })} </span>
</div>
<div className="flex justify-between items-center pt-2 border-t border-gray-200">
<span className="text-sm font-medium text-gray-700">
<span className="text-xs text-gray-500 ml-1">( {Number(productionOrder.output_quantity || 0).toLocaleString(undefined, { maximumFractionDigits: 4 })} )</span>
</span>
<span className="text-md font-bold text-primary-main">
{(productionOrder.output_quantity > 0 ? totalEstimatedCost / productionOrder.output_quantity : 0).toLocaleString(undefined, { maximumFractionDigits: 2 })}
</span>
</div>
</div>
</div>
</div>
)}
</div>