anxiao_web/pages/video/js/orgApi/getAlarmEventList.js

187 lines
5.9 KiB
JavaScript
Raw Permalink 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";
import {openEventHandle} from "../popEventHandle.js";
import { alarmManageInfo } from "../popEventHandle.js";
import { openMoveDeviceVideo } from "../openMoveDeviceVideo.js";
import { deviceHash } from "../../api/moveDeviceWebsocket.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:"15%", title: '预警点'},
{field:'alarmType', width:"15%", title: '预警类型'},
{field:'timestamp', width:"25%", title: '预警时间'},
{field:'state', width:"25%", 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}>`
}},
{field:'opear', width:"20%", title: '操作',toolbar: '#eventUploadScript'},
]],
limit:Number.MAX_VALUE // 数据表格默认全部显示
});
//监听行工具事件
layuiObj.layuitable.on('tool(eventUpload)',function(obj){
var data=obj["data"];
showAlarmEventImg(data)
})
}
var alarmEventIndex=null;
var currentEventData=null;
function showAlarmEventImg(data){
currentEventData=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:220px;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 class="alarmHandleBtnBox">
<button class="layui-btn layui-btn-normal alarmHandleBtn">处置</button>
<button class="layui-btn layui-btn-normal alarmHandleEndBtn">结束</button>
<button class="layui-btn layui-btn-normal alarmHandleCloseBtn">关闭</button>
</div>
</div>`,
success: function(layero){
eventHandlePage();
}
});
}
function closeAlarmEvent(){
layuiObj.layer.close(alarmEventIndex);
alarmEventIndex=null;
}
function eventHandlePage(){
$(".alarmHandleBtn").on('click',function(){
handleIotHandle();
//打开视频
createMoveDeviceVideoData();
//更新任务状态
crateUpdateEventAlarmData("processing");
})
$(".alarmHandleEndBtn").on('click',function(){
crateUpdateEventAlarmData("processed")
})
$(".alarmHandleCloseBtn").on('click',function(){
crateUpdateEventAlarmData("close")
})
}
function crateUpdateEventAlarmData(state){
updateEventAlarmState(state).then(res=>{
var code=res.data.code;
if(code==0){//再去刷新table
showAlarmEventList();
}
})
closeAlarmEvent();
}
function updateEventAlarmState(state){
var data={
"eventId":currentEventData["eventId"],
"newState":state
}
var loginurl=stationurl+"/firectrl/client/sensor/alarm_event/update";
return axios({
method: 'post',
url:loginurl,
data: data
})
}
function createMoveDeviceVideoData(){
var station=currentEventData["station"];
var temp=[];
for(var d in deviceHash){
if(deviceHash[d]["station"]==station){
temp.push(deviceHash[d]);
}
}
openMoveDeviceVideo(temp);
}
function handleIotHandle(){
alarmManageInfo["longitude"]=currentEventData["longitude"];
alarmManageInfo["latitude"]=currentEventData["latitude"];
alarmManageInfo["deviceid"]=currentEventData["deviceid"];
alarmManageInfo["showname"]=currentEventData["address"];
alarmManageInfo["alarminfo"]=currentEventData
openEventHandle();
}
export {
showAlarmEventList,
alarmEventListTable,
alarmEventList,
currentEventData
}