feat: 修正 BOM 單位顯示與完工入庫彈窗 UI 統一規範
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
|
||||
import { useState, useEffect } from "react";
|
||||
import { Plus, Factory, Search, Eye, Pencil, Trash2 } from 'lucide-react';
|
||||
import { formatQuantity } from "@/lib/utils";
|
||||
import { Button } from "@/Components/ui/button";
|
||||
import AuthenticatedLayout from "@/Layouts/AuthenticatedLayout";
|
||||
import { Head, router, Link } from "@inertiajs/react";
|
||||
@@ -20,8 +21,9 @@ import {
|
||||
SelectTrigger,
|
||||
SelectValue,
|
||||
} from "@/Components/ui/select";
|
||||
import { Badge } from "@/Components/ui/badge";
|
||||
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/Components/ui/table";
|
||||
import ProductionOrderStatusBadge from "@/Components/ProductionOrder/ProductionOrderStatusBadge";
|
||||
import { formatDate } from "@/lib/date";
|
||||
|
||||
interface ProductionOrder {
|
||||
id: number;
|
||||
@@ -32,7 +34,7 @@ interface ProductionOrder {
|
||||
output_batch_number: string;
|
||||
output_quantity: number;
|
||||
production_date: string;
|
||||
status: 'draft' | 'completed' | 'cancelled';
|
||||
status: 'draft' | 'pending' | 'approved' | 'in_progress' | 'completed' | 'cancelled';
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
@@ -51,11 +53,15 @@ interface Props {
|
||||
};
|
||||
}
|
||||
|
||||
const statusConfig: Record<string, { label: string; variant: "default" | "secondary" | "destructive" | "outline" }> = {
|
||||
draft: { label: "草稿", variant: "secondary" },
|
||||
completed: { label: "已完成", variant: "default" },
|
||||
cancelled: { label: "已取消", variant: "destructive" },
|
||||
};
|
||||
const statusOptions = [
|
||||
{ value: 'all', label: '全部狀態' },
|
||||
{ value: 'draft', label: '草稿' },
|
||||
{ value: 'pending', label: '審核中' },
|
||||
{ value: 'approved', label: '已核准' },
|
||||
{ value: 'in_progress', label: '製作中' },
|
||||
{ value: 'completed', label: '已完成' },
|
||||
{ value: 'cancelled', label: '已取消' },
|
||||
];
|
||||
|
||||
export default function ProductionIndex({ productionOrders, filters }: Props) {
|
||||
const [search, setSearch] = useState(filters.search || "");
|
||||
@@ -154,10 +160,11 @@ export default function ProductionIndex({ productionOrders, filters }: Props) {
|
||||
<SelectValue placeholder="選擇狀態" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
<SelectItem value="all">全部狀態</SelectItem>
|
||||
<SelectItem value="draft">草稿</SelectItem>
|
||||
<SelectItem value="completed">已完成</SelectItem>
|
||||
<SelectItem value="cancelled">已取消</SelectItem>
|
||||
{statusOptions.map(opt => (
|
||||
<SelectItem key={opt.value} value={opt.value}>
|
||||
{opt.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
@@ -230,18 +237,16 @@ export default function ProductionIndex({ productionOrders, filters }: Props) {
|
||||
</code>
|
||||
</TableCell>
|
||||
<TableCell className="text-right font-medium">
|
||||
{order.output_quantity.toLocaleString()}
|
||||
{formatQuantity(order.output_quantity)}
|
||||
</TableCell>
|
||||
<TableCell className="text-gray-600">
|
||||
{order.warehouse?.name || '-'}
|
||||
</TableCell>
|
||||
<TableCell className="text-gray-600">
|
||||
{order.production_date}
|
||||
{formatDate(order.production_date)}
|
||||
</TableCell>
|
||||
<TableCell className="text-center">
|
||||
<Badge variant={statusConfig[order.status]?.variant || "secondary"} className="font-normal capitalize">
|
||||
{statusConfig[order.status]?.label || order.status}
|
||||
</Badge>
|
||||
<ProductionOrderStatusBadge status={order.status} />
|
||||
</TableCell>
|
||||
<TableCell className="text-center">
|
||||
<div className="flex items-center justify-center gap-2">
|
||||
@@ -272,19 +277,21 @@ export default function ProductionIndex({ productionOrders, filters }: Props) {
|
||||
</Link>
|
||||
</Can>
|
||||
<Can permission="production_orders.delete">
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="button-outlined-error"
|
||||
title="刪除"
|
||||
onClick={() => {
|
||||
if (confirm('確定要刪除此生產工單嗎?')) {
|
||||
router.delete(route('production-orders.destroy', order.id));
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Trash2 className="h-4 w-4" />
|
||||
</Button>
|
||||
{(order.status === 'draft' || order.status === 'cancelled') && (
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
className="button-outlined-error"
|
||||
title="刪除"
|
||||
onClick={() => {
|
||||
if (confirm('確定要刪除此生產工單嗎?')) {
|
||||
router.delete(route('production-orders.destroy', order.id));
|
||||
}
|
||||
}}
|
||||
>
|
||||
<Trash2 className="h-4 w-4" />
|
||||
</Button>
|
||||
)}
|
||||
</Can>
|
||||
</div>
|
||||
</TableCell>
|
||||
|
||||
Reference in New Issue
Block a user