Browse Source

实时监控显示、历史监测进度条

luyanan 6 years ago
parent
commit
a37b4a61d1

+ 1 - 1
src/api/bridgeInfo.js

@ -61,7 +61,7 @@ export function setUnreadToRead(params) {
61 61
// 监测信息
62 62
export function getMonitorByDay(params) {
63 63
  return request({
64
    url: '/ajax/collect/wave/server/day',
64
    url: '/ajax/collect/wave/server/dayTime',
65 65
    method: 'get',
66 66
    params
67 67
  })

+ 9 - 3
src/views/bridgesConsole/bridgeDetail/index.vue

@ -29,6 +29,7 @@
29 29
        <el-card class="box-card block-group">
30 30
          <div slot="header" class="block-title">
31 31
            <span>实时监测</span>
32
            <el-button v-if="serverSeqArr.length" type="text" @click="updateDataList">刷新</el-button>
32 33
          </div>
33 34
          <el-row class="line-chart-box" v-if="monitorList.length">
34 35
            <el-col :xs="24" :sm="24" :lg="24" v-for="item in monitorShowList" :key="item.index">
@ -159,12 +160,17 @@ export default {
159 160
    if (this.bridgeId) {
160 161
      this.serverSeqArr = queryInfo.queryServers(this.bridgeId, true)
161 162
      if (this.serverSeqArr.length) {
162
        this.getSysTime()
163
        this.getDangerList()
163
        this.updateDataList()
164 164
      }
165 165
    }
166 166
  },
167 167
  methods: {
168
    updateDataList() {
169
      this.monitorList = []
170
      this.monitorCache = []
171
      this.getSysTime()
172
      this.getDangerList()
173
    },
168 174
    getDangerList() {
169 175
      var arr = this.serverSeqArr
170 176
      const param = {
@ -192,7 +198,7 @@ export default {
192 198
        if (res.success && res.data && res.data.length > 0) {
193 199
          // that.sysTime = res.data + that.eastEightDistrict - (5 * 60 * 1000)
194 200
          const nowt = parseTime(res.data[0].ctime, true, true)
195
          that.sysTime = (new Date(nowt)).getTime() + that.eastEightDistrict - 2 * 60 * 1000
201
          that.sysTime = (new Date(nowt)).getTime() + that.eastEightDistrict - 10 * 1000
196 202
          const localTime = new Date().getTime() + that.eastEightDistrict
197 203
          that.localTimeiv = localTime - that.sysTime
198 204
          that.first_Q = true

+ 70 - 20
src/views/bridgesConsole/bridgeMonitor/index.vue

@ -3,28 +3,35 @@
3 3
    <el-card class="box-card block-group">
4 4
      <div slot="header" class="block-title">
5 5
          <el-date-picker
6
            style="width: 200px;margin-right:15px"
6 7
            v-model="valueDate"
8
            :editable="false"
7 9
            type="date"
8 10
            value-format="yyyyMMdd"
9 11
            :picker-options="pickerOptions0"
10 12
            @change="changeDate">
11 13
          </el-date-picker>
12
          <!-- <el-date-picker
13
            v-model="dateRange"
14
            type="datetimerange"
15
            align="right"
16
            start-placeholder="开始日期"
17
            end-placeholder="结束日期"
18
            :default-time="['12:00:00', '08:00:00']">
19
          </el-date-picker> -->
14
          <el-select v-model="TimeVal">
15
            <el-option
16
              v-for="item in optionsTime"
17
              :key="item.value"
18
              :label="item.label"
19
              :value="item.value"
20
              @change="changeTimeRange">
21
            </el-option>
22
          </el-select>
20 23
          <el-button type="primary" @click="getMonitorByDay">查询</el-button>
21 24
      </div>
22
      <el-row class="line-chart-box" v-if="alarmList.length">
23
        <el-col :xs="24" :sm="24" :lg="24" v-for="item in alarmShowList" :key="item.index">
25
      <el-row class="line-chart-box">
26
        <el-col :xs="24" :sm="24" :lg="24" v-for="item in alarmShowList" :key="item.index" v-if="alarmList.length">
24 27
          <lineChart :chartData="item" :historyM="historyM"></lineChart>
25 28
        </el-col>
29
        <div class="progress-box" v-if="progressShow">
30
          <span>正在加载 {{proBar}}%</span>
31
          <el-progress :text-inside="true" :stroke-width="18" :percentage="proBar"></el-progress>
32
        </div>
26 33
      </el-row>
27
      <DefaultPage v-if="!alarmList.length"></DefaultPage>
34
      <DefaultPage v-if="!alarmList.length && !progressShow"></DefaultPage>
28 35
      <div class="pagination-container">
29 36
        <el-pagination
30 37
          background
@ -49,6 +56,7 @@ import { parseTime } from '@/utils'
49 56
import lineChart from '../lineChart/LineChart'
50 57
51 58
import DefaultPage from '@/components/DefaultPage'
59
import NProgress from 'nprogress'
52 60
53 61
export default {
54 62
  data() {
@ -60,13 +68,16 @@ export default {
60 68
          return time.getTime() > Date.now() - 8.64e7
61 69
        }
62 70
      },
63
      valueDate: this.formatTime((new Date()).getTime() + ((8 - 24) * 60 * 60 * 1000)),
64
      dateRange: '',
71
      valueDate: this.formatTime(Date.now() - 8.64e7).substring(0, 8),
72
      TimeVal: '000000',
73
      optionsTime: [],
65 74
      serverSeqArr: [],
66 75
      alarmList: [],
67 76
      monitorCache: [],
68 77
      pageSize: 2,
69
      pageNo: 1
78
      pageNo: 1,
79
      progressShow: false,
80
      proBar: 0
70 81
    }
71 82
  },
72 83
  components: {
@ -80,24 +91,54 @@ export default {
80 91
  },
81 92
  created() {
82 93
    this.bridgeId = Cookies.get('bridgeId')
94
    this.optionsCreat()
83 95
    this.serverSeqArr = queryInfo.queryServers(this.bridgeId, true)
84 96
    if (this.serverSeqArr.length) {
85 97
      this.getMonitorByDay()
86 98
    }
87 99
  },
88 100
  methods: {
101
    optionsCreat() {
102
      for (let i = 0; i < 24; i++) {
103
        var num = (i < 10 ? ('0' + i) : i)
104
        var oPt = {
105
          value: `${num}0000`,
106
          label: `${num}:00:00 - ${num}:59:59`
107
        }
108
        this.optionsTime.push(oPt)
109
      }
110
    },
89 111
    formatTime(time) {
90 112
      var d = new Date()
91 113
      d.setTime(time)
92
      d = JSON.stringify(d).replace(/[^\d]/g, '').substring(0, 8)
114
      d = JSON.stringify(d).replace(/[^\d]/g, '')
93 115
      return d
94 116
    },
117
    changeProgress() {
118
      var that = this
119
      var clearInt = setInterval(function() {
120
        that.proBar = that.proBar + parseInt((Math.random() * 10), 10)
121
        if (that.proBar >= 84) {
122
          that.proBar = 84
123
          clearInterval(clearInt)
124
        }
125
      }, 1000 * Math.random())
126
    },
95 127
    getMonitorByDay() {
128
      this.progressShow = true
129
      NProgress.start()
96 130
      var that = this
97
      var date = that.valueDate
131
      that.proBar = 0
132
      that.alarmList = []
133
      that.changeProgress()
134
      var sDate = that.valueDate + that.TimeVal
135
      var sDateForm = (new Date(parseTime(sDate, true, true))).getTime()
136
      var eDate = that.formatTime(sDateForm + 8 * 60 * 60 * 1000 + 59 * 60 * 1000 + 59 * 1000).substring(0, 14)
98 137
      var arr = this.serverSeqArr
99
      getMonitorByDay({ seq: arr, day: date }).then(res => {
138
      getMonitorByDay({ seq: arr, begin: sDate, end: eDate }).then(res => {
139
        NProgress.inc()
100 140
        if (res.success && res.data) {
141
          this.progressShow = false
101 142
          var monitorList = []
102 143
          for (let i = 0; i < res.data.length; i++) {
103 144
            var str = res.data[i].cid
@ -128,9 +169,9 @@ export default {
128 169
    },
129 170
    changeDate(val) {
130 171
      this.valueDate = val
131
      if (this.serverSeqArr.length) {
132
        this.getMonitorByDay()
133
      }
172
    },
173
    changeTimeRange(val) {
174
      this.TimeVal = val
134 175
    },
135 176
    handleCurrentChange(val) {
136 177
      this.pageNo = val
@ -147,4 +188,13 @@ export default {
147 188
    margin-left: 15px;
148 189
  }
149 190
}
191
.progress-box{
192
  width: 400px;
193
  padding: 80px;
194
  margin: auto;
195
  text-align: center;
196
  line-height: 40px;
197
  color:#999;
198
  font-size:13px;
199
}
150 200
</style>

+ 8 - 6
src/views/bridgesConsole/lineChart/LineChart.vue

@ -106,8 +106,8 @@ export default {
106 106
        },
107 107
        yAxis: {
108 108
          type: 'value',
109
          max: 8191,
110
          min: -8192
109
          max: 9000,
110
          min: -9000
111 111
        },
112 112
        legend: {
113 113
          data: ['信号值']
@ -143,25 +143,27 @@ export default {
143 143
          dataZoom: [
144 144
            {
145 145
              type: 'slider',
146
              xAxisIndex: 0,
146
              show: true,
147
              xAxisIndex: [0],
147 148
              start: 0,
148 149
              end: 100
149 150
            },
150 151
            {
151 152
              type: 'inside',
152
              xAxisIndex: 0,
153
              xAxisIndex: [0],
153 154
              start: 0,
154 155
              end: 100
155 156
            },
156 157
            {
157 158
              type: 'slider',
158
              yAxisIndex: 0,
159
              show: true,
160
              yAxisIndex: [0],
159 161
              start: 0,
160 162
              end: 100
161 163
            },
162 164
            {
163 165
              type: 'inside',
164
              yAxisIndex: 0,
166
              yAxisIndex: [0],
165 167
              start: 0,
166 168
              end: 100
167 169
            }