Pārlūkot izejas kodu

fix: 灯光的亮度调整百分比

chenzhen 6 dienas atpakaļ
vecāks
revīzija
458f943dd7

+ 65 - 51
src/components/slider/Slider.vue

@@ -1,5 +1,8 @@
 <template>
-  <div class="slider-container" ref="slider-container">
+  <div
+    class="slider-container"
+    ref="slider-container"
+  >
     <div class="slider-track">
       <span class="slider-internalValue-text">{{ min }}</span>
       <div
@@ -7,7 +10,8 @@
         :style="{ width: `${progressWidth}%` }"
         @touchstart.stop="startDrag"
         @touchmove.stop="onDrag"
-        @touchend.stop="endDrag">
+        @touchend.stop="endDrag"
+      >
         <span class="slider-progress-line"></span>
       </div>
       <span
@@ -15,7 +19,7 @@
         class="slider-internal-text"
         :style="{
           left: isFollow && progressWidth < 86 ? `calc(${progressWidth}% + 10px)` : 'auto',
-          color: followColor
+          color: followColor,
         }"
         >{{ showValue ? internalValue : max }}{{ suffix }}
       </span>
@@ -26,59 +30,69 @@
         >{{ showValue ? internalValue : max }}<sup class="slider-internal-text-suffix">{{ suffix }}</sup>
         </span
       > -->
-      <span v-else class="slider-max-text" :style="{ color: maxColor }">{{ max }}</span>
+      <span
+        v-else
+        class="slider-max-text"
+        :style="{ color: maxColor }"
+        >{{ max }}</span
+      >
     </div>
   </div>
 </template>
 
 <script setup>
-import { computed, defineModel, defineProps, onMounted, ref, useTemplateRef, watch } from "vue"
+import { computed, defineModel, defineProps, onMounted, ref, useTemplateRef, watch } from 'vue';
+import { customRound } from '@/utils';
 
-const emit = defineEmits(["onEnd", "onStart"])
+const emit = defineEmits(['onEnd', 'onStart']);
 const props = defineProps({
   min: {
     type: Number,
-    default: 0
+    default: 0,
   },
   max: {
     type: Number,
-    default: 100
+    default: 100,
   },
   isFollow: {
     type: Boolean,
-    default: false
+    default: false,
   },
   suffixNormal: {
     type: Boolean,
-    default: false
+    default: false,
   },
   suffix: {
     type: String,
-    default: ""
+    default: '',
   },
   showValue: {
     type: Boolean,
-    default: false
-  }
-})
+    default: false,
+  },
+  type: {
+    type: String,
+    default: '',
+  },
+});
 
-const model = defineModel()
+const model = defineModel();
 watch(
   () => model.value,
-  newValue => {
+  (newValue) => {
     if (newValue) {
-      internalValue.value = newValue
+      internalValue.value = newValue;
     }
   }
-)
-const internalValue = ref(model.value || props.min)
-const isDragging = ref(false)
-let animationFrameId = null
-const sliderContainer = useTemplateRef("slider-container")
+);
+const internalValue = ref(model.value || props.min);
+const isDragging = ref(false);
+let animationFrameId = null;
+const sliderContainer = useTemplateRef('slider-container');
 const progressWidth = computed(() => {
-  const percentage = ((internalValue.value - props.min) / (props.max - props.min)) * 100
-  return `${Math.max(percentage, 10)}`
-})
+  const percentage = ((internalValue.value - props.min) / (props.max - props.min)) * 100;
+  return `${Math.max(percentage, 10)}`;
+});
 
 // const computedTrackBackground = computed(() => {
 //   const percentage = ((internalValue.value - props.min) / (props.max - props.min)) * 100
@@ -86,52 +100,52 @@ const progressWidth = computed(() => {
 // })
 
 const followColor = computed(() => {
-  const percentage = ((internalValue.value - props.min) / (props.max - props.min)) * 100
-  return percentage >= 95 ? "rgba(255, 255, 255, 0.6)" : "var(--Blue, #001428)"
-})
+  const percentage = ((internalValue.value - props.min) / (props.max - props.min)) * 100;
+  return percentage >= 95 ? 'rgba(255, 255, 255, 0.6)' : 'var(--Blue, #001428)';
+});
 const maxColor = computed(() => {
-  const percentage = ((internalValue.value - props.min) / (props.max - props.min)) * 100
-  return percentage >= 95 ? "rgba(255, 255, 255, 0.6)" : "rgb(116, 128, 141)"
-})
+  const percentage = ((internalValue.value - props.min) / (props.max - props.min)) * 100;
+  return percentage >= 95 ? 'rgba(255, 255, 255, 0.6)' : 'rgb(116, 128, 141)';
+});
 
-const startDrag = event => {
-  isDragging.value = true
-  emit("onStart", internalValue.value)
-}
+const startDrag = (event) => {
+  isDragging.value = true;
+  emit('onStart', internalValue.value);
+};
 
-const onDrag = event => {
-  if (!isDragging.value) return
+const onDrag = (event) => {
+  if (!isDragging.value) return;
 
-  const touch = event.touches[0]
+  const touch = event.touches[0];
 
-  const sliderRect = sliderContainer.value.getBoundingClientRect()
+  const sliderRect = sliderContainer.value.getBoundingClientRect();
 
-  const offsetX = touch.clientX - sliderRect.left + 16
+  const offsetX = touch.clientX - sliderRect.left + 16;
   //   console.log(touch, sliderRect, offsetX)
   // 计算百分比并确保在 0 到 1 之间
-  const percentage = Math.min(Math.max(offsetX / sliderRect.width, 0), 1)
-  const newValue = Math.round(percentage * (props.max - props.min) + props.min)
+  const percentage = Math.min(Math.max(offsetX / sliderRect.width, 0), 1);
+  const newValue = Math.round(percentage * (props.max - props.min) + props.min);
 
   // 更新 internalValue
   if (animationFrameId) {
-    cancelAnimationFrame(animationFrameId)
+    cancelAnimationFrame(animationFrameId);
   }
   animationFrameId = requestAnimationFrame(() => {
-    model.value = internalValue.value = newValue
+    model.value = internalValue.value = props.type == 'light' ? customRound(newValue,20) : newValue;
     // emit('update:modelValue', internalValue.value) // 确保使用正确的事件名称
-  })
-}
+  });
+};
 const endDrag = () => {
-  isDragging.value = false
+  isDragging.value = false;
   if (animationFrameId) {
-    cancelAnimationFrame(animationFrameId)
+    cancelAnimationFrame(animationFrameId);
   }
-  emit("onEnd")
-}
+  emit('onEnd');
+};
 
 onMounted(() => {
   // 这里可以添加初始化逻辑
-})
+});
 </script>
 
 <style scoped lang="scss">

+ 278 - 277
src/utils/index.ts

@@ -1,35 +1,36 @@
 // Parse the time to string
-import Keys from '@/constant/key'
-import { store } from '@/store'
-import Cookies from 'js-cookie'
-import any = jasmine.any
+import Keys from '@/constant/key';
+import { store } from '@/store';
+import Cookies from 'js-cookie';
+import { type } from 'os';
+import any = jasmine.any;
 
 export const parseTime = (
   time?: object | string | number | null,
   cFormat?: string
 ): string | null => {
   if (time === undefined || !time) {
-    return null
+    return null;
   }
-  const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}'
-  let date: Date
+  const format = cFormat || '{y}-{m}-{d} {h}:{i}:{s}';
+  let date: Date;
   if (typeof time === 'object') {
-    date = time as Date
+    date = time as Date;
   } else {
     if (typeof time === 'string') {
       if (/^[0-9]+$/.test(time)) {
         // support "1548221490638"
-        time = parseInt(time)
+        time = parseInt(time);
       } else {
         // support safari
         // https://stackoverflow.com/questions/4310953/invalid-date-in-safari
-        time = time.replace(new RegExp(/-/gm), '/')
+        time = time.replace(new RegExp(/-/gm), '/');
       }
     }
     if (typeof time === 'number' && time.toString().length === 10) {
-      time = time * 1000
+      time = time * 1000;
     }
-    date = new Date(time)
+    date = new Date(time);
   }
   const formatObj: { [key: string]: number } = {
     y: date.getFullYear(),
@@ -38,197 +39,198 @@ export const parseTime = (
     h: date.getHours(),
     i: date.getMinutes(),
     s: date.getSeconds(),
-    a: date.getDay()
-  }
+    a: date.getDay(),
+  };
   const timeStr = format.replace(/{([ymdhisa])+}/g, (result, key) => {
-    const value = formatObj[key]
+    const value = formatObj[key];
     // Note: getDay() returns 0 on Sunday
     if (key === 'a') {
-      return ['日', '一', '二', '三', '四', '五', '六'][value]
+      return ['日', '一', '二', '三', '四', '五', '六'][value];
     }
-    return value.toString().padStart(2, '0')
-  })
-  return timeStr
-}
+    return value.toString().padStart(2, '0');
+  });
+  return timeStr;
+};
 
 // Format and filter json data using filterKeys array
 export const formatJson = (filterKeys: any, jsonData: any) =>
-  jsonData.map((data: any) => filterKeys.map((key: string) => {
-    if (key === 'timestamp') {
-      return parseTime(data[key])
-    } else {
-      return data[key]
-    }
-  }))
+  jsonData.map((data: any) =>
+    filterKeys.map((key: string) => {
+      if (key === 'timestamp') {
+        return parseTime(data[key]);
+      } else {
+        return data[key];
+      }
+    })
+  );
 
 // Check if an element has a class
 export const hasClass = (ele: HTMLElement, className: string) => {
-  return !!ele.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)'))
-}
+  return !!ele.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)'));
+};
 
 // Add class to element
 export const addClass = (ele: HTMLElement, className: string) => {
-  if (!hasClass(ele, className)) ele.className += ' ' + className
-}
+  if (!hasClass(ele, className)) ele.className += ' ' + className;
+};
 
 // Remove class from element
 export const removeClass = (ele: HTMLElement, className: string) => {
   if (hasClass(ele, className)) {
-    const reg = new RegExp('(\\s|^)' + className + '(\\s|$)')
-    ele.className = ele.className.replace(reg, ' ')
+    const reg = new RegExp('(\\s|^)' + className + '(\\s|$)');
+    ele.className = ele.className.replace(reg, ' ');
   }
-}
+};
 
 // Toggle class for the selected element
 export const toggleClass = (ele: HTMLElement, className: string) => {
   if (!ele || !className) {
-    return
+    return;
   }
-  let classString = ele.className
-  const nameIndex = classString.indexOf(className)
+  let classString = ele.className;
+  const nameIndex = classString.indexOf(className);
   if (nameIndex === -1) {
-    classString += '' + className
+    classString += '' + className;
   } else {
     classString =
-      classString.substr(0, nameIndex) +
-      classString.substr(nameIndex + className.length)
+      classString.substr(0, nameIndex) + classString.substr(nameIndex + className.length);
   }
-  ele.className = classString
-}
+  ele.className = classString;
+};
 export const setQueryConfig = function (queryConfig: any) {
-  let _str = ''
+  let _str = '';
   for (const o in queryConfig) {
     if (queryConfig[o] !== -1) {
-      _str += o + '=' + queryConfig[o] + '&'
+      _str += o + '=' + queryConfig[o] + '&';
     }
   }
-  _str = _str.substring(0, _str.length - 1) // 末尾是&
-  return _str
-}
+  _str = _str.substring(0, _str.length - 1); // 末尾是&
+  return _str;
+};
 
 // 获取用户信息
 export const getUserInfo = function () {
   // debugger
-  let userInfo = store.state.user
+  let userInfo = store.state.user;
   const paramsInfo: any = {
     openid: userInfo.openid,
     userId: userInfo.userId,
     mac: userInfo.mac,
     pubname: Keys.pubname,
-    projectId: userInfo.projectId
-  }
+    projectId: userInfo.projectId,
+  };
   if (userInfo.userName) {
-    paramsInfo.userName = userInfo.userName
+    paramsInfo.userName = userInfo.userName;
   }
   if (userInfo.userPhone) {
-    paramsInfo.userPhone = userInfo.userPhone
+    paramsInfo.userPhone = userInfo.userPhone;
   }
-  return paramsInfo
-}
-
+  return paramsInfo;
+};
 
 // 地址通用参赛携带
 export const getComparams = function () {
-  let userInfo = store.state.user
+  let userInfo = store.state.user;
   let paramsInfo: any = {
     openid: Keys.openid,
     userId: userInfo.userId,
     pubname: Keys.pubname,
     mac: userInfo.mac,
-    projectId: userInfo.projectId
-  }
+    projectId: userInfo.projectId,
+  };
   if (userInfo.userName) {
-    paramsInfo.userName = userInfo.userName
+    paramsInfo.userName = userInfo.userName;
   }
   if (userInfo.userPhone) {
-    paramsInfo.userPhone = userInfo.userPhone
+    paramsInfo.userPhone = userInfo.userPhone;
   }
-  return paramsInfo
-}
+  return paramsInfo;
+};
 
 export const formatDate = function (split: string = 'YYYYMMDD', date: any = new Date()) {
   //三目运算符
-  const dates = date ? date : new Date()
+  const dates = date ? date : new Date();
   //年份
-  const year: number = dates.getFullYear()
+  const year: number = dates.getFullYear();
   //月份下标是0-11
-  const month: any = (dates.getMonth() + 1) < 10 ? '0' + (dates.getMonth() + 1) : (dates.getMonth() + 1)
+  const month: any =
+    dates.getMonth() + 1 < 10 ? '0' + (dates.getMonth() + 1) : dates.getMonth() + 1;
   //具体的天数
-  const day: any = dates.getDate() < 10 ? '0' + dates.getDate() : dates.getDate()
+  const day: any = dates.getDate() < 10 ? '0' + dates.getDate() : dates.getDate();
   // //小时
-  const Hours = dates.getHours() < 10 ? '0' + dates.getHours() : dates.getHours()
+  const Hours = dates.getHours() < 10 ? '0' + dates.getHours() : dates.getHours();
   // //分钟
-  const Minutes = dates.getMinutes() < 10 ? '0' + dates.getMinutes() : dates.getMinutes()
+  const Minutes = dates.getMinutes() < 10 ? '0' + dates.getMinutes() : dates.getMinutes();
   // //秒
-  const Seconds = dates.getSeconds() < 10 ? '0' + dates.getSeconds() : dates.getSeconds()
+  const Seconds = dates.getSeconds() < 10 ? '0' + dates.getSeconds() : dates.getSeconds();
   //返回数据格式
   if (split === 'YYYY年MM月DD日') {
-    return year + '年' + month + '月' + day + '日'
+    return year + '年' + month + '月' + day + '日';
   } else if (split === 'YYYY.MM') {
-    return year + '.' + month
+    return year + '.' + month;
   } else if (split === 'YYYYMM') {
-    return year + '' + month
+    return year + '' + month;
   } else if (split === 'YYYY-MM-DD') {
-    return year + '-' + month + '-' + day
+    return year + '-' + month + '-' + day;
   } else if (split === 'YYYY.MM.DD HH:mm') {
-    return year + '.' + month + "." + day + " " + Hours + ":" + Minutes
+    return year + '.' + month + '.' + day + ' ' + Hours + ':' + Minutes;
   } else if (split === 'YYYY.MM.DD HH:mm:ss') {
-    return year + '.' + month + "." + day + " " + Hours + ":" + Minutes + ":" + Seconds
-  }
-  else {
-    return year + '' + month + '' + day
+    return year + '.' + month + '.' + day + ' ' + Hours + ':' + Minutes + ':' + Seconds;
+  } else {
+    return year + '' + month + '' + day;
   }
-}
+};
 
 // 把字符串 (yyyymmdd) 转换成日期格式(yyyy-mm-dd)
 export const formatDateStr = function (date: any) {
   if (date) {
-    return date.replace(/^(\d{4})(\d{2})(\d{2})$/, '$1-$2-$3')
+    return date.replace(/^(\d{4})(\d{2})(\d{2})$/, '$1-$2-$3');
   } else {
-    return ''
+    return '';
   }
-}
+};
 export const getTomorrow = function (split: any = '') {
-  let dates = new Date()
-  dates.setTime(dates.getTime() + 24 * 60 * 60 * 1000)
-  const Year: number = dates.getFullYear()
+  let dates = new Date();
+  dates.setTime(dates.getTime() + 24 * 60 * 60 * 1000);
+  const Year: number = dates.getFullYear();
   //月份下标是0-11
-  const Months: any = (dates.getMonth() + 1) < 10 ? '0' + (dates.getMonth() + 1) : (dates.getMonth() + 1)
+  const Months: any =
+    dates.getMonth() + 1 < 10 ? '0' + (dates.getMonth() + 1) : dates.getMonth() + 1;
   //具体的天数
-  const day: any = dates.getDate() < 10 ? '0' + dates.getDate() : dates.getDate()
+  const day: any = dates.getDate() < 10 ? '0' + dates.getDate() : dates.getDate();
   //返回数据格式
-  return Year + split + Months + split + day
-}
+  return Year + split + Months + split + day;
+};
 
 export function getHours() {
-  return new Date().getHours()
+  return new Date().getHours();
 }
 
 export function parseImgUrl(base: string, img: string) {
   if (img) {
-    return `${process.env.BASE_URL}images/${base}/${img}`
+    return `${process.env.BASE_URL}images/${base}/${img}`;
   } else {
-    return ''
+    return '';
   }
 }
 
 // 判断舒服在当前公司
 export function isWithinLocation(companyConfig: any) {
-  let targetLocationInfo, maxDistance
+  let targetLocationInfo, maxDistance;
   // 是否有权限不限制距离 true-不限制,false-限制
-  let remoteControl = store.state.user.remoteControl
+  let remoteControl = store.state.user.remoteControl;
   // let companyConfig = store.state.company.companyConfig
 
   if (companyConfig.sagaCare && companyConfig.sagaCareLimit) {
-    maxDistance = companyConfig.sagaCareDistance
-    let location = companyConfig.sagaCareCoords.split(',')
+    maxDistance = companyConfig.sagaCareDistance;
+    let location = companyConfig.sagaCareCoords.split(',');
     targetLocationInfo = {
       longitude: location[0],
-      latitude: location[1]
-    }
+      latitude: location[1],
+    };
   }
-  maxDistance = maxDistance || 1
-  let toastTip = '您好像不在公司'
+  maxDistance = maxDistance || 1;
+  let toastTip = '您好像不在公司';
 }
 
 /**
@@ -236,11 +238,11 @@ export function isWithinLocation(companyConfig: any) {
  * @param year
  */
 export function getAddYear(year: number = 0) {
-  let time = new Date()
-  time.setFullYear(time.getFullYear() + year)
-  let y = time.getFullYear()
-  let m = time.getMonth() + 1
-  return new Date(y + '/' + m)
+  let time = new Date();
+  time.setFullYear(time.getFullYear() + year);
+  let y = time.getFullYear();
+  let m = time.getMonth() + 1;
+  return new Date(y + '/' + m);
 }
 
 /**
@@ -248,22 +250,22 @@ export function getAddYear(year: number = 0) {
  *  获取上一个月,日期格式yyyyMM
  */
 export function getPreMonth(formatType: any = '') {
-  const nowdays = new Date()
-  let year = nowdays.getFullYear()
-  let month: any = nowdays.getMonth()
+  const nowdays = new Date();
+  let year = nowdays.getFullYear();
+  let month: any = nowdays.getMonth();
   if (month === 0) {
-    month = 12
-    year = year - 1
+    month = 12;
+    year = year - 1;
   }
   if (month < 10) {
-    month = '0' + month
+    month = '0' + month;
   }
   if (formatType === 'YYYY.MM') {
-    return year + '.' + month
+    return year + '.' + month;
   } else if (formatType === 'YYYY年MM月') {
-    return year + '年' + month + '月'
+    return year + '年' + month + '月';
   } else {
-    return year + '' + month
+    return year + '' + month;
   }
 }
 
@@ -272,39 +274,36 @@ export function getPreMonth(formatType: any = '') {
  */
 export const formatEnergyDate = function (time: any) {
   //三目运算符
-  const dates = time ? new Date(time) : new Date()
+  const dates = time ? new Date(time) : new Date();
   //月份下标是0-11
-  const months: any = (dates.getMonth() + 1) < 10 ? '0' + (dates.getMonth() + 1) : (dates.getMonth() + 1)
+  const months: any =
+    dates.getMonth() + 1 < 10 ? '0' + (dates.getMonth() + 1) : dates.getMonth() + 1;
   //具体的天数
-  const day: any = dates.getDate() < 10 ? '0' + dates.getDate() : dates.getDate()
-  const year: number = dates.getFullYear()
-  const hours = dates.getHours() < 10 ? '0' + dates.getHours() : dates.getHours()
+  const day: any = dates.getDate() < 10 ? '0' + dates.getDate() : dates.getDate();
+  const year: number = dates.getFullYear();
+  const hours = dates.getHours() < 10 ? '0' + dates.getHours() : dates.getHours();
   // //分钟
-  const minutes = dates.getMinutes() < 10 ? '0' + dates.getMinutes() : dates.getMinutes()
+  const minutes = dates.getMinutes() < 10 ? '0' + dates.getMinutes() : dates.getMinutes();
   //返回数据格式
-  return [
-    year + '年' + months + '月',
-    months + '月' + day + '日',
-    hours + ':' + minutes
-  ]
-}
+  return [year + '年' + months + '月', months + '月' + day + '日', hours + ':' + minutes];
+};
 
 export const setSession = function (key: any = '', obj: any = '') {
   if (obj) {
-    let str = JSON.stringify(obj)
-    sessionStorage.setItem(key, str)
+    let str = JSON.stringify(obj);
+    sessionStorage.setItem(key, str);
   }
-}
+};
 
 export const getSession = function (key: any = '') {
   if (key) {
-    let obj: any = sessionStorage.getItem(key)
+    let obj: any = sessionStorage.getItem(key);
     if (obj) {
-      return JSON.parse(obj)
+      return JSON.parse(obj);
     }
   }
-  return ''
-}
+  return '';
+};
 
 /**
  * 本地存储localStorage
@@ -314,13 +313,13 @@ export const getSession = function (key: any = '') {
 export const setLocalStorage = function (key: any = '', obj: any = '') {
   if (obj) {
     if (obj instanceof Object) {
-      let str = JSON.stringify(obj)
-      localStorage.setItem(key, str)
+      let str = JSON.stringify(obj);
+      localStorage.setItem(key, str);
     } else {
-      localStorage.setItem(key, obj)
+      localStorage.setItem(key, obj);
     }
   }
-}
+};
 
 /**
  * 获取本地存储
@@ -328,251 +327,253 @@ export const setLocalStorage = function (key: any = '', obj: any = '') {
  */
 export const getLocalStorage = function (key: any) {
   if (key) {
-    let obj: any = localStorage.getItem(key)
+    let obj: any = localStorage.getItem(key);
     if (obj) {
-      return JSON.parse(obj)
+      return JSON.parse(obj);
     } else {
-      return ''
+      return '';
     }
   }
-  return ''
-}
+  return '';
+};
 
 /**
  * 存储最新的空间信息
  * @param spaceInfo
  */
 export const setLocalNewSpaceInfo = function (spaceInfo: any) {
-  setLocalStorage(Keys.storageSpaceInfoKey, spaceInfo)
-}
+  setLocalStorage(Keys.storageSpaceInfoKey, spaceInfo);
+};
 
 /**
  * 获取最新的空间信息
  */
 export const getLocalNewSpaceInfo = function () {
-  let spaceInfo: any = getLocalStorage(Keys.storageSpaceInfoKey)
-  return spaceInfo
-}
+  let spaceInfo: any = getLocalStorage(Keys.storageSpaceInfoKey);
+  return spaceInfo;
+};
 
 /**
  * 本地缓存建筑,楼层,空间
  */
 export const localStorageSpaceId = function (buildingId: any, floorId: any, spaceId: any) {
-  let spaceMap: any = getLocalStorage(Keys.storageSpaceKey) ? getLocalStorage(Keys.storageSpaceKey) : {}
-  let key: any = `${buildingId},${floorId}`
-  spaceMap[key] = spaceId
-  setLocalStorage(Keys.storageSpaceKey, spaceMap)
-}
-export const getStorageSpaceId = function () {
   let spaceMap: any = getLocalStorage(Keys.storageSpaceKey)
-  return spaceMap
-}
+    ? getLocalStorage(Keys.storageSpaceKey)
+    : {};
+  let key: any = `${buildingId},${floorId}`;
+  spaceMap[key] = spaceId;
+  setLocalStorage(Keys.storageSpaceKey, spaceMap);
+};
+export const getStorageSpaceId = function () {
+  let spaceMap: any = getLocalStorage(Keys.storageSpaceKey);
+  return spaceMap;
+};
 
 /**
  *  本地缓存建筑对应的楼层
  */
 export const localStorageFloor = function (buildingId: any, floorId: any) {
-  let floorMap: any = getLocalStorage(Keys.storageFloorKey) ? getLocalStorage(Keys.storageFloorKey) : {}
-  floorMap[buildingId] = floorId
-  setLocalStorage(Keys.storageFloorKey, floorMap)
-}
+  let floorMap: any = getLocalStorage(Keys.storageFloorKey)
+    ? getLocalStorage(Keys.storageFloorKey)
+    : {};
+  floorMap[buildingId] = floorId;
+  setLocalStorage(Keys.storageFloorKey, floorMap);
+};
 /**
  * 获取本地存储的建筑对应的关系
  * @param buildingId
  * @param floorId
  */
 export const getLocalStorageFloor = function () {
-  let floorMap: any = getLocalStorage(Keys.storageFloorKey)
-  return floorMap
-}
+  let floorMap: any = getLocalStorage(Keys.storageFloorKey);
+  return floorMap;
+};
 
 /**
  * 缓存搜索页面最近查找的数据
  * @param item
  */
 export const setLocalSearchSpace = function (item: any) {
-  let historySearch: any = getLocalStorage(Keys.historySearchSpaceKey)
-  let flag = false
-  historySearch = historySearch ? historySearch : []
+  let historySearch: any = getLocalStorage(Keys.historySearchSpaceKey);
+  let flag = false;
+  historySearch = historySearch ? historySearch : [];
   historySearch.map((historyItem: any) => {
     if (historyItem.id === item.id) {
-      flag = true
+      flag = true;
     }
-  })
+  });
   if (!flag) {
-    historySearch.push(item)
+    historySearch.push(item);
   }
-  setLocalStorage(Keys.historySearchSpaceKey, historySearch)
-}
+  setLocalStorage(Keys.historySearchSpaceKey, historySearch);
+};
 
 /**
  * 获取搜索页面最近查找的数据
  */
 export const getLocalSearchSpace = function () {
-  return getLocalStorage(Keys.historySearchSpaceKey) ? getLocalStorage(Keys.historySearchSpaceKey) : []
-}
+  return getLocalStorage(Keys.historySearchSpaceKey)
+    ? getLocalStorage(Keys.historySearchSpaceKey)
+    : [];
+};
 
 /**
  *存储当前项目id
  */
 export const setLocalProjectId = function (projectId: any) {
-  setLocalStorage(Keys.projectId, projectId)
-}
+  setLocalStorage(Keys.projectId, projectId);
+};
 
 /**
  * 获取当前项目id
  * @param projectId
  */
 export const getLocalProjectId = function () {
-  return localStorage.getItem(Keys.projectId)
-}
+  return localStorage.getItem(Keys.projectId);
+};
 /**
  * 清楚当前所有的存储数据
  */
 export const clearAllLocalData = function () {
-  localStorage.clear()
-  Cookies.remove('userInfo')
-  Cookies.remove('projectId')
-  Cookies.remove('accessToken')
-}
+  localStorage.clear();
+  Cookies.remove('userInfo');
+  Cookies.remove('projectId');
+  Cookies.remove('accessToken');
+};
 
 export const doHandleMonth = function (month: any) {
-  let m: any = month
+  let m: any = month;
   if (month.toString().length == 1) {
-    m = '0' + month
+    m = '0' + month;
   }
-  return m
-}
+  return m;
+};
 
 export const getWeekDate = function (day: any) {
-  let weeks: any = new Array(
-    '周日',
-    '周一',
-    '周二',
-    '周三',
-    '周四',
-    '周五',
-    '周六'
-  )
-  let week: any = weeks[day]
-  return week
-}
+  let weeks: any = new Array('周日', '周一', '周二', '周三', '周四', '周五', '周六');
+  let week: any = weeks[day];
+  return week;
+};
 
 export const getNowWeek = function () {
-  let date: any = new Date()
-  let day: any = date.getDay()
-  let nowWeek: any = getWeekDate(day)
-  return nowWeek
-}
+  let date: any = new Date();
+  let day: any = date.getDay();
+  let nowWeek: any = getWeekDate(day);
+  return nowWeek;
+};
 
 export const getDate = function (date: any) {
-  return date.getDate() < 10 ? '0' + date.getDate() : date.getDate()
-}
+  return date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
+};
 
 /**
  * 初始化24:00
  */
 export const getTimers = function () {
-  let timers: any = new Array()
+  let timers: any = new Array();
   for (let i = 0; i <= 24; i++) {
-    let str: any = '00'
+    let str: any = '00';
     if (i < 10) {
-      str = '0' + i
+      str = '0' + i;
     } else {
-      str = i
+      str = i;
     }
-    timers.push(str + ':00')
+    timers.push(str + ':00');
     if (i < 24) {
-      timers.push(str + ':30')
+      timers.push(str + ':30');
     }
   }
-  console.log("timers====")
-  console.log(timers)
-  return timers
-}
+  console.log('timers====');
+  console.log(timers);
+  return timers;
+};
 
 export const getNowTime = function () {
-  let date: any = new Date()
-  let hours: any = date.getHours()
-  let minute: any = date.getMinutes()
-  let index: any = date.getHours()
+  let date: any = new Date();
+  let hours: any = date.getHours();
+  let minute: any = date.getMinutes();
+  let index: any = date.getHours();
   if (minute < 30) {
-    hours = hours + ':' + '00'
-    index = index * 2
+    hours = hours + ':' + '00';
+    index = index * 2;
   } else {
-    hours = hours + ':' + '30'
-    index = index * 2 + 1
+    hours = hours + ':' + '30';
+    index = index * 2 + 1;
   }
-  return [hours, index]
-}
+  return [hours, index];
+};
 
 // 获取当前真实时间
 export const getRelNowTime = function () {
-  let date: any = new Date()
-  let hours: any = date.getHours()
-  let minute: any = date.getMinutes()
+  let date: any = new Date();
+  let hours: any = date.getHours();
+  let minute: any = date.getMinutes();
   if (hours < 10) {
-    hours = "0" + hours
+    hours = '0' + hours;
   }
   if (minute < 10) {
-    minute = "0" + minute
+    minute = '0' + minute;
   }
-  return hours + "" + minute + "00"
-}
+  return hours + '' + minute + '00';
+};
 
 /**
  * 19000转成19:00
  */
 export const formatTimerStr = function (timer: any) {
   if (timer) {
-    let str: any = (timer / 10000).toFixed(2)
-    str = str.replace(".", ":")
-    return str
+    let str: any = (timer / 10000).toFixed(2);
+    str = str.replace('.', ':');
+    return str;
   } else {
-    return ''
+    return '';
   }
-}
+};
 
 export const newNumber = function (start: any, end: any, masAddess: any) {
-  return masAddess + "" + Math.round(Math.random() * (end - start) + start);//生成在[start,end]范围内的随机数值,只支持不小于0的合法范围
-}
+  return masAddess + '' + Math.round(Math.random() * (end - start) + start); //生成在[start,end]范围内的随机数值,只支持不小于0的合法范围
+};
 
-export const formateTimeContinuous: any = function (index: any = 1,
+export const formateTimeContinuous: any = function (
+  index: any = 1,
   startTime: any,
   endTime: any,
-  type: any = 1, data: any = [], that: any) {
-  let todayDate: any = new Date()
-  let tomorrowData = new Date(todayDate.setTime(todayDate.getTime() + 24 * 60 * 60 * 1000))
-  let nowDate: any = formatDate("YYYY-MM-DD");
-  let tomorrowDate: any = formatDate("YYYY-MM-DD", tomorrowData);
+  type: any = 1,
+  data: any = [],
+  that: any
+) {
+  let todayDate: any = new Date();
+  let tomorrowData = new Date(todayDate.setTime(todayDate.getTime() + 24 * 60 * 60 * 1000));
+  let nowDate: any = formatDate('YYYY-MM-DD');
+  let tomorrowDate: any = formatDate('YYYY-MM-DD', tomorrowData);
   data.map((item: any) => {
     // debugger
     let date: any = formatDateStr(item.date);
     let week: any = getWeekDate(new Date(date).getDay());
     if (date == nowDate) {
-      week = '今日'
+      week = '今日';
     } else if (date == tomorrowDate) {
-      week = '次日'
+      week = '次日';
     }
     item.week = week;
   });
   // debugger
-  let text: any = "";
+  let text: any = '';
   // 工作时间和第二天连续的问题
   // 工作时间连续的问题
   let cusStartTime: any = data[index].cusStartTime;
   let cusEndTime: any = data[index].cusEndTime;
   if (type === 1) {
     // debugger;
-    if (endTime === "240000") {
+    if (endTime === '240000') {
       // 处理时间连续的问题
       let customSceneList: any = data[index]?.customSceneList ?? [];
-      if (cusStartTime === "000000") {
+      if (cusStartTime === '000000') {
         text = data[index].week;
         endTime = cusEndTime;
       }
       customSceneList.map((item: any) => {
-        if (item.startTime === "000000") {
+        if (item.startTime === '000000') {
           text = data[index].week;
           endTime = item.endTime;
         } else if (endTime === item.startTime) {
@@ -586,7 +587,7 @@ export const formateTimeContinuous: any = function (index: any = 1,
       });
       if (text) {
         let nowIndex: any = index + 1;
-        that.text = text
+        that.text = text;
         if (nowIndex < data.length - 1) {
           return formateTimeContinuous(nowIndex, startTime, endTime, 1, data, that);
         } else {
@@ -612,51 +613,51 @@ export const formateTimeContinuous: any = function (index: any = 1,
     }
   } else {
     // 预约时候后找最近的一段预约时间
-    let nowTime: any = (getNowTime()[0]).replace(":", "") + "00"
+    let nowTime: any = getNowTime()[0].replace(':', '') + '00';
     let customSceneList: any = data[index]?.customSceneList ?? [];
     customSceneList.map((item: any) => {
       if (index === 0) {
         if (nowTime < item.startTime) {
           if (!startTime || !endTime) {
-            startTime = item.startTime
-            endTime = item.endTime
-            text = data[index].week
+            startTime = item.startTime;
+            endTime = item.endTime;
+            text = data[index].week;
           }
         }
       } else {
         if (!startTime || !endTime) {
-          startTime = item.startTime
-          endTime = item.endTime
-          text = data[index].week
+          startTime = item.startTime;
+          endTime = item.endTime;
+          text = data[index].week;
         } else {
           // debugger
           // debugger
           if (endTime == '240000') {
-            if (item.startTime == "000000") {
-              endTime = item.endTime
-              text = data[index].week
+            if (item.startTime == '000000') {
+              endTime = item.endTime;
+              text = data[index].week;
             }
           } else {
             if (endTime === item.startTime) {
-              endTime = item.endTime
-              text = data[index].week
+              endTime = item.endTime;
+              text = data[index].week;
             }
           }
         }
       }
       if (that.text) {
-        let startText: any = that.text.split("~")[0]
-        that.text = startText
+        let startText: any = that.text.split('~')[0];
+        that.text = startText;
         if (text && text != startText) {
-          that.text = startText + "~" + text
+          that.text = startText + '~' + text;
         }
       } else {
-        that.text = text
+        that.text = text;
       }
-    })
+    });
     if (startTime && endTime) {
       if (endTime == '240000') {
-        let nowIndex: any = index + 1
+        let nowIndex: any = index + 1;
         if (nowIndex < data.length - 1) {
           return formateTimeContinuous(nowIndex, startTime, endTime, 2, data, that);
         } else {
@@ -674,7 +675,7 @@ export const formateTimeContinuous: any = function (index: any = 1,
         };
       }
     } else {
-      let nowIndex: any = index + 1
+      let nowIndex: any = index + 1;
       if (nowIndex < data.length - 1) {
         return formateTimeContinuous(nowIndex, startTime, endTime, 2, data, that);
       } else {
@@ -686,7 +687,7 @@ export const formateTimeContinuous: any = function (index: any = 1,
       }
     }
   }
-}
+};
 
 export const fix: any = function (d: any) {
   if (parseInt(d) == d) return parseFloat(d);
@@ -709,11 +710,11 @@ export const fix: any = function (d: any) {
 
   d1 = d1 / len;
   return d1;
-}
+};
 
 // 自定义四舍五入
-export const customRound = (number: number) => {
- // 如果传入的是布尔值,直接返回
+export const customRound = (number: number, type: number = 10) => {
+  // 如果传入的是布尔值,直接返回
   if (typeof number === 'boolean') {
     return number;
   }
@@ -722,7 +723,7 @@ export const customRound = (number: number) => {
   if (number > 100) return 100;
 
   // 获取个位数
-  const remainder = number % 10;
+  const remainder = number % type;
   // 获取十位数的基数
   const base = number - remainder;
 
@@ -730,6 +731,6 @@ export const customRound = (number: number) => {
   if (remainder <= 4) {
     return base;
   } else {
-    return base + 10;
+    return base + type;
   }
-}
+};

+ 139 - 105
src/views/envmonitor/taiguv1/components/Lamp/LightMore.vue

@@ -6,45 +6,74 @@
           <img
             :src="lampData.isOpen ? lampOpenIcon : lampCloseIcon"
             alt=""
-            :style="lampData.isOpen ? { width: '58px', height: '62px' } : ''" />
+            :style="lampData.isOpen ? { width: '58px', height: '62px' } : ''"
+          />
         </div>
         <div class="light-name">{{ $t(`lamp.${lampData.lampStatusText}`) }}</div>
       </div>
       <div class="right">
-        <div class="control" :ref="setRef" @click="handleSwitch('isOpen', true)">{{ $t(`common.全开`) }}</div>
-        <div class="control" :ref="setRef" @click="handleSwitch('isOpen', false)">{{ $t(`common.全关`) }}</div>
+        <div
+          class="control"
+          :ref="setRef"
+          @click="handleSwitch('isOpen', true)"
+        >
+          {{ $t(`common.全开`) }}
+        </div>
+        <div
+          class="control"
+          :ref="setRef"
+          @click="handleSwitch('isOpen', false)"
+        >
+          {{ $t(`common.全关`) }}
+        </div>
       </div>
     </div>
-    <div class="light-middle" v-if="lampData.isOpen">
+    <div
+      class="light-middle"
+      v-if="lampData.isOpen"
+    >
       <div class="bright-slider">
         <Slider
           :min="min"
           :max="max"
+          type="light"
           v-model="lampData.brightValue"
           isFollow
           showValue
           suffixNormal
           suffix="%"
           @onStart="sendEvent(true)"
-          @onEnd="setLampStatus('brightValue')" />
+          @onEnd="setLampStatus('brightValue')"
+        />
       </div>
       <!-- <div class="temp-slider">
         <LampSlider v-model="lampData.colorTempValue" @onEnd="setLampStatus('colorTempValue')" />
       </div> -->
     </div>
 
-    <div class="divider" v-if="lampData.isOpen">
-      <img src="@/assets/svg/line.svg" alt="" />
+    <div
+      class="divider"
+      v-if="lampData.isOpen"
+    >
+      <img
+        src="@/assets/svg/line.svg"
+        alt=""
+      />
     </div>
 
     <div class="light-bottom">
-      <div class="item-box" :class="item.brightValue ? 'light-box-active' : ''" v-for="(item, index) in lampList">
+      <div
+        class="item-box"
+        :class="item.brightValue ? 'light-box-active' : ''"
+        v-for="(item, index) in lampList"
+      >
         <div class="name">{{ item.localName }}</div>
         <div style="width: 100rpx">
           <SwitchButton
             :loading="allLampStatus[item.id]?.loading"
             v-model="item.isOpen"
-            @change="sigleLampChange('isOpen', item, 'single')" />
+            @change="sigleLampChange('isOpen', item, 'single')"
+          />
         </div>
       </div>
     </div>
@@ -52,19 +81,21 @@
 </template>
 
 <script setup>
-import lampCloseIcon from "@/assets/taiguv1/svg/lamp_close_p_icon.svg"
-import lampOpenIcon from "@/assets/taiguv1/svg/lamp_open_p_icon.svg"
-import Slider from "@/components/slider/Slider.vue"
-import SwitchButton from "@/components/switch-button/SwitchButton.vue"
-import { computed, nextTick, onMounted, onUnmounted, ref, watch } from "vue"
-import eventBus from "@/utils/eventBus"
-import useDeviceControl from "@/hooks/useDeviceControl"
-import { useStore } from "@/store"
-const store = useStore()
-const deviceControl = useDeviceControl()
-const min = 0
-const max = 100
-let closeUpdate = false
+import lampCloseIcon from '@/assets/taiguv1/svg/lamp_close_p_icon.svg';
+import lampOpenIcon from '@/assets/taiguv1/svg/lamp_open_p_icon.svg';
+import Slider from '@/components/slider/Slider.vue';
+import SwitchButton from '@/components/switch-button/SwitchButton.vue';
+import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
+import eventBus from '@/utils/eventBus';
+import useDeviceControl from '@/hooks/useDeviceControl';
+import { customRound } from '@/utils';
+import { useStore } from '@/store';
+import { type } from 'os';
+const store = useStore();
+const deviceControl = useDeviceControl();
+const min = 0;
+const max = 100;
+let closeUpdate = false;
 // 接收父组件传递的初始状态
 const props = defineProps({
   lampStatus: {
@@ -72,31 +103,31 @@ const props = defineProps({
     default: () => {
       return {
         isOpen: false,
-        brightValue: 0
-      }
-    }
+        brightValue: 0,
+      };
+    },
   },
   equipList: {
     type: Array,
     default: () => {
-      return []
-    }
-  }
-})
+      return [];
+    },
+  },
+});
 
-const controlBtn = ref([])
-const setRef = el => {
+const controlBtn = ref([]);
+const setRef = (el) => {
   if (el) {
     if (!controlBtn.value.includes(el)) {
-      controlBtn.value.push(el)
+      controlBtn.value.push(el);
     }
   }
-}
+};
 
-const lampList = ref(props.equipList || [])
-const lampData = ref(props.lampStatus)
+const lampList = ref(props.equipList || []);
+const lampData = ref(props.lampStatus);
 
-const allLampStatus = computed(() => store.state.taiguv1.lampSwitchStatus)
+const allLampStatus = computed(() => store.state.taiguv1.lampSwitchStatus);
 
 // const lampSwitchStatus = computed(() => {
 //   let statusText = ''
@@ -118,126 +149,129 @@ watch(
   () => props.lampStatus,
   (newVal, oldVal) => {
     if (!newVal || closeUpdate) {
-      return
+      return;
     }
-    lampData.value = { ...newVal }
+    // newVal.brightValue = customRound(newVal.brightValue, 20);
+    lampData.value = { ...newVal };
   },
   { deep: true } // 添加深度监听
-)
+);
 watch(
   () => props.equipList,
   (newVal, oldVal) => {
     if (!newVal || closeUpdate) {
-      return
+      return;
     }
-    compareStatus(newVal)
+    compareStatus(newVal);
   },
   { deep: true }
-)
+);
 
 // 对比和store中开关状态
-const compareStatus = data => {
-  lampList.value = data.map(item => {
-    const currentStatus = allLampStatus.value[item.id]
-    let isOpen = item.brightValue !== 0
+const compareStatus = (data) => {
+  lampList.value = data.map((item) => {
+    const currentStatus = allLampStatus.value[item.id];
+    let isOpen = item.brightValue !== 0;
     // 基础状态对象
     const baseStatus = {
       ...item,
-      isOpen: isOpen
-    }
+      isOpen: isOpen,
+    };
 
     if (!currentStatus) {
-      return baseStatus
+      return baseStatus;
     }
 
     // 如果最后切换状态与当前运行状态相同,重置状态
     if (currentStatus.lastSwitchStatus == isOpen) {
-      store.dispatch("taiguv1/setLampStatus", {
+      store.dispatch('taiguv1/setLampStatus', {
         id: item.id,
         status: {
           loading: false,
-          lastSwitchStatus: null
-        }
-      })
-      return baseStatus
+          lastSwitchStatus: null,
+        },
+      });
+      return baseStatus;
     }
 
     // 如果有待处理的切换状态,使用该状态
     return {
       ...item,
-      isOpen: currentStatus.lastSwitchStatus ?? isOpen
-    }
-  })
-}
+      isOpen: currentStatus.lastSwitchStatus ?? isOpen,
+    };
+  });
+};
 // 整体开关
 const handleSwitch = (type, value) => {
-  lampData.value.isOpen = value
-  setLampStatus(type)
-}
+  lampData.value.isOpen = value;
+  setLampStatus(type);
+};
 
 // 单个开关
 const sigleLampChange = (type, source, all) => {
-  if (type == "isOpen") {
-    store.dispatch("taiguv1/setLampStatus", {
+  if (type == 'isOpen') {
+    store.dispatch('taiguv1/setLampStatus', {
       id: source.id,
       status: {
         loading: true,
-        lastSwitchStatus: source.isOpen
-      }
-    })
+        lastSwitchStatus: source.isOpen,
+      },
+    });
   }
-  if (all == "single") {
-    const params = deviceControl.assemblyLampCommand(source[type], type, source)
-    deviceControl.sendCommands(params)
+  if (all == 'single') {
+    const params = deviceControl.assemblyLampCommand(source[type], type, source);
+    deviceControl.sendCommands(params);
   }
-}
-const setLampStatus = type => {
-  if (type == "isOpen") {
-    store.dispatch("taiguv1/setLampStatus", {
-      id: "all",
+};
+const setLampStatus = (type) => {
+  if (type == 'isOpen') {
+    store.dispatch('taiguv1/setLampStatus', {
+      id: 'all',
       status: {
         loading: true,
-        lastSwitchStatus: lampData.value.isOpen
-      }
-    })
-    lampList.value.forEach(item => {
-      item.isOpen = lampData.value.isOpen
-      sigleLampChange(type, item, "all")
-    })
+        lastSwitchStatus: lampData.value.isOpen,
+      },
+    });
+    lampList.value.forEach((item) => {
+      item.isOpen = lampData.value.isOpen;
+      sigleLampChange(type, item, 'all');
+    });
+  }else {
+    lampData.value[type]=customRound(lampData.value[type],20)
   }
-  const params = deviceControl.assemblyLampCommand(lampData.value[type], type, lampList.value)
+  const params = deviceControl.assemblyLampCommand(lampData.value[type], type, lampList.value);
   deviceControl.sendCommands(params, () => {
-    debouncedSendEvent(false)
-  })
-}
-const sendEvent = close => {
-  closeUpdate = close
-  eventBus.emit("close_deviece_timer", { close })
-}
-const debouncedSendEvent = deviceControl.debounce(sendEvent, 1500)
+    debouncedSendEvent(false);
+  });
+};
+const sendEvent = (close) => {
+  closeUpdate = close;
+  eventBus.emit('close_deviece_timer', { close });
+};
+const debouncedSendEvent = deviceControl.debounce(sendEvent, 1500);
 
 onMounted(() => {
   nextTick(() => {
-    controlBtn.value.forEach(button => {
-      button.addEventListener("touchstart", handleTouchStart)
-    })
-  })
-})
+    controlBtn.value.forEach((button) => {
+      button.addEventListener('touchstart', handleTouchStart);
+    });
+  });
+});
 
 // 添加 touchstart 处理函数
-const handleTouchStart = event => {
-  const button = event.currentTarget
-  button.classList.add("active")
+const handleTouchStart = (event) => {
+  const button = event.currentTarget;
+  button.classList.add('active');
   setTimeout(() => {
-    button.classList.remove("active")
-  }, 200)
-}
+    button.classList.remove('active');
+  }, 200);
+};
 // 添加 onUnmounted 钩子
 onUnmounted(() => {
-  controlBtn.value.forEach(button => {
-    button.removeEventListener("touchstart", handleTouchStart)
-  })
-})
+  controlBtn.value.forEach((button) => {
+    button.removeEventListener('touchstart', handleTouchStart);
+  });
+});
 </script>
 <style lang="scss" scoped>
 .more-box {

+ 6 - 1
src/views/envmonitor/taiguv1/components/Lamp/index.vue

@@ -25,7 +25,7 @@
           <div class="status">{{ $t(`lamp.${lampData.lampStatusText}`) }}</div>
         </div>
 
-        <div class="bottom-right" v-if="lampData.isOpen">{{ lampData.brightValue || 0 }} <sup>%</sup></div>
+        <div class="bottom-right" v-if="lampData.isOpen">{{ customRound(lampData.brightValue,20) || 0 }} <sup>%</sup></div>
       </div>
 
       <div class="lamp-slider" v-if="lampData.isOpen">
@@ -45,10 +45,12 @@ import FilterIcon from "@/assets/taiguv1/svg/filter_icon.svg"
 import Slider from "@/components/slider/Slider.vue"
 import SwitchButton from "@/components/switch-button/SwitchButton.vue"
 import useDeviceControl from "@/hooks/useDeviceControl"
+import { customRound } from "@/utils"
 import { useStore } from "@/store"
 import { parseImgUrl } from "@/utils"
 import { computed, ref, watch } from "vue"
 import eventBus from "@/utils/eventBus"
+import { constants } from 'fs';
 const min = 0
 const max = 100
 let closeUpdate = false
@@ -103,6 +105,7 @@ const compareStatus = data => {
       ...data,
       isOpen: data.isOpen
     }
+    console.log("data==",data);
   }
   if (allLampStatus.value.all) {
     if (allLampStatus.value.all.lastSwitchStatus == data.isOpen) {
@@ -145,6 +148,8 @@ const setLampStatus = type => {
         lastSwitchStatus: lampData.value.isOpen
       }
     })
+  }else{
+    lampData.value[type]=customRound(lampData.value[type],20)
   }
 
   sendEvent(true)