设备配置参数(运行速度)
This commit is contained in:
@@ -33,7 +33,7 @@ import {
|
||||
import SerialNumGenerate from "./SerialNumGenerate"
|
||||
import { getPlaneDeviceList, bindDrone, unbindDrone, bindSmartDevice, unbindSmartDevice, getAllDevice } from '@/api/device';
|
||||
import { getOrgList } from '@/api/organization/index';
|
||||
import { getSiteByOrgId, getStationList } from '@/api/stationManage/index';
|
||||
import { getSiteByOrgId, getStationList, deviceRunParamSelectByDeviceId, deviceRunParamSave, deviceRunParamDelete } from '@/api/stationManage/index';
|
||||
import { getUser } from '@/api/user/index';
|
||||
import { useSelector } from 'react-redux';
|
||||
import { RootState } from '@/src/store';
|
||||
@@ -73,6 +73,7 @@ export default function DeviceManagementPage() {
|
||||
|
||||
// 无人机相关状态
|
||||
const { userInfo } = useSelector((state: RootState) => state.user);
|
||||
const { stationId } = useSelector((state: RootState) => state.station);
|
||||
const [droneList, setDroneList] = useState([]);
|
||||
const [bindModalVisible, setBindModalVisible] = useState(false);
|
||||
const [bindForm] = Form.useForm();
|
||||
@@ -113,6 +114,12 @@ export default function DeviceManagementPage() {
|
||||
const [editSmartForm] = Form.useForm();
|
||||
const [currentEditSmart, setCurrentEditSmart] = useState(null);
|
||||
|
||||
// 设备参数管理相关状态
|
||||
const [paramModalVisible, setParamModalVisible] = useState(false);
|
||||
const [currentParamDevice, setCurrentParamDevice] = useState(null);
|
||||
const [paramData, setParamData] = useState(null);
|
||||
const [paramForm] = Form.useForm();
|
||||
|
||||
// 获取无人机列表(带分页 + 筛选)
|
||||
const fetchDroneList = async () => {
|
||||
setLoading(true);
|
||||
@@ -155,6 +162,55 @@ export default function DeviceManagementPage() {
|
||||
setCurrentEditSmart(null);
|
||||
};
|
||||
|
||||
// 打开设备参数管理弹窗
|
||||
const openParamModal = async (record) => {
|
||||
setCurrentParamDevice(record);
|
||||
setParamModalVisible(true);
|
||||
await fetchParamData(record.serialNumber);
|
||||
};
|
||||
|
||||
// 获取设备参数
|
||||
const fetchParamData = async (deviceId) => {
|
||||
try {
|
||||
const res = await deviceRunParamSelectByDeviceId({ deviceId });
|
||||
if (res.code == 200) {
|
||||
if (res.data) {
|
||||
setParamData(res.data);
|
||||
paramForm.setFieldsValue({ runSpeed: res.data.runSpeed });
|
||||
} else {
|
||||
setParamData(null);
|
||||
paramForm.setFieldsValue({ runSpeed: null });
|
||||
}
|
||||
} else {
|
||||
utils.message.error(res.msg || '获取参数失败');
|
||||
}
|
||||
} catch (err) {
|
||||
utils.message.error('获取参数失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 保存参数
|
||||
const saveParam = async (values) => {
|
||||
try {
|
||||
const payload = {
|
||||
...values,
|
||||
deviceId: currentParamDevice.serialNumber,
|
||||
siteId: stationId,
|
||||
orgId: userInfo.orgId
|
||||
};
|
||||
const res = await deviceRunParamSave(payload);
|
||||
if (res.code === 200) {
|
||||
utils.message.success('保存参数成功');
|
||||
setParamModalVisible(false);
|
||||
//await fetchParamData(currentParamDevice.serialNumber);
|
||||
} else {
|
||||
utils.message.error(res.msg || '保存参数失败');
|
||||
}
|
||||
} catch (err) {
|
||||
utils.message.error('操作异常');
|
||||
}
|
||||
};
|
||||
|
||||
const fetchSmartList = async () => {
|
||||
setLoading(true);
|
||||
try {
|
||||
@@ -373,7 +429,6 @@ export default function DeviceManagementPage() {
|
||||
title: '操作', width: 280, key: 'action', fixed: 'right',
|
||||
render: (_, record) => (
|
||||
<Space>
|
||||
<Button size="small" icon={<EditOutlined />} onClick={() => openEditSmartModal(record)}>编辑</Button>
|
||||
|
||||
<Tooltip title="清除人员绑定">
|
||||
<Button size="small" icon={<DisconnectOutlined />} onClick={() => handleUnbindSmart([record.serialNumber], 1)}>用户</Button>
|
||||
@@ -384,6 +439,8 @@ export default function DeviceManagementPage() {
|
||||
<Tooltip title="清除组织绑定">
|
||||
<Button size="small" icon={<DisconnectOutlined />} onClick={() => handleUnbindSmart([record.serialNumber], 3)}>组织</Button>
|
||||
</Tooltip>
|
||||
<Button size="small" icon={<EditOutlined />} onClick={() => openParamModal(record)}>参数</Button>
|
||||
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
@@ -688,6 +745,33 @@ export default function DeviceManagementPage() {
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
|
||||
{/* 设备参数管理弹窗 */}
|
||||
<Modal
|
||||
title={`设备参数管理 - ${currentParamDevice?.deviceAlias || currentParamDevice?.serialNumber}`}
|
||||
open={paramModalVisible}
|
||||
onCancel={() => {
|
||||
setParamModalVisible(false);
|
||||
setCurrentParamDevice(null);
|
||||
setParamData(null);
|
||||
}}
|
||||
footer={null}
|
||||
width={500}
|
||||
>
|
||||
{/* 显示和编辑参数 */}
|
||||
<Form
|
||||
form={paramForm}
|
||||
layout="vertical"
|
||||
onFinish={saveParam}
|
||||
>
|
||||
<Form.Item label="运行速度" name="runSpeed" rules={[{ required: true, message: '请输入运行速度' }]}>
|
||||
<InputNumber placeholder="请输入运行速度" style={{ width: '100%' }} />
|
||||
</Form.Item>
|
||||
<Form.Item>
|
||||
<Button type="primary" htmlType="submit">保存参数</Button>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</>
|
||||
) : activeTab === 'drone' ? (
|
||||
<>
|
||||
|
||||
Reference in New Issue
Block a user