import { layuiObj,loginInfo } from "./index.js";
import { getCurrData } from "../../../public/js/timestamp.js";
import { getSchoolOptions } from "./schoolSearch.js";
import { stationurl,movedeviceurl,brigade } from "../../../public/js/url.js";
import { deviceHash } from "../api/moveDeviceWebsocket.js";
import { notifyDetailList } from "./popNotifyDetail.js";
let notifyListMore=[];
let earlyWarningHistoryList=[];
let imgUrlArr=[];
function openAlarmHistory(){
layuiObj["layer"].open({
type: 1,
title: "事件查询", //不显示标题栏
// closeBtn: false,
area: ['1260px', '560px'],
id: new Date().getTime(), //设定一个id,防止重复弹出
btnAlign: 'c',
resize:false,
// moveType: 0, //拖拽模式,0或者1
content:`
`,
success:function(){
renderClockFrom();
intellEarlyWarningSelectEvent();
}
})
}
function renderClockFrom(){
$("#intellEarlyWarningSchoolSelect").html(getSchoolOptions());
layuiObj.layuiForm.render("select","intellEarlyWarningHistoryForm");
$("#intellEarlyWarningSchoolSelect").siblings("div.layui-form-select").find("div.layui-select-title").find("input").attr("onfocus","this.select()");
layuiObj.laydate.render({
elem: '#intellEarlyWarningHistoryStart',
type: 'datetime',
});
layuiObj.laydate.render({
elem: '#intellEarlyWarningHistoryEnd',
type: 'datetime',
});
}
function intellEarlyWarningSelectEvent(){
$("#intellEarlyWarningHistoryBtn").off('')
$("#intellEarlyWarningHistoryBtn").on('click',(e)=>{
var start=$("#intellEarlyWarningHistoryStart").val();
var end=$("#intellEarlyWarningHistoryEnd").val();
var station=$("#intellEarlyWarningSchoolSelect").find("option:selected").val();
var type=$("#intellEarlyWarningTypeSelect").find("option:selected").val();
var data={
"brigade":brigade,
"start":start,
"end":end
}
if(station!="000"){
data["station"]=station
}
$(".intellEarlyWarningList").removeClass("commonfile");
switch(type){
case "1":
selectAlarmByOrg(data);
break;
case "2":
getNotifyCountMore(data);
break;
case "3":
$(".intellEarlyWarningList").addClass("commonfile")
selectCommonfile(data);
break;
default:
break;
}
return false;
})
}
function selectAlarmByOrg(data){
alarmByorgGetlist(data).then(res=>{
earlyWarningHistoryList=[];
var code=res["data"]["code"];
if(code==0){
var data=res["data"]["data"];
earlyWarningHistoryList=data;
if(earlyWarningHistoryList.length>0){
earlyWarningHistoryList.reverse();
}
}
showAlarmByorgTable();
})
}
function alarmByorgGetlist(data){
var alarmOrgUrl=movedeviceurl+"/mdev/alarm/byorg/getlist";
return axios({
method: 'post',
url:alarmOrgUrl,
data:data
})
}
//获取通知列表
function getNotifyCountMore(reqData){
reqData["sender"]=loginInfo["user_name"];
notifyListMore=[];
let nurlCount=movedeviceurl+"/mdev/notice/getcount";
axios({
method: 'post',
url:nurlCount,
data:reqData
}).then(res => {
var code=res["data"]["code"];
if(code==0){
var data=res["data"]["data"];
var count=data["count"];
if(count!=0){
var reqList=getPageReq(reqData,count);
//获取列表
var pArr=reqList.map((item)=>{
reqData=item;
let nurlList=movedeviceurl+"/mdev/notice/getlist";
return axios({
method: 'post',
url:nurlList,
data:reqData
})
})
Promise.all(pArr).then((result) => {
console.log(result);
for(var i=0;i{
var reqData={
"noticeid":item.noticeid
}
let nsurl=movedeviceurl+"/mdev/notice/getstatus";
notifyStatus.push( axios({
method: 'post',
url:nsurl,
data:reqData
}));
})
Promise.all(notifyStatus).then(res=>{
for(var i =0;i详情`
}
},
]],
limit:Number.MAX_VALUE // 数据表格默认全部显示
});
listenEarlyWarningTable();
}
function listenEarlyWarningTable(){
layuiObj.layuitable.on('tool(intellEarlyWarningTable)', function(obj){
var event=obj["event"];
var data = obj.data;
switch(event){
case "handle":
notifyDetailList(data)
break;
default:
break;
}
})
}
//分页请求
function getPageReq(reqOrgData,count){
let number=1000;
let page=Math.ceil(count/number);
let reqList=[];
for(let i=0;i{
var code=res["data"]["code"];
if(code==0){
var data=res["data"]["data"];
showCommonfileTable(data)
}
})
}
function selectCommonfileGetlist(data){
var commonfileUrl=stationurl+"/firectrl/school/commonfile/getlist";
return axios({
method: 'post',
url:commonfileUrl,
data:data
})
}
function showCommonfileTable(data){
console.log(data);
imgUrlArr=[];
layuiObj.layuitable.render({
elem:'#intellEarlyWarningTable',
data:data,
cols: [[
{field:'comment', width:"20%", title: '标题'},
{field:'station', width:"20%", title: '学校'},
{field:'creator', width:"20%", title: '使用者'},
{field:'timestamp', width:"20%", title: '上传时间'},
{field:'imageUrls', width:"20%", title: '文件',templet:function(data) {
return `${getImageUrl(data)}`
}
},
]],
limit:Number.MAX_VALUE // 数据表格默认全部显示
});
for(var i=0;i`
}
return imgs;
}
export {openAlarmHistory}