import React, { useState } from 'react'; import { Search, Download, Printer, Calendar, Filter, BarChart3, PieChart, LineChart, ArrowUpRight, RefreshCw, FileText } from 'lucide-react'; import { Button } from "../ui/button"; import { Input } from "../ui/input"; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow, } from "../ui/table"; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue, } from "../ui/select"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "../ui/tabs"; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from "../ui/card"; import { Badge } from "../ui/badge"; import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, Legend, ResponsiveContainer, Line, LineChart as RechartsLineChart } from 'recharts'; import { toast } from "sonner@2.0.3"; import { cn } from "../ui/utils"; // --- Mock Data --- const MOCK_PRINT_LOG = [ { id: '1-251201', productName: 'Whole Milk', category: 'Dairy', printedAt: '2024-03-20 09:30 AM', printedBy: 'Alice Johnson', location: 'Downtown Store (101)', expiryDate: '2024-03-27', status: 'Valid' }, { id: '2-251201', productName: 'Ground Beef', category: 'Meat', printedAt: '2024-03-20 10:15 AM', printedBy: 'Bob Smith', location: 'Uptown Store (102)', expiryDate: '2024-03-23', status: 'Valid' }, { id: '3-251201', productName: 'Croissant', category: 'Bakery', printedAt: '2024-03-19 14:00 PM', printedBy: 'Charlie Brown', location: 'Downtown Store (101)', expiryDate: '2024-03-20', status: 'Expired' }, { id: '4-251201', productName: 'Caesar Salad', category: 'Deli', printedAt: '2024-03-18 11:45 AM', printedBy: 'Alice Johnson', location: 'Downtown Store (101)', expiryDate: '2024-03-21', status: 'Expiring Soon' }, { id: '5-251201', productName: 'Orange Juice', category: 'Beverage', printedAt: '2024-03-18 08:20 AM', printedBy: 'Bob Smith', location: 'Airport Kiosk (201)', expiryDate: '2024-03-25', status: 'Valid' }, ]; const MOCK_CATEGORY_STATS = [ { name: 'Dairy', count: 450 }, { name: 'Meat', count: 320 }, { name: 'Bakery', count: 280 }, { name: 'Deli', count: 190 }, { name: 'Produce', count: 150 }, { name: 'Beverage', count: 120 }, ]; const MOCK_USAGE_TRENDS = [ { date: 'Mon', count: 120 }, { date: 'Tue', count: 132 }, { date: 'Wed', count: 101 }, { date: 'Thu', count: 134 }, { date: 'Fri', count: 190 }, { date: 'Sat', count: 230 }, { date: 'Sun', count: 210 }, ]; export function ReportsView() { const [activeTab, setActiveTab] = useState('print-log'); const handleReprint = (labelId: string) => { // Logic to reprint would go here // For now, we simulate the action toast.success(`Reprinting label ${labelId}`, { description: "Watermark 'RePrint' applied.", }); }; return (
{/* Toolbar:与 Products/Locations 一致 — 单行、圆角、细边框、bg-gray-50、无标题、框内文字黑色 */}
Period Search:
-
{/* Tabs:参考 Labels 的 tab 形式 */}
{(['print-log', 'label-report'] as const).map((tab) => ( ))}
{/* Content Area:与 Products 一致,无内边距 */}
{activeTab === 'print-log' && (
Label ID Product Name Category Printed At Printed By Location Expiry Date Action {MOCK_PRINT_LOG.map((log) => ( {log.id} {log.productName} {log.category} {log.printedAt} {log.printedBy} {log.location} {log.expiryDate} ))}
)} {activeTab === 'label-report' && (
{/* Summary Cards */}
Total Labels Printed
2,543

+20.1% from last month

Most Printed Category
Dairy

450 labels generated

Top Product
Whole Milk

182 labels generated

Avg. Daily Prints
85

+12% from last week

{/* Category Breakdown Chart */} Labels by Category Distribution of printed labels across product categories. `${value}`} /> {/* Usage Trend Chart */} Print Volume Trends Daily label printing volume for the last 7 days.
{/* Top Products Table */} Most Used Products Product Name Category Total Printed Usage % Whole Milk Dairy 182 7.2% Ground Beef 80/20 Meat 145 5.7% Chicken Breast Meat 132 5.2% Sliced Ham Deli 98 3.8%
)}
); }