更新採購單跟商品資料一些bug
All checks were successful
Koori-ERP-Deploy-System / deploy-demo (push) Has been skipped
Koori-ERP-Deploy-System / deploy-production (push) Successful in 52s

This commit is contained in:
2026-01-06 15:45:13 +08:00
parent 7160a7e780
commit fad74df6ac
9 changed files with 159 additions and 64 deletions

View File

@@ -46,11 +46,12 @@ export function PurchaseOrderItemsTable({
<Table>
<TableHeader>
<TableRow className="bg-gray-50 hover:bg-gray-50">
<TableHead className="w-[30%] text-left"></TableHead>
<TableHead className="w-[15%] text-left"></TableHead>
<TableHead className="w-[10%] text-left"></TableHead>
<TableHead className="w-[20%] text-left"></TableHead>
<TableHead className="w-[20%] text-left"></TableHead>
<TableHead className="w-[25%] text-left"></TableHead>
<TableHead className="w-[10%] text-left"></TableHead>
<TableHead className="w-[10%] text-left"></TableHead>
<TableHead className="w-[15%] text-left"></TableHead>
<TableHead className="w-[15%] text-left"></TableHead>
<TableHead className="w-[15%] text-left"></TableHead>
{!isReadOnly && <TableHead className="w-[5%]"></TableHead>}
</TableRow>
</TableHeader>
@@ -58,7 +59,7 @@ export function PurchaseOrderItemsTable({
{items.length === 0 ? (
<TableRow>
<TableCell
colSpan={isReadOnly ? 5 : 6}
colSpan={isReadOnly ? 6 : 7}
className="text-center text-gray-400 py-12 italic"
>
{isDisabled ? "請先選擇供應商後才能新增商品" : "尚未新增任何商品項"}
@@ -115,11 +116,20 @@ export function PurchaseOrderItemsTable({
)}
</TableCell>
{/* 單位 */}
{/* 採購單位 */}
<TableCell>
<span className="text-gray-500 font-medium">{item.unit || "-"}</span>
</TableCell>
{/* 換算基本單位 */}
<TableCell>
<span className="text-gray-500 font-medium">
{item.conversion_rate && item.base_unit
? `${parseFloat((item.quantity * item.conversion_rate).toFixed(2))} ${item.base_unit}`
: "-"}
</span>
</TableCell>
{/* 單價 */}
<TableCell className="text-left">
{isReadOnly ? (
@@ -135,12 +145,23 @@ export function PurchaseOrderItemsTable({
onItemChange?.(index, "unitPrice", Number(e.target.value))
}
disabled={isDisabled}
className={`h-10 text-left w-32 ${isPriceAlert(item.unitPrice, item.previousPrice)
? "border-amber-400 bg-amber-50 focus-visible:ring-amber-500"
: "border-gray-200"
className={`h-10 text-left w-32 ${
// 如果有數量但沒有單價,顯示錯誤樣式
item.quantity > 0 && (!item.unitPrice || item.unitPrice <= 0)
? "border-red-400 bg-red-50 focus-visible:ring-red-500"
: isPriceAlert(item.unitPrice, item.previousPrice)
? "border-amber-400 bg-amber-50 focus-visible:ring-amber-500"
: "border-gray-200"
}`}
/>
{isPriceAlert(item.unitPrice, item.previousPrice) && (
{/* 錯誤提示:有數量但沒有單價 */}
{item.quantity > 0 && (!item.unitPrice || item.unitPrice <= 0) && (
<p className="text-[10px] text-red-600 font-medium">
</p>
)}
{/* 價格警示:單價高於上次 */}
{item.unitPrice > 0 && isPriceAlert(item.unitPrice, item.previousPrice) && (
<p className="text-[10px] text-amber-600 font-medium animate-pulse">
: {formatCurrency(item.previousPrice || 0)}
</p>