import React, { useState } from 'react'; import { Form, Input, Select, Switch, Button, Row, Col, Card as AntdCard, Tag, Table, message, Typography, Space, TimePicker, Divider, } from 'antd'; import { CloudOutlined, TeamOutlined, BellOutlined, DatabaseOutlined, CalendarOutlined, CheckCircleOutlined, DownloadOutlined, FileTextOutlined, DeleteOutlined, RestOutlined, SettingOutlined, UserOutlined, NotificationOutlined, ApiOutlined, SafetyCertificateOutlined, ToolOutlined, RightOutlined, EyeOutlined, } from '@ant-design/icons'; import { Smartphone, Mail, Send, MessageSquare, ShieldCheck, Users, LineChart, Wrench, Cpu, Camera, Wind, Box, Activity, Zap, RefreshCw, Shield, Key, Lock, } from 'lucide-react'; import dayjs from 'dayjs'; const { Text, Title } = Typography; const BasicSettings = () => { const [form] = Form.useForm(); // 响应式字体大小 const fontNormal = 'clamp(12px, 0.75vw, 13px)'; const fontSmall = 'clamp(11px, 0.7vw, 12px)'; const fontTitle = 'clamp(14px, 0.85vw, 16px)'; const fontLarge = 'clamp(18px, 1.1vw, 22px)'; const handleSave = () => { message.success('设置已保存'); }; // 顶部统计卡片数据 const topCards = [ { title: '当前版本', value: 'v2.8.1', tag: '最新版', tagColor: 'blue', icon: , bg: 'linear-gradient(135deg, #e6f4ff 0%, #bae0ff 100%)' }, { title: '在线用户', value: '12', trend: '↑ 2', trendColor: '#52c41a', icon: , bg: 'linear-gradient(135deg, #f6ffed 0%, #d9f7be 100%)' }, { title: '告警通道', value: '3 / 4', trend: '正常', trendColor: '#52c41a', icon: , bg: 'linear-gradient(135deg, #fff2f0 0%, #ffccc7 100%)' }, { title: '数据备份状态', value: '正常', trend: '●', trendColor: '#52c41a', icon: , bg: 'linear-gradient(135deg, #e6fffb 0%, #b5f5ec 100%)' }, { title: '最近更新', value: '2025-05-20', icon: , bg: 'linear-gradient(135deg, #f9f0ff 0%, #efdbff 100%)' }, ]; // 角色权限概览 const roleOverview = [ { title: '超级管理员', users: 2, perms: 28, tags: ['全部权限', '系统管理'], color: '#1677ff', bg: '#e6f4ff', icon: }, { title: '运维工程师', users: 5, perms: 18, tags: ['设备管理', '工单管理'], color: '#52c41a', bg: '#f6ffed', icon: }, { title: '巡检主管', users: 8, perms: 12, tags: ['巡检管理', '告警处理'], color: '#fa8c16', bg: '#fff7e6', icon: }, { title: '数据分析师', users: 3, perms: 15, tags: ['数据分析', '报表查看'], color: '#722ed1', bg: '#f9f0ff', icon: }, ]; // 设备状态 const deviceStatuses = [ { name: '逆变器', count: '5/5', status: '正常' }, { name: '汇流箱', count: '20/20', status: '正常' }, { name: '气象站', count: '1/1', status: '正常' }, { name: '摄像头', count: '12/12', status: '正常' }, { name: '无人机', count: '2/2', status: '正常' }, { name: '机器人', count: '5/5', status: '正常' }, { name: 'API接口', count: '正常', status: '正常' }, { name: 'Modbus', count: '正常', status: '正常' }, ]; return (
{/* 顶部统计卡片 */} {topCards.map((item, idx) => (
{React.cloneElement(item.icon as React.ReactElement, { size: 20, style: item.icon.props.style ? { ...item.icon.props.style, fontSize: 20 } : { fontSize: 20 } })}
{item.title}
{item.value} {item.tag && {item.tag}} {item.trend && {item.trend}}
))}
{/* 左侧 */} {/* 基础配置 */} 基础配置} bordered={false} style={{ borderRadius: 10, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }} bodyStyle={{ padding: '16px' }} >
工单自动编号 AI建议自动生成 移动端同步
{/* 通知与告警策略 */} 通知与告警策略} bordered={false} style={{ borderRadius: 10, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }} bodyStyle={{ padding: '16px' }} > {[ { label: '短信', icon: , color: '#52c41a', status: '已启用' }, { label: '邮件', icon: , color: '#1677ff', status: '已启用' }, { label: 'Telegram', icon: , color: '#13c2c2', status: '已启用' }, { label: '系统通知', icon: , color: '#fa8c16', status: '已启用' }, ].map((item, idx) => (
{React.cloneElement(item.icon as React.ReactElement, { style: { color: item.color } })}
{item.label}
{item.status}
))}
严重告警立即通知 发电下降超过 15% 通信中断通知 每日汇总推送 夜间免打扰
{/* 用户与权限预览 */} 用户与权限预览} bordered={false} style={{ borderRadius: 10, boxShadow: '0 2px 8px rgba(0,0,0,0.04)', marginBottom: 0 }} bodyStyle={{ padding: '12px' }} > `共 ${total} 条` }} columns={[ { title: '用户名', dataIndex: 'name', key: 'name', fixed: 'left', width: 80 }, { title: '角色', dataIndex: 'role', key: 'role', width: 100, render: (role) => { const config: any = { '超级管理员': { color: '#1677ff', bg: '#e6f4ff' }, '运维工程师': { color: '#52c41a', bg: '#f6ffed' }, '巡检主管': { color: '#fa8c16', bg: '#fff7e6' }, '数据分析师': { color: '#722ed1', bg: '#f9f0ff' }, }; const s = config[role] || { color: '#8c8c8c', bg: '#f5f5f5' }; return {role}; } }, { title: '手机号', dataIndex: 'phone', key: 'phone', width: 110 }, { title: '邮箱', dataIndex: 'email', key: 'email', ellipsis: true }, { title: '状态', dataIndex: 'status', key: 'status', width: 70, render: (status) => (
{status} ) }, { title: '操作', key: 'action', width: 60, render: () => , fixed: 'right' }, ]} dataSource={[ { name: '张运维', role: '超级管理员', phone: '138****0001', email: 'zhangyw@pvsmart.com', status: '在线' }, { name: '李工程师', role: '运维工程师', phone: '139****0002', email: 'li.gongcheng@pvsmart.com', status: '在线' }, { name: '王班长', role: '巡检主管', phone: '137****0003', email: 'wang.banzhang@pvsmart.com', status: '在线' }, { name: '赵分析师', role: '数据分析师', phone: '136****0004', email: 'zhao.fx@pvsmart.com', status: '在线' }, ]} /> {/* 右侧 */}
{/* 角色权限概览 */} 角色权限概览} bordered={false} style={{ borderRadius: 10, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }} bodyStyle={{ padding: '10px' }} > {roleOverview.map((role, idx) => (
{React.cloneElement(role.icon as React.ReactElement, { size: 16 })}
{role.title}
用户 {role.users} | 权限 {role.perms}
{role.tags.map((tag, tidx) => ( {tag} ))}
))} {/* 设备接入状态 */} 设备接入状态} extra={} bordered={false} style={{ borderRadius: 10, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }} bodyStyle={{ padding: '12px' }} >
{deviceStatuses.map((item, idx) => (
{item.name} {item.count}
))}
{[ { x: 60, y: 40, icon: , label: '逆变器' }, { x: 140, y: 40, icon: , label: '汇流箱' }, { x: 160, y: 80, icon: , label: '气象站' }, { x: 140, y: 120, icon: , label: '摄像头' }, { x: 60, y: 120, icon: , label: '机器人' }, { x: 40, y: 80, icon: , label: '接口' }, ].map((node, i) => (
{node.icon}
{node.label}
))}
{/* 数据与安全 */} 数据与安全} bordered={false} style={{ borderRadius: 10, marginBottom: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }} bodyStyle={{ padding: '12px' }} >
{[ { label: '数据保留', value: '3 年', icon: }, { label: '登录审计', value: '已开启', icon: , color: '#52c41a' }, { label: '自动备份', value: '02:00', icon: }, { label: 'API 密钥', value: '正常', icon: , color: '#52c41a' }, { label: '最近备份', value: '2025-05-24 02:00', icon: }, { label: 'SSL 证书', value: '有效期至 2026-12-31', icon: }, { label: '双因素认证', value: '已开启', icon: , color: '#52c41a' }, ].map((item, idx) => (
{React.isValidElement(item.icon) ? React.cloneElement(item.icon as React.ReactElement, { size: 12, style: { ...item.icon.props.style, fontSize: 12 } }) : item.icon}
{item.label}
{item.value}
))}
{/* 系统维护 */} 系统维护} extra={} bordered={false} style={{ borderRadius: 10, boxShadow: '0 2px 8px rgba(0,0,0,0.04)' }} bodyStyle={{ padding: '12px' }} > {[ { label: '清理缓存', icon: , color: '#1677ff' }, { label: '重启服务', icon: , color: '#1677ff' }, { label: '备份下载', icon: , color: '#1677ff' }, { label: '日志导出', icon: , color: '#1677ff' }, ].map((btn, idx) => (
))} ); }; export default BasicSettings;