feat: 可视化大屏展示

This commit is contained in:
2025-12-26 19:50:46 +08:00
parent 9fd7e0c656
commit 02f9b46b22
453 changed files with 70777 additions and 130 deletions
@@ -0,0 +1,458 @@
.dashboard-page {
position: relative;
width: 100%;
height: 100%;
background: var(--bg-primary);
overflow: hidden;
display: flex;
flex-direction: column;
&::before {
content: '';
position: absolute;
inset: 0;
background:
radial-gradient(circle at 20% 20%, rgba(0, 212, 255, 0.12), transparent 45%),
radial-gradient(circle at 80% 10%, rgba(0, 255, 136, 0.08), transparent 45%),
radial-gradient(circle at 70% 80%, rgba(0, 212, 255, 0.08), transparent 55%);
z-index: 0;
pointer-events: none;
}
.dashboard-bg-animation {
position: absolute;
inset: 0;
background-image:
linear-gradient(rgba(0, 212, 255, 0.05) 1px, transparent 1px),
linear-gradient(90deg, rgba(0, 212, 255, 0.05) 1px, transparent 1px);
background-size: 40px 40px;
animation: gridMove 32s linear infinite;
z-index: 0;
pointer-events: none;
}
}
/* Main Content Grid */
.dashboard-spin {
height: 100%;
:global(.ant-spin-container) {
height: 100%;
display: flex;
flex-direction: column;
}
}
.dashboard-content {
flex: 1;
padding: 16px 18px;
overflow: hidden;
position: relative;
z-index: 1;
height: 100%;
}
.dashboard-grid {
display: grid;
grid-template-columns: 25% 50% 25%;
grid-template-rows: 100%;
gap: 14px;
height: 100%;
width: 100%;
}
.grid-col {
display: flex;
flex-direction: column;
gap: 16px;
height: 100%;
overflow: hidden;
}
/* Panel Card Styles */
.panel-card {
background: transparent !important;
border-radius: 8px;
display: flex;
flex-direction: column;
&.glass-panel {
position: relative;
background: rgba(19, 26, 61, 0.7) !important;
border: 1px solid rgba(0, 212, 255, 0.15) !important;
backdrop-filter: blur(8px);
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
overflow: hidden;
&::before {
content: '';
position: absolute;
inset: 0;
pointer-events: none;
background:
linear-gradient(90deg, rgba(0, 212, 255, 0.6), transparent 60px) top left / 60px 2px no-repeat,
linear-gradient(180deg, rgba(0, 212, 255, 0.6), transparent 60px) top left / 2px 60px no-repeat,
linear-gradient(270deg, rgba(0, 212, 255, 0.6), transparent 60px) top right / 60px 2px no-repeat,
linear-gradient(180deg, rgba(0, 212, 255, 0.6), transparent 60px) top right / 2px 60px no-repeat,
linear-gradient(90deg, rgba(0, 212, 255, 0.6), transparent 60px) bottom left / 60px 2px no-repeat,
linear-gradient(0deg, rgba(0, 212, 255, 0.6), transparent 60px) bottom left / 2px 60px no-repeat,
linear-gradient(270deg, rgba(0, 212, 255, 0.6), transparent 60px) bottom right / 60px 2px no-repeat,
linear-gradient(0deg, rgba(0, 212, 255, 0.6), transparent 60px) bottom right / 2px 60px no-repeat;
opacity: 0.35;
}
}
:global(.ant-card-head) {
min-height: 40px;
padding: 0 12px;
border-bottom: 1px solid rgba(0, 212, 255, 0.1);
.ant-card-head-title {
font-size: 15px;
color: #fff;
padding: 8px 0;
}
}
:global(.ant-card-body) {
flex: 1;
padding: 12px;
overflow: hidden;
position: relative;
display: flex;
flex-direction: column;
}
}
.chart-wrapper {
flex: 1;
width: 100%;
position: relative;
min-height: 0; /* Important for flex child */
> div {
height: 100% !important;
}
}
.flex-grow {
flex: 1;
}
.fill-bottom {
flex: 0.8; /* Slightly smaller than other sections if needed */
}
/* Alert List */
.alert-list-container {
height: 100%;
overflow-y: auto;
&::-webkit-scrollbar {
width: 4px;
}
&::-webkit-scrollbar-thumb {
background: rgba(0, 212, 255, 0.2);
border-radius: 2px;
}
}
.alert-item {
padding: 8px 0 !important;
border-bottom: 1px solid rgba(255,255,255,0.05) !important;
.alert-row {
display: flex;
width: 100%;
align-items: flex-start;
.alert-badge {
margin-right: 8px;
margin-top: 2px;
}
.alert-content {
flex: 1;
.alert-head {
display: flex;
justify-content: space-between;
margin-bottom: 2px;
.alert-name { color: #fff; font-weight: 500; font-size: 13px; }
.alert-time { color: var(--accent-blue); font-size: 12px; font-family: monospace; }
}
.alert-msg {
color: rgba(255,255,255,0.6);
font-size: 12px;
line-height: 1.2;
}
}
}
}
/* Center Column Specifics */
.kpi-row {
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 12px;
height: 80px;
}
.kpi-card {
background: rgba(19, 26, 61, 0.7);
border: 1px solid rgba(0, 212, 255, 0.15);
border-radius: 6px;
display: flex;
align-items: center;
padding: 0 16px;
.kpi-icon {
font-size: 24px;
margin-right: 12px;
width: 40px;
height: 40px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
background: rgba(255,255,255,0.05);
&.blue { color: #00d4ff; box-shadow: 0 0 10px rgba(0, 212, 255, 0.2); }
&.green { color: #00ff88; box-shadow: 0 0 10px rgba(0, 255, 136, 0.2); }
&.yellow { color: #ffb800; box-shadow: 0 0 10px rgba(255, 184, 0, 0.2); }
&.purple { color: #9d4edd; box-shadow: 0 0 10px rgba(157, 78, 221, 0.2); }
}
.kpi-info {
.label { font-size: 12px; color: rgba(255,255,255,0.6); }
.value { font-size: 24px; font-weight: bold; color: #fff; font-family: 'Segoe UI', sans-serif; line-height: 1.2; }
small { font-size: 14px; margin-left: 2px; }
}
}
.map-portal-wrapper {
flex: 2; /* Occupy most space */
position: relative;
background: rgba(0,0,0,0.2);
border: 1px solid rgba(0, 212, 255, 0.3);
border-radius: 12px;
overflow: hidden;
display: flex;
justify-content: center;
align-items: center;
/* Grid Background */
.map-bg-grid {
position: absolute;
inset: 0;
background-image:
linear-gradient(rgba(0, 212, 255, 0.2) 1px, transparent 1px),
linear-gradient(90deg, rgba(0, 212, 255, 0.2) 1px, transparent 1px);
background-size: 80px 80px;
perspective: 1000px;
transform: perspective(500px) rotateX(20deg) scale(1.5);
opacity: 0.3;
animation: gridMove 20s linear infinite;
}
.map-content {
position: relative;
z-index: 3;
display: flex;
justify-content: center;
align-items: center;
}
.radar-sweep {
position: absolute;
inset: 0;
z-index: 2;
pointer-events: none;
display: flex;
align-items: center;
justify-content: center;
&::before {
content: '';
width: 520px;
height: 520px;
border-radius: 50%;
background:
repeating-radial-gradient(circle, rgba(0, 212, 255, 0.22) 0 1px, transparent 1px 28px),
radial-gradient(circle, rgba(0, 212, 255, 0.18), transparent 62%),
radial-gradient(circle, rgba(0, 255, 136, 0.10), transparent 70%);
filter: drop-shadow(0 0 18px rgba(0, 212, 255, 0.25));
opacity: 0.55;
}
&::after {
content: '';
position: absolute;
width: 520px;
height: 520px;
border-radius: 50%;
background: conic-gradient(
from 0deg,
rgba(0, 212, 255, 0.00) 0deg,
rgba(0, 212, 255, 0.28) 18deg,
rgba(0, 212, 255, 0.06) 45deg,
rgba(0, 212, 255, 0.00) 75deg,
rgba(0, 212, 255, 0.00) 360deg
);
mix-blend-mode: screen;
animation: radarRotate 2.8s linear infinite;
opacity: 0.9;
}
}
.portal-center {
text-align: center;
width: 340px;
height: 340px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
background: rgba(10, 14, 39, 0.78);
padding: 0 34px;
border-radius: 50%;
border: 1px solid var(--accent-blue);
box-shadow: 0 0 30px rgba(0, 212, 255, 0.2);
backdrop-filter: blur(5px);
position: relative;
overflow: hidden;
&::before {
content: '';
position: absolute;
inset: 10px;
border-radius: 50%;
background:
radial-gradient(circle at 30% 30%, rgba(0, 212, 255, 0.22), transparent 45%),
radial-gradient(circle at 70% 70%, rgba(0, 255, 136, 0.12), transparent 50%);
opacity: 0.6;
pointer-events: none;
}
.portal-title {
color: #fff;
margin-bottom: 24px;
font-size: 22px;
letter-spacing: 2px;
text-shadow: 0 0 10px var(--accent-blue);
}
.portal-btn {
height: 44px;
padding: 0 32px;
font-size: 16px;
background: linear-gradient(90deg, #00d4ff, #007aff);
border: none;
box-shadow: 0 4px 15px rgba(0, 212, 255, 0.4);
transition: all 0.3s;
&:hover {
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(0, 212, 255, 0.6);
}
}
}
}
.task-filter {
:global(.ant-segmented) {
background: rgba(0, 212, 255, 0.06);
border: 1px solid rgba(0, 212, 255, 0.18);
}
:global(.ant-segmented-item-label) {
color: rgba(255, 255, 255, 0.75);
font-size: 12px;
}
:global(.ant-segmented-item-selected) {
background: rgba(0, 212, 255, 0.22) !important;
}
:global(.ant-picker) {
background: rgba(0, 212, 255, 0.06);
border: 1px solid rgba(0, 212, 255, 0.18);
color: rgba(255, 255, 255, 0.85);
}
:global(.ant-picker-input > input) {
color: rgba(255, 255, 255, 0.85);
font-size: 12px;
}
:global(.ant-picker-suffix) {
color: rgba(255, 255, 255, 0.55);
}
}
/* Right Column */
.task-overview-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 8px;
.task-stat-box {
background: rgba(255,255,255,0.03);
padding: 8px;
text-align: center;
border-radius: 4px;
.val { font-size: 18px; font-weight: bold; color: #fff; }
.lbl { font-size: 11px; color: rgba(255,255,255,0.5); }
.val.pending { color: var(--accent-yellow); }
.val.running { color: var(--accent-blue); }
.val.completed { color: var(--accent-green); }
.val.failed { color: var(--accent-red); }
}
}
/* Animation Keyframes */
@keyframes gridMove {
0% { background-position: 0 0; }
100% { background-position: 0 80px; }
}
@keyframes radarRotate {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
/* Media Queries for Responsive adjustments on smaller screens (if needed) */
@media (max-width: 1400px) {
.dashboard-grid {
grid-template-columns: 28% 44% 28%;
}
}
@media (max-width: 1200px) {
.dashboard-page {
height: auto;
overflow-y: auto;
}
.dashboard-content {
height: auto;
overflow: visible;
}
.dashboard-grid {
grid-template-columns: 1fr;
grid-template-rows: auto;
}
.grid-col {
height: auto;
min-height: 400px;
}
.map-portal-wrapper {
min-height: 300px;
}
}
@@ -0,0 +1,504 @@
import React, { useState, useEffect, useCallback, useMemo } from 'react';
import { Card, Button, List, Tag, Spin, message, DatePicker, Segmented, Space } from 'antd';
import {
DesktopOutlined,
CheckCircleOutlined,
WarningOutlined,
RocketOutlined,
EnvironmentOutlined,
PieChartOutlined
} from '@ant-design/icons';
import { Line, Pie, Column, Area, Gauge, Rose } from '@ant-design/plots';
import { history } from 'umi';
import dayjs from 'dayjs';
import {
getDeviceStats,
getTaskStats,
getTrendData,
getMockAlerts,
DeviceStats,
TaskStats,
TrendItem,
AlertItem,
} from '@/services/dashboard';
import './index.less';
const Dashboard: React.FC = () => {
const [loading, setLoading] = useState(true);
const [deviceStats, setDeviceStats] = useState<DeviceStats | null>(null);
const [taskStats, setTaskStats] = useState<TaskStats | null>(null);
const [taskTrend, setTaskTrend] = useState<TrendItem[]>([]);
const [deviceTrend, setDeviceTrend] = useState<TrendItem[]>([]);
const [alerts, setAlerts] = useState<AlertItem[]>([]);
const [annualData, setAnnualData] = useState<any[]>([]);
const [failureAnalysisData, setFailureAnalysisData] = useState<any[]>([]);
const [taskStatType, setTaskStatType] = useState<'day' | 'month' | 'year'>('day');
const [taskStatDate, setTaskStatDate] = useState(dayjs());
const [tenantId, setTenantId] = useState<string | undefined>();
const [includeChildren, setIncludeChildren] = useState<boolean>(true);
useEffect(() => {
// 模拟年度数据
const mockAnnual: any[] = [];
for (let i = 1; i <= 12; i++) {
mockAnnual.push({
month: `${i}月`,
value: Math.floor(Math.random() * 500) + 100,
type: '任务总数',
});
mockAnnual.push({
month: `${i}月`,
value: Math.floor(Math.random() * 450) + 80,
type: '成功任务',
});
}
setAnnualData(mockAnnual);
// 模拟失败原因数据
setFailureAnalysisData([
{ type: '信号丢失', value: 27 },
{ type: '电池不足', value: 25 },
{ type: '天气原因', value: 18 },
{ type: '机械故障', value: 15 },
{ type: '人为取消', value: 10 },
{ type: '其他', value: 5 },
]);
}, []);
useEffect(() => {
const handler = (e: any) => {
const nextTenantId = e?.detail?.tenantId as string | undefined;
const nextIncludeChildren = !!e?.detail?.includeChildren;
setTenantId(nextTenantId);
setIncludeChildren(nextIncludeChildren);
};
window.addEventListener('tenant-change', handler as any);
return () => window.removeEventListener('tenant-change', handler as any);
}, []);
const fetchData = useCallback(async () => {
setLoading(true);
try {
const [deviceRes, taskRes, trendRes] = await Promise.all([
getDeviceStats({ tenantId, includeChildren }),
getTaskStats({
tenantId,
includeChildren,
statType: taskStatType,
date:
taskStatType === 'day'
? taskStatDate.format('YYYY-MM-DD')
: taskStatType === 'month'
? taskStatDate.format('YYYY-MM')
: taskStatDate.format('YYYY'),
}),
getTrendData(7),
]);
setDeviceStats(deviceRes);
setTaskStats(taskRes);
setTaskTrend(trendRes.taskTrend);
setDeviceTrend(trendRes.deviceTrend);
setAlerts(getMockAlerts());
} catch (error) {
console.error('获取数据失败:', error);
message.error('数据加载异常');
} finally {
setLoading(false);
}
}, [includeChildren, taskStatDate, taskStatType, tenantId]);
useEffect(() => {
if (!tenantId) return;
fetchData();
}, [fetchData]);
// 定时刷新和时间更新
useEffect(() => {
const dataTimer = setInterval(fetchData, 30000);
return () => {
clearInterval(dataTimer);
};
}, [fetchData]);
const goTo3D = () => {
history.push('/map3d');
};
// --- 图表配置 ---
const taskTrendSeriesData = useMemo(() => {
return taskTrend.flatMap((t) => [
{ date: t.date, type: '创建', value: t.created || 0 },
{ date: t.date, type: '完成', value: t.completed || 0 },
{ date: t.date, type: '失败', value: t.failed || 0 },
]);
}, [taskTrend]);
const deviceOnlineRateTrendData = useMemo(() => {
return deviceTrend.map((t) => {
const total = t.total || 0;
const online = t.online || 0;
return {
date: t.date,
value: total > 0 ? Math.round((online / total) * 100) : 0,
};
});
}, [deviceTrend]);
const taskTrendConfig: any = {
data: taskTrendSeriesData,
xField: 'date',
yField: 'value',
seriesField: 'type',
smooth: true,
color: ['#00d4ff', '#00ff88', '#ffb800'],
areaStyle: {
fill: 'l(270) 0:#ffffff 0.5:#7ec2f3 1:#1890ff',
fillOpacity: 0.1,
},
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.65)' } }, grid: null },
yAxis: { label: { style: { fill: 'rgba(255,255,255,0.65)' } }, grid: { line: { style: { stroke: 'rgba(255,255,255,0.1)' } } } },
tooltip: { showMarkers: true },
height: 180,
};
const pieConfig: any = {
data: deviceStats?.byType || [],
angleField: 'count',
colorField: 'name',
radius: 0.7,
innerRadius: 0.5,
label: {
type: 'outer',
content: '{name} {percentage}',
style: { fill: 'rgba(255,255,255,0.65)' },
},
legend: { position: 'bottom', itemValue: { style: { fill: 'rgba(255,255,255,0.65)' } }, itemName: { style: { fill: 'rgba(255,255,255,0.65)' } } },
height: 200,
};
const columnConfig: any = {
data: [
{ type: '在线', value: deviceStats?.online || 0, color: '#00ff88' },
{ type: '离线', value: deviceStats?.offline || 0, color: '#8b9dc3' },
{ type: '故障', value: deviceStats?.fault || 0, color: '#ff4d4f' },
],
xField: 'type',
yField: 'value',
seriesField: 'type',
color: ({ type }: any) => {
if(type === '在线') return '#00ff88';
if(type === '故障') return '#ff4d4f';
return '#8b9dc3';
},
label: {
position: 'middle',
style: { fill: '#fff' },
},
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.65)' } } },
yAxis: { label: { style: { fill: 'rgba(255,255,255,0.65)' } }, grid: { line: { style: { stroke: 'rgba(255,255,255,0.1)' } } } },
legend: false,
height: 180,
};
const deviceOnlineRateConfig: any = {
data: deviceOnlineRateTrendData,
xField: 'date',
yField: 'value',
smooth: true,
color: '#00d4ff',
areaStyle: { fillOpacity: 0.15 },
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.65)' } }, grid: null },
yAxis: {
label: { style: { fill: 'rgba(255,255,255,0.65)' } },
grid: { line: { style: { stroke: 'rgba(255,255,255,0.08)' } } },
},
tooltip: { showMarkers: true },
height: 160,
};
const areaConfig: any = {
data: annualData,
xField: 'month',
yField: 'value',
seriesField: 'type',
color: ['#00d4ff', '#00ff88'],
areaStyle: { fillOpacity: 0.3 },
xAxis: { label: { style: { fill: 'rgba(255,255,255,0.65)' } } },
yAxis: { label: { style: { fill: 'rgba(255,255,255,0.65)' } }, grid: { line: { style: { stroke: 'rgba(255,255,255,0.1)' } } } },
legend: { position: 'top-right', itemName: { style: { fill: '#fff' } } },
smooth: true,
height: 220,
};
const roseConfig: any = {
data: failureAnalysisData,
xField: 'type',
yField: 'value',
seriesField: 'type',
radius: 0.9,
label: {
offset: -15,
content: '{name}',
style: { fill: '#fff' },
},
legend: { position: 'bottom', itemName: { style: { fill: 'rgba(255,255,255,0.65)' } } },
height: 200,
};
const taskStatusPieConfig: any = {
data: [
{ name: '待执行', value: taskStats?.pending || 0 },
{ name: '执行中', value: taskStats?.running || 0 },
{ name: '已完成', value: taskStats?.completed || 0 },
{ name: '已失败', value: taskStats?.failed || 0 },
],
angleField: 'value',
colorField: 'name',
radius: 0.85,
innerRadius: 0.55,
label: {
type: 'outer',
content: '{name} {percentage}',
style: { fill: 'rgba(255,255,255,0.65)' },
},
legend: { position: 'bottom', itemValue: { style: { fill: 'rgba(255,255,255,0.65)' } }, itemName: { style: { fill: 'rgba(255,255,255,0.65)' } } },
height: 190,
};
const getAlertColor = (level: string) => {
switch (level) {
case 'critical': return 'red';
case 'error': return 'orange';
case 'warning': return 'gold';
default: return 'blue';
}
};
const taskPeriodText = useMemo(() => {
if (taskStatType === 'day') return '当日';
if (taskStatType === 'month') return '当月';
return '当年';
}, [taskStatType]);
const taskNewLabel = useMemo(() => {
if (taskStatType === 'day') return '当日任务';
if (taskStatType === 'month') return '当月任务';
return '当年任务';
}, [taskStatType]);
const datePickerFormat = useMemo(() => {
if (taskStatType === 'day') return 'YYYY-MM-DD';
if (taskStatType === 'month') return 'YYYY-MM';
return 'YYYY';
}, [taskStatType]);
return (
<div className="dashboard-page">
<div className="dashboard-bg-animation"></div>
<Spin spinning={loading} wrapperClassName="dashboard-spin">
<div className="dashboard-content">
<div className="dashboard-grid">
{/* 左侧栏:设备态势 */}
<div className="grid-col left-col">
<Card title="设备类型分布" className="panel-card glass-panel" size="small">
<div className="chart-wrapper">
<Pie {...pieConfig} />
</div>
</Card>
<Card title="设备状态统计" className="panel-card glass-panel" size="small">
<div className="chart-wrapper">
<Column {...columnConfig} />
</div>
</Card>
<Card title="近7日在线率趋势" className="panel-card glass-panel" size="small">
<div className="chart-wrapper">
<Area {...deviceOnlineRateConfig} />
</div>
</Card>
<Card
title={<span><WarningOutlined className="icon-warning" /> 实时告警</span>}
className="panel-card glass-panel flex-grow"
size="small"
extra={<Tag color="#f50">Live</Tag>}
>
<div className="alert-list-container">
<List
dataSource={alerts}
split={false}
renderItem={(item) => (
<List.Item className="alert-item">
<div className="alert-row">
<div className="alert-badge">
<Tag color={getAlertColor(item.level)}>{item.level.toUpperCase().slice(0,1)}</Tag>
</div>
<div className="alert-content">
<div className="alert-head">
<span className="alert-name">{item.deviceName || item.taskName}</span>
<span className="alert-time">{dayjs(item.timestamp).format('HH:mm')}</span>
</div>
<div className="alert-msg">{item.message}</div>
</div>
</div>
</List.Item>
)}
/>
</div>
</Card>
</div>
{/* 中间栏:核心监控 */}
<div className="grid-col center-col">
{/* 顶部KPI */}
<div className="kpi-row">
<div className="kpi-card">
<div className="kpi-icon blue"><DesktopOutlined /></div>
<div className="kpi-info">
<div className="label">设备总数</div>
<div className="value">{deviceStats?.total || 0}</div>
</div>
</div>
<div className="kpi-card">
<div className="kpi-icon green"><CheckCircleOutlined /></div>
<div className="kpi-info">
<div className="label">在线率</div>
<div className="value">{deviceStats?.onlineRate || 0}<small>%</small></div>
</div>
</div>
<div className="kpi-card">
<div className="kpi-icon yellow"><RocketOutlined /></div>
<div className="kpi-info">
<div className="label">{taskNewLabel}</div>
<div className="value">{taskStats?.todayNew || 0}</div>
</div>
</div>
<div className="kpi-card">
<div className="kpi-icon purple"><PieChartOutlined /></div>
<div className="kpi-info">
<div className="label">执行成功率</div>
<div className="value">{taskStats?.successRate || 0}<small>%</small></div>
</div>
</div>
</div>
{/* 地图/3D入口 */}
<div className="map-portal-wrapper">
<div className="map-bg-grid"></div>
<div className="radar-sweep"></div>
<div className="map-content">
<div className="portal-center">
<EnvironmentOutlined style={{ fontSize: 56, color: '#00d4ff', marginBottom: 20 }} />
<h2 className="portal-title">全域数字孪生监控中心</h2>
<Button type="primary" shape="round" size="large" onClick={goTo3D} className="portal-btn">
立即进入监控视图
</Button>
</div>
</div>
</div>
{/* 底部年度统计 */}
<Card title="年度任务执行趋势分析" className="panel-card glass-panel fill-bottom" size="small">
<div className="chart-wrapper">
<Area {...areaConfig} />
</div>
</Card>
</div>
{/* 右侧栏:任务与运维 */}
<div className="grid-col right-col">
<Card
title={`${taskPeriodText}任务统计`}
className="panel-card glass-panel"
size="small"
extra={
<Space size={8} className="task-filter">
<Segmented
size="small"
options={[
{ label: '日', value: 'day' },
{ label: '月', value: 'month' },
{ label: '年', value: 'year' },
]}
value={taskStatType}
onChange={(v) => setTaskStatType(v as any)}
/>
<DatePicker
size="small"
value={taskStatDate}
onChange={(v) => v && setTaskStatDate(v)}
picker={taskStatType === 'day' ? 'date' : taskStatType}
allowClear={false}
format={datePickerFormat}
disabledDate={(d) => !!d && d.isAfter(dayjs(), 'day')}
/>
</Space>
}
>
<div className="task-overview-grid">
<div className="task-stat-box">
<div className="val pending">{taskStats?.pending || 0}</div>
<div className="lbl">待执行</div>
</div>
<div className="task-stat-box">
<div className="val running">{taskStats?.running || 0}</div>
<div className="lbl">执行中</div>
</div>
<div className="task-stat-box">
<div className="val completed">{taskStats?.completed || 0}</div>
<div className="lbl">已完成</div>
</div>
<div className="task-stat-box">
<div className="val failed">{taskStats?.failed || 0}</div>
<div className="lbl">已失败</div>
</div>
</div>
<div style={{ marginTop: 16 }}>
<Gauge
percent={taskStats?.successRate ? taskStats.successRate / 100 : 0}
range={{ color: 'l(0) 0:#bde8ff 1:#9ec9ff' }}
startAngle={Math.PI}
endAngle={2 * Math.PI}
indicator={null}
statistic={{
content: {
style: { fontSize: '20px', color: '#fff' },
formatter: () => `${taskPeriodText}成功率`,
},
}}
height={100}
/>
</div>
</Card>
<Card title="任务状态占比" className="panel-card glass-panel" size="small">
<div className="chart-wrapper">
<Pie {...taskStatusPieConfig} />
</div>
</Card>
<Card title="近7日任务趋势" className="panel-card glass-panel" size="small">
<div className="chart-wrapper">
<Line {...taskTrendConfig} />
</div>
</Card>
<Card title="异常原因分析" className="panel-card glass-panel flex-grow" size="small">
<div className="chart-wrapper">
<Rose {...roseConfig} />
</div>
</Card>
</div>
</div>
</div>
</Spin>
</div>
);
};
export default Dashboard;