anxiao_web/pages/index/js/orgApi/getAlarmEventList.js

104 lines
3.5 KiB
JavaScript
Raw Normal View History

2024-07-24 09:22:32 +08:00
import { stationurl,brigade } from "../../../../public/js/url.js";
import { getCurrData } from "../../../../public/js/timestamp.js";
import { layuiObj } from "../index.js";
var alarmEventList=[];
function getAlarmEventList(){
var data={
"brigade":brigade,
"pagesize":2000,
"pageindex":0,
"start":getCurrData()+" 00:00:00",
"end":getCurrData()+" 23:59:59",
"state":"close"
}
var loginurl=stationurl+"/firectrl/client/sensor/alarm_event/getlist_diff";
return axios({
method: 'post',
url:loginurl,
data: data
})
}
function showAlarmEventList(){
alarmEventList=[];
getAlarmEventList().then(res=>{
var code=res.data.code;
if(code==0){
var data=res.data.data;
for(var i=0;i<data.length;i++){
alarmEventList.unshift(data[i])
}
}
alarmEventListTable();
})
}
function alarmEventListTable(){
layuiObj.layuitable.render({
elem:'#eventUpload',
data:alarmEventList,
cols: [[
{field:'station', width:"20%", title: '预警点'},
{field:'alarmType', width:"20%", title: '预警类型'},
{field:'timestamp', width:"20%", title: '预警时间'},
{field:'state', width:"40%", title: '状态',templet : function(data) {// 替换数据
var state=data["state"];
switch(state){
case "new"://新事件
var src=`./pages/cmddispatch/image/alarmEventNew.png`;
break;
case "processing"://处置中
var src=`./pages/cmddispatch/image/alarmEventProcessing.png`;
break;
case "processed"://已关闭
var src=`./pages/cmddispatch/image/alarmEventProcessed.png`;
break;
default:
var src=`./pages/cmddispatch/image/alarmEventNew.png`;
break;
}
return `<img src=${src}>`
}},
]],
limit:Number.MAX_VALUE // 数据表格默认全部显示
});
//监听行工具事件
layuiObj.layuitable.on('tool(eventUpload)',function(obj){
var data=obj["data"];
showAlarmEventImg(data)
})
}
var alarmEventIndex=null;
function showAlarmEventImg(data){
var eventDataJson=data.eventData;
var eventData=JSON.parse(eventDataJson);
var pic=eventData["pic"];
alarmEventIndex=layuiObj.layer.open({
type: 1,
title: '事件照片', //不显示标题栏
offset: 'auto',
shade: 0.6,
id:new Date().getTime(), //设定一个id防止重复弹出
btnAlign: 'c',
moveType: 1, //拖拽模式0或者1
content: `
<div style="padding:10px;color:#fff;background:#032357;height:190px;overflow-y:auto;">
<img src='${pic}'>
<div class="alarmEventInfoImg">
<p>报警信息</p>
<p><span>预警点</span><span>${data["station"]}</span></p>
<p><span>预警类型</span><span>${data["alarmType"]}</span></p>
<p><span>预警时间</span><span>${data["timestamp"]}</span></p>
</div>
</div>`,
success: function(layero){
}
});
}
export {
showAlarmEventList,
alarmEventListTable,
alarmEventList
}