detail.vue 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <a-card>
  3. <a-spin spinning="" >
  4. <a-tabs v-model:activeKey="state.tabsActive">
  5. <a-tab-pane
  6. v-for="item in state.tabs"
  7. :key="item.key"
  8. :tab="item.name"
  9. />
  10. </a-tabs>
  11. </a-spin>
  12. <OverView :deviceId="state.deviceId" :key="state.deviceId" v-if="state.tabsActive === '1'"/>
  13. <CloudView v-else-if="state.tabsActive === '2'"/>
  14. <DeviceShadow v-else-if="state.tabsActive === '3'" />
  15. <MsgTrack v-else-if="state.tabsActive === '4'" />
  16. <SubDevice @goDetail="goDetail" v-else-if="state.tabsActive === '5'" />
  17. <DeviceTag @goDetail="goDetail" v-else-if="state.tabsActive === '6'" />
  18. <Ota v-else-if="state.tabsActive === '7'" />
  19. <Live v-else-if="state.tabsActive === '8'" />
  20. </a-card>
  21. </template>
  22. <script lang="ts" setup >
  23. import { onMounted, reactive } from 'vue'
  24. import OverView from './components/overview.vue'
  25. import CloudView from './components/cloudview.vue'
  26. import DeviceShadow from './components/deviceShadow.vue'
  27. import MsgTrack from './components/msgTrack.vue'
  28. import SubDevice from './components/subDevice.vue'
  29. import DeviceTag from './components/deviceTag.vue'
  30. import Ota from './components/ota.vue'
  31. import Live from './components/live.vue'
  32. import { useRoute } from 'vue-router'
  33. import { DeviceContriller } from '@/controller'
  34. // const tabs = [
  35. // {
  36. // name: '概述',
  37. // key: '1'
  38. // },
  39. // {
  40. // name: '云端下发',
  41. // key: '2'
  42. // },
  43. // {
  44. // name: '设备影子',
  45. // key: '3'
  46. // },
  47. // {
  48. // name: '消息跟踪',
  49. // key: '4'
  50. // },
  51. // {
  52. // name: '子设备',
  53. // key: '5'
  54. // },
  55. // {
  56. // name: '标签',
  57. // key: '6'
  58. // },
  59. // {
  60. // name: 'OTA',
  61. // key: '7'
  62. // },
  63. // {
  64. // name: 'Live',
  65. // key: '8'
  66. // }
  67. // ]
  68. const route = useRoute()
  69. const deviceId = route.query.id as string
  70. const state = reactive({
  71. tabsActive: '1',
  72. spinning: false,
  73. deviceId: deviceId,
  74. deviceDetail: {},
  75. tabs: [
  76. {
  77. name: '概述',
  78. key: '1'
  79. },
  80. {
  81. name: '云端下发',
  82. key: '2'
  83. },
  84. {
  85. name: '设备影子',
  86. key: '3'
  87. },
  88. {
  89. name: '消息跟踪',
  90. key: '4'
  91. },
  92. {
  93. name: '子设备',
  94. key: '5'
  95. },
  96. {
  97. name: '标签',
  98. key: '6'
  99. },
  100. {
  101. name: 'OTA',
  102. key: '7'
  103. },
  104. {
  105. name: 'Live',
  106. key: '8'
  107. }
  108. ]
  109. })
  110. const goDetail = ({ id }) => {
  111. state.tabsActive = '1'
  112. state.deviceId = id
  113. }
  114. const getDeviceById = async () => {
  115. state.spinning = true
  116. const deviceDetail = await DeviceContriller.byId(deviceId)
  117. state.deviceDetail = deviceDetail
  118. if (!deviceDetail.rtsUrl) {
  119. state.tabs.splice(7, 1)
  120. }
  121. state.spinning = false
  122. }
  123. onMounted(() => {
  124. getDeviceById()
  125. })
  126. </script>
  127. <style lang="less" scoped >
  128. </style>