import React, { useState } from 'react'; import { Box, Paper, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, Typography, Chip, Card, CardContent, } from '@mui/material'; import { useReactTable, getCoreRowModel, createColumnHelper, flexRender, } from '@tanstack/react-table'; import DescriptionIcon from '@mui/icons-material/Description'; import CheckCircleIcon from '@mui/icons-material/CheckCircle'; import CancelIcon from '@mui/icons-material/Cancel'; import CalendarTodayIcon from '@mui/icons-material/CalendarToday'; interface QCReport { id: string; productName: string; isQualified: boolean; remarks: string; reportDate: string; batchNumber: string; inspector: string; testResults: string; specifications: string; } interface QCReportFormProps { reports: QCReport[]; } function QCReportForm({ reports }: QCReportFormProps): JSX.Element { const [selectedReport, setSelectedReport] = useState(null); const handleReportClick = (report: QCReport): void => { setSelectedReport(report); }; const getQualifiedStatus = (isQualified: boolean) => { return isQualified ? ( } label="合格" color="success" size="small" sx={{ fontWeight: 'medium' }} /> ) : ( } label="不合格" color="error" size="small" sx={{ fontWeight: 'medium' }} /> ); }; const columnHelper = createColumnHelper(); const columns = [ // columnHelper.accessor('productName', { // header: '產品', // cell: info => ( // // {info.getValue()} // // ), // }), columnHelper.accessor('isQualified', { header: '合格', cell: info => getQualifiedStatus(info.getValue()), }), columnHelper.accessor('remarks', { header: '備註', cell: info => ( {info.getValue()} ), }), columnHelper.accessor('reportDate', { header: '上報日期', cell: info => ( {info.getValue()} ), }), ]; const table = useReactTable({ data: reports, columns, getCoreRowModel: getCoreRowModel(), }); return ( {/* Title */} {/* 品質控制上報系統 品質檢測結果上報與管理 */} {/* */} {/* Table Section */} 上報資料 {table.getHeaderGroups().map(headerGroup => ( {headerGroup.headers.map(header => ( {header.isPlaceholder ? null : flexRender(header.column.columnDef.header, header.getContext())} ))} ))} {table.getRowModel().rows.map(row => ( handleReportClick(row.original)} sx={{ cursor: 'pointer', '&:hover': { bgcolor: 'grey.50' }, bgcolor: selectedReport?.id === row.original.id ? 'primary.light' : 'inherit', transition: 'background-color 0.15s', }} > {row.getVisibleCells().map(cell => ( {flexRender(cell.column.columnDef.cell, cell.getContext())} ))} ))}
{/* Details Section */} {/* 詳細資訊 {selectedReport ? ( 上報詳情 產品名稱: {selectedReport.productName} 檢測結果: {getQualifiedStatus(selectedReport.isQualified)} 批次號碼: {selectedReport.batchNumber} 檢驗員: {selectedReport.inspector} 上報日期:{selectedReport.reportDate} 檢測規格: {selectedReport.specifications} 檢測結果詳情: {selectedReport.testResults} 備註 (REMARKS): {selectedReport.remarks} ) : ( 請點擊表格中的記錄來查看詳細資訊 )} */}
); } // Dummy data const dummyReports = [ // { // id: '1', // productName: '智慧手機 Pro Max', // isQualified: true, // remarks: '所有檢測項目均符合標準規格', // reportDate: '2024-08-07', // batchNumber: 'SPM-240807-001', // inspector: '張品質', // testResults: '外觀檢查:無瑕疵,功能測試:100%通過,性能測試:符合標準', // specifications: '螢幕解析度≥1080p,電池續航≥24小時,防水等級IPX7', // }, { id: '2', productName: '無線藍牙耳機', isQualified: false, remarks: '包裝有破損', reportDate: '2024-08-06', batchNumber: 'WBE-240806-002', inspector: '李測試', testResults: '音質測試:左右聲道音量差異>3dB,不符合標準', specifications: '頻響範圍20Hz-20kHz,左右聲道音量差≤1dB,電池續航≥8小時', }, { id: '3', productName: '筆記型電腦', isQualified: true, remarks: '經檢查,無損壞', reportDate: '2024-08-05', batchNumber: 'NB-240805-003', inspector: '王檢驗', testResults: '溫度測試:CPU最高溫度75°C,性能測試:符合預期', specifications: 'CPU溫度≤85°C,開機時間≤30秒,電池續航≥6小時', }, // { // id: '4', // productName: '智慧手錶', // isQualified: false, // remarks: '防水測試未通過,密封性能不足', // reportDate: '2024-08-04', // batchNumber: 'SW-240804-004', // inspector: '劉品管', // testResults: '防水測試:IPX5等級測試失敗,發現進水現象', // specifications: '防水等級≥IPX7,電池續航≥48小時,心率監測精度≥95%', // }, // { // id: '5', // productName: '平板電腦', // isQualified: true, // remarks: '觸控靈敏度優良,顯示效果佳', // reportDate: '2024-08-03', // batchNumber: 'TB-240803-005', // inspector: '陳測試', // testResults: '觸控測試:反應時間<10ms,顯示測試:色彩準確度98%', // specifications: '螢幕尺寸10.1吋,解析度2K,觸控反應時間≤15ms', // }, ]; // Main component const EscalationLog: React.FC = () => { return ; }; export default EscalationLog;