seTable.vue 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <template>
  2. <el-table ref="initList" :data="initList" height="11.11111vh" @row-click="clickData" highlight-current-row @cell-mouse-enter="mouseEnter" @cell-mouse-leave="mouseLeave">
  3. <el-table-column label="告警时间" align="center" prop="time" show-overflow-tooltip />
  4. <el-table-column label="告警内容" align="center" prop="evtname" show-overflow-tooltip />
  5. <el-table-column label="告警类型" align="center" prop="dwtype" show-overflow-tooltip >
  6. <template slot-scope="scope">
  7. <span>{{scope.row.dwtype == "1" ? "用户传输装置" : scope.row.dwtype == "2" ? "喷淋水压" :
  8. scope.row.dwtype == "2" ? "喷淋水压" : scope.row.dwtype == "5" ? "消防水箱液位" :
  9. scope.row.dwtype == "6" ? "RTU" : scope.row.dwtype == "16" ? "消防视频监控" : "其它"}}</span>
  10. </template>
  11. </el-table-column>
  12. <el-table-column label="告警状态" align="center" prop="evt" show-overflow-tooltip >
  13. <template slot-scope="scope">
  14. <span :class="scope.row.evt ? 'handle' : 'untreated'">{{scope.row.evt ? "已处理" : "未处理"}}</span>
  15. </template>
  16. </el-table-column>
  17. </el-table>
  18. </template>
  19. <script>
  20. export default {
  21. data() {
  22. return {
  23. initList:[],
  24. table_interval:null,
  25. };
  26. },
  27. created(){
  28. this.initData();
  29. },
  30. mounted() {},
  31. methods: {
  32. //初始化数据
  33. initData() {
  34. let that = this
  35. let num = 0
  36. let wsUri = "wss://iot.usky.cn:55120";
  37. try {
  38. let websocket = new WebSocket(wsUri);
  39. websocket.onopen = function(evt) {
  40. let json = {};
  41. json.agentid = 'admin';
  42. websocket.send(JSON.stringify(json));
  43. };
  44. websocket.onclose = function(evt) {
  45. this.initWebSocket();
  46. };
  47. websocket.onmessage = function(evt) {
  48. let warningInfo = eval('(' + evt.data + ')');
  49. if(warningInfo.dwtype){
  50. that.initList.push(warningInfo)
  51. if(num == '0'){
  52. if(that.initList.length>2){
  53. that.dataScrolling();
  54. num = 1
  55. }
  56. }
  57. }
  58. };
  59. websocket.onerror = function(evt) {
  60. // console.log("Error:", evt.data);
  61. (function() {})()
  62. };
  63. } catch (exception) {
  64. // console.log("Exception:", exception);
  65. (function() {})()
  66. }
  67. that.dataScrolling();
  68. },
  69. //数据滚动
  70. dataScrolling:function(){
  71. let top=this.$refs.initList.bodyWrapper;
  72. this.table_interval=setInterval(() => {
  73. top.scrollTop+=1;
  74. if(top.clientHeight+top.scrollTop==top.scrollHeight){
  75. top.scrollTop=0;
  76. }
  77. }, 100);
  78. },
  79. //鼠标进入,停止滚动
  80. mouseEnter:function(){
  81. clearInterval(this.table_interval);
  82. this.table_interval=null;
  83. },
  84. //鼠标离开,开始滚动
  85. mouseLeave:function(){
  86. this.dataScrolling();
  87. },
  88. //点击行
  89. clickData(row, event, column){
  90. },
  91. cellStyle (row, column, rowIndex, columnIndex) {
  92. //列的label的名称
  93. if (row.column.label === "告警" || row.column.label === "离线") {
  94. return 'color:#2280D9' //修改的样式
  95. }
  96. },
  97. },
  98. };
  99. </script>
  100. <style scoped>
  101. /*最外层透明*/
  102. .el-table{
  103. height:11.11111vh !important;
  104. }
  105. </style>