1
|
//告警策略
|
1
|
//告警策略
|
2
|
-layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], function (exports) {
|
2
|
+layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist','table','xmSelect'], function (exports) {
|
3
|
var $ = layui.$;
|
3
|
var $ = layui.$;
|
4
|
var form = layui.form;
|
4
|
var form = layui.form;
|
5
|
var laydate = layui.laydate;
|
5
|
var laydate = layui.laydate;
|
6
|
var admin = layui.admin;
|
6
|
var admin = layui.admin;
|
7
|
var common = layui.common;
|
7
|
var common = layui.common;
|
8
|
var domainName = common.domainName;
|
8
|
var domainName = common.domainName;
|
|
|
9
|
+ var table = layui.table;
|
|
|
10
|
+ var xmSelect = layui.xmSelect;
|
9
|
|
11
|
|
10
|
//对外暴露的接口
|
12
|
//对外暴露的接口
|
11
|
exports('alarmpolicyAdd', function (data) {
|
13
|
exports('alarmpolicyAdd', function (data) {
|
12
|
var sessions = layui.sessions;
|
14
|
var sessions = layui.sessions;
|
13
|
var accessToken = sessions.getToken()['access_token'];
|
15
|
var accessToken = sessions.getToken()['access_token'];
|
14
|
- console.log(data)
|
16
|
+ var seriousInkeySelect ;
|
|
|
17
|
+ var options = '';
|
|
|
18
|
+ var defaultoptions = '';
|
|
|
19
|
+ var conditionoptions = "<option value=\"2\">等于</option>\n" +
|
|
|
20
|
+ " <option value=\"6\">包含</option>\n" +
|
|
|
21
|
+ " <option value=\"9\">不包含</option>";
|
|
|
22
|
+ var seriousresIds = [];
|
|
|
23
|
+ var importantresIds = [];
|
|
|
24
|
+ var commonlyresIds = [];
|
|
|
25
|
+ var seriousresTypes = [];
|
|
|
26
|
+ var importantresTypes = [];
|
|
|
27
|
+ var commonlyresTypes = [];
|
|
|
28
|
+ var seriousJoinTypes = [];
|
|
|
29
|
+ var importantJoinTypes = [];
|
|
|
30
|
+ var commonlyJoinTypes = [];
|
|
|
31
|
+ var seriousInkeys = '';
|
|
|
32
|
+ var importantInkeys = '';
|
|
|
33
|
+ var commonlyInkeys = '';
|
|
|
34
|
+ var policyConfigItems = [];
|
15
|
form.render(null, 'add-alarmpolicy-form');
|
35
|
form.render(null, 'add-alarmpolicy-form');
|
16
|
//初始化日期组件
|
36
|
//初始化日期组件
|
17
|
laydate.render({
|
37
|
laydate.render({
|
|
@@ -29,7 +49,6 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
|
@@ -29,7 +49,6 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
29
|
,type: 'time'
|
49
|
,type: 'time'
|
30
|
,range: true
|
50
|
,range: true
|
31
|
});
|
51
|
});
|
32
|
- var resType = localStorage.getItem("currentResType");
|
|
|
33
|
//编辑
|
52
|
//编辑
|
34
|
if(data && data.id){
|
53
|
if(data && data.id){
|
35
|
admin.req({
|
54
|
admin.req({
|
|
@@ -42,10 +61,144 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
|
@@ -42,10 +61,144 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
42
|
exprToChar(res.object, 'seriousExpr');
|
61
|
exprToChar(res.object, 'seriousExpr');
|
43
|
form.val("add-alarmpolicy-form",res.object);
|
62
|
form.val("add-alarmpolicy-form",res.object);
|
44
|
$("#alarm-policy-kpiName").val(res.object.kpiId +" "+ res.object.kpiName);
|
63
|
$("#alarm-policy-kpiName").val(res.object.kpiId +" "+ res.object.kpiName);
|
|
|
64
|
+ $("#serious_policy_param_val").val(res.object.kpiId);
|
|
|
65
|
+ $("#important_policy_param_val").val(res.object.kpiId);
|
|
|
66
|
+ $("#commonly_policy_param_val").val(res.object.kpiId);
|
45
|
$("#seriousTimes").val(res.object.seriousTimes);
|
67
|
$("#seriousTimes").val(res.object.seriousTimes);
|
46
|
$("#importantTimes").val(res.object.importantTimes);
|
68
|
$("#importantTimes").val(res.object.importantTimes);
|
47
|
$("#commonlyTimes").val(res.object.commonlyTimes);
|
69
|
$("#commonlyTimes").val(res.object.commonlyTimes);
|
48
|
$("#alarmPolicyType").val(res.object.policyType);
|
70
|
$("#alarmPolicyType").val(res.object.policyType);
|
|
|
71
|
+ if(res.data && res.data.length>0){
|
|
|
72
|
+ let seriousItems = res.data.filter(item=>item.policyFlag === 'serious');
|
|
|
73
|
+ let importantItems = res.data.filter(item=>item.policyFlag === 'important');
|
|
|
74
|
+ let commonlyItems = res.data.filter(item=>item.policyFlag === 'commonly');
|
|
|
75
|
+ seriouspolicyItems =seriousItems;
|
|
|
76
|
+ importantpolicyItems = importantItems;
|
|
|
77
|
+ commonlypolicyItems = commonlyItems;
|
|
|
78
|
+ if(seriousItems && seriousItems.length>0){
|
|
|
79
|
+
|
|
|
80
|
+ var timeobj ={}
|
|
|
81
|
+ for (let i = 0; i < seriousItems.length; i++) {
|
|
|
82
|
+ var times = new Date().getTime();
|
|
|
83
|
+ timeobj['time'+i] =times;
|
|
|
84
|
+ var cond = '';
|
|
|
85
|
+ if(seriousItems[i].relationSymbol && seriousItems[i].relationSymbol == '0'){
|
|
|
86
|
+ cond = `<div class="layui-form-item cont-base" id="serious-policy-box-${times}-condition">
|
|
|
87
|
+ <input type="checkbox" lay-skin="switch" lay-text="或|且" value="是">
|
|
|
88
|
+ </div>`;
|
|
|
89
|
+ }else if(seriousItems[i].relationSymbol && seriousItems[i].relationSymbol == '1'){
|
|
|
90
|
+ cond = `<div class="layui-form-item cont-base" id="serious-policy-box-${times}-condition">
|
|
|
91
|
+ <input type="checkbox" lay-skin="switch" lay-text="或|且" checked value="否">
|
|
|
92
|
+ </div>`;
|
|
|
93
|
+ }
|
|
|
94
|
+ var clone = ""
|
|
|
95
|
+ if(i<seriousItems.length-1) {
|
|
|
96
|
+ clone = $(`#serious-policy-box`).clone();
|
|
|
97
|
+ clone.attr("id", "serious-policy-box-" + times).find("i.policy-input-add").addClass("hide")
|
|
|
98
|
+ .parent().parent().find("i.policy-input-del").attr("data-id", "serious-policy-box-" + times).removeClass("hide")
|
|
|
99
|
+ .parent().parent().find("div.paramval").addClass("hide")
|
|
|
100
|
+ .parent().parent().find("input.layui-input").val("");
|
|
|
101
|
+ clone.find("select.policyparam").html(options);
|
|
|
102
|
+ clone.find("select.condition").html(conditionoptions);
|
|
|
103
|
+ clone.find("input[type=tel]").val('');
|
|
|
104
|
+ }
|
|
|
105
|
+ if(i==0) {
|
|
|
106
|
+ $(`#serious-policy-box`).after(clone).after(cond);
|
|
|
107
|
+ $("#serious-policy-box select.condition").val(seriousItems[0].operatorSymbol);
|
|
|
108
|
+ $("#serious-policy-box input[type=tel]").val(seriousItems[0].operatorValue);
|
|
|
109
|
+ }else{
|
|
|
110
|
+ var timestr =timeobj['time'+(i-1)];
|
|
|
111
|
+ $(`#serious-policy-box-${timestr}`).after(clone).after(cond);
|
|
|
112
|
+ $(`#serious-policy-box-${timestr} select.policyparam`).val(seriousItems[i].confNo);
|
|
|
113
|
+ $(`#serious-policy-box-${timestr} select.condition`).val(seriousItems[i].operatorSymbol);
|
|
|
114
|
+ $(`#serious-policy-box-${timestr} input[type=tel]`).val(seriousItems[i].operatorValue);
|
|
|
115
|
+ }
|
|
|
116
|
+ form.render();
|
|
|
117
|
+ }
|
|
|
118
|
+ }
|
|
|
119
|
+ if(importantItems && importantItems.length>0){
|
|
|
120
|
+ var timeobj ={}
|
|
|
121
|
+ for (let i = 0; i < importantItems.length; i++) {
|
|
|
122
|
+ var times = new Date().getTime();
|
|
|
123
|
+ timeobj['time'+i] =times;
|
|
|
124
|
+ var cond = '';
|
|
|
125
|
+ if(importantItems[i].relationSymbol && importantItems[i].relationSymbol == '0'){
|
|
|
126
|
+ cond = `<div class="layui-form-item cont-base" id="important-policy-box-${times}-condition">
|
|
|
127
|
+ <input type="checkbox" lay-skin="switch" lay-text="或|且" value="是">
|
|
|
128
|
+ </div>`;
|
|
|
129
|
+ }else if(importantItems[i].relationSymbol && importantItems[i].relationSymbol == '1'){
|
|
|
130
|
+ cond = `<div class="layui-form-item cont-base" id="important-policy-box-${times}-condition">
|
|
|
131
|
+ <input type="checkbox" checked lay-skin="switch" lay-text="或|且" value="否">
|
|
|
132
|
+ </div>`;
|
|
|
133
|
+ }
|
|
|
134
|
+ var clone = ""
|
|
|
135
|
+ if(i<importantItems.length-1) {
|
|
|
136
|
+ clone = $(`#important-policy-box`).clone();
|
|
|
137
|
+ clone.attr("id", "important-policy-box-" + times).find("i.policy-input-add").addClass("hide")
|
|
|
138
|
+ .parent().parent().find("i.policy-input-del").attr("data-id", "important-policy-box-" + times).removeClass("hide")
|
|
|
139
|
+ .parent().parent().find("div.paramval").addClass("hide")
|
|
|
140
|
+ .parent().parent().find("input.layui-input").val("");
|
|
|
141
|
+ clone.find("select.policyparam").html(options);
|
|
|
142
|
+ clone.find("select.condition").html(conditionoptions);
|
|
|
143
|
+ clone.find("input[type=tel]").val('');
|
|
|
144
|
+ }
|
|
|
145
|
+ if(i==0) {
|
|
|
146
|
+ $(`#important-policy-box`).after(clone).after(cond);
|
|
|
147
|
+ $("#important-policy-box select.condition").val(importantItems[0].operatorSymbol);
|
|
|
148
|
+ $("#important-policy-box input[type=tel]").val(importantItems[0].operatorValue);
|
|
|
149
|
+ }else{
|
|
|
150
|
+ var timestr =timeobj['time'+(i-1)];
|
|
|
151
|
+ $(`#important-policy-box-${timestr}`).after(clone).after(cond);
|
|
|
152
|
+ $(`#important-policy-box-${timestr} select.policyparam`).val(importantItems[i].confNo);
|
|
|
153
|
+ $(`#important-policy-box-${timestr} select.condition`).val(importantItems[i].operatorSymbol);
|
|
|
154
|
+ $(`#important-policy-box-${timestr} input[type=tel]`).val(importantItems[i].operatorValue);
|
|
|
155
|
+ }
|
|
|
156
|
+ form.render();
|
|
|
157
|
+ }
|
|
|
158
|
+ }
|
|
|
159
|
+ if(commonlyItems && commonlyItems.length>0){
|
|
|
160
|
+ var timeobj ={}
|
|
|
161
|
+ for (let i = 0; i < commonlyItems.length; i++) {
|
|
|
162
|
+ var times = new Date().getTime();
|
|
|
163
|
+ timeobj['time'+i] =times;
|
|
|
164
|
+ var cond = '';
|
|
|
165
|
+ if(commonlyItems[i].relationSymbol && commonlyItems[i].relationSymbol == '0'){
|
|
|
166
|
+ cond = `<div class="layui-form-item cont-base" id="commonly-policy-box-${times}-condition">
|
|
|
167
|
+ <input type="checkbox" lay-skin="switch" lay-text="或|且" value="是">
|
|
|
168
|
+ </div>`;
|
|
|
169
|
+ }else if(commonlyItems[i].relationSymbol && commonlyItems[i].relationSymbol == '1'){
|
|
|
170
|
+ cond = `<div class="layui-form-item cont-base" id="commonly-policy-box-${times}-condition">
|
|
|
171
|
+ <input type="checkbox" checked lay-skin="switch" lay-text="或|且" value="否">
|
|
|
172
|
+ </div>`;
|
|
|
173
|
+ }
|
|
|
174
|
+ var clone = ""
|
|
|
175
|
+ if(i<commonlyItems.length-1) {
|
|
|
176
|
+ clone = $(`#commonly-policy-box`).clone();
|
|
|
177
|
+ clone.attr("id", "commonly-policy-box-" + times).find("i.policy-input-add").addClass("hide")
|
|
|
178
|
+ .parent().parent().find("i.policy-input-del").attr("data-id", "commonly-policy-box-" + times).removeClass("hide")
|
|
|
179
|
+ .parent().parent().find("div.paramval").addClass("hide")
|
|
|
180
|
+ .parent().parent().find("input.layui-input").val("");
|
|
|
181
|
+ clone.find("select.policyparam").html(options);
|
|
|
182
|
+ clone.find("select.condition").html(conditionoptions);
|
|
|
183
|
+ clone.find("input[type=tel]").val('');
|
|
|
184
|
+ }
|
|
|
185
|
+ if(i==0) {
|
|
|
186
|
+ $(`#commonly-policy-box`).after(clone).after(cond);
|
|
|
187
|
+ $("#commonly-policy-box select.condition").val(commonlyItems[0].operatorSymbol);
|
|
|
188
|
+ $("#commonly-policy-box input[type=tel]").val(commonlyItems[0].operatorValue);
|
|
|
189
|
+ }else{
|
|
|
190
|
+ var timestr =timeobj['time'+(i-1)];
|
|
|
191
|
+ $(`#commonly-policy-box-${timestr}`).after(clone).after(cond);
|
|
|
192
|
+ $(`#commonly-policy-box-${timestr} select.policyparam`).val(commonlyItems[i].confNo);
|
|
|
193
|
+ $(`#commonly-policy-box-${timestr} select.condition`).val(commonlyItems[i].operatorSymbol);
|
|
|
194
|
+ $(`#commonly-policy-box-${timestr} input[type=tel]`).val(commonlyItems[i].operatorValue);
|
|
|
195
|
+ }
|
|
|
196
|
+
|
|
|
197
|
+ form.render();
|
|
|
198
|
+ }
|
|
|
199
|
+ }
|
|
|
200
|
+
|
|
|
201
|
+ }
|
49
|
}
|
202
|
}
|
50
|
});
|
203
|
});
|
51
|
}else{
|
204
|
}else{
|
|
@@ -67,21 +220,376 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
|
@@ -67,21 +220,376 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
67
|
var id = $(this).data("flag");
|
220
|
var id = $(this).data("flag");
|
68
|
$("#"+id).val('08:00:00 - 19:59:59');
|
221
|
$("#"+id).val('08:00:00 - 19:59:59');
|
69
|
});
|
222
|
});
|
70
|
- // zhangtianqi 2022-06-22
|
|
|
71
|
- /*$('.noticeExpr').unbind('click').on('click', function () {
|
|
|
72
|
- var id = $(this).prop('id');
|
|
|
73
|
- var alarmTimes = '';
|
|
|
74
|
- if (['seriousExpr', 'importantExpr', 'commonlyExpr'].includes(id)) {
|
|
|
75
|
- id = id.substring(0, id.length - 4);
|
|
|
76
|
- alarmTimes = $('#' + id + 'Times').val();
|
|
|
77
|
- }
|
|
|
78
|
- editNoticeExpr($(this).val(), alarmTimes, id);
|
|
|
79
|
- });*/
|
|
|
80
|
//指标信息
|
223
|
//指标信息
|
81
|
if(data.kpiId){
|
224
|
if(data.kpiId){
|
82
|
$("#alarm-policy-kpiId").val(data.kpiId);
|
225
|
$("#alarm-policy-kpiId").val(data.kpiId);
|
83
|
$("#alarm-policy-kpiName").val(data.kpiId + " " + data.name);
|
226
|
$("#alarm-policy-kpiName").val(data.kpiId + " " + data.name);
|
84
|
}
|
227
|
}
|
|
|
228
|
+ initpolicyParam();
|
|
|
229
|
+ function initpolicyParam() {
|
|
|
230
|
+ admin.req({
|
|
|
231
|
+ url: `${domainName}/api-web/manage/ddic/findSucDdics/alarmpolicy_param?access_token=${accessToken}`,
|
|
|
232
|
+ method: 'POST',
|
|
|
233
|
+ async: false,
|
|
|
234
|
+ success: function (res) {
|
|
|
235
|
+ var ddiclist = res.data;
|
|
|
236
|
+ $.each(ddiclist, function (i, v) {
|
|
|
237
|
+ if(v.ddicCode=="current_kpi") {
|
|
|
238
|
+ defaultoptions += '<option value="' + v.ddicCode + '">' + v.ddicName + '</option>';
|
|
|
239
|
+ $('select[name=serious_policy_param]').html(defaultoptions);
|
|
|
240
|
+ $('select[name=important_policy_param]').html(defaultoptions);
|
|
|
241
|
+ $('select[name=commonly_policy_param]').html(defaultoptions);
|
|
|
242
|
+
|
|
|
243
|
+ }else {
|
|
|
244
|
+ options += '<option value="' + v.ddicCode + '">' + v.ddicName + '</option>';
|
|
|
245
|
+ }
|
|
|
246
|
+ });
|
|
|
247
|
+ form.render('select');
|
|
|
248
|
+ }
|
|
|
249
|
+ });
|
|
|
250
|
+ }
|
|
|
251
|
+ form.on('select(serious_policy_param)', function(data){
|
|
|
252
|
+ if (data.value != ''){
|
|
|
253
|
+ //加载对应的参数
|
|
|
254
|
+ if(data.value == "device_id"){
|
|
|
255
|
+ var device_id = $(this).closest(".cont-base").find("input[type=tel]");
|
|
|
256
|
+ $(this).closest(".cont-base").find("input[type=tel]").unbind('click').on("click",function () {
|
|
|
257
|
+ common.openWin("template/res/reslist", "选择设备", {oldData: seriousresIds}, ["选择"], function () {
|
|
|
258
|
+ var data = table.checkStatus('reslist_resListTable').data;
|
|
|
259
|
+ if (data.length == 0) {
|
|
|
260
|
+ layer.msg("请至少选择一条数据!", {icon: 7, time: 3000});
|
|
|
261
|
+ return false;
|
|
|
262
|
+ }
|
|
|
263
|
+ seriousresIds = [];
|
|
|
264
|
+ var device = ''
|
|
|
265
|
+ $.each(data, function (i, v) {
|
|
|
266
|
+ seriousresIds.push(v.id);
|
|
|
267
|
+ device +=v.id + ',';
|
|
|
268
|
+
|
|
|
269
|
+ })
|
|
|
270
|
+ if(device.length>0){
|
|
|
271
|
+ device = device.substring(0,device.length-1)
|
|
|
272
|
+ }
|
|
|
273
|
+ console.log(device_id)
|
|
|
274
|
+ device_id.val(device);
|
|
|
275
|
+ return device;
|
|
|
276
|
+ })
|
|
|
277
|
+ })
|
|
|
278
|
+
|
|
|
279
|
+ }else if(data.value== "dev_type"){
|
|
|
280
|
+ var dev_type = $(this).closest(".cont-base").find("input[type=tel]");
|
|
|
281
|
+ $(this).closest(".cont-base").find("input[type=tel]").unbind('click').on("click",function () {
|
|
|
282
|
+ //回填数据
|
|
|
283
|
+ common.openWin("baseconfig/resourcetype/index", "选择设备类型",
|
|
|
284
|
+ {
|
|
|
285
|
+ "resTypes": seriousresTypes
|
|
|
286
|
+ }, ["选择"], function () {
|
|
|
287
|
+ //找到选择的资源类型 并且订阅
|
|
|
288
|
+ var resourcetype = layui.resourcetype({"resTypes": seriousresTypes});
|
|
|
289
|
+ var data = resourcetype.getResTypeChecks();
|
|
|
290
|
+ var resTypes = ''
|
|
|
291
|
+ seriousresTypes = [];
|
|
|
292
|
+ if(data.length>0){
|
|
|
293
|
+ resTypes = data.substring(1,data.length)
|
|
|
294
|
+ }
|
|
|
295
|
+ seriousresTypes.push(resTypes.split(",")[0])
|
|
|
296
|
+ dev_type.val(resTypes);
|
|
|
297
|
+ return resTypes;
|
|
|
298
|
+ });
|
|
|
299
|
+ });
|
|
|
300
|
+ }else if(data.value == "join_type"){
|
|
|
301
|
+ var join_type= $(this).closest(".cont-base").find("input[type=tel]");
|
|
|
302
|
+ $(this).closest(".cont-base").find("input[type=tel]").unbind('click').on("click",function () {
|
|
|
303
|
+ //回填数据
|
|
|
304
|
+ common.openWin("baseconfig/bustype/index", "选择业务类型",
|
|
|
305
|
+ {
|
|
|
306
|
+ "busIds": seriousJoinTypes
|
|
|
307
|
+ }, ["选择"], function () {
|
|
|
308
|
+ //找到选择的所有业务 并且订阅
|
|
|
309
|
+ var bustype = layui.bustype({"busIds": seriousJoinTypes});
|
|
|
310
|
+ var data = bustype.getData();
|
|
|
311
|
+ var joinTypes = ''
|
|
|
312
|
+ seriousJoinTypes = [];
|
|
|
313
|
+ if(data.length>0){
|
|
|
314
|
+ joinTypes = data.substring(1,data.length)
|
|
|
315
|
+ }
|
|
|
316
|
+ seriousJoinTypes.push(joinTypes.split(",")[0]);
|
|
|
317
|
+ join_type.val(joinTypes);
|
|
|
318
|
+ return joinTypes
|
|
|
319
|
+ });
|
|
|
320
|
+ });
|
|
|
321
|
+ }else if(data.value == "inKey"){
|
|
|
322
|
+ //绑定资源类型下拉选择
|
|
|
323
|
+ $(this).closest(".cont-base").find("input[type=tel]").before('<div id="seriousvalue" class="xm-select-demo"></div>');
|
|
|
324
|
+ var inkeys= $(this).closest(".cont-base").find("input[type=tel]");
|
|
|
325
|
+ var seriousvalue =$(this).closest(".cont-base").find("div#seriousvalue");
|
|
|
326
|
+ //inkeys.hide();
|
|
|
327
|
+ $(this).closest(".cont-base").find("input[type=tel]").unbind('click').on("click",function () {
|
|
|
328
|
+ admin.req({
|
|
|
329
|
+ url: 'http://192.168.0.44:8080' + '/log-access/v1/lm2_logjoin_info_views?access_token=' + accessToken,
|
|
|
330
|
+ async: false,
|
|
|
331
|
+ success: function (res) {
|
|
|
332
|
+ // 资源类型下拉框
|
|
|
333
|
+ var logjoinList = res.data;
|
|
|
334
|
+ xmSelect.render({
|
|
|
335
|
+ el: '#seriousvalue',
|
|
|
336
|
+ tips: '=inKey=',
|
|
|
337
|
+ filterable: true,
|
|
|
338
|
+ //radio: false,
|
|
|
339
|
+ clickClose: false,
|
|
|
340
|
+ initValue: [seriousInkeys.split(",")[0]],
|
|
|
341
|
+ layVerify: 'required',
|
|
|
342
|
+ autoRow: true,
|
|
|
343
|
+ toolbar: {
|
|
|
344
|
+ show: true,
|
|
|
345
|
+ list: ['CLEAR']
|
|
|
346
|
+ },
|
|
|
347
|
+ height: '300px',
|
|
|
348
|
+ data: logjoinList,
|
|
|
349
|
+ on: function (data) {
|
|
|
350
|
+ seriousInkeys = data.arr.map(item => item.inKey).join(',');
|
|
|
351
|
+ inkeys.val(seriousInkeys);
|
|
|
352
|
+ if(data && data.isAdd) {
|
|
|
353
|
+ seriousvalue.remove();
|
|
|
354
|
+ inkeys.show();
|
|
|
355
|
+ }
|
|
|
356
|
+ return seriousInkeys
|
|
|
357
|
+ }
|
|
|
358
|
+ });
|
|
|
359
|
+ }
|
|
|
360
|
+ });
|
|
|
361
|
+ })
|
|
|
362
|
+ }
|
|
|
363
|
+ }
|
|
|
364
|
+ });
|
|
|
365
|
+ form.on('select(important_policy_param)', function(data){
|
|
|
366
|
+ if (data.value != ''){
|
|
|
367
|
+ //加载对应的参数
|
|
|
368
|
+ if(data.value == "device_id"){
|
|
|
369
|
+ var device_id = $(this).closest(".cont-base").find("input[type=tel]");
|
|
|
370
|
+ $(this).closest(".cont-base").find("input[type=tel]").unbind('click').on("click",function () {
|
|
|
371
|
+ common.openWin("template/res/reslist", "选择设备", {oldData: importantresIds}, ["选择"], function () {
|
|
|
372
|
+ var data = table.checkStatus('reslist_resListTable').data;
|
|
|
373
|
+ if (data.length == 0) {
|
|
|
374
|
+ layer.msg("请至少选择一条数据!", {icon: 7, time: 3000});
|
|
|
375
|
+ return false;
|
|
|
376
|
+ }
|
|
|
377
|
+ importantresIds = [];
|
|
|
378
|
+ var device = ''
|
|
|
379
|
+ $.each(data, function (i, v) {
|
|
|
380
|
+ importantresIds.push(v.id);
|
|
|
381
|
+ device +=v.id + ',';
|
|
|
382
|
+
|
|
|
383
|
+ })
|
|
|
384
|
+ if(device.length>0){
|
|
|
385
|
+ device = device.substring(0,device.length-1)
|
|
|
386
|
+ }
|
|
|
387
|
+ console.log(device_id)
|
|
|
388
|
+ device_id.val(device);
|
|
|
389
|
+ return device;
|
|
|
390
|
+ })
|
|
|
391
|
+ })
|
|
|
392
|
+
|
|
|
393
|
+ }else if(data.value== "dev_type"){
|
|
|
394
|
+ var dev_type = $(this).closest(".cont-base").find("input[type=tel]");
|
|
|
395
|
+ $(this).closest(".cont-base").find("input[type=tel]").unbind('click').on("click",function () {
|
|
|
396
|
+ //回填数据
|
|
|
397
|
+ common.openWin("baseconfig/resourcetype/index", "选择设备类型",
|
|
|
398
|
+ {
|
|
|
399
|
+ "resTypes": importantresTypes
|
|
|
400
|
+ }, ["选择"], function () {
|
|
|
401
|
+ //找到选择的资源类型 并且订阅
|
|
|
402
|
+ var resourcetype = layui.resourcetype({"resTypes": importantresTypes});
|
|
|
403
|
+ var data = resourcetype.getResTypeChecks();
|
|
|
404
|
+ var resTypes = ''
|
|
|
405
|
+ importantresTypes = [];
|
|
|
406
|
+ if(data.length>0){
|
|
|
407
|
+ resTypes = data.substring(1,data.length)
|
|
|
408
|
+ }
|
|
|
409
|
+ importantresTypes.push(resTypes.split(",")[0])
|
|
|
410
|
+ dev_type.val(resTypes);
|
|
|
411
|
+ return resTypes;
|
|
|
412
|
+ });
|
|
|
413
|
+ });
|
|
|
414
|
+ }else if(data.value == "join_type"){
|
|
|
415
|
+ var join_type= $(this).closest(".cont-base").find("input[type=tel]");
|
|
|
416
|
+ $(this).closest(".cont-base").find("input[type=tel]").unbind('click').on("click",function () {
|
|
|
417
|
+ //回填数据
|
|
|
418
|
+ common.openWin("baseconfig/bustype/index", "选择业务类型",
|
|
|
419
|
+ {
|
|
|
420
|
+ "busIds": importantJoinTypes
|
|
|
421
|
+ }, ["选择"], function () {
|
|
|
422
|
+ //找到选择的所有业务 并且订阅
|
|
|
423
|
+ var bustype = layui.bustype({"busIds": importantJoinTypes});
|
|
|
424
|
+ var data = bustype.getData();
|
|
|
425
|
+ var joinTypes = ''
|
|
|
426
|
+ importantJoinTypes = [];
|
|
|
427
|
+ if(data.length>0){
|
|
|
428
|
+ joinTypes = data.substring(1,data.length)
|
|
|
429
|
+ }
|
|
|
430
|
+ importantJoinTypes.push(joinTypes.split(",")[0]);
|
|
|
431
|
+ join_type.val(joinTypes);
|
|
|
432
|
+ return joinTypes
|
|
|
433
|
+ });
|
|
|
434
|
+ });
|
|
|
435
|
+ }else if(data.value == "inKey"){
|
|
|
436
|
+ //绑定资源类型下拉选择
|
|
|
437
|
+ $(this).closest(".cont-base").find("input[type=tel]").before('<div id="importantvalue" class="xm-select-demo"></div>');
|
|
|
438
|
+ var inkeys= $(this).closest(".cont-base").find("input[type=tel]");
|
|
|
439
|
+ var importantvalue =$(this).closest(".cont-base").find("div#importantvalue");
|
|
|
440
|
+ //inkeys.hide();
|
|
|
441
|
+ $(this).closest(".cont-base").find("input[type=tel]").unbind('click').on("click",function () {
|
|
|
442
|
+ admin.req({
|
|
|
443
|
+ url: 'http://192.168.0.44:8080' + '/log-access/v1/lm2_logjoin_info_views?access_token=' + accessToken,
|
|
|
444
|
+ async: false,
|
|
|
445
|
+ success: function (res) {
|
|
|
446
|
+ // 资源类型下拉框
|
|
|
447
|
+ var logjoinList = res.data;
|
|
|
448
|
+ xmSelect.render({
|
|
|
449
|
+ el: '#importantvalue',
|
|
|
450
|
+ tips: '=inKey=',
|
|
|
451
|
+ filterable: true,
|
|
|
452
|
+ //radio: false,
|
|
|
453
|
+ clickClose: false,
|
|
|
454
|
+ initValue: [importantInkeys.split(",")[0]],
|
|
|
455
|
+ layVerify: 'required',
|
|
|
456
|
+ autoRow: true,
|
|
|
457
|
+ toolbar: {
|
|
|
458
|
+ show: true,
|
|
|
459
|
+ list: [ 'CLEAR']
|
|
|
460
|
+ },
|
|
|
461
|
+ height: '300px',
|
|
|
462
|
+ data: logjoinList,
|
|
|
463
|
+ on: function (data) {
|
|
|
464
|
+ importantInkeys = data.arr.map(item => item.inKey).join(',');
|
|
|
465
|
+ inkeys.val(importantInkeys);
|
|
|
466
|
+ if(data && data.isAdd) {
|
|
|
467
|
+ importantvalue.remove();
|
|
|
468
|
+ inkeys.show();
|
|
|
469
|
+ }
|
|
|
470
|
+ return importantInkeys
|
|
|
471
|
+ }
|
|
|
472
|
+ });
|
|
|
473
|
+ }
|
|
|
474
|
+ });
|
|
|
475
|
+ })
|
|
|
476
|
+ }
|
|
|
477
|
+ }
|
|
|
478
|
+ });
|
|
|
479
|
+ form.on('select(commonly_policy_param)', function(data){
|
|
|
480
|
+ if (data.value != ''){
|
|
|
481
|
+ //加载对应的参数
|
|
|
482
|
+ if(data.value == "device_id"){
|
|
|
483
|
+ var device_id = $(this).closest(".cont-base").find("input[type=tel]");
|
|
|
484
|
+ $(this).closest(".cont-base").find("input[type=tel]").unbind('click').on("click",function () {
|
|
|
485
|
+ common.openWin("template/res/reslist", "选择设备", {oldData: commonlyresIds}, ["选择"], function () {
|
|
|
486
|
+ var data = table.checkStatus('reslist_resListTable').data;
|
|
|
487
|
+ if (data.length == 0) {
|
|
|
488
|
+ layer.msg("请至少选择一条数据!", {icon: 7, time: 3000});
|
|
|
489
|
+ return false;
|
|
|
490
|
+ }
|
|
|
491
|
+ commonlyresIds = [];
|
|
|
492
|
+ var device = ''
|
|
|
493
|
+ $.each(data, function (i, v) {
|
|
|
494
|
+ commonlyresIds.push(v.id);
|
|
|
495
|
+ device +=v.id + ',';
|
|
|
496
|
+
|
|
|
497
|
+ })
|
|
|
498
|
+ if(device.length>0){
|
|
|
499
|
+ device = device.substring(0,device.length-1)
|
|
|
500
|
+ }
|
|
|
501
|
+ //console.log(device_id)
|
|
|
502
|
+ device_id.val(device);
|
|
|
503
|
+ return device;
|
|
|
504
|
+ })
|
|
|
505
|
+ })
|
|
|
506
|
+
|
|
|
507
|
+ }else if(data.value== "dev_type"){
|
|
|
508
|
+ var dev_type = $(this).closest(".cont-base").find("input[type=tel]");
|
|
|
509
|
+ $(this).closest(".cont-base").find("input[type=tel]").unbind('click').on("click",function () {
|
|
|
510
|
+ //回填数据
|
|
|
511
|
+ common.openWin("baseconfig/resourcetype/index", "选择设备类型",
|
|
|
512
|
+ {
|
|
|
513
|
+ "resTypes": commonlyresTypes
|
|
|
514
|
+ }, ["选择"], function () {
|
|
|
515
|
+ //找到选择的资源类型 并且订阅
|
|
|
516
|
+ var resourcetype = layui.resourcetype({"resTypes": commonlyresTypes});
|
|
|
517
|
+ var data = resourcetype.getResTypeChecks();
|
|
|
518
|
+ var resTypes = ''
|
|
|
519
|
+ commonlyresTypes = [];
|
|
|
520
|
+ if(data.length>0){
|
|
|
521
|
+ resTypes = data.substring(1,data.length)
|
|
|
522
|
+ }
|
|
|
523
|
+ commonlyresTypes.push(resTypes.split(",")[0])
|
|
|
524
|
+ dev_type.val(resTypes);
|
|
|
525
|
+ return resTypes;
|
|
|
526
|
+ });
|
|
|
527
|
+ });
|
|
|
528
|
+ }else if(data.value == "join_type"){
|
|
|
529
|
+ var join_type= $(this).closest(".cont-base").find("input[type=tel]");
|
|
|
530
|
+ $(this).closest(".cont-base").find("input[type=tel]").unbind('click').on("click",function () {
|
|
|
531
|
+ //回填数据
|
|
|
532
|
+ common.openWin("baseconfig/bustype/index", "选择业务类型",
|
|
|
533
|
+ {
|
|
|
534
|
+ "busIds": commonlyJoinTypes
|
|
|
535
|
+ }, ["选择"], function () {
|
|
|
536
|
+ //找到选择的所有业务 并且订阅
|
|
|
537
|
+ var bustype = layui.bustype({"busIds": commonlyJoinTypes});
|
|
|
538
|
+ var data = bustype.getData();
|
|
|
539
|
+ var joinTypes = ''
|
|
|
540
|
+ commonlyJoinTypes = [];
|
|
|
541
|
+ if(data.length>0){
|
|
|
542
|
+ joinTypes = data.substring(1,data.length)
|
|
|
543
|
+ }
|
|
|
544
|
+ commonlyJoinTypes.push(joinTypes.split(",")[0]);
|
|
|
545
|
+ join_type.val(joinTypes);
|
|
|
546
|
+ return joinTypes
|
|
|
547
|
+ });
|
|
|
548
|
+ });
|
|
|
549
|
+ }else if(data.value == "inKey"){
|
|
|
550
|
+ //绑定资源类型下拉选择
|
|
|
551
|
+ $(this).closest(".cont-base").find("input[type=tel]").before('<div id="commonlyvalue" class="xm-select-demo"></div>');
|
|
|
552
|
+ var inkeys= $(this).closest(".cont-base").find("input[type=tel]");
|
|
|
553
|
+ var commonlyvalue =$(this).closest(".cont-base").find("div#commonlyvalue");
|
|
|
554
|
+ //inkeys.hide();
|
|
|
555
|
+ $(this).closest(".cont-base").find("input[type=tel]").unbind('click').on("click",function () {
|
|
|
556
|
+ admin.req({
|
|
|
557
|
+ url: 'http://192.168.0.44:8080' + '/log-access/v1/lm2_logjoin_info_views?access_token=' + accessToken,
|
|
|
558
|
+ async: false,
|
|
|
559
|
+ success: function (res) {
|
|
|
560
|
+ // 资源类型下拉框
|
|
|
561
|
+ var logjoinList = res.data;
|
|
|
562
|
+ xmSelect.render({
|
|
|
563
|
+ el: '#commonlyvalue',
|
|
|
564
|
+ tips: '=inKey=',
|
|
|
565
|
+ filterable: true,
|
|
|
566
|
+ //radio: false,
|
|
|
567
|
+ clickClose: false,
|
|
|
568
|
+ initValue: [commonlyInkeys.split(",")[0]],
|
|
|
569
|
+ layVerify: 'required',
|
|
|
570
|
+ autoRow: true,
|
|
|
571
|
+ toolbar: {
|
|
|
572
|
+ show: true,
|
|
|
573
|
+ list: ['CLEAR']
|
|
|
574
|
+ },
|
|
|
575
|
+ height: '300px',
|
|
|
576
|
+ data: logjoinList,
|
|
|
577
|
+ on: function (data) {
|
|
|
578
|
+ commonlyInkeys = data.arr.map(item => item.inKey).join(',');
|
|
|
579
|
+ inkeys.val(commonlyInkeys);
|
|
|
580
|
+ if(data && data.isAdd) {
|
|
|
581
|
+ commonlyvalue.remove();
|
|
|
582
|
+ inkeys.show();
|
|
|
583
|
+ }
|
|
|
584
|
+ return commonlyInkeys
|
|
|
585
|
+ }
|
|
|
586
|
+ });
|
|
|
587
|
+ }
|
|
|
588
|
+ });
|
|
|
589
|
+ })
|
|
|
590
|
+ }
|
|
|
591
|
+ }
|
|
|
592
|
+ });
|
85
|
|
593
|
|
86
|
//告警规则类型切换事件
|
594
|
//告警规则类型切换事件
|
87
|
form.on('radio(alarm-policy-rule-type)', function (data) {
|
595
|
form.on('radio(alarm-policy-rule-type)', function (data) {
|
|
@@ -105,7 +613,9 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
|
@@ -105,7 +613,9 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
105
|
$("#alarm-policy-kpiId").val(data[0].kpiId);
|
613
|
$("#alarm-policy-kpiId").val(data[0].kpiId);
|
106
|
$("#alarm-policy-kpiName").val(data[0].kpiId + " " + data[0].kpiName);
|
614
|
$("#alarm-policy-kpiName").val(data[0].kpiId + " " + data[0].kpiName);
|
107
|
$("#alarmPolicyName").val(data[0].kpiName + "告警策略");
|
615
|
$("#alarmPolicyName").val(data[0].kpiName + "告警策略");
|
108
|
-
|
616
|
+ $("#serious_policy_param_val").val(data[0].kpiId);
|
|
|
617
|
+ $("#important_policy_param_val").val(data[0].kpiId);
|
|
|
618
|
+ $("#commonly_policy_param_val").val(data[0].kpiId);
|
109
|
var arry = [ "base", "cpu", "mem"];
|
619
|
var arry = [ "base", "cpu", "mem"];
|
110
|
return true;
|
620
|
return true;
|
111
|
}
|
621
|
}
|
|
@@ -123,7 +633,9 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
|
@@ -123,7 +633,9 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
123
|
$(`#${id}`).remove();
|
633
|
$(`#${id}`).remove();
|
124
|
});
|
634
|
});
|
125
|
|
635
|
|
126
|
-
|
636
|
+ var seriouspolicyItems = [];
|
|
|
637
|
+ var importantpolicyItems = [];
|
|
|
638
|
+ var commonlypolicyItems = [];
|
127
|
//生成策略
|
639
|
//生成策略
|
128
|
$("a.createpolicybtn").on("click",function (){
|
640
|
$("a.createpolicybtn").on("click",function (){
|
129
|
var kpiId = $("#alarm-policy-kpiId").val();
|
641
|
var kpiId = $("#alarm-policy-kpiId").val();
|
|
@@ -135,27 +647,200 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
|
@@ -135,27 +647,200 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
135
|
return false;
|
647
|
return false;
|
136
|
}
|
648
|
}
|
137
|
var policyFlag = $(this).data("flag");
|
649
|
var policyFlag = $(this).data("flag");
|
138
|
- var conOjb = {"0":">","1":"<","2":"=","3":">=","4":"<=","5":"equals","6":"contains","7":"startsWith","8":"endsWith"};
|
650
|
+ var conOjb = {"0":">","1":"<","2":"=","3":">=","4":"<=","5":"equals","6":"contains","7":"startsWith","8":"endsWith","9":"nocontains"};
|
139
|
var doms = $(`[id^=${policyFlag}-policy-box]`);
|
651
|
var doms = $(`[id^=${policyFlag}-policy-box]`);
|
140
|
var policyStr = '';
|
652
|
var policyStr = '';
|
141
|
- $(doms).each(function(i,v){
|
|
|
142
|
- var domId = $(v).attr("id");
|
|
|
143
|
- if(domId.indexOf("condition") != -1){//条件
|
|
|
144
|
- var open = $(v).find('.layui-form-switch').hasClass("layui-form-onswitch");
|
|
|
145
|
- if(open){ policyStr += "||" }else{ policyStr += "&&" }
|
|
|
146
|
- }else{ //值
|
|
|
147
|
- var conditon = $(v).find("."+policyFlag+"_condition").val();
|
|
|
148
|
- var cls = policyFlag +"_value";
|
|
|
149
|
- var conval = $(v).find('[flag="'+cls+'"]').val().trim();
|
|
|
150
|
- if(conval){
|
|
|
151
|
- if(conditon < 5){ //数字类的
|
|
|
152
|
- policyStr += `Double.parseDouble([${kpiId},kpiValue])${conOjb[conditon]}${conval}`;
|
|
|
153
|
- }else{ //字符串类的
|
|
|
154
|
- policyStr += `[${kpiId},kpiValue].${conOjb[conditon]}("${conval}")`;
|
653
|
+ var relationobj = {"1": 0,"3":1,"5":2,"7":3,"9":4,"11":5,"13":6,"15":7}
|
|
|
654
|
+ if(policyFlag.indexOf("serious")!=-1) {
|
|
|
655
|
+ seriouspolicyItems = [];
|
|
|
656
|
+ $(doms).each(function (i, v) {
|
|
|
657
|
+ var domId = $(v).attr("id");
|
|
|
658
|
+ if (domId.indexOf("condition") != -1) {//条件
|
|
|
659
|
+ var j = relationobj[''+i+''];
|
|
|
660
|
+ console.log(j);
|
|
|
661
|
+ var open = $(v).find('.layui-form-switch').hasClass("layui-form-onswitch");
|
|
|
662
|
+ if (open) {
|
|
|
663
|
+ policyStr += "||"
|
|
|
664
|
+
|
|
|
665
|
+ seriouspolicyItems[j].relationSymbol= "1"
|
|
|
666
|
+ } else {
|
|
|
667
|
+ policyStr += "&&"
|
|
|
668
|
+ seriouspolicyItems[j].relationSymbol= "0"
|
|
|
669
|
+ }
|
|
|
670
|
+ } else { //值
|
|
|
671
|
+ var conditon = $(v).find(".condition").val();
|
|
|
672
|
+ var cls = policyFlag + "_value";
|
|
|
673
|
+ var paramflag = policyFlag + "_policy_param"
|
|
|
674
|
+ var conval = $(v).find('[flag="' + cls + '"]').val().trim();
|
|
|
675
|
+ var param = $(v).find('[name="' + paramflag + '"]').val().trim();
|
|
|
676
|
+ if (conval && param) {
|
|
|
677
|
+ if (param == "current_kpi") {
|
|
|
678
|
+ var itemObj = {
|
|
|
679
|
+ "confNo":kpiId,
|
|
|
680
|
+ "kpiId" :kpiId,
|
|
|
681
|
+ "type":param,
|
|
|
682
|
+ "operatorSymbol":conditon,
|
|
|
683
|
+ 'operatorValue':conval,
|
|
|
684
|
+ "relationSymbol": '',
|
|
|
685
|
+ "isTermOver": 0,
|
|
|
686
|
+ "sort": 0,
|
|
|
687
|
+ "policyFlag":policyFlag
|
|
|
688
|
+ }
|
|
|
689
|
+ seriouspolicyItems.push(itemObj);
|
|
|
690
|
+ if (conditon < 5) { //数字类的
|
|
|
691
|
+ policyStr += `Double.parseDouble([${kpiId},kpiValue])${conOjb[conditon]}${conval}`;
|
|
|
692
|
+ } else { //字符串类的
|
|
|
693
|
+ policyStr += `[${kpiId},kpiValue]${conOjb[conditon]}("${conval}")`;
|
|
|
694
|
+ }
|
|
|
695
|
+ } else {
|
|
|
696
|
+ var itemObj = {
|
|
|
697
|
+ "confNo":param,
|
|
|
698
|
+ "kpiId" :kpiId,
|
|
|
699
|
+ "type":param,
|
|
|
700
|
+ "operatorSymbol":conditon,
|
|
|
701
|
+ 'operatorValue':conval,
|
|
|
702
|
+ "relationSymbol": '',
|
|
|
703
|
+ "isTermOver": 0,
|
|
|
704
|
+ "sort": i-1,
|
|
|
705
|
+ "policyFlag":policyFlag
|
|
|
706
|
+ }
|
|
|
707
|
+ seriouspolicyItems.push(itemObj);
|
|
|
708
|
+ if (conditon < 5) {
|
|
|
709
|
+ policyStr += `[${param}]${conOjb[conditon]}"${conval}"`;
|
|
|
710
|
+ } else {
|
|
|
711
|
+ policyStr += `[${param}]${conOjb[conditon]}("${conval}")`;
|
|
|
712
|
+ }
|
|
|
713
|
+
|
|
|
714
|
+ }
|
155
|
}
|
715
|
}
|
156
|
}
|
716
|
}
|
157
|
- }
|
|
|
158
|
- });
|
717
|
+ });
|
|
|
718
|
+ }else if(policyFlag.indexOf("important")!=-1){
|
|
|
719
|
+ importantpolicyItems = [];
|
|
|
720
|
+ $(doms).each(function (i, v) {
|
|
|
721
|
+ var domId = $(v).attr("id");
|
|
|
722
|
+ if (domId.indexOf("condition") != -1) {//条件
|
|
|
723
|
+ var j = relationobj[''+i+''];
|
|
|
724
|
+ var open = $(v).find('.layui-form-switch').hasClass("layui-form-onswitch");
|
|
|
725
|
+ if (open) {
|
|
|
726
|
+ policyStr += "||"
|
|
|
727
|
+ importantpolicyItems[j].relationSymbol= "1"
|
|
|
728
|
+ } else {
|
|
|
729
|
+ policyStr += "&&"
|
|
|
730
|
+ importantpolicyItems[j].relationSymbol= "0"
|
|
|
731
|
+ }
|
|
|
732
|
+ } else { //值
|
|
|
733
|
+ var conditon = $(v).find(".condition").val();
|
|
|
734
|
+ var cls = policyFlag + "_value";
|
|
|
735
|
+ var paramflag = policyFlag + "_policy_param"
|
|
|
736
|
+ var conval = $(v).find('[flag="' + cls + '"]').val().trim();
|
|
|
737
|
+ var param = $(v).find('[name="' + paramflag + '"]').val().trim();
|
|
|
738
|
+ if (conval && param) {
|
|
|
739
|
+ if (param == "current_kpi") {
|
|
|
740
|
+ var itemObj = {
|
|
|
741
|
+ "confNo":kpiId,
|
|
|
742
|
+ "kpiId" :kpiId,
|
|
|
743
|
+ "type":param,
|
|
|
744
|
+ "operatorSymbol": conditon,
|
|
|
745
|
+ 'operatorValue': conval,
|
|
|
746
|
+ "relationSymbol": '',
|
|
|
747
|
+ "isTermOver": 0,
|
|
|
748
|
+ "sort": 0,
|
|
|
749
|
+ "policyFlag":policyFlag
|
|
|
750
|
+ }
|
|
|
751
|
+ importantpolicyItems.push(itemObj);
|
|
|
752
|
+ if (conditon < 5) { //数字类的
|
|
|
753
|
+ policyStr += `Double.parseDouble([${kpiId},kpiValue])${conOjb[conditon]}${conval}`;
|
|
|
754
|
+ } else { //字符串类的
|
|
|
755
|
+ policyStr += `[${kpiId},kpiValue]${conOjb[conditon]}("${conval}")`;
|
|
|
756
|
+ }
|
|
|
757
|
+ } else {
|
|
|
758
|
+ var itemObj = {
|
|
|
759
|
+ "confNo":param,
|
|
|
760
|
+ "kpiId" :kpiId,
|
|
|
761
|
+ "type":param,
|
|
|
762
|
+ "operatorSymbol": conditon,
|
|
|
763
|
+ 'operatorValue': conval,
|
|
|
764
|
+ "relationSymbol": '',
|
|
|
765
|
+ "isTermOver": 0,
|
|
|
766
|
+ "sort": i-1,
|
|
|
767
|
+ "policyFlag":policyFlag
|
|
|
768
|
+ }
|
|
|
769
|
+ importantpolicyItems.push(itemObj);
|
|
|
770
|
+ if (conditon < 5) {
|
|
|
771
|
+ policyStr += `[${param}]${conOjb[conditon]}"${conval}"`;
|
|
|
772
|
+ } else {
|
|
|
773
|
+ policyStr += `[${param}]${conOjb[conditon]}("${conval}")`;
|
|
|
774
|
+ }
|
|
|
775
|
+
|
|
|
776
|
+ }
|
|
|
777
|
+ }
|
|
|
778
|
+ }
|
|
|
779
|
+ });
|
|
|
780
|
+
|
|
|
781
|
+ }else if(policyFlag.indexOf("commonly")!=-1){
|
|
|
782
|
+ commonlypolicyItems = [];
|
|
|
783
|
+ $(doms).each(function (i, v) {
|
|
|
784
|
+ var domId = $(v).attr("id");
|
|
|
785
|
+ if (domId.indexOf("condition") != -1) {//条件
|
|
|
786
|
+ var j = relationobj[''+i+''];
|
|
|
787
|
+ var open = $(v).find('.layui-form-switch').hasClass("layui-form-onswitch");
|
|
|
788
|
+ if (open) {
|
|
|
789
|
+ policyStr += "||"
|
|
|
790
|
+ commonlypolicyItems[j].relationSymbol= "1";
|
|
|
791
|
+ } else {
|
|
|
792
|
+ policyStr += "&&"
|
|
|
793
|
+ commonlypolicyItems[j].relationSymbol= "0";
|
|
|
794
|
+ }
|
|
|
795
|
+ } else { //值
|
|
|
796
|
+ var conditon = $(v).find(".condition").val();
|
|
|
797
|
+ var cls = policyFlag + "_value";
|
|
|
798
|
+ var paramflag = policyFlag + "_policy_param"
|
|
|
799
|
+ var conval = $(v).find('[flag="' + cls + '"]').val().trim();
|
|
|
800
|
+ var param = $(v).find('[name="' + paramflag + '"]').val().trim();
|
|
|
801
|
+ if (conval && param) {
|
|
|
802
|
+ if (param == "current_kpi") {
|
|
|
803
|
+ var itemObj = {
|
|
|
804
|
+ "confNo":kpiId,
|
|
|
805
|
+ "kpiId" :kpiId,
|
|
|
806
|
+ "type":param,
|
|
|
807
|
+ "operatorSymbol":conditon,
|
|
|
808
|
+ 'operatorValue':conval,
|
|
|
809
|
+ "relationSymbol": '',
|
|
|
810
|
+ "isTermOver": 0,
|
|
|
811
|
+ "sort": 0,
|
|
|
812
|
+ "policyFlag":policyFlag
|
|
|
813
|
+ }
|
|
|
814
|
+ commonlypolicyItems.push(itemObj);
|
|
|
815
|
+ if (conditon < 5) { //数字类的
|
|
|
816
|
+ policyStr += `Double.parseDouble([${kpiId},kpiValue])${conOjb[conditon]}${conval}`;
|
|
|
817
|
+ } else { //字符串类的
|
|
|
818
|
+ policyStr += `[${kpiId},kpiValue]${conOjb[conditon]}("${conval}")`;
|
|
|
819
|
+ }
|
|
|
820
|
+ } else {
|
|
|
821
|
+ var itemObj = {
|
|
|
822
|
+ "confNo":param,
|
|
|
823
|
+ "kpiId" :kpiId,
|
|
|
824
|
+ "type":param,
|
|
|
825
|
+ "operatorSymbol":conditon,
|
|
|
826
|
+ 'operatorValue': conval,
|
|
|
827
|
+ "relationSymbol": '',
|
|
|
828
|
+ "isTermOver": 0,
|
|
|
829
|
+ "sort": i-1,
|
|
|
830
|
+ "policyFlag":policyFlag
|
|
|
831
|
+ }
|
|
|
832
|
+ commonlypolicyItems.push(itemObj);
|
|
|
833
|
+ if (conditon < 5) {
|
|
|
834
|
+ policyStr += `[${param}]${conOjb[conditon]}"${conval}"`;
|
|
|
835
|
+ } else {
|
|
|
836
|
+ policyStr += `[${param}]${conOjb[conditon]}("${conval}")`;
|
|
|
837
|
+ }
|
|
|
838
|
+
|
|
|
839
|
+ }
|
|
|
840
|
+ }
|
|
|
841
|
+ }
|
|
|
842
|
+ });
|
|
|
843
|
+ }
|
159
|
if(policyStr){
|
844
|
if(policyStr){
|
160
|
$(`#${policyFlag}Policy`).val(policyStr);
|
845
|
$(`#${policyFlag}Policy`).val(policyStr);
|
161
|
}else{
|
846
|
}else{
|
|
@@ -186,11 +871,33 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
|
@@ -186,11 +871,33 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
186
|
charToExpr(data, 'commonlyExpr');
|
871
|
charToExpr(data, 'commonlyExpr');
|
187
|
charToExpr(data, 'importantExpr');
|
872
|
charToExpr(data, 'importantExpr');
|
188
|
charToExpr(data, 'seriousExpr');
|
873
|
charToExpr(data, 'seriousExpr');
|
189
|
-
|
874
|
+ var params = {};
|
|
|
875
|
+ var policyConfigObj ={}
|
|
|
876
|
+ policyConfigObj.seriousPolicyDesc = data["seriousPolicy"];
|
|
|
877
|
+ policyConfigObj.importantPolicyDesc = data["importantPolicy"];
|
|
|
878
|
+ policyConfigObj.commonlyPolicyDesc = data["commonlyPolicy"];
|
|
|
879
|
+ if(seriouspolicyItems.length>0) {
|
|
|
880
|
+ for (let i = 0; i < seriouspolicyItems.length; i++) {
|
|
|
881
|
+ policyConfigItems.push(seriouspolicyItems[i]);
|
|
|
882
|
+ }
|
|
|
883
|
+ }
|
|
|
884
|
+ if(importantpolicyItems.length>0){
|
|
|
885
|
+ for (let i = 0; i < importantpolicyItems.length; i++) {
|
|
|
886
|
+ policyConfigItems.push(importantpolicyItems[i]);
|
|
|
887
|
+ }
|
|
|
888
|
+ }
|
|
|
889
|
+ if(commonlypolicyItems.length>0){
|
|
|
890
|
+ for (let i = 0; i < commonlypolicyItems.length; i++) {
|
|
|
891
|
+ policyConfigItems.push(commonlypolicyItems[i]);
|
|
|
892
|
+ }
|
|
|
893
|
+ }
|
|
|
894
|
+ params.data = JSON.stringify(data);
|
|
|
895
|
+ params.policyConfigObj =JSON.stringify(policyConfigObj);
|
|
|
896
|
+ params.policyConfigItems = policyConfigItems;
|
190
|
form.on('submit(add-alarmpolicy-form)',function () {
|
897
|
form.on('submit(add-alarmpolicy-form)',function () {
|
191
|
admin.req({
|
898
|
admin.req({
|
192
|
url : domainName + '/api-web/alarmPolicy/save?access_token='+accessToken
|
899
|
url : domainName + '/api-web/alarmPolicy/save?access_token='+accessToken
|
193
|
- ,data:JSON.stringify(data)
|
900
|
+ ,data:JSON.stringify(params)
|
194
|
,type:'post'
|
901
|
,type:'post'
|
195
|
,contentType: "application/json; charset=utf-8"
|
902
|
,contentType: "application/json; charset=utf-8"
|
196
|
,done:function (res){
|
903
|
,done:function (res){
|
|
@@ -198,9 +905,9 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
|
@@ -198,9 +905,9 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
198
|
localStorage.setItem("detailPageOfcustomPolicyId",res.str)
|
905
|
localStorage.setItem("detailPageOfcustomPolicyId",res.str)
|
199
|
layer.msg(res.msg, { offset: '15px' , icon: 1 , time: 1000 },function (){
|
906
|
layer.msg(res.msg, { offset: '15px' , icon: 1 , time: 1000 },function (){
|
200
|
localStorage.removeItem("currentResType");
|
907
|
localStorage.removeItem("currentResType");
|
201
|
- if(layui.alarmpolicyIndex && layui.alarmpolicyIndex()){
|
|
|
202
|
- layui.alarmpolicyIndex().reloadAlarmPolicy()
|
|
|
203
|
- }
|
908
|
+ // if(layui.alarmpolicyIndex && layui.alarmpolicyIndex()){
|
|
|
909
|
+ // layui.alarmpolicyIndex().reloadAlarmPolicy()
|
|
|
910
|
+ // }
|
204
|
});
|
911
|
});
|
205
|
}else{
|
912
|
}else{
|
206
|
layer.msg(res.msg, { offset: '15px' , icon: 7 , time: 1000 });
|
913
|
layer.msg(res.msg, { offset: '15px' , icon: 7 , time: 1000 });
|
|
@@ -221,9 +928,13 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
|
@@ -221,9 +928,13 @@ layui.define(['form', 'admin', 'laydate', 'common','sessions','reskpilist'], fun |
221
|
var clone = $(`#${id}`).clone();
|
928
|
var clone = $(`#${id}`).clone();
|
222
|
clone.attr("id",id+"-"+times).find("i.policy-input-add").addClass("hide")
|
929
|
clone.attr("id",id+"-"+times).find("i.policy-input-add").addClass("hide")
|
223
|
.parent().parent().find("i.policy-input-del").attr("data-id",id + "-"+times).removeClass("hide")
|
930
|
.parent().parent().find("i.policy-input-del").attr("data-id",id + "-"+times).removeClass("hide")
|
|
|
931
|
+ .parent().parent().find("div.paramval").addClass("hide")
|
224
|
.parent().parent().find("input.layui-input").val("");
|
932
|
.parent().parent().find("input.layui-input").val("");
|
|
|
933
|
+ //console.log(clone.find("select.policyparam").html(options))
|
|
|
934
|
+ clone.find("select.policyparam").html(options);
|
|
|
935
|
+ clone.find("select.condition").html(conditionoptions);
|
|
|
936
|
+ clone.find("input[type=tel]").val('');
|
225
|
$(`#${id}`).after(clone).after(cond);
|
937
|
$(`#${id}`).after(clone).after(cond);
|
226
|
-
|
|
|
227
|
form.render();
|
938
|
form.render();
|
228
|
//渲染新增事件
|
939
|
//渲染新增事件
|
229
|
$("i.policy-input-add").off("click").on("click",function (){
|
940
|
$("i.policy-input-add").off("click").on("click",function (){
|