import React, { useState } from 'react';
import {
Layout, Card, Row, Col, Button, Table, Tag, Select, Input, Typography, Space,
Statistic, message, Drawer, Descriptions, Timeline, Divider, Form, Modal
} from 'antd';
import {
PlusOutlined, SearchOutlined, EditOutlined, EyeOutlined,
ClockCircleOutlined, CheckCircleOutlined, PlayCircleOutlined,
CloseCircleOutlined, ThunderboltOutlined, SettingOutlined,
SendOutlined, PauseOutlined, ArrowRightOutlined, FileDoneOutlined,
RobotOutlined, CloudOutlined, RiseOutlined,
BranchesOutlined
} from '@ant-design/icons';
import { Pie, Line, Bar } from '@ant-design/charts';
import dayjs from 'dayjs';
const { Option } = Select;
const { Search } = Input;
const { Text, Title } = Typography;
// 模拟数据(完全匹配参考图)
const workOrderList = [
{
id: 'WO20250524001',
title: '逆变器 INV-05 告警排查',
source: 'AI诊断',
type: '检修',
priority: 'high',
handler: '李工',
deadline: '2025-05-24 14:30',
status: 'pending',
description: ''
},
{
id: 'WO20250524002',
title: '区块 B-12 热斑复检',
source: '无人机巡检',
type: '巡检',
priority: 'high',
handler: '王工',
deadline: '2025-05-24 15:00',
status: 'processing',
description: '对AI识别热斑区域进行复检与红外复核,确认是否需要更换组件。'
},
{
id: 'WO20250524003',
title: '组件清洗任务 C-05',
source: '清洗优化',
type: '清洗',
priority: 'medium',
handler: '赵工',
deadline: '2025-05-24 16:00',
status: 'dispatched',
description: ''
},
{
id: 'WO20250524004',
title: '周界摄像头 CAM-08 离线修复',
source: '视频监控',
type: '维修',
priority: 'medium',
handler: '陈工',
deadline: '2025-05-24 17:30',
status: 'processing',
description: ''
},
{
id: 'WO20250524005',
title: '除草机器人补给',
source: '装备控制',
type: '运维',
priority: 'low',
handler: '刘工',
deadline: '2025-05-24 18:00',
status: 'pending',
description: ''
},
{
id: 'WO20250524006',
title: '逆变器室夜间巡检',
source: '人工创建',
type: '巡检',
priority: 'medium',
handler: '张运维',
deadline: '2025-05-24 21:00',
status: 'completed',
description: ''
}
];
// 工单状态配置
const statusConfig = {
pending: { label: '待处理', color: '#1890ff', icon: },
dispatched: { label: '已派发', color: '#52c41a', icon: },
processing: { label: '执行中', color: '#2f54eb', icon: },
suspended: { label: '挂起', color: '#faad14', icon: },
completed: { label: '已完成', color: '#52c41a', icon: },
closed: { label: '已关闭', color: '#8c8c8c', icon: }
};
// 优先级配置
const priorityConfig = {
low: { label: '低', color: '#52c41a' },
medium: { label: '中', color: '#faad14' },
high: { label: '高', color: '#ff4d4f' },
urgent: { label: '紧急', color: '#f5222d' }
};
// 统计卡片数据
const overviewCards = [
{ title: '今日新增工单', value: 18, suffix: '单', desc: '较昨日 +3', color: '#1890ff', icon: },
{ title: '待处理工单', value: 12, suffix: '单', desc: '高优先级 5', color: '#ff4d4f', icon: },
{ title: '执行中工单', value: 9, suffix: '单', desc: '按时率 92%', color: '#52c41a', icon: },
{ title: '已完成工单', value: 126, suffix: '单', desc: '本月累计', color: '#52c41a', icon: },
{ title: '平均处理时长', value: 4.3, suffix: '小时', desc: '较上周 -12% ↓', color: '#1890ff', icon: },
{ title: 'AI建议生成', value: 7, suffix: '单', desc: '今日自动生成', color: '#722ed1', icon: }
];
// 任务排班数据
const scheduleData = [
{ handler: '李工', tasks: [{ title: 'INV-05 告警排查', time: '08:30 - 12:00', type: 'alarm' }] },
{ handler: '王工', tasks: [{ title: 'B-12 热斑复检', time: '13:30 - 15:00', type: 'inspect' }] },
{ handler: '赵工', tasks: [{ title: '组件清洗 C-05', time: '09:00 - 12:00', type: 'clean' }, { title: '清洗效果复检', time: '15:00 - 17:00', type: 'clean' }] },
{ handler: '陈工', tasks: [{ title: '周界摄像头修复', time: '10:00 - 12:30', type: 'repair' }, { title: '设备巡检', time: '15:30 - 17:30', type: 'inspect' }] }
];
// 告警趋势数据
const alarmTrendData = [
{ date: '05-18', count: 5 },
{ date: '05-19', count: 10 },
{ date: '05-20', count: 5 },
{ date: '05-21', count: 5 },
{ date: '05-22', count: 12 },
{ date: '05-23', count: 10 },
{ date: '05-24', count: 12 }
];
// 告警列表数据
const alarmList = [
{ name: 'INV-05 逆变器告警', time: '05-24 10:24' },
{ name: 'B-12 区块热斑告警', time: '05-24 09:56' },
{ name: 'B-12 组件温度异常', time: '05-24 09:32' }
];
export default function WorkOrderPage() {
const [selectedOrder, setSelectedOrder] = useState(workOrderList[1]); // 默认选中执行中的工单
const [drawerVisible, setDrawerVisible] = useState(false);
const [editModalVisible, setEditModalVisible] = useState(false);
const [editingOrder, setEditingOrder] = useState(null);
const [editForm] = Form.useForm();
// 表格列定义
const columns = [
{ title: '工单编号', dataIndex: 'id', key: 'id', width: 140 },
{ title: '工单标题', dataIndex: 'title', key: 'title' },
{ title: '来源', dataIndex: 'source', key: 'source', width: 100 },
{ title: '类型', dataIndex: 'type', key: 'type', width: 80 },
{
title: '优先级',
dataIndex: 'priority',
key: 'priority',
width: 80,
render: (priority) => (
{priorityConfig[priority]?.label}
)
},
{ title: '负责人', dataIndex: 'handler', key: 'handler', width: 80 },
{ title: '截止时间', dataIndex: 'deadline', key: 'deadline', width: 160 },
{
title: '状态',
dataIndex: 'status',
key: 'status',
width: 100,
render: (status) => (
{statusConfig[status]?.label}
)
},
{
title: '操作',
key: 'action',
width: 80,
render: (_, record) => (
)
}
];
// 工单状态分布饼图数据
const pieData = [
{ type: '待处理', value: 12, color: '#1890ff' },
{ type: '执行中', value: 9, color: '#2f54eb' },
{ type: '已完成', value: 126, color: '#52c41a' },
{ type: '已挂起', value: 4, color: '#faad14' }
];
return (
{/* 顶部统计卡片 */}
{overviewCards.map((card, idx) => (
{card.title}
{card.value} {card.suffix}
{card.desc}
{card.icon}
))}
{/* 筛选栏 */}
时间范围
} />
{/* 左侧工单列表 */}
`共 ${total} 条` }}
scroll={{ x: 'max-content' }}
rowClassName={(record) => record.id === selectedOrder?.id ? 'selected-row' : ''}
onRow={(record) => ({ onClick: () => setSelectedOrder(record) })}
/>
{/* 工单状态分布 + 任务排班 */}
`${datum.value} (${((datum.value / 147) * 100).toFixed(2)}%)`
}}
interactions={[{ type: 'pie-legend-active' }]}
/>
任务排班 / 日历视图}>
} />
2025-05-24 (今天)
} />
{scheduleData.map((item, idx) => (
{item.handler}
{item.tasks.map((task, i) => (
))}
))}
{/* 右侧工单详情面板 */}
{selectedOrder?.title}
高优先级
工单编号: {selectedOrder?.id}
}>
来源:{selectedOrder?.source}
工单类型:{selectedOrder?.type}
负责人:{selectedOrder?.handler}
协同人员:无人机A01 / 张运维
计划时间:2025-05-24 13:30 ~ 15:00
关联区域:B-12
关联设备:UAV-A01
当前状态:执行中
任务描述
{selectedOrder?.description}
{/* 流程步骤 */}
{['已创建', '已派发', '执行中', '已完成'].map((step, idx) => (
))}
{/* 操作按钮 */}
{/* AI建议与关联信息 */}
关联告警趋势(近7天)
关联告警列表(近3条)
{alarmList.map((alarm, idx) => (
))}
{/* 工单详情抽屉 */}
setDrawerVisible(false)}
open={drawerVisible}
destroyOnClose
>
{selectedOrder && (
{selectedOrder.id}
{statusConfig[selectedOrder.status]?.label}
{selectedOrder.title}
{priorityConfig[selectedOrder.priority]?.label}
{selectedOrder.source}
{selectedOrder.type}
{selectedOrder.handler || '—'}
{selectedOrder.deadline}
{selectedOrder.description || '—'}
)}
{/* 编辑工单弹窗 */}
setEditModalVisible(false)}
onOk={() => { editForm.validateFields().then(values => { message.success('工单保存成功'); setEditModalVisible(false); }); }}
okText="保存"
cancelText="取消"
width={600}
destroyOnClose
>
);
}