Geen omschrijving

dangerDetail.vue 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <div class="dashboard-editor-container">
  3. <el-card class="box-card block-group">
  4. <div slot="header" class="block-title">
  5. <span>{{alarmTime}}</span>
  6. <span>{{alarmTit}}</span>
  7. </div>
  8. <el-row class="line-chart-box">
  9. <el-col :xs="24" :sm="24" :lg="24" v-for="(item, index) in alarmShowList" :key="item.index">
  10. <lineChart :chartData="item.data" :startTime="item.stime" :legendName="'传感器' + item.seq" :lineColor="index" :intervalTime="intervalTime"></lineChart>
  11. </el-col>
  12. </el-row>
  13. <div class="pagination-container">
  14. <el-pagination
  15. background
  16. @current-change="handleCurrentChange"
  17. :current-page.sync="pageNo"
  18. :page-size="pageSize"
  19. layout="prev, pager, next, jumper"
  20. :total="alarmList.length">
  21. </el-pagination>
  22. </div>
  23. </el-card>
  24. </div>
  25. </template>
  26. <script>
  27. import { urlParse, parseTime } from '@/utils'
  28. import { getDangerDetail, setUnreadToRead } from '@/api/bridgeInfo'
  29. import lineChart from '../lineChart/LineChart'
  30. export default {
  31. data() {
  32. return {
  33. alarmId: '',
  34. alarmTit: '',
  35. alarmRead: false,
  36. alarmList: [],
  37. pageSize: 6,
  38. pageNo: 1,
  39. intervalTime: 3 * 1000
  40. }
  41. },
  42. components: {
  43. lineChart
  44. },
  45. created() {
  46. this.alarmId = urlParse('aid')
  47. this.alarmTit = urlParse('msg')
  48. this.alarmRead = urlParse('flag')
  49. this.getDangerDetail()
  50. if (this.alarmRead === 'false') {
  51. this.setUnreadToRead()
  52. }
  53. },
  54. computed: {
  55. alarmTime() {
  56. const alramM = this.alarmId.split('_')
  57. return parseTime(alramM[ alramM.length - 1], true)
  58. },
  59. alarmShowList() {
  60. return this.alarmList.slice((this.pageNo - 1) * this.pageSize, this.pageNo * this.pageSize)
  61. }
  62. },
  63. methods: {
  64. getDangerDetail() {
  65. const param = {
  66. aid: this.alarmId
  67. }
  68. getDangerDetail(param).then(res => {
  69. if (res.success && res.data) {
  70. for (let i = 0; i < res.data.length; i++) {
  71. const arr = JSON.parse('[' + String(res.data[i].data.split(',')) + ']')
  72. res.data[i].data = arr
  73. }
  74. this.alarmList = res.data
  75. }
  76. })
  77. },
  78. setUnreadToRead() {
  79. const param = {
  80. aid: this.alarmId
  81. }
  82. setUnreadToRead(param).then(res => {
  83. })
  84. },
  85. handleCurrentChange(val) {
  86. this.pageNo = val
  87. }
  88. }
  89. }
  90. </script>
  91. <style rel="stylesheet/scss" lang="scss" scoped>
  92. .dashboard-editor-container .block-group .block-title{
  93. justify-content: flex-start;
  94. span{
  95. margin-right: 15px;
  96. }
  97. }
  98. </style>