alarm.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <template>
  2. <!-- 设备数量 -->
  3. <div class="layout-1">
  4. <el-row :gutter="8">
  5. <el-col class="gutter-row item item1" :span="4" v-show="is_show" >
  6. <a href="javascript:void(0);" @click="search()">
  7. <div class="gutter-box" :style="item1Style">
  8. <div class="today-add">
  9. <span>总设备数量</span>
  10. </div>
  11. <div class="count">
  12. <div>
  13. <span class="number">
  14. <i class="el-icon-loading" v-if="showLoading"></i>
  15. <countTo v-else :startVal="startVal" :endVal="total" :duration="duration"></countTo>
  16. </span>
  17. </div>
  18. <span class="text">设备总数</span>
  19. </div>
  20. </div>
  21. </a>
  22. </el-col>
  23. <el-col class="gutter-row item item1" :span="4" v-for="(item,index) in list" :key="index" >
  24. <a href="javascript:void(0);" @click="search(item.id)">
  25. <div class="gutter-box" :style="item.style">
  26. <div class="today-add">
  27. <span>{{item.name}}设备数量</span>
  28. </div>
  29. <div class="count">
  30. <div>
  31. <span class="number">
  32. <i class="el-icon-loading" v-if="showLoading"></i>
  33. <countTo v-else :startVal="startVal" :endVal="item.total" :duration="duration"></countTo>
  34. </span>
  35. </div>
  36. <span class="text">{{item.name}}总数</span>
  37. </div>
  38. </div>
  39. </a>
  40. </el-col>
  41. </el-row>
  42. </div>
  43. </template>
  44. <script>
  45. import countTo from "vue-count-to";
  46. import { parseTime } from '@/utils'
  47. import viewDialog from "./component/viewDialog"
  48. import exportAlarm from "./component/exportAlarm"
  49. import exportDialog from "./component/exportDialog"
  50. import { action } from '@/directive/permission/index.js'
  51. export default {
  52. name: "alarm_realtimeAlarm",
  53. mixins: [exportAlarm],
  54. directives: { action },
  55. components: {
  56. countTo,
  57. },
  58. props:[
  59. 'countList',
  60. ],
  61. data() {
  62. return {
  63. duration: 3000,
  64. showLoading: true,
  65. startVal: 0,
  66. list:[],
  67. is_show:false,
  68. item1Style: { "background-color": "#32c5d2" },
  69. itemStyleList:[
  70. { "background-color": "#4caf50" },
  71. { "background-color": "#7ba7bd" },
  72. { "background-color": "#e7505a" },
  73. { "background-color": "#4cb563" },
  74. ]
  75. };
  76. },
  77. computed: {
  78. total: function() {
  79. let list = this.list;
  80. let total =0;
  81. list.forEach((item) => {
  82. total = total+item.total;
  83. });
  84. return total;
  85. },
  86. online: function() {
  87. return this.statusCount.alarm + this.statusCount.normal;
  88. }
  89. },
  90. created(){
  91. },
  92. mounted() {
  93. this.getEquTotal();
  94. },
  95. methods: {
  96. //获取设备类别
  97. getEquTotal(){
  98. this.$http.get("getTotalByEquipmentType").then(response => {
  99. this.list =[];
  100. let list =response.data;
  101. list.forEach((item,index,array)=>{
  102. item.style = this.itemStyleList[index];
  103. this.list.push(item);
  104. });
  105. this.is_show=true;
  106. });
  107. this.showLoading=false;
  108. },
  109. search(name)
  110. {
  111. this.$emit('eq_type',name)
  112. }
  113. },
  114. };
  115. </script>
  116. <style lang='scss' scoped>
  117. @import "./alarm.scss";
  118. </style>