import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'; import { Head, Link } from '@inertiajs/react'; import { Button } from '@/Components/ui/button'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from '@/Components/ui/table'; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, AlertDialogTrigger, } from "@/Components/ui/alert-dialog"; import { Badge } from "@/Components/ui/badge"; import { Plus, FileUp, Eye, Trash2 } from 'lucide-react'; import { useState, useEffect } from "react"; import { format } from 'date-fns'; import Pagination from "@/Components/shared/Pagination"; import { SearchableSelect } from "@/Components/ui/searchable-select"; import { router } from "@inertiajs/react"; interface ImportBatch { id: number; import_date: string; status: 'pending' | 'confirmed'; total_quantity: number; total_amount: number; importer?: { name: string; }; created_at: string; } interface Props { batches: { data: ImportBatch[]; links: any[]; // Pagination links }; filters?: { // Add filters prop if not present, though we main need per_page state per_page?: string; } } export default function SalesImportIndex({ batches, filters = {} }: Props) { const [perPage, setPerPage] = useState(filters?.per_page?.toString() || "10"); useEffect(() => { if (filters?.per_page) { setPerPage(filters.per_page.toString()); } }, [filters?.per_page]); const handlePerPageChange = (value: string) => { setPerPage(value); router.get( route("sales-imports.index"), { per_page: value }, { preserveState: true, preserveScroll: true, replace: true } ); }; return (

銷售單匯入管理

匯入並管理銷售出貨紀錄

ID 匯入日期 匯入人員 總數量 總金額 狀態 操作 {batches.data.length === 0 ? ( 尚無匯入紀錄 ) : ( batches.data.map((batch) => ( #{batch.id} {format(new Date(batch.created_at), 'yyyy/MM/dd HH:mm')} {batch.importer?.name || '--'} {Math.floor(batch.total_quantity || 0).toLocaleString()} NT$ {Number(batch.total_amount || 0).toLocaleString(undefined, { minimumFractionDigits: 0, maximumFractionDigits: 2 })} {batch.status === 'confirmed' ? '已確認' : '待確認'}
{batch.status === 'pending' && ( 確認刪除匯入紀錄 確定要刪除此筆匯入紀錄(#{batch.id})嗎?此操作將會移除所有相關的明細資料且無法復原。 取消 router.delete(route('sales-imports.destroy', batch.id), { preserveScroll: true })} > 確認刪除 )}
)) )}
{/* Pagination */}
每頁顯示
); }