2026-01-28 18:04:45 +08:00
|
|
|
|
|
2026-01-29 14:37:21 +08:00
|
|
|
|
import { useState, useCallback, useEffect } from "react";
|
2026-01-28 18:04:45 +08:00
|
|
|
|
import AuthenticatedLayout from "@/Layouts/AuthenticatedLayout";
|
|
|
|
|
|
import { Head, Link, router } from "@inertiajs/react";
|
2026-01-29 14:37:21 +08:00
|
|
|
|
import { debounce } from "lodash";
|
|
|
|
|
|
import { SearchableSelect } from "@/Components/ui/searchable-select";
|
2026-02-13 13:16:05 +08:00
|
|
|
|
import { StatusBadge } from "@/Components/shared/StatusBadge";
|
2026-01-28 18:04:45 +08:00
|
|
|
|
import {
|
|
|
|
|
|
Table,
|
|
|
|
|
|
TableBody,
|
|
|
|
|
|
TableCell,
|
|
|
|
|
|
TableHead,
|
|
|
|
|
|
TableHeader,
|
|
|
|
|
|
TableRow,
|
|
|
|
|
|
} from "@/Components/ui/table";
|
|
|
|
|
|
import { Button } from "@/Components/ui/button";
|
|
|
|
|
|
import { Input } from "@/Components/ui/input";
|
|
|
|
|
|
import {
|
|
|
|
|
|
Dialog,
|
|
|
|
|
|
DialogContent,
|
|
|
|
|
|
DialogHeader,
|
|
|
|
|
|
DialogTitle,
|
|
|
|
|
|
DialogTrigger,
|
|
|
|
|
|
DialogFooter,
|
2026-01-29 14:37:21 +08:00
|
|
|
|
DialogDescription,
|
2026-01-28 18:04:45 +08:00
|
|
|
|
} from "@/Components/ui/dialog";
|
|
|
|
|
|
import { Label } from "@/Components/ui/label";
|
|
|
|
|
|
import {
|
|
|
|
|
|
Plus,
|
|
|
|
|
|
Search,
|
|
|
|
|
|
ArrowLeftRight,
|
|
|
|
|
|
Loader2,
|
2026-01-29 14:37:21 +08:00
|
|
|
|
Eye,
|
|
|
|
|
|
Pencil,
|
|
|
|
|
|
Trash2,
|
|
|
|
|
|
X,
|
2026-01-28 18:04:45 +08:00
|
|
|
|
} from "lucide-react";
|
2026-01-29 14:37:21 +08:00
|
|
|
|
import {
|
|
|
|
|
|
AlertDialog,
|
|
|
|
|
|
AlertDialogAction,
|
|
|
|
|
|
AlertDialogCancel,
|
|
|
|
|
|
AlertDialogContent,
|
|
|
|
|
|
AlertDialogDescription,
|
|
|
|
|
|
AlertDialogFooter,
|
|
|
|
|
|
AlertDialogHeader,
|
|
|
|
|
|
AlertDialogTitle,
|
|
|
|
|
|
} from "@/Components/ui/alert-dialog";
|
2026-01-28 18:04:45 +08:00
|
|
|
|
import Pagination from "@/Components/shared/Pagination";
|
|
|
|
|
|
import { toast } from "sonner";
|
2026-01-29 14:37:21 +08:00
|
|
|
|
import { Can } from '@/Components/Permission/Can';
|
2026-02-03 17:29:32 +08:00
|
|
|
|
import { usePermission } from '@/hooks/usePermission';
|
2026-01-29 14:37:21 +08:00
|
|
|
|
|
|
|
|
|
|
export default function Index({ warehouses, orders, filters }: any) {
|
2026-02-03 17:29:32 +08:00
|
|
|
|
const { can } = usePermission();
|
2026-01-29 14:37:21 +08:00
|
|
|
|
const [searchTerm, setSearchTerm] = useState(filters.search || "");
|
|
|
|
|
|
const [warehouseFilter, setWarehouseFilter] = useState(filters.warehouse_id || "all");
|
|
|
|
|
|
const [perPage, setPerPage] = useState(filters.per_page || "10");
|
2026-01-28 18:04:45 +08:00
|
|
|
|
|
2026-01-29 14:37:21 +08:00
|
|
|
|
// Sync state with props
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
setSearchTerm(filters.search || "");
|
|
|
|
|
|
setWarehouseFilter(filters.warehouse_id || "all");
|
|
|
|
|
|
setPerPage(filters.per_page || "10");
|
|
|
|
|
|
}, [filters]);
|
2026-01-28 18:04:45 +08:00
|
|
|
|
|
|
|
|
|
|
// Create Dialog State
|
|
|
|
|
|
const [isCreateOpen, setIsCreateOpen] = useState(false);
|
|
|
|
|
|
const [sourceWarehouseId, setSourceWarehouseId] = useState("");
|
|
|
|
|
|
const [targetWarehouseId, setTargetWarehouseId] = useState("");
|
|
|
|
|
|
const [creating, setCreating] = useState(false);
|
2026-01-29 14:37:21 +08:00
|
|
|
|
const [deleteId, setDeleteId] = useState<string | null>(null);
|
2026-01-28 18:04:45 +08:00
|
|
|
|
|
2026-01-29 14:37:21 +08:00
|
|
|
|
// Debounced Search Handler
|
|
|
|
|
|
const debouncedSearch = useCallback(
|
|
|
|
|
|
debounce((term: string, warehouse: string) => {
|
|
|
|
|
|
router.get(
|
|
|
|
|
|
route('inventory.transfer.index'),
|
|
|
|
|
|
{ ...filters, search: term, warehouse_id: warehouse === "all" ? "" : warehouse },
|
|
|
|
|
|
{ preserveState: true, replace: true, preserveScroll: true }
|
|
|
|
|
|
);
|
|
|
|
|
|
}, 500),
|
|
|
|
|
|
[filters]
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const handleSearchChange = (term: string) => {
|
|
|
|
|
|
setSearchTerm(term);
|
|
|
|
|
|
debouncedSearch(term, warehouseFilter);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleFilterChange = (value: string) => {
|
|
|
|
|
|
setWarehouseFilter(value);
|
|
|
|
|
|
router.get(
|
|
|
|
|
|
route('inventory.transfer.index'),
|
|
|
|
|
|
{ ...filters, warehouse_id: value === "all" ? "" : value },
|
|
|
|
|
|
{ preserveState: false, replace: true, preserveScroll: true }
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleClearSearch = () => {
|
|
|
|
|
|
setSearchTerm("");
|
|
|
|
|
|
router.get(
|
|
|
|
|
|
route('inventory.transfer.index'),
|
|
|
|
|
|
{ ...filters, search: "", warehouse_id: warehouseFilter === "all" ? "" : warehouseFilter },
|
|
|
|
|
|
{ preserveState: true, replace: true, preserveScroll: true }
|
|
|
|
|
|
);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handlePerPageChange = (value: string) => {
|
|
|
|
|
|
setPerPage(value);
|
|
|
|
|
|
router.get(
|
|
|
|
|
|
route('inventory.transfer.index'),
|
|
|
|
|
|
{ ...filters, per_page: value },
|
|
|
|
|
|
{ preserveState: false, replace: true, preserveScroll: true }
|
|
|
|
|
|
);
|
2026-01-28 18:04:45 +08:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleCreate = () => {
|
|
|
|
|
|
if (!sourceWarehouseId) {
|
|
|
|
|
|
toast.error("請選擇來源倉庫");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (!targetWarehouseId) {
|
|
|
|
|
|
toast.error("請選擇目的倉庫");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (sourceWarehouseId === targetWarehouseId) {
|
|
|
|
|
|
toast.error("來源與目的倉庫不能相同");
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
setCreating(true);
|
|
|
|
|
|
router.post(route('inventory.transfer.store'), {
|
|
|
|
|
|
from_warehouse_id: sourceWarehouseId,
|
|
|
|
|
|
to_warehouse_id: targetWarehouseId
|
|
|
|
|
|
}, {
|
|
|
|
|
|
onFinish: () => setCreating(false),
|
|
|
|
|
|
onSuccess: () => {
|
|
|
|
|
|
setIsCreateOpen(false);
|
|
|
|
|
|
setSourceWarehouseId("");
|
|
|
|
|
|
setTargetWarehouseId("");
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2026-01-29 14:37:21 +08:00
|
|
|
|
const confirmDelete = (id: string) => {
|
|
|
|
|
|
setDeleteId(id);
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const handleDelete = () => {
|
|
|
|
|
|
if (deleteId) {
|
|
|
|
|
|
router.delete(route('inventory.transfer.destroy', [deleteId]), {
|
|
|
|
|
|
onSuccess: () => {
|
|
|
|
|
|
setDeleteId(null);
|
|
|
|
|
|
toast.success("已成功刪除");
|
|
|
|
|
|
},
|
|
|
|
|
|
onError: () => setDeleteId(null),
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const getStatusBadge = (status: string) => {
|
2026-01-28 18:04:45 +08:00
|
|
|
|
switch (status) {
|
|
|
|
|
|
case 'draft':
|
2026-02-13 13:16:05 +08:00
|
|
|
|
return <StatusBadge variant="neutral">草稿</StatusBadge>;
|
|
|
|
|
|
case 'dispatched':
|
|
|
|
|
|
return <StatusBadge variant="info">配送中</StatusBadge>;
|
2026-01-28 18:04:45 +08:00
|
|
|
|
case 'completed':
|
2026-02-13 13:16:05 +08:00
|
|
|
|
return <StatusBadge variant="success">已完成</StatusBadge>;
|
2026-01-28 18:04:45 +08:00
|
|
|
|
case 'voided':
|
2026-02-13 13:16:05 +08:00
|
|
|
|
return <StatusBadge variant="destructive">已作廢</StatusBadge>;
|
2026-01-28 18:04:45 +08:00
|
|
|
|
default:
|
2026-02-13 13:16:05 +08:00
|
|
|
|
return <StatusBadge variant="neutral">{status}</StatusBadge>;
|
2026-01-28 18:04:45 +08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
<AuthenticatedLayout
|
2026-01-29 14:37:21 +08:00
|
|
|
|
breadcrumbs={[
|
2026-02-05 09:33:36 +08:00
|
|
|
|
{ label: '商品與庫存管理', href: '#' },
|
2026-01-29 14:37:21 +08:00
|
|
|
|
{ label: '庫存調撥', href: route('inventory.transfer.index'), isPage: true },
|
|
|
|
|
|
]}
|
2026-01-28 18:04:45 +08:00
|
|
|
|
>
|
|
|
|
|
|
<Head title="庫存調撥" />
|
|
|
|
|
|
|
2026-01-29 14:37:21 +08:00
|
|
|
|
<div className="container mx-auto p-6 max-w-7xl">
|
|
|
|
|
|
<div className="flex items-center justify-between mb-6">
|
|
|
|
|
|
<div>
|
|
|
|
|
|
<h1 className="text-2xl font-bold text-grey-0 flex items-center gap-2">
|
|
|
|
|
|
<ArrowLeftRight className="h-6 w-6 text-primary-main" />
|
|
|
|
|
|
庫存調撥管理
|
|
|
|
|
|
</h1>
|
|
|
|
|
|
<p className="text-gray-500 mt-1">
|
|
|
|
|
|
建立與管理倉庫間的商品調撥單,追蹤庫存轉移紀錄。
|
|
|
|
|
|
</p>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Toolbar */}
|
|
|
|
|
|
<div className="bg-white rounded-lg shadow-sm border p-4 mb-6">
|
|
|
|
|
|
<div className="flex flex-col md:flex-row gap-4">
|
|
|
|
|
|
{/* Search */}
|
|
|
|
|
|
<div className="flex-1 relative">
|
|
|
|
|
|
<Search className="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 h-4 w-4" />
|
|
|
|
|
|
<Input
|
|
|
|
|
|
placeholder="搜尋調撥單號、備註..."
|
|
|
|
|
|
value={searchTerm}
|
|
|
|
|
|
onChange={(e) => handleSearchChange(e.target.value)}
|
|
|
|
|
|
className="pl-10 pr-10 h-9"
|
|
|
|
|
|
/>
|
|
|
|
|
|
{searchTerm && (
|
|
|
|
|
|
<button
|
|
|
|
|
|
onClick={handleClearSearch}
|
|
|
|
|
|
className="absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600"
|
|
|
|
|
|
>
|
|
|
|
|
|
<X className="h-4 w-4" />
|
|
|
|
|
|
</button>
|
|
|
|
|
|
)}
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
{/* Warehouse Filter */}
|
|
|
|
|
|
<SearchableSelect
|
|
|
|
|
|
value={warehouseFilter}
|
|
|
|
|
|
onValueChange={handleFilterChange}
|
|
|
|
|
|
options={[
|
|
|
|
|
|
{ label: "所有倉庫", value: "all" },
|
|
|
|
|
|
...warehouses.map((w: any) => ({ label: w.name, value: w.id.toString() }))
|
|
|
|
|
|
]}
|
|
|
|
|
|
placeholder="選擇倉庫"
|
|
|
|
|
|
className="w-full md:w-[200px] h-9"
|
|
|
|
|
|
/>
|
2026-01-28 18:04:45 +08:00
|
|
|
|
|
2026-01-29 14:37:21 +08:00
|
|
|
|
{/* Action Buttons */}
|
|
|
|
|
|
<div className="flex gap-2 w-full md:w-auto">
|
2026-02-03 17:24:34 +08:00
|
|
|
|
<Can permission="inventory_transfer.create">
|
2026-01-28 18:04:45 +08:00
|
|
|
|
<Dialog open={isCreateOpen} onOpenChange={setIsCreateOpen}>
|
|
|
|
|
|
<DialogTrigger asChild>
|
2026-01-29 14:37:21 +08:00
|
|
|
|
<Button className="flex-1 md:flex-none button-filled-primary">
|
|
|
|
|
|
<Plus className="w-4 h-4 mr-2" />
|
2026-01-28 18:04:45 +08:00
|
|
|
|
新增調撥單
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</DialogTrigger>
|
2026-01-29 14:37:21 +08:00
|
|
|
|
<DialogContent className="sm:max-w-[425px]">
|
2026-01-28 18:04:45 +08:00
|
|
|
|
<DialogHeader>
|
|
|
|
|
|
<DialogTitle>建立新調撥單</DialogTitle>
|
2026-01-29 14:37:21 +08:00
|
|
|
|
<DialogDescription>
|
|
|
|
|
|
請選擇來源倉庫與目的倉庫。
|
|
|
|
|
|
</DialogDescription>
|
2026-01-28 18:04:45 +08:00
|
|
|
|
</DialogHeader>
|
2026-01-29 14:37:21 +08:00
|
|
|
|
<div className="grid gap-4 py-4">
|
2026-01-28 18:04:45 +08:00
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
|
<Label>來源倉庫</Label>
|
2026-01-29 14:37:21 +08:00
|
|
|
|
<SearchableSelect
|
|
|
|
|
|
value={sourceWarehouseId}
|
|
|
|
|
|
onValueChange={setSourceWarehouseId}
|
|
|
|
|
|
options={warehouses.map((w: any) => ({ label: w.name, value: w.id.toString() }))}
|
|
|
|
|
|
placeholder="請選擇來源倉庫"
|
|
|
|
|
|
className="h-9"
|
|
|
|
|
|
/>
|
2026-01-28 18:04:45 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
<div className="space-y-2">
|
|
|
|
|
|
<Label>目的倉庫</Label>
|
2026-01-29 14:37:21 +08:00
|
|
|
|
<SearchableSelect
|
|
|
|
|
|
value={targetWarehouseId}
|
|
|
|
|
|
onValueChange={setTargetWarehouseId}
|
|
|
|
|
|
options={warehouses.filter((w: any) => w.id.toString() !== sourceWarehouseId).map((w: any) => ({ label: w.name, value: w.id.toString() }))}
|
|
|
|
|
|
placeholder="請選擇目的倉庫"
|
|
|
|
|
|
className="h-9"
|
|
|
|
|
|
/>
|
2026-01-28 18:04:45 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
<DialogFooter>
|
2026-01-29 14:37:21 +08:00
|
|
|
|
<Button type="button" variant="outline" className="button-outlined-primary" onClick={() => setIsCreateOpen(false)}>
|
|
|
|
|
|
取消
|
|
|
|
|
|
</Button>
|
2026-01-29 13:04:54 +08:00
|
|
|
|
<Button onClick={handleCreate} className="button-filled-primary" disabled={creating || !sourceWarehouseId || !targetWarehouseId}>
|
2026-01-28 18:04:45 +08:00
|
|
|
|
{creating && <Loader2 className="mr-2 h-4 w-4 animate-spin" />}
|
2026-01-29 13:04:54 +08:00
|
|
|
|
新增
|
2026-01-28 18:04:45 +08:00
|
|
|
|
</Button>
|
|
|
|
|
|
</DialogFooter>
|
|
|
|
|
|
</DialogContent>
|
|
|
|
|
|
</Dialog>
|
2026-01-29 14:37:21 +08:00
|
|
|
|
</Can>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden">
|
|
|
|
|
|
<Table>
|
|
|
|
|
|
<TableHeader className="bg-gray-50">
|
|
|
|
|
|
<TableRow>
|
|
|
|
|
|
<TableHead className="w-[50px] text-center font-medium text-gray-600">#</TableHead>
|
|
|
|
|
|
<TableHead className="font-medium text-gray-600">單號</TableHead>
|
|
|
|
|
|
<TableHead className="font-medium text-gray-600">來源倉庫</TableHead>
|
|
|
|
|
|
<TableHead className="font-medium text-gray-600">目的倉庫</TableHead>
|
|
|
|
|
|
<TableHead className="font-medium text-gray-600">建立日期</TableHead>
|
|
|
|
|
|
<TableHead className="font-medium text-gray-600">過帳日期</TableHead>
|
|
|
|
|
|
<TableHead className="font-medium text-gray-600">建立人員</TableHead>
|
2026-02-13 13:16:05 +08:00
|
|
|
|
<TableHead className="text-center font-medium text-gray-600">狀態</TableHead>
|
2026-01-29 14:37:21 +08:00
|
|
|
|
<TableHead className="text-center font-medium text-gray-600">操作</TableHead>
|
|
|
|
|
|
</TableRow>
|
|
|
|
|
|
</TableHeader>
|
|
|
|
|
|
<TableBody>
|
|
|
|
|
|
{orders.data.length === 0 ? (
|
|
|
|
|
|
<TableRow>
|
|
|
|
|
|
<TableCell colSpan={9} className="text-center h-24 text-gray-500">
|
|
|
|
|
|
尚無調撥紀錄
|
|
|
|
|
|
</TableCell>
|
|
|
|
|
|
</TableRow>
|
|
|
|
|
|
) : (
|
|
|
|
|
|
orders.data.map((order: any, index: number) => (
|
|
|
|
|
|
<TableRow
|
|
|
|
|
|
key={order.id}
|
|
|
|
|
|
className="hover:bg-gray-50/50 transition-colors cursor-pointer group"
|
|
|
|
|
|
onClick={() => router.visit(route('inventory.transfer.show', [order.id]))}
|
|
|
|
|
|
>
|
|
|
|
|
|
<TableCell className="text-center text-gray-500 font-medium">
|
|
|
|
|
|
{(orders.current_page - 1) * orders.per_page + index + 1}
|
|
|
|
|
|
</TableCell>
|
|
|
|
|
|
<TableCell className="font-medium text-primary-main">{order.doc_no}</TableCell>
|
|
|
|
|
|
<TableCell className="text-gray-700">{order.from_warehouse_name}</TableCell>
|
|
|
|
|
|
<TableCell className="text-gray-700">{order.to_warehouse_name}</TableCell>
|
|
|
|
|
|
<TableCell className="text-gray-500 text-sm">{order.created_at}</TableCell>
|
|
|
|
|
|
<TableCell className="text-gray-500 text-sm">{order.posted_at || '-'}</TableCell>
|
|
|
|
|
|
<TableCell className="text-sm">{order.created_by}</TableCell>
|
2026-02-13 13:16:05 +08:00
|
|
|
|
<TableCell className="text-center">{getStatusBadge(order.status)}</TableCell>
|
2026-01-29 14:37:21 +08:00
|
|
|
|
<TableCell className="text-center">
|
|
|
|
|
|
<div className="flex items-center justify-center gap-2" onClick={(e) => e.stopPropagation()}>
|
2026-02-03 17:29:32 +08:00
|
|
|
|
{(() => {
|
|
|
|
|
|
const isEditable = order.status === 'draft';
|
|
|
|
|
|
const canEdit = can('inventory_transfer.edit');
|
|
|
|
|
|
const canView = can('inventory_transfer.view');
|
|
|
|
|
|
|
|
|
|
|
|
if (isEditable && canEdit) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Link href={route('inventory.transfer.show', [order.id])}>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
variant="outline"
|
|
|
|
|
|
size="sm"
|
|
|
|
|
|
className="button-outlined-primary"
|
|
|
|
|
|
title="編輯"
|
|
|
|
|
|
>
|
|
|
|
|
|
<Pencil className="w-4 h-4 ml-0.5" />
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</Link>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (canView) {
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Link href={route('inventory.transfer.show', [order.id])}>
|
|
|
|
|
|
<Button
|
|
|
|
|
|
variant="outline"
|
|
|
|
|
|
size="sm"
|
|
|
|
|
|
className="button-outlined-primary"
|
|
|
|
|
|
title="查閱"
|
|
|
|
|
|
>
|
|
|
|
|
|
<Eye className="w-4 h-4 ml-0.5" />
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
</Link>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
})()}
|
|
|
|
|
|
|
|
|
|
|
|
{order.status === 'draft' && (
|
|
|
|
|
|
<Can permission="inventory_transfer.delete">
|
2026-01-29 14:37:21 +08:00
|
|
|
|
<Button
|
|
|
|
|
|
variant="outline"
|
|
|
|
|
|
size="sm"
|
2026-02-03 17:29:32 +08:00
|
|
|
|
className="button-outlined-error"
|
|
|
|
|
|
title="刪除"
|
|
|
|
|
|
onClick={() => confirmDelete(order.id)}
|
2026-01-29 14:37:21 +08:00
|
|
|
|
>
|
2026-02-03 17:29:32 +08:00
|
|
|
|
<Trash2 className="w-4 h-4 ml-0.5" />
|
2026-01-29 14:37:21 +08:00
|
|
|
|
</Button>
|
2026-02-03 17:29:32 +08:00
|
|
|
|
</Can>
|
|
|
|
|
|
)}
|
2026-01-29 14:37:21 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</TableCell>
|
|
|
|
|
|
</TableRow>
|
|
|
|
|
|
))
|
|
|
|
|
|
)}
|
|
|
|
|
|
</TableBody>
|
|
|
|
|
|
</Table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div className="mt-4 flex flex-col sm:flex-row items-center justify-between gap-4">
|
|
|
|
|
|
<div className="flex items-center gap-4">
|
|
|
|
|
|
<div className="flex items-center gap-2 text-sm text-gray-500">
|
|
|
|
|
|
<span>每頁顯示</span>
|
|
|
|
|
|
<SearchableSelect
|
|
|
|
|
|
value={perPage}
|
|
|
|
|
|
onValueChange={handlePerPageChange}
|
|
|
|
|
|
options={[
|
|
|
|
|
|
{ label: "10", value: "10" },
|
|
|
|
|
|
{ label: "20", value: "20" },
|
|
|
|
|
|
{ label: "50", value: "50" },
|
|
|
|
|
|
{ label: "100", value: "100" }
|
|
|
|
|
|
]}
|
2026-02-03 17:24:34 +08:00
|
|
|
|
className="w-[90px] h-8"
|
2026-01-29 14:37:21 +08:00
|
|
|
|
showSearch={false}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<span>筆</span>
|
2026-01-28 18:04:45 +08:00
|
|
|
|
</div>
|
2026-01-29 14:37:21 +08:00
|
|
|
|
<span className="text-sm text-gray-500">共 {orders.total} 筆紀錄</span>
|
2026-01-28 18:04:45 +08:00
|
|
|
|
</div>
|
2026-01-29 14:37:21 +08:00
|
|
|
|
<Pagination links={orders.links} />
|
2026-01-28 18:04:45 +08:00
|
|
|
|
</div>
|
2026-01-29 14:37:21 +08:00
|
|
|
|
|
|
|
|
|
|
<AlertDialog open={!!deleteId} onOpenChange={(open) => !open && setDeleteId(null)}>
|
|
|
|
|
|
<AlertDialogContent>
|
|
|
|
|
|
<AlertDialogHeader>
|
|
|
|
|
|
<AlertDialogTitle>確定要刪除此調撥單嗎?</AlertDialogTitle>
|
|
|
|
|
|
<AlertDialogDescription>
|
|
|
|
|
|
此動作無法復原。如果單據已存在重要資料,請謹慎操作。
|
|
|
|
|
|
</AlertDialogDescription>
|
|
|
|
|
|
</AlertDialogHeader>
|
|
|
|
|
|
<AlertDialogFooter>
|
|
|
|
|
|
<AlertDialogCancel>取消</AlertDialogCancel>
|
2026-02-02 09:34:24 +08:00
|
|
|
|
<AlertDialogAction onClick={handleDelete} className="button-filled-error">確認刪除</AlertDialogAction>
|
2026-01-29 14:37:21 +08:00
|
|
|
|
</AlertDialogFooter>
|
|
|
|
|
|
</AlertDialogContent>
|
|
|
|
|
|
</AlertDialog>
|
2026-01-28 18:04:45 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
</AuthenticatedLayout>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|