Przeglądaj źródła

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

luyanan 6 lat temu
rodzic
commit
cb60790a1d

+ 7 - 11
src/permission.js

2
import store from './store'
2
import store from './store'
3
import NProgress from 'nprogress' // Progress 进度条
3
import NProgress from 'nprogress' // Progress 进度条
4
import 'nprogress/nprogress.css'// Progress 进度条样式
4
import 'nprogress/nprogress.css'// Progress 进度条样式
5
import { Message } from 'element-ui'
6
import { getCookiesName } from '@/utils/auth' // 验权
5
import { getCookiesName } from '@/utils/auth' // 验权
7
import queryInfo from '@/utils/queryInfo'
6
import queryInfo from '@/utils/queryInfo'
8
7
27
      if (store.getters.roles.length === 0) { // 判断当前用户是否已拉取完user_info信息
26
      if (store.getters.roles.length === 0) { // 判断当前用户是否已拉取完user_info信息
28
        // console.log(5555)
27
        // console.log(5555)
29
        store.dispatch('GetUserInfo').then(res => { // 拉取user_info
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
      } else {
37
      } else {
42
        // console.log(4444)
38
        // console.log(4444)

+ 19 - 0
src/utils/index.js

85
    return result
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
import axios from 'axios'
1
import axios from 'axios'
2
import qs from 'qs'
2
import qs from 'qs'
3
import { comUrl } from '@/utils/index'
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
// 创建axios实例
8
// 创建axios实例
6
const service = axios.create({
9
const service = axios.create({
41
    }
44
    }
42
    if (!(data instanceof Object)) {
45
    if (!(data instanceof Object)) {
43
      // 判断data不是Object时,解析成Object
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
    return response.data
55
    return response.data
47
  } else {
56
  } else {

+ 2 - 3
src/utils/timingConstruct.js

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

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

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

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

88
import queryInfo from '@/utils/queryInfo'
88
import queryInfo from '@/utils/queryInfo'
89
import queryDict from '@/utils/queryDict'
89
import queryDict from '@/utils/queryDict'
90
import monModel from '@/utils/timingConstruct'
90
import monModel from '@/utils/timingConstruct'
91
import { urlParse, parseTime } from '@/utils'
91
import { urlParse, parseTime, isEqualArr } from '@/utils'
92
import { getDangerList, getSysTime, getMonitorByTime } from '@/api/bridgeInfo'
92
import { getDangerList, getSysTime, getMonitorByTime } from '@/api/bridgeInfo'
93
93
94
import lineChart from '../lineChart/LineChart'
94
import lineChart from '../lineChart/LineChart'
125
      cableMain: {},
125
      cableMain: {},
126
      addr: {},
126
      addr: {},
127
      dangerList: '',
127
      dangerList: '',
128
      dangerAidArr: [],
129
      first_Dan: true,
128
      serverSeqArr: [],
130
      serverSeqArr: [],
129
      serverList: [],
130
      deviceList: [],
131
      transducerList: [],
131
      transducerList: [],
132
      currentNo: 1,
132
      currentNo: 1,
133
      currentSize: 4,
133
      currentSize: 4,
138
      maxShowLength: 300,
138
      maxShowLength: 300,
139
      monitorList: [],
139
      monitorList: [],
140
      monitorCache: [],
140
      monitorCache: [],
141
      jishiTime: ''
141
      jishiTime: '',
142
      jishiTime2: ''
142
    }
143
    }
143
  },
144
  },
144
  computed: {
145
  computed: {
162
    queryInfo.qaiCb(function() {
163
    queryInfo.qaiCb(function() {
163
      if (that.bridgeId) {
164
      if (that.bridgeId) {
164
        that.serverSeqArr = queryInfo.queryServers(that.bridgeId, true)
165
        that.serverSeqArr = queryInfo.queryServers(that.bridgeId, true)
166
        that.transducerList = queryInfo.queryTrans(that.bridgeId)
165
        if (that.serverSeqArr.length) {
167
        if (that.serverSeqArr.length) {
166
          that.updateDataList()
168
          that.updateDataList()
167
          that.getDangerList()
169
          that.getDangerList()
171
  },
173
  },
172
  methods: {
174
  methods: {
173
    updateDataList() {
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
    getDangerList() {
187
    getDangerList() {
188
      var that = this
182
      var arr = this.serverSeqArr
189
      var arr = this.serverSeqArr
183
      const param = {
190
      const param = {
184
        seq: arr,
191
        seq: arr,
185
        pageSize: 5,
192
        pageSize: 5,
186
        pageNo: 1
193
        pageNo: 1
187
      }
194
      }
188
      this.loadprogress1 = true
195
      if (that.first_Dan) {
196
        this.loadprogress1 = true
197
      }
189
      getDangerList(param).then(res => {
198
      getDangerList(param).then(res => {
199
        var dCache = that.dangerAidArr
200
        var DList = []
190
        if (res.success && res.data.data) {
201
        if (res.success && res.data.data) {
191
          this.loadprogress1 = false
192
          const dataS = res.data.data
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
      var that = this
243
      var that = this
205
      var arr = this.serverSeqArr
244
      var arr = this.serverSeqArr
206
      getSysTime({ seq: arr }).then(res => {
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
      var endTime = this.formatTime(this.sysTime)
273
      var endTime = this.formatTime(this.sysTime)
230
      that.sysTime += 1000
274
      that.sysTime += 1000
231
      getMonitorByTime({ seq: arr, begin: startTime, end: endTime }).then(res => {
275
      getMonitorByTime({ seq: arr, begin: startTime, end: endTime }).then(res => {
232
        var mCache = that.monitorCache
233
        var mList = []
276
        var mList = []
234
        if (res.success && res.data) {
277
        if (res.success && res.data) {
235
          if (that.first_Q) {
278
          if (that.first_Q) {
236
            that.loadprogress2 = false
237
            if (res.data.length) {
279
            if (res.data.length) {
238
              that.first_Q = false
280
              that.first_Q = false
281
              that.loadprogress2 = false
239
              var ftime = res.data[0].ctime
282
              var ftime = res.data[0].ctime
240
              monModel.construct(mCache, res.data)
241
242
              var f_q_t = that.sysTime
283
              var f_q_t = that.sysTime
243
284
244
              for (;;) {
285
              for (;;) {
246
                var ftsE = that.formatTime(f_q_t + 500)
287
                var ftsE = that.formatTime(f_q_t + 500)
247
                if (fts >= ftime) {
288
                if (fts >= ftime) {
248
                  if (fts > that.sysTime) {
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
                f_q_t += 1000
293
                f_q_t += 1000
254
                  break
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
          } else {
302
          } else {
262
            var xtime = that.formatTime(that.sysTime)
303
            var xtime = that.formatTime(that.sysTime)
263
            var xtimeE = that.formatTime(that.sysTime + 500)
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
          that.monitorList = mList
311
          that.monitorList = mList
343
  },
384
  },
344
  beforeDestroy() {
385
  beforeDestroy() {
345
    this.$once('hook:beforeDestroy', () => {
386
    this.$once('hook:beforeDestroy', () => {
346
      clearInterval(this.jishiTime)
387
      clearTimeout(this.jishiTime)
388
      clearTimeout(this.jishiTime2)
347
    })
389
    })
348
  }
390
  }
349
}
391
}