Ver código fonte

feat(device): 添加灯杆亮度控制功能

- 实现了灯杆亮度调节的组件
- 添加了与后端 API 交互的逻辑
- 集成了加载状态和错误提示
nahida 1 ano atrás
pai
commit
1145ad1edc
1 arquivos alterados com 67 adições e 0 exclusões
  1. 67 0
      src/views/device/pole/pole-detail.vue

+ 67 - 0
src/views/device/pole/pole-detail.vue

@@ -0,0 +1,67 @@
+<script setup>
+import {clientGet} from "@/utils/apiClient.js";
+import {ElLoading, ElMessage} from "element-plus";
+
+const props = defineProps({
+  deviceNumber:{
+    type: String,
+    default: ''
+  }
+})
+
+const brightness = ref('');
+const poleInfo = ref({
+  light_num: '', //灯杆编号
+  brightness: '', //灯杆当前亮度
+  flag: 0, //0是关 1是开 (灯杆当前状态)
+  voltage: '', //电压
+  current: '', //电流
+  power: '', //功率
+  power_quantity: '', //电量
+  light_total_time: '',//累计开的时间
+  onlineStatus: 0//0离线 1在线 在线状态
+});
+
+const controlPole = async (brightness) => {
+  const loadingInstance = ElLoading.service({
+    target: '.slider-container',
+    text: 'Loading',
+    background: 'rgba(0, 0, 0, 0.7)'
+  });
+
+  try {
+    const res = await clientGet("/pole/instruct/issued/reportEnvironmentalData", {
+      params: {
+        cmd: '6011',
+        brightness: brightness?.toString(),
+        packageId: '1050',
+        lightNums: props.deviceNumber,
+      }
+    });
+    if (res.code !== 200) {
+      ElMessage.error(res.msg);
+    }
+
+  } catch (error) {
+    ElMessage.error('An error occurred');
+  } finally {
+    loadingInstance.close();
+  }
+}
+
+const control = () => {
+  controlPole(brightness.value);
+}
+
+onMounted(() => {
+
+})
+</script>
+
+<template>
+  <el-slider v-model="brightness" :step="10" :max="100" :min="0" @change="control"/>
+</template>
+
+<style scoped lang="scss">
+
+</style>