装备控制界面
This commit is contained in:
86
src/components/DraggableModal.jsx
Normal file
86
src/components/DraggableModal.jsx
Normal file
@@ -0,0 +1,86 @@
|
||||
import React, { useState, useRef, useEffect } from 'react';
|
||||
import { Modal } from 'antd';
|
||||
|
||||
const DraggableModal = ({
|
||||
open,
|
||||
onCancel,
|
||||
title,
|
||||
width = 420,
|
||||
children,
|
||||
...props
|
||||
}) => {
|
||||
const [position, setPosition] = useState({ x: 0, y: 0 });
|
||||
const [isDragging, setIsDragging] = useState(false);
|
||||
const startPos = useRef({ x: 0, y: 0 });
|
||||
|
||||
// 打开时重置位置
|
||||
useEffect(() => {
|
||||
if (open) {
|
||||
setPosition({ x: 0, y: 0 });
|
||||
}
|
||||
}, [open]);
|
||||
|
||||
// 拖拽开始
|
||||
const handleMouseDown = (e) => {
|
||||
startPos.current = {
|
||||
x: e.clientX - position.x,
|
||||
y: e.clientY - position.y,
|
||||
};
|
||||
setIsDragging(true);
|
||||
};
|
||||
|
||||
// 拖拽中
|
||||
useEffect(() => {
|
||||
const handleMouseMove = (e) => {
|
||||
if (!isDragging) return;
|
||||
setPosition({
|
||||
x: e.clientX - startPos.current.x,
|
||||
y: e.clientY - startPos.current.y,
|
||||
});
|
||||
};
|
||||
|
||||
const handleMouseUp = () => {
|
||||
setIsDragging(false);
|
||||
};
|
||||
|
||||
if (isDragging) {
|
||||
document.addEventListener('mousemove', handleMouseMove);
|
||||
document.addEventListener('mouseup', handleMouseUp);
|
||||
}
|
||||
|
||||
return () => {
|
||||
document.removeEventListener('mousemove', handleMouseMove);
|
||||
document.removeEventListener('mouseup', handleMouseUp);
|
||||
};
|
||||
}, [isDragging]);
|
||||
|
||||
return (
|
||||
<Modal
|
||||
open={open}
|
||||
onCancel={onCancel}
|
||||
footer={null}
|
||||
width={width}
|
||||
mask={false}
|
||||
style={{
|
||||
transform: `translate(${position.x}px, ${position.y}px)`,
|
||||
transition: isDragging ? 'none' : 'transform 0.2s ease',
|
||||
}}
|
||||
title={
|
||||
<div
|
||||
onMouseDown={handleMouseDown}
|
||||
style={{
|
||||
cursor: isDragging ? 'grabbing' : 'grab',
|
||||
userSelect: 'none',
|
||||
}}
|
||||
>
|
||||
{title}
|
||||
</div>
|
||||
}
|
||||
{...props}
|
||||
>
|
||||
{children}
|
||||
</Modal>
|
||||
);
|
||||
};
|
||||
|
||||
export default DraggableModal;
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useState } from 'react';
|
||||
import {
|
||||
Card, Row, Col, Select, DatePicker, Input, Button, Space, Table, Tag,
|
||||
Statistic, Typography
|
||||
Statistic, Typography, Modal, Form, Checkbox, message
|
||||
} from 'antd';
|
||||
import {
|
||||
BellOutlined, ClockCircleOutlined, CheckCircleOutlined, ExclamationCircleOutlined
|
||||
@@ -34,9 +34,20 @@ const mockAlerts = [
|
||||
{ id: 'AL-20260428-003', content: 'CAM-02 视频离线', device: 'CAM-02', level: '提示', time: '2026-04-28 09:32:45', duration: '0分钟', status: '待处理', handler: '-' },
|
||||
];
|
||||
|
||||
// 通知渠道
|
||||
const channelOptions = [
|
||||
{ label: '企业微信', value: 'wecom' },
|
||||
{ label: '钉钉', value: 'dingtalk' },
|
||||
{ label: '邮件', value: 'email' },
|
||||
{ label: '短信', value: 'sms' },
|
||||
];
|
||||
|
||||
export default function AlarmCenterPage() {
|
||||
const [selectedAlert, setSelectedAlert] = useState<any>(mockAlerts[0]);
|
||||
const [detailVisible, setDetailVisible] = useState(true);
|
||||
const [confirmModalVisible, setConfirmModalVisible] = useState(false);
|
||||
const [notifyChannels, setNotifyChannels] = useState<string[]>(['wecom', 'dingtalk', 'email']);
|
||||
const [form] = Form.useForm();
|
||||
|
||||
const columns = [
|
||||
{ title: '告警编号', dataIndex: 'id', width: 180 },
|
||||
@@ -131,19 +142,20 @@ export default function AlarmCenterPage() {
|
||||
}
|
||||
};
|
||||
|
||||
// 提交确认告警
|
||||
const handleConfirmAlarm = () => {
|
||||
form.validateFields().then(values => {
|
||||
console.log('确认告警:', selectedAlert.id, values.notifyChannels);
|
||||
message.success('告警已确认,通知将发送至:' + values.notifyChannels.join(','));
|
||||
setConfirmModalVisible(false);
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<div style={{ background: '#f5f7fa', minHeight: '100vh', padding: '0 24px 24px' }}>
|
||||
|
||||
{/* ===================== 统一宽度容器 ===================== */}
|
||||
<div style={{ display: 'flex', gap: 16, marginTop: 16, width: '100%' }}>
|
||||
|
||||
{/* ===================== 左侧:所有模块宽度完全一致 ===================== */}
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
|
||||
{/* 统一容器:保证 筛选 + 统计 宽度完全一样 */}
|
||||
<div style={{ width: "100%" }}>
|
||||
|
||||
{/* 筛选卡片 */}
|
||||
<Card style={{ borderRadius: 8, border: 'none', marginBottom: 16 }} bodyStyle={{ padding: '16px' }}>
|
||||
<Row gutter={16} align="middle">
|
||||
<Col><Select placeholder="告警级别" style={{ width: 120 }} /></Col>
|
||||
@@ -156,144 +168,46 @@ export default function AlarmCenterPage() {
|
||||
</Row>
|
||||
</Card>
|
||||
|
||||
{/* 统计卡片 - 现在和筛选卡片一样宽 */}
|
||||
<div
|
||||
style={{
|
||||
display: "flex",
|
||||
gap: "16px",
|
||||
marginBottom: 16,
|
||||
width: "100%"
|
||||
}}
|
||||
>
|
||||
<div style={{ flex: 1 }}>
|
||||
<Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '12px 0 0 0' }}>
|
||||
<Statistic
|
||||
title="今日告警总数"
|
||||
value={5}
|
||||
prefix={<BellOutlined style={{ color: '#ff4d4f' }} />}
|
||||
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#ff4d4f' }}
|
||||
/>
|
||||
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>昨日 28</div>
|
||||
</Card>
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '8px 0 0 0' }}>
|
||||
<Statistic
|
||||
title="严重告警"
|
||||
value={0}
|
||||
prefix={<ExclamationCircleOutlined style={{ color: '#ff4d4f' }} />}
|
||||
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#ff4d4f' }}
|
||||
/>
|
||||
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>重要 2</div>
|
||||
</Card>
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '8px 0 0 0' }}>
|
||||
<Statistic
|
||||
title="处理中"
|
||||
value={1}
|
||||
prefix={<ClockCircleOutlined style={{ color: '#faad14' }} />}
|
||||
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#faad14' }}
|
||||
/>
|
||||
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>待处理 4</div>
|
||||
</Card>
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '8px 0 0 0' }}>
|
||||
<Statistic
|
||||
title="已关闭"
|
||||
value={0}
|
||||
prefix={<CheckCircleOutlined style={{ color: '#52c41a' }} />}
|
||||
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#52c41a' }}
|
||||
/>
|
||||
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>闭环完成</div>
|
||||
</Card>
|
||||
</div>
|
||||
<div style={{ flex: 1 }}>
|
||||
<Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '8px 0 0 0' }}>
|
||||
<Statistic
|
||||
title="平均响应"
|
||||
value="49分钟"
|
||||
prefix={<ClockCircleOutlined style={{ color: '#1890ff' }} />}
|
||||
valueStyle={{ fontSize: 28, fontWeight: 700, color: '#1890ff' }}
|
||||
/>
|
||||
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>时间估算</div>
|
||||
</Card>
|
||||
</div>
|
||||
<div style={{ display: "flex", gap: "16px", marginBottom: 16, width: "100%" }}>
|
||||
<div style={{ flex: 1 }}><Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '12px 0 0 0' }}>
|
||||
<Statistic title="今日告警总数" value={5} prefix={<BellOutlined style={{ color: '#ff4d4f' }} />} valueStyle={{ fontSize: 28, fontWeight: 700, color: '#ff4d4f' }} />
|
||||
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>昨日 28</div>
|
||||
</Card></div>
|
||||
<div style={{ flex: 1 }}><Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '8px 0 0 0' }}>
|
||||
<Statistic title="严重告警" value={0} prefix={<ExclamationCircleOutlined style={{ color: '#ff4d4f' }} />} valueStyle={{ fontSize: 28, fontWeight: 700, color: '#ff4d4f' }} />
|
||||
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>重要 2</div>
|
||||
</Card></div>
|
||||
<div style={{ flex: 1 }}><Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '8px 0 0 0' }}>
|
||||
<Statistic title="处理中" value={1} prefix={<ClockCircleOutlined style={{ color: '#faad14' }} />} valueStyle={{ fontSize: 28, fontWeight: 700, color: '#faad14' }} />
|
||||
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>待处理 4</div>
|
||||
</Card></div>
|
||||
<div style={{ flex: 1 }}><Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '8px 0 0 0' }}>
|
||||
<Statistic title="已关闭" value={0} prefix={<CheckCircleOutlined style={{ color: '#52c41a' }} />} valueStyle={{ fontSize: 28, fontWeight: 700, color: '#52c41a' }} />
|
||||
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>闭环完成</div>
|
||||
</Card></div>
|
||||
<div style={{ flex: 1 }}><Card bordered={false} style={{ borderRadius: 8, padding: '12px' }} bodyStyle={{ padding: '8px 0 0 0' }}>
|
||||
<Statistic title="平均响应" value="49分钟" prefix={<ClockCircleOutlined style={{ color: '#1890ff' }} />} valueStyle={{ fontSize: 28, fontWeight: 700, color: '#1890ff' }} />
|
||||
<div style={{ fontSize: 12, color: '#999', marginTop: 4 }}>时间估算</div>
|
||||
</Card></div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
{/* 告警列表(宽度 = 筛选卡片 完全一致) */}
|
||||
{/* 告警列表 + 右侧详情(不换行、表格自适应、可横向滚动) */}
|
||||
<div style={{
|
||||
display: 'flex',
|
||||
gap: 16,
|
||||
width: '100%',
|
||||
flexWrap: 'nowrap', /* 强制不换行 */
|
||||
alignItems: 'stretch', /* 高度对齐 */
|
||||
marginBottom: 16
|
||||
}}>
|
||||
|
||||
{/* 左侧告警列表:自适应宽度 + 横向滚动 */}
|
||||
<div style={{
|
||||
flex: 1,
|
||||
minWidth: 0, /* 关键:允许表格缩小 */
|
||||
}}>
|
||||
<Card
|
||||
bordered={false}
|
||||
style={{
|
||||
borderRadius: 8,
|
||||
marginBottom: 16,
|
||||
height: '100%',
|
||||
}}
|
||||
>
|
||||
<div style={{ display: 'flex', gap: 16, width: '100%', flexWrap: 'nowrap', alignItems: 'stretch', marginBottom: 16 }}>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<Card bordered={false} style={{ borderRadius: 8, marginBottom: 16, height: '100%' }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 16 }}>
|
||||
<div>
|
||||
<Typography.Text strong style={{ fontSize: 16, color: '#0837A8', fontWeight: 800 }}>告警列表(共8条)</Typography.Text><br />
|
||||
<Text type="secondary" style={{ fontSize: 12 }}>点击告警查看详情</Text>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Table
|
||||
rowKey="id"
|
||||
columns={columns}
|
||||
dataSource={mockAlerts}
|
||||
pagination={{ pageSize: 8 }}
|
||||
scroll={{ x: 'max-content' }} /* 表格超出自动横向滚动 */
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
<Table rowKey="id" columns={columns} dataSource={mockAlerts} pagination={{ pageSize: 8 }} scroll={{ x: 'max-content' }} style={{ width: '100%' }} />
|
||||
</Card>
|
||||
</div>
|
||||
|
||||
{/* 右侧详情:固定 360px,不挤压、不换行 */}
|
||||
{detailVisible && selectedAlert && (
|
||||
<div style={{
|
||||
width: 360,
|
||||
flexShrink: 0, /* 关键:不被挤压 */
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
}}>
|
||||
<Card
|
||||
title="告警详情"
|
||||
bordered={false}
|
||||
style={{
|
||||
borderRadius: 8,
|
||||
height: '100%',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
overflow: 'hidden'
|
||||
}}
|
||||
bodyStyle={{
|
||||
padding: '16px',
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
flex: 1,
|
||||
overflow: 'hidden'
|
||||
}}
|
||||
>
|
||||
|
||||
{/* 可滚动内容区域 */}
|
||||
<div style={{ width: 360, flexShrink: 0, display: 'flex', flexDirection: 'column' }}>
|
||||
<Card title="告警详情" bordered={false} style={{ borderRadius: 8, height: '100%', display: 'flex', flexDirection: 'column', overflow: 'hidden' }} bodyStyle={{ padding: '16px', display: 'flex', flexDirection: 'column', flex: 1, overflow: 'hidden' }}>
|
||||
<div style={{ flex: 1, overflow: 'auto', paddingRight: 8 }}>
|
||||
<div style={{ marginBottom: 20 }}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
||||
@@ -325,10 +239,9 @@ export default function AlarmCenterPage() {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 固定底部操作按钮 */}
|
||||
<div style={{ marginTop: 12, paddingTop: 12, borderTop: '1px solid #f0f0f0' }}>
|
||||
<Space direction="vertical" style={{ width: '100%' }}>
|
||||
<Button type="primary" block>确认告警</Button>
|
||||
<Button type="primary" block onClick={() => setConfirmModalVisible(true)}>确认告警</Button>
|
||||
<Button block>标记处理中</Button>
|
||||
<Button block danger>关闭告警</Button>
|
||||
</Space>
|
||||
@@ -338,46 +251,43 @@ export default function AlarmCenterPage() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* 三个图表卡片:告警趋势 + 分类占比 + 设备分布 */}
|
||||
<Row gutter={16}>
|
||||
<Col span={8}>
|
||||
<Card
|
||||
bordered={false}
|
||||
style={{ borderRadius: 8 }}
|
||||
title="告警趋势"
|
||||
extra={<Button type="link">更多 </Button>}
|
||||
>
|
||||
<Card bordered={false} style={{ borderRadius: 8 }} title="告警趋势" extra={<Button type="link">更多 </Button>}>
|
||||
<Line {...trendConfig} height={180} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Card
|
||||
bordered={false}
|
||||
style={{ borderRadius: 8 }}
|
||||
title="告警分类占比"
|
||||
extra={<Button type="link">更多 </Button>}
|
||||
>
|
||||
<Card bordered={false} style={{ borderRadius: 8 }} title="告警分类占比" extra={<Button type="link">更多 </Button>}>
|
||||
<Pie {...pieConfig} height={180} />
|
||||
</Card>
|
||||
</Col>
|
||||
<Col span={8}>
|
||||
<Card
|
||||
bordered={false}
|
||||
style={{ borderRadius: 8 }}
|
||||
title="告警来源设备分布"
|
||||
extra={<Button type="link">更多</Button>}
|
||||
>
|
||||
<Card bordered={false} style={{ borderRadius: 8 }} title="告警来源设备分布" extra={<Button type="link">更多</Button>}>
|
||||
<Bar {...barConfig} height={180} />
|
||||
</Card>
|
||||
</Col>
|
||||
</Row>
|
||||
|
||||
</div>
|
||||
|
||||
{/* ===================== 右侧详情面板:高度拉伸至视口 ===================== */}
|
||||
|
||||
</div>
|
||||
|
||||
</div >
|
||||
{/* 确认告警弹窗 */}
|
||||
<Modal
|
||||
title="确认告警"
|
||||
open={confirmModalVisible}
|
||||
onCancel={() => setConfirmModalVisible(false)}
|
||||
onOk={handleConfirmAlarm}
|
||||
destroyOnClose
|
||||
>
|
||||
<Form form={form} initialValues={{ notifyChannels }}>
|
||||
<Form.Item label="发送通知至" name="notifyChannels">
|
||||
<Checkbox.Group options={channelOptions} />
|
||||
</Form.Item>
|
||||
<div style={{ fontSize: 12, color: '#999' }}>
|
||||
确认后将向选中渠道发送通知
|
||||
</div>
|
||||
</Form>
|
||||
</Modal>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user