Commit 0d3619b1 authored by xiexingan's avatar xiexingan

Merge branch 'dev' of gitlab.suntrayoa.com:geqilin/energyai_vue into dev

parents 0c2a7e93 a3cf6843
......@@ -149,7 +149,7 @@ export default {
isRouterAlive: true,
queryDetailVisible: false,
urlPath: window.CONFIG.urlPath,
tipList: [],
paramsList: [],
showList: [],
takeoverInfo: ''
}
......@@ -173,7 +173,7 @@ export default {
mounted() {
this.initWebSocket()
this.initWebSocket2()
// this.getDateList()
this.getDateList()
},
destroyed: function () {
this.websocketclose()
......@@ -222,24 +222,10 @@ export default {
},
//接收后端返回的数据
websocketonmessage(e) {
console.log('takeover:', sessionStorage.getItem('takeover'))
if (
sessionStorage.getItem('takeover') != undefined &&
sessionStorage.getItem('takeover') == 'true'
) {
this.ishowAlarm = false
} else {
this.ishowAlarm = true
}
// 在这里使用后端返回的数据,对数据进行处理渲染
// this.tipList = []
this.showList = []
if (
sessionStorage.getItem('token') &&
sessionStorage.getItem('token') != undefined
) {
// if (util.cookies.get('token') && util.cookies.get('token') != undefined) { //登录才能获取
// this.tipList = JSON.parse(e.data)
var alarmsInfo = JSON.parse(e.data)
//console.log(alarmsInfo, '-------')
if (alarmsInfo.status != 1) {
......@@ -339,10 +325,6 @@ export default {
websocketclose(e) {
console.log('断开连接', e)
},
send() {
this.websock.send('1')
},
// ====================================
//初始化weosocket2
initWebSocket2() {
......@@ -470,9 +452,6 @@ export default {
websocketclose2(e) {
console.log('断开连接2', e)
},
send2() {
this.websock.send('2')
},
// 同意被接管
agreed() {
let item = this.takeoverInfo
......@@ -513,81 +492,21 @@ export default {
//登录后页面刷新的时候获取
getDateList() {
console.log('takeover:', sessionStorage.getItem('takeover'))
if (
sessionStorage.getItem('takeover') != undefined &&
sessionStorage.getItem('takeover') == 'true'
) {
this.ishowAlarm = false
} else {
this.ishowAlarm = true
}
console.log('ishowAlarm:', this.ishowAlarm)
this.tipList = []
this.showList = []
if (
sessionStorage.getItem('token') &&
sessionStorage.getItem('token') != undefined
) {
this.$http({
url: this.$http.adornUrlAlarm('/alarmsInfo/queryList'),
method: 'post',
params: this.$http.adornParams({
status: 1,
stationId: localStorage.getItem('stationId')
})
url: this.$http.adornUrl('/equipment/getListParam'),
method: 'get',
params: this.$http.adornParams({})
}).then((data) => {
if (data && data.code === 0) {
this.tipList = data.list
if (this.tipList.length < 4) {
this.tipList.forEach((element) => {
this.showList.push(element)
})
} else if (this.tipList.length >= 4) {
for (let index = 0; index < 4; index++) {
this.showList.push(this.tipList[index])
}
}
if (this.showList) {
this.showList.sort(this.sortBy('occurrenceTime', true))
}
// console.log(this.tipList, '-------')
// console.log(this.showList, '-------')
//console.log(this.showList, '1----------1')
this.$store.dispatch('d2admin/toast/set', this.tipList.length)
this.paramsList = data.bean
console.log('paramsList:', this.paramsList)
}
})
} else {
//清空接管提示框
this.$store.dispatch('d2admin/takeover/setTakeover', null)
}
},
/**数组根据数组对象中的某个属性值进行排序的方法
* 使用例子:newArray.sort(sortBy('number',false)) //表示根据number属性降序排列;若第二个参数不传递,默认表示升序排序
* @param attr 排序的属性 如number属性
* @param rev true表示升序排列,false降序排序
* */
sortBy: function (attr, rev) {
//第二个参数没有传递 默认升序排列
if (rev == undefined) {
rev = 1
} else {
rev = rev ? 1 : -1
}
return function (a, b) {
a = a[attr]
b = b[attr]
if (a < b) {
return rev * -1
}
if (a > b) {
return rev * 1
}
return 0
}
},
doBtn(item) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment