seTable.vue 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <template>
  2. <el-table ref="initList" :data="initList" height="200" @row-click="clickData" highlight-current-row @cell-mouse-enter="mouseEnter" @cell-mouse-leave="mouseLeave" v-loading="loading">
  3. <template slot="empty">
  4. <span>{{text}}</span>
  5. </template>
  6. <el-table-column label="时间" align="left" prop="alarmTime" show-overflow-tooltip min-width="35%" />
  7. <el-table-column label="内容" align="left" prop="property" show-overflow-tooltip min-width="25%"/>
  8. <el-table-column label="名称" align="left" prop="deviceName" show-overflow-tooltip min-width="25%"/>
  9. <el-table-column label="地点" align="left" prop="unitInfo" show-overflow-tooltip min-width="15%"/>
  10. </el-table>
  11. </template>
  12. <script>
  13. import axios from 'axios'
  14. export default {
  15. data() {
  16. return {
  17. initList:[],
  18. table_interval:null,
  19. text:"",
  20. loading:true,
  21. };
  22. },
  23. created(){
  24. this.initData();
  25. // this.timing()
  26. },
  27. mounted() {},
  28. methods: {
  29. //初始化数据
  30. initData() {
  31. axios({
  32. method: 'post',
  33. url: 'https://smartpark.caih.com/dmapi/tbAlarm/page',
  34. data:{
  35. current: 1,
  36. size: 100,
  37. type:1,
  38. },
  39. timeout: 3000,
  40. }).then(res =>{
  41. if(res.data.data.records){
  42. let data = res.data.data.records
  43. this.initList = data
  44. }
  45. this.loading = false
  46. this.text = "暂无数据"
  47. }).catch(err =>{
  48. this.loading = false
  49. this.text = "数据加载失败..."
  50. })
  51. },
  52. //数据滚动
  53. dataScrolling:function(){
  54. let top=this.$refs.initList.bodyWrapper;
  55. this.table_interval=setInterval(() => {
  56. top.scrollTop+=1;
  57. if(top.clientHeight+top.scrollTop==top.scrollHeight){
  58. top.scrollTop=0;
  59. }
  60. }, 100);
  61. },
  62. //鼠标进入,停止滚动
  63. mouseEnter:function(){
  64. // clearInterval(this.table_interval);
  65. // this.table_interval=null;
  66. },
  67. //鼠标离开,开始滚动
  68. mouseLeave:function(){
  69. // this.dataScrolling();
  70. },
  71. timing(){
  72. setInterval(() =>{
  73. this.initList = []
  74. },1000 * 60)
  75. },
  76. //点击行
  77. clickData(row){
  78. this.$emit("xfgjClick",row)
  79. },
  80. // cellStyle (row, column, rowIndex, columnIndex) {
  81. // //列的label的名称
  82. // if (row.column.label === "告警" || row.column.label === "离线") {
  83. // return 'color:#2280D9' //修改的样式
  84. // }
  85. // },
  86. },
  87. };
  88. </script>
  89. <style lang="scss" scoped>
  90. @import '@/assets/styles/common.scss';
  91. ::v-deep {
  92. .el-table__body-wrapper::-webkit-scrollbar {
  93. /*width: 0;宽度为0隐藏*/
  94. width: 4px;
  95. }
  96. .el-table__body-wrapper::-webkit-scrollbar-thumb {
  97. border-radius: 6px;
  98. height: 50px;
  99. background: $white;//滚动条颜色
  100. }
  101. .el-table__body-wrapper::-webkit-scrollbar-track {
  102. box-shadow: inset 0 0 5px rgba(35,40,49,1);
  103. border-radius: 6px;
  104. background: $modularBackGround;//滚动条背景色
  105. }
  106. }
  107. </style>