监控、工单报表清洗在线用户页面

This commit is contained in:
mmc
2026-05-08 11:00:11 +08:00
parent 9645c2b651
commit 254ab64358
12 changed files with 1805 additions and 101 deletions

4
env.js
View File

@@ -9,8 +9,8 @@ const currentEnv = import.meta.env?.MODE || process.env.NODE_ENV;
// 环境配置映射 // 环境配置映射
const envConfig = { const envConfig = {
[ENV.DEV]: { [ENV.DEV]: {
//baseURL: 'http://192.168.2.59:8081',//http://192.168.2.56:8081 baseURL: 'http://192.168.2.59:8081',//http://192.168.2.56:8081
baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081 //baseURL: 'http://1.95.137.212:59015',//http://192.168.2.56:8081
WS_URL: 'ws://192.168.2.56:9002/ws/', WS_URL: 'ws://192.168.2.56:9002/ws/',
}, },
[ENV.PROD]: { [ENV.PROD]: {

View File

@@ -1,9 +1,28 @@
import request from '../request'; import request from './request';
//新增物模型 //新增物模型
export function addDeviceModel(data) { export function addDeviceModel(data) {
return request({ return request({
url: 'system/devicemodel/add', url: '/system/devicemodel/add',
method: 'post',
data
});
}
//物模型列表export function addDeviceModel(data) {
export function getDeviceModelList(params) {
return request({
url: ' /iot/deviceModel/list',
method: 'get',
params
});
}
//物模型修改
export function updateDeviceModel(data) {
return request({
url: '/system/devicemodel/update',
method: 'post', method: 'post',
data data
}); });

View File

@@ -1,12 +1,13 @@
import { useState } from 'react'; import { useState } from 'react';
import { import {
Card, Table, Button, Space, Form, Modal, Input, Select, InputNumber, Card, Table, Button, Space, Form, Modal, Input, Select, InputNumber,
Tabs, Tag, Popconfirm, message, Divider, Switch, Empty Tabs, Tag, Popconfirm, message, Divider, Switch, Empty, Checkbox
} from 'antd'; } from 'antd';
import { import {
PlusOutlined, EditOutlined, DeleteOutlined, ProductOutlined, PlusOutlined, EditOutlined, DeleteOutlined, ProductOutlined,
AppstoreOutlined, SwapOutlined, VideoCameraOutlined AppstoreOutlined, SwapOutlined, VideoCameraOutlined
} from '@ant-design/icons'; } from '@ant-design/icons';
import { addDeviceModel } from '../../api/deviceAccess.ts';
const { Option } = Select; const { Option } = Select;
const { TabPane } = Tabs; const { TabPane } = Tabs;
@@ -40,24 +41,24 @@ const modelDetailList: Record<number, {
}> = { }> = {
10: { 10: {
props: [ props: [
{ id: 1, code: 'device_online', name: '在线状态', type: 'bool', rw: 'r', isAlarm: false }, { id: 1, code: 'device_online', name: '在线状态', type: 'bool', rw: 'r', isAlarm: false, unit: '', required: true, defaultValue: null },
{ id: 2, code: 'record_status', name: '录像状态', type: 'string', rw: 'r', isAlarm: false }, { id: 2, code: 'record_status', name: '录像状态', type: 'string', rw: 'r', isAlarm: false, unit: '', required: true, defaultValue: null },
], ],
events: [{ id: 1, code: 'alarm_perimeter', name: '周界入侵告警' }], events: [{ id: 1, code: 'alarm_perimeter', name: '周界入侵告警' }],
actions: [{ actionId: 'take_snapshot', actionName: '截图', params: {} }] actions: [{ actionId: 'take_snapshot', actionName: '截图', params: {} }]
}, },
11: { 11: {
props: [ props: [
{ id: 1, code: 'temp', name: '温度', type: 'float', rw: 'r', isAlarm: true }, { id: 1, code: 'temp', name: '温度', type: 'float', rw: 'r', isAlarm: true, unit: '℃', required: true, defaultValue: null },
{ id: 2, code: 'humi', name: '湿度', type: 'float', rw: 'r', isAlarm: true }, { id: 2, code: 'humi', name: '湿度', type: 'float', rw: 'r', isAlarm: true, unit: '%', required: true, defaultValue: null },
], ],
events: [{ id: 1, code: 'temp_over', name: '超温告警' }], events: [{ id: 1, code: 'temp_over', name: '超温告警' }],
actions: [] actions: []
}, },
12: { 12: {
props: [ props: [
{ id: 1, code: 'battery', name: '电量', type: 'int', rw: 'r', isAlarm: true }, { id: 1, code: 'battery', name: '电量', type: 'int', rw: 'r', isAlarm: true, unit: '%', required: true, defaultValue: null },
{ id: 2, code: 'voltage', name: '电压', type: 'float', rw: 'r', isAlarm: true }, { id: 2, code: 'voltage', name: '电压', type: 'float', rw: 'r', isAlarm: true, unit: 'V', required: true, defaultValue: null },
], ],
events: [{ id: 1, code: 'low_power', name: '低电量告警' }], events: [{ id: 1, code: 'low_power', name: '低电量告警' }],
actions: [] actions: []
@@ -101,12 +102,12 @@ export default function DeviceAccessPage() {
const [itemType, setItemType] = useState<'props' | 'events' | 'actions'>('props'); const [itemType, setItemType] = useState<'props' | 'events' | 'actions'>('props');
const [itemForm] = Form.useForm(); const [itemForm] = Form.useForm();
// 指令 + 参数 新增状态 // 指令 + 参数 + 枚举
const [actionModal, setActionModal] = useState(false); const [actionModal, setActionModal] = useState(false);
const [currentAction, setCurrentAction] = useState<any>(null); const [currentAction, setCurrentAction] = useState<any>(null);
const [paramList, setParamList] = useState<any[]>([]); const [paramList, setParamList] = useState<any[]>([]);
// 字段映射(实时增删改查,实时保存) // 字段映射
const [mappingList, setMappingList] = useState(mappingInitList); const [mappingList, setMappingList] = useState(mappingInitList);
const [mappingModal, setMappingModal] = useState(false); const [mappingModal, setMappingModal] = useState(false);
const [mappingForm] = Form.useForm(); const [mappingForm] = Form.useForm();
@@ -133,35 +134,45 @@ export default function DeviceAccessPage() {
setVisible(true); setVisible(true);
}; };
// 提交 // ===================== 物模型提交(完全匹配你的JSON) =====================
const handleSubmit = () => { const handleSubmit = () => {
form.validateFields().then(values => { form.validateFields().then(values => {
if (modalType === 'model') { if (modalType === 'model') {
const submitData = { const submitData = {
name: values.name, name: values.name,
connectType: values.connectType, connectType: values.connectType,
version: "1.0", version: '1.0',
deviceType: values.deviceType, deviceType: values.deviceType,
supportProperties: modelDetail.props.map(p => ({ supportProperties: modelDetail.props.map(p => ({
propertyKey: p.code, propertyKey: p.code,
propertyName: p.name, propertyName: p.name,
dataType: p.type, dataType: p.type,
unit: p.unit || "", unit: p.unit || '',
required: true, required: p.required ?? true,
defaultValue: null defaultValue: p.defaultValue ?? null,
isAlarm: p.isAlarm ?? false
})), })),
supportActions: modelDetail.actions supportActions: modelDetail.actions.map(act => ({
actionId: act.actionId,
actionName: act.actionName,
params: act.params || {}
}))
}; };
console.log("最终提交物模型:", submitData); addDeviceModel(submitData).then(res => {
message.success("物模型保存成功"); if (res.code === 200) {
message.success('物模型保存成功');
}
});
console.log('✅ 最终提交物模型(完全匹配接口)', submitData);
message.success('物模型保存成功');
} else { } else {
message.success("保存成功"); message.success('保存成功');
} }
setVisible(false); setVisible(false);
}); });
}; };
// 属性/事件 编辑 // 属性编辑
const openItemModal = (type: 'props' | 'events' | 'actions', record?: any) => { const openItemModal = (type: 'props' | 'events' | 'actions', record?: any) => {
setItemType(type); setItemType(type);
itemForm.resetFields(); itemForm.resetFields();
@@ -181,7 +192,7 @@ export default function DeviceAccessPage() {
setModelDetail({ ...modelDetail, [type]: list }); setModelDetail({ ...modelDetail, [type]: list });
}; };
// ===================== 字段映射:增删改 立即保存 ===================== // 字段映射
const openMappingModal = (record?: any) => { const openMappingModal = (record?: any) => {
mappingForm.resetFields(); mappingForm.resetFields();
if (record) mappingForm.setFieldsValue(record); if (record) mappingForm.setFieldsValue(record);
@@ -211,7 +222,6 @@ export default function DeviceAccessPage() {
message.success('字段映射删除成功'); message.success('字段映射删除成功');
}; };
// 获取告警属性
const getAlarmProps = () => modelDetail?.props?.filter(item => item.isAlarm) || []; const getAlarmProps = () => modelDetail?.props?.filter(item => item.isAlarm) || [];
// 表格列 // 表格列
@@ -243,7 +253,6 @@ export default function DeviceAccessPage() {
const modelColumns = [ const modelColumns = [
{ title: '模型名称', dataIndex: 'name' }, { title: '模型名称', dataIndex: 'name' },
{ title: '描述', dataIndex: 'desc' },
{ title: '操作', render: r => <Button type="text" icon={<EditOutlined />} onClick={() => openModal('model', r)}>编辑</Button> } { title: '操作', render: r => <Button type="text" icon={<EditOutlined />} onClick={() => openModal('model', r)}>编辑</Button> }
]; ];
@@ -261,7 +270,7 @@ export default function DeviceAccessPage() {
{activeTab === 'product' && <Card><Space className="mb-3"><Button type="primary" icon={<PlusOutlined />} onClick={() => openModal('product')}>新增产品</Button></Space><Table rowKey="id" columns={productColumns} dataSource={productList} /></Card>} {activeTab === 'product' && <Card><Space className="mb-3"><Button type="primary" icon={<PlusOutlined />} onClick={() => openModal('product')}>新增产品</Button></Space><Table rowKey="id" columns={productColumns} dataSource={productList} /></Card>}
{activeTab === 'model' && <Card><Space className="mb-3"><Button type="primary" icon={<PlusOutlined />} onClick={() => openModal('model')}>新增物模型</Button></Space><Table rowKey="id" columns={modelColumns} dataSource={modelList} /></Card>} {activeTab === 'model' && <Card><Space className="mb-3"><Button type="primary" icon={<PlusOutlined />} onClick={() => openModal('model')}>新增物模型</Button></Space><Table rowKey="id" columns={modelColumns} dataSource={modelList} /></Card>}
<Modal open={visible} width={850} onCancel={() => setVisible(false)} onOk={handleSubmit} destroyOnClose <Modal open={visible} width={900} onCancel={() => setVisible(false)} onOk={handleSubmit} destroyOnClose
title={modalType === 'device' ? '设备配置' : modalType === 'product' ? '产品配置' : '物模型配置'}> title={modalType === 'device' ? '设备配置' : modalType === 'product' ? '产品配置' : '物模型配置'}>
<Form form={form} layout="vertical"> <Form form={form} layout="vertical">
{modalType === 'device' && ( {modalType === 'device' && (
@@ -344,15 +353,28 @@ export default function DeviceAccessPage() {
<Divider>属性列表</Divider> <Divider>属性列表</Divider>
<Button size="small" type="primary" icon={<PlusOutlined />} onClick={() => openItemModal('props')} className="mb-2">新增属性</Button> <Button size="small" type="primary" icon={<PlusOutlined />} onClick={() => openItemModal('props')} className="mb-2">新增属性</Button>
<Table size="small" dataSource={modelDetail.props} pagination={false} columns={[ <Table size="small" dataSource={modelDetail.props} pagination={false} columns={[
{ title: '编码', dataIndex: 'code' }, { title: '名称', dataIndex: 'name' }, { title: '类型', dataIndex: 'type' }, { title: '编码', dataIndex: 'code' },
{ title: '名称', dataIndex: 'name' },
{ title: '类型', dataIndex: 'type' },
{ title: '单位', dataIndex: 'unit' },
{ title: '默认值', dataIndex: 'defaultValue' },
{ title: '告警', render: r => <Switch checked={r.isAlarm} disabled size="small" /> }, { title: '告警', render: r => <Switch checked={r.isAlarm} disabled size="small" /> },
{ title: '操作', render: r => <Space><Button type="text" icon={<EditOutlined />} onClick={() => openItemModal('props', r)}>编辑</Button><Popconfirm onConfirm={() => deleteItem('props', r.id)}><Button type="text" danger icon={<DeleteOutlined />}>删除</Button></Popconfirm></Space> } {
title: '操作', render: r => (
<Space>
<Button type="text" icon={<EditOutlined />} onClick={() => openItemModal('props', r)}>编辑</Button>
<Popconfirm onConfirm={() => deleteItem('props', r.id)}>
<Button type="text" danger icon={<DeleteOutlined />}>删除</Button>
</Popconfirm>
</Space>
)
}
]} /> ]} />
<Divider>指令列表</Divider> <Divider>指令列表</Divider>
<Button size="small" type="primary" icon={<PlusOutlined />} onClick={() => { <Button size="small" type="primary" icon={<PlusOutlined />} onClick={() => {
setCurrentAction({ actionId: '', actionName: '', params: {} }); setCurrentAction({ actionId: '', actionName: '', params: {} });
setParamList([]); setParamList([{ paramKey: '', type: 'int', desc: '', defaultValue: '', enum: [] }]);
setActionModal(true); setActionModal(true);
}} className="mb-2">新增指令</Button> }} className="mb-2">新增指令</Button>
<Table size="small" dataSource={modelDetail.actions} pagination={false} columns={[ <Table size="small" dataSource={modelDetail.actions} pagination={false} columns={[
@@ -388,16 +410,28 @@ export default function DeviceAccessPage() {
</Form> </Form>
</Modal> </Modal>
<Modal open={itemModal} width={520} zIndex={1001} destroyOnClose onCancel={() => setItemModal(false)} onOk={saveItem} title="编辑"> {/* 属性弹窗:完整字段 */}
<Modal open={itemModal} width={580} zIndex={1001} destroyOnClose onCancel={() => setItemModal(false)} onOk={saveItem} title="配置属性">
<Form form={itemForm} layout="vertical"> <Form form={itemForm} layout="vertical">
<Form.Item name="id" hidden><Input /></Form.Item> <Form.Item name="id" hidden><Input /></Form.Item>
<Form.Item label="编码" name="code" rules={[{ required: true }]}><Input /></Form.Item> <Form.Item label="属性编码" name="code" rules={[{ required: true }]}><Input placeholder="如 temperature" /></Form.Item>
<Form.Item label="名称" name="name" rules={[{ required: true }]}><Input /></Form.Item> <Form.Item label="属性名称" name="name" rules={[{ required: true }]}><Input placeholder="如 温度" /></Form.Item>
{itemType === 'props' && <><Form.Item label="数据类型" name="type"><Select><Option value="int">int</Option><Option value="float">float</Option><Option value="string">string</Option></Select></Form.Item><Form.Item label="作为告警参数" name="isAlarm" valuePropName="checked"><Switch /></Form.Item></>} <Form.Item label="数据类型" name="type">
<Select>
<Option value="int">int</Option>
<Option value="float">float</Option>
<Option value="string">string</Option>
<Option value="bool">bool</Option>
</Select>
</Form.Item>
<Form.Item label="单位" name="unit"><Input placeholder="如 ℃、%、V" /></Form.Item>
{/*<Form.Item label="是否必填" name="required" valuePropName="checked"><Switch /></Form.Item>*/}
<Form.Item label="默认值" name="defaultValue"><Input placeholder="选填" /></Form.Item>
<Form.Item label="是否作为告警参数" name="isAlarm" valuePropName="checked"><Switch /></Form.Item>
</Form> </Form>
</Modal> </Modal>
{/* 指令 + 参数 弹窗 */} {/* 指令 + 参数 + 枚举 */}
<Modal <Modal
title="配置指令" title="配置指令"
open={actionModal} open={actionModal}
@@ -407,7 +441,8 @@ export default function DeviceAccessPage() {
obj[item.paramKey] = { obj[item.paramKey] = {
type: item.type, type: item.type,
description: item.desc || '', description: item.desc || '',
default: item.defaultValue default: item.defaultValue,
...(item.enum?.length ? { enum: item.enum } : {})
}; };
return obj; return obj;
}, {}); }, {});
@@ -419,68 +454,69 @@ export default function DeviceAccessPage() {
}; };
const exists = modelDetail.actions.some(x => x.actionId === currentAction.actionId); const exists = modelDetail.actions.some(x => x.actionId === currentAction.actionId);
let newActions = []; setModelDetail({
if (exists) { ...modelDetail,
newActions = modelDetail.actions.map(x => x.actionId === currentAction.actionId ? action : x); actions: exists
} else { ? modelDetail.actions.map(x => x.actionId === currentAction.actionId ? action : x)
newActions = [...modelDetail.actions, action]; : [...modelDetail.actions, action]
} });
setModelDetail({ ...modelDetail, actions: newActions });
setActionModal(false); setActionModal(false);
message.success('保存成功'); message.success('保存成功');
}} }}
width={700} width={750}
> >
<div style={{ marginBottom: 16 }}> <div style={{ marginBottom: 16, display: 'flex', gap: 8 }}>
<Input <Input
placeholder="指令编码 如 restart" placeholder="指令编码 如 restart"
value={currentAction?.actionId} value={currentAction?.actionId}
onChange={(e) => setCurrentAction({ ...currentAction, actionId: e.target.value })} onChange={(e) => setCurrentAction({ ...currentAction, actionId: e.target.value })}
style={{ width: '48%', marginRight: '4%' }} style={{ flex: 1 }}
/> />
<Input <Input
placeholder="指令名称 如 重启设备" placeholder="指令名称 如 重启设备"
value={currentAction?.actionName} value={currentAction?.actionName}
onChange={(e) => setCurrentAction({ ...currentAction, actionName: e.target.value })} onChange={(e) => setCurrentAction({ ...currentAction, actionName: e.target.value })}
style={{ width: '48%' }} style={{ flex: 1 }}
/> />
</div> </div>
<Divider>指令参数</Divider> <Divider>指令参数(支持枚举)</Divider>
{paramList.map((item, index) => ( {/* 只保留 1 个参数,不支持新增多行 */}
<div key={index} style={{ display: 'flex', gap: 8, marginBottom: 10, alignItems: 'center' }}> {paramList.length > 0 && (
<Input placeholder="参数名" value={item.paramKey} onChange={(e) => { <div key={0} style={{ display: 'flex', gap: 8, marginBottom: 10, alignItems: 'center' }}>
<Input placeholder="参数名" value={paramList[0].paramKey} onChange={(e) => {
const arr = [...paramList]; const arr = [...paramList];
arr[index].paramKey = e.target.value; arr[0].paramKey = e.target.value;
setParamList(arr); setParamList(arr);
}} /> }} />
<Select value={item.type} style={{ width: 100 }} onChange={(v) => { <Select value={paramList[0].type} style={{ width: 100 }} onChange={(v) => {
const arr = [...paramList]; const arr = [...paramList];
arr[index].type = v; arr[0].type = v;
setParamList(arr); setParamList(arr);
}}> }}>
<Select.Option value="int">int</Select.Option> <Select.Option value="int">int</Select.Option>
<Select.Option value="string">string</Select.Option> <Select.Option value="string">string</Select.Option>
</Select> </Select>
<Input placeholder="描述" value={item.desc} onChange={(e) => { <Input placeholder="描述" value={paramList[0].desc} onChange={(e) => {
const arr = [...paramList]; const arr = [...paramList];
arr[index].desc = e.target.value; arr[0].desc = e.target.value;
setParamList(arr); setParamList(arr);
}} /> }} />
<Input placeholder="默认值" value={item.defaultValue} onChange={(e) => { <Input placeholder="默认值" value={paramList[0].defaultValue} onChange={(e) => {
const arr = [...paramList]; const arr = [...paramList];
arr[index].defaultValue = e.target.value; arr[0].defaultValue = e.target.value;
setParamList(arr);
}} />
<Input placeholder="枚举,逗号分隔" value={paramList[0].enum?.join(',')} onChange={(e) => {
const arr = [...paramList];
arr[0].enum = e.target.value.split(',').map(s => s.trim());
setParamList(arr); setParamList(arr);
}} /> }} />
<Button danger size="small" onClick={() => setParamList(paramList.filter((_, i) => i !== index))}>删</Button>
</div> </div>
))} )}
<Button size="small" type="dashed" block onClick={() => {
setParamList([...paramList, { paramKey: '', type: 'int', desc: '', defaultValue: '' }])
}}>+ 添加参数</Button>
</Modal> </Modal>
<Modal open={mappingModal} width={600} zIndex={1002} destroyOnClose onCancel={() => setMappingModal(false)} onOk={saveMapping} title="字段映射配置"> <Modal open={mappingModal} width={600} zIndex={1002} destroyOnClose onCancel={() => setMappingModal(false)} onOk={saveMapping} title="字段映射配置">

View File

@@ -0,0 +1,160 @@
import React, { useState } from 'react';
import {
Input, Button, Table, message, Space, Tabs, Card
} from 'antd';
import { SearchOutlined, ReloadOutlined } from '@ant-design/icons';
const { Search } = Input;
const { TabPane } = Tabs;
// 模拟在线用户数据
const mockOnlineUsers = [
{
id: 1,
sessionId: 'c85c6fe7-2e70-47...',
loginName: 'admin',
dept: '研发部门',
host: '127.0.0.1',
location: '内网IP',
os: 'Linux',
browser: 'Firefox 136.0',
loginTime: '2026-05-08 09:46:08'
},
{
id: 2,
sessionId: '9f6c7d73-f684-4e...',
loginName: 'admin',
dept: '研发部门',
host: '127.0.0.1',
location: '内网IP',
os: 'Windows >=10',
browser: 'Edge 147',
loginTime: '2026-05-08 10:11:27'
}
];
const OnlineUserPage = () => {
const [activeTab, setActiveTab] = useState('onlineUser'); // 默认选中在线用户
const [loading, setLoading] = useState(false);
const [dataSource, setDataSource] = useState(mockOnlineUsers);
const [searchParams, setSearchParams] = useState({
loginAddress: '',
userName: ''
});
// 搜索
const handleSearch = () => {
setLoading(true);
// 模拟接口请求
setTimeout(() => {
setLoading(false);
message.success('搜索完成');
}, 500);
};
// 重置
const handleReset = () => {
setSearchParams({ loginAddress: '', userName: '' });
setDataSource(mockOnlineUsers);
message.info('已重置搜索条件');
};
// 强退用户
const handleForceLogout = (record) => {
message.info(`已向会话 ${record.sessionId} 发送强退指令`);
};
// 表格列配置
const columns = [
{ title: '序号', dataIndex: 'id', width: 60 },
{ title: '会话编号', dataIndex: 'sessionId', ellipsis: true },
{ title: '登录名称', dataIndex: 'loginName' },
{ title: '所属部门', dataIndex: 'dept' },
{ title: '主机', dataIndex: 'host' },
{ title: '登录地点', dataIndex: 'location' },
{ title: '操作系统', dataIndex: 'os' },
{ title: '浏览器', dataIndex: 'browser' },
{ title: '登录时间', dataIndex: 'loginTime' },
{
title: '操作', width: 100,
render: (_, record) => (
<Button type="link" onClick={() => handleForceLogout(record)} style={{ color: '#1890ff' }}>
强退
</Button>
)
}
];
return (
<div style={{ padding: 20, background: '#f5f7fa', minHeight: '100vh' }}>
{/* ====================== 顶部 Tabs ====================== */}
<Tabs
activeKey={activeTab}
onChange={setActiveTab}
style={{ marginBottom: 20 }}
>
<TabPane tab="在线用户" key="onlineUser" />
<TabPane tab="其他监控" key="other" />
</Tabs>
{/* ====================== Tab 1:在线用户 ====================== */}
{activeTab === 'onlineUser' && (
<Card bordered={false} style={{ borderRadius: 8 }}>
{/* 搜索栏 */}
<div style={{ display: 'flex', alignItems: 'center', gap: 16, marginBottom: 20 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<span>登录地址</span>
<Input
placeholder="请输入登录地址"
value={searchParams.loginAddress}
onChange={(e) => setSearchParams({ ...searchParams, loginAddress: e.target.value })}
style={{ width: 200 }}
/>
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<span>用户名称</span>
<Input
placeholder="请输入用户名称"
value={searchParams.userName}
onChange={(e) => setSearchParams({ ...searchParams, userName: e.target.value })}
style={{ width: 200 }}
/>
</div>
<Button type="primary" icon={<SearchOutlined />} onClick={handleSearch} loading={loading}>
搜索
</Button>
<Button icon={<ReloadOutlined />} onClick={handleReset}>
重置
</Button>
</div>
{/* 在线用户表格 */}
<Table
rowKey="id"
columns={columns}
dataSource={dataSource}
loading={loading}
pagination={{
total: 2,
pageSize: 10,
showSizeChanger: true,
showTotal: (total) => `共 ${total} 条`,
showQuickJumper: true
}}
bordered={false}
/>
</Card>
)}
{/* ====================== Tab 2:其他页面(你可以随便改内容) ====================== */}
{activeTab === 'other' && (
<Card bordered={false} style={{ borderRadius: 8, padding: '40px 0', textAlign: 'center' }}>
<h2>其他监控内容</h2>
<p>这里可以放服务状态、CPU监控、内存监控、接口监控等内容</p>
</Card>
)}
</div>
);
};
export default OnlineUserPage;

View File

@@ -23,7 +23,7 @@ export default function StationManage() {
// 组织列表 // 组织列表
const [orgList, setOrgList] = useState([]); const [orgList, setOrgList] = useState([]);
// 🔥 新增:选中的组织ID(用于筛选) // 🔥 选中的组织ID(用于筛选)
const [selectedOrgId, setSelectedOrgId] = useState<number | undefined>(undefined); const [selectedOrgId, setSelectedOrgId] = useState<number | undefined>(undefined);
// 获取当前登录用户信息 // 获取当前登录用户信息
@@ -50,7 +50,7 @@ export default function StationManage() {
total: 0 total: 0
}); });
// ====================== 获取组织列表(根据 userId 过滤) ====================== // ====================== 获取组织列表 ======================
const getOrgData = () => { const getOrgData = () => {
const params = { const params = {
pageNum: 1, pageNum: 1,
@@ -64,14 +64,12 @@ export default function StationManage() {
}); });
}; };
// ====================== 获取场站列表(分页 + 组织筛选) ====================== // ====================== 获取场站列表 ======================
const getStationData = () => { const getStationData = () => {
const params = { const params = {
pageNum: pagination.pageNum, pageNum: pagination.pageNum,
pageSize: pagination.pageSize, pageSize: pagination.pageSize,
orgId: userInfo?.orgId, orgId: selectedOrgId, // 🔥 最终使用的筛选 orgId
// 🔥 把选中的组织ID传进去
filterOrgId: selectedOrgId,
}; };
getStationList(params).then(res => { getStationList(params).then(res => {
if (res.code === 200) { if (res.code === 200) {
@@ -93,26 +91,37 @@ export default function StationManage() {
}); });
}; };
// 🔥 组织筛选变化 // 组织筛选变化
const handleOrgChange = (value: number) => { const handleOrgChange = (value: number) => {
setSelectedOrgId(value); setSelectedOrgId(value);
setPagination({ ...pagination, pageNum: 1 }); // 筛选重置页码 setPagination({ ...pagination, pageNum: 1 });
}; };
// 🔥 重置筛选 // 重置筛选
const handleReset = () => { const handleReset = () => {
setSelectedOrgId(undefined); setSelectedOrgId(undefined);
setPagination({ ...pagination, pageNum: 1 }); setPagination({ ...pagination, pageNum: 1 });
}; };
// 初始化加载 // ====================== 初始化加载 ======================
useEffect(() => {
getOrgData();
}, []);
// 🔥 关键:如果 userInfo.orgId 存在,则默认选中
useEffect(() => {
if (userInfo?.orgId) {
setSelectedOrgId(userInfo.orgId);
}
}, [userInfo]);
// 加载数据
useEffect(() => { useEffect(() => {
getStationData(); getStationData();
getOrgData();
}, [ }, [
pagination.pageNum, pagination.pageNum,
pagination.pageSize, pagination.pageSize,
selectedOrgId // 🔥 监听筛选变化 selectedOrgId
]); ]);
// ====================== 新增 / 编辑 场站 ====================== // ====================== 新增 / 编辑 场站 ======================
@@ -247,7 +256,8 @@ export default function StationManage() {
{contextHolder} {contextHolder}
<Card title="场站管理" style={{ borderRadius: 8 }}> <Card title="场站管理" style={{ borderRadius: 8 }}>
{/* 🔥 筛选栏 */} {/* 🔥 筛选栏:只有 userInfo 没有 orgId 时才显示 */}
{!userInfo?.orgId && (
<div style={{ marginBottom: 16, display: 'flex', alignItems: 'center', gap: 16 }}> <div style={{ marginBottom: 16, display: 'flex', alignItems: 'center', gap: 16 }}>
<Select <Select
placeholder="请选择组织筛选" placeholder="请选择组织筛选"
@@ -263,13 +273,14 @@ export default function StationManage() {
))} ))}
</Select> </Select>
<Button onClick={handleReset}>重置</Button> <Button onClick={handleReset}>重置</Button>
</div>
)}
<div style={{ marginLeft: 'auto' }}> <div style={{ display: 'flex', justifyContent: 'end', marginBottom: 16 }}>
<Button type="primary" icon={<PlusOutlined />} onClick={handleAdd}> <Button type="primary" icon={<PlusOutlined />} onClick={handleAdd}>
新增场站 新增场站
</Button> </Button>
</div> </div>
</div>
<Table <Table
rowKey="id" rowKey="id"

View File

@@ -2,7 +2,8 @@ import React, { useState, useEffect } from 'react';
import { import {
Layout, Tabs, Card, Row, Col, Button, Typography, Space, Modal, Form, Tree, message, Layout, Tabs, Card, Row, Col, Button, Typography, Space, Modal, Form, Tree, message,
Input, Popconfirm, Divider, InputNumber, Pagination, Table, Select, Input, Popconfirm, Divider, InputNumber, Pagination, Table, Select,
Tag, Checkbox, App Tag, Checkbox, App,
Switch
} from 'antd'; } from 'antd';
import { import {
PlusOutlined, EditOutlined, DeleteOutlined, UserOutlined PlusOutlined, EditOutlined, DeleteOutlined, UserOutlined
@@ -445,6 +446,12 @@ export default function UserRolePage() {
? <Tag color="green">正常</Tag> ? <Tag color="green">正常</Tag>
: <Tag color="red">停用</Tag> : <Tag color="red">停用</Tag>
}, },
{
title: '是否有设备权限', dataIndex: 'deviceOperatePerm', width: 80,
render: (_, s) => s.deviceOperatePerm == true
? <Tag color="green">有权限</Tag>
: <Tag color="red">无权限</Tag>
},
{ {
title: '操作', title: '操作',
width: 220, width: 220,
@@ -719,7 +726,22 @@ export default function UserRolePage() {
</Select> </Select>
</Form.Item> </Form.Item>
</Col> </Col>
)} )}
<Col span={12}>
<Form.Item
name="deviceOperatePerm"
label="设备操作权限"
valuePropName="checked"
initialValue={false}
>
<Switch
checkedChildren="有"
unCheckedChildren="无"
/>
</Form.Item>
</Col>
</Row> </Row>
</Form> </Form>
</Modal> </Modal>

View File

@@ -167,7 +167,6 @@ export default function CleanOptimizationPage() {
<Statistic <Statistic
title="预计收益提升" title="预计收益提升"
value={8278} value={8278}
prefix="¥"
prefix={ prefix={
<div style={{ background: '#f9f0ff', borderRadius: '50%', width: 36, height: 36, display: 'flex', alignItems: 'center', justifyContent: 'center' }}> <div style={{ background: '#f9f0ff', borderRadius: '50%', width: 36, height: 36, display: 'flex', alignItems: 'center', justifyContent: 'center' }}>
<span style={{ color: '#722ed1', fontSize: 18 }}>¥</span> <span style={{ color: '#722ed1', fontSize: 18 }}>¥</span>

View File

@@ -0,0 +1,283 @@
import React, { useState } from 'react';
import {
Card, Row, Col, Statistic, Table, Select, Input, Tag,
Typography, Button
} from 'antd';
import {
CloudOutlined, CheckCircleOutlined, WarningOutlined,
MinusCircleOutlined, ThunderboltOutlined,
RiseOutlined, SunOutlined, BarChartOutlined
} from '@ant-design/icons';
import { Line, Bar, Pie } from '@ant-design/charts';
const { Option } = Select;
const { Search } = Input;
const { Text, Title } = Typography;
// 模拟数据
const deviceList = [
{ id: 1, name: '摄像头 CAM-01', type: '摄像头', status: '正常', data: '35.2 ℃', communication: '通讯正常', updateTime: '2026-04-28 11:32:45' },
{ id: 2, name: '摄像头 CAM-02', type: '摄像头', status: '离线', data: '-', communication: '通讯离线', updateTime: '2026-04-28 12:10:00' },
{ id: 3, name: '摄像头 CAM-03', type: '摄像头', status: '正常', data: '33.9 ℃', communication: '通讯正常', updateTime: '2026-04-28 11:32:45' },
{ id: 4, name: '汇流箱 CMB-A01', type: '汇流箱', status: '预警', data: '46.3 ℃', communication: '通讯正常', updateTime: '2026-04-28 11:32:45' },
{ id: 5, name: '汇流箱 CMB-A02', type: '汇流箱', status: '正常', data: '41.1 ℃', communication: '通讯正常', updateTime: '2026-04-28 11:32:45' },
{ id: 6, name: '逆变器 INV-A01', type: '逆变器', status: '正常', data: '66.8 kW', communication: '通讯正常', updateTime: '2026-04-28 12:00:00' },
{ id: 7, name: '逆变器 INV-A02', type: '逆变器', status: '预警', data: '54.2 kW', communication: '通讯正常', updateTime: '2026-04-28 12:05:00' },
{ id: 8, name: '逆变器 INV-B01', type: '逆变器', status: '正常', data: '22.4 kW', communication: '通讯正常', updateTime: '2026-04-28 11:32:45' },
{ id: 9, name: '电表 METER-01', type: '电表', status: '正常', data: '66.8 kW', communication: '通讯正常', updateTime: '2026-04-28 11:32:45' }
];
const powerTrendData = [
{ time: '00:00', power: 50, rated: 1000 },
{ time: '04:00', power: 70, rated: 1000 },
{ time: '08:00', power: 90, rated: 1000 },
{ time: '12:00', power: 110, rated: 1000 },
{ time: '16:00', power: 100, rated: 1000 },
{ time: '20:00', power: 80, rated: 1000 },
{ time: '24:00', power: 60, rated: 1000 }
];
const inverterPowerData = [
{ name: 'INV-01', power: 164.2 },
{ name: 'INV-02', power: 166.8 },
{ name: 'INV-03', power: 162.1 },
{ name: 'INV-04', power: 159.7 },
{ name: 'INV-05', power: 159.8 }
];
const heatmapData = [
['#1677ff', '#52c41a', '#1677ff', '#faad14', '#52c41a', '#1677ff', '#faad14', '#1677ff', '#1677ff', '#52c41a', '#1677ff', '#1677ff'],
['#52c41a', '#1677ff', '#faad14', '#52c41a', '#1677ff', '#faad14', '#1677ff', '#1677ff', '#52c41a', '#1677ff', '#1677ff', '#52c41a'],
['#1677ff', '#faad14', '#52c41a', '#1677ff', '#faad14', '#1677ff', '#1677ff', '#52c41a', '#1677ff', '#1677ff', '#1677ff', '#52c41a'],
['#faad14', '#52c41a', '#1677ff', '#faad14', '#1677ff', '#1677ff', '#52c41a', '#1677ff', '#1677ff', '#52c41a', '#1677ff', '#faad14'],
['#52c41a', '#1677ff', '#faad14', '#1677ff', '#1677ff', '#52c41a', '#1677ff', '#1677ff', '#52c41a', '#1677ff', '#faad14', '#52c41a']
];
const OnlineRateData = [
{ type: '在线', value: 12 },
{ type: '离线', value: 1 },
{ type: '告警', value: 2 },
{ type: '总数', value: 13 }
];
const RealTimeMonitorPage = () => {
const [loading, setLoading] = useState(false);
const [filterStatus, setFilterStatus] = useState('all');
const [filterType, setFilterType] = useState(undefined);
const [searchName, setSearchName] = useState('');
const filteredList = deviceList.filter(item => {
if (filterStatus === 'all') return true;
if (filterStatus === 'normal') return item.status === '正常';
if (filterStatus === 'warning') return item.status === '预警';
if (filterStatus === 'offline') return item.status === '离线';
return true;
}).filter(item => !filterType || item.type === filterType)
.filter(item => !searchName || item.name.includes(searchName));
const getStatusTag = (status) => {
switch (status) {
case '正常': return <Tag color="green" icon={<CheckCircleOutlined />}>正常</Tag>;
case '预警': return <Tag color="orange" icon={<WarningOutlined />}>预警</Tag>;
case '离线': return <Tag color="gray" icon={<MinusCircleOutlined />}>离线</Tag>;
default: return status;
}
};
const columns = [
{
title: '设备名称', dataIndex: 'name', key: 'name',
render: (name, record) => (
<div style={{ display: 'flex', alignItems: 'center', gap: 8 }}>
<span style={{ color: '#1890ff' }}>
{record.type === '摄像头' ? '摄' : record.type === '汇流箱' ? '汇' : record.type === '逆变器' ? '逆' : record.type === '电表' ? '网' : '其'}
</span>
{name}
</div>
)
},
{ title: '类型', dataIndex: 'type' },
{ title: '当前状态', dataIndex: 'status', render: getStatusTag },
{ title: '实时功率/数据', dataIndex: 'data' },
{ title: '通讯状态', dataIndex: 'communication' },
{ title: '更新时间', dataIndex: 'updateTime' }
];
return (
<div style={{ padding: 20, background: '#f0f2f5', minHeight: '100vh' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', marginBottom: 20 }}>
<div>
<Title level={4} style={{ margin: 0 }}>实时监控中心</Title>
<Text type="secondary">全方位实时掌握电站设备运行状态与发电表现</Text>
</div>
<div style={{ display: 'flex', gap: 16 }}>
<div style={{ textAlign: 'right' }}>
<Statistic
title="在线率"
value="92.3"
suffix="%"
valueStyle={{ color: '#52c41a', fontSize: 20, fontWeight: 700 }}
/>
</div>
<div style={{ textAlign: 'right' }}>
<Statistic
title="设备"
value={13}
valueStyle={{ fontSize: 20, fontWeight: 700 }}
/>
</div>
<div style={{ textAlign: 'right' }}>
<Statistic
title="离线"
value={1}
valueStyle={{ color: '#8c8c8c', fontSize: 20, fontWeight: 700 }}
/>
</div>
<div style={{ textAlign: 'right' }}>
<Statistic
title="告警"
value={2}
valueStyle={{ color: '#faad14', fontSize: 20, fontWeight: 700 }}
/>
</div>
</div>
</div>
<Row gutter={16}>
<Col span={14}>
<Card
title="电站拓扑图 (实时)"
style={{ marginBottom: 16, borderRadius: 8 }}
extra={<Text type="secondary">真实正射底图 · 设备状态联动</Text>}
>
<div style={{ position: 'relative', height: 400, background: '#e6f7ff', borderRadius: 8 }}>
<div style={{ position: 'absolute', top: '50%', left: '50%', transform: 'translate(-50%,-50%)', textAlign: 'center' }}>
<CloudOutlined style={{ fontSize: 48, color: '#1890ff' }} />
<p>电站拓扑底图</p>
</div>
</div>
</Card>
<Card title="设备实时监控列表" style={{ borderRadius: 8 }}>
<div style={{ display: 'flex', alignItems: 'center', gap: 16, marginBottom: 16 }}>
<div style={{ display: 'flex', gap: 8 }}>
<Button type={filterStatus === 'all' ? 'primary' : 'default'} onClick={() => setFilterStatus('all')}>全部 13</Button>
<Button type={filterStatus === 'normal' ? 'primary' : 'default'} onClick={() => setFilterStatus('normal')}>正常 10</Button>
<Button type={filterStatus === 'warning' ? 'primary' : 'default'} onClick={() => setFilterStatus('warning')}>告警 2</Button>
<Button type={filterStatus === 'offline' ? 'primary' : 'default'} onClick={() => setFilterStatus('offline')}>离线 1</Button>
</div>
<Select placeholder="全部类型" style={{ width: 120 }} allowClear onChange={setFilterType}>
<Option value="摄像头">摄像头</Option>
<Option value="汇流箱">汇流箱</Option>
<Option value="逆变器">逆变器</Option>
<Option value="电表">电表</Option>
</Select>
<Search placeholder="搜索设备名称" style={{ width: 200 }} value={searchName} onChange={(e) => setSearchName(e.target.value)} />
</div>
<Table rowKey="id" columns={columns} dataSource={filteredList} pagination={{ total: 13, pageSize: 10 }} size="small" />
</Card>
</Col>
<Col span={10}>
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="当前总功率"
value={66.8}
suffix="kW"
prefix={<ThunderboltOutlined />}
valueStyle={{ color: '#1890ff', fontSize: 24, fontWeight: 700 }}
/>
</Card>
</Col>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="并网状态"
value="并网正常"
prefix={<CheckCircleOutlined />}
valueStyle={{ color: '#52c41a', fontSize: 20, fontWeight: 700 }}
/>
</Card>
</Col>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="电网电压"
value={380.2}
suffix="v"
prefix={<BarChartOutlined />}
valueStyle={{ color: '#1890ff', fontSize: 24, fontWeight: 700 }}
/>
</Card>
</Col>
</Row>
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="今日发电量"
value={4752}
suffix="kWh"
prefix={<RiseOutlined />}
valueStyle={{ color: '#52c41a', fontSize: 24, fontWeight: 700 }}
/>
</Card>
</Col>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="辐照度"
value={815}
suffix="W/m²"
prefix={<SunOutlined />}
valueStyle={{ color: '#faad14', fontSize: 24, fontWeight: 700 }}
/>
</Card>
</Col>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="环境温度"
value={28.4}
suffix="℃"
valueStyle={{ color: '#1890ff', fontSize: 24, fontWeight: 700 }}
/>
</Card>
</Col>
</Row>
<Card title="实时功率曲线" style={{ marginBottom: 16, borderRadius: 8 }}>
<Line data={powerTrendData} xField="time" yField={['power', 'rated']} color={['#1890ff', '#52c41a']} height={180} />
</Card>
<Card title="逆变器功率对比" style={{ marginBottom: 16, borderRadius: 8 }}>
<Bar data={inverterPowerData} xField="name" yField="power" color={'#1677ff'} height={180} />
</Card>
<Row gutter={16}>
<Col span={12}>
<Card title="组串电流热力图" style={{ borderRadius: 8 }}>
{heatmapData.map((row, i) => (
<div key={i} style={{ display: 'flex', gap: 4, marginBottom: 4 }}>
<div style={{ width: 40 }}>INV-0{i + 1}</div>
{row.map((c, j) => <div key={j} style={{ width: 16, height: 24, background: c, borderRadius: 2 }} />)}
</div>
))}
</Card>
</Col>
<Col span={12}>
<Card title="设备在线率" style={{ borderRadius: 8 }}>
<Pie data={OnlineRateData} angleField="value" colorField="type" radius={0.7} innerRadius={0.6} height={220} />
</Card>
</Col>
</Row>
</Col>
</Row>
</div>
);
};
export default RealTimeMonitorPage;

581
src/pages/ReportCenter.tsx Normal file
View File

@@ -0,0 +1,581 @@
import React, { useState } from 'react';
import {
Card, Row, Col, Tabs, Button, Space, Select, Table, Statistic,
DatePicker, message, Tag, Empty,
Typography
} from 'antd';
import {
CloudOutlined, BarChartOutlined, BellOutlined,
CalendarOutlined, LinkOutlined, FileTextOutlined,
DownloadOutlined
} from '@ant-design/icons';
import { Line, Pie } from '@ant-design/charts';
import dayjs from 'dayjs';
const { TabPane } = Tabs;
const { RangePicker } = DatePicker;
const { Option } = Select;
// 模拟数据
const overviewData = {
powerToday: 69302.3,
currentPower: 89343.1,
currentAlarm: 5,
processingOrder: 2,
deviceOnlineRate: 92.3,
generatedReport: 4
};
// 发电报表模拟数据
const powerTrendData = [
{ date: '2026-04-28', avgPower: 40.33, dailyPower: 4580.6 }
];
const powerDetailData = [
{ date: '2026-04-28', avgPower: 40.33, dailyPower: 4580.6, totalPower: 182345.7 }
];
// 告警报表模拟数据
const alarmLevelData = [
{ type: 'MAJOR', value: 2 },
{ type: 'INFO', value: 2 },
{ type: 'MINOR', value: 1 }
];
const alarmStatusData = [
{ type: 'PENDING', value: 3 },
{ type: 'PROCESSING', value: 2 }
];
const alarmTrendData = [
{ date: '2026-04-28', count: 5 }
];
const deviceAlarmRankData = [
{ device: 'INV-A02', count: 2 },
{ device: 'CAM-02', count: 2 },
{ device: 'CMB-A01', count: 1 }
];
// 工单报表模拟数据
const orderStatusData = [
{ type: 'DISPATCHED', value: 1 },
{ type: 'PENDING', value: 1 },
{ type: 'PROCESSING', value: 1 }
];
const orderPriorityData = [
{ type: 'LOW', value: 1 },
{ type: 'MEDIUM', value: 1 },
{ type: 'HIGH', value: 1 }
];
const orderSourceData = [
{ type: 'ALARM', value: 2 },
{ type: 'MANUAL', value: 1 }
];
const orderTrendData = [
{ date: '2026-04-28', newOrder: 3, completed: 0 }
];
const orderEfficiencyData = {
avgProcessHour: 0.00,
completionRate: '0.0%',
newOrderToday: 0
};
// 设备健康模拟数据
const deviceHealthList = [
{ deviceCode: 'CAM-02', deviceName: '摄像头 CAM-02', type: 'CAMERA', online: 'OFFLINE', run: 'FAULT', temp: 0, power: 0, healthScore: 40, healthStatus: 'OFFLINE' },
{ deviceCode: 'INV-A02', deviceName: '逆变器 INV-A02', type: 'INVERTER', online: 'ONLINE', run: 'WARNING', temp: 82.5, power: 54.2, healthScore: 70, healthStatus: 'WARNING' },
{ deviceCode: 'CMB-A01', deviceName: '汇流箱 CMB-A01', type: 'COMBINER_BOX', online: 'ONLINE', run: 'WARNING', temp: 46.3, power: 0, healthScore: 70, healthStatus: 'WARNING' },
{ deviceCode: 'INV-A01', deviceName: '逆变器 INV-A01', type: 'INVERTER', online: 'ONLINE', run: 'NORMAL', temp: 46, power: 66.8, healthScore: 92, healthStatus: 'HEALTHY' },
{ deviceCode: 'INV-B01', deviceName: '逆变器 INV-B01', type: 'INVERTER', online: 'ONLINE', run: 'NORMAL', temp: 43.8, power: 22410.8, healthScore: 92, healthStatus: 'HEALTHY' },
{ deviceCode: 'CMB-A02', deviceName: '汇流箱 CMB-A02', type: 'COMBINER_BOX', online: 'ONLINE', run: 'NORMAL', temp: 41.1, power: 0, healthScore: 92, healthStatus: 'HEALTHY' },
{ deviceCode: 'MET-01', deviceName: '气象站 MET-01', type: 'WEATHER_STATION', online: 'ONLINE', run: 'NORMAL', temp: 28.4, power: 0, healthScore: 92, healthStatus: 'HEALTHY' },
{ deviceCode: 'METER-01', deviceName: '电表 METER-01', type: 'METER', online: 'ONLINE', run: 'NORMAL', temp: 39.2, power: 66811.3, healthScore: 92, healthStatus: 'HEALTHY' },
{ deviceCode: 'CAM-01', deviceName: '摄像头 CAM-01', type: 'CAMERA', online: 'ONLINE', run: 'NORMAL', temp: 35.2, power: 0, healthScore: 92, healthStatus: 'HEALTHY' },
{ deviceCode: 'CAM-03', deviceName: '摄像头 CAM-03', type: 'CAMERA', online: 'ONLINE', run: 'NORMAL', temp: 33.9, power: 0, healthScore: 92, healthStatus: 'HEALTHY' }
];
// 报表文件模拟数据
const reportFileList = [
{ id: 'RPT-ALARM_STAT-20260429092501', name: '告警统计报表', type: 'ALARM_STAT', format: 'EXCEL', status: 'SUCCESS', time: '2026-04-29T09:25:03+08:00' },
{ id: 'RPT-DEMO-WORKORDER-001', name: '西北荒漠一号光伏电站工单效率统计', type: 'WORK_ORDER_STAT', format: 'EXCEL', status: 'SUCCESS', time: '2026-04-29T09:12:42+08:00' },
{ id: 'RPT-DEMO-ALARM-001', name: '西北荒漠一号光伏电站告警统计', type: 'ALARM_STAT', format: 'EXCEL', status: 'SUCCESS', time: '2026-04-29T09:12:42+08:00' },
{ id: 'RPT-DEMO-POWER-001', name: '西北荒漠一号光伏电站发电日报', type: 'POWER_DAILY', format: 'EXCEL', status: 'SUCCESS', time: '2026-04-29T09:12:42+08:00' }
];
export default function ReportCenterPage() {
const [activeTab, setActiveTab] = useState('power');
const [timeType, setTimeType] = useState('day');
const [dateRange, setDateRange] = useState([dayjs().subtract(7, 'day'), dayjs()]);
// 顶部概览卡片
const OverviewCards = () => (
< div
style={{
display: 'flex',
flexWrap: 'wrap', // 自动换行
gap: '16px', // 卡片间距
marginBottom: '20px'
}
}
>
{/* 今日发电量 */}
< div
style={{
flex: '1 1 210px', // 基础宽度 210px,允许扩展
height: '140px', // 固定高度
flexShrink: 0 // 不压缩
}}
>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="今日发电量"
value={overviewData.powerToday}
precision={1}
suffix="kWh"
valueStyle={{ color: '#52c41a', fontSize: 28, fontWeight: 700 }}
prefix={<CloudOutlined style={{ fontSize: 32, color: '#52c41a' }} />}
/>
<div style={{ fontSize: 12, color: '#666' }}>遥测与 latest 聚合</div>
</Card>
</div >
{/* 当前功率 */}
< div
style={{
flex: '1 1 210px', // 基础宽度 210px,允许扩展
height: '140px',
flexShrink: 0
}}
>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="当前功率"
value={overviewData.currentPower}
precision={1}
suffix="kW"
valueStyle={{ color: '#1890ff', fontSize: 28, fontWeight: 700 }}
prefix={<BarChartOutlined style={{ fontSize: 32, color: '#1890ff' }} />}
/>
<div style={{ fontSize: 12, color: '#666' }}>实时功率汇总</div>
</Card>
</div >
{/* 当前告警 */}
< div
style={{
flex: '1 1 210px', // 基础宽度 210px,允许扩展
height: '140px',
flexShrink: 0
}}
>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="当前告警"
value={overviewData.currentAlarm}
suffix="条"
valueStyle={{ color: '#ff4d4f', fontSize: 28, fontWeight: 700 }}
prefix={<BellOutlined style={{ fontSize: 32, color: '#ff4d4f' }} />}
/>
<div style={{ fontSize: 12, color: '#666' }}>累计 5 条</div>
</Card>
</div >
{/* 处理中工单 */}
< div
style={{
flex: '1 1 210px', // 基础宽度 210px,允许扩展
height: '140px',
flexShrink: 0
}}
>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="处理中工单"
value={overviewData.processingOrder}
suffix="单"
valueStyle={{ color: '#faad14', fontSize: 28, fontWeight: 700 }}
prefix={<CalendarOutlined style={{ fontSize: 32, color: '#faad14' }} />}
/>
<div style={{ fontSize: 12, color: '#666' }}>全部 3 单</div>
</Card>
</div >
{/* 设备在线率 */}
< div
style={{
flex: '1 1 210px', // 基础宽度 210px,允许扩展
height: '140px',
flexShrink: 0
}}
>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="设备在线率"
value={overviewData.deviceOnlineRate}
precision={1}
suffix="%"
valueStyle={{ color: '#52c41a', fontSize: 28, fontWeight: 700 }}
prefix={<LinkOutlined style={{ fontSize: 32, color: '#52c41a' }} />}
/>
<div style={{ fontSize: 12, color: '#666' }}>来自设备主数据</div>
</Card>
</div >
{/* 已生成报表 */}
< div
style={{
flex: '1 1 210px', // 基础宽度 210px,允许扩展
height: '140px',
flexShrink: 0
}}
>
<Card bordered={false} style={{ borderRadius: 8, height: '100%' }}>
<Statistic
title="已生成报表"
value={overviewData.generatedReport}
suffix="份"
valueStyle={{ color: '#722ed1', fontSize: 28, fontWeight: 700 }}
prefix={<FileTextOutlined style={{ fontSize: 32, color: '#722ed1' }} />}
/>
<div style={{ fontSize: 12, color: '#666' }}>SUCCESS 文件记录</div>
</Card>
</div >
</div >
);
// 发电报表
const PowerReportTab = () => (
<div>
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 16, gap: 16 }}>
<RangePicker
value={dateRange}
onChange={setDateRange}
style={{ flex: 1 }}
/>
<Space>
<Button size="small" onClick={() => setTimeType('hour')}>小时</Button>
<Button size="small" type={timeType === 'day' ? 'primary' : 'default'} onClick={() => setTimeType('day')}>日</Button>
<Button size="small" onClick={() => setTimeType('month')}>月</Button>
</Space>
<Button type="primary">查询</Button>
</div>
<Card bordered={false} style={{ borderRadius: 8, marginBottom: 16 }} title="发电趋势">
<Line
data={powerTrendData}
xField="date"
yField={['avgPower', 'dailyPower']}
seriesField="type"
color={['#1890ff', '#52c41a']}
point={{ size: 5 }}
legend={{ position: 'top-right' }}
yAxis={{
label: { formatter: (v) => `${v}` },
}}
/>
</Card>
<Card bordered={false} style={{ borderRadius: 8 }} title="发电趋势明细">
<Table
rowKey="date"
columns={[
{ title: '时间', dataIndex: 'date' },
{ title: '平均功率(kW)', dataIndex: 'avgPower' },
{ title: '日发电量(kWh)', dataIndex: 'dailyPower' },
{ title: '累计发电量(kWh)', dataIndex: 'totalPower' }
]}
dataSource={powerDetailData}
pagination={false}
/>
</Card>
</div>
);
// 告警报表
const AlarmReportTab = () => (
<div>
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }} title="告警等级分布">
<Pie
data={alarmLevelData}
angleField="value"
colorField="type"
color={['#1890ff', '#52c41a', '#faad14']}
radius={0.8}
innerRadius={0.5}
legend={{ position: 'right' }}
/>
</Card>
</Col>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }} title="告警状态分布">
<Pie
data={alarmStatusData}
angleField="value"
colorField="type"
color={['#1890ff', '#52c41a']}
radius={0.8}
innerRadius={0.5}
legend={{ position: 'right' }}
/>
</Card>
</Col>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }} title="告警日趋势">
<Line
data={alarmTrendData}
xField="date"
yField="count"
color="#1890ff"
point={{ size: 5 }}
legend={{ position: 'top-right' }}
/>
</Card>
</Col>
</Row>
<Card bordered={false} style={{ borderRadius: 8 }} title="设备告警排行">
<Table
rowKey="device"
columns={[
{ title: '设备编码', dataIndex: 'device' },
{ title: '告警数', dataIndex: 'count' }
]}
dataSource={deviceAlarmRankData}
pagination={false}
/>
</Card>
</div>
);
// 工单报表
const WorkOrderReportTab = () => (
<div>
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }} title="工单状态分布">
<Pie
data={orderStatusData}
angleField="value"
colorField="type"
color={['#1890ff', '#52c41a', '#faad14']}
radius={0.8}
innerRadius={0.5}
legend={{ position: 'right' }}
/>
</Card>
</Col>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }} title="优先级分布">
<Pie
data={orderPriorityData}
angleField="value"
colorField="type"
color={['#1890ff', '#52c41a', '#faad14']}
radius={0.8}
innerRadius={0.5}
legend={{ position: 'right' }}
/>
</Card>
</Col>
<Col span={8}>
<Card bordered={false} style={{ borderRadius: 8 }} title="来源分布">
<Pie
data={orderSourceData}
angleField="value"
colorField="type"
color={['#1890ff', '#52c41a']}
radius={0.8}
innerRadius={0.5}
legend={{ position: 'right' }}
/>
</Card>
</Col>
</Row>
<Row gutter={16}>
<Col span={6}>
<Card bordered={false} style={{ borderRadius: 8 }} title="处理效率">
<div style={{ display: 'flex', gap: 16 }}>
<div>
<Statistic
value={orderEfficiencyData.avgProcessHour}
precision={2}
valueStyle={{ color: '#1890ff', fontSize: 24 }}
/>
<div style={{ fontSize: 12, color: '#666' }}>平均处理小时</div>
</div>
<div>
<Statistic
value={0}
suffix="%"
valueStyle={{ color: '#1890ff', fontSize: 24 }}
formatter={() => orderEfficiencyData.completionRate}
/>
<div style={{ fontSize: 12, color: '#666' }}>完成率</div>
</div>
<div>
<Statistic
value={orderEfficiencyData.newOrderToday}
valueStyle={{ color: '#1890ff', fontSize: 24 }}
/>
<div style={{ fontSize: 12, color: '#666' }}>今日新增</div>
</div>
</div>
</Card>
</Col>
<Col span={18}>
<Card bordered={false} style={{ borderRadius: 8 }} title="工单日趋势">
<Table
rowKey="date"
columns={[
{ title: '日期', dataIndex: 'date' },
{ title: '新增', dataIndex: 'newOrder' },
{ title: '完成', dataIndex: 'completed' }
]}
dataSource={orderTrendData}
pagination={false}
/>
</Card>
</Col>
</Row>
</div>
);
// 设备健康报表
const DeviceHealthTab = () => (
<div>
<Row gutter={16} style={{ marginBottom: 16 }}>
<Col span={6}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="设备在线率"
value={92.3}
precision={1}
suffix="%"
valueStyle={{ color: '#52c41a', fontSize: 24, fontWeight: 700 }}
prefix={<LinkOutlined style={{ fontSize: 28, color: '#52c41a' }} />}
/>
<div style={{ fontSize: 12, color: '#666' }}>来自 pv_device</div>
</Card>
</Col>
<Col span={6}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="离线设备"
value={1}
suffix="台"
valueStyle={{ color: '#faad14', fontSize: 24, fontWeight: 700 }}
prefix={<BellOutlined style={{ fontSize: 28, color: '#faad14' }} />}
/>
<div style={{ fontSize: 12, color: '#666' }}>在线状态统计</div>
</Card>
</Col>
<Col span={6}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="异常设备"
value={3}
suffix="台"
valueStyle={{ color: '#ff4d4f', fontSize: 24, fontWeight: 700 }}
prefix={<BellOutlined style={{ fontSize: 28, color: '#ff4d4f' }} />}
/>
<div style={{ fontSize: 12, color: '#666' }}>运行状态统计</div>
</Card>
</Col>
<Col span={6}>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Statistic
title="平均温度"
value={38.4}
precision={1}
suffix="℃"
valueStyle={{ color: '#1890ff', fontSize: 24, fontWeight: 700 }}
prefix={<BarChartOutlined style={{ fontSize: 28, color: '#1890ff' }} />}
/>
<div style={{ fontSize: 12, color: '#666' }}>来自 device_latest</div>
</Card>
</Col>
</Row>
<Card bordered={false} style={{ borderRadius: 8 }} title="设备健康列表">
<Table
rowKey="deviceCode"
columns={[
{ title: '设备编码', dataIndex: 'deviceCode' },
{ title: '设备名称', dataIndex: 'deviceName' },
{ title: '类型', dataIndex: 'type' },
{ title: '在线', dataIndex: 'online', render: (v) => <Tag color={v === 'ONLINE' ? 'green' : 'red'}>{v}</Tag> },
{ title: '运行', dataIndex: 'run', render: (v) => <Tag color={v === 'NORMAL' ? 'green' : v === 'WARNING' ? 'orange' : 'red'}>{v}</Tag> },
{ title: '温度', dataIndex: 'temp' },
{ title: '功率', dataIndex: 'power' },
{ title: '健康分', dataIndex: 'healthScore' },
{ title: '健康状态', dataIndex: 'healthStatus', render: (v) => <Tag color={v === 'HEALTHY' ? 'green' : v === 'WARNING' ? 'orange' : 'red'}>{v}</Tag> }
]}
dataSource={deviceHealthList}
pagination={false}
scroll={{ x: 'max-content' }}
/>
</Card>
</div>
);
// 报表文件
const ReportFileTab = () => (
<div>
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 16, gap: 16 }}>
<Select placeholder="报表类型" style={{ width: 150 }} allowClear>
<Option value="POWER_DAILY">发电日报</Option>
<Option value="ALARM_STAT">告警统计</Option>
<Option value="WORK_ORDER_STAT">工单统计</Option>
</Select>
<Select placeholder="生成状态" style={{ width: 150 }} allowClear>
<Option value="SUCCESS">成功</Option>
<Option value="FAILED">失败</Option>
</Select>
<Button type="primary">查询</Button>
<Button type="primary" onClick={() => message.success('报表生成任务已提交')}>生成报表</Button>
</div>
<Card bordered={false} style={{ borderRadius: 8 }}>
<Table
rowKey="id"
columns={[
{ title: '报表编码', dataIndex: 'id' },
{ title: '报表名称', dataIndex: 'name' },
{ title: '类型', dataIndex: 'type' },
{ title: '格式', dataIndex: 'format' },
{ title: '状态', dataIndex: 'status', render: (v) => <Tag color={v === 'SUCCESS' ? 'green' : 'red'}>{v}</Tag> },
{ title: '生成时间', dataIndex: 'time' },
{ title: '操作', render: () => <Button type="link" icon={<DownloadOutlined />}>下载</Button> }
]}
dataSource={reportFileList}
pagination={{ total: 4, pageSize: 10, showSizeChanger: true, showTotal: (total) => `共 ${total} 条` }}
/>
</Card>
</div>
);
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>
<p style={{ color: '#666', margin: '4px 0 0' }}>发电、告警、工单效率、设备健康与报表文件统一分析</p>
</div>
<Button type="primary" size="large">生成报表</Button>
</div>
{/* 顶部概览卡片 */}
<OverviewCards />
{/* 标签页 */}
<Tabs activeKey={activeTab} onChange={setActiveTab}>
<TabPane tab="发电报表" key="power">{PowerReportTab()}</TabPane>
<TabPane tab="告警报表" key="alarm">{AlarmReportTab()}</TabPane>
<TabPane tab="工单报表" key="order">{WorkOrderReportTab()}</TabPane>
<TabPane tab="设备健康" key="device">{DeviceHealthTab()}</TabPane>
<TabPane tab="报表文件" key="file">{ReportFileTab()}</TabPane>
</Tabs>
</div>
);
}

View File

@@ -17,6 +17,7 @@ import Organization from '../components/SystemSetting/Organization';
import StationManage from '../components/SystemSetting/StationManage'; import StationManage from '../components/SystemSetting/StationManage';
import { getMenuList } from '../api/mune'; import { getMenuList } from '../api/mune';
import DeviceAccessPage from '../components/SystemSetting/DeviceAccessPage'; import DeviceAccessPage from '../components/SystemSetting/DeviceAccessPage';
import OnlineUserPage from '../components/SystemSetting/OnlineUser';
const { Header, Content } = Layout; const { Header, Content } = Layout;
const { Text } = Typography; const { Text } = Typography;
@@ -156,6 +157,9 @@ export default function SystemSettings() {
if (item.path === '/systemSetting/systemMaintenance') { if (item.path === '/systemSetting/systemMaintenance') {
return { key: 'systemMaintenance', label: '系统维护', icon: <SyncOutlined /> }; return { key: 'systemMaintenance', label: '系统维护', icon: <SyncOutlined /> };
} }
if (item.path === '/systemSetting/monitor') {
return { key: 'monitor', label: '系统监控', icon: <SyncOutlined /> };
}
return null; return null;
}).filter(Boolean); }).filter(Boolean);
@@ -193,6 +197,8 @@ export default function SystemSettings() {
return <DataSafetyPage />; return <DataSafetyPage />;
case 'systemMaintenance': case 'systemMaintenance':
return <SystemMaintenancePage />; return <SystemMaintenancePage />;
case 'monitor':
return <OnlineUserPage />;
default: default:
return <DefaultPage />; return <DefaultPage />;
} }

582
src/pages/WorkOrder.tsx Normal file
View 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}>
创建 --&gt; 已派发
<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;

View File

@@ -4,6 +4,9 @@ import type { RouteObject } from 'react-router-dom';
import VideoMonitorPage from '../pages/VideoMonitorPage'; import VideoMonitorPage from '../pages/VideoMonitorPage';
import AIDiagnosisPage from '../pages/AIAnalysis'; import AIDiagnosisPage from '../pages/AIAnalysis';
import CleanOptimizationPage from '../pages/CleanOptimization'; import CleanOptimizationPage from '../pages/CleanOptimization';
import WorkOrderPage from '../pages/WorkOrder';
import ReportCenterPage from '../pages/ReportCenter';
import RealTimeMonitorPage from '../pages/RealTimeMonitor';
const Layout = lazy(() => import('../components/Layout')); const Layout = lazy(() => import('../components/Layout'));
const ProtectedRoute = lazy(() => import('../components/ProtectedRoute')); const ProtectedRoute = lazy(() => import('../components/ProtectedRoute'));
@@ -53,6 +56,7 @@ export const routeMeta: Record<string, {
'/manage/menuList': { title: '菜单管理', roles: ['admin'], requiresAuth: true }, '/manage/menuList': { title: '菜单管理', roles: ['admin'], requiresAuth: true },
'/organization': { title: '组织管理', roles: ['admin'], requiresAuth: true }, '/organization': { title: '组织管理', roles: ['admin'], requiresAuth: true },
'/station': { title: '场站管理', roles: ['admin'], requiresAuth: true }, '/station': { title: '场站管理', roles: ['admin'], requiresAuth: true },
'/RealtimeMonitor': { title: '实时监控', roles: ['admin', 'operator', 'viewer'], requiresAuth: true },
}; };
const routes: RouteObject[] = [ const routes: RouteObject[] = [
@@ -82,12 +86,13 @@ const routes: RouteObject[] = [
{ path: 'overview', element: <Home /> }, { path: 'overview', element: <Home /> },
{ path: 'devices', element: <Devices /> }, { path: 'devices', element: <Devices /> },
{ path: 'video', element: <Video /> }, { path: 'video', element: <Video /> },
{ path: 'RealtimeMonitor', element: <RealTimeMonitorPage /> },
{ path: 'monitor', element: <VideoMonitorPage /> }, { path: 'monitor', element: <VideoMonitorPage /> },
{ path: 'alerts', element: <Alerts /> }, { path: 'alerts', element: <Alerts /> },
{ path: 'AIanalysis', element: <AIDiagnosisPage /> }, { path: 'AIanalysis', element: <AIDiagnosisPage /> },
{ path: 'clean', element: <CleanOptimizationPage /> }, { path: 'clean', element: <CleanOptimizationPage /> },
{ path: 'task', element: <div>工单任务</div> }, { path: 'task', element: <WorkOrderPage /> },
{ path: 'table', element: <div>报表中心</div> }, { path: 'table', element: <ReportCenterPage /> },
{ path: 'systemSetting', element: <SystemSetting /> }, { path: 'systemSetting', element: <SystemSetting /> },
{ path: 'downloads', element: <Downloads /> }, { path: 'downloads', element: <Downloads /> },
{ path: 'serialNumGenerate', element: <SerialNumGenerate /> }, { path: 'serialNumGenerate', element: <SerialNumGenerate /> },