根据场站选择无人机成功

This commit is contained in:
mmc
2026-05-25 15:26:28 +08:00
parent 5c02139117
commit 59f6b1e763
4 changed files with 17 additions and 6 deletions

View File

@@ -3,7 +3,7 @@ import { Layout, Typography, Menu, Tabs } from 'antd';
import { AimOutlined, AppstoreOutlined, SettingOutlined } from '@ant-design/icons';
import DeviceOverviewPage from '../components/devices/DeviceOverviewPage';
import DeviceStatusPage from '../components/devices/DeviceStatusPage';
import { getDeviceListApi, getPlaneDeviceList } from '../api/device';
import { getDeviceListApi, getSiteUAVList } from '../api/device';
import { useSelector } from 'react-redux';
import { RootState } from '../store';
import WayLinePage from '../components/devices/WayLinePage';
@@ -22,6 +22,7 @@ export default function DeviceIndexPage() {
const [activeTab, setActiveTab] = useState('overview');
const [selectedSn, setSelectedSn] = useState(null);
const { userInfo } = useSelector((state: RootState) => state.user);
const { stationId } = useSelector((state: RootState) => state.station);
const [devices, setDevices] = useState([]);
const [planedevices, setPlaneDevices] = useState([]);
const [devicesAll, setDevicesAll] = useState([]);
@@ -34,13 +35,13 @@ export default function DeviceIndexPage() {
// 👇 核心:给无人机补全 lastRunningStatus + type: 'plane'
const fetchAllData = async () => {
if (!userInfo?.username) return;
if (!userInfo?.username || !stationId) return;
try {
// 1. 同时发请求
const [deviceRes, planeRes] = await Promise.all([
getDeviceListApi({ tenantName: userInfo.username, deptId: 1 }),
getPlaneDeviceList(),
getSiteUAVList(stationId),
]);
// 2. 处理普通设备
@@ -84,7 +85,7 @@ export default function DeviceIndexPage() {
useEffect(() => {
fetchAllData();
}, [userInfo]);
}, [userInfo, stationId]);
const handleViewStatus = (sn) => {
setSelectedSn(sn);