2026-05-11 10:47:51 +08:00
|
|
|
|
import React, { useState, useEffect } from 'react';
|
|
|
|
|
|
import { Layout, Typography, Menu } from 'antd';
|
|
|
|
|
|
import { AppstoreOutlined, SettingOutlined } from '@ant-design/icons';
|
|
|
|
|
|
import DeviceOverviewPage from '../components/devices/DeviceOverviewPage';
|
|
|
|
|
|
import { getDeviceListApi, getPlaneDeviceList } from '../api/device';
|
|
|
|
|
|
import { useSelector } from 'react-redux';
|
|
|
|
|
|
import { RootState } from '../store';
|
|
|
|
|
|
|
|
|
|
|
|
const { Header, Content } = Layout;
|
|
|
|
|
|
const { Text } = Typography;
|
|
|
|
|
|
|
|
|
|
|
|
// 设置状态页面(你后续自己填内容)
|
|
|
|
|
|
const DeviceStatusSettingPage = () => (
|
|
|
|
|
|
<div style={{ padding: 20 }}>
|
|
|
|
|
|
<h2>设置状态页面(/devices/status)</h2>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
export default function DeviceIndexPage() {
|
|
|
|
|
|
const [activeTab, setActiveTab] = useState('overview');
|
|
|
|
|
|
const { userInfo } = useSelector((state: RootState) => state.user);
|
|
|
|
|
|
const [devices, setDevices] = useState([]);
|
|
|
|
|
|
const [planedevices, setPlaneDevices] = useState([]);
|
|
|
|
|
|
const [devicesAll, setDevicesAll] = useState([]);
|
|
|
|
|
|
|
|
|
|
|
|
const tabs = [
|
|
|
|
|
|
{ key: 'overview', label: '装备总览', icon: <AppstoreOutlined />, path: '/devices/overview' },
|
|
|
|
|
|
{ key: 'status', label: '设置状态', icon: <SettingOutlined />, path: '/devices/status' },
|
2026-04-21 08:51:57 +08:00
|
|
|
|
];
|
2026-04-17 17:20:41 +08:00
|
|
|
|
|
2026-05-11 10:47:51 +08:00
|
|
|
|
const renderContent = () => {
|
|
|
|
|
|
if (activeTab === 'overview') return <DeviceOverviewPage devices={devices} planedevices={planedevices} devicesAll={devicesAll} />;
|
|
|
|
|
|
if (activeTab === 'status') return <DeviceStatusSettingPage />;
|
|
|
|
|
|
return null;
|
|
|
|
|
|
};
|
|
|
|
|
|
const getPlaneList = () => {
|
|
|
|
|
|
getPlaneDeviceList().then(res => {
|
|
|
|
|
|
if (res?.code == 200) {
|
|
|
|
|
|
const drones = res?.data?.detail;
|
|
|
|
|
|
setPlaneDevices(drones);
|
|
|
|
|
|
setDevicesAll([...devices, ...drones]);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const getDevice = () => {
|
|
|
|
|
|
const data = { tenantName: userInfo.username, deptId: 1 };
|
|
|
|
|
|
getDeviceListApi(data).then(res => {
|
|
|
|
|
|
if (res?.code == 200 && res?.data?.length) {
|
|
|
|
|
|
setDevices(res.data);
|
|
|
|
|
|
setDevicesAll([...planedevices, ...res.data.data]);
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
getDevice();
|
|
|
|
|
|
getPlaneList();
|
|
|
|
|
|
}, []);
|
2026-04-17 17:20:41 +08:00
|
|
|
|
|
|
|
|
|
|
|
2026-05-11 10:47:51 +08:00
|
|
|
|
return (
|
|
|
|
|
|
<Layout style={{ minHeight: '100vh', background: '#fff', overflow: 'hidden' }}>
|
|
|
|
|
|
<div style={{ display: 'flex', paddingBottom: "12px" }}>
|
|
|
|
|
|
<div style={{ padding: '20px 24px 0' }}>
|
|
|
|
|
|
<Typography.Title level={4} style={{ margin: 0 }}>装备控制</Typography.Title>
|
|
|
|
|
|
<Text type="secondary"> 装备总览、状态监控与参数配置</Text>
|
2026-05-09 16:44:39 +08:00
|
|
|
|
</div>
|
|
|
|
|
|
|
2026-05-11 10:47:51 +08:00
|
|
|
|
<Header style={{ background: '#fff', padding: 0, borderBottom: '1px solid #f0f0f0', position: 'sticky', top: 0, zIndex: 10 }}>
|
|
|
|
|
|
<Menu
|
|
|
|
|
|
mode="horizontal"
|
|
|
|
|
|
selectedKeys={[activeTab]}
|
|
|
|
|
|
onClick={({ key }) => setActiveTab(key)}
|
|
|
|
|
|
items={tabs}
|
|
|
|
|
|
style={{ border: 0, height: 64, lineHeight: '64px' }}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Header>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<Content style={{
|
|
|
|
|
|
maxHeight: 'calc(100vh - 64px)',
|
|
|
|
|
|
overflowY: 'auto',
|
|
|
|
|
|
background: '#f5f7fa',
|
|
|
|
|
|
padding: '20px',
|
|
|
|
|
|
scrollbarWidth: "none"
|
|
|
|
|
|
}}>
|
|
|
|
|
|
{renderContent()}
|
2026-05-09 16:44:39 +08:00
|
|
|
|
</Content>
|
|
|
|
|
|
</Layout>
|
2026-04-21 08:51:57 +08:00
|
|
|
|
);
|
2026-04-17 17:20:41 +08:00
|
|
|
|
}
|