index.vue 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. <template>
  2. <div class="c-record-dashboard">
  3. <div
  4. class="c-record-dashboard__main"
  5. :style="style"
  6. >
  7. <DeviceInfo
  8. v-if="showDeviceInfo"
  9. :device="currentDeviceInfo"
  10. @fullscreenChange="onDeviceInfoClose"
  11. />
  12. <AlarmInfo
  13. v-if="showAlarmInfo"
  14. :alarm="currentAlarmInfo"
  15. @fullscreenChange="onAlarmInfoClose"
  16. />
  17. <DeviceSort
  18. v-if="showDeviceSort"
  19. :list="deviceList"
  20. @fullscreenChange="onDeviceSortClose"
  21. @save="onDeviceSortSave"
  22. />
  23. <LinkState
  24. v-if="showLinkState"
  25. :device="currentLinkState"
  26. @fullscreenChange="onLinkStateClose"
  27. />
  28. <Header />
  29. <div class="l-flex--col center">
  30. <div class="l-flex--row">
  31. <div class="l-flex--col l-flex__none">
  32. <div
  33. class="l-flex__none dashboard-item"
  34. style="width: 404px; height: 281px"
  35. >
  36. <DeviceStatus :items="statusData" />
  37. </div>
  38. <div
  39. class="l-flex__none dashboard-item"
  40. style="width: 404px; height: 281px"
  41. >
  42. <Map :device-list="deviceList" />
  43. </div>
  44. </div>
  45. <div class="l-flex--col l-flex__none">
  46. <div
  47. class="l-flex__none dashboard-item"
  48. style="width: 904px; height: 586px"
  49. >
  50. <Record
  51. ref="record"
  52. @openDeviceInfo="openDeviceInfo"
  53. @openDeviceSort="openDeviceSort"
  54. @openLinkState="openLinkState"
  55. />
  56. </div>
  57. </div>
  58. <div class="l-flex--col l-flex__none">
  59. <div
  60. class="l-flex__none dashboard-item"
  61. style="width: 404px; height: 281px"
  62. >
  63. <MessageNotice @openAlarmInfo="openAlarmInfo" />
  64. </div>
  65. <div
  66. class="l-flex__none dashboard-item"
  67. style="width: 404px; height: 281px"
  68. >
  69. <AlarmLevel :items="exceptionLevelStatisticArray" />
  70. </div>
  71. </div>
  72. </div>
  73. <div class="l-flex--row">
  74. <div class="l-flex--col l-flex__none">
  75. <div
  76. class="l-flex__none dashboard-item"
  77. style="width: 404px; height: 284px"
  78. >
  79. <AlarmType />
  80. </div>
  81. </div>
  82. <div class="l-flex--col l-flex__none">
  83. <div
  84. class="l-flex__none dashboard-item"
  85. style="width: 904px; height: 284px"
  86. >
  87. <DeviceCalender :device-list="deviceList" />
  88. </div>
  89. </div>
  90. <div class="l-flex--col l-flex__none">
  91. <div
  92. class="l-flex__none dashboard-item"
  93. style="width: 404px; height: 284px"
  94. >
  95. <AlarmRate />
  96. </div>
  97. </div>
  98. </div>
  99. </div>
  100. </div>
  101. </div>
  102. </template>
  103. <script>
  104. import {
  105. getDevices,
  106. getDeviceStatistics
  107. } from '@/api/device'
  108. import DeviceStatus from './DeviceStatus'
  109. import DeviceCalender from './DeviceCalender'
  110. import Map from './Map'
  111. import AlarmType from './AlarmType'
  112. import AlarmRate from './AlarmRate'
  113. import AlarmLevel from './AlarmLevel'
  114. import DeviceInfo from './DeviceInfo'
  115. import AlarmInfo from './AlarmInfo'
  116. import MessageNotice from './MessageNotice'
  117. import Record from './Record'
  118. import DeviceSort from './DeviceSort'
  119. import Header from './Header'
  120. import LinkState from './LinkState'
  121. export default {
  122. components: {
  123. DeviceSort,
  124. DeviceInfo,
  125. AlarmInfo,
  126. DeviceStatus,
  127. Map,
  128. AlarmType,
  129. AlarmRate,
  130. MessageNotice,
  131. Record,
  132. DeviceCalender,
  133. AlarmLevel,
  134. Header,
  135. LinkState
  136. },
  137. data () {
  138. return {
  139. loading: false,
  140. style: null,
  141. statusData: [
  142. { label: '设备总数', value: '-' },
  143. { label: '设备在线数', value: '-' },
  144. { label: '设备离线数', value: '-' },
  145. { label: '设备未启用数', value: '-' }
  146. ],
  147. exceptionLevelStatisticArray: [
  148. { label: '预警等级总数', value: '-' },
  149. { label: '紧急等级', value: '-' },
  150. { label: '提示等级', value: '-' },
  151. { label: '普通等级', value: '-' }
  152. ],
  153. deviceList: [],
  154. showDeviceInfo: false,
  155. currentDeviceInfo: null,
  156. showAlarmInfo: false,
  157. currentAlarmInfo: null,
  158. showDeviceSort: false,
  159. currentDeviceSort: null,
  160. showLinkState: false,
  161. currentLinkState: null
  162. }
  163. },
  164. created () {
  165. this.getDeviceStatistics()
  166. this.$timer = setInterval(this.getDeviceStatistics, 60000)
  167. },
  168. mounted () {
  169. this.checkScale()
  170. window.addEventListener('resize', this.checkScale)
  171. },
  172. beforeDestroy () {
  173. clearInterval(this.$timer)
  174. window.removeEventListener('resize', this.checkScale)
  175. },
  176. methods: {
  177. checkScale () {
  178. this.style = {
  179. transform: `scale(${window.innerWidth / 1920}, ${window.innerHeight / 1080})`
  180. }
  181. },
  182. openLinkState (item) {
  183. this.currentLinkState = item
  184. this.showLinkState = true
  185. },
  186. onLinkStateClose () {
  187. this.currentLinkState = null
  188. this.showLinkState = false
  189. },
  190. openDeviceInfo (item) {
  191. this.showDeviceInfo = true
  192. this.currentDeviceInfo = item
  193. },
  194. onDeviceInfoClose () {
  195. this.currentDeviceInfo = null
  196. this.showDeviceInfo = false
  197. },
  198. openDeviceSort () {
  199. this.showDeviceSort = true
  200. },
  201. onDeviceSortClose () {
  202. this.showDeviceSort = false
  203. },
  204. onDeviceSortSave (deviceList) {
  205. this.deviceList = deviceList
  206. this.showDeviceSort = false
  207. this.$refs.record.refresh()
  208. },
  209. openAlarmInfo (alarm) {
  210. this.currentAlarmInfo = alarm
  211. this.showAlarmInfo = true
  212. },
  213. onAlarmInfoClose () {
  214. this.currentAlarmInfo = null
  215. this.showAlarmInfo = false
  216. },
  217. getDeviceStatistics () {
  218. getDeviceStatistics().then(({ data }) => {
  219. const { deactivatedTotal, notConnectedTotal, offLineTotal, onLineTotal, total } = data
  220. this.statusData = [
  221. { label: '设备总数', value: total },
  222. { label: '设备在线数', value: onLineTotal },
  223. { label: '设备离线数', value: offLineTotal + notConnectedTotal },
  224. { label: '设备未启用数', value: deactivatedTotal }
  225. ]
  226. this.getDevices(total - deactivatedTotal)
  227. })
  228. },
  229. getDevices (total) {
  230. getDevices({
  231. pageNum: 1,
  232. pageSize: total,
  233. activate: 1
  234. }, { custom: true }).then(({ data }) => {
  235. this.deviceList = data
  236. })
  237. }
  238. }
  239. }
  240. </script>
  241. <style lang="scss" scoped>
  242. .c-record-dashboard {
  243. height: 100%;
  244. overflow: hidden;
  245. &__main {
  246. width: 1920px;
  247. height: 1080px;
  248. background: url("~@/assets/v0/bg.png");
  249. transform-origin: left top;
  250. }
  251. }
  252. .dashboard-item {
  253. & ~ & {
  254. margin-top: 24px;
  255. }
  256. }
  257. .l-flex--row {
  258. & ~ & {
  259. margin-top: 24px;
  260. }
  261. }
  262. .l-flex--col {
  263. & ~ & {
  264. margin-left: 24px;
  265. }
  266. }
  267. </style>