Browse Source

实时监控全部显示当前的传感器波形图;报警列表5s请求一次;session失效重新登录

luyanan 6 years ago
parent
commit
cb60790a1d

+ 7 - 11
src/permission.js

@ -2,7 +2,6 @@ import router from './router'
2 2
import store from './store'
3 3
import NProgress from 'nprogress' // Progress 进度条
4 4
import 'nprogress/nprogress.css'// Progress 进度条样式
5
import { Message } from 'element-ui'
6 5
import { getCookiesName } from '@/utils/auth' // 验权
7 6
import queryInfo from '@/utils/queryInfo'
8 7
@ -27,16 +26,13 @@ router.beforeEach((to, from, next) => {
27 26
      if (store.getters.roles.length === 0) { // 判断当前用户是否已拉取完user_info信息
28 27
        // console.log(5555)
29 28
        store.dispatch('GetUserInfo').then(res => { // 拉取user_info
30
          const roles = [res.data.type.toString()]
31
          store.dispatch('GenerateRoutes', { roles }).then(() => { // 根据roles权限生成可访问的路由表
32
            router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表
33
            next({ ...to, replace: true })
34
          })
35
        }).catch((err) => {
36
          store.dispatch('FedLogOut').then(() => {
37
            Message.error(err || '登录状态失效,请重新登录')
38
            next({ path: '/' })
39
          })
29
          if (res.success) {
30
            const roles = [res.data.type.toString()]
31
            store.dispatch('GenerateRoutes', { roles }).then(() => { // 根据roles权限生成可访问路由表
32
              router.addRoutes(store.getters.addRouters) // 动态添加可访问路由表
33
              next({ ...to, replace: true })
34
            })
35
          }
40 36
        })
41 37
      } else {
42 38
        // console.log(4444)

+ 19 - 0
src/utils/index.js

@ -85,3 +85,22 @@ export function debounce(func, wait, immediate) {
85 85
    return result
86 86
  }
87 87
}
88
89
export function isEqualArr(arr1, arr2) {
90
  if (!arr1 || !arr2) {
91
    return false
92
  }
93
  if (arr1.length !== arr2.length) {
94
    return false
95
  }
96
  for (var i = 0; i < arr1.length; i++) {
97
    if (arr1[i] instanceof Array && arr2[i] instanceof Array) {
98
      if (!isEqualArr(arr1[i], arr2[i])) {
99
        return false
100
      } else if (arr1[i] !== arr2[i]) {
101
        return false
102
      }
103
    }
104
  }
105
  return true
106
}

+ 10 - 1
src/utils/request.js

@ -1,6 +1,9 @@
1 1
import axios from 'axios'
2 2
import qs from 'qs'
3 3
import { comUrl } from '@/utils/index'
4
import { Message } from 'element-ui'
5
import router from '@/router'
6
import store from '@/store'
4 7
5 8
// 创建axios实例
6 9
const service = axios.create({
@ -41,7 +44,13 @@ service.interceptors.response.use(response => {
41 44
    }
42 45
    if (!(data instanceof Object)) {
43 46
      // 判断data不是Object时,解析成Object
44
      // data = JSON.parse(data)
47
      data = JSON.parse(data)
48
    }
49
    if (!response.data.success && response.data.code === 1) {
50
      store.dispatch('FedLogOut').then(() => {
51
        Message.error('登录状态失效,请重新登录')
52
        router.push({ path: '/' })
53
      })
45 54
    }
46 55
    return response.data
47 56
  } else {

+ 2 - 3
src/utils/timingConstruct.js

@ -10,9 +10,9 @@ var monitorModel = {
10 10
    for (let i = 0; i < $data.length; ++i) {
11 11
      if ($data[i].ctime === $data[0].ctime) {
12 12
        mCache.push({
13
          cid: $data[i].cid,
13
          cid: $data[i].seq,
14 14
          cd: {
15
            tit: '',
15
            tit: $data[i].code,
16 16
            xData: [],
17 17
            seData: []
18 18
          }
@ -26,7 +26,6 @@ var monitorModel = {
26 26
      item.xData.push(parseTime(ftend, true, true))
27 27
      item.seData.push($daI.hvalue)
28 28
      item.seData.push($daI.lvalue)
29
      item.tit = $daI.cid
30 29
    } else {
31 30
      item.xData.push(parseTime(ftbegin, true, true))
32 31
      item.xData.push(parseTime(ftend, true, true))

+ 1 - 1
src/views/bridgesConsole/bridgeDetail/components/BInfoDialog03.vue

@ -63,7 +63,7 @@ export default {
63 63
  data() {
64 64
    return {
65 65
      dialogW: this.$parent.dialogW,
66
      deviceList: this.$parent.deviceList,
66
      deviceList: [],
67 67
      dialogTableVisible: false,
68 68
      pageSize: 4,
69 69
      pageNo: 1

+ 79 - 37
src/views/bridgesConsole/bridgeDetail/index.vue

@ -88,7 +88,7 @@ import Cookies from 'js-cookie'
88 88
import queryInfo from '@/utils/queryInfo'
89 89
import queryDict from '@/utils/queryDict'
90 90
import monModel from '@/utils/timingConstruct'
91
import { urlParse, parseTime } from '@/utils'
91
import { urlParse, parseTime, isEqualArr } from '@/utils'
92 92
import { getDangerList, getSysTime, getMonitorByTime } from '@/api/bridgeInfo'
93 93
94 94
import lineChart from '../lineChart/LineChart'
@ -125,9 +125,9 @@ export default {
125 125
      cableMain: {},
126 126
      addr: {},
127 127
      dangerList: '',
128
      dangerAidArr: [],
129
      first_Dan: true,
128 130
      serverSeqArr: [],
129
      serverList: [],
130
      deviceList: [],
131 131
      transducerList: [],
132 132
      currentNo: 1,
133 133
      currentSize: 4,
@ -138,7 +138,8 @@ export default {
138 138
      maxShowLength: 300,
139 139
      monitorList: [],
140 140
      monitorCache: [],
141
      jishiTime: ''
141
      jishiTime: '',
142
      jishiTime2: ''
142 143
    }
143 144
  },
144 145
  computed: {
@ -162,6 +163,7 @@ export default {
162 163
    queryInfo.qaiCb(function() {
163 164
      if (that.bridgeId) {
164 165
        that.serverSeqArr = queryInfo.queryServers(that.bridgeId, true)
166
        that.transducerList = queryInfo.queryTrans(that.bridgeId)
165 167
        if (that.serverSeqArr.length) {
166 168
          that.updateDataList()
167 169
          that.getDangerList()
@ -171,32 +173,69 @@ export default {
171 173
  },
172 174
  methods: {
173 175
    updateDataList() {
174
      clearTimeout(this.jishiTime)
175
      this.jishiTime = ''
176
      this.sysTime = ''
177
      this.monitorList = []
178
      this.monitorCache = []
179
      this.getSysTime()
176
      var that = this
177
      clearTimeout(that.jishiTime)
178
      that.jishiTime = ''
179
      that.sysTime = ''
180
      that.monitorList = []
181
      that.monitorCache = []
182
      if (that.transducerList.length) {
183
        monModel.construct(that.monitorCache, that.transducerList)
184
      }
185
      that.getSysTime()
180 186
    },
181 187
    getDangerList() {
188
      var that = this
182 189
      var arr = this.serverSeqArr
183 190
      const param = {
184 191
        seq: arr,
185 192
        pageSize: 5,
186 193
        pageNo: 1
187 194
      }
188
      this.loadprogress1 = true
195
      if (that.first_Dan) {
196
        this.loadprogress1 = true
197
      }
189 198
      getDangerList(param).then(res => {
199
        var dCache = that.dangerAidArr
200
        var DList = []
190 201
        if (res.success && res.data.data) {
191
          this.loadprogress1 = false
192 202
          const dataS = res.data.data
193
          for (let i = 0; i < dataS.length; i++) {
194
            if (dataS[i].alarmTime) {
195
              dataS[i].alarmTime = parseTime(dataS[i].alarmTime, true)
203
          if (that.first_Dan) {
204
            that.first_Dan = false
205
            for (let i = 0; i < dataS.length; i++) {
206
              dCache.push(dataS[i].aid)
207
              if (dataS[i].alarmTime) {
208
                dataS[i].alarmTime = parseTime(dataS[i].alarmTime, true)
209
              }
210
              dataS[i].device = `${this.bridgeName}大桥${dataS[i].device}采集盒检测到异常情况`
211
            }
212
            that.dangerList = dataS
213
          } else {
214
            for (let i = 0; i < dataS.length; i++) {
215
              DList.push(dataS[i].aid)
216
              if (dataS[i].alarmTime) {
217
                dataS[i].alarmTime = parseTime(dataS[i].alarmTime, true)
218
              }
219
              dataS[i].device = `${this.bridgeName}大桥${dataS[i].device}采集盒检测到异常情况`
220
            }
221
            if (!isEqualArr(DList, dCache)) {
222
              dCache = []
223
              dCache = DList
224
              that.dangerList = dataS
196 225
            }
197
            dataS[i].device = `${this.bridgeName}大桥${dataS[i].device}采集盒检测到异常情况`
198 226
          }
199
          this.dangerList = dataS
227
          that.loadprogress1 = false
228
          if (that && !that._isDestroyed) {
229
            that.jishiTime2 = setTimeout(function() {
230
              if (that && !that._isDestroyed) {
231
                that.getDangerList(param)
232
              }
233
            }, 5000)
234
          } else {
235
            that.jishiTime2 = ''
236
          }
237
        } else {
238
          that.loadprogress1 = false
200 239
        }
201 240
      })
202 241
    },
@ -204,15 +243,20 @@ export default {
204 243
      var that = this
205 244
      var arr = this.serverSeqArr
206 245
      getSysTime({ seq: arr }).then(res => {
207
        if (res.success && res.data && res.data.length > 0) {
208
          const nowt = parseTime(res.data[0].ctime, true, true)
209
          that.sysTime = (new Date(nowt)).getTime() + that.eastEightDistrict - 2 * 1000
210
          const localTime = new Date().getTime() + that.eastEightDistrict
211
          that.localTimeiv = localTime - that.sysTime
212
          that.first_Q = true
213
          that.getTimingMonitor()
214
        } else {
215
          that.loadprogress2 = false
246
        if (res.success) {
247
          if (res.data && res.data.length > 0) {
248
            const nowt = parseTime(res.data[0].ctime, true, true)
249
            that.sysTime = (new Date(nowt)).getTime() + that.eastEightDistrict - 2 * 1000
250
            that.first_Q = true
251
          } else {
252
            that.sysTime = (new Date()).getTime() + that.eastEightDistrict - 2 * 1000
253
            that.loadprogress2 = false
254
          }
255
          setTimeout(function() {
256
            const localTime = new Date().getTime() + that.eastEightDistrict
257
            that.localTimeiv = localTime - that.sysTime
258
            that.getTimingMonitor()
259
          }, 1)
216 260
        }
217 261
      })
218 262
    },
@ -229,16 +273,13 @@ export default {
229 273
      var endTime = this.formatTime(this.sysTime)
230 274
      that.sysTime += 1000
231 275
      getMonitorByTime({ seq: arr, begin: startTime, end: endTime }).then(res => {
232
        var mCache = that.monitorCache
233 276
        var mList = []
234 277
        if (res.success && res.data) {
235 278
          if (that.first_Q) {
236
            that.loadprogress2 = false
237 279
            if (res.data.length) {
238 280
              that.first_Q = false
281
              that.loadprogress2 = false
239 282
              var ftime = res.data[0].ctime
240
              monModel.construct(mCache, res.data)
241
242 283
              var f_q_t = that.sysTime
243 284
244 285
              for (;;) {
@ -246,7 +287,7 @@ export default {
246 287
                var ftsE = that.formatTime(f_q_t + 500)
247 288
                if (fts >= ftime) {
248 289
                  if (fts > that.sysTime) {
249
                    monModel.setData(mCache, res.data, fts, ftsE, null)
290
                    monModel.setData(that.monitorCache, res.data, fts, ftsE, null)
250 291
                  }
251 292
                }
252 293
                f_q_t += 1000
@ -254,17 +295,17 @@ export default {
254 295
                  break
255 296
                }
256 297
              }
257
              for (let l = 0; l < mCache.length; ++l) {
258
                mList.push(mCache[l].cd)
298
              for (let l = 0; l < that.monitorCache.length; ++l) {
299
                mList.push(that.monitorCache[l].cd)
259 300
              }
260 301
            }
261 302
          } else {
262 303
            var xtime = that.formatTime(that.sysTime)
263 304
            var xtimeE = that.formatTime(that.sysTime + 500)
264 305
265
            monModel.setData(mCache, res.data, xtime, xtimeE, that.maxShowLength)
266
            for (let l = 0; l < mCache.length; ++l) {
267
              mList.push(mCache[l].cd)
306
            monModel.setData(that.monitorCache, res.data, xtime, xtimeE, that.maxShowLength)
307
            for (let l = 0; l < that.monitorCache.length; ++l) {
308
              mList.push(that.monitorCache[l].cd)
268 309
            }
269 310
          }
270 311
          that.monitorList = mList
@ -343,7 +384,8 @@ export default {
343 384
  },
344 385
  beforeDestroy() {
345 386
    this.$once('hook:beforeDestroy', () => {
346
      clearInterval(this.jishiTime)
387
      clearTimeout(this.jishiTime)
388
      clearTimeout(this.jishiTime2)
347 389
    })
348 390
  }
349 391
}