监控、工单报表清洗在线用户页面
This commit is contained in:
582
src/pages/WorkOrder.tsx
Normal file
582
src/pages/WorkOrder.tsx
Normal file
@@ -0,0 +1,582 @@
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
Layout, Card, Row, Col, Button, Table, Tag, Select, Input, Typography, Space,
|
||||
Statistic, Modal, message, Empty, Drawer, Descriptions, Timeline, Divider, Form
|
||||
} from 'antd';
|
||||
import {
|
||||
CheckOutlined, ClockCircleOutlined, ControlOutlined,
|
||||
BarChartOutlined, RiseOutlined, ArrowUpOutlined,
|
||||
SearchOutlined, PlusOutlined, EditOutlined, DeleteOutlined,
|
||||
EyeOutlined, CommentOutlined, PauseOutlined, FormOutlined
|
||||
} from '@ant-design/icons';
|
||||
import { Pie, Bar } from '@ant-design/charts';
|
||||
|
||||
const { Option } = Select;
|
||||
const { Search } = Input;
|
||||
const { Text, Title } = Typography;
|
||||
|
||||
// 模拟数据
|
||||
const workOrderData = [
|
||||
{
|
||||
id: 'WO-20260428-003',
|
||||
title: 'A区组件例行巡检',
|
||||
source: '人工创建',
|
||||
device: 'INV-A01',
|
||||
deviceName: '逆变器 INV-A01',
|
||||
type: '巡检',
|
||||
priority: 'low',
|
||||
status: 'dispatched',
|
||||
handler: '李工程师',
|
||||
createTime: '2026-04-28 19:55:18',
|
||||
desc: '结合日常运维计划执行 A 区逆变器和汇流箱巡检。'
|
||||
},
|
||||
{
|
||||
id: 'WO-20260428-002',
|
||||
title: 'CAM-02 离线排查',
|
||||
source: '告警',
|
||||
device: 'CAM-02',
|
||||
deviceName: '摄像头 CAM-02',
|
||||
type: '故障排查',
|
||||
priority: 'medium',
|
||||
status: 'pending',
|
||||
handler: '',
|
||||
createTime: '2026-04-28 19:55:18',
|
||||
desc: ''
|
||||
},
|
||||
{
|
||||
id: 'WO-20260428-001',
|
||||
title: 'INV-A02 温度过高现场检查',
|
||||
source: '告警',
|
||||
device: 'INV-A02',
|
||||
deviceName: '逆变器 INV-A02',
|
||||
type: '故障排查',
|
||||
priority: 'high',
|
||||
status: 'processing',
|
||||
handler: '张运维',
|
||||
createTime: '2026-04-28 19:55:18',
|
||||
desc: ''
|
||||
}
|
||||
];
|
||||
|
||||
// 工单状态配置
|
||||
const statusConfig = {
|
||||
pending: { label: '待处理', color: '#faad14', icon: <ClockCircleOutlined /> },
|
||||
dispatched: { label: '已派发', color: '#1890ff', icon: <ControlOutlined /> },
|
||||
processing: { label: '处理中', color: '#2f54eb', icon: <BarChartOutlined /> },
|
||||
suspended: { label: '挂起', color: '#faad14', icon: <PauseOutlined /> },
|
||||
completed: { label: '已完成', color: '#52c41a', icon: <CheckOutlined /> },
|
||||
closed: { label: '已关闭', color: '#8c8c8c', icon: <CheckOutlined /> }
|
||||
};
|
||||
|
||||
// 优先级配置
|
||||
const priorityConfig = {
|
||||
low: { label: '低', color: '#52c41a' },
|
||||
medium: { label: '中', color: '#faad14' },
|
||||
high: { label: '高', color: '#ff4d4f' },
|
||||
urgent: { label: '紧急', color: '#f5222d' }
|
||||
};
|
||||
|
||||
const WorkOrderPage = () => {
|
||||
const [searchParams, setSearchParams] = useState({ orderNo: '', status: '' });
|
||||
const [drawerVisible, setDrawerVisible] = useState(false);
|
||||
const [currentOrder, setCurrentOrder] = useState(null);
|
||||
|
||||
// 👇 新增:编辑工单弹窗状态
|
||||
const [editModalVisible, setEditModalVisible] = useState(false);
|
||||
const [editingOrder, setEditingOrder] = useState(null);
|
||||
const [editForm] = Form.useForm();
|
||||
|
||||
// 打开编辑弹窗
|
||||
const openEditModal = (record) => {
|
||||
setEditingOrder(record);
|
||||
editForm.setFieldsValue({
|
||||
title: record.title,
|
||||
source: record.source,
|
||||
type: record.type,
|
||||
priority: record.priority,
|
||||
handler: record.handler,
|
||||
deviceCode: record.device,
|
||||
deviceName: record.deviceName,
|
||||
desc: record.desc
|
||||
});
|
||||
setEditModalVisible(true);
|
||||
};
|
||||
|
||||
// 提交编辑
|
||||
const handleEditSubmit = () => {
|
||||
editForm.validateFields().then(values => {
|
||||
console.log('保存工单:', { ...editingOrder, ...values });
|
||||
message.success('工单保存成功');
|
||||
setEditModalVisible(false);
|
||||
});
|
||||
};
|
||||
|
||||
// 表格列定义
|
||||
const columns = [
|
||||
{
|
||||
title: '工单编号',
|
||||
dataIndex: 'id',
|
||||
key: 'id',
|
||||
width: 140
|
||||
},
|
||||
{
|
||||
title: '标题',
|
||||
dataIndex: 'title',
|
||||
key: 'title'
|
||||
},
|
||||
{
|
||||
title: '来源',
|
||||
dataIndex: 'source',
|
||||
key: 'source',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '设备',
|
||||
dataIndex: 'device',
|
||||
key: 'device',
|
||||
width: 100
|
||||
},
|
||||
{
|
||||
title: '优先级',
|
||||
dataIndex: 'priority',
|
||||
key: 'priority',
|
||||
width: 80,
|
||||
render: (priority) => (
|
||||
<Tag color={priorityConfig[priority]?.color} style={{ borderRadius: 12, padding: '0 8px' }}>
|
||||
{priorityConfig[priority]?.label}
|
||||
</Tag>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
key: 'status',
|
||||
width: 100,
|
||||
render: (status) => (
|
||||
<Tag color={statusConfig[status]?.color}>
|
||||
{statusConfig[status]?.label}
|
||||
</Tag>
|
||||
)
|
||||
},
|
||||
{
|
||||
title: '处理人',
|
||||
dataIndex: 'handler',
|
||||
key: 'handler',
|
||||
width: 100,
|
||||
render: (handler) => handler || '—'
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'createTime',
|
||||
key: 'createTime',
|
||||
width: 160
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 320,
|
||||
fixed: 'right',
|
||||
render: (_, record) => (
|
||||
<Space size="small" wrap>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
icon={<EyeOutlined />}
|
||||
onClick={() => {
|
||||
setCurrentOrder(record);
|
||||
setDrawerVisible(true);
|
||||
}}
|
||||
>
|
||||
详情
|
||||
</Button>
|
||||
<Button
|
||||
type="link"
|
||||
size="small"
|
||||
icon={<EditOutlined />}
|
||||
onClick={() => openEditModal(record)}
|
||||
>
|
||||
编辑
|
||||
</Button>
|
||||
<Button type="link" size="small" onClick={() => message.info('派发工单')}>派发</Button>
|
||||
<Button type="link" size="small" style={{ color: '#52c41a' }}>开始</Button>
|
||||
<Button type="link" size="small" style={{ color: '#faad14' }}>挂起</Button>
|
||||
<Button type="link" size="small" style={{ color: '#1890ff' }}>恢复</Button>
|
||||
<Button type="link" size="small" style={{ color: '#52c41a' }}>完成</Button>
|
||||
<Button type="link" size="small" danger>关闭</Button>
|
||||
<Button type="link" size="small" icon={<CommentOutlined />}>评论</Button>
|
||||
</Space>
|
||||
)
|
||||
}
|
||||
];
|
||||
|
||||
// 饼图数据
|
||||
const pieData = [
|
||||
{ type: '待处理', value: 1, color: '#1890ff' },
|
||||
{ type: '已派发', value: 1, color: '#52c41a' },
|
||||
{ type: '处理中', value: 1, color: '#faad14' }
|
||||
];
|
||||
|
||||
// 柱状图数据
|
||||
const barData = [
|
||||
{ priority: '紧急', count: 0 },
|
||||
{ priority: '高', count: 1 },
|
||||
{ priority: '中', count: 1 },
|
||||
{ priority: '低', count: 1 }
|
||||
];
|
||||
|
||||
return (
|
||||
<div style={{ padding: 20, background: '#f5f7fa', minHeight: '100vh' }}>
|
||||
{/* 顶部标题和搜索 */}
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 20 }}>
|
||||
<div>
|
||||
<Typography.Title level={4} style={{ margin: 0 }}>工单管理</Typography.Title>
|
||||
<Text type="secondary">告警转工单、派发处理、流转记录与事件联动闭环</Text>
|
||||
</div>
|
||||
<Space>
|
||||
<Input
|
||||
placeholder="请输入工单编号"
|
||||
prefix={<SearchOutlined />}
|
||||
style={{ width: 220 }}
|
||||
value={searchParams.orderNo}
|
||||
onChange={(e) => setSearchParams({ ...searchParams, orderNo: e.target.value })}
|
||||
/>
|
||||
<Select
|
||||
placeholder="状态"
|
||||
style={{ width: 120 }}
|
||||
allowClear
|
||||
onChange={(val) => setSearchParams({ ...searchParams, status: val })}
|
||||
>
|
||||
<Option value="pending">待处理</Option>
|
||||
<Option value="dispatched">已派发</Option>
|
||||
<Option value="processing">处理中</Option>
|
||||
<Option value="suspended">挂起</Option>
|
||||
</Select>
|
||||
<Button type="primary" icon={<SearchOutlined />}>查询</Button>
|
||||
<Button icon={<PlusOutlined />}>新建工单</Button>
|
||||
</Space>
|
||||
</div>
|
||||
|
||||
{/* 统计卡片 */}
|
||||
<Row gutter={16} style={{ marginBottom: 20 }}>
|
||||
<Col span={4}>
|
||||
<Card bordered={false} style={{ borderRadius: 8 }}>
|
||||
<Statistic
|
||||
title="全部工单"
|
||||
value={3}
|
||||
suffix="单"
|
||||
prefix={<CheckOutlined style={{ color: '#1890ff', fontSize: 24 }} />}
|
||||
valueStyle={{ fontSize: 28, fontWeight: 700 }}
|
||||
/>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>当前电站</Text>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
<Card bordered={false} style={{ borderRadius: 8 }}>
|
||||
<Statistic
|
||||
title="待处理"
|
||||
value={1}
|
||||
suffix="单"
|
||||
prefix={<ClockCircleOutlined style={{ color: '#faad14', fontSize: 24 }} />}
|
||||
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#faad14' }}
|
||||
/>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>PENDING</Text>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
<Card bordered={false} style={{ borderRadius: 8 }}>
|
||||
<Statistic
|
||||
title="已派发"
|
||||
value={1}
|
||||
suffix="单"
|
||||
prefix={<ControlOutlined style={{ color: '#1890ff', fontSize: 24 }} />}
|
||||
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#1890ff' }}
|
||||
/>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>DISPATCHED</Text>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
<Card bordered={false} style={{ borderRadius: 8 }}>
|
||||
<Statistic
|
||||
title="处理中"
|
||||
value={1}
|
||||
suffix="单"
|
||||
prefix={<BarChartOutlined style={{ color: '#2f54eb', fontSize: 24 }} />}
|
||||
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#2f54eb' }}
|
||||
/>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>PROCESSING</Text>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
<Card bordered={false} style={{ borderRadius: 8 }}>
|
||||
<Statistic
|
||||
title="挂起"
|
||||
value={0}
|
||||
suffix="单"
|
||||
prefix={<PauseOutlined style={{ color: '#faad14', fontSize: 24 }} />}
|
||||
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#faad14' }}
|
||||
/>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>SUSPENDED</Text>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={4}>
|
||||
<Card bordered={false} style={{ borderRadius: 8 }}>
|
||||
<Statistic
|
||||
title="今日新增"
|
||||
value={0}
|
||||
suffix="单"
|
||||
prefix={<RiseOutlined style={{ color: '#52c41a', fontSize: 24 }} />}
|
||||
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#52c41a' }}
|
||||
/>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>逾期 0 单</Text>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{/* 工单列表 */}
|
||||
<Card bordered={false} style={{ borderRadius: 8, marginBottom: 20 }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 16 }}>
|
||||
<div>
|
||||
<Typography.Title level={5} style={{ margin: 0, color: "#0837A8" }}>工单列表</Typography.Title>
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>工单状态变化会写入流转记录和事件中心</Text>
|
||||
</div>
|
||||
<Space>
|
||||
<Select placeholder="优先级" style={{ width: 120 }} allowClear>
|
||||
<Option value="low">低</Option>
|
||||
<Option value="medium">中</Option>
|
||||
<Option value="high">高</Option>
|
||||
</Select>
|
||||
<Select placeholder="来源" style={{ width: 120 }} allowClear>
|
||||
<Option value="manual">人工创建</Option>
|
||||
<Option value="alarm">告警</Option>
|
||||
</Select>
|
||||
<Input placeholder="设备编码" style={{ width: 150 }} />
|
||||
</Space>
|
||||
</div>
|
||||
<Table
|
||||
rowKey="id"
|
||||
columns={columns}
|
||||
dataSource={workOrderData}
|
||||
pagination={false}
|
||||
scroll={{ x: 'max-content' }}
|
||||
size="middle"
|
||||
/>
|
||||
</Card>
|
||||
|
||||
{/* 底部图表区域:降低卡片高度 */}
|
||||
<Row gutter={16}>
|
||||
<Col span={8}>
|
||||
<Card
|
||||
bordered={false}
|
||||
style={{ borderRadius: 8, height: 280 }}
|
||||
title="工单状态分布"
|
||||
>
|
||||
<Pie
|
||||
data={pieData}
|
||||
angleField="value"
|
||||
colorField="type"
|
||||
color={['#1890ff', '#52c41a', '#faad14']}
|
||||
radius={0.8}
|
||||
innerRadius={0.5}
|
||||
legend={{ position: 'right' }}
|
||||
interactions={[{ type: 'pie-legend-active' }, { type: 'element-active' }]}
|
||||
height={200}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Card
|
||||
bordered={false}
|
||||
style={{ borderRadius: 8, height: 280 }}
|
||||
title="工单优先级结构"
|
||||
>
|
||||
<Bar
|
||||
data={barData}
|
||||
xField="priority"
|
||||
yField="count"
|
||||
color="#1890ff"
|
||||
barWidthRatio={0.5}
|
||||
label={{ position: 'middle', style: { fill: '#fff' } }}
|
||||
xAxis={{ label: { autoRotate: false } }}
|
||||
legend={false}
|
||||
height={200}
|
||||
/>
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Card
|
||||
bordered={false}
|
||||
style={{ borderRadius: 8, height: 280 }}
|
||||
title="闭环说明"
|
||||
>
|
||||
<Space wrap style={{ marginBottom: 16 }}>
|
||||
<Tag color="blue">告警转工单</Tag>
|
||||
<Tag color="blue">流转记录</Tag>
|
||||
<Tag color="blue">事件中心</Tag>
|
||||
<Tag color="blue">WebSocket刷新</Tag>
|
||||
</Space>
|
||||
<div style={{ height: 140, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
|
||||
<Empty description="流程说明区域" />
|
||||
</div>
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
{/* 工单详情抽屉 */}
|
||||
<Drawer
|
||||
title="工单详情"
|
||||
placement="right"
|
||||
width={600}
|
||||
onClose={() => setDrawerVisible(false)}
|
||||
open={drawerVisible}
|
||||
destroyOnClose
|
||||
>
|
||||
{currentOrder && (
|
||||
<div>
|
||||
<Title level={5}>基础信息</Title>
|
||||
<Descriptions column={2} bordered size="small">
|
||||
<Descriptions.Item label="工单编号">{currentOrder.id}</Descriptions.Item>
|
||||
<Descriptions.Item label="状态">{statusConfig[currentOrder.status]?.label}</Descriptions.Item>
|
||||
<Descriptions.Item label="标题">{currentOrder.title}</Descriptions.Item>
|
||||
<Descriptions.Item label="优先级">
|
||||
<Tag color={priorityConfig[currentOrder.priority]?.color}>
|
||||
{priorityConfig[currentOrder.priority]?.label}
|
||||
</Tag>
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="来源">{currentOrder.source}</Descriptions.Item>
|
||||
<Descriptions.Item label="设备">{currentOrder.device}</Descriptions.Item>
|
||||
<Descriptions.Item label="处理人">{currentOrder.handler || '—'}</Descriptions.Item>
|
||||
<Descriptions.Item label="创建时间">{currentOrder.createTime}</Descriptions.Item>
|
||||
<Descriptions.Item label="描述" span={2}>
|
||||
{currentOrder.desc || '—'}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
|
||||
<Divider />
|
||||
<Title level={5}>关联告警</Title>
|
||||
<Descriptions column={2} bordered size="small">
|
||||
<Descriptions.Item label="告警编号">-</Descriptions.Item>
|
||||
<Descriptions.Item label="告警状态">-</Descriptions.Item>
|
||||
<Descriptions.Item label="告警名称" span={2}>-</Descriptions.Item>
|
||||
</Descriptions>
|
||||
|
||||
<Divider />
|
||||
<Title level={5}>流转时间线</Title>
|
||||
<Timeline mode="left">
|
||||
<Timeline.Item label={currentOrder.createTime}>
|
||||
创建 --> 已派发
|
||||
<div style={{ color: '#666', fontSize: 12, marginTop: 4 }}>
|
||||
阶段4B演示工单初始化
|
||||
<br />
|
||||
system
|
||||
</div>
|
||||
</Timeline.Item>
|
||||
</Timeline>
|
||||
|
||||
<Divider />
|
||||
<Title level={5}>评论</Title>
|
||||
<Table
|
||||
columns={[
|
||||
{ title: '时间', dataIndex: 'time', width: 150 },
|
||||
{ title: '操作人', dataIndex: 'operator', width: 100 },
|
||||
{ title: '内容', dataIndex: 'content' }
|
||||
]}
|
||||
dataSource={[]}
|
||||
pagination={false}
|
||||
size="small"
|
||||
locale={{ emptyText: '暂无评论' }}
|
||||
/>
|
||||
|
||||
<Divider />
|
||||
<Title level={5}>附件元数据</Title>
|
||||
<Table
|
||||
columns={[
|
||||
{ title: '文件名', dataIndex: 'name' },
|
||||
{ title: '类型', dataIndex: 'type', width: 100 },
|
||||
{ title: '上传人', dataIndex: 'uploader', width: 100 },
|
||||
{ title: '时间', dataIndex: 'time', width: 150 }
|
||||
]}
|
||||
dataSource={[]}
|
||||
pagination={false}
|
||||
size="small"
|
||||
locale={{ emptyText: '暂无附件' }}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
</Drawer>
|
||||
|
||||
{/* 👇 编辑工单弹窗 */}
|
||||
<Modal
|
||||
title="编辑工单"
|
||||
open={editModalVisible}
|
||||
onCancel={() => setEditModalVisible(false)}
|
||||
onOk={handleEditSubmit}
|
||||
okText="保存"
|
||||
cancelText="取消"
|
||||
width={600}
|
||||
destroyOnClose
|
||||
>
|
||||
<Form form={editForm} layout="vertical" initialValues={{ priority: 'low', source: '人工创建', type: '巡检' }}>
|
||||
<Form.Item label="标题" name="title" rules={[{ required: true, message: '请输入标题' }]}>
|
||||
<Input />
|
||||
</Form.Item>
|
||||
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<Form.Item label="来源" name="source">
|
||||
<Select>
|
||||
<Option value="人工创建">人工创建</Option>
|
||||
<Option value="告警">告警</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item label="类型" name="type">
|
||||
<Select>
|
||||
<Option value="巡检">巡检</Option>
|
||||
<Option value="故障排查">故障排查</Option>
|
||||
<Option value="维护">维护</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<Form.Item label="优先级" name="priority">
|
||||
<Select>
|
||||
<Option value="low">低</Option>
|
||||
<Option value="medium">中</Option>
|
||||
<Option value="high">高</Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item label="处理人" name="handler">
|
||||
<Input />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Row gutter={16}>
|
||||
<Col span={12}>
|
||||
<Form.Item label="设备编码" name="deviceCode">
|
||||
<Input disabled />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={12}>
|
||||
<Form.Item label="设备名称" name="deviceName">
|
||||
<Input disabled />
|
||||
</Form.Item>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
<Form.Item label="描述" name="desc">
|
||||
<Input.TextArea rows={4} />
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default WorkOrderPage;
|
||||
Reference in New Issue
Block a user