index.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <template>
  2. <el-row class="mianBox-af">
  3. <el-row class="headerBox">
  4. <el-col class="title">
  5. <img src="../../../assets/image-af/title1.png" alt="" />
  6. 设备工况
  7. </el-col>
  8. </el-row>
  9. <el-row class="contentBox">
  10. <el-col>
  11. <div ref="echartD1" class="echartD"></div>
  12. <div class="equipmentNumber greenNumber">{{resList.deviceTotal}}</div>
  13. <div class="equipmentName">设备总数</div>
  14. </el-col>
  15. <el-col>
  16. <div ref="echartD2" class="echartD"></div>
  17. <div class="equipmentNumber yellowNumber">{{resList.alarmTotal}}</div>
  18. <div class="equipmentName">告警次数</div>
  19. </el-col>
  20. <el-col>
  21. <div ref="echartD3" class="echartD"></div>
  22. <div class="equipmentNumber blueNumber">{{resList.unOnline}}</div>
  23. <div class="equipmentName">离线总数</div>
  24. </el-col>
  25. </el-row>
  26. </el-row>
  27. </template>
  28. <script>
  29. import * as echarts from "echarts";
  30. import echartsGet from "./echart";
  31. export default {
  32. props:['resInfo'],
  33. data() {
  34. return {
  35. isCheck: "info",
  36. option: null,
  37. resList:{}
  38. };
  39. },
  40. watch: {
  41. "$store.state.windowWidth"() {
  42. echarts.init(this.$refs.echartD1).resize();
  43. echarts.init(this.$refs.echartD2).resize();
  44. echarts.init(this.$refs.echartD3).resize();
  45. },
  46. resInfo(){
  47. this.getData()
  48. }
  49. },
  50. mounted(){
  51. this.getData()
  52. },
  53. methods: {
  54. async getData(){
  55. console.log(this.resInfo.apiAddr)
  56. let res = await this.$axios.get(this.resInfo.apiAddr + '?' +this.$qs.stringify({
  57. applicationCode: this.resInfo.applicationCode
  58. }))
  59. if(res.success){
  60. console.log(res)
  61. this.resList = res.data
  62. this.resList.alarmChart = (res.data.alarmList.reduce((next,res)=>{
  63. next.findIndex(val=>val.registerDeviceId === res.registerDeviceId) === -1 && next.push(res)
  64. return next
  65. },[]).length / this.resList.deviceTotal ).toFixed(2)
  66. this.enidCheck()
  67. }
  68. },
  69. enidCheck(){
  70. echarts.init(this.$refs.echartD1).setOption(echartsGet(1- this.resList.unOnline/this.resList.deviceTotal, ['rgba(47,255,91,0)',`rgba(47,255,91,.4)`,'rgba(47,255,91,1)',],'在线率'));
  71. echarts.init(this.$refs.echartD2).setOption(echartsGet(this.resList.alarmChart, ['rgba(225,199,47,0)','rgba(225,199,47,.4)','rgba(225,199,47,1)',],'告警率'));
  72. echarts.init(this.$refs.echartD3).setOption(echartsGet(this.resList.unOnline/this.resList.deviceTotal, ['rgba(5,60,125,0)','rgba(47,174,225,.4)', 'rgba(47,174,225,1)'],'离线率'));
  73. },
  74. },
  75. };
  76. </script>
  77. <style lang="scss" scoped>
  78. .mianBox-af {
  79. .contentBox{
  80. flex: 1;
  81. width: 100%;
  82. display: flex;
  83. justify-content: space-between;
  84. padding: 10px 0;
  85. overflow: hidden;
  86. .el-col{
  87. display: flex;
  88. flex-direction: column;
  89. align-items: center;
  90. justify-content: center;
  91. overflow: hidden;
  92. .echartD{
  93. flex: 1;
  94. width: 100%;
  95. height: 100%;
  96. min-height: 95px;
  97. }
  98. .equipmentNumber{
  99. width: 115px;
  100. height: 35px;
  101. font-size: 30px;
  102. font-weight: 700;
  103. color: #FFF;
  104. font-family: "DS", "DS-B", "DS-BB", "DS-BS";
  105. text-align: center;
  106. line-height: 35px;
  107. }
  108. .equipmentName{
  109. font-size: 14px;
  110. }
  111. .equipmentNumber.greenNumber{
  112. border-bottom: 2px solid #2FFF5B;
  113. background: linear-gradient(to bottom, transparent 0%,#2fff5b5c 100%);
  114. }
  115. .equipmentNumber.yellowNumber{
  116. border-bottom: 2px solid #FFC72F;
  117. background: linear-gradient(to bottom, transparent 0%,#e1c72f66 100%);
  118. }
  119. .equipmentNumber.blueNumber{
  120. border-bottom: 2px solid #2FAEFF;
  121. background: linear-gradient(to bottom, transparent 0%,#2faee166 100%);
  122. }
  123. }
  124. }
  125. }
  126. </style>