更新採購單跟商品資料一些bug
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user