import { useState } from "react"; import styles from './InspectionTaskPlan.less'; import { Button, Card, Col, Row, Table, Tabs, Input, Space, Modal, Tag, Tree } from "antd"; import { SearchOutlined, DownloadOutlined, PlusOutlined, DownOutlined, RightOutlined, ReloadOutlined } from "@ant-design/icons"; // 自定义树节点图标 const TreeNode = Tree.TreeNode; // 设备树数据 const deviceTreeData = [ { title: "407输送机", key: "407", expanded: true, children: [ { title: "托辊组 (600)", key: "407_rollers", children: [ { title: "1#托辊组", key: "407_roller_1" }, { title: "2#托辊组", key: "407_roller_2" }, { title: "3#托辊组", key: "407_roller_3" }, { title: "4#托辊组", key: "407_roller_4" } ] }, { title: "电机 (2)", key: "407_motors", children: [ { title: "1#电机", key: "407_motor_1" }, { title: "2#电机", key: "407_motor_2" } ] }, { title: "减速器 (2)", key: "407_reducers", children: [ { title: "1#减速器", key: "407_reducer_1" }, { title: "2#减速器", key: "407_reducer_2" } ] }, { title: "滚筒 (2)", key: "407_drums" }, { title: "输送带", key: "407_belt" }, { title: "物料溜槽", key: "407_chute" } ] }, { title: "MA501输送机", key: "MA501", expanded: false }, { title: "PM105输送机", key: "PM105", expanded: false } ]; const { TabPane } = Tabs; const { Search } = Input; // 数据分析巡检管理组件 const DataAnalysisInspectionManagement = () => { const [activeKey, setActiveKey] = useState('1'); const [query, setQuery] = useState(''); const [page, setPage] = useState(1); const [pageSize, setPageSize] = useState(10); const [detailVisible, setDetailVisible] = useState(false); const [currentRecord, setCurrentRecord] = useState(null); const [expandedKeys, setExpandedKeys] = useState(['407', '407_rollers', '407_motors', '407_reducers']); const [selectedKeys, setSelectedKeys] = useState(['407_roller_1']); // 处理树节点展开/折叠 const onExpand = (expandedKeysValue) => { setExpandedKeys(expandedKeysValue); }; // 处理树节点选择 const onSelect = (selectedKeysValue) => { setSelectedKeys(selectedKeysValue); }; // 渲染设备树 const renderDeviceTree = () => { const renderTreeNodes = (data) => { return data.map((item) => { if (item.children) { return ( {renderTreeNodes(item.children)} ); } return ; }); }; return (

设备层级导航

{renderTreeNodes(deviceTreeData)}
); }; // 表格列配置 const columns = [ { title: '序号', dataIndex: 'id', key: 'id', width: 80, align: 'center', }, { title: '设备/部件', dataIndex: 'device', key: 'device', width: 150, render: (text) => {text}, }, { title: '运行时长', dataIndex: 'duration', key: 'duration', width: 120, align: 'center', }, { title: '异常类型', dataIndex: 'type', key: 'type', width: 120, align: 'center', render: (t) => { let color = 'green'; if (t === '温度预警') color = 'orange'; if (t === '异常') color = 'red'; return {t}; }, }, { title: '环境温度', dataIndex: 'temperature', key: 'temperature', width: 120, align: 'center', }, { title: '处理状态', dataIndex: 'status', key: 'status', width: 120, align: 'center', render: (status) => { let color = '#006665'; if (status === '待检修') color = '#ff6600'; return {status}; }, }, ]; // 表格数据(示例) const initialData = [ { key: 1, id: 1, device: '407输送机1#托辊组', duration: '300小时', type: '无异常', temperature: '25.5℃', status: '正常', }, { key: 2, id: 2, device: '407输送机1#电机', duration: '280小时', type: '温度预警', temperature: '48℃', status: '待检修', }, { key: 3, id: 3, device: '407输送机2#托辊组', duration: '290小时', type: '无异常', temperature: '26.2℃', status: '正常', }, { key: 4, id: 4, device: '407输送机2#电机', duration: '275小时', type: '无异常', temperature: '45℃', status: '正常', }, { key: 5, id: 5, device: '407输送机3#托辊组', duration: '285小时', type: '无异常', temperature: '25.8℃', status: '正常', }, { key: 6, id: 6, device: '407输送机1#减速器', duration: '310小时', type: '无异常', temperature: '32℃', status: '正常', }, { key: 7, id: 7, device: '407输送机2#减速器', duration: '305小时', type: '无异常', temperature: '33℃', status: '正常', }, { key: 8, id: 8, device: '407输送机滚筒', duration: '315小时', type: '无异常', temperature: '28℃', status: '正常', }, { key: 9, id: 9, device: '407输送机输送带', duration: '320小时', type: '无异常', temperature: '27℃', status: '正常', }, { key: 10, id: 10, device: '407输送物料溜槽', duration: '300小时', type: '无异常', temperature: '26℃', status: '正常', }, ]; const [data, setData] = useState(initialData); function openDetail(record) { setCurrentRecord(record); setDetailVisible(true); } function closeDetail() { setDetailVisible(false); setCurrentRecord(null); } function handleSearch(value) { setQuery(value); // 简单本地过滤示例 — 实际请接后端 const filtered = initialData.filter((r) => r.device.includes(value) || String(r.id) === value); setData(filtered); setPage(1); } function handleExport() { // 简单 CSV 导出示例 const headers = ['id', 'device', 'duration', 'type', 'temperature', 'status']; const rows = data.map((r) => headers.map((h) => (r[h] ?? '')).join(',')); const csv = [headers.join(','), ...rows].join('\n'); const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' }); const url = URL.createObjectURL(blob); const a = document.createElement('a'); a.href = url; a.download = 'data_analysis_export.csv'; document.body.appendChild(a); a.click(); document.body.removeChild(a); URL.revokeObjectURL(url); } return (
{/* 左侧设备导航树 */} {renderDeviceTree()} {/* 右侧主要内容区域 */} {/* 设备拓扑和环境监测区域 */} {/* 设备拓扑可视化 */}
正常
预警
异常

407/输送机

长度 1900mm,宽度 2500mm

{/* 设备拓扑图占位 */}
{/* 巡检区域环境监测 */}
温度
26°C
湿度
55%RH
甲烷
0.0%
一氧化碳
4.0ppm
粉尘(PM2.5)
16μg/m³
{/* 热成像图占位 */}
} allowClear style={{ width: 320 }} className={styles.searchInput} />
数据更新时间:2025-12-15 10:00
`共${total}条`, pageSizeOptions: ['10', '20', '50'], onChange: (p, ps) => { setPage(p); setPageSize(ps); }, // 确保分页样式与界面一致 className: styles.tablePagination }} bordered // 添加表格样式 className={styles.historyTable} // 行悬停效果 onRow={(record) => ({ onClick: () => openDetail(record), style: { cursor: 'pointer', '&:hover': { backgroundColor: 'rgba(0, 102, 101, 0.05)' } } })} />

实时数据监控

显示关键指标、趋势图和告警列表(此处为占位)

图表占位
告警列表占位
{currentRecord ? (

设备:{currentRecord.device}

运行时长:{currentRecord.duration}

异常类型:{currentRecord.type}

环境温度:{currentRecord.temperature}

处理状态:{currentRecord.status}

趋势图/更多信息占位
) : null}
); }; export default DataAnalysisInspectionManagement;