无人机管理后台前端(已迁走)
罗广辉
2025-10-11 02409bfbe15f22fc3b5dccadabfd860a660a49d9
src/views/device/components/use-device-setting.js
@@ -1,12 +1,13 @@
import { ElMessage } from 'element-plus';
import { putDeviceProps, putDevicePropsNew } from '@/api/device-setting';
import { putDeviceProps } from '@/api/device-setting';
import {
  DeviceSettingKeyEnum,
  ObstacleAvoidanceStatusEnum,
  NightLightsStateEnum,
  DistanceLimitStatusEnum,
} from '@/types/device-setting';
import { messages } from '@/lang';
export function useDeviceSetting() {
  // 生成参数
@@ -49,18 +50,17 @@
  }
  // 设置设备属性
  async function setDeviceProps(sn, body, workspaceId) {
  async function setDeviceProps(sn, workspaceId, body) {
    try {
      const { code, message: msg } = await putDevicePropsNew(sn, body, workspaceId);
      if (code === 0) {
        return true;
      }
      throw msg;
    } catch (e) {
      ElMessage({
        message: '设备属性设置失败',
        type: 'error',
       await putDeviceProps(sn, workspaceId, body).then(res => {
         if (res.data.code === 0) {
           ElMessage({
             message: '设备属性设置成功!',
             type: 'success',
           });
         }
      });
    } catch (e) {
      return false;
    }
  }