From ce097f78d63562d5ac35d88674ca48bf6584b5a5 Mon Sep 17 00:00:00 2001
From: mmc <1556375442@qq.com>
Date: Tue, 26 May 2026 13:44:59 +0800
Subject: [PATCH] =?UTF-8?q?=E6=99=BA=E8=83=BD=E8=A3=85=E5=A4=87=E7=BB=91?=
=?UTF-8?q?=E5=AE=9A=E8=A7=A3=E7=BB=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/api/device.ts | 28 ++
.../SystemSetting/DeviceManagement.tsx | 292 +++++++++++++++++-
2 files changed, 303 insertions(+), 17 deletions(-)
diff --git a/src/api/device.ts b/src/api/device.ts
index 4fdc48a..33bc6be 100644
--- a/src/api/device.ts
+++ b/src/api/device.ts
@@ -165,6 +165,33 @@ export function unbindDrone(data) {
})
}
+// 获取所有智能装备列表
+export function getSmartDeviceList(params) {
+ return request({
+ url: '/iot/device/list',
+ method: 'get',
+ params
+ })
+}
+
+// 绑定智能装备
+export function bindSmartDevice(data) {
+ return request({
+ url: '/iot/device/bind',
+ method: 'post',
+ data
+ })
+}
+
+// 解绑智能装备
+export function unbindSmartDevice(data) {
+ return request({
+ url: '/iot/device/unbind',
+ method: 'post',
+ data
+ })
+}
+
// 直播心跳
export function postLiveHeartbeat(data) {
@@ -177,3 +204,4 @@ export function postLiveHeartbeat(data) {
+
diff --git a/src/components/SystemSetting/DeviceManagement.tsx b/src/components/SystemSetting/DeviceManagement.tsx
index 1c44e8e..472573b 100644
--- a/src/components/SystemSetting/DeviceManagement.tsx
+++ b/src/components/SystemSetting/DeviceManagement.tsx
@@ -17,7 +17,10 @@ import {
Row,
Col,
App,
+ Typography,
} from 'antd';
+
+const { Text } = Typography;
import {
SearchOutlined,
ReloadOutlined,
@@ -28,7 +31,7 @@ import {
DisconnectOutlined,
} from '@ant-design/icons';
import SerialNumGenerate from "./SerialNumGenerate"
-import { getPlaneDeviceList, bindDrone, unbindDrone } from '@/api/device';
+import { getPlaneDeviceList, bindDrone, unbindDrone, getSmartDeviceList, bindSmartDevice, unbindSmartDevice } from '@/api/device';
import { getOrgList } from '@/api/organization/index';
import { getSiteByOrgId, getStationList } from '@/api/stationManage/index';
import { getUser } from '@/api/user/index';
@@ -77,6 +80,18 @@ export default function DeviceManagementPage() {
const [bindForm] = Form.useForm();
const [selectedDroneKeys, setSelectedDroneKeys] = useState([]);
+ // 智能装备相关状态
+ const [smartList, setSmartList] = useState([]);
+ const [selectedSmartKeys, setSelectedSmartKeys] = useState([]);
+ const [bindSmartModalVisible, setBindSmartModalVisible] = useState(false);
+ const [bindSmartForm] = Form.useForm();
+ const [smartParams, setSmartParams] = useState({
+ pageNum: 1,
+ pageSize: 10,
+ });
+ const [smartTotal, setSmartTotal] = useState(0);
+
+
// 下拉数据状态
const [orgOptions, setOrgOptions] = useState([]);
const [siteOptions, setSiteOptions] = useState([]);
@@ -101,6 +116,22 @@ export default function DeviceManagementPage() {
}
};
+ const fetchSmartList = async () => {
+ setLoading(true);
+ try {
+ const res: any = await getSmartDeviceList(smartParams);
+ if (res.code === 200) {
+ setSmartList(res.rows || []);
+ setSmartTotal(res.total || res.rows.length); // 👈 关键:把总数存起来
+
+ }
+ } catch (err) {
+ utils.message.error('获取智能装备列表失败');
+ } finally {
+ setLoading(false);
+ }
+ };
+
// 获取组织列表
const fetchOrgs = async () => {
try {
@@ -156,12 +187,12 @@ export default function DeviceManagementPage() {
};
useEffect(() => {
- if (activeTab === 'drone') {
- fetchDroneList();
- fetchAllDataForMapping(); // 进入无人机管理时获取全量匹配数据
+ if (activeTab === 'drone' || activeTab === 'smart') {
+ fetchAllDataForMapping();
+ if (activeTab === 'drone') fetchDroneList();
+ if (activeTab === 'smart') fetchSmartList();
}
- }, [activeTab]);
-
+ }, [activeTab, smartParams]);
// 打开绑定弹窗
const openBindModal = async () => {
if (selectedDroneKeys.length === 0) {
@@ -182,6 +213,25 @@ export default function DeviceManagementPage() {
setUserOptions([]);
};
+ // 打开智能装备绑定弹窗
+ const openBindSmartModal = async () => {
+ if (selectedSmartKeys.length === 0) {
+ return utils.message.warning('请先在列表中选中需要绑定的智能装备');
+ }
+
+ setBindSmartModalVisible(true);
+ await fetchOrgs();
+
+ bindSmartForm.setFieldsValue({
+ deviceIds: selectedSmartKeys.join(', '),
+ orgId: undefined,
+ siteId: undefined,
+ userId: undefined,
+ });
+ setSiteOptions([]);
+ setUserOptions([]);
+ };
+
const handleBind = async (values) => {
try {
const payload = {
@@ -205,6 +255,110 @@ export default function DeviceManagementPage() {
}
};
+ const handleBindSmart = async (values) => {
+ try {
+ const payload = {
+ siteId: values.siteId,
+ orgId: values.orgId,
+ userId: values.userId,
+ deviceIds: values.deviceIds.split(',').map(s => s.trim()),
+ };
+ const res: any = await bindSmartDevice(payload);
+ if (res.code === 200) {
+ utils.message.success('绑定成功');
+ setBindSmartModalVisible(false);
+ bindSmartForm.resetFields();
+ fetchSmartList();
+ } else {
+ utils.message.error(res.msg || '绑定失败');
+ }
+ } catch (err) {
+ utils.message.error('操作异常');
+ }
+ };
+
+ const handleUnbindSmart = (deviceIds, type) => {
+ const validIds = (deviceIds || []).filter(id => id);
+ if (validIds.length === 0) {
+ return utils.message.warning('未选择有效设备,无法解绑');
+ }
+
+ const typeText = { 1: '人员', 2: '场站', 3: '组织' }[type];
+
+ modal.confirm({
+ title: '确认解绑',
+ content: `确定要为选中的智能装备清除${typeText}绑定吗?`,
+ okText: '确定',
+ cancelText: '取消',
+ onOk: async () => {
+ try {
+ const res: any = await unbindSmartDevice({ deviceIds: validIds, type });
+ if (res.code === 200) {
+ utils.message.success('解绑成功');
+ fetchSmartList();
+ setSelectedSmartKeys([]);
+ } else {
+ utils.message.error(res.msg || '解绑失败');
+ }
+ } catch (err) {
+ utils.message.error('操作异常');
+ }
+ }
+ });
+ };
+
+ const smartColumns = [
+ { title: '设备名称', width: 150, dataIndex: 'deviceAlias', key: 'name' },
+ { title: '设备码', width: 280, dataIndex: 'serialNumber', key: 'sn' },
+ {
+ title: '所属组织',
+ width: 150,
+ key: 'orgName',
+ render: (_, record) => {
+ const org = allOrgOptions.find(o => (o.orgId || o.id) == record.orgId);
+ return org ? (org.orgName || org.name) :