{
- setParamModalVisible(false);
- setCurrentParamDevice(null);
- }}
- onSuccess={() => {
- }}
- />
-
-
-
-
- >
- ) : activeTab === 'drone' ? (
- <>
- {/* 无人机搜索栏 */}
-
- setDroneParams({ ...droneParams, sn: e.target.value })}
- />
-
- } onClick={() => setDroneParams({ pageNum: 1, pageSize: 10, sn: '', status: '' })}>重置
-
- } onClick={openBindModal}>绑定无人机
-
-
-
-
-
-
-
`共 ${t} 条`,
- onChange: (page, pageSize) => {
- setDroneParams({ ...droneParams, pageNum: page, pageSize });
- },
- }}
- scroll={{ y: 'auto', x: '700px' }}
- />
-
-
- {
- setBindModalVisible(false);
- setSiteOptions([]);
- setUserOptions([]);
- bindForm.resetFields();
- }}
- onOk={() => bindForm.submit()}
- width={500}
- >
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- >
- ) : (
- <>
-
-
-
-
-
- } onClick={handleSearch}>查询
-
-
- } onClick={handleReset}>重置
-
-
- } onClick={handleAdd}>新增
-
-
-
- `共 ${total} 条`,
- }}
- />
- >
- )
- }
+ {renderTabContent()}
);
}
diff --git a/src/components/SystemSetting/DroneManagement.tsx b/src/components/SystemSetting/DroneManagement.tsx
new file mode 100644
index 0000000..05e7b0b
--- /dev/null
+++ b/src/components/SystemSetting/DroneManagement.tsx
@@ -0,0 +1,456 @@
+import React, { useState, useEffect } from 'react';
+import {
+ Table,
+ Input,
+ Button,
+ Form,
+ Select,
+ Space,
+ Tag,
+ Modal,
+ Checkbox,
+ Tooltip,
+ Typography,
+ App,
+} from 'antd';
+const { Text } = Typography;
+import {
+ ReloadOutlined,
+ LinkOutlined,
+ DisconnectOutlined,
+} from '@ant-design/icons';
+
+import {
+ getPlaneDeviceList,
+ bindDrone,
+ unbindDrone,
+} from '@/api/device';
+import { getOrgList } from '@/api/organization/index';
+import { getSiteByOrgId, getStationList } 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';
+
+interface DroneManagementProps {
+ allOrgOptions: any[];
+ allSiteOptions: any[];
+ allUserOptions: any[];
+ onAllDataNeedRefresh?: () => void;
+}
+
+export default function DroneManagement({
+ allOrgOptions,
+ allSiteOptions,
+ allUserOptions,
+ onAllDataNeedRefresh,
+}: DroneManagementProps) {
+ const { modal } = App.useApp();
+ const { userInfo } = useSelector((state: RootState) => state.user);
+ const { stationId, currentStation } = useSelector((state: RootState) => state.station);
+
+ const [loading, setLoading] = useState(false);
+ const [droneList, setDroneList] = useState([]);
+ const [bindModalVisible, setBindModalVisible] = useState(false);
+ const [bindForm] = Form.useForm();
+ const [selectedDroneKeys, setSelectedDroneKeys] = useState([]);
+
+ const [droneParams, setDroneParams] = useState({
+ pageNum: 1,
+ pageSize: 20,
+ sn: '',
+ status: ''
+ });
+ const [droneTotal, setDroneTotal] = useState(0);
+
+ const [droneOrgOptions, setDroneOrgOptions] = useState([]);
+ const [droneSiteOptions, setDroneSiteOptions] = useState([]);
+ const [droneUserOptions, setDroneUserOptions] = useState([]);
+
+ const isAdmin = userInfo?.roleKey === 'admin';
+ const isManager = userInfo?.roleKey === 'manager' || userInfo?.roleKey === 'Manager';
+ const orgFieldDisabled = !isAdmin;
+ const siteFieldDisabled = !(isAdmin || isManager);
+ const userFieldDisabled = false;
+
+ const defaultOrgId = currentStation?.orgId || userInfo?.orgId;
+ const defaultSiteId = stationId || currentStation?.siteId || currentStation?.id;
+ const defaultUserId = userInfo?.userId;
+
+ const fetchDroneList = async () => {
+ setLoading(true);
+ try {
+ const res = await getPlaneDeviceList(droneParams);
+ if (res.code === 200) {
+ setDroneList(res.rows || []);
+ setDroneTotal(res.total || res.rows?.length || 0);
+ }
+ } catch (err) {
+ utils.message.error('获取无人机列表失败');
+ } finally {
+ setLoading(false);
+ }
+ };
+
+ const fetchOrgs = async () => {
+ try {
+ const res = await getOrgList({});
+ if (res.code === 200) {
+ setDroneOrgOptions(res.rows || []);
+ }
+ return res;
+ } catch (err) {
+ console.error('获取组织列表失败', err);
+ return null;
+ }
+ };
+
+ const fetchSites = async (orgId) => {
+ try {
+ const res = await getSiteByOrgId({ id: orgId });
+ if (res.code === 200) {
+ setDroneSiteOptions(res.data || []);
+ }
+ return res;
+ } catch (err) {
+ console.error(err);
+ return null;
+ }
+ };
+
+ const fetchUsers = async (siteId) => {
+ try {
+ const res = await getUser({
+ siteId,
+ pageNum: 1,
+ pageSize: 1000
+ });
+ if (res.code === 200) {
+ setDroneUserOptions(res.rows || []);
+ }
+ return res;
+ } catch (err) {
+ console.error(err);
+ return null;
+ }
+ };
+
+ useEffect(() => {
+ fetchDroneList();
+ }, [droneParams]);
+
+ const openBindModal = async () => {
+ if (!selectedDroneKeys.length) {
+ return utils.message.warning('请先在列表中选中需要绑定的无人机');
+ }
+ bindForm.resetFields();
+ setBindModalVisible(true);
+ setDroneOrgOptions([]);
+ setDroneSiteOptions([]);
+ setDroneUserOptions([]);
+ };
+
+ useEffect(() => {
+ if (!bindModalVisible) {
+ bindForm.resetFields();
+ return;
+ }
+ const fetchAndSetForm = async () => {
+ const orgRes = await fetchOrgs();
+ const orgList = orgRes?.code === 200 ? (orgRes?.rows || []) : [];
+ setDroneOrgOptions(orgList);
+
+ const finalOrgId = defaultOrgId && orgList.some(o => (o.id || o.orgId) == defaultOrgId)
+ ? defaultOrgId
+ : (orgList[0]?.id || orgList[0]?.orgId);
+
+ let siteList = [];
+ if (finalOrgId) {
+ const siteRes = await fetchSites(finalOrgId);
+ siteList = siteRes?.code === 200 ? (siteRes?.data || []) : [];
+ }
+ setDroneSiteOptions(siteList);
+
+ const finalSiteId = defaultSiteId && siteList.some(s => (s.id || s.siteId) == defaultSiteId)
+ ? defaultSiteId
+ : (siteList[0]?.id || siteList[0]?.siteId);
+
+ let userList = [];
+ if (finalSiteId) {
+ const userRes = await fetchUsers(finalSiteId);
+ userList = userRes?.code === 200 ? (userRes?.rows || []) : [];
+ }
+ setDroneUserOptions(userList);
+
+ const finalUserId = defaultUserId && userList.some(u => u.userId == defaultUserId)
+ ? defaultUserId
+ : (userList[0]?.userId);
+
+ requestAnimationFrame(() => {
+ bindForm.setFieldsValue({
+ sns: selectedDroneKeys.join(', '),
+ orgId: finalOrgId,
+ siteId: finalSiteId,
+ userId: finalUserId,
+ });
+ });
+ };
+ fetchAndSetForm();
+ }, [bindModalVisible, defaultOrgId, defaultSiteId, defaultUserId, selectedDroneKeys]);
+
+ const handleBind = async (values) => {
+ try {
+ const payload = {
+ siteId: values.siteId,
+ orgId: values.orgId,
+ userId: values.userId,
+ sns: values.sns.split(',').map(s => s.trim()),
+ };
+ const res = await bindDrone(payload);
+ if (res.code === 200 && res.data == true) {
+ utils.message.success('绑定成功');
+ setBindModalVisible(false);
+ setSelectedDroneKeys([]);
+ bindForm.resetFields();
+ fetchDroneList();
+ onAllDataNeedRefresh?.();
+ } else {
+ utils.message.error(res.msg || '绑定失败');
+ }
+ } catch (err) {
+ utils.message.error('操作异常');
+ }
+ };
+
+ const handleUnbind = (sns, type) => {
+ const validSns = (sns || []).filter(item =>
+ item !== null && item !== undefined && item !== '' && item.trim() !== ''
+ );
+ if (validSns.length === 0) {
+ return utils.message.warning('未选择有效设备,无法解绑');
+ }
+ const typeText = { 1: '人员', 2: '场站', 3: '组织' }[type];
+ modal.confirm({
+ title: '确认解绑',
+ content: `确定要为选中的无人机清除${typeText}绑定吗?`,
+ okText: '确定',
+ cancelText: '取消',
+ onOk: async () => {
+ try {
+ const res = await unbindDrone({ sns: validSns, type });
+ if (res.code === 200) {
+ utils.message.success('解绑成功');
+ fetchDroneList();
+ setSelectedDroneKeys([]);
+ onAllDataNeedRefresh?.();
+ } else {
+ utils.message.error(res.msg || '解绑失败');
+ }
+ } catch (err) {
+ utils.message.error('操作异常');
+ }
+ }
+ });
+ };
+
+ const droneColumns = [
+ { title: '设备名称', width: 150, dataIndex: 'drone_callsign', key: 'name' },
+ { title: 'SN码', width: 180, dataIndex: 'device_sn', key: 'sn' },
+ { title: '机场SN', width: 150, dataIndex: 'gateway_sn', key: 'gsn' },
+ {
+ title: '所属组织', width: 150, key: 'orgName',
+ render: (_, record) => {
+ const org = allOrgOptions.find(o => (o.orgId || o.id) == record.orgId);
+ return org ? (org.orgName || org.name) : 未绑定;
+ },
+ },
+ {
+ title: '所属场站', width: 150, key: 'siteName',
+ render: (_, record) => {
+ const site = allSiteOptions.find(s => (s.siteId || s.id) == record.siteId);
+ return site ? (site.siteName || site.name) : 未绑定;
+ },
+ },
+ {
+ title: '负责人', width: 150, key: 'userName',
+ render: (_, record) => {
+ const user = allUserOptions.find(u => u.userId == record.userId);
+ return user ? (user.nickName || user.userName) : 未绑定;
+ },
+ },
+ {
+ title: '状态', width: 150, dataIndex: 'onlineStatus', key: 'status',
+ render: s => {s === 1 ? '在线' : '离线'}
+ },
+ {
+ title: '操作', key: 'action', fixed: 'right' as const, width: 250,
+ render: (_, record: any) => (
+
+
+ } onClick={() => handleUnbind([record.gateway_sn], 1)}>用户
+
+
+ } onClick={() => handleUnbind([record.gateway_sn], 2)}>场站
+
+
+ } onClick={() => handleUnbind([record.gateway_sn], 3)}>组织
+
+
+ ),
+ },
+ ];
+
+ const selectorgId = Form.useWatch('orgId', bindForm);
+ const selectsiteId = Form.useWatch('siteId', bindForm);
+
+ useEffect(() => {
+ if (selectorgId) {
+ fetchSites(selectorgId);
+ }
+ }, [selectorgId]);
+
+ useEffect(() => {
+ if (selectsiteId) {
+ fetchUsers(selectsiteId);
+ }
+ }, [selectsiteId]);
+
+ return (
+ <>
+
+ setDroneParams({ ...droneParams, sn: e.target.value })}
+ />
+
+ } onClick={() => setDroneParams({ pageNum: 1, pageSize: 10, sn: '', status: '' })}>重置
+ } onClick={openBindModal}>绑定无人机
+
+
+
+
+
+
+
`共 ${t} 条`,
+ onChange: (page, pageSize) => {
+ setDroneParams({ ...droneParams, pageNum: page, pageSize });
+ },
+ }}
+ scroll={{ y: 'auto', x: '700px' }}
+ />
+
+
+
+
+ 绑定无人机
+
+ }
+ open={bindModalVisible}
+ onCancel={() => {
+ setBindModalVisible(false);
+ setDroneOrgOptions([]);
+ setDroneSiteOptions([]);
+ setDroneUserOptions([]);
+ bindForm.resetFields();
+ }}
+ destroyOnClose={false}
+ onOk={() => bindForm.submit()}
+ width={540}
+ >
+ 已选无人机({selectedDroneKeys.length}台)SN>} name="sns" rules={[{ required: true, message: '请输入 SN' }]}>
+
+
+
+ 所属组织
+
+ }
+ name="orgId" rules={[{ required: true, message: '请选择组织' }]}
+ >
+
+
+
+ 所属场站
+
+ }
+ name="siteId" rules={[{ required: !siteFieldDisabled, message: '请选择场站' }]}
+ >
+
+
+
+
+
+
+
+ >
+ );
+}
diff --git a/src/components/SystemSetting/SmartDeviceManagement.tsx b/src/components/SystemSetting/SmartDeviceManagement.tsx
new file mode 100644
index 0000000..fecd59e
--- /dev/null
+++ b/src/components/SystemSetting/SmartDeviceManagement.tsx
@@ -0,0 +1,608 @@
+import React, { useState, useEffect } from 'react';
+import {
+ Table,
+ Input,
+ Button,
+ Form,
+ Select,
+ Space,
+ Tag,
+ Modal,
+ Checkbox,
+ Tooltip,
+ Typography,
+ App,
+ Card,
+ InputNumber,
+} from 'antd';
+const { Text } = Typography;
+import {
+ ReloadOutlined,
+ LinkOutlined,
+ DisconnectOutlined,
+ EditOutlined,
+} from '@ant-design/icons';
+
+import {
+ getAllDevice,
+ bindSmartDevice,
+ unbindSmartDevice,
+ getDeviceAuth,
+ hasPermission,
+} from '@/api/device';
+import { getOrgList } from '@/api/organization/index';
+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';
+import DeviceParamModal from '../devices/DeviceParamModal';
+
+interface SmartDeviceManagementProps {
+ allOrgOptions: any[];
+ allSiteOptions: any[];
+ allUserOptions: any[];
+ onAllDataNeedRefresh?: () => void;
+}
+
+export default function SmartDeviceManagement({
+ allOrgOptions,
+ allSiteOptions,
+ allUserOptions,
+ onAllDataNeedRefresh,
+}: SmartDeviceManagementProps) {
+ const { modal } = App.useApp();
+ const { userInfo } = useSelector((state: RootState) => state.user);
+ const { stationId, currentStation } = useSelector((state: RootState) => state.station);
+
+ const [loading, setLoading] = useState(false);
+ const [smartList, setSmartList] = useState([]);
+ const [selectedSmartKeys, setSelectedSmartKeys] = useState([]);
+ const [bindSmartModalVisible, setBindSmartModalVisible] = useState(false);
+ const [bindSmartForm] = Form.useForm();
+ const [smartParams, setSmartParams] = useState({
+ pageNum: 1,
+ pageSize: 20,
+ serialNumber: '',
+ });
+ const [smartTotal, setSmartTotal] = useState(0);
+
+ const [smartOrgOptions, setSmartOrgOptions] = useState([]);
+ const [smartSiteOptions, setSmartSiteOptions] = useState([]);
+ const [smartUserOptions, setSmartUserOptions] = useState([]);
+
+ const [editSmartModalVisible, setEditSmartModalVisible] = useState(false);
+ const [editSmartForm] = Form.useForm();
+ const [currentEditSmart, setCurrentEditSmart] = useState(null);
+
+ const [paramModalVisible, setParamModalVisible] = useState(false);
+ const [currentParamDevice, setCurrentParamDevice] = useState(null);
+
+ const [paramModalVisible1, setParamModalVisible1] = useState(false);
+ const [currentParamDevice1, setCurrentParamDevice1] = useState(null);
+ const [paramForm1] = Form.useForm();
+
+ const isAdmin = userInfo?.roleKey === 'admin';
+ const isManager = userInfo?.roleKey === 'manager' || userInfo?.roleKey === 'Manager';
+ const orgFieldDisabled = !isAdmin;
+ const siteFieldDisabled = !(isAdmin || isManager);
+
+ const defaultOrgId = currentStation?.orgId || userInfo?.orgId;
+ const defaultSiteId = stationId || currentStation?.siteId || currentStation?.id;
+ const defaultUserId = userInfo?.userId;
+
+ const fetchSmartList = async () => {
+ setLoading(true);
+ try {
+ const res = await getAllDevice(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 {
+ const res = await getOrgList({});
+ if (res.code === 200) {
+ setSmartOrgOptions(res.rows || []);
+ }
+ return res;
+ } catch (err) {
+ console.error('获取组织列表失败', err);
+ return null;
+ }
+ };
+
+ const fetchSites = async (orgId) => {
+ try {
+ const res = await getSiteByOrgId({ id: orgId });
+ if (res.code === 200) {
+ setSmartSiteOptions(res.data || []);
+ }
+ return res;
+ } catch (err) {
+ console.error(err);
+ return null;
+ }
+ };
+
+ const fetchUsers = async (siteId) => {
+ try {
+ const res = await getUser({
+ siteId,
+ pageNum: 1,
+ pageSize: 1000
+ });
+ if (res.code === 200) {
+ setSmartUserOptions(res.rows || []);
+ }
+ return res;
+ } catch (err) {
+ console.error(err);
+ return null;
+ }
+ };
+
+ useEffect(() => {
+ fetchSmartList();
+ }, [smartParams]);
+
+ const openEditSmartModal = (record) => {
+ setCurrentEditSmart(record);
+ setEditSmartModalVisible(true);
+ editSmartForm.setFieldsValue({
+ deviceAlias: record.deviceAlias,
+ serialNumber: record.serialNumber,
+ onlineStatus: record.onlineStatus,
+ });
+ };
+
+ const saveEditSmart = (values) => {
+ setSmartList(prev => prev.map((item: any) => {
+ if (item.serialNumber === (currentEditSmart as any)?.serialNumber) {
+ return { ...item, ...values };
+ }
+ return item;
+ }));
+ utils.message.success('装备编辑成功');
+ setEditSmartModalVisible(false);
+ editSmartForm.resetFields();
+ setCurrentEditSmart(null);
+ };
+
+ const openParamModal = async (record) => {
+ getDevivePermisstion(record);
+ };
+
+ const openParamModal1 = async (record) => {
+ setCurrentParamDevice1(record);
+ setParamModalVisible1(true);
+ };
+
+ const getDevivePermisstion = (data) => {
+ const params = {
+ deviceId: data.serialNumber,
+ };
+ hasPermission(params).then(res => {
+ if (res.code == 200) {
+ if (res.data) {
+ setCurrentParamDevice(data);
+ setParamModalVisible(true);
+ } else {
+ utils.message.error('无权限');
+ }
+ }
+ });
+ };
+
+ const saveParam1 = async (values) => {
+ try {
+ const payload = {
+ deviceId: (currentParamDevice1 as any)?.serialNumber,
+ duration: values?.minute,
+ };
+ const res = await getDeviceAuth(payload);
+ if (res.code === 200 && res.data == true) {
+ utils.message.success('保存参数成功');
+ setParamModalVisible1(false);
+ } else {
+ utils.message.error(res.msg || '授权失败');
+ }
+ } catch (err) {
+ utils.message.error('操作异常');
+ }
+ };
+
+ const openBindSmartModal = async () => {
+ if (!selectedSmartKeys.length) {
+ return utils.message.warning('请先在列表中选中需要绑定的智能装备');
+ }
+ bindSmartForm.resetFields();
+ setBindSmartModalVisible(true);
+ setSmartOrgOptions([]);
+ setSmartSiteOptions([]);
+ setSmartUserOptions([]);
+ const orgRes = await fetchOrgs();
+ const orgList = orgRes?.code === 200 ? (orgRes?.rows || []) : [];
+ const finalOrgId = defaultOrgId && orgList.some(o => (o.id || o.orgId) == defaultOrgId)
+ ? defaultOrgId
+ : (orgList[0]?.id || orgList[0]?.orgId);
+ let siteList = [];
+ if (finalOrgId) {
+ const siteRes = await fetchSites(finalOrgId);
+ siteList = siteRes?.code === 200 ? (siteRes?.data || []) : [];
+ }
+ const finalSiteId = defaultSiteId && siteList.some(s => (s.id || s.siteId) == defaultSiteId)
+ ? defaultSiteId
+ : (siteList[0]?.id || siteList[0]?.siteId);
+ let userList = [];
+ if (finalSiteId) {
+ const userRes = await fetchUsers(finalSiteId);
+ userList = userRes?.code === 200 ? (userRes.rows || []) : [];
+ }
+ const finalUserId = defaultUserId && userList.some(u => u.userId == defaultUserId)
+ ? defaultUserId
+ : (userList[0]?.userId);
+ setTimeout(() => {
+ bindSmartForm.setFieldsValue({
+ deviceIds: selectedSmartKeys.join(', '),
+ orgId: finalOrgId,
+ siteId: finalSiteId,
+ userId: Number(finalUserId) || '',
+ });
+ }, 0);
+ };
+
+ 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 = await bindSmartDevice(payload);
+ if (res.code === 200 && res.data == true) {
+ utils.message.success('绑定成功');
+ setBindSmartModalVisible(false);
+ bindSmartForm.resetFields();
+ fetchSmartList();
+ onAllDataNeedRefresh?.();
+ } else {
+ utils.message.error('绑定失败');
+ }
+ } 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 as number];
+ modal.confirm({
+ title: '确认解绑',
+ content: `确定要为选中的智能装备清除${typeText}绑定吗?`,
+ okText: '确定',
+ cancelText: '取消',
+ onOk: async () => {
+ try {
+ const res = await unbindSmartDevice({ deviceIds: validIds, type });
+ if (res.code === 200) {
+ utils.message.success('解绑成功');
+ fetchSmartList();
+ setSelectedSmartKeys([]);
+ onAllDataNeedRefresh?.();
+ } 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: any) => {
+ const org = allOrgOptions.find(o => (o.orgId || o.id) == record.orgId);
+ return org ? (org.orgName || org.name) : 未绑定;
+ },
+ },
+ {
+ title: '所属场站', width: 150, key: 'siteName',
+ render: (_, record: any) => {
+ const site = allSiteOptions.find(s => (s.siteId || s.id) == record.siteId);
+ return site ? (site.siteName || site.name) : 未绑定;
+ },
+ },
+ {
+ title: '负责人', width: 150, key: 'userName',
+ render: (_, record: any) => {
+ const user = allUserOptions.find(u => u.userId == record.userId);
+ return user ? (user.nickName || user.userName) : 未绑定;
+ },
+ },
+ { title: '在线状态', width: 120, dataIndex: 'onlineStatus', key: 'online', render: s => {s === 'ONLINE' || s === 1 ? '在线' : '离线'} },
+ {
+ title: '操作', width: 280, key: 'action', fixed: 'right' as const,
+ render: (_, record: any) => (
+
+
+ } onClick={() => handleUnbindSmart([record.serialNumber], 1)}>用户
+
+
+ } onClick={() => handleUnbindSmart([record.serialNumber], 2)}>场站
+
+
+ } onClick={() => handleUnbindSmart([record.serialNumber], 3)}>组织
+
+ } onClick={() => openParamModal(record)}>参数
+ {userInfo?.userId == 1 && } onClick={() => openParamModal1(record)}>授权}
+
+ ),
+ },
+ ];
+
+ const selectorgId = Form.useWatch('orgId', bindSmartForm);
+ const selectsiteId = Form.useWatch('siteId', bindSmartForm);
+
+ useEffect(() => {
+ if (selectorgId) {
+ fetchSites(selectorgId);
+ }
+ }, [selectorgId]);
+
+ useEffect(() => {
+ if (selectsiteId) {
+ fetchUsers(selectsiteId);
+ }
+ }, [selectsiteId]);
+
+ return (
+ <>
+
+
+ setSmartParams({ ...smartParams, serialNumber: e.target.value.trim() })}
+ />
+ } onClick={() => setSmartParams({ pageNum: 1, pageSize: 10, serialNumber: '' })}>重置
+ } onClick={openBindSmartModal}>绑定装备
+
+
+
+
+
+
+
+
record.serialNumber}
+ columns={smartColumns}
+ dataSource={smartList}
+ loading={loading}
+ pagination={{
+ current: smartParams.pageNum,
+ pageSize: smartParams.pageSize,
+ total: smartTotal,
+ showSizeChanger: true,
+ showTotal: (t) => `共 ${t} 条`,
+ onChange: (page, pageSize) => {
+ setSmartParams({ pageNum: page, pageSize });
+ },
+ }}
+ scroll={{ y: 'auto', x: '700px' }}
+ />
+
+
+
+
+ 绑定智能装备
+
+ }
+ open={bindSmartModalVisible}
+ onCancel={() => {
+ setBindSmartModalVisible(false);
+ setSmartOrgOptions([]);
+ setSmartSiteOptions([]);
+ setSmartUserOptions([]);
+ bindSmartForm.resetFields();
+ }}
+ destroyOnClose={false}
+ onOk={() => bindSmartForm.submit()}
+ width={540}
+ >
+ 已选智能装备({selectedSmartKeys.length}台)ID>} name="deviceIds" rules={[{ required: true, message: '请选择装备' }]}>
+
+
+
+ 所属组织
+
+ }
+ name="orgId" rules={[{ required: true, message: '请选择组织' }]}
+ >
+
+
+
+ 所属场站
+
+ }
+ name="siteId" rules={[{ required: !siteFieldDisabled, message: '请选择场站' }]}
+ >
+
+
+
+
+
+
+
+
+ {
+ setEditSmartModalVisible(false);
+ setCurrentEditSmart(null);
+ editSmartForm.resetFields();
+ }}
+ onOk={() => editSmartForm.submit()}
+ width={480}
+ >
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 设备授权
+
+ - {(currentParamDevice1 as any)?.deviceAlias || (currentParamDevice1 as any)?.serialNumber}
+
+
+ }
+ open={paramModalVisible1}
+ onCancel={() => {
+ setParamModalVisible1(false);
+ setCurrentParamDevice1(null);
+ }}
+ footer={null}
+ width={560}
+ >
+ 授权时间(min)}
+ name="minute"
+ rules={[
+ { required: true, message: '请输入授权剩余时间' },
+ { type: 'number', min: 0, message: '授权时间不能小于0' }
+ ]}
+ >
+
+
+
+
+
+
+
+
+
+
+
+ {
+ setParamModalVisible(false);
+ setCurrentParamDevice(null);
+ }}
+ onSuccess={() => {
+ }}
+ />
+ >
+ );
+}
diff --git a/src/components/devices/DeviceParamModal.tsx b/src/components/devices/DeviceParamModal.tsx
index 53212e7..95a0e60 100644
--- a/src/components/devices/DeviceParamModal.tsx
+++ b/src/components/devices/DeviceParamModal.tsx
@@ -2,22 +2,20 @@ import React, { useState, useEffect } from 'react';
import {
Modal,
Form,
- Card,
Row,
Col,
InputNumber,
Input,
Checkbox,
Slider,
- Button,
- Space,
+ Spin,
} from 'antd';
import { useSelector } from 'react-redux';
import { RootState } from '@/store';
import { deviceRunParamSelectByDeviceId, deviceRunParamSave } from '@/api/stationManage/index';
import utils from '@/lib/utils';
-const GainSliderInput = ({ value = 0.5, onChange, disabled, min = 0.1, max = 1, step = 0.01 }) => {
+const GainSliderInput = ({ value, onChange, disabled, min = 0.1, max = 1, step = 0.01 }) => {
const handleSliderChange = (val) => {
onChange?.(val);
};
@@ -165,11 +163,13 @@ const DeviceParamModal: React.FC = ({ open, device, onCan
setParamData(res.data);
paramForm.setFieldsValue({ ...res.data });
} else {
+ utils.message.error('获取参数失败');
+
setParamData(null);
paramForm.resetFields();
}
} else {
- utils.message.error(res.msg || '获取参数失败');
+ utils.message.error('获取参数失败');
}
} catch (err) {
utils.message.error('获取参数失败');
@@ -179,6 +179,7 @@ const DeviceParamModal: React.FC = ({ open, device, onCan
};
const saveParam = async (values) => {
+ setLoading(true);
try {
const payload = {
leftForwardGain: Math.max(0.1, Math.min(1, values.leftForwardGain >= 10 ? values.leftForwardGain / 10 : values.leftForwardGain)),
@@ -200,6 +201,8 @@ const DeviceParamModal: React.FC = ({ open, device, onCan
}
} catch (err) {
utils.message.error('操作异常');
+ } finally {
+ setLoading(false);
}
};
@@ -231,85 +234,80 @@ const DeviceParamModal: React.FC = ({ open, device, onCan
onOk={() => paramForm.submit()}
confirmLoading={loading}
width={780}
- bodyStyle={{ padding: '16px 24px 0px' }}
destroyOnClose
>
-