index.vue 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <template>
  2. <div class="_energy">
  3. <layout>
  4. <template #left>
  5. <div style="height: 100%;display: flex;flex-direction: column;overflow: hidden;">
  6. <deviceList :resultData="leftData.IlluminatingDevice" />
  7. </div>
  8. </template>
  9. <template #content>
  10. <!-- <p>景观照明</p> -->
  11. </template>
  12. <template #right>
  13. <div style="height: 100%;display: flex;flex-direction: column;overflow: hidden;">
  14. <running :resultData="leftData" style="flex: 1;" />
  15. <switchAll :resultData="leftData.RunAnalyse" style="flex: 1;" />
  16. <eventList :resultData="leftData.EventList?.alarm" style="flex: 1;" />
  17. </div>
  18. </template>
  19. </layout>
  20. </div>
  21. </template>
  22. <script setup name="Role">
  23. import { getIlluminating } from "@/api/system/illuminating"
  24. import layout from "@/components/layout_/index.vue";
  25. import deviceList from './modules/deviceList.vue'
  26. import running from './modules/running.vue'
  27. import eventList from './modules/eventList.vue'
  28. import switchAll from './modules/switchAll.vue'
  29. const route = useRoute()
  30. const intervalId = ref(null)
  31. const leftData = ref({})
  32. // 生命周期
  33. onMounted(() => {
  34. getIlluminatingData()
  35. });
  36. onUnmounted(() => {
  37. clearInterval(intervalId.value);
  38. })
  39. function getIlluminatingData() {
  40. clearInterval(intervalId.value);
  41. getIlluminating().then((res) => {
  42. if (res.code == 200) {
  43. leftData.value = res.data
  44. if (route.path == '/system/sceneLighting') {
  45. intervalId.value = setInterval(getIlluminatingData, 10000);
  46. } else {
  47. clearInterval(intervalId.value);
  48. }
  49. }
  50. }).catch(() => {
  51. if (route.path == '/system/sceneLighting') {
  52. intervalId.value = null
  53. getIlluminatingData()
  54. }
  55. })
  56. }
  57. </script>
  58. <style lang="scss">
  59. ._energy {
  60. height: 100%;
  61. }
  62. </style>