index4.vue 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. <template>
  2. <el-table
  3. :data="resData"
  4. class="transparentTableRow scroll"
  5. height="280"
  6. :cell-class-name="tableRowClassName"
  7. :cell-style="cellStyle"
  8. style="margin-top:10px"
  9. >
  10. <el-table-column
  11. show-overflow-tooltip
  12. min-width="20"
  13. v-for="item in headerData"
  14. :key="item.prop"
  15. :prop="item.prop"
  16. align="left"
  17. :label="item.name"
  18. ></el-table-column>
  19. </el-table>
  20. </template>
  21. <script>
  22. export default {
  23. props: {
  24. resData: { type: Array, default: () => [] },
  25. headerData: { type: Array, default: () => [] },
  26. },
  27. data() {
  28. return {
  29. resData:[]
  30. };
  31. },
  32. mounted() {
  33. this.initWebSocket()
  34. },
  35. methods: {
  36. initWebSocket() {
  37. let arrData = [];
  38. let wsUri = "wss://iot.usky.cn:55120";
  39. try {
  40. // if (typeof MozWebSocket == 'function')
  41. // WebSocket = MozWebSocket;
  42. let websocket = new WebSocket(wsUri);
  43. websocket.onopen = function(evt) {
  44. var json = {};
  45. json.agentid = 'admin';
  46. websocket.send(JSON.stringify(json));
  47. };
  48. websocket.onclose = function(evt) {
  49. this.initWebSocket();
  50. };
  51. websocket.onmessage = function(evt) {
  52. var warningInfo = eval('(' + evt.data + ')');
  53. };
  54. websocket.onerror = function(evt) {
  55. (function() {})()
  56. };
  57. } catch (exception) {
  58. (function() {})()
  59. }
  60. },
  61. tableRowClassName({row, column, rowIndex, columnIndex}) {
  62. if (column.property === 'deathToll' && row.deathToll > 0) {
  63. return "death";
  64. }
  65. },
  66. cellStyle (row, column, rowIndex, columnIndex) {
  67. //列的label的名称
  68. if (row.column.label === "告警" || row.column.label === "离线") {
  69. return 'color:#2280D9' //修改的样式
  70. }
  71. },
  72. },
  73. };
  74. </script>
  75. <style>
  76. </style>