瀏覽代碼

隧道模型

2545307760@qq.com 7 月之前
父節點
當前提交
325b0ade4c

+ 0 - 1
web/src/pinia/modules/screen.js

@@ -25,7 +25,6 @@ export const useScreenStore = defineStore('screen',() => {
 
 
     const setCurrentTunnel = (val) => {
     const setCurrentTunnel = (val) => {
         currentTunnel.value = val
         currentTunnel.value = val
-        console.log('执行2', currentTunnel.value)
     }
     }
     return {
     return {
         controllerData,
         controllerData,

+ 0 - 2
web/src/view/admin/tunnel/tunnel.vue

@@ -514,7 +514,6 @@ const getData = async() => {
     region.value = res.data
     region.value = res.data
   })
   })
   await queryTunnelList(searchData.value).then(res => {
   await queryTunnelList(searchData.value).then(res => {
-    console.log(res.data.list)
     tunnel.value = res.data.list
     tunnel.value = res.data.list
     total.value = res.data.total
     total.value = res.data.total
     searchData.value.pageInfo.page = res.data.page
     searchData.value.pageInfo.page = res.data.page
@@ -781,7 +780,6 @@ const lightBySn = ref()
 const tunnelDataPanel = (val) => {
 const tunnelDataPanel = (val) => {
   isDataPanel.value = true
   isDataPanel.value = true
   tunnelTimeData.value = val
   tunnelTimeData.value = val
-  console.log('数据面板',val)
   groupedBySn.value = tunnelTimeData.value.envData.reduce((acc, current) => {
   groupedBySn.value = tunnelTimeData.value.envData.reduce((acc, current) => {
     const { sn } = current
     const { sn } = current
     // 如果 acc(累加器)中没有当前 sn 对应的数组,则创建一个新的数组
     // 如果 acc(累加器)中没有当前 sn 对应的数组,则创建一个新的数组

+ 0 - 1
web/src/view/screen/components/chart.vue

@@ -95,7 +95,6 @@ watch(() => useScreen.currentTunnel, (newValue, oldValue) => {
 })
 })
 
 
 const yourMethod = (value) => {
 const yourMethod = (value) => {
-  console.log('Method called with:', value)
   chartLoading(value.envData)
   chartLoading(value.envData)
   // 你的逻辑代码
   // 你的逻辑代码
 }
 }

+ 0 - 1
web/src/view/screen/components/lightChart.vue

@@ -84,7 +84,6 @@ watch(() => useScreen.currentTunnel, (newValue, oldValue) => {
 })
 })
 
 
 const yourMethod = (value) => {
 const yourMethod = (value) => {
-  console.log('Method called with:', value)
   chartLoading(value.envData)
   chartLoading(value.envData)
   // 你的逻辑代码
   // 你的逻辑代码
 }
 }

+ 1 - 2
web/src/view/screen/components/map.vue

@@ -76,13 +76,13 @@ export default defineComponent({
       const list = useScreen.tunnelList
       const list = useScreen.tunnelList
       list.forEach(item => {
       list.forEach(item => {
         if (item.ID === id) {
         if (item.ID === id) {
-          console.log(item)
           dialogData.value = item
           dialogData.value = item
         }
         }
       })
       })
     }
     }
     const callParentMethod = () => {
     const callParentMethod = () => {
       useScreen.setCurrentTunnel(dialogData.value)
       useScreen.setCurrentTunnel(dialogData.value)
+      dialogVisible.value = false
     }
     }
     return {
     return {
       center,
       center,
@@ -128,6 +128,5 @@ export default defineComponent({
 .infoDialog{
 .infoDialog{
   width: 300px;
   width: 300px;
   height: 100px;
   height: 100px;
-
 }
 }
 </style>
 </style>

+ 150 - 3
web/src/view/screen/dataScreen.vue

@@ -92,8 +92,15 @@ import Map from './components/map.vue'
 import warnTitle from '@/assets/warnTitle.png'
 import warnTitle from '@/assets/warnTitle.png'
 import lightChart from './components/lightChart.vue'
 import lightChart from './components/lightChart.vue'
 import { queryTunnelList } from '@/api/tunnel'
 import { queryTunnelList } from '@/api/tunnel'
-import { reactive, onMounted } from 'vue'
+import {reactive, onMounted, ref, watch} from 'vue'
+// 单灯控制
+import { updateTunnelLamp } from "@/api/tunnel";
+// 四路控制
+import { deviceSwitch } from "@/api/device";
 import {useScreenStore} from "@/pinia/modules/screen";
 import {useScreenStore} from "@/pinia/modules/screen";
+import {ElMessage} from "element-plus";
+// 灯光数据
+const lampData = reactive({})
 const useScreen = useScreenStore()
 const useScreen = useScreenStore()
 
 
 const deviceList = reactive([
 const deviceList = reactive([
@@ -112,21 +119,161 @@ const condition = {
   regionId: 0,
   regionId: 0,
   userId: 1
   userId: 1
 }
 }
-const jumpScreen = (type) => {
-  console.log(type)
+
+// 存储模型数据
+let materialOne = reactive({})
+let materialTwo = reactive({})
+
+// 亮度调整
+const transparency = ref(0)
+const relayList = reactive([])
+const changeTransparency = (e) => {
+  let option = {
+    0: [0.8, 33, 1],
+    50: [0.5, 66, 2],
+    100: [0.2, 100, 3]
+  }
+  materialOne.opacity = option[e][0]
+  if (lampData.switchType === '单灯控制器') {
+    updateTunnelLamp({
+      id: lampData.ID,
+      tunnelSn: lampData.tunnelSn,
+      lampValue1: option[e][1]
+    }).then(res => {
+      if (res.code === 0) {
+        ElMessage.success('已发送')
+      }
+    })
+  } else {
+    let relay = relayList[0].deviceRelays
+    console.log(relayList[0])
+    for (let i = 0; i < relay.length; i++) {
+      relay[i].state = i < option[e][2];
+    }
+    for (let j = 0; j < relay.length; j++) {
+      deviceSwitch({
+        tunnelSn: lampData.tunnelSn,
+        radarId: relayList[0].radarId,
+        relayId: relay[j].relayId,
+        state: relay[j].state
+      }).then(res => {
+        if (res.code === 0) {
+          console.log('发送成功')
+        }
+      })
+    }
+  }
+}
+
+const transparencyTwo = ref(0)
+const changeTransparencyTwo = (e) => {
+  let option = {
+    0: [0.8, 33, 1],
+    50: [0.5, 66, 2],
+    100: [0.2, 100, 3]
+  }
+  materialTwo.opacity = option[e][0]
+  if (lampData.switchType === '单灯控制器') {
+    updateTunnelLamp({
+      id: lampData.ID,
+      tunnelSn: lampData.tunnelSn,
+      lampValue2: option[e][1]
+    }).then(res => {
+      if (res.code === 0) {
+        ElMessage.success('已发送')
+      }
+    })
+  } else {
+    let relay = relayList[1].deviceRelays
+    for (let i = 0; i < relay.length; i++) {
+      if (i < option[e][2]) {
+        relay[i].state = true
+      } else {
+        relay[i].state = false
+      }
+    }
+    for (let j = 0; j < relay.length; j++) {
+      deviceSwitch({
+        tunnelSn: lampData.tunnelSn,
+        radarId: relayList[1].radarId,
+        relayId: relay[j].relayId,
+        state: relay[j].state
+      }).then(res => {
+        if (res.code === 0) {
+          console.log('发送成功');
+        }
+      })
+    }
+  }
 }
 }
 
 
 const parentMethod = (e) => {
 const parentMethod = (e) => {
   console.log('子组件调用了')
   console.log('子组件调用了')
   console.log(e)
   console.log(e)
 }
 }
+
+const brightness = () => {
+  if (lampData.switchType === '单灯控制器') {
+    let val1 = lampData.lampValue1
+    let val2 = lampData.lampValue2
+    let judge = {
+      0:[0.8,0],
+      33: [0.8,0],
+      66: [0.5,50],
+      100: [0.2,100],
+    }
+    transparency.value = judge[val1][1]
+    transparencyTwo.value = judge[val1][1]
+    materialOne.opacity = judge[val1][0]
+    materialTwo.opacity = judge[val2][0]
+  } else if(lampData.switchType === '四路控制器') {
+    relayList.length = 0
+    lampData.devices.forEach(item => {
+      if (item.genre === 6) {
+        relayList.push(item)
+      }
+    })
+    let deviceLamp1 = relayList[0].deviceRelays
+    let deviceLamp2 = relayList[1].deviceRelays
+    let count1 = 0
+    let count2 = 0
+    deviceLamp1.forEach(item => {
+      item.state ? count1++ : count1
+    })
+    deviceLamp2.forEach(item => {
+      item.state ? count2++ : count2
+    })
+    let judgeWay = {
+      0: [0.8,0],
+      1: [0.8,0],
+      2: [0.5,50],
+      3: [0.2,100],
+      4: [0.2,100]
+    }
+    transparency.value = judgeWay[count1][1]
+    transparencyTwo.value = judgeWay[count2][1]
+    materialOne.opacity = judgeWay[count1][0]
+    materialTwo.opacity = judgeWay[count2][0]
+  }
+}
 onMounted(() => {
 onMounted(() => {
   queryTunnelList(condition).then(res => {
   queryTunnelList(condition).then(res => {
     if (res.code === 0) {
     if (res.code === 0) {
       useScreen.setTunnelList(res.data)
       useScreen.setTunnelList(res.data)
+      Object.assign(lampData, res.data.list[0])
+      brightness()
     }
     }
   })
   })
 })
 })
+
+watch(() => useScreen.currentTunnel, (newValue, oldValue) => {
+  yourMethod(newValue) // 调用你的方法
+})
+
+const yourMethod = (value) => {
+  Object.assign(lampData, value)
+  brightness()
+}
 </script>
 </script>
 
 
 <style scoped lang="less">
 <style scoped lang="less">