339 lines
10 KiB
JavaScript
339 lines
10 KiB
JavaScript
|
|
let layer,table,buildCheck,$,form;
|
|||
|
|
const bidCode = parent.$('#bidPro').val();
|
|||
|
|
var isSubOk = false
|
|||
|
|
var mengIndex = 0
|
|||
|
|
layui.use(['layer','table','form','jquery'], function () {
|
|||
|
|
$ = layui.jquery
|
|||
|
|
form = layui.form
|
|||
|
|
layer = layui.layer;
|
|||
|
|
table = layui.table;
|
|||
|
|
//建管单位下拉选
|
|||
|
|
getBuildLists();
|
|||
|
|
|
|||
|
|
// 响应成功后的拦截器
|
|||
|
|
$.ajaxSetup({
|
|||
|
|
beforeSend: function(xhr, options) {
|
|||
|
|
var originalSuccess = options.success
|
|||
|
|
options.success = function(data, textStatus, jqXhr) {
|
|||
|
|
data = modifyResponseData(data);
|
|||
|
|
// success(data,textStatus, jqXhr);
|
|||
|
|
originalSuccess.apply(this, arguments)
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
|
|||
|
|
table.on('tool(test)', function (obj) {
|
|||
|
|
var data = obj.data;
|
|||
|
|
console.log(data)
|
|||
|
|
// console.log(data,'-----row-----')
|
|||
|
|
if (obj.event === 'edit') {
|
|||
|
|
layer.open({
|
|||
|
|
type: 1,
|
|||
|
|
title: '告警处置', //显示标题栏
|
|||
|
|
closeBtn: 1,
|
|||
|
|
area: '600px;',
|
|||
|
|
id: 'LAY_layuipro', //设定一个id,防止重复弹出
|
|||
|
|
resize: false,
|
|||
|
|
btn: ['确定', '取消'],
|
|||
|
|
btnAlign: 'c',
|
|||
|
|
moveType: 1, //拖拽模式,0或者1
|
|||
|
|
skin:"layui-layer-molv",
|
|||
|
|
content: $("#biaodan"),
|
|||
|
|
success: function (layero) {
|
|||
|
|
$(':focus').blur();
|
|||
|
|
// 添加form标识
|
|||
|
|
layero.addClass('layui-form');
|
|||
|
|
// 将保存按钮改变成提交按钮
|
|||
|
|
layero.find('.layui-layer-btn0').attr({
|
|||
|
|
'lay-filter': 'formDemo',
|
|||
|
|
'lay-submit': ''
|
|||
|
|
});
|
|||
|
|
$("#form_info")[0].reset();
|
|||
|
|
$("#isAlarm1").attr("checked",true);
|
|||
|
|
$("#alarmContent").val(data.warnContent);
|
|||
|
|
form.render();
|
|||
|
|
},
|
|||
|
|
yes: function (layero, index) {
|
|||
|
|
form.on('submit(formDemo)', function (Fdata) {
|
|||
|
|
//表单数据formData
|
|||
|
|
var formData = Fdata.field;
|
|||
|
|
// console.log(formData,'-----formData-----')
|
|||
|
|
const url = commonUrl + "screen/largeScreen/alarmMge/warnProcess";
|
|||
|
|
const params = {
|
|||
|
|
"warnId": data.warnId,
|
|||
|
|
"status": formData.isAlarm,
|
|||
|
|
"remark": formData.alarmMask,
|
|||
|
|
}
|
|||
|
|
// console.log(params)
|
|||
|
|
let encryptStr = encryptCBC(JSON.stringify(params));
|
|||
|
|
ajaxRequest(url, "POST", encryptStr, true, function () {
|
|||
|
|
}, function (result) {
|
|||
|
|
// console.log(result);
|
|||
|
|
if (result.code === 200) {
|
|||
|
|
layer.close('LAY_layuipro')
|
|||
|
|
getQueryList()
|
|||
|
|
} else if (result.code === 500) {
|
|||
|
|
layer.msg(result.msg, { icon: 2 });
|
|||
|
|
}else if(result.code === 401){
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}, function (xhr, status, error) {
|
|||
|
|
error(xhr, status, error)
|
|||
|
|
}, "application/json",aqEnnable);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
cancel: function () {
|
|||
|
|
// 右上角关闭事件的逻辑
|
|||
|
|
layer.close('LAY_layuipro')
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}else if(obj.event === 'view'){
|
|||
|
|
layer.open({
|
|||
|
|
type: 1,
|
|||
|
|
title: '告警查看', //显示标题栏
|
|||
|
|
closeBtn: 1,
|
|||
|
|
area: '600px;',
|
|||
|
|
id: 'LAY_layuipro1', //设定一个id,防止重复弹出
|
|||
|
|
resize: false,
|
|||
|
|
btn: ['确定', '取消'],
|
|||
|
|
btnAlign: 'c',
|
|||
|
|
moveType: 1, //拖拽模式,0或者1
|
|||
|
|
skin:"layui-layer-molv",
|
|||
|
|
content: $("#biaodan"),
|
|||
|
|
success: function (layero) {
|
|||
|
|
$(':focus').blur();
|
|||
|
|
// 添加form标识
|
|||
|
|
layero.addClass('layui-form');
|
|||
|
|
// 将保存按钮改变成提交按钮
|
|||
|
|
layero.find('.layui-layer-btn0').attr({
|
|||
|
|
'lay-filter': 'formDemo',
|
|||
|
|
'lay-submit': ''
|
|||
|
|
});
|
|||
|
|
$("#form_info")[0].reset();
|
|||
|
|
$("#alarmContent").val(data.warnContent);
|
|||
|
|
$("#alarmMask").val(data.remark);
|
|||
|
|
if(data.status=='1'){
|
|||
|
|
$("#isAlarm1").attr("checked",true);
|
|||
|
|
$("#isAlarm2").attr("checked",false);
|
|||
|
|
}else if(data.status=='2'){
|
|||
|
|
$("#isAlarm1").attr("checked",false);
|
|||
|
|
$("#isAlarm2").attr("checked",true);
|
|||
|
|
}
|
|||
|
|
form.render();
|
|||
|
|
},
|
|||
|
|
yes: function (layero, index) {
|
|||
|
|
layer.close('LAY_layuipro1')
|
|||
|
|
},
|
|||
|
|
cancel: function () {
|
|||
|
|
// 右上角关闭事件的逻辑
|
|||
|
|
layer.close('LAY_layuipro1')
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
}else if(obj.event === 'upload'){
|
|||
|
|
layer.open({
|
|||
|
|
type: 1,
|
|||
|
|
title: '推送', //显示标题栏
|
|||
|
|
closeBtn: 1,
|
|||
|
|
area: '600px;',
|
|||
|
|
id: 'LAY_layuipro2', //设定一个id,防止重复弹出
|
|||
|
|
resize: false,
|
|||
|
|
btn: ['推送', '取消'],
|
|||
|
|
btnAlign: 'c',
|
|||
|
|
moveType: 1, //拖拽模式,0或者1
|
|||
|
|
skin:"layui-layer-molv",
|
|||
|
|
content: $("#upload"),
|
|||
|
|
success: function (layero) {
|
|||
|
|
$(':focus').blur();
|
|||
|
|
// 添加form标识
|
|||
|
|
layero.addClass('layui-form');
|
|||
|
|
// 将保存按钮改变成提交按钮
|
|||
|
|
layero.find('.layui-layer-btn0').attr({
|
|||
|
|
'lay-filter': 'formDemo',
|
|||
|
|
'lay-submit': ''
|
|||
|
|
});
|
|||
|
|
// $("#form_info")[0].reset();
|
|||
|
|
console.log(data)
|
|||
|
|
$("#warnContentTwo").val(data.warnContent);
|
|||
|
|
$("#proName").val(data.proName);
|
|||
|
|
$("#warnTime").val(data.warnTime);
|
|||
|
|
if(data.status=='0'){
|
|||
|
|
$("#status").val('未处理');
|
|||
|
|
}else if(data.status=='1'){
|
|||
|
|
$("#status").val('告警');
|
|||
|
|
}else if(data.status=='2'){
|
|||
|
|
$("#status").val('未告警');
|
|||
|
|
}
|
|||
|
|
form.render();
|
|||
|
|
},
|
|||
|
|
yes: function (layero, index) {
|
|||
|
|
form.on('submit(formDemo)', function (Fdata) {
|
|||
|
|
//表单数据formData
|
|||
|
|
var formData = Fdata.field;
|
|||
|
|
// console.log(formData,'-----formData-----')
|
|||
|
|
const url = commonUrl + "screen/largeScreen/alarmMge/warnUpload";
|
|||
|
|
const params = {
|
|||
|
|
"warnId": data.warnId,
|
|||
|
|
"warnContent": formData.warnContent,
|
|||
|
|
"status": data.status,
|
|||
|
|
"proName": formData.proName,
|
|||
|
|
"warnTime": formData.warnTime,
|
|||
|
|
}
|
|||
|
|
// console.log(params)
|
|||
|
|
let encryptStr = encryptCBC(JSON.stringify(params));
|
|||
|
|
ajaxRequest(url, "POST", encryptStr, true, function () {
|
|||
|
|
}, function (result) {
|
|||
|
|
// console.log(result);
|
|||
|
|
if (result.code === 200) {
|
|||
|
|
layer.close('LAY_layuipro2')
|
|||
|
|
layer.msg(result.msg, { icon: 1 });
|
|||
|
|
getQueryList()
|
|||
|
|
} else if (result.code === 500) {
|
|||
|
|
layer.msg(result.msg, { icon: 2 });
|
|||
|
|
}else if(result.code === 401){
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}, function (xhr, status, error) {
|
|||
|
|
error(xhr, status, error)
|
|||
|
|
}, "application/json",aqEnnable);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
cancel: function () {
|
|||
|
|
// 右上角关闭事件的逻辑
|
|||
|
|
layer.close('LAY_layuipro2')
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
|
|||
|
|
});
|
|||
|
|
|
|||
|
|
function getBuildLists(){
|
|||
|
|
let paramData = 'bidCode=' + bidCode + '&roleCode=' + roleCode + '&orgId=' + orgId + '&userId=' + userId;
|
|||
|
|
let montageParam = aqEnnable ? encryptCBC(paramData) : ' &' + encryptCBC(paramData);
|
|||
|
|
const url = commonUrl + "system/sys/select/getBuildLists?params=" + montageParam; // url
|
|||
|
|
ajaxRequestGet(url, "GET", true, function () {
|
|||
|
|
}, function (result) {
|
|||
|
|
if (result.code === 200) {
|
|||
|
|
let html = '';
|
|||
|
|
if (result.data && result.data.length > 0) {
|
|||
|
|
$.each(result.data, function (index, item) {
|
|||
|
|
html += '<option value="' + item.orgId + '">' + item.name + '</option>'
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
$('#build').empty().append(html);
|
|||
|
|
layui.form.render();
|
|||
|
|
|
|||
|
|
//选择单位下拉选
|
|||
|
|
getSelectLists();
|
|||
|
|
updateSelection();
|
|||
|
|
} else if (result.code === 500) {
|
|||
|
|
layer.msg(result.msg, { icon: 2 });
|
|||
|
|
}
|
|||
|
|
}, function (xhr, status, error) {
|
|||
|
|
error(xhr, status, error)
|
|||
|
|
}, aqEnnable);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function getSelectLists(){
|
|||
|
|
let paramData = 'bidCode=' + bidCode + '&roleCode=' + roleCode + '&orgId=' + orgId + '&userId=' + userId;
|
|||
|
|
let montageParam = aqEnnable ? encryptCBC(paramData) : ' &' + encryptCBC(paramData);
|
|||
|
|
const url = commonUrl + "system/sys/select/getSelectLists?params=" + montageParam; // url
|
|||
|
|
ajaxRequestGet(url, "GET", true, function () {
|
|||
|
|
}, function (result) {
|
|||
|
|
if (result.code === 200) {
|
|||
|
|
getSelect(result.data)
|
|||
|
|
} else if (result.code === 500) {
|
|||
|
|
layer.msg(result.msg, { icon: 2 });
|
|||
|
|
}
|
|||
|
|
}, function (xhr, status, error) {
|
|||
|
|
error(xhr, status, error)
|
|||
|
|
}, aqEnnable);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function getSelect(data){
|
|||
|
|
$("#selection").empty();
|
|||
|
|
var html ="";
|
|||
|
|
for (var i = 0; i < data.length; i++) {
|
|||
|
|
if(i == 0){
|
|||
|
|
html += '<div class="item bright" id="'+data[i].id+'">'+data[i].name+'</div>' ;
|
|||
|
|
}else{
|
|||
|
|
html += '<div class="item dark" id="'+data[i].id+'">'+data[i].name+'</div>' ;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
buildCheck = data[0].id;
|
|||
|
|
init(data[0].id);
|
|||
|
|
$("#selection").append(html);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function updateSelection() {
|
|||
|
|
$("#selection").on("click", ".item", function() {
|
|||
|
|
$(".item").removeClass("bright").addClass("dark"); // 点击时将所有元素设置为 dark 类
|
|||
|
|
$(this).removeClass("dark").addClass("bright"); // 点击的元素设置为 bright 类
|
|||
|
|
var clickedId = $(this).attr('id'); // 获取被点击的 div 元素的 id 值
|
|||
|
|
console.log("选中的值为: " + clickedId);
|
|||
|
|
buildCheck = clickedId;
|
|||
|
|
init(clickedId);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function init(warnType){
|
|||
|
|
const url = commonUrl + "screen/largeScreen/alarmMge/getAlarmMgeList"; // 建管单位url
|
|||
|
|
table.render({
|
|||
|
|
elem: '#demo',
|
|||
|
|
url: url,
|
|||
|
|
// skin: 'line',
|
|||
|
|
page: true,
|
|||
|
|
headers:{
|
|||
|
|
decrypt:"decrypt",
|
|||
|
|
"Authorization":token
|
|||
|
|
},
|
|||
|
|
where: {
|
|||
|
|
bidCode:bidCode,
|
|||
|
|
warnType:warnType,
|
|||
|
|
orgId:$('#build').val(),
|
|||
|
|
warnContent:$('#warnContent').val(),
|
|||
|
|
// teamLeader:$('#teamLeader').val()
|
|||
|
|
},
|
|||
|
|
cols: [[
|
|||
|
|
{type: 'numbers', title: '序号'}, // 添加序号列
|
|||
|
|
// {field: 'orgName', title: '',align:'center'},
|
|||
|
|
{field: 'proName', title: '工程名称',align:'center'},
|
|||
|
|
{field: 'warnContent', title: '告警内容',align:'center'},
|
|||
|
|
{field: 'warnTime', title: '告警时间',align:'center'},
|
|||
|
|
// {field: 'teamLeader', title: '班组长',align:'center'},
|
|||
|
|
// {field: 'remark', title: '备注',align:'center'},
|
|||
|
|
// {field: 'userName', title: '处理人',align:'center'},
|
|||
|
|
{field: 'status', title: '处理状态',align:'center'},
|
|||
|
|
// {field: 'updateTime', title: '处理时间',align:'center'},
|
|||
|
|
{fixed: 'right', title: '操作', align:'center',toolbar: '#barDemo' }
|
|||
|
|
]],
|
|||
|
|
initComplete: function () {
|
|||
|
|
// 在表格渲染完成后,重新渲染序号列
|
|||
|
|
var that = this.elem.next();
|
|||
|
|
var tool = that.children('.layui-table-box').children('.layui-table-fixed').children('.layui-table-body').children('.layui-table');
|
|||
|
|
tool.find("tr").each(function (index, item) {
|
|||
|
|
$(this).find('td[data-field="LAY_TABLE_INDEX"]').text(index + 1);
|
|||
|
|
});
|
|||
|
|
},
|
|||
|
|
done:function(res, curr, count, origin){
|
|||
|
|
// console.log(res);
|
|||
|
|
$("[data-field='status']").children().each(function(){
|
|||
|
|
if($(this).text()=='0'){
|
|||
|
|
$(this).text('未处理')
|
|||
|
|
}else if($(this).text()=='1'){
|
|||
|
|
$(this).text('告警')
|
|||
|
|
}else if($(this).text()=='2'){
|
|||
|
|
$(this).text('未告警')
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
})
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
function getQueryList(){
|
|||
|
|
init(buildCheck)
|
|||
|
|
}
|
|||
|
|
|