航线任务 今日航线计划 完成 执行中任务
This commit is contained in:
@@ -56,7 +56,7 @@ const handleLogoutAndRedirect = () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// 只提示一次
|
// 只提示一次
|
||||||
message.error('登录已过期,请重新登录');
|
message?.error('登录已过期,请重新登录');
|
||||||
|
|
||||||
// 只跳转一次
|
// 只跳转一次
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -84,7 +84,7 @@ api.interceptors.response.use(
|
|||||||
|
|
||||||
// 网络异常
|
// 网络异常
|
||||||
if (!error.response) {
|
if (!error.response) {
|
||||||
message.error('网络异常,请稍后重试');
|
message?.error('网络异常,请稍后重试');
|
||||||
return Promise.reject(error);
|
return Promise.reject(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -188,14 +188,55 @@ export default function WayLinePage({ planedevices }) {
|
|||||||
}, [listDrone]);
|
}, [listDrone]);
|
||||||
|
|
||||||
// 顶部统计
|
// 顶部统计
|
||||||
const topCards = [
|
const [todayCount, setTodayCount] = useState(0);
|
||||||
{ title: '今日航线计划', value: '18', unit: '条', trend: '较昨日 +2', trendColor: '#00B42A', icon: <LayoutGrid size={22} />, color: '#165DFF' },
|
const [yesterdayCount, setYesterdayCount] = useState(0);
|
||||||
{ title: '执行中任务', value: '6', unit: '个', desc: '进行中', icon: <Plane size={22} />, color: '#165DFF' },
|
const [trend, setTrend] = useState('');
|
||||||
{ title: '待审批任务', value: '4', unit: '个', trend: '较昨日 -1', trendColor: '#F53F3F', icon: <Calendar size={22} />, color: '#FF7D00' },
|
const [trendColor, setTrendColor] = useState('');
|
||||||
{ title: '任务完成率', value: '92', unit: '%', trend: '较昨日 +6%', trendColor: '#00B42A', icon: <CheckCircle2 size={22} />, color: '#00B42A' },
|
|
||||||
{ title: 'AI 优化收益', value: '+7.8', unit: '%', trend: '较昨日 +1.2%', trendColor: '#00B42A', icon: <TrendingUp size={22} />, color: '#722ED1' },
|
// 计算今日/昨日任务数量
|
||||||
{ title: '覆盖装备', value: '4 类 / 9 台', unit: '', desc: '全部在线', icon: <Satellite size={22} />, color: '#165DFF' },
|
const calcTodayTaskCount = () => {
|
||||||
];
|
if (!taskList?.length) return;
|
||||||
|
|
||||||
|
const todayStart = dayjs().startOf('day').valueOf();
|
||||||
|
const todayEnd = dayjs().endOf('day').valueOf();
|
||||||
|
const yesterdayStart = dayjs().subtract(1, 'day').startOf('day').valueOf();
|
||||||
|
const yesterdayEnd = dayjs().subtract(1, 'day').endOf('day').valueOf();
|
||||||
|
|
||||||
|
const todayTotal = taskList.filter(t => {
|
||||||
|
const time = dayjs(t.begin_at).valueOf();
|
||||||
|
return time >= todayStart && time <= todayEnd;
|
||||||
|
}).length;
|
||||||
|
|
||||||
|
const yesterdayTotal = taskList.filter(t => {
|
||||||
|
const time = dayjs(t.begin_at).valueOf();
|
||||||
|
return time >= yesterdayStart && time <= yesterdayEnd;
|
||||||
|
}).length;
|
||||||
|
|
||||||
|
const diff = todayTotal - yesterdayTotal;
|
||||||
|
let trendText = '';
|
||||||
|
let color = '#00B42A';
|
||||||
|
|
||||||
|
if (diff > 0) {
|
||||||
|
trendText = `较昨日 +${diff}`;
|
||||||
|
color = '#00B42A';
|
||||||
|
} else if (diff < 0) {
|
||||||
|
trendText = `较昨日 ${diff}`;
|
||||||
|
color = '#F53F3F';
|
||||||
|
} else {
|
||||||
|
trendText = '较昨日 持平';
|
||||||
|
color = '#86909C';
|
||||||
|
}
|
||||||
|
|
||||||
|
setTodayCount(todayTotal);
|
||||||
|
setYesterdayCount(yesterdayTotal);
|
||||||
|
setTrend(trendText);
|
||||||
|
setTrendColor(color);
|
||||||
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
calcTodayTaskCount();
|
||||||
|
}, [taskList]);
|
||||||
|
|
||||||
|
|
||||||
// 获取任务列表数据 【时间戳已改为秒级】
|
// 获取任务列表数据 【时间戳已改为秒级】
|
||||||
const getListTask = async () => {
|
const getListTask = async () => {
|
||||||
@@ -351,6 +392,24 @@ export default function WayLinePage({ planedevices }) {
|
|||||||
};
|
};
|
||||||
const { waitList, runList, finishList } = groupBoardData();
|
const { waitList, runList, finishList } = groupBoardData();
|
||||||
|
|
||||||
|
const topCards = [
|
||||||
|
{
|
||||||
|
title: '今日航线计划',
|
||||||
|
value: todayCount,
|
||||||
|
unit: '条',
|
||||||
|
trend: trend,
|
||||||
|
trendColor: trendColor,
|
||||||
|
icon: <LayoutGrid size={22} />,
|
||||||
|
color: '#165DFF'
|
||||||
|
},
|
||||||
|
{ title: '执行中任务', value: runList.length, unit: '个', desc: '进行中', icon: <Plane size={22} />, color: '#165DFF' },
|
||||||
|
{ title: '待审批任务', value: '4', unit: '个', trend: '较昨日 -1', trendColor: '#F53F3F', icon: <Calendar size={22} />, color: '#FF7D00' },
|
||||||
|
{ title: '任务完成率', value: finishList.length ? Math.round((finishList.length / taskList.length) * 100) : 0, unit: '%', trend: '较昨日 +6%', trendColor: '#00B42A', icon: <CheckCircle2 size={22} />, color: '#00B42A' },
|
||||||
|
{ title: 'AI 优化收益', value: '+7.8', unit: '%', trend: '较昨日 +1.2%', trendColor: '#00B42A', icon: <TrendingUp size={22} />, color: '#722ED1' },
|
||||||
|
{ title: '覆盖装备', value: '4 类 / 9 台', unit: '', desc: '全部在线', icon: <Satellite size={22} />, color: '#165DFF' },
|
||||||
|
];
|
||||||
|
|
||||||
|
|
||||||
// 指令下发逻辑
|
// 指令下发逻辑
|
||||||
const sendFlightCommand = async (command: 'return_home' | 'return_home_cancel' | 'flighttask_pause' | 'flighttask_recovery') => {
|
const sendFlightCommand = async (command: 'return_home' | 'return_home_cancel' | 'flighttask_pause' | 'flighttask_recovery') => {
|
||||||
if (!listDrone?.device_sn) {
|
if (!listDrone?.device_sn) {
|
||||||
@@ -428,7 +487,7 @@ export default function WayLinePage({ planedevices }) {
|
|||||||
{React.cloneElement(item.icon, { size: 18 })}
|
{React.cloneElement(item.icon, { size: 18 })}
|
||||||
</div>
|
</div>
|
||||||
<div style={{ flex: 1 }}>
|
<div style={{ flex: 1 }}>
|
||||||
<div style={{ fontSize: 10, color: '#86909C' }}>{item.title}</div>
|
<div style={{ fontSize: 13, color: '#86909C' }}>{item.title}</div>
|
||||||
<div style={{ display: 'flex', alignItems: 'baseline', gap: 4 }}>
|
<div style={{ display: 'flex', alignItems: 'baseline', gap: 4 }}>
|
||||||
<span style={{ fontSize: 'clamp(16px, 1vw, 20px)', fontWeight: 700, color: '#1D2129' }}>{item.value}</span>
|
<span style={{ fontSize: 'clamp(16px, 1vw, 20px)', fontWeight: 700, color: '#1D2129' }}>{item.value}</span>
|
||||||
<span style={{ fontSize: 9, color: '#4E5969' }}>{item.unit}</span>
|
<span style={{ fontSize: 9, color: '#4E5969' }}>{item.unit}</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user