From 1d6165c86d75f4f9436490618377e1fb2004bf9b Mon Sep 17 00:00:00 2001 From: mmc <1556375442@qq.com> Date: Mon, 25 May 2026 13:21:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=91=E5=AE=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../SystemSetting/DeviceManagement.tsx | 133 +++++++++++++++--- 1 file changed, 112 insertions(+), 21 deletions(-) diff --git a/src/components/SystemSetting/DeviceManagement.tsx b/src/components/SystemSetting/DeviceManagement.tsx index b15da1e..a71550c 100644 --- a/src/components/SystemSetting/DeviceManagement.tsx +++ b/src/components/SystemSetting/DeviceManagement.tsx @@ -28,6 +28,9 @@ import { } from '@ant-design/icons'; import SerialNumGenerate from "./SerialNumGenerate" import { getPlaneDeviceList, bindDrone, unbindDrone } from '@/api/device'; +import { getOrgList } from '@/api/organization/index.tsx'; +import { getSiteByOrgId } from '@/api/stationManage/index'; +import { getUser } from '@/api/user/index'; import { useSelector } from 'react-redux'; import { RootState } from '@/src/store'; import utils from '@/lib/utils'; @@ -71,12 +74,17 @@ export default function DeviceManagementPage() { const [bindForm] = Form.useForm(); const [selectedDroneKeys, setSelectedDroneKeys] = useState([]); + // 下拉数据状态 + const [orgOptions, setOrgOptions] = useState([]); + const [siteOptions, setSiteOptions] = useState([]); + const [userOptions, setUserOptions] = useState([]); + const fetchDroneList = async () => { setLoading(true); try { const res: any = await getPlaneDeviceList(); - if (res.code == 200) { - setDroneList(res?.data?.detail || []); + if (res.code === 200) { + setDroneList(res.data?.detail || res.data || []); } } catch (err) { utils.message.error('获取无人机列表失败'); @@ -85,12 +93,62 @@ export default function DeviceManagementPage() { } }; + // 获取组织列表 + const fetchOrgs = async () => { + try { + const res: any = await getOrgList({}); + if (res.code === 200) { + setOrgOptions(res.rows || []); + } + } catch (err) { + console.error('获取组织列表失败', err); + } + }; + + // 根据组织获取场站 + const fetchSites = async (orgId) => { + setSiteOptions([]); + try { + const res: any = await getSiteByOrgId({ id: orgId }); + if (res.code === 200) { + setSiteOptions(res.data || []); + } + } catch (err) { + console.error('获取场站列表失败', err); + } + }; + + // 根据场站获取用户 + const fetchUsers = async (siteId) => { + try { + const res: any = await getUser({ siteId, pageNum: 1, pageSize: 1000 }); + if (res.code === 200) { + setUserOptions(res.rows || []); + } + } catch (err) { + console.error('获取用户列表失败', err); + } + }; + useEffect(() => { if (activeTab === 'drone') { fetchDroneList(); } }, [activeTab]); + // 打开绑定弹窗 + const openBindModal = () => { + if (selectedDroneKeys.length === 0) { + return utils.message.warning('请先在列表中选中需要绑定的无人机'); + } + setBindModalVisible(true); + fetchOrgs(); + bindForm.setFieldsValue({ + sns: selectedDroneKeys.join(', '), + userId: userInfo?.userId + }); + }; + const handleBind = async (values) => { try { const payload = { @@ -265,7 +323,7 @@ export default function DeviceManagementPage() { <>
- + @@ -287,28 +345,61 @@ export default function DeviceManagementPage() { setBindModalVisible(false)} + onCancel={() => { + setBindModalVisible(false); + setSiteOptions([]); + setUserOptions([]); + }} onOk={() => bindForm.submit()} width={500} > -
- - + + + - - - - - - - - - - - - - - + + + + + + + + + + +