卡片样式
This commit is contained in:
@@ -22,11 +22,12 @@ import AgoraTextTest from '../AgoraRtc.tsx';
|
||||
import { useWebRTCPlayer } from '../useWebRTCStream.tsx';
|
||||
import VideoPlayer from '../VideoPlayer.tsx.tsx';
|
||||
import CesiumMap from '../Map.jsx';
|
||||
import { getUAVState, getSiteDevice, getSiteUAVList } from '@/api/device.ts';
|
||||
import { getUAVState, getSiteDevice, getSiteUAVList, getsinglePlan, getRobotTaskList } from '@/api/device.ts';
|
||||
import dayjs from 'dayjs';
|
||||
import { useMqtt } from '@/hooks/useMqtt';
|
||||
import envConfig from '../../../env';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { RootState } from '@/store';
|
||||
import envConfig from '../../../env';
|
||||
|
||||
const { Content } = Layout;
|
||||
const { Text, Title } = Typography;
|
||||
@@ -62,6 +63,7 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
|
||||
const [devices, setDevices] = useState([]);
|
||||
const [planedevices, setPlaneDevices] = useState([]);
|
||||
const [devicesAll, setDevicesAll] = useState([]);
|
||||
const [taskStats, setTaskStats] = useState({ completed: 12, total: 15 });
|
||||
|
||||
// 获取数据
|
||||
const fetchAllData = async () => {
|
||||
@@ -107,6 +109,72 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
|
||||
useEffect(() => {
|
||||
fetchAllData();
|
||||
}, [userInfo, stationId]);
|
||||
useEffect(() => {
|
||||
fetchTaskStats();
|
||||
}, [devicesAll.length]);
|
||||
|
||||
// 获取今日任务统计
|
||||
const fetchTaskStats = async () => {
|
||||
if (!stationId) return;
|
||||
|
||||
try {
|
||||
const todayStart = dayjs().startOf('day').unix();
|
||||
const todayEnd = dayjs().endOf('day').unix();
|
||||
|
||||
let completedCount = 0;
|
||||
let totalCount = 0;
|
||||
|
||||
// 1. 获取无人机今日任务
|
||||
if (planedevices?.length > 0) {
|
||||
try {
|
||||
const sns = planedevices.map(item => item.gateway_sn);
|
||||
const droneRes = await getsinglePlan({ sns, beginAt: todayStart, endAt: todayEnd });
|
||||
if (droneRes?.code === 200 && droneRes.data) {
|
||||
let droneTasks = [];
|
||||
Object.values(droneRes.data).forEach((item: any) => {
|
||||
if (item.list) droneTasks = droneTasks.concat(item.list);
|
||||
});
|
||||
totalCount += droneTasks.length;
|
||||
// 计算无人机完成的任务
|
||||
completedCount += droneTasks.filter(t =>
|
||||
['success', 'completed', 'executed', 'FINISH', 'COMPLETED'].includes(t.status)
|
||||
).length;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取无人机任务统计失败', err);
|
||||
}
|
||||
}
|
||||
|
||||
// 2. 获取机器人今日任务
|
||||
try {
|
||||
const robotRes = await getRobotTaskList({ siteId: String(stationId) });
|
||||
if (robotRes?.code == 200 && robotRes.data) {
|
||||
const todayRobotTasks = robotRes.data.filter((t: any) => {
|
||||
// 简单判断是今日的任务
|
||||
if (t.createTime) {
|
||||
const taskTime = dayjs(t.createTime);
|
||||
return taskTime.isAfter(dayjs().startOf('day')) && taskTime.isBefore(dayjs().endOf('day'));
|
||||
}
|
||||
return true; // 默认都算
|
||||
});
|
||||
totalCount += todayRobotTasks.length;
|
||||
// 计算机器人完成的任务
|
||||
completedCount += todayRobotTasks.filter((t: any) =>
|
||||
['FINISH', 'FINISHED', 'COMPLETED', 'completed'].includes(t.taskStaus)
|
||||
).length;
|
||||
}
|
||||
} catch (err) {
|
||||
console.error('获取机器人任务统计失败', err);
|
||||
}
|
||||
|
||||
|
||||
setTaskStats({ completed: completedCount, total: totalCount });
|
||||
|
||||
} catch (err) {
|
||||
console.error('获取任务统计失败', err);
|
||||
setTaskStats({ completed: 12, total: 15 });
|
||||
}
|
||||
};
|
||||
|
||||
// 当前选中设备(切换时才变)
|
||||
const selectedDevice = useMemo(() => {
|
||||
@@ -278,14 +346,21 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
|
||||
const totalMowers = devicesAll?.filter(d => d.productName?.includes('割草机')).length || 0;
|
||||
const activeMowers = devicesAll?.filter(d => d.productName?.includes('割草机') && d.onlineStatus === 1).length || 0;
|
||||
const washDroneStandby = planedevices?.filter(d => d.productName?.includes('清洗') && d.onlineStatus === 1).length || 0;
|
||||
|
||||
|
||||
|
||||
// 今日任务执行统计
|
||||
const completedTasks = taskStats.completed;
|
||||
const totalTasks = taskStats.total;
|
||||
const completionRate = totalTasks > 0 ? Math.round((completedTasks / totalTasks) * 100) : 0;
|
||||
|
||||
return [
|
||||
{ title: '无人机机场状态', icon: <EnvironmentOutlined />, value: `${onlineDrones} / ${totalDrones}`, sub: `可调度 ${onlineDrones} 架`, color: '#1890ff' },
|
||||
{ title: '机器人', icon: <BranchesOutlined />, value: `${totalMowers} 台`, sub: `作业中 ${activeMowers}`, color: '#13c2c2' },
|
||||
{ title: '无人机', icon: <CloudOutlined />, value: `${totalDrones} 架`, sub: `待命 ${washDroneStandby}`, color: '#eb2f96' },
|
||||
{ title: '设备平均电量', icon: <ThunderboltOutlined />, value: '86%', sub: '', color: '#52c41a' },
|
||||
{ title: '今日任务执行', icon: <CheckCircleOutlined />, value: '12 / 15', sub: '完成率 80%', color: '#2f54eb' },
|
||||
{ title: '今日任务执行', icon: <CheckCircleOutlined />, value: `${completedTasks} / ${totalTasks}`, sub: `完成率 ${completionRate}%`, color: '#2f54eb' },
|
||||
];
|
||||
}, [devicesAll, planedevices]);
|
||||
}, [devicesAll, planedevices, persistentDroneData, uavState, taskStats]);
|
||||
|
||||
// 设备调度列表
|
||||
const dynamicScheduleList = useMemo(() => {
|
||||
@@ -343,7 +418,7 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
|
||||
<Content style={{ margin: '0 8', }}>
|
||||
<Row gutter={[8, 8]} style={{ marginBottom: 12, flexWrap: 'wrap' }}>
|
||||
{dynamicTopCards.map((card, idx) => (
|
||||
<Col key={idx} style={{ minWidth: '160px', flex: '1 0 auto' }}>
|
||||
<Col key={idx} style={{ minWidth: '360px', flex: '0 0 auto' }}>
|
||||
<Card bordered={false} style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.05)', height: 90 }} bodyStyle={{ padding: '12px', height: '100%' }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 10, height: '100%' }}>
|
||||
<div style={{ width: 40, height: 40, borderRadius: 8, background: `${card.color}15`, color: card.color, display: 'flex', alignItems: 'center', justifyContent: 'center', fontSize: 'clamp(14px, 1.2vw, 18px)', flexShrink: 0 }}>
|
||||
|
||||
@@ -532,7 +532,6 @@ export default function WayLinePage({ onRefresh }) {
|
||||
if (item.list) combinedList = combinedList.concat(item.list);
|
||||
});
|
||||
}
|
||||
console.log('看板任务列表:', combinedList);
|
||||
setBoardTaskList(combinedList);
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
@@ -27,12 +27,60 @@ const { Text, Title } = Typography;
|
||||
|
||||
// 模拟数据(完全匹配参考图)
|
||||
const overviewCards = [
|
||||
{ title: '本月发电量', value: '138.6', unit: 'MWh', trend: '环比 ↑ +6.2%', color: '#00B42A', bg: '#E8FFEA', icon: <RiseOutlined /> },
|
||||
{ title: 'PR均值', value: '82.8', unit: '%', trend: '环比 ↑ +1.1%', color: '#165DFF', bg: '#E8F3FF', icon: <LineChartOutlined /> },
|
||||
{ title: '运维工单完成率', value: '93.4', unit: '%', trend: '本月累计 126 单', color: '#165DFF', bg: '#E8F3FF', icon: <FileDoneOutlined /> },
|
||||
{ title: '告警闭环率', value: '94.2', unit: '%', trend: '严重告警 8 条', color: '#F53F3F', bg: '#FFF1F0', icon: <BellOutlined /> },
|
||||
{ title: '清洗收益提升', value: '+7.6', unit: '%', trend: '预估增发 12,850 kWh', color: '#00B42A', bg: '#E8FFEA', icon: <ThunderboltOutlined /> },
|
||||
{ title: '自动生成报告', value: '24', unit: '份', trend: '本月累计', color: '#722ED1', bg: '#F9F0FF', icon: <FileTextOutlined /> },
|
||||
{
|
||||
title: '本月发电量',
|
||||
value: '138.6',
|
||||
unit: 'MWh',
|
||||
trend: '环比 ↑ +6.2%',
|
||||
color: '#00B42A',
|
||||
iconBg: '#E8FFEA',
|
||||
icon: <ThunderboltOutlined style={{ color: '#00B42A', fontSize: 24 }} />
|
||||
},
|
||||
{
|
||||
title: 'PR均值',
|
||||
value: '82.8',
|
||||
unit: '%',
|
||||
trend: '环比 ↑ +1.1%',
|
||||
color: '#165DFF',
|
||||
iconBg: '#E8F3FF',
|
||||
icon: <LineChartOutlined style={{ color: '#165DFF', fontSize: 24 }} />
|
||||
},
|
||||
{
|
||||
title: '运维工单完成率',
|
||||
value: '93.4',
|
||||
unit: '%',
|
||||
trend: '本月累计 126 单',
|
||||
color: '#165DFF',
|
||||
iconBg: '#E8F3FF',
|
||||
icon: <CheckCircleOutlined style={{ color: '#165DFF', fontSize: 24 }} />
|
||||
},
|
||||
{
|
||||
title: '告警闭环率',
|
||||
value: '94.2',
|
||||
unit: '%',
|
||||
trend: '严重告警 8 条',
|
||||
color: '#F53F3F',
|
||||
iconBg: '#FFF1F0',
|
||||
icon: <BellOutlined style={{ color: '#F53F3F', fontSize: 24 }} />
|
||||
},
|
||||
{
|
||||
title: '清洗收益提升',
|
||||
value: '+7.6',
|
||||
unit: '%',
|
||||
trend: '预估增发 12,850 kWh',
|
||||
color: '#00B42A',
|
||||
iconBg: '#E8FFEA',
|
||||
icon: <ThunderboltOutlined style={{ color: '#00B42A', fontSize: 24 }} />
|
||||
},
|
||||
{
|
||||
title: '自动生成报告',
|
||||
value: '24',
|
||||
unit: '份',
|
||||
trend: '本月累计',
|
||||
color: '#722ED1',
|
||||
iconBg: '#F9F0FF',
|
||||
icon: <FileTextOutlined style={{ color: '#722ED1', fontSize: 24 }} />
|
||||
},
|
||||
];
|
||||
|
||||
const monthlyPowerData = [
|
||||
@@ -132,11 +180,7 @@ export default function ReportCenterPage() {
|
||||
.report-tabs .ant-tabs-nav {
|
||||
margin-bottom: 8px !important;
|
||||
}
|
||||
.report-tabs .ant-tabs-tab {
|
||||
padding: 2px 4px !important;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.filter-label {
|
||||
font-size: 12px;
|
||||
color: #86909C;
|
||||
@@ -153,7 +197,7 @@ export default function ReportCenterPage() {
|
||||
}
|
||||
`}
|
||||
</style>
|
||||
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 16 }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', marginBottom: 8 }}>
|
||||
<Typography.Title level={4} style={{ margin: '0 32px 0 0', }}>报表中心</Typography.Title>
|
||||
|
||||
{/* 页面头部标签 */}
|
||||
@@ -169,66 +213,52 @@ export default function ReportCenterPage() {
|
||||
|
||||
|
||||
<Row
|
||||
gutter={[8, 8]}
|
||||
gutter={[12, 12]}
|
||||
style={{
|
||||
marginBottom: 8,
|
||||
flexWrap: 'wrap',
|
||||
}}
|
||||
>
|
||||
{overviewCards.map((card, idx) => (
|
||||
<Col key={idx} style={{ minWidth: '168px', flex: '1 0 auto', maxWidth: "250px" }}>
|
||||
<Col key={idx} style={{ minWidth: '180px', flex: '1 0 auto', maxWidth: "240px" }}>
|
||||
<Card
|
||||
bordered={false}
|
||||
bodyStyle={{ padding: '16px' }}
|
||||
style={{
|
||||
borderRadius: 8,
|
||||
height: 120,
|
||||
display: 'flex',
|
||||
flexDirection: 'column',
|
||||
justifyContent: 'center'
|
||||
}}
|
||||
bodyStyle={{ padding: '20px 20px', display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}
|
||||
style={{ borderRadius: 8, boxShadow: '0 2px 8px rgba(0,0,0,0.06)' }}
|
||||
>
|
||||
<Statistic
|
||||
title={
|
||||
<span style={{ fontSize: 14, color: '#666', fontWeight: 500 }}>
|
||||
{card.title}
|
||||
</span>
|
||||
}
|
||||
value={card.value}
|
||||
precision={card.title === 'PR均值' ? 1 : 1}
|
||||
suffix={
|
||||
card.unit && (
|
||||
<span style={{ fontSize: 16, marginLeft: 4 }}>{card.unit}</span>
|
||||
)
|
||||
}
|
||||
valueStyle={{
|
||||
color: card.color,
|
||||
fontSize: 28,
|
||||
fontWeight: 700,
|
||||
marginBottom: 4
|
||||
{/* 左侧文字区域 */}
|
||||
<div style={{ flex: 1, display: 'flex', flexDirection: 'column', alignItems: 'flex-start' }}>
|
||||
<div style={{ fontSize: 14, color: '#86909C', marginBottom: 8, fontWeight: 500 }}>
|
||||
{card.title}
|
||||
</div>
|
||||
<div style={{ fontSize: 28, fontWeight: 700, color: card.color, lineHeight: 1, marginBottom: 8 }}>
|
||||
{card.value}
|
||||
<span style={{ fontSize: 14, fontWeight: 500, marginLeft: 2, color: '#1D2129' }}>{card.unit}</span>
|
||||
</div>
|
||||
{/* 底部环比/备注 */}
|
||||
<div style={{ fontSize: 12, color: '#86909C', fontWeight: 500 }}>
|
||||
{card.trend}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 右侧圆形图标区域 */}
|
||||
|
||||
<div
|
||||
style={{
|
||||
width: 48,
|
||||
height: 48,
|
||||
borderRadius: '50%',
|
||||
backgroundColor: card.iconBg || '#f0f7ff',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
flexShrink: 0,
|
||||
marginLeft: 8
|
||||
}}
|
||||
/>
|
||||
>
|
||||
{card.icon}
|
||||
</div>
|
||||
|
||||
{card.rate && (
|
||||
<div style={{ fontSize: 12, color: '#999', marginTop: 2 }}>
|
||||
环比
|
||||
<span
|
||||
style={{
|
||||
marginLeft: 4,
|
||||
color: card.rateUp ? '#52c41a' : '#ff4d4f',
|
||||
fontWeight: 600
|
||||
}}
|
||||
>
|
||||
{card.rate}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{card.desc && (
|
||||
<div style={{ fontSize: 12, color: '#999', marginTop: 2 }}>
|
||||
{card.desc}
|
||||
</div>
|
||||
)}
|
||||
</Card>
|
||||
</Col>
|
||||
))}
|
||||
|
||||
@@ -450,8 +450,8 @@ const WorkOrderPage = () => {
|
||||
<Card bordered={false} bodyStyle={{ padding: '20px 16px' }} style={cardStyle}>
|
||||
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
|
||||
<div>
|
||||
<div style={{ fontSize: 'clamp(12px, 0.8vw, 13px)', color: '#86909C', marginBottom: 8 }}>{item.title}</div>
|
||||
<div style={{ display: 'flex', alignItems: 'baseline', gap: 6, marginBottom: 8 }}>
|
||||
<div style={{ fontSize: 'clamp(12px, 0.8vw, 13px)', color: '#86909C', marginBottom: 2 }}>{item.title}</div>
|
||||
<div style={{ display: 'flex', alignItems: 'baseline', gap: 6, marginBottom: 2 }}>
|
||||
<div style={{ fontSize: 'clamp(20px, 1.4vw, 24px)', fontWeight: 800, color: '#1D2129' }}>{item.value}</div>
|
||||
{item.unit && <span style={{ fontSize: 13, color: '#1D2129', fontWeight: 600 }}>{item.unit}</span>}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user