根据二级路由 优化控制状态界面
This commit is contained in:
@@ -53,7 +53,7 @@ const logs = [
|
||||
{ time: '10:05:22', device: 'RBT-01', type: '事件', desc: '电量较低,建议回充', level: '低电量' },
|
||||
];
|
||||
|
||||
export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceSelect }) {
|
||||
export default function DeviceOverviewPage() {
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
const { stationId } = useSelector((state: RootState) => state.station);
|
||||
|
||||
@@ -68,6 +68,7 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
|
||||
const [devicesAll, setDevicesAll] = useState([]);
|
||||
const [taskStats, setTaskStats] = useState({ completed: 12, total: 15 });
|
||||
const [deviceStatistics, setDeviceStatistics] = useState(null);
|
||||
const [currentSelectedRobot, setCurrentSelectedRobot] = useState(null);
|
||||
|
||||
// 编辑机器人弹窗相关
|
||||
const [editRobotModalOpen, setEditRobotModalOpen] = useState(false);
|
||||
@@ -115,6 +116,7 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
|
||||
console.error('数据请求失败', err);
|
||||
}
|
||||
};
|
||||
const onViewStatus = (sn) => { }
|
||||
|
||||
|
||||
// 打开编辑弹窗
|
||||
@@ -233,9 +235,9 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
|
||||
|
||||
// 当前选中设备(切换时才变)
|
||||
const selectedDevice = useMemo(() => {
|
||||
const sn = selectedSn || (devicesAll?.[0]?.device_sn || devicesAll?.[0]?.serialNumber);
|
||||
const sn = currentSelectedRobot || (devicesAll?.[0]?.device_sn || devicesAll?.[0]?.serialNumber);
|
||||
return devicesAll?.find(item => (item.device_sn || item.serialNumber) === sn) || null;
|
||||
}, [devicesAll, selectedSn]);
|
||||
}, [devicesAll, currentSelectedRobot]);
|
||||
|
||||
const isUAV = !!selectedDevice?.gateway_sn;
|
||||
useEffect(() => {
|
||||
@@ -510,7 +512,7 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
|
||||
const getVal = (val) => val == "no_rain" ? "无" : (val || '-');
|
||||
|
||||
const handleDeviceChange = (id) => {
|
||||
if (onDeviceSelect) onDeviceSelect(id);
|
||||
setCurrentSelectedRobot(id);
|
||||
};
|
||||
|
||||
// 获取无人机状态
|
||||
@@ -646,18 +648,19 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
|
||||
{
|
||||
title: '操作',
|
||||
key: 'action',
|
||||
width: 80,
|
||||
width: 120,
|
||||
//fixed: 'right',
|
||||
render: (_, record) => (
|
||||
<Space size={4}>
|
||||
{/* 编辑按钮绑定弹窗 */}
|
||||
|
||||
<Button
|
||||
size="small"
|
||||
type="text"
|
||||
icon={<EditOutlined />}
|
||||
onClick={() => openEditRobotModal(record)}
|
||||
title="编辑"
|
||||
/>
|
||||
<Button size="small" type="text" icon={<SettingOutlined />} />
|
||||
<Button size="small" type="text" icon={<SettingOutlined />} title="设置" />
|
||||
</Space>
|
||||
)
|
||||
}]}
|
||||
@@ -718,7 +721,7 @@ export default function DeviceOverviewPage({ onViewStatus, selectedSn, onDeviceS
|
||||
<Button
|
||||
type="primary" size="small" ghost icon={<InfoCircleOutlined />}
|
||||
style={{ borderRadius: 4, fontSize: 11, marginLeft: 'auto' }}
|
||||
onClick={() => onViewStatus && onViewStatus(selectedDevice.device_sn || selectedDevice.serialNumber)}
|
||||
onClick={() => onViewStatus(selectedDevice.device_sn || selectedDevice.serialNumber)}
|
||||
>详情</Button>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user