infrared.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. <template>
  2. <div class="yui-tree-box">
  3. <project-item-tree @treeclick="treeclick" iconfontClass="el-icon-place"></project-item-tree>
  4. <div class="hui-tree-content">
  5. <div class="infrared box-background">
  6. <div class="infrared-box">
  7. <div class="infrared-center">
  8. <test-alarm ref="testAlarm" :type="1"></test-alarm>
  9. <div class="bim-box">
  10. <model type="infrared" fileId="10000754876737"></model>
  11. </div>
  12. </div>
  13. <div class="infrared-right">
  14. <div class="infrared-chart hui-flex">
  15. <div class="hui-chart-title">
  16. 统计分析
  17. </div>
  18. <div ref="chart1" class="hui-flex-box"></div>
  19. </div>
  20. <div class="infrared-list">
  21. <div class="alarm-table-box hui-flex">
  22. <div class="alarm-title">
  23. <div class="hui-chart-title">
  24. 周界报警
  25. </div>
  26. <div class="alarm-tr">
  27. <span class="tr-100">设备名称</span>
  28. <span class="tr-130">报警时间</span>
  29. <span class="tr-50">状态</span>
  30. </div>
  31. </div>
  32. <div class="hui-flex-box hui-no-tips" v-if="list.length === 0">
  33. <empty width="100" description="暂无进出记录"></empty>
  34. </div>
  35. <div class="alarm-table hui-flex-box" v-else>
  36. <div class="alarm-tr" v-for="(item,index) in list" :key="index">
  37. <span class="tr-100 hui-ellipsis">{{item.deviceName}}</span>
  38. <span class="tr-130">{{item.date}}</span>
  39. <span class="tr-50 tr-center">
  40. <span class="color-red" v-if="!item.state">报警中</span>
  41. <span class="color-blue" v-else-if="item.state === 1">处理中</span>
  42. <span class="color-green" v-else-if="item.state === 2">已处理</span>
  43. </span>
  44. </div>
  45. </div>
  46. </div>
  47. </div>
  48. </div>
  49. </div>
  50. </div>
  51. </div>
  52. </div>
  53. </template>
  54. <script>
  55. import projectItemTree from '@/components/common/projectItemTree'
  56. import testAlarm from '@/components/work/common/testAlarm'
  57. import model from '@/components/work/common/model'
  58. import {
  59. getDeviceAlarmList
  60. } from '@/httpApi/test'
  61. export default {
  62. data() {
  63. return {
  64. list: [],
  65. type: 2
  66. }
  67. },
  68. created() {
  69. this.init();
  70. },
  71. components: {
  72. testAlarm,
  73. projectItemTree,
  74. model
  75. },
  76. methods: {
  77. init(option) {
  78. let postData = {
  79. type: this.type, //1-周界报警
  80. projectId: this.$store.getters.project.id
  81. }
  82. if (option) postData = Object.assign(postData, option);
  83. getDeviceAlarmList(postData).then(res => {
  84. if (res.state) {
  85. this.list = res.data;
  86. let obj = {},
  87. list = [];
  88. for (let i = 0; i < this.list.length; i++) {
  89. if (!obj[this.list[i].deviceId]) {
  90. obj[this.list[i].deviceId] = 1;
  91. list.push({
  92. id: this.list[i].deviceId,
  93. name: this.list[i].deviceName,
  94. value: 0,
  95. })
  96. }
  97. list.find(node => node.id == this.list[i].deviceId).value++;
  98. }
  99. this.$nextTick(() => {
  100. this.chart(this.$refs.chart1, list.map(node => node.value), list.map(node =>
  101. node.name))
  102. })
  103. }
  104. })
  105. },
  106. treeclick(item) {
  107. let obj = item.id ? {
  108. projectItemTargetId: item.id
  109. } : {}
  110. if (this.$refs.testAlarm) this.$refs.testAlarm.init(obj);
  111. this.init(option);
  112. },
  113. chart(elem, data, x) {
  114. let chart = echarts.init(elem);
  115. let option = {
  116. tooltip: {
  117. show: true,
  118. trigger: 'axis',
  119. formatter: function() {
  120. return ''
  121. },
  122. backgroundColor: 'rgba(255,255,255,0)',
  123. borderWidth: 0,
  124. padding: 0,
  125. axisPointer: {
  126. lineStyle: {
  127. type: 'solid',
  128. color: '#4E5561',
  129. }
  130. }
  131. },
  132. grid: {
  133. left: '15',
  134. top: '25',
  135. right: '15',
  136. bottom: '5',
  137. containLabel: true
  138. },
  139. color: ['#1978E5'],
  140. xAxis: {
  141. type: 'category',
  142. data: x,
  143. axisLabel: {
  144. margin: 4,
  145. color: '#D0DEEE',
  146. fontSize: 10
  147. },
  148. boundaryGap: false,
  149. axisLine: {
  150. lineStyle: {
  151. color: '#6C8097'
  152. }
  153. },
  154. axisTick: {
  155. show: false
  156. }
  157. },
  158. yAxis: {
  159. type: 'value',
  160. axisLabel: {
  161. margin: 10,
  162. color: '#D0DEEE',
  163. fontSize: 10
  164. },
  165. splitLine: {
  166. show: true,
  167. lineStyle: {
  168. color: 'rgba(108,128,151,0.3)',
  169. type: 'dashed'
  170. }
  171. }
  172. },
  173. series: [{
  174. data: data,
  175. type: 'line',
  176. symbolSize: 6,
  177. areaStyle: {
  178. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  179. offset: 0,
  180. color: 'rgba(0,150,255,0.15)'
  181. },
  182. {
  183. offset: 1,
  184. color: 'rgba(0,150,255,0)'
  185. }
  186. ])
  187. },
  188. z: 99
  189. }, {
  190. data: data,
  191. type: 'line',
  192. showSymbol: false,
  193. label: {
  194. show: true,
  195. color: '#D0DEEE'
  196. },
  197. areaStyle: {
  198. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  199. offset: 0,
  200. color: 'rgba(0,150,255,0.15)'
  201. },
  202. {
  203. offset: 1,
  204. color: 'rgba(0,150,255,0)'
  205. }
  206. ])
  207. },
  208. z: 99
  209. }]
  210. };
  211. chart.setOption(option);
  212. },
  213. },
  214. }
  215. </script>
  216. <style lang="scss">
  217. .infrared {
  218. width: 100%;
  219. height: 100%;
  220. padding: 20px;
  221. overflow: auto;
  222. .infrared-box {
  223. width: 100%;
  224. height: 100%;
  225. min-width: 1100px;
  226. min-height: 699px;
  227. display: flex;
  228. }
  229. .infrared-center {
  230. flex: 1;
  231. width: 0;
  232. height: 100%;
  233. display: flex;
  234. flex-direction: column;
  235. }
  236. .infrared-right {
  237. height: 100%;
  238. width: 350px;
  239. margin-left: 12px;
  240. display: flex;
  241. flex-direction: column;
  242. }
  243. .infrared-chart {
  244. height: 306px;
  245. background: rgba(0, 4, 10, 0.3);
  246. padding: 20px;
  247. }
  248. .infrared-list {
  249. margin-top: 12px;
  250. background: rgba(0, 4, 10, 0.3);
  251. flex: 1;
  252. height: 0;
  253. }
  254. }
  255. </style>