import AuthenticatedLayout from "@/Layouts/AuthenticatedLayout";
import { Head, Link } from "@inertiajs/react";
import { PageProps } from "@/types/global";
import {
Table,
TableBody,
TableCell,
TableHead,
TableHeader,
TableRow,
} from "@/Components/ui/table";
import { Button } from "@/Components/ui/button";
import { StatusBadge } from "@/Components/shared/StatusBadge";
import { ArrowLeft, FileText, Package } from "lucide-react";
import Pagination from "@/Components/shared/Pagination";
import { formatDate } from "@/utils/format";
interface Transaction {
id: number;
inventory_id: number;
type: string;
quantity: number;
unit_cost: number;
total_cost: number;
actual_time: string;
note: string | null;
batch_no: string | null;
user_id: number;
created_at: string;
warehouse_name: string;
user_name: string;
}
interface ShowProps extends PageProps {
product: {
id: number;
code: string;
name: string;
unit_name: string;
};
transactions: {
data: Transaction[];
links: any[];
total: number;
from: number;
to: number;
current_page: number;
last_page: number;
per_page: number;
};
filters: {
date_from: string;
date_to: string;
warehouse_id: string;
};
/** 報表頁面的完整篩選狀態(用於返回時恢復) */
reportFilters: {
date_from: string;
date_to: string;
warehouse_id: string;
category_id: string;
search: string;
per_page: string;
report_page: string;
};
warehouses: { id: number; name: string }[];
}
export default function InventoryReportShow({ product, transactions, filters, reportFilters, warehouses }: ShowProps) {
// 類型 Badge 顏色映射
// 類型 Badge 顏色映射
const getTypeBadgeVariant = (type: string): "success" | "destructive" | "neutral" => {
switch (type) {
case '入庫':
case '手動入庫':
case '調撥入庫':
return "success";
case '出庫':
case '調撥出庫':
return "destructive";
default:
return "neutral";
}
};
return (
查看商品「{product.name}」的所有庫存異動紀錄