vrv.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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="vrv box-background">
  6. <div class="vrv-box">
  7. <div class="vrv-center">
  8. <test-alarm ref="testAlarm" :type="24"></test-alarm>
  9. <div class="bim-box">
  10. <model type="vrv" fileId="10000786668082"></model>
  11. </div>
  12. </div>
  13. <div class="vrv-right">
  14. <div class="vrv-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="vrv-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: 25
  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,
  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(
  101. node =>
  102. node.name))
  103. })
  104. }
  105. })
  106. },
  107. treeclick(item) {
  108. let obj = item.id ? {
  109. projectItemTargetId: item.id
  110. } : {}
  111. if (this.$refs.testAlarm) this.$refs.testAlarm.init(obj);
  112. this.init(obj);
  113. },
  114. chart(elem, data, x) {
  115. let chart = echarts.init(elem);
  116. let option = {
  117. tooltip: {
  118. show: true,
  119. trigger: 'axis',
  120. formatter: function() {
  121. return ''
  122. },
  123. backgroundColor: 'rgba(255,255,255,0)',
  124. borderWidth: 0,
  125. padding: 0,
  126. axisPointer: {
  127. lineStyle: {
  128. type: 'solid',
  129. color: '#4E5561',
  130. }
  131. }
  132. },
  133. grid: {
  134. left: '15',
  135. top: '25',
  136. right: '15',
  137. bottom: '5',
  138. containLabel: true
  139. },
  140. color: ['#1978E5'],
  141. xAxis: {
  142. type: 'category',
  143. data: x,
  144. axisLabel: {
  145. margin: 4,
  146. color: '#D0DEEE',
  147. fontSize: 10
  148. },
  149. boundaryGap: false,
  150. axisLine: {
  151. lineStyle: {
  152. color: '#6C8097'
  153. }
  154. },
  155. axisTick: {
  156. show: false
  157. }
  158. },
  159. yAxis: {
  160. type: 'value',
  161. axisLabel: {
  162. margin: 10,
  163. color: '#D0DEEE',
  164. fontSize: 10
  165. },
  166. splitLine: {
  167. show: true,
  168. lineStyle: {
  169. color: 'rgba(108,128,151,0.3)',
  170. type: 'dashed'
  171. }
  172. }
  173. },
  174. series: [{
  175. data: data,
  176. type: 'line',
  177. symbolSize: 6,
  178. areaStyle: {
  179. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  180. offset: 0,
  181. color: 'rgba(0,150,255,0.15)'
  182. },
  183. {
  184. offset: 1,
  185. color: 'rgba(0,150,255,0)'
  186. }
  187. ])
  188. },
  189. z: 99
  190. }, {
  191. data: data,
  192. type: 'line',
  193. showSymbol: false,
  194. label: {
  195. show: true,
  196. color: '#D0DEEE'
  197. },
  198. areaStyle: {
  199. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  200. offset: 0,
  201. color: 'rgba(0,150,255,0.15)'
  202. },
  203. {
  204. offset: 1,
  205. color: 'rgba(0,150,255,0)'
  206. }
  207. ])
  208. },
  209. z: 99
  210. }]
  211. };
  212. chart.setOption(option);
  213. },
  214. },
  215. }
  216. </script>
  217. <style lang="scss">
  218. .vrv {
  219. width: 100%;
  220. height: 100%;
  221. padding: 20px;
  222. overflow: auto;
  223. .vrv-box {
  224. width: 100%;
  225. height: 100%;
  226. min-width: 1100px;
  227. min-height: 699px;
  228. display: flex;
  229. }
  230. .vrv-center {
  231. flex: 1;
  232. width: 0;
  233. height: 100%;
  234. display: flex;
  235. flex-direction: column;
  236. }
  237. .vrv-right {
  238. height: 100%;
  239. width: 350px;
  240. margin-left: 12px;
  241. display: flex;
  242. flex-direction: column;
  243. }
  244. .vrv-chart {
  245. height: 306px;
  246. background: rgba(0, 4, 10, 0.3);
  247. padding: 20px;
  248. }
  249. .vrv-list {
  250. margin-top: 12px;
  251. background: rgba(0, 4, 10, 0.3);
  252. flex: 1;
  253. height: 0;
  254. }
  255. }
  256. </style>