...
|
...
|
@@ -59,59 +59,47 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','reslist','sessions',' |
|
|
return;
|
|
|
}
|
|
|
var tempData = table.checkStatus('alarmtemplateTable').data;
|
|
|
if(tempData && tempData.length > 0){
|
|
|
$('[lay-id="/baseconfig/alarmpolicy/index"]').find('.layui-tab-close').trigger('click');
|
|
|
var url = 'baseconfig/alarmpolicy/index';
|
|
|
var params = {type:'alarmTemplate'};
|
|
|
view('commonViewModel').render(url,params).then(function (res) {
|
|
|
layer.open({
|
|
|
title: ["配置策略", 'font-size:18px;'],
|
|
|
type: 1,
|
|
|
area: ['90%', '90%'],
|
|
|
resize: false,
|
|
|
content: laytpl(res.body).render(JSON.stringify(params)),
|
|
|
btn: ["选择","取消"],
|
|
|
id:'alarm_template_Table_tactics',//设定一个id,防止重复弹出
|
|
|
success: function (index, layero) {
|
|
|
var oldAlarmPolicyIdList = [];
|
|
|
if (tempData.length<=1){
|
|
|
admin.req({
|
|
|
url: common.domainName + '/api-web/alarmPolicy/getbytempId/'+tempData[0].alarmTempId,
|
|
|
async: false,
|
|
|
error: function () {
|
|
|
layer.close(loading);
|
|
|
}
|
|
|
}).done(function (response) {
|
|
|
if (response) {
|
|
|
oldAlarmPolicyIdList = response.data.map(item => item.alarmPolicyId)
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
},
|
|
|
yes: function (index, layero) {
|
|
|
var policyData = layui.alarmpolicyIndex().getData();
|
|
|
if(policyData && policyData.length > 0){
|
|
|
var tempIds = [],policyIds=[];
|
|
|
$.each(tempData,function (i,v){
|
|
|
tempIds.push(v.alarmTempId);
|
|
|
})
|
|
|
$.each(policyData,function (i,v){
|
|
|
policyIds.push(v.alarmPolicyId);
|
|
|
})
|
|
|
admin.req({
|
|
|
url : domainName + '/api-web/alarmtemplate/config/policy'
|
|
|
,type:'post'
|
|
|
,data:{ tempIds:tempIds.toString(),policyIds:policyIds.toString() }
|
|
|
,done:function (res){
|
|
|
if(res.success){
|
|
|
layer.msg(res.msg, { offset: '15px' , icon: 1 , time: 1000 },function (){
|
|
|
layer.closeAll();
|
|
|
reloadalarmtemplateTable();
|
|
|
});
|
|
|
}else{
|
|
|
layer.msg(res.msg, { offset: '15px' , icon: 7 , time: 1000 });
|
|
|
}
|
|
|
}
|
|
|
if(tempData && tempData.length > 0){
|
|
|
common.openWin("baseconfig/alarmpolicy/index","选择策略",{oldData:oldAlarmPolicyIdList},["选择","取消"], function () {
|
|
|
var policyData = layui.alarmpolicyIndex().getData();
|
|
|
var tempIds = [],policyIds=[];
|
|
|
$.each(tempData,function (i,v){
|
|
|
tempIds.push(v.alarmTempId);
|
|
|
})
|
|
|
$.each(policyData,function (i,v){
|
|
|
policyIds.push(v.alarmPolicyId);
|
|
|
})
|
|
|
admin.req({
|
|
|
url : domainName + '/api-web/alarmtemplate/config/policy'
|
|
|
,type:'post'
|
|
|
,data:{ tempIds:tempIds.toString(),policyIds:policyIds.toString() }
|
|
|
,done:function (res){
|
|
|
if(res.success){
|
|
|
layer.msg(res.msg, { offset: '15px' , icon: 1 , time: 1000 },function (){
|
|
|
layer.closeAll();
|
|
|
reloadalarmtemplateTable();
|
|
|
});
|
|
|
}else{
|
|
|
layer.msg("请至少选择一条策略", { offset: '15px' , icon: 7 , time: 1000 });
|
|
|
return false;
|
|
|
layer.msg(res.msg, { offset: '15px' , icon: 7 , time: 1000 });
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
})
|
|
|
})
|
|
|
|
|
|
// common.openWin("baseconfig/alarmpolicy/index","配置策略",{type:'alarmTemplate'},["选择","取消"], function () {
|
|
|
//
|
|
|
// });
|
|
|
});
|
|
|
});
|
|
|
}else{
|
|
|
layer.msg("请至少选择一条数据!", { offset: '15px' , icon: 7 , time: 1000 });
|
|
|
}
|
...
|
...
|
@@ -135,7 +123,24 @@ layui.define(['table', 'form', 'admin', 'layer', 'common','reslist','sessions',' |
|
|
layer.msg('请选择一条要配置的数据',{icon: 7,time:2000});
|
|
|
return;
|
|
|
}
|
|
|
common.openWin("template/res/reslist","配置资源",{},["选择","取消"], function () {
|
|
|
var oldResIdList = [];
|
|
|
if (tempIds.length<=1){
|
|
|
admin.req({
|
|
|
url: common.domainName + '/api-web/alarmtemplate/getResIdByTempId',
|
|
|
async: false,
|
|
|
data: {
|
|
|
tempId:tempIds.toString(),
|
|
|
},
|
|
|
error: function () {
|
|
|
layer.close(loading);
|
|
|
}
|
|
|
}).done(function (response) {
|
|
|
if (response) {
|
|
|
oldResIdList = response.data.map(item => item.resId)
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
common.openWin("template/res/reslist","配置资源",{oldData:oldResIdList},["选择","取消"], function () {
|
|
|
var resObj = layui.reslist().getData();
|
|
|
if(resObj && resObj.length > 0){
|
|
|
var resIds = [];
|
...
|
...
|
|