在线面板数据优化 创建并执行成功
This commit is contained in:
@@ -32,6 +32,7 @@ import { useSelector } from 'react-redux';
|
||||
import { RootState } from '@/src/store';
|
||||
import envConfig from '../../../env';
|
||||
import DeviceController from './DeviceController';
|
||||
import { getSiteByOrgId } from '@/src/api/stationManage';
|
||||
|
||||
const { Text, Title } = Typography;
|
||||
const { RangePicker } = DatePicker;
|
||||
@@ -39,6 +40,7 @@ const { RangePicker } = DatePicker;
|
||||
export default function RobotTaskPage() {
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
const { stationId } = useSelector((state: RootState) => state.station);
|
||||
const [excuteStatus, setExcuteStatus] = useState("stop"); //"stop" "running" "pause"
|
||||
|
||||
const fontSmall = 'clamp(10px, 0.7vw, 11px)';
|
||||
const fontNormal = 'clamp(12px, 0.75vw, 13px)';
|
||||
@@ -62,10 +64,11 @@ export default function RobotTaskPage() {
|
||||
const controller = new DeviceController(userInfo, messageApi);
|
||||
controllerRef.current = controller;
|
||||
return () => {
|
||||
controllerRef.current?.destroy();
|
||||
if (controllerRef.current) {
|
||||
controllerRef.current.destroy?.();
|
||||
}
|
||||
controllerRef.current = null;
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
}, [])
|
||||
|
||||
@@ -97,7 +100,7 @@ export default function RobotTaskPage() {
|
||||
if (!stationId) return;
|
||||
|
||||
try {
|
||||
const deviceRes = await getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1 });
|
||||
const deviceRes = await getSiteDevice({ siteId: stationId, pageSize: 9999, pageNum: 1, orgId: userInfo.orgId });
|
||||
const devData = deviceRes?.code === 200 ? (deviceRes.rows || []) : [];
|
||||
setDevices(devData);
|
||||
} catch (err) {
|
||||
@@ -144,7 +147,6 @@ export default function RobotTaskPage() {
|
||||
}
|
||||
};
|
||||
useEffect(() => {
|
||||
console.log('selectedPathWork changed:', selectedPathWork);
|
||||
|
||||
try {
|
||||
// 1. 没有数据直接清空
|
||||
@@ -154,7 +156,7 @@ export default function RobotTaskPage() {
|
||||
}
|
||||
|
||||
// 2. 安全解析 JSON
|
||||
const data = JSON.parse(selectedPathWork?.jsonData);
|
||||
const data = selectedPathWork?.jsonData;
|
||||
const path = data?.path || [];
|
||||
|
||||
// 3. 空路径提示
|
||||
@@ -208,7 +210,7 @@ export default function RobotTaskPage() {
|
||||
let hasPathPoints = false;
|
||||
try {
|
||||
if (route.jsonData) {
|
||||
const data = JSON.parse(route.jsonData);
|
||||
const data = route.jsonData;
|
||||
hasPathPoints = data.path && data.path.length > 0;
|
||||
}
|
||||
} catch (err) {
|
||||
@@ -236,7 +238,8 @@ export default function RobotTaskPage() {
|
||||
const params = {
|
||||
deviceId: selectedRobotForExecute.serialNumber,
|
||||
routeId: selectedRouteForExecute.id,
|
||||
siteId: stationId
|
||||
siteId: stationId,
|
||||
...(userInfo?.orgId ? { orgId: userInfo.orgId } : {}),
|
||||
};
|
||||
|
||||
console.log('执行任务参数:', params);
|
||||
@@ -246,8 +249,8 @@ export default function RobotTaskPage() {
|
||||
utils.message.success('任务执行成功');
|
||||
setExecuteModalVisible(false);
|
||||
setExecutingRobot(selectedRobotForExecute);
|
||||
fetchTaskList(); // 刷新任务列表
|
||||
controllerRef.current?.connect(selectedRobotForExecute);
|
||||
//fetchTaskList(); // 刷新任务列表
|
||||
controllerRef.current?.connectDevice(selectedRobotForExecute);
|
||||
} else {
|
||||
utils.message.error(res.msg || '任务执行失败');
|
||||
}
|
||||
@@ -414,8 +417,14 @@ export default function RobotTaskPage() {
|
||||
{ title: '累计作业里程', value: '12.5', unit: 'km', trend: '较昨日 +1.2', trendColor: '#00B42A', icon: <TrendingUp size={22} />, color: '#722ED1' },
|
||||
{ title: '任务完成率', value: taskList.length ? Math.round((finishList.length / taskList.length) * 100) : 0, unit: '%', trend: '较昨日 +5%', trendColor: '#00B42A', icon: <CheckCircle2 size={22} />, color: '#00B42A' },
|
||||
{ title: '异常告警', value: '2', unit: '次', trend: '较昨日 -1', trendColor: '#00B42A', icon: <AlertCircle size={22} />, color: '#F53F3F' },
|
||||
{ title: '在线率', value: '98', unit: '%', desc: '良好', icon: <Satellite size={22} />, color: '#165DFF' },
|
||||
];
|
||||
{
|
||||
title: '在线率',
|
||||
value: `${devices?.length ? Math.round((devices.filter(d => d.onlineStatus == 1).length / devices.length) * 100) : 0}`,
|
||||
unit: '%',
|
||||
desc: '良好',
|
||||
icon: <Satellite size={22} />,
|
||||
color: '#165DFF'
|
||||
}];
|
||||
|
||||
return (
|
||||
<div className="normal-spacing" style={{ background: '#f5f7fa', minHeight: '100vh', padding: '0px', paddingTop: 0 }}>
|
||||
|
||||
Reference in New Issue
Block a user