Authored by 王涛

删除浙江工程依赖,将文件拷贝过来

Too many changes to show.

To preserve performance only 8 of 8+ files are displayed.

@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 <dependencies> 18 <dependencies>
19 <dependency> 19 <dependency>
20 <groupId>com.honggroup</groupId> 20 <groupId>com.honggroup</groupId>
21 - <artifactId>hg-monitor-web-zj</artifactId> 21 + <artifactId>hg-monitor-web-base</artifactId>
22 <version>0.0.1-SNAPSHOT</version> 22 <version>0.0.1-SNAPSHOT</version>
23 </dependency> 23 </dependency>
24 </dependencies> 24 </dependencies>
  1 +//活动告警
  2 +layui.define(['table', 'form', 'laydate', 'admin', 'layer', 'laytpl', 'common', 'sessions','commonDetail','soulTable', 'treeTable'], function (exports) {
  3 + var $ = layui.$;
  4 + var form = layui.form;
  5 + var layer = layui.layer;
  6 + var admin = layui.admin;
  7 + var table = layui.table;
  8 + var laydate = layui.laydate;
  9 + var laytpl = layui.laytpl;
  10 + var treeTable = layui.treeTable;
  11 + var common = layui.common;
  12 + var commonDetail=layui.commonDetail;
  13 + var domainName = common.domainName;
  14 + var todayStr = '';
  15 + //对外暴露的接口
  16 + exports('activewarning', function () {
  17 + var sessions = layui.sessions;
  18 + var accessToken = sessions.getToken()['access_token'];
  19 + var router = layui.router();
  20 + var alarmLevel = router.search.level; //告警级别
  21 + var checkList = common.checkPermission(accessToken);
  22 + var resId = router.search.resId;//资源Id
  23 + var kpiId = router.search.kpiId;//指标Id
  24 + var bizId = router.search.bizId;//业务Id
  25 + var alarmNo = router.search.alarmNo;//告警编号
  26 + var busIdSelect;
  27 + var busTypeList = [];
  28 + if(!bizId){
  29 + bizId='';
  30 + }
  31 + if (resId) {
  32 + resId = decodeURIComponent(resId);
  33 + }
  34 + if (alarmNo) {
  35 + $("#activewarningkw").val(alarmNo);
  36 + }
  37 + var netFlag = router.search.netFlag;//网络标识
  38 + var resType = router.search.restype ? router.search.restype : '';//资源类型
  39 + var soulTable = layui.soulTable;
  40 +
  41 + var sortKey = '';
  42 +
  43 + if ($("#alarmLevelSearchBox").val()) {
  44 + alarmLevel = $("#alarmLevelSearchBox").val()
  45 + }
  46 + //回显告警级别
  47 + $("#alarmLevelSearchBox").val(alarmLevel);
  48 + form.render("select");
  49 +
  50 + function initDate() {
  51 + let startMin = {};
  52 + let endMax = {};
  53 + //开始时间
  54 + var start = laydate.render({
  55 + elem: '#activewarningStartdate'
  56 + , trigger: 'click'
  57 + ,ready: function(date){
  58 + startMin=start.config.min;
  59 + }
  60 + , done: function (value, date) {
  61 + date.month--;
  62 + end.config.min = date;
  63 + if(value === ''){//点击清空
  64 + end.config.min = startMin;
  65 + }
  66 + form.render();
  67 + reloadTable()
  68 + }
  69 + });
  70 + //结束时间
  71 + var end = laydate.render({
  72 + elem: '#activewarningEnddate'
  73 + , trigger: 'click'
  74 + ,ready: function(date){
  75 + endMax=end.config.max;
  76 + }
  77 + , done: function (value, date) {
  78 + date.month--;
  79 + start.config.max = date;
  80 + if(value === ''){//点击清空
  81 + start.config.max = endMax;
  82 + }
  83 + form.render();
  84 + reloadTable();
  85 + }
  86 + });
  87 + //绑定业务下拉选择数据
  88 + admin.req({
  89 + url: domainName + '/api-web/home/business/findUserBusTypeAll?table=',
  90 + success: function (response) {
  91 + if (response && response.success) {
  92 + busTypeList = response.data;
  93 + var bizList = response.data.map(item => {
  94 + return {
  95 + name: item.busTypeName,
  96 + value: item.busId,
  97 + parentId: item.parentId
  98 + }
  99 + });
  100 + var bizTree=common.pidToChildren(bizList, 'value', 'parentId');
  101 +
  102 + // 影响业务下拉框
  103 + busIdSelect = xmSelect.render({
  104 + el: '#bisTypeSearchBox',
  105 + name: 'bizId',
  106 + tips: '=所属业务=',
  107 + //开启搜索
  108 + filterable: true,
  109 + clickClose: true,
  110 + initValue: [bizId.split(',')[0]],
  111 + toolbar: {
  112 + show: true,
  113 + list: ['ALL', 'REVERSE', 'CLEAR']
  114 + },
  115 + height: '170px',
  116 + tree: {
  117 + show: true,
  118 + showFolderIcon: true,
  119 + showLine: true,
  120 + strict: true,
  121 + //间距
  122 + indent: 20,
  123 + },
  124 + model: {
  125 + label: {
  126 + type: 'text'
  127 + }
  128 + },
  129 + data: bizTree,
  130 + on: function (data) {
  131 + if (data.arr.length != 0) {
  132 + var str='';
  133 + $.each(data.arr,function (i,v) {
  134 + str+=v.value+',';
  135 + })
  136 + bizId = str.substring(0,str.length-1);
  137 + } else {
  138 + bizId = '';
  139 + }
  140 + form.render();
  141 + reloadTable();
  142 + }
  143 + });
  144 + if(busIdSelect){
  145 + //追加样式
  146 + $('#bisTypeSearchBox').find('.xm-body').eq(0).css("width","230px");
  147 + }
  148 + } else {
  149 + layer.msg('获取业务失败', {icon: 2});
  150 + }
  151 + },
  152 + error: function () {
  153 + layer.msg('获取业务失败', {icon: 2});
  154 + }
  155 + });
  156 +
  157 + $.ajax({
  158 + url: common.domainName + '/api-web/manage/kpi/findKpiInAlarm?access_token='+accessToken+'&tableName=b_alarm',
  159 + type: "get",
  160 + success:function (res) {
  161 + var kpis = res.data;
  162 + var html = '<option value="">=指标名称=</option>'
  163 + $.each(kpis,function (i,e) {
  164 + html+='<option value="'+e.kpiId+'">'+e.kpiName+'</option>'
  165 + })
  166 + $("#alarmKpiSearchBox").html('');
  167 + $("#alarmKpiSearchBox").append(html);
  168 + form.render();
  169 + }
  170 + })
  171 + $.ajax({
  172 + url: `${common.domainName}/api-web/manage/restype/list?access_token=${accessToken}`,
  173 + method: 'GET',
  174 + success: function (res) {
  175 + // 资源类型下拉框
  176 + var resTypeList = res.data.map(item => {
  177 + return {
  178 + name: item.resTypeName,
  179 + value: item.resTypeCode,
  180 + parentId: item.parentId
  181 + }
  182 + });
  183 + var resTypeTree = treeTable.pidToChildren(resTypeList, "value", "parentId");
  184 + xmSelect.render({
  185 + el: '#resTypeSearchBox',
  186 + name: "resType",
  187 + tips: '=资源类型=',
  188 + filterable: true,
  189 + radio: true,
  190 + clickClose: true,
  191 + initValue: [resType],
  192 + toolbar: {
  193 + show: true,
  194 + list: ['CLEAR']
  195 + },
  196 + tree: {
  197 + show: true,
  198 + showFolderIcon: true,
  199 + showLine: true,
  200 + strict: false,
  201 + indent: 20
  202 + },
  203 + model: {
  204 + label: {
  205 + type: 'text'
  206 + }
  207 + },
  208 + height: '200px',
  209 + data: resTypeTree,
  210 + on: function (data) {
  211 + if(data.isAdd){
  212 + if (data.arr.length != 0) {
  213 + resType = data.arr[0].value;
  214 + } else {
  215 + resType = '';
  216 + }
  217 + reloadTable();
  218 + }
  219 + }
  220 + });
  221 + }
  222 + });
  223 + }
  224 +
  225 + //回车搜索
  226 + $('#activewarningkw, input[name="durationVal"]').keydown(function (e) {
  227 + if (e.keyCode === 13) {
  228 + reloadTable();
  229 + }
  230 + });
  231 + //选择框搜索事件
  232 + bindSelectEvent();
  233 + initDate();
  234 +
  235 + function initToolBarClickEvent() {
  236 + //告警消除
  237 + $("#clearBtn").unbind('click').on('click', function () {
  238 + if ($.inArray('app:alarm:clear', checkList) == -1) {
  239 + layer.msg('暂无权限!', {icon: 7, time: 3000});
  240 + return;
  241 + }
  242 + var ids = [];
  243 + var data = table.checkStatus('activewarningTable').data;
  244 + if (data.length == 0) {
  245 + layer.msg('请最少选择一项数据', {icon: 7, time: 2000});
  246 + return;
  247 + }
  248 + //选中的告警ID放到集合中
  249 + $.each(data, function (i, obj) {
  250 + ids.push(obj.id)
  251 + });
  252 + //获取以往告警消除意见
  253 + admin.req({
  254 + url: common.domainName + '/api-web/home/alarm/clear/reason',
  255 + type: "get",
  256 + data:{
  257 + alarmId: ids.toString()
  258 + },
  259 + done:function (data) {
  260 + var clearReson = "暂无参考处理方案,请输入处理方案";
  261 + var hisReason = "";
  262 + var reasonlist = data.reason;
  263 + if(reasonlist && reasonlist.length > 0){
  264 + hisReason = "参考方案:\n";
  265 + $.each(reasonlist,function (i,v) {
  266 + var idx = i + 1;
  267 + hisReason += idx +":"+v +"\n";
  268 + });
  269 + }
  270 +
  271 + layer.prompt({id: "alarms_clear_id", title: '告警消除', area: ['400px'], formType: 2,value: hisReason}, function (text, index) {
  272 + admin.req({
  273 + url: common.domainName + '/api-web/home/alarm/clear'
  274 + , type: "post"
  275 + , data: {
  276 + ids: ids.toString(),
  277 + reason: text,
  278 + access_token: accessToken,
  279 + noticeFlag: $('input[name="noticeFlag"]:checked').val()
  280 + }
  281 + , done: function (res) {
  282 + //如果消除成功,关闭弹出框然后重新加载页面
  283 + if (res.success) {
  284 + layer.close(index);
  285 + layer.msg('告警已消除!', {icon: 1, time: 2000});
  286 + reloadTable();
  287 + } else {
  288 + layer.msg('告警消除失败,请与管理员联系!', {icon: 7, time: 3000});
  289 + }
  290 + }
  291 + });
  292 + });
  293 +
  294 + $("#alarms_clear_id").find('textarea.layui-layer-input').attr("placeholder", clearReson);
  295 + $("#alarms_clear_id").append('<div style="padding-top: 15px;"><span>是否通知:</span> ' +
  296 + '<input type="radio" name="noticeFlag" value="true" title="是" >&nbsp;是' +
  297 + '<input type="radio" name="noticeFlag" value="false" title="否" checked="" style="margin-left: 20px;">&nbsp;否</div> ');
  298 + }
  299 + });
  300 + });
  301 + //告警关闭
  302 + $("#closeBtn").unbind('click').on("click", function () {
  303 + if ($.inArray('app:alarm:close', checkList) == -1) {
  304 + layer.msg('暂无权限!', {icon: 7, time: 3000});
  305 + return;
  306 + }
  307 + var ids = [];
  308 + var data = table.checkStatus('activewarningTable').data;
  309 + var alarmStatus = true;
  310 + if (data.length == 0) {
  311 + layer.msg('请最少选择一项数据', {icon: 7, time: 2000});
  312 + return;
  313 + }
  314 + //选中的告警ID放到集合中
  315 + $.each(data, function (i, obj) {
  316 + var status = JSON.stringify(obj.alarmStatus);
  317 + if (status && status == '1') {
  318 + alarmStatus = false;
  319 + }
  320 + ids.push(obj.id)
  321 + });
  322 + if (!alarmStatus) {
  323 + layer.msg('已关闭的告警不可重复关闭!', {icon: 7, time: 3000});
  324 + return;
  325 + }
  326 + layer.prompt({
  327 + id: "alarms_cloes_id",
  328 + formType: 2,
  329 + title: '告警关闭',
  330 + area: ['400px']
  331 + },
  332 + function (value, index) {
  333 + if (value === "") {
  334 + layer.msg('请填写关闭意见', {icon: 7, time: 3000});
  335 + }
  336 + if ($('#closeDuration').val() === "") {
  337 + layer.msg('请填写关闭时长', {icon: 7, time: 3000});
  338 + return;
  339 + }
  340 + admin.req({
  341 + url: common.domainName + '/api-web/home/alarm/close'
  342 + , type: "post"
  343 + , data: {
  344 + ids: ids.toString(),
  345 + reason: value,
  346 + duration: $('#closeDuration').val() * 60,
  347 + closeType: $('input[name="closeType"]:checked').val(),
  348 + noticeFlag: $('input[name="noticeFlag"]:checked').val(),
  349 + kpiAllFlag: $('input[name="kpiAllFlag"]:checked').val(),
  350 + access_token: accessToken
  351 + }
  352 + , done: function (res) {
  353 + if (res.success) {
  354 + layer.close(index);
  355 + layer.msg('关闭成功', {icon: 1, time: 2000}, function () {
  356 + reloadTable();
  357 + });
  358 + } else {
  359 + layer.msg('告警关闭失败,请与管理员联系!', {icon: 7, time: 3000});
  360 + }
  361 + }
  362 + });
  363 + });
  364 + $("#alarms_cloes_id").find('textarea.layui-layer-input').attr("placeholder", "请输入关闭意见(必填)");// /[^(\d||/.)]/g,''
  365 + $("#alarms_cloes_id").append('<br/>' +
  366 + '<input type="number" id="closeDuration" class="layui-input" min="0" oninput="if(value.length>5)value=value.slice(0,5)" onkeyup="value=value.replace(/(\\d*\\.\\d).*/,\'$1\')" placeholder="输入关闭时长,单位小时(必填)"/>');
  367 +
  368 + $("#alarms_cloes_id").append('<br/><div style="line-height: 38px;"><span>关闭类型:</span> ' +
  369 + '<input type="radio" name="closeType" value="0" title="关闭告警" checked="">&nbsp;关闭告警' +
  370 + '<input type="radio" name="closeType" value="1" title="关闭通知" style="margin-left: 20px;">&nbsp;关闭通知</div> ');
  371 +
  372 + $("#alarms_cloes_id").append('<div style="line-height: 38px;"><span>是否关闭该指标所有告警/通知:</span> ' +
  373 + '<input type="radio" name="kpiAllFlag" value="true" title="是">&nbsp;是' +
  374 + '<input type="radio" name="kpiAllFlag" value="false" title="否" checked="" style="margin-left: 20px;">&nbsp;否</div> ');
  375 +
  376 + $("#alarms_cloes_id").append('<div style="line-height: 38px;"><span>是否通知:</span> ' +
  377 + '<input type="radio" name="noticeFlag" value="true" title="是">&nbsp;是' +
  378 + '<input type="radio" name="noticeFlag" value="false" title="否" checked="" style="margin-left: 20px;">&nbsp;否</div> ');
  379 + });
  380 + //告警确认
  381 + $("#confirmBtn").unbind('click').on("click", function () {
  382 + if ($.inArray('app:alarm:confirm', checkList) == -1) {
  383 + layer.msg('暂无权限!', {icon: 7, time: 3000});
  384 + return;
  385 + }
  386 + var ids = [];
  387 + var data = table.checkStatus('activewarningTable').data;
  388 + if (data.length == 0) {
  389 + layer.msg('请最少选择一项数据', {icon: 7, time: 2000});
  390 + return;
  391 + }
  392 + $.each(data, function (i, obj) {
  393 + ids.push(obj.id)
  394 + });
  395 + layer.prompt({
  396 + id: "alarms_confirm_id",
  397 + formType: 2,
  398 + title: '告警确认',
  399 + area: ['400px']
  400 + },
  401 + function (value, index) {
  402 + if (value === "") {
  403 + layer.msg('请填确认意见', {icon: 7, time: 3000});
  404 + }
  405 + admin.req({
  406 + url: common.domainName + '/api-web/home/alarm/confirm'
  407 + , type: "post"
  408 + , data: {
  409 + ids: ids.toString(),
  410 + reason: value,
  411 + level: $('input[name="confrimlevel"]:checked').val(),
  412 + access_token: accessToken
  413 + }
  414 + , done: function (res) {
  415 + if (res.success) {
  416 + layer.close(index);
  417 + layer.msg('告警确认成功', {icon: 1, time: 2000}, function () {
  418 + reloadTable();
  419 + });
  420 + } else {
  421 + layer.msg('告警确认失败,请与管理员联系!', {icon: 7, time: 3000});
  422 + }
  423 + }
  424 + });
  425 + });
  426 + $("#alarms_confirm_id").find('textarea.layui-layer-input').attr("placeholder", "请输入意见(必填)");
  427 + $("#alarms_confirm_id").append('<br/> ' +
  428 + '<input type="radio" name="confrimlevel" value="0" title="紧急" checked="">&nbsp;紧急' +
  429 + '<input type="radio" name="confrimlevel" value="1" title="非常紧急" style="margin-left: 20px;">&nbsp;非常紧急' +
  430 + '<input type="radio" name="confrimlevel" value="2" title="不紧急" style="margin-left: 20px;">&nbsp;不紧急');
  431 + });
  432 + //告警恢复
  433 + $("#resumeBtn").unbind('click').on("click", function () {
  434 + if ($.inArray('app:alarm:resume', checkList) == -1) {
  435 + layer.msg('暂无权限!', {icon: 7, time: 3000});
  436 + return;
  437 + }
  438 + var ids = [];
  439 + var closeIds = [];
  440 + var data = table.checkStatus('activewarningTable').data;
  441 + var resumeStatus = true;
  442 + if (data.length == 0) {
  443 + layer.msg('请最少选择一项数据', {icon: 7, time: 2000});
  444 + return;
  445 + }
  446 + var msg = "";
  447 + //选中的告警ID放到集合中
  448 + $.each(data, function (i, obj) {
  449 + var alarmStatus = JSON.stringify(obj.alarmStatus);
  450 + //已关闭的告警才可以恢复,告警状态,0告警,1关闭
  451 + if (alarmStatus && alarmStatus == '0') {
  452 + resumeStatus = false;
  453 + msg = '只能恢复已关闭状态的告警,请重新选择!';
  454 + }
  455 + ids.push(obj.id);
  456 + closeIds.push(obj.closeId);
  457 + });
  458 + if (!resumeStatus) {
  459 + layer.msg(msg, {icon: 7, time: 3000});
  460 + return;
  461 + }
  462 + layer.prompt({title: '恢复说明(必填)', formType: 2}, function (text, index) {
  463 + admin.req({
  464 + url: common.domainName + '/api-web/home/alarm/resume'
  465 + , type: "post"
  466 + , data: {
  467 + ids: ids.toString(),
  468 + reason: text,
  469 + closeId: closeIds.toString(),
  470 + resumeType: '0',//0告警关闭,1历史告警
  471 + access_token: accessToken
  472 + }
  473 + , done: function (res) {
  474 + //如果消除成功,关闭弹出框然后重新加载页面
  475 + if (res.success) {
  476 + layer.close(index);
  477 + layer.msg('告警已恢复!', {icon: 1, time: 3000}, function () {
  478 + reloadTable();
  479 + });
  480 + } else {
  481 + layer.msg('告警恢复失败,请与管理员联系!', {icon: 7, time: 3000});
  482 + }
  483 + }
  484 + });
  485 + })
  486 + });
  487 + //导出
  488 + $("#exportAarmBtn").unbind('click').on("click", function () {
  489 + if ($.inArray('app:alarm:export', checkList) == -1) {
  490 + layer.msg('暂无权限!', {icon: 7, time: 3000});
  491 + return;
  492 + }
  493 + var data = table.checkStatus('activewarningTable').data;
  494 + if (data.length == 0) {
  495 + //确认提示框
  496 + layer.confirm('当前没选择告警,将全量导出数据,请确认', {
  497 + btn: ['确定', '取消'] //按钮
  498 + }, function () {
  499 + var url = common.domainName + '/api-web/home/alarm/exportExcel/condition?access_token=' + accessToken;
  500 + url += '&kpiName=' + $("#activewarningkw").val();
  501 + url += '&busId=' + (bizId && bizId!='undefined' ? bizId : '');
  502 + url += '&resId=' + (resId && resId!='undefined' ? bizId : '');
  503 + url += '&kpiId=' + (kpiId && kpiId!='undefined' ? bizId : '');
  504 + url += '&alarmStatus=' + $("#alarmStatusSearchBox").val();
  505 + url += '&alarmLevel=' + $("#alarmLevelSearchBox").val();
  506 + url += '&confirmStatus=' + $("#alarmConfirmSearchBox").val();
  507 + url += '&beginTime=' + $("#activewarningStartdate").val();
  508 + url += '&endTime=' + $("#activewarningEnddate").val();
  509 + url += '&sortKey=' + sortKey;
  510 + url += '&alarmKpi=' + ($("#alarmKpiSearchBox").val() != 'KPI97B835A4' ? $("#alarmKpiSearchBox").val() : '');
  511 + url += '&isBus=' + ($("#alarmKpiSearchBox").val() == 'KPI97B835A4' ? 'Y' : '');
  512 + url += '&durationVal=' + ($('#inline-condition-duration input[name="durationVal"]').val());
  513 + url += '&durationUnit=' + ($('#inline-condition-duration select[name="durationUnit"]').val());
  514 + url += '&alarmTimeDay=' + todayStr;
  515 + url += '&resType=' + resType;
  516 + url += '&page=1&limit=999999';
  517 + window.open(url);
  518 + layer.closeAll();
  519 + });
  520 + } else {
  521 + var ids = [];
  522 + //讲选中的告警ID放到集合中
  523 + $.each(data, function (i, obj) {
  524 + ids.push(obj.id);
  525 + });
  526 + ids = ids.toString();
  527 + var url = common.domainName + '/api-web/home/alarm/exportExcel?alarmIds=' + ids + "&access_token=" + accessToken;
  528 + window.open(url)
  529 + }
  530 + });
  531 + //发送通知
  532 + $("#sendNoticeBtn").unbind('click').on("click", function () {
  533 + if ($.inArray('app:alarm:sendnotice', checkList) == -1) {
  534 + layer.msg('暂无权限!', {icon: 7, time: 3000});
  535 + return;
  536 + }
  537 + var ids = [];
  538 + var resIds = [];
  539 + var data = table.checkStatus('activewarningTable').data;
  540 + if (data.length == 0) {
  541 + layer.msg('请最少选择一项数据', {icon: 7, time: 2000});
  542 + return;
  543 + }
  544 + if (data.length > 1) {
  545 + layer.msg('请最多选择一项数据', {icon: 7, time: 2000});
  546 + return;
  547 + }
  548 + //将选中的告警ID放到集合中
  549 + $.each(data, function (i, obj) {
  550 + ids.push(obj.id);
  551 + resIds.push(obj.resId);
  552 + });
  553 + admin.req({
  554 + url: common.domainName + '/api-web/home/alarm/subscribe/user/' + resIds.toString()
  555 + , done: function (res) {
  556 + if (res.data && res.data.length > 0) {
  557 + var username = '';
  558 + var begin = '<div style="padding: 0 5px 0 5px;"><table class="layui-table"><thead>' +
  559 + '<tr><th></th><th>名称</th><th>电话</th><th>邮箱</th></tr></thead><tbody>';
  560 + var end = '</tbody></table></div>';
  561 + $.each(res.data, function (i, v) {
  562 + username += '<tr><td><input class="userName" type="checkbox" data-name="' + v.username + '" checked></td><td>' + v.nickname + '</td><td>' + v.phone + '</td><td>' + v.email + '</td></tr>';
  563 + });
  564 + //获取告警通知接收人
  565 + var reciveUsers = begin + username + end;
  566 + layer.open({
  567 + type: 1
  568 + , title: "通知接收人"
  569 + , shade: 0.8
  570 + , area: ['600px', '390px']
  571 + , id: 'lay_users' //设定一个id,防止重复弹出
  572 + , content: reciveUsers
  573 + , btn: ['发送', '关闭']
  574 + , yes: function () {
  575 + var names = [];
  576 + $("input[class='userName']:checked").each(function(i){
  577 + names.push($(this).attr("data-name"));
  578 + });
  579 + if(names.length<1){
  580 + layer.msg('请最少选择一个用户', {icon: 7, time: 2000});
  581 + return;
  582 + }
  583 + admin.req({
  584 + url: common.domainName + '/api-web/home/alarm/sendnotice'
  585 + , type: "post"
  586 + , data: {
  587 + ids: ids.toString(),
  588 + names:names.toString(),
  589 + access_token: accessToken
  590 + }
  591 + , done: function (res) {
  592 + layer.closeAll();
  593 + if (res.success) {
  594 + layer.msg('发送成功', {icon: 1, time: 2000});
  595 + } else {
  596 + layer.msg('发送失败,稍后再试', {icon: 7, time: 2000});
  597 + }
  598 + }
  599 + });
  600 + }
  601 + });
  602 + } else {
  603 + layer.msg('未获取到接收所选通知的用户!', {icon: 7, time: 2000});
  604 + }
  605 + }
  606 + });
  607 + });
  608 + }
  609 +
  610 + //告警处理及时率
  611 + getAlarmCount();
  612 +
  613 + var activeAlarmTable;
  614 + //获取配置的列
  615 + common.getTableCols({
  616 + domId: 'activewarningTable',
  617 + moduleId: 'activewarning',
  618 + resType: ''
  619 + },function (retCols) {
  620 + var cols = [
  621 + {type: 'checkbox', fixed: 'left'}
  622 + , {
  623 + field: 'alarmLevel', title: '级别', align: 'center', width: 120, sort: true,
  624 + templet: `
  625 + <div>
  626 + {{# if (d.alarmLevel == 3) {
  627 + }} <span class="layui-table-warn" style="width: 100%;">严重</span> {{#
  628 + } else if (d.alarmLevel == 2) {
  629 + }} <span class="layui-table-close" style="width: 100%;">重要</span> {{#
  630 + } else if (d.alarmLevel == 1) {
  631 + }} <span class="layui-table-normal" style="width: 100%;">一般</span> {{#
  632 + } }}
  633 + </div>
  634 + `
  635 + }
  636 + , {
  637 + field: 'alarmNo', title: '告警编号', align: 'center', width: 140, sort: true,
  638 + }
  639 + , {
  640 + field: 'resName', title: '资源名称', width: 230, sort: true,
  641 + templet:`
  642 + <div>
  643 + <div style="display: flex;align-items: center;">
  644 + {{# if (d.confirmStatus == 0 || d.confirmStatus == null) { }}
  645 + <i lay-tips="新的告警未确认,告警确认后消失!" class="shake iconfont" style="color: red;font-size: 28px;">&#xe68b;</i>
  646 + {{# } }}
  647 + {{# if(d.isBus == 'N'){ }}
  648 + <span lay-tips="{{ d.resName }}" style="margin:0 5px;max-width: 160px;overflow: hidden; text-overflow: ellipsis; white-space: nowrap;display: inline-block;" data-isBus="{{d.isBus}}" data-resid="{{d.resId}}" data-restype="{{d.resType}}" data-warn-zymc="{{d.id}}" data-ip="{{d.ip}}"
  649 + data-resname="{{d.resName}}" data-pingenable="{{d.pingEnable}}" class="layui-table-link">{{d.resName}}</span>
  650 + {{# }else{ }}
  651 + <span lay-tips="{{ d.resName }}" style="margin:0 5px;max-width: 160px;overflow: hidden; text-overflow: ellipsis; white-space: nowrap;display: inline-block;" data-isBus="{{d.isBus}}" data-resid="{{d.resId}}" data-restype="{{d.resType}}" data-warn-zymc="{{d.id}}" data-ip="{{d.ip}}"
  652 + data-resname="{{d.resName}}" data-pingenable="{{d.pingEnable}}" >{{d.resName}}</span>
  653 + {{# } }}
  654 + <a class="layui-icon reslist-view-topo hide" data-resid="{{d.resId}}" lay-tips="查看资源拓扑"><i class="iconfont" style="font-size: 20px;
  655 + color: #FEB61E;"></i></a>
  656 + </div>
  657 + </div>
  658 + `
  659 + }
  660 + , {
  661 + field: 'kpiName', title: '指标名称', align: 'center', width: 120, sort: true,
  662 + templet: `
  663 + <div>
  664 + {{#
  665 + var kpiName = d.kpiName == 'TYPE'?'ERRPT':d.kpiName;
  666 + if (d.kpiIdent != 1) {
  667 + if(d.isWarning != 1) {
  668 + }} <div>{{kpiName}}</div> {{#
  669 + } else { }}
  670 + <div><span data-ident="{{d.kpiIdent}}" data-trend="{{d.isTrend}}" data-warning="{{d.isWarning}}" data-resid="{{d.resId}}" data-flag="{{d.flag}}" data-kpi="{{d.kpiId}}" data-warn-zbmc="{{d.id}}" data-name="{{kpiName}}" class="layui-table-link">{{kpiName}}</span></div>
  671 + {{# }
  672 + } else { }}
  673 + <div><span data-ident="{{d.kpiIdent}}" data-trend="{{d.isTrend}}" data-warning="{{d.isWarning}}" data-resid="{{d.resId}}" data-flag="{{d.flag}}" data-kpi="{{d.kpiId}}" data-warn-zbmc="{{d.id}}" data-name="{{kpiName}}" class="layui-table-link">{{kpiName}}</span></div>
  674 + {{# }
  675 + }}
  676 + </div>`
  677 + }
  678 + , {field: 'alarmContent', title: '告警内容', align: 'center', width: 500}
  679 + , {
  680 + field: 'alarmResource', title: '告警来源', align: 'center', minWidth: 120, templet: `<div>
  681 + {{# if (d.alarmResource == 1) { }}
  682 + <div>华为告警</div>
  683 + {{# } else { }}
  684 + <div>监控系统</div>
  685 + {{# } }}
  686 + </div>`
  687 + }
  688 + , {field: 'updateTime', title: '告警时间', align: 'center', minWidth: 180, sort: true}
  689 + , {field: 'alarmTime', title: '首次告警时间', align: 'center', minWidth: 180, sort: true}
  690 + , {field: 'durationStr', title: '持续时间', align: 'center', width: 190}
  691 + , {field: 'alarmRepeatCnt', title: '告警次数', align: 'center', width: 180}
  692 + , {field: 'nickName', title: '通知人', align: 'center', width: 180}
  693 + , {field: 'adminName', title: '负责人', align: 'center', width: 180}
  694 + , {field: 'noticeTime', title: '通知时间', align: 'center', width: 180, hide: true}
  695 + , {
  696 + title: '操作', align: 'center', minWidth: 100,
  697 + templet: '<div><span data-warn-view="{{d.id}}" class="layui-table-link">查看</span> <span data-warn-path="{{d.id}}" class="layui-table-link">轨迹</span></div>'
  698 + }
  699 + ];
  700 +
  701 + if (retCols) {
  702 + cols = retCols;
  703 + }
  704 +
  705 + //渲染表格
  706 + activeAlarmTable = table.render({
  707 + elem: '#activewarningTable'
  708 + , url: domainName + '/api-web/home/alarm/alarmListPage'
  709 + , id: 'activewarningTable'
  710 + , toolbar: '#activeAlarmtoolbar' //开启头部工具栏,并为其绑定左侧模板
  711 + , defaultToolbar: ['filter']
  712 + , where: {
  713 + access_token: accessToken,
  714 + kpiName: $("#activewarningkw").val(),
  715 + busId: bizId,
  716 + resId: resId,
  717 + kpiId: kpiId,
  718 + alarmStatus: $("#alarmStatusSearchBox").val(),
  719 + alarmLevel: alarmLevel,
  720 + confirmStatus: $("#alarmConfirmSearchBox").val(),
  721 + beginTime: $("#activewarningStartdate").val(),
  722 + endTime: $("#activewarningEnddate").val(),
  723 + sortKey: sortKey,
  724 + alarmKpi: $("#alarmKpiSearchBox").val()!='KPI97B835A4'?$("#alarmKpiSearchBox").val():'',
  725 + isBus:$("#alarmKpiSearchBox").val()=='KPI97B835A4'?'Y':'',
  726 + durationVal: $('#inline-condition-duration input[name="durationVal"]').val(),
  727 + durationUnit: $('#inline-condition-duration select[name="durationUnit"]').val(),
  728 + netFlag: netFlag,
  729 + resType:resType
  730 + }
  731 + , height: 'full-245'
  732 + , cellMinWidth: 80
  733 + , page: {
  734 + layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
  735 + , theme: '#1E9FFF'
  736 + }
  737 + , even: true
  738 + , drag: {toolbar: false}
  739 + , cols: [cols],
  740 + done: function (res, curr, count) {
  741 + soulTable.render(this)
  742 + var groupurl = domainName + '/api-web/home/alarm/countAlarmNumByAlarmLevel?alarmTimeDay=' + todayStr + '&access_token=' + accessToken;
  743 + $.ajax({
  744 + url: groupurl,
  745 + type: 'get',
  746 + data: {
  747 + access_token: accessToken,
  748 + kpiName: $("#activewarningkw").val(),
  749 + busId: bizId,
  750 + resId: resId,
  751 + kpiId: kpiId,
  752 + alarmStatus: $("#alarmStatusSearchBox").val(),
  753 + alarmLevel: alarmLevel,
  754 + confirmStatus: $("#alarmConfirmSearchBox").val(),
  755 + beginTime: $("#activewarningStartdate").val(),
  756 + endTime: $("#activewarningEnddate").val(),
  757 + sortKey: sortKey,
  758 + //alarmKpi: $("#alarmKpiSearchBox").val(),
  759 + alarmKpi: $("#alarmKpiSearchBox").val()!='KPI97B835A4'?$("#alarmKpiSearchBox").val():'',
  760 + isBus:$("#alarmKpiSearchBox").val()=='KPI97B835A4'?'Y':'',
  761 + durationVal: $('#inline-condition-duration input[name="durationVal"]').val(),
  762 + durationUnit: $('#inline-condition-duration select[name="durationUnit"]').val(),
  763 + netFlag: netFlag,
  764 + resType:resType
  765 + },
  766 + success: function (res) {
  767 + var map = res.map;
  768 + if (map) {
  769 + layui.use('laytpl', function () {
  770 + var laytpl = layui.laytpl;
  771 + var getTpl = document.getElementById("alarm-count-id-tpl").innerHTML;
  772 + laytpl(getTpl).render(map, function (html) {
  773 + $('#alarm-count-id').html(html);
  774 + });
  775 + //告警升级量 悬浮提示
  776 + var alarmUpRate, alarmDealRate;
  777 + $("#alarm_level_up_area_id").hover(function () {
  778 + alarmUpRate = layer.tips("活动告警中升级的告警总量及占比",
  779 + '#alarm_level_up_area_id', {tips: [1]});
  780 + }, function () {
  781 + layer.close(alarmUpRate);
  782 + });
  783 + //告警处理及时率
  784 + $("#alarm_deal_rate_area_id").hover(function () {
  785 + alarmDealRate = layer.tips("活动告警中及时处理的告警量占比",
  786 + '#alarm_deal_rate_area_id', {tips: [1]});
  787 + }, function () {
  788 + layer.close(alarmDealRate);
  789 + });
  790 +
  791 + $('[data-warn-zymc]').unbind('click').on('click', function () {
  792 + //先去查找资源有没有权限
  793 +
  794 + var resId = $(this).data("resid");
  795 + var resType = $(this).data("restype");
  796 + var ip = $(this).data("ip") ? $(this).data("ip") : "";
  797 + var resName = $(this).data("resname");
  798 + var pingEnable = $(this).data("pingenable"); //获取pingEnable的值 joke add 20200619
  799 + var resTypeName = '';
  800 + var adminName = '';
  801 + var manageIp = '';
  802 + var collProtocol = '';
  803 + var sign='false';
  804 + $.ajax({
  805 + url: common.domainName + "/api-web/home/resource/findById?resId="+resId + '&access_token='+ accessToken,
  806 + async: false,
  807 + type:'get',
  808 + success: function (res) {
  809 + sign=res.str;
  810 + var data = res.object;
  811 + resType = data.resType;
  812 + adminName = data.adminName;
  813 + manageIp = data.manageIp;
  814 + collProtocol = data.collProtocol;
  815 + resTypeName = data.resTypeName;
  816 + }
  817 + })
  818 + if(sign=='false'){
  819 + layer.msg('当前用户暂无此资源权限!', {icon: 7, time: 3000});
  820 + return false;
  821 + }
  822 + let title = resName;
  823 + if (title && title !== '') {
  824 + title += '|';
  825 + }
  826 + if (resTypeName && resType !== 'HOST_X86SERVER') {
  827 + title += resTypeName + '|';
  828 + }
  829 + if (ip) {
  830 + if (resType === 'HOST_X86SERVER') {
  831 + if (collProtocol && (collProtocol.split(",").length > 1 || collProtocol === 'SSH')) {
  832 + title += '应用IP-' + ip + '|';
  833 + }
  834 + } else {
  835 + title += ip + '|';
  836 + }
  837 + }
  838 + if (resType === 'HOST_X86SERVER' && collProtocol && collProtocol.indexOf('SNMP') !== -1 ) {
  839 + if (manageIp) {
  840 + title += '管理IP-' + manageIp + '|';
  841 + }
  842 + }
  843 + if (adminName) {
  844 + title += adminName + '|';
  845 + }
  846 + if (title.length > 0) {
  847 + title = title.substr(0, title.length - 1);
  848 + }
  849 + if (pingEnable == '2') { //如果pingEnable为2,则进入ping状态详情页面
  850 + commonDetail.openNewWin('template/detail/pingIndex', title, {'resId': resId}, false);
  851 + } else { //否则进入监控详情页面
  852 + commonDetail.openDetail(resId, resType, title);
  853 + }
  854 + });
  855 +
  856 + //指标名称点击事件
  857 + $('[data-warn-zbmc]').unbind("click").on('click', function () {
  858 + var name = $(this).data("name");
  859 + var params = {
  860 + resId: $(this).data("resid"),
  861 + kpiId: $(this).data("kpi"),
  862 + flag: $(this).data("flag"),
  863 + name: name,
  864 + warning: $(this).data("warning"),
  865 + ident: $(this).data("ident"),
  866 + trend: $(this).data("trend")
  867 + };
  868 + common.openLineChart(name, params);
  869 + });
  870 +
  871 + //告警操作日志
  872 + $('[data-warn-view]').unbind('click').on('click', function () {
  873 + admin.req({
  874 + url: common.domainName + '/api-web/home/alarm/info'
  875 + , data: {
  876 + alarmId: $(this).data('warn-view'),
  877 + access_token: accessToken
  878 + }
  879 + }).done(function (res) {
  880 + laytpl($('#warnViewWinTpl').html()).render(res.obj, function (html) {
  881 + layer.open({
  882 + area: '750px',
  883 + title: ['告警操作信息', 'font-size:18px;'],
  884 + type: 1,
  885 + content: html
  886 + });
  887 + });
  888 + });
  889 + });
  890 +
  891 + //告警轨迹
  892 + $('[data-warn-path]').unbind('click').on('click', function () {
  893 + var id = $(this).attr('data-warn-path');
  894 + var view = layui.view;
  895 + var params = {
  896 + "warnId": id
  897 + };
  898 + view('commonViewModel').render("template/detail/warn_gj").then(function (res) {
  899 + layer.open({
  900 + title: ['告警轨迹', 'font-size:18px;'],
  901 + type: 1,
  902 + area: ['900px', '650px'],
  903 + content: laytpl(res.body).render(JSON.stringify(params))
  904 + });
  905 + });
  906 + });
  907 +
  908 + });
  909 + //点击严重重要一般统计告警
  910 + $("#alarm-count-id").find(".warn-count-item").unbind('click').on("click", function () {
  911 + var alarmLevel = $(this).attr("alarm-level");
  912 + if (alarmLevel != '' && alarmLevel != null && alarmLevel != undefined) {
  913 + $("#alarmLevelSearchBox").val(alarmLevel)
  914 + layui.form.render('select');
  915 + reloadTable();
  916 + } else {
  917 + $("#alarmLevelSearchBox").val("");
  918 + layui.form.render('select');
  919 + if (alarmLevel === '') {
  920 + reloadTable();
  921 + }
  922 + }
  923 + });
  924 + initToolBarClickEvent();
  925 + //表格排序监听 joke add 20200408
  926 + table.on('sort(activewarningTable)', function (obj) {
  927 + //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如:
  928 + if (obj.type != null) {
  929 + sortKey = obj.field + ' ' + obj.type;
  930 + } else {
  931 + sortKey = '';
  932 + }
  933 + reloadTable('sort');
  934 + })
  935 + //更改告警级别颜色
  936 + setColourLevel();
  937 + }
  938 + }
  939 + })
  940 +
  941 + //触发拖动列事件,参数为保存按钮的id
  942 + common.dragCols("activewarning_cols_save");
  943 +
  944 + //保存列顺序
  945 + $("#activewarning_cols_save").unbind("click").on("click", function () {
  946 + var params = {
  947 + domId: 'activewarningTable',
  948 + moduleId: 'activewarning',
  949 + resType: '',
  950 + cols: JSON.stringify(activeAlarmTable.config.cols)
  951 + }
  952 + common.saveTableCols(params,0);
  953 + });
  954 + resTopo();
  955 + }
  956 + });
  957 + });
  958 +
  959 + //更改告警级别颜色
  960 + function setColourLevel() {
  961 + //获取告警等级
  962 + let alarmLevel = $("#alarmLevelSearchBox").val();
  963 + $('#alarm_serious').css("color","#666");
  964 + $('#alarm_important').css("color","#666");
  965 + $('#alarm_commonly').css("color","#666");
  966 + switch (alarmLevel) {
  967 + case "3"://严重告警
  968 + $('#alarm_serious').css("color","#D81E06");
  969 + break;
  970 + case "2"://重要告警
  971 + $('#alarm_important').css("color","#FF7E00");
  972 + break;
  973 + case "1"://一般告警
  974 + $('#alarm_commonly').css("color","#1e9fff");
  975 + break;
  976 + default://其他 空或无
  977 + break;
  978 + }
  979 + }
  980 +
  981 + //绑定下拉搜索事件
  982 + function bindSelectEvent() {
  983 + //选择业务搜索
  984 + form.on('select(bisTypeSearch)', function (data) {
  985 + bizId = data.value;
  986 + reloadTable();
  987 + });
  988 + //选择业务搜索
  989 + form.on('select(alarmKpiSearch)', function (data) {
  990 + reloadTable();
  991 + });
  992 + // 告警状态
  993 + form.on('select(alarmStatusSearch)', function (data) {
  994 + reloadTable();
  995 + });
  996 + //告警级别
  997 + form.on('select(alarmLevelSearch)', function (data) {
  998 + reloadTable();
  999 + });
  1000 + // 告警确认
  1001 + form.on('select(alarmConfirmSearch)', function (data) {
  1002 + reloadTable();
  1003 + });
  1004 + }
  1005 +
  1006 + $("#todayOrAllBtn").unbind().on("click",function () {
  1007 + var $that = $(this);
  1008 + var str = $(this).text();
  1009 + if(str.indexOf("今日") > -1){
  1010 + $that.text("全部告警")
  1011 + todayStr = common.getToday('day');
  1012 + }else{
  1013 + todayStr = ''
  1014 + $that.text("今日告警")
  1015 + }
  1016 + reloadTable();
  1017 + })
  1018 +
  1019 +
  1020 + //刷新表格
  1021 + function reloadTable(type) {
  1022 + if (type != 'sort'){
  1023 + sortKey = '';
  1024 + }
  1025 + activeAlarmTable.reload({
  1026 + page: {
  1027 + curr: 1
  1028 + }
  1029 + ,where: {
  1030 + access_token: accessToken,
  1031 + kpiName: $("#activewarningkw").val(),
  1032 + busId: bizId,
  1033 + resId: resId,
  1034 + kpiId: kpiId,
  1035 + alarmStatus: $("#alarmStatusSearchBox").val(),
  1036 + alarmLevel: $("#alarmLevelSearchBox").val(),
  1037 + confirmStatus: $("#alarmConfirmSearchBox").val(),
  1038 + beginTime: $("#activewarningStartdate").val(),
  1039 + endTime: $("#activewarningEnddate").val(),
  1040 + sortKey: sortKey,
  1041 + //alarmKpi: $("#alarmKpiSearchBox").val(),
  1042 + alarmKpi: $("#alarmKpiSearchBox").val()!='KPI97B835A4'?$("#alarmKpiSearchBox").val():'',
  1043 + isBus:$("#alarmKpiSearchBox").val()=='KPI97B835A4'?'Y':'',
  1044 + durationVal: $('#inline-condition-duration input[name="durationVal"]').val(),
  1045 + durationUnit: $('#inline-condition-duration select[name="durationUnit"]').val(),
  1046 + alarmTimeDay:todayStr,
  1047 + resType:resType
  1048 + }
  1049 + });
  1050 + }
  1051 +
  1052 + //获取告警统计信息
  1053 + function getAlarmCount() {
  1054 + admin.req({
  1055 + url: common.domainName + "/api-web/home/alarm/countByAlarmLevel"
  1056 + , type: "get"
  1057 + , done: function (data) {
  1058 + var alarms = data.data;
  1059 + if (data.code == 0) {
  1060 + $.each(alarms, function (i, v) {
  1061 + if (v.alarmLevel == 5) {//及时率
  1062 + $("#alarm_dealRate").html(v.alarmNum + "%");
  1063 + }
  1064 + });
  1065 + } else {
  1066 + console.error("接口请求失败")
  1067 + console.log(data.msg);
  1068 + }
  1069 + }
  1070 + })
  1071 + }
  1072 +
  1073 + form.render(null, 'activewarning-form');
  1074 + //60秒倒计时
  1075 + (function () {
  1076 + var autoBtn = $('#activewarningAutoFlush');
  1077 + var timer = null;
  1078 +
  1079 + function autoFlush(target) {
  1080 + var el = target.find('span');
  1081 + var checked = target.find('input').prop('checked');
  1082 + localStorage.setItem('alarm_auto__flush', checked);
  1083 + function fn() {
  1084 + var second = el.data('second');
  1085 + var checked = target.find('input').prop('checked');
  1086 + if (!checked) {
  1087 + return;
  1088 + }
  1089 + --second;
  1090 + el.data('second', second);
  1091 + el.html(second + '秒');
  1092 +
  1093 + timer = setTimeout(fn, 1000);
  1094 + if (second <= 0) {
  1095 + clearTimeout(timer);
  1096 + reloadTable()
  1097 + $(el).data('second', 60);
  1098 + $(el).text("60秒");
  1099 + fn();
  1100 + }
  1101 + }
  1102 + if (checked) {
  1103 + timer = setTimeout(fn, 1000);
  1104 + } else {
  1105 + clearTimeout(timer);
  1106 + }
  1107 + }
  1108 + form.on("checkbox(warnActiveAutoFlush)",function (data) {
  1109 + autoFlush(autoBtn);
  1110 + })
  1111 + /*autoBtn.change(function () {
  1112 + autoFlush(autoBtn);
  1113 + });*/
  1114 + var auto = localStorage.getItem('alarm_auto__flush')
  1115 + auto = auto ? auto : false;
  1116 + autoBtn.find('input').prop('checked', auto);
  1117 +
  1118 + autoFlush(autoBtn);
  1119 +
  1120 + admin.on('hash(*)', function (router) {
  1121 + if (router.href === '/activewarning') {
  1122 + autoFlush(autoBtn);
  1123 + } else {
  1124 + clearTimeout(timer);
  1125 + }
  1126 + });
  1127 + })();
  1128 +
  1129 + function resTopo() {
  1130 +
  1131 + //绑定鼠标移入移出事件
  1132 + $('table tr').hover(function (obj) {
  1133 + $(obj.currentTarget).find('.reslist-view-topo').removeClass('hide');
  1134 + }, function (obj) {
  1135 + $(obj.currentTarget).find('.reslist-view-topo').addClass('hide');
  1136 + })
  1137 +
  1138 + // 加入/移出收藏夹
  1139 + $('a.reslist-view-topo').unbind('click').on('click', function () {
  1140 + common.viewResTopo($(this).data('resid'));
  1141 + });
  1142 +
  1143 + }
  1144 + });
  1145 +});
  1 +layui.define(['commonDetail','common', 'admin'], function (exports) {
  2 + var $ = layui.$;
  3 + var commonDetail = layui.commonDetail;
  4 + var common = layui.common;
  5 + var admin = layui.admin;
  6 + //对外暴露的接口
  7 + exports('arms', function (data) {
  8 + var resId = '';
  9 + var resType = '';
  10 + var os = '';
  11 + var domainName = common.domainName;
  12 + var showFlag = common.getUrlParam("show");
  13 + if(showFlag && showFlag == '0'){
  14 + resId = common.getUrlParam("resId");
  15 + resType = common.getUrlParam("resType");
  16 + os = common.getUrlParam("os");
  17 + }else{
  18 + resId = data.resId;
  19 + resType = data.resType;
  20 + os = data.os;
  21 + }
  22 +
  23 + //基本信息
  24 + var jbxxKpi = "KPIE13DD9A3,KPIF74D9D2B";
  25 +
  26 + commonDetail.bindTips();
  27 +
  28 + renderPageInfo()
  29 +
  30 + //渲染页面
  31 + function renderPageInfo() {
  32 + //资源状态
  33 + commonDetail.renderResHealth("arms_health_state", resId);
  34 + //基本信息
  35 + commonDetail.renderText("arms_baseinfo", resId, jbxxKpi, null, null, null, "true");
  36 +
  37 + //GC瞬时次数/每分钟
  38 + dataRenderingBase("arms_frequency_lineChart", resId, "KPIB30309CF,KPI6AFFCBDB", "GC瞬时次数/每分钟", null);
  39 + // //GC瞬时耗时/每分钟
  40 + dataRenderingBase("arms_elapsed_lineChart", resId, "KPI5769F327,KPI8B2CCCCF", "GC瞬时耗时/每分钟", null);
  41 + // //堆内存详情/每分钟
  42 + dataRenderingBase("arms_JVM_memory_lineChart", resId, "KPI5C214A8F,KPI14BD24A7,KPI206706E5", "堆内存详情/每分钟", null);
  43 + // //非堆内存/每分钟
  44 + dataRenderingBase("arms_NOJVN_memory_lineChart", resId, "KPIA751DDD7,KPIB0C32458,KPIBEA62DAA,KPID346BB6F", "非堆内存/每分钟", null);
  45 + // //直接缓冲区/每分钟
  46 + dataRenderingBase("arms_cacheRegion_lineChart", resId, "KPIBAD64951,KPIA80D93D8", "直接缓冲区/每分钟", null);
  47 + // //JVM线程数/每分钟
  48 + dataRenderingBase("arms_JVM_threadCount_lineChart", resId, "KPI7C4BEB26,KPI97B71BAA,KPI15EC2627,KPIA9E2E4DE,KPI068D9FA5,KPI6ECA9036,KPI328E5AFE,KPI8F8FAD7F", "JVM线程数/每分钟", null, 1);
  49 + //响应时间/每分钟
  50 + dataRenderingBase("arms_time_lineChart", resId, "KPI678F9FC3", "响应时间/每分钟", null);
  51 + // Start Wang 2022/2/24 9:29 解决:arms采集结果展示(详情页面开发)
  52 + // 节点详情
  53 + commonDetail.renderTable("arms_node_detail",false,resId,"KPI452C0F78,KPI5769F327,KPI8B2CCCCF,KPI678F9FC3,KPI649E288B,KPI8DC835B1,KPI4D6871EA,KPICC063E40,KPIFC03301B",'节点详情',`detail`,'KPIFC03301B','desc');
  54 + // End Wang 2022/2/24 9:30
  55 + //活动告警
  56 + commonDetail.renderActiveAlarms("arms_active_alram", resId);
  57 + }
  58 +
  59 + //折线图数据渲染及页面设置
  60 + function dataRenderingBase(id, resId, kpiId, title, flag) {
  61 + var dataList = {};
  62 + var item = {};
  63 + var other = {};
  64 + item.legend = {};
  65 + item.x = {};
  66 + item.y = {};
  67 + //获取数据
  68 + admin.req({
  69 + url: domainName + '/api-web/details/getBase',
  70 + data: {
  71 + resId: resId,
  72 + kpiIds: kpiId,
  73 + }
  74 + }).done(function (response) {
  75 + if (response.success && !response.msg) {//有数据
  76 + dataList.legend = response.map.legend;
  77 + dataList.x = response.map.x;
  78 + if (response.map.y != null) {
  79 + var series = [];
  80 + $.each(response.map.y, function (i, v) {
  81 + var item = {
  82 + name: dataList.legend[i],
  83 + stack: 'Total',
  84 + type: 'line',
  85 + emphasis: {
  86 + focus: 'series'
  87 + },
  88 + itemStyle: {
  89 + normal: {
  90 + color: common.colorsArr[i%6].start
  91 + }
  92 + },
  93 + data: v,
  94 + };
  95 + series.push(item);
  96 + });
  97 + other["series"]=series;
  98 + }
  99 + initLinChart(id, resId, kpiId, title, flag, dataList, other);
  100 + } else {//无数据
  101 + //初始化数据
  102 + }
  103 + });
  104 + //页面渲染
  105 + return {item, other}
  106 + }
  107 + //初始化折线图
  108 + function initLinChart(id, resId, kpiId, title, flag, data, other) {
  109 + //初始化echarts
  110 + var myChart = echarts.init(document.getElementById(id));
  111 +
  112 + //初始化配置option
  113 + var option;
  114 + option = {
  115 + legend: {//设置图表图例
  116 + data: data.legend,
  117 + },
  118 + tooltip: {
  119 + trigger: 'axis',
  120 + },
  121 + toolbox: {
  122 + feature: {
  123 + saveAsImage: {}
  124 + }
  125 + },
  126 + xAxis: {//X轴数据
  127 + type: 'category',
  128 + boundaryGap: false,
  129 + data: data.x,
  130 + },
  131 + yAxis: {//设置提示
  132 + type: 'value'
  133 + },
  134 + grid: { //直角坐标系内绘图网格
  135 + left: '3%',
  136 + right: '4%',
  137 + bottom: '3%',
  138 + containLabel: true
  139 + },
  140 + series: [//y轴数据
  141 + {
  142 + data: data.y?data.y:{},
  143 + type: 'line',
  144 + smooth: true
  145 + }
  146 + ]
  147 + };
  148 + //获取传入option对象
  149 + var keys = Object.keys(other);
  150 + //替换option属性
  151 + keys.forEach(item => {
  152 + option[item]=other[item];
  153 + });
  154 + option && myChart.setOption(option);
  155 + }
  156 +
  157 +
  158 + //定时任务
  159 + var timer = setInterval(function () {
  160 + renderPageInfo()
  161 + },commonDetail.timerTime);
  162 + commonDetail.detailTimer.push(timer);
  163 + });
  164 +});
  1 +layui.define(['tree', 'laypage', 'laytpl', 'admin', 'form', 'table', 'commonCols', 'echarts', 'sessions',"commonDetail",'tableTree','soulTable'], function (exports) {
  2 + var $ = layui.$;
  3 + var laytpl = layui.laytpl;
  4 + var tree = layui.tree;
  5 + var form = layui.form;
  6 + var view = layui.view;
  7 + var table = layui.table;
  8 + var admin = layui.admin;
  9 + var commonCols = layui.commonCols;
  10 + var soulTable = layui.soulTable;
  11 + var tableTree = layui.tableTree;
  12 + var common = layui.common;
  13 + var commonDetail = layui.commonDetail;
  14 + var busId = '';//当前业务Id
  15 + var appId = '';
  16 + var curTreeNode = '';
  17 + var curBizResType = '';//当前业务所在的资源类型
  18 +
  19 + var sortKey = '';
  20 +
  21 +
  22 + function autoHeight(el) {
  23 + // var height = el.parents('.layui-card').height();
  24 + // el.css('min-height', height - 75);
  25 + }
  26 +
  27 + // 隐藏左侧菜单
  28 + $('#LAY_app_flexible').click();
  29 +
  30 + //对外暴露的接口
  31 + exports('bizindex', function () {
  32 + var sessions = layui.sessions;
  33 + var accessToken = sessions.getToken()['access_token'];
  34 + var router = layui.router();
  35 + // 资源视图父级表格
  36 + var bizParentList;
  37 + // 资源视图表格
  38 + var bizListTable;
  39 + //点击卡片
  40 + $('#bizindexTable').unbind('click').on('click', '[data-biz-card]', function () {
  41 + var resType = $(this).data("biz-card");
  42 + var isLeaf = $(this).data("biz-leaf");
  43 + //过滤业务卡片
  44 + if (isLeaf =='1') {
  45 + //回选树节点
  46 + selectedBizTreeNode('[data-id="' + resType + '"]', "biz");
  47 + renderBizResTypeCard(resType);
  48 + } else if(isLeaf == '0'){
  49 + selectedBizTreeNode('[data-id="' + resType + '"]', "biz");
  50 + renderSecondIndex(resType);
  51 + }else{
  52 + //curBizResType = resType;
  53 + $("div[data-id='"+busId+"']").find("div[data-id='"+resType+"'] .layui-tree-entry:first span.layui-tree-txt").trigger("click")
  54 + }
  55 + });
  56 + // 查看拓扑
  57 + $('#bizindexTable').on('click', '.bizcard-view-topo', function () {
  58 + common.viewBizTopo($(this).data('busid'));
  59 + return false;
  60 + });
  61 + //回车搜索
  62 + $('#bizindex_keyword').keydown(function (e) {
  63 + if (e.keyCode === 13) {
  64 + // renderList(busId, curBizResType);
  65 + reloadTable();
  66 + return false;
  67 + }
  68 + });
  69 +
  70 + var loading = layer.load(2);
  71 +
  72 + // 树收缩事件
  73 + $('#bizindex-leftree-shrink').on('click', function () {
  74 + $(".bizIndexLeft").animate({width:0,minWidth:0,marginLeft:0},300,function () {
  75 + $("#bizindex-leftree_btn").show();
  76 + $("#bizindex-leftree-shrink").hide();
  77 + });
  78 + });
  79 +
  80 + //树展开事件
  81 + $("#bizindex-leftree_btn").on("click",function () {
  82 + $("#bizindex-leftree_btn").hide();
  83 + $("#bizindex-leftree-shrink").show();
  84 + $(".bizIndexLeft").animate({minWidth:250,marginLeft:10},300);
  85 + });
  86 +
  87 + //this
  88 + loadBizTree();
  89 +
  90 + function renderIndex(busId, resType) {
  91 + $('#bizIndexContent').show();
  92 + $('#bizListContent').hide();
  93 + $('#biztreeTableContent').hide();
  94 + $('#bizDetailContent').empty();
  95 + $('#bizDetailContent').hide();
  96 + var bizindexTable = $('#bizindexTable');
  97 + autoHeight(bizindexTable);
  98 + window.setResizeEvents('autoHeight', autoHeight);
  99 +
  100 + bizindexTable.html('<div class="loading"></div>');
  101 + admin.req({
  102 + url: common.domainName + '/api-web/home/resource/healthByResType?pResType=' + resType + '&busId=' + busId,
  103 + }).done(function (res) {
  104 + laytpl($('#bizindexTpl').html()).render({list: res.data}, function (html) {
  105 + bizindexTable.html(html);
  106 + });
  107 + });
  108 + }
  109 +
  110 + function renderDefaultIndex() {
  111 + $('#bizIndexContent').show();
  112 + $('#bizListContent').hide();
  113 + $('#biztreeTableContent').hide();
  114 + $('#bizDetailContent').empty();
  115 + $('#bizDetailContent').hide();
  116 + var bizindexTable = $('#bizindexTable');
  117 + autoHeight(bizindexTable);
  118 + window.setResizeEvents('autoHeight', autoHeight);
  119 + admin.req({
  120 + url: common.domainName + '/api-web/home/resource/countResourceGroupByBusType',
  121 + }).done(function (res) {
  122 + layer.close(loading);
  123 + laytpl($('#bizindexTpl').html()).render({list: res.data, isBiz: true}, function (html) {
  124 + bizindexTable.html(html);
  125 + });
  126 + });
  127 + }
  128 +
  129 + function renderSecondIndex(parentId) {
  130 + $('#bizIndexContent').show();
  131 + $('#bizListContent').hide();
  132 + $('#biztreeTableContent').hide();
  133 + $('#bizDetailContent').empty();
  134 + $('#bizDetailContent').hide();
  135 + var bizindexTable = $('#bizindexTable');
  136 + autoHeight(bizindexTable);
  137 + window.setResizeEvents('autoHeight', autoHeight);
  138 + admin.req({
  139 + url: common.domainName + '/api-web/home/resource/countSecondNum?parentId='+parentId,
  140 + }).done(function (res) {
  141 + layer.close(loading);
  142 + laytpl($('#bizindexTpl').html()).render({list: res.data, isBiz: true}, function (html) {
  143 + bizindexTable.html(html);
  144 + });
  145 + });
  146 + }
  147 +
  148 + //详细页面
  149 + function renderDetail(resId, resType) {
  150 + $('#bizIndexContent').hide();
  151 + $('#bizListContent').hide();
  152 + $('#biztreeTableContent').hide();
  153 + $('#bizDetailContent').show();
  154 + var url = common.detailPath(resType);
  155 + view('commonViewModel').render(url).then(function (res) {
  156 + var params = {
  157 + "resId": resId,
  158 + "resType": resType
  159 + };
  160 + laytpl(res.body).render(JSON.stringify(params), function (html) {
  161 + $("#bizDetailContent").html(html);
  162 + });
  163 + });
  164 +
  165 + }
  166 +
  167 + //加载树节点
  168 + function loadBizTree(val) {
  169 + //获取树节点数据
  170 + $("#bizindextree").empty();
  171 + if (val == '' || val == null || val == undefined) {
  172 + val = '';
  173 + }
  174 + admin.req({
  175 + url: common.domainName + '/api-web/home/business/getBusTree?keyword=' + val + '&notExist=machineroom',
  176 + sync: true,
  177 + done: function (res) {
  178 + $('.layui-form layui-card-header')
  179 + if (res.success) {
  180 + var data = res.data;
  181 + tree.render({
  182 + elem: '#bizindextree',
  183 + showLine: false,
  184 + data: data,
  185 + click: function (node) {
  186 + if (node && node.data && node.data.children && node.data.children.length == 1) {
  187 + $('[data-id="' + node.data.children[0].id + '"]').find('.layui-tree-iconClick:first').click()
  188 + }
  189 + curTreeNode = node;
  190 + curBizResType = node.data.id;
  191 + if (node.data.code) {
  192 + busId = JSON.parse(node.data.code)["busId"];
  193 + appId = JSON.parse(node.data.code)["appId"];
  194 + }
  195 + var el = null;
  196 + if (node.data.children) {
  197 + el = $(node.elem[0]).find('>.layui-tree-entry .layui-tree-txt');
  198 + } else {
  199 + el = $(node.elem[0]).find('.layui-tree-txt');
  200 + }
  201 +
  202 + var action = 'removeClass';
  203 + if (!el.hasClass('tree-node-select') && node.state === 'open') {
  204 + action = 'addClass';
  205 + el.parents('.layui-tree').find('.tree-node-select').removeClass('tree-node-select');
  206 + }
  207 +
  208 + el[action]('tree-node-select');
  209 + // 决定显示那个视图
  210 + var optionsStr = '';
  211 + if (node.data.code) {
  212 + optionsStr = JSON.parse(node.data.code)['options'];
  213 + }
  214 + if (optionsStr && optionsStr != "") {
  215 + options = JSON.parse(optionsStr);
  216 + var callback = options.bizCallBack;
  217 + var fun = eval(callback);
  218 + // 获取回调方法
  219 + if ($.isFunction(fun)) {
  220 + fun.call(this, data, node.data, options);
  221 + }
  222 + } else if (node.data.code && JSON.parse(node.data.code).isLeaf == '0') {
  223 + renderSecondIndex(node.data.id);
  224 + } else {
  225 + if (node.data && node.data.system) {
  226 + //操作系统
  227 + if (node.data.system.length > 0) {
  228 + renderSystem(node.data.system);
  229 + }
  230 + } else {
  231 + renderBizResTypeCard(node.data.id);
  232 + }
  233 +
  234 + }
  235 + }
  236 + });
  237 + $("#bizTotal").html(res.count);
  238 + loadParamSelect();
  239 + resTopo();
  240 + }
  241 + }
  242 + }).error(function () {
  243 + layer.close(loading);
  244 + var data = new Array();
  245 + tree.render({
  246 + elem: '#bizindextree',
  247 + showLine: false,
  248 + data: data
  249 + });
  250 + $("#bizTotal").html('0')
  251 + laytpl($('#bizindexTpl').html()).render({list: new Array()}, function (html) {
  252 + $('#bizindexTable').html(html);
  253 + });
  254 + });
  255 + renderDefaultIndex();
  256 + }
  257 +
  258 + $("#bizTotal").parent().on("click",function () {
  259 + renderDefaultIndex();
  260 + })
  261 +
  262 + $(".layui-input-search").keyup(function (e) {
  263 + if (e.keyCode === 13) {
  264 + loadBizTree($(this).val())
  265 + }
  266 + });
  267 +
  268 + //资源详细页面
  269 + function loadResDetailInfo(parentNode, data, node, options) {
  270 + var resId = data.id;
  271 + var resType = data.pid;
  272 + renderDetail(resId, resType);
  273 + }
  274 +
  275 + function loadChildResTypeCount(parentNode, data, node, options) {
  276 + var resId = data.id;
  277 + for (var i = 0; i < parentNode.length; i++) {
  278 + if (parentNode.id == data.id) {
  279 + resId = '';
  280 + break;
  281 + }
  282 + }
  283 + var code = JSON.parse(data.code);
  284 + renderIndex(code.busId, resId);
  285 + }
  286 +
  287 + function loadChildBusCount(parentNode, data, node, options) {
  288 + var resId = data.id;
  289 + for (var i = 0; i < parentNode.length; i++) {
  290 + if (parentNode.id == data.id) {
  291 + resId = '';
  292 + break;
  293 + }
  294 + }
  295 + var code = JSON.parse(data.code);
  296 + renderSecondIndex(code.busId);
  297 + }
  298 +
  299 + function openResourceView(parentNode, data, node, options) {
  300 + var code = JSON.parse(data.code);
  301 + renderList(code.busId, data.id);
  302 + }
  303 + //资源视图父级列表
  304 + function openParentResourceView(parentNode, data, node, options) {
  305 + var code = JSON.parse(data.code);
  306 + renderParentList(code.busId, data.id);
  307 + }
  308 +
  309 + //加载虚拟化数据(平台、资源池、物理机、虚拟机)
  310 + function loadVirtualizationView(parentNode, data, node, options) {
  311 + renderTreeTable(busId, data.id);
  312 + }
  313 + //加载weblogic
  314 + function loadWeblogicView(parentNode, data, node, options) {
  315 + renderParentList(busId, data.id);
  316 + }
  317 +
  318 + //资源状态
  319 + form.on('select(biz_resStatus)', function (data) {
  320 + // renderList(busId, curBizResType)
  321 + reloadTable();
  322 + });
  323 + //集群选择事件
  324 + form.on('select(biz_res_cluster)', function (data) {
  325 + // renderList(busId, curBizResType);
  326 + reloadTable();
  327 + });
  328 + //资源池选择事件
  329 + form.on('select(biz_res_colony)', function (data) {
  330 + // renderList(busId, curBizResType);
  331 + reloadTable();
  332 + });
  333 + //资源连接状态选择事件
  334 + form.on('select(biz_state)', function (data) {
  335 + // renderList(busId, curBizResType);
  336 + reloadTable();
  337 + });
  338 +
  339 + //资源连接状态选择事件
  340 + form.on('select(biz_platform)', function (data) {
  341 + // renderList(busId, curBizResType);
  342 + reloadTable();
  343 + });
  344 + //连接状态
  345 + form.on('select(bizlink_state)', function (data) {
  346 + // renderList(currentResType);
  347 + reloadTable();
  348 + });
  349 + //连接状态
  350 + form.on('select(bizlink_state)', function (data) {
  351 + // renderList(currentResType);
  352 + reloadTable();
  353 + });
  354 + //资源池选择事件
  355 + form.on('select(biz_sub_restype)', function (data) {
  356 + // renderList(currentResType);
  357 + if (data.value) {
  358 + bizLoadRightResTypeSelectEvent(busId, data.value, 'normal')
  359 + } else {
  360 + bizLoadRightResTypeSelectEvent(busId, curTreeNode.data.id, 'normal')
  361 + }
  362 + reloadTable();
  363 + });
  364 +
  365 + //操作系统
  366 + function renderSystem(system) {
  367 + $('#bizIndexContent').hide();
  368 + $('#bizListContent').show();
  369 + $('#bizDetailContent').empty();
  370 + $('#bizDetailContent').hide();
  371 + $('#biztreeTableContent').hide();
  372 +
  373 + //清除查询条件
  374 + $("#bizindex_keyword").val("");
  375 + $("#biz_resStatus").val("");
  376 + $("#biz_res_colony").val("");
  377 + $("#biz_res_cluster").val("");
  378 + $("#bizlink_state").val("");
  379 + $("#biz_state").val("");
  380 + busId="";
  381 + //隐藏资源类型
  382 + $("#biz_sub_restype").parent().parent().addClass("hide");
  383 + form.render('select');
  384 +
  385 + form.render(null, 'biz-list-form');
  386 + var cols = commonCols.resTypeCls["OperatingSystem"];
  387 + var resTypeList=[];
  388 + $.each(system, function (i, v) {
  389 + resTypeList.push(v.value);
  390 + busId=v.pid;
  391 + });
  392 + //获取配置的列
  393 + common.getTableCols({
  394 + domId: 'bizListTable',
  395 + moduleId: 'bizIndex',
  396 + resType: 'OperatingSystem'
  397 + },function (retCols) {
  398 + if (retCols) {
  399 + cols = retCols;
  400 + }
  401 + bizListTable = table.render({
  402 + elem: '#bizListTable'
  403 + // //, toolbar: '<div><button id="bizIndex_cols_save" class="layui-btn layui-btn-primary layui-btn-xs toolbar-btn" lay-tips="保存列顺序"><i class="iconfont">&#xe633;</i></button></div>' //开启头部工具栏,并为其绑定左侧模板
  404 + , toolbar: '#bizList-top-head-info-tpl' //开启头部工具栏,并为其绑定左侧模板
  405 + , defaultToolbar: ['filter']
  406 + , drag: {toolbar: false}
  407 + , url: common.domainName + '/api-web/home/res-list/' + resTypeList.toString()
  408 + , where: {
  409 + access_token: accessToken,
  410 + resName: $("#bizindex_keyword").val(),
  411 + resHealth: $("#biz_resStatus").val(),
  412 + busId: busId,
  413 + colonlyId: $("#biz_res_colony").val(),
  414 + parentId: $("#biz_res_cluster").val(),
  415 + linkState: $("#bizlink_state").val(),
  416 + state: $("#biz_state").val(),
  417 + resCategory: 'resources',
  418 + }
  419 + , height: 'full-165'
  420 + , cellMinWidth: 80
  421 + , page: {
  422 + layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
  423 + , theme: '#1E9FFF'
  424 + }
  425 + , autoSort: false
  426 + , cols: [cols]
  427 + , done: function (res) {
  428 + soulTable.render(this);
  429 + getResCount(busId, resTypeList.toString());
  430 + commonCols.colsClickEvent();
  431 +
  432 + bizLoadRightResTypeSelectEvent(busId, 'OperatingSystem', 'normal', res.obj);
  433 + //表格排序监听 joke add 20200408
  434 + table.on('sort(bizListTable)', function (obj) {
  435 + //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如:
  436 + if (obj.type != null) {
  437 + sortKey = obj.field + ' ' + obj.type;
  438 + } else {
  439 + sortKey = '';
  440 + }
  441 + reloadTable();
  442 + })
  443 + //触发拖动列事件,参数为保存按钮的id
  444 + common.dragCols("bizIndex_cols_save");
  445 + //保存列顺序
  446 + $("#bizIndex_cols_save").unbind("click").on("click", function () {
  447 + var params = {
  448 + domId: 'bizListTable',
  449 + moduleId: 'bizIndex',
  450 + resType: 'OperatingSystem',
  451 + cols: bizListTable.config.cols
  452 + }
  453 + common.saveTableCols(params);
  454 + });
  455 + resTopo();
  456 + }
  457 + });
  458 + });
  459 +
  460 + }
  461 + //获取业务下的资源类型健康统计
  462 + function renderBizResTypeCard(bizId) {
  463 + busId = bizId;
  464 + $('#bizIndexContent').show();
  465 + $('#bizListContent').hide();
  466 + $('#biztreeTableContent').hide();
  467 + $('#bizDetailContent').empty();
  468 + $('#bizDetailContent').hide();
  469 + var bizindexTable = $('#bizindexTable');
  470 + autoHeight(bizindexTable);
  471 + window.setResizeEvents('autoHeight', autoHeight);
  472 + admin.req({
  473 + url: common.domainName + "/api-web/datavis/getResTotal/?busId=" + bizId
  474 + , done: function (res) {
  475 + laytpl($('#bizindexTpl').html()).render({list: res.data}, function (html) {
  476 + bizindexTable.html(html);
  477 + });
  478 + }
  479 + });
  480 + }
  481 +
  482 +
  483 + function renderParentList(busId, resType) {
  484 + $('#bizIndexContent').hide();
  485 + $('#bizListContent').show();
  486 + $('#bizDetailContent').empty();
  487 + $('#bizDetailContent').hide();
  488 + $('#biztreeTableContent').hide();
  489 + renderBizSerach(resType, busId, true);
  490 + form.render(null, 'biz-list-form');
  491 + var cols = commonCols.resTypeCls[resType];
  492 + //获取配置的列
  493 + common.getTableCols({
  494 + domId: 'bizParentList',
  495 + moduleId: 'bizIndex',
  496 + resType: resType
  497 + },function (retCols) {
  498 + if (retCols) {
  499 + cols = retCols;
  500 + }
  501 + bizParentList = table.render({
  502 + elem: '#bizListTable'
  503 + , url: common.domainName + '/api-web/home/res-list/' + resType
  504 + , toolbar: '#bizList-top-head-info-tpl' //开启头部工具栏,并为其绑定左侧模板
  505 + , defaultToolbar: ['filter']
  506 + , drag: {toolbar: false}
  507 + , where: {
  508 + access_token: accessToken,
  509 + resName: $("#bizindex_keyword").val(),
  510 + resHealth: $("#biz_resStatus").val(),
  511 + busId: busId,
  512 + colonlyId: $("#biz_res_colony").val(),
  513 + parentId: $("#biz_res_cluster").val(),
  514 + linkState: $("#bizlink_state").val(),
  515 + state: $("#biz_state").val(),
  516 + resCategory: 'resources'
  517 + }
  518 + , height: 'full-165'
  519 + , cellMinWidth: 80
  520 + , page: {
  521 + layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
  522 + , theme: '#1E9FFF'
  523 + }
  524 + , autoSort: false
  525 + , cols: [cols]
  526 + , done: function (res) {
  527 + soulTable.render(this)
  528 + getResCount(busId, resType)
  529 +
  530 + commonCols.colsClickEvent();
  531 +
  532 + //表格排序监听 joke add 20200408
  533 + table.on('sort(bizListTable)', function (obj) {
  534 + //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如:
  535 + if (obj.type != null) {
  536 + sortKey = obj.field + ' ' + obj.type;
  537 + } else {
  538 + sortKey = '';
  539 + }
  540 + reloadTable();
  541 + })
  542 +
  543 + //触发拖动列事件,参数为保存按钮的id
  544 + common.dragCols("bizIndex_cols_save");
  545 +
  546 + bizLoadRightResTypeSelectEvent(busId, resType, 'normal', res.obj);
  547 + //保存列顺序
  548 + $("#bizIndex_cols_save").unbind("click").on("click", function () {
  549 + var params = {
  550 + domId: 'bizParentList',
  551 + moduleId: 'bizIndex',
  552 + resType: resType,
  553 + cols: bizParentList.config.cols
  554 + }
  555 + common.saveTableCols(params);
  556 + });
  557 + resTopo();
  558 + }
  559 + });
  560 + });
  561 + }
  562 + //资源列表
  563 + function renderList(busId, resType) {
  564 + $('#bizIndexContent').hide();
  565 + $('#bizListContent').show();
  566 + $('#bizDetailContent').empty();
  567 + $('#bizDetailContent').hide();
  568 + $('#biztreeTableContent').hide();
  569 +
  570 + renderBizSerach(resType, busId);
  571 +
  572 + form.render(null, 'biz-list-form');
  573 + var cols = commonCols.resTypeCls[resType];
  574 + //获取配置的列
  575 + common.getTableCols({
  576 + domId: 'bizListTable',
  577 + moduleId: 'bizIndex',
  578 + resType: resType
  579 + },function (retCols) {
  580 + if (retCols) {
  581 + cols = retCols;
  582 + }
  583 + bizListTable = table.render({
  584 + elem: '#bizListTable'
  585 + //, toolbar: '<div><button id="bizIndex_cols_save" class="layui-btn layui-btn-primary layui-btn-xs toolbar-btn" lay-tips="保存列顺序"><i class="iconfont">&#xe634;</i></button></div>' //开启头部工具栏,并为其绑定左侧模板
  586 + , toolbar: '#bizList-top-head-info-tpl' //开启头部工具栏,并为其绑定左侧模板
  587 + , defaultToolbar: ['filter']
  588 + , drag: {toolbar: false}
  589 + , url: common.domainName + '/api-web/home/res-list/' + resType
  590 + , where: {
  591 + access_token: accessToken,
  592 + resName: $("#bizindex_keyword").val(),
  593 + resHealth: $("#biz_resStatus").val(),
  594 + busId: busId,
  595 + colonlyId: $("#biz_res_colony").val(),
  596 + parentId: $("#biz_res_cluster").val(),
  597 + linkState: $("#bizlink_state").val(),
  598 + state: $("#biz_state").val(),
  599 + resCategory: 'resources'
  600 + }
  601 + , height: 'full-165'
  602 + , cellMinWidth: 80
  603 + , page: {
  604 + layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
  605 + , theme: '#1E9FFF'
  606 + }
  607 + , autoSort: false
  608 + , cols: [cols]
  609 + , done: function (res) {
  610 + soulTable.render(this)
  611 + getResCount(busId, resType)
  612 +
  613 + commonCols.colsClickEvent();
  614 +
  615 + //表格排序监听 joke add 20200408
  616 + table.on('sort(bizListTable)', function (obj) {
  617 + //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如:
  618 + if (obj.type != null) {
  619 + sortKey = obj.field + ' ' + obj.type;
  620 + } else {
  621 + sortKey = '';
  622 + }
  623 + reloadTable();
  624 + })
  625 +
  626 + //触发拖动列事件,参数为保存按钮的id
  627 + common.dragCols("bizIndex_cols_save");
  628 + bizLoadRightResTypeSelectEvent(busId, resType, 'normal', res.obj);
  629 +
  630 + //保存列顺序
  631 + $("#bizIndex_cols_save").unbind("click").on("click", function () {
  632 + var params = {
  633 + domId: 'bizListTable',
  634 + moduleId: 'bizIndex',
  635 + resType: resType,
  636 + cols: bizListTable.config.cols
  637 + }
  638 + common.saveTableCols(params);
  639 + });
  640 + resTopo();
  641 + }
  642 + });
  643 + });
  644 + }
  645 +
  646 + //树表格
  647 + function renderTreeTable(busId, resType) {
  648 + $('#bizIndexContent').hide();
  649 + $('#bizListContent').hide();
  650 + $('#bizDetailContent').empty();
  651 + $('#bizDetailContent').hide();
  652 + $('#biztreeTableContent').show();
  653 + $(".top-head-info").removeClass("hide");
  654 + layer.load(2); //加载层。
  655 +
  656 + //非平台才有以下三个指标信息
  657 + if (resType != 'VIRTUALIZATION_VMWARE') {
  658 + //绑定虚拟化平台
  659 + common.virtualPlatFormSelect("biz_virtual_platForm_select", busId, function () {
  660 + form.render("select");
  661 + });
  662 + if(resType == 'MIDDLEWARE_WEBLOGIC'){
  663 + $("#biz_virtual_platform_div_id").hide();
  664 + }
  665 + } else {
  666 + $("#biz_virtual_platform_div_id").hide();
  667 + }
  668 +
  669 + var cols = commonCols.resTypeCls[resType];
  670 +
  671 + admin.req({
  672 + url: common.domainName + "/api-web/home/virtual-res-list/" + resType
  673 + , data: {
  674 + ptId: $("#biz_virtual_platForm_select").val(),
  675 + health: $("#biz_treetable_resStatus").val(),
  676 + busId: busId,
  677 + keyWords: $("#biz_treetable_keyword").val(),
  678 + state: $("#biz_treetable_res_state").val()
  679 + }
  680 + , done: function (res) {
  681 + if (res.code == 0) {
  682 + var bizTableTreeVirtual;
  683 + //获取配置的列
  684 + common.getTableCols({
  685 + domId: 'bizTableTreeVirtual',
  686 + moduleId: 'bizIndex',
  687 + resType: resType
  688 + },function (retCols) {
  689 + if (retCols) {
  690 + cols = retCols;
  691 + }
  692 + bizTableTreeVirtual = table.render({
  693 + elem: '#biz_virtual_platform_treeTable',
  694 + data: res.data,
  695 + treeConfig: { //表格树所需配置
  696 + showField: 'resName' //表格树显示的字段
  697 + , treeid: 'resId' //treeid所对应字段的值在表格数据中必须是唯一的,且不能为空。
  698 + , treepid: ''//父级id字段名称
  699 + , iconClass: 'layui-icon-triangle-r' //小图标class样式 窗口图标 layui-icon-layer
  700 + },
  701 + tree: {
  702 + iconIndex: 1
  703 + },
  704 + page: false,
  705 + limit: 9999,
  706 + autoColumnWidth: false,
  707 + cols: [cols]
  708 + , height: 'full-220',
  709 + done: function (res){
  710 + soulTable.render(this);
  711 + common.treeTableDragCols('#biz_virtual_platform_treeTable', '#bizTreeList-top-head-info-tpl');
  712 + bizLoadRightResTypeSelectEvent(busId, resType, 'tree', res.obj);
  713 + // 保存列顺序
  714 + $('#biz_virtual_platform_treeTable').next().find('.btn_save_cols').unbind('click').on('click', function (){
  715 + common.saveTableCols({
  716 + domId: 'bizTableTreeVirtual',
  717 + moduleId: 'bizIndex',
  718 + resType: resType,
  719 + cols: bizTableTreeVirtual.config.cols
  720 + });
  721 + });
  722 + commonCols.colsClickEvent();
  723 + resTopo();
  724 + }
  725 + });
  726 + /*bizTableTreeVirtual.on('tool(tableEvent)',function (obj) {
  727 + if(!obj.data.treeList){
  728 + var field = obj.field; //单元格字段
  729 + var value = obj.value; //修改后的值
  730 + var data = obj.data; //当前行数据
  731 + var event = obj.event; //当前单元格事件属性值
  732 + var subResType = '';
  733 + if(data.resType == 'VIRTUALIZATION_VMWARE' || data.resType == 'VIRTUALIZATION_HUAWEI'){
  734 + subResType = data.resType=='VIRTUALIZATION_VMWARE'?'VIRTUALIZATION_VMWARE_CLUSTER':'VIRTUALIZATION_HUAWEI_CLUSTER';
  735 + }else if(data.resType.indexOf('CLUSTER')>-1){
  736 + subResType = data.resType=='VIRTUALIZATION_VMWARE_CLUSTER'?'VIRTUALIZATION_VMWARE_PHYSICSHOST':'VIRTUALIZATION_HUAWEI_PHYSICSHOST';
  737 + }else if(data.resType.indexOf('PHYSICSHOST')>-1){
  738 + subResType = data.resType=='VIRTUALIZATION_VMWARE_PHYSICSHOST'?'VIRTUALIZATION_VMWARE_VHOST':'VIRTUALIZATION_HUAWEI_VHOST';
  739 + }else{
  740 + subResType = data.resType
  741 + }
  742 + if(event === 'loadChildren'){
  743 + $.ajax({
  744 + url: common.domainName + "/api-web/home/virtual-res-list/" + subResType
  745 + , type: "get"
  746 + , data: {
  747 + ptId: $("#biz_virtual_platForm_select").val(),
  748 + health: $("#treetable_resStatus").val(),
  749 + busId: busId,
  750 + keyWords: $("#biz_treetable_keyword").val(),
  751 + state: $("#biz_treetable_state").val(),
  752 + access_token:accessToken,
  753 + parentId:data.resId
  754 + }
  755 + , success: function (res) {
  756 + if (res.data.length > 0) {
  757 + obj.loadChildren(res.data);
  758 + commonCols.colsClickEvent();
  759 + }
  760 + }
  761 + })
  762 + }
  763 + }
  764 + });*/
  765 + //统计总数
  766 + // $('#biz_virtual_platform_treeTable').next().find('.layui-table-box').after(laytpl($('#biz-treetable-countTpl').html()).render(res.data.length));
  767 + });
  768 + } else {
  769 + console.log(data.msg);
  770 + }
  771 + layer.closeAll();
  772 + //关键字回车事件
  773 + $('#biz_treetable_keyword').keydown(function (e) {
  774 + if (e.keyCode === 13) {
  775 + renderTreeTable(busId, curTreeNode.data.id)
  776 + return false;
  777 + }
  778 + });
  779 + //选择资源状态
  780 + form.on('select(biz_treetable_resStatus)', function (data) {
  781 + renderTreeTable(busId, curTreeNode.data.id);
  782 + });
  783 + //选择业务
  784 + form.on('select(treetableBizTypes)', function (data) {
  785 + renderTreeTable(busId, curTreeNode.data.id);
  786 + });
  787 + //选择业务
  788 + form.on('select(biz_treetable_res_state)', function (data) {
  789 + renderTreeTable(busId, curTreeNode.data.id);
  790 + });
  791 +
  792 + //选择平台
  793 + form.on('select(biz_virtual_platForm_select)', function (data) {
  794 + renderTreeTable(busId, curTreeNode.data.id);
  795 + });
  796 + //资源连接状态选择时间
  797 + form.on('select(biz_treetable_state)', function (data) {
  798 + renderTreeTable(busId, curTreeNode.data.id);
  799 + });
  800 + }
  801 + }).error(function () {
  802 + layer.closeAll();
  803 + });
  804 + }
  805 +
  806 + //获取资源统计
  807 + function getResCount(busId, resType) {
  808 + admin.req({
  809 + url: common.domainName + "/api-web/home/res-list/count/" + resType + "?busId=" + busId
  810 + , done: function (data) {
  811 + var rest = data.map;
  812 + if (data.code === 0) {
  813 + $("#resGoodCount").text("优:" + rest.good);
  814 + $("#resWorseCount").text("良:" + rest.worse);
  815 + $("#resWorstCount").text("中:" + rest.worst);
  816 + } else {
  817 + console.log(data.msg);
  818 + }
  819 + }
  820 + });
  821 + }
  822 +
  823 + //回选树节点
  824 + function selectedBizTreeNode(target, type) {
  825 + $(".layui-tree-txt").removeClass("tree-node-select")
  826 + if (type == 'biz') { //如果是业务,默认展开第一节点
  827 + $(target).addClass("layui-tree-spread");
  828 + $(target).find(".layui-tree-entry").find('.layui-tree-txt').eq(0).addClass("tree-node-select");
  829 + $(target).parent().show();
  830 + $(target).find(".layui-tree-pack").eq(0).show();
  831 + } else if (type == 'select') {
  832 + $(target).parent().show();
  833 + $(target).find(".layui-tree-txt:first").addClass("tree-node-select");
  834 + } else {
  835 + var el = $('[data-id="' + busId + '"]').find(target);
  836 + $(target).parent().show();
  837 + el.find(".layui-tree-txt").addClass("tree-node-select")
  838 + }
  839 + }
  840 +
  841 + //加载资源池、集群等查询条件
  842 + function renderBizSerach(resType, busId, subflag) {
  843 + //清空查询条件 joke add 20200409 开始
  844 + $('#bizindex_keyword').val('');
  845 + $('#biz_resStatus').val('');
  846 + $('#biz_res_colony').val('');
  847 + $('#biz_res_cluster').val('');
  848 + form.render('select');
  849 + //清空查询条件 joke add 20200409 开始
  850 +
  851 +
  852 + var targetId = '';
  853 + var searchType = "";
  854 + var optons = "";
  855 + //华为云物理机,加载华为云集群查询条件
  856 + if (resType == 'HUAWEI_CLOUD_PHYSICSHOST') {
  857 + optons = "<option value=''>=所属集群=</option>"
  858 + searchType = "HUAWEI_CLOUD_CLUSTER";
  859 + targetId = "biz_res_cluster";
  860 + $("#biz_res_cluster_id").show();
  861 + } else if ("MIDDLEWARE_WEBLOGIC" == resType) {
  862 + optons = "<option value=''>=所属控制台=</option>"
  863 + searchType = "MIDDLEWARE_WEBLOGIC";
  864 + targetId = 'biz_res_cluster'
  865 + $("#biz_res_cluster_id").show();
  866 + } else {
  867 + $("#biz_res_cluster_id").hide();
  868 + }
  869 + //华为云的集群、虚拟化物理机,查询条件绑定资源池
  870 + if (resType == 'HUAWEI_CLOUD_CLUSTER' || resType == 'VIRTUALIZATION_VMWARE_PHYSICSHOST') {
  871 + optons = "<option value=''>=所属资源池=</option>"
  872 + if (resType == 'VIRTUALIZATION_VMWARE_PHYSICSHOST') {
  873 + searchType = "VIRTUALIZATION_VMWARE_CLUSTER";
  874 + }
  875 + if (resType == 'HUAWEI_CLOUD_CLUSTER') {
  876 + searchType = "HUAWEI_CLOUD_COLONY";
  877 + }
  878 + targetId = "biz_res_colony";
  879 + $("#biz_res_colony_id").show();
  880 + } else {
  881 + $("#biz_res_colony_id").hide();
  882 + }
  883 + if ("MIDDLEWARE_WEBLOGIC" == resType) {
  884 + $("#biz_platform_id").hide()
  885 + }
  886 +
  887 + if (resType == 'VIRTUALIZATION_VMWARE' || resType == 'VIRTUALIZATION_HUAWEI' || resType == 'MIDDLEWARE_WEBLOGIC') {
  888 + $("#biz_virtual_platform_div_id").hide();
  889 + }
  890 + if (targetId && searchType) {
  891 + var url = "/api-web/home/res-list/" + searchType + "?page=1&limit=50&busId=" + busId;
  892 + if(searchType == 'MIDDLEWARE_WEBLOGIC'){
  893 + url += '&parentId=null'
  894 + }
  895 + admin.req({
  896 + url: common.domainName + url
  897 + }).done(function (res) {
  898 + if (res.data) {
  899 + $.each(res.data, function (i, v) {
  900 + optons += '<option value="' + v.resId + '">' + v.resName + '</option>';
  901 + });
  902 + }
  903 + $('#' + targetId).html(optons);
  904 + form.render("select");
  905 + })
  906 + }
  907 +
  908 + //vmware虚拟机 joke add 20200528
  909 + if (resType == 'VIRTUALIZATION_VMWARE_VHOST') {
  910 + $("#biz_platform_id").show();
  911 + //绑定虚拟化平台
  912 + common.virtualPlatFormSelect("biz_platform", "", function () {
  913 + form.render("select");
  914 + });
  915 + } else {
  916 + $("#biz_platform_id").hide();
  917 + }
  918 + if(subflag){
  919 + $("#biz_sub_restype").parent().parent().removeClass("hide");
  920 + $("#bizListContent").find(".top-head-info").removeClass("hide");
  921 + var url = `${common.domainName}/api-web/bResource/finsResTypeListByParentId?resType=${resType}`
  922 + admin.req({
  923 + url: url
  924 + }).done(function (res) {
  925 + var subhtml = '<option value="">=资源类型=</option>';
  926 + if (res.data) {
  927 + $.each(res.data, function (i, v) {
  928 + subhtml += '<option value="' + v.name + '">' + v.val + '</option>';
  929 + });
  930 + }
  931 + $('#biz_sub_restype').html(subhtml);
  932 + form.render("select");
  933 + })
  934 + } else {
  935 + if (!$("#bizListContent").find(".top-head-info").hasClass("hide")) {
  936 + $("#bizListContent").find(".top-head-info").addClass("hide")
  937 + }
  938 + if (!$("#biz_sub_restype").parent().parent().hasClass("hide")) {
  939 + $("#biz_sub_restype").parent().parent().addClass("hide");
  940 + }
  941 + }
  942 + }
  943 +
  944 + function bizLoadRightResTypeSelectEvent(busId, resType, type, obj) {
  945 + var str = '';
  946 + var domStr = 'bizListContent'
  947 + var fun = reloadTable;
  948 + if (type == 'tree') {
  949 + str = 'tree_'
  950 + domStr = 'biztreeTableContent'
  951 + fun = renderTreeTable
  952 + }
  953 + var map = obj;
  954 + $.each(map, function (key, values) {
  955 + $("#" + str + key + "_biz").html(map[key])
  956 + });
  957 + //清除筛选条件
  958 + $("#" + domStr).find(".info-box-count .num span").unbind().on("click", function () {
  959 + var val = $(this).data("value"), target = $(this).data("target");
  960 + if (val && target) {
  961 + $("#" + target).val(val);
  962 + form.render("select")
  963 + fun(busId, resType);
  964 + } else {
  965 + //清除查询条件
  966 + $('#bizindex_keyword').val('');
  967 + $('#biz_res_colony').val('');
  968 + $('#biz_res_cluster').val('');
  969 + $('#biz_resStatus').val('');
  970 + $('#bizlink_state').val('');
  971 + $('#biz_state').val('');
  972 + $('#biz_sub_restype').val('');
  973 + $("#biz_virtual_platForm_select").val('');
  974 + $("#biz_treetable_resStatus").val('');
  975 + $("#biz_treetable_keyword").val('');
  976 + $("#biz_treetable_res_state").val('');
  977 + $('#biz_platform').val('');
  978 + form.render("select")
  979 + fun(busId, resType);
  980 + }
  981 + })
  982 + }
  983 +
  984 + //重新load表格
  985 + function reloadTable() {
  986 + var platform = $("#biz_platform").find("option:selected").text();
  987 + if (platform == '=所属平台=') {
  988 + platform = '';
  989 + }
  990 + bizListTable = bizParentList = table.reload('bizListTable', {
  991 + page: {
  992 + curr: 1
  993 + }
  994 + ,where: { //请求参数(注意:这里面的参数可任意定义,并非下面固定的格式)
  995 + access_token: accessToken,
  996 + resName: $("#bizindex_keyword").val(),
  997 + resHealth: $("#biz_resStatus").val(),
  998 + busId: busId,
  999 + colonlyId: $("#biz_res_colony").val(),
  1000 + parentId: $("#biz_res_cluster").val(),
  1001 + sortKey: sortKey,
  1002 + state: $("#biz_state").val(),
  1003 + linkState: $("#bizlink_state").val(),
  1004 + platform: platform,
  1005 + subResType:$("#biz_sub_restype").val()
  1006 + }
  1007 + })
  1008 + }
  1009 +
  1010 + function loadParamSelect() {
  1011 + if (router.search.busId) {
  1012 + busId = router.search.busId;
  1013 + var type = router.search.type ? router.search.type : 'select';
  1014 + //回选树节点
  1015 + selectedBizTreeNode('[data-id="' + busId + '"]', type);
  1016 + renderBizResTypeCard(busId);
  1017 + }
  1018 + }
  1019 +
  1020 + function resTopo() {
  1021 +
  1022 + //绑定鼠标移入移出事件
  1023 + $('table tr').hover(function (obj) {
  1024 + $(obj.currentTarget).find('.reslist-view-topo').removeClass('hide');
  1025 + }, function (obj) {
  1026 + $(obj.currentTarget).find('.reslist-view-topo').addClass('hide');
  1027 + })
  1028 +
  1029 + // 加入/移出收藏夹
  1030 + $('a.reslist-view-topo').unbind('click').on('click', function () {
  1031 + common.viewResTopo($(this).data('resid'));
  1032 + });
  1033 +
  1034 + }
  1035 + });
  1036 +});
  1 +// 业务类型管理
  2 +layui.define(['table', 'form', 'admin', 'layer', 'laytpl', 'common', 'view', 'sessions', 'commonDetail', 'treeTable', 'xmSelect', 'userlist', 'reslist'], function (exports) {
  3 + var $ = layui.$;
  4 + var form = layui.form;
  5 + var layer = layui.layer;
  6 + var admin = layui.admin;
  7 + var table = layui.table;
  8 + var treeTable = layui.treeTable;
  9 + var xmSelect = layui.xmSelect;
  10 + var laytpl = layui.laytpl;
  11 + var view = layui.view;
  12 + var common = layui.common;
  13 + var commonDetail = layui.commonDetail;
  14 + var domainName = common.domainName;
  15 + // 业务类型展示表格
  16 + var busTypeTable;
  17 + // 对外暴露的接口
  18 + exports('bustype', function (data) {
  19 + var sessions = layui.sessions;
  20 + var accessToken = sessions.getToken()['access_token'];
  21 +
  22 + var cutoverId = '', targetType = '';
  23 + if (data && data.cutoverId) {
  24 + cutoverId = data.cutoverId;
  25 + targetType = data.targetType;
  26 + }
  27 + var mode = (data && data.mode) ? data.mode : '';
  28 + var username = (data && data.username) ? data.username : '';
  29 + //展示类型
  30 + var showTypeList=[];
  31 + var dataBusType=[];
  32 + initShowType();
  33 +
  34 + // 查询条件
  35 + var conditions = {busTypeName: ''};
  36 + // 加载遮罩
  37 + var loading;
  38 + var checkList = common.checkPermission(accessToken);
  39 +
  40 + loadBusTypeTable();
  41 + // 查询条件框回车查询事件
  42 + $('#condition-bustype-name').keydown(function (e) {
  43 + if (e.keyCode === 13) {
  44 + loadBusTypeTable();
  45 + return false;
  46 + }
  47 + });
  48 +
  49 + //查询按钮点击事件 joke add 20210428
  50 + $('#bustypeQueryBtn').on('click',function () {
  51 + loadBusTypeTable();
  52 + });
  53 +
  54 + // 删除按钮删除事件
  55 + $('#btn-bustype-delete').click(function () {
  56 + var checks = busTypeTable.checkStatus(false);
  57 + var busId = $.map(checks, function (item) {
  58 + return item.busId;
  59 + });
  60 + deleteBusTypeByIds(busId);
  61 + });
  62 + //授权按钮事件
  63 + $("#btn-bustype-authorization").click(function () {
  64 + var checks = busTypeTable.checkStatus(false);
  65 + var busId = [];
  66 + var j = 0;
  67 + var number = 0;
  68 + for (var i = 0; i < checks.length; i++) {
  69 + if (checks[i].children != null) {
  70 + j++;
  71 + number = checks[i].children.length;
  72 + }
  73 + }
  74 + if (j = 1 && checks.length - number == 1) {
  75 + busId = checks[0].busId;
  76 + } else {
  77 + busId = $.map(checks, function (item) {
  78 + return item.busId;
  79 + });
  80 + }
  81 + if (busId.length == 0) {
  82 + layer.msg('请先选择数据', {icon: 0, timeout: 3000});
  83 + return;
  84 + } else if (busId.length == 1) {
  85 + busId = busId[0];
  86 + } else {
  87 + busId = busId.toString();
  88 + }
  89 + authorizationIndex(busId)
  90 + })
  91 +
  92 + var cols = []
  93 + if (!mode) {
  94 + cols.push({
  95 + type: 'checkbox'
  96 + })
  97 + }
  98 + cols = cols.concat([{
  99 + type: 'numbers', title: '序号', align: 'center', width: 70
  100 + }, {
  101 + field: 'busTypeName', title: '名称', align: 'left',
  102 + templet:
  103 + '<div>' +
  104 + ' <span' +
  105 + ' data-code="{{d.busTypeCode}}"' +
  106 + ' class="layui-table-link btn-bustype-edit">{{d.busTypeName}}' +
  107 + ' </span>' +
  108 + '</div>'
  109 + }, {
  110 + field: 'nickname', title: '负责人', align: 'center'
  111 + }, {
  112 + field: 'busTypeDesc', title: '业务类型描述', align: 'left'
  113 + }, {
  114 + field: 'isOps', title: '乙方运维', align: 'center',width: 120,
  115 + templet: function (d) {
  116 + if(d.isOps==0){
  117 + return '否';
  118 + }else{
  119 + return '是';
  120 + }
  121 +
  122 + }
  123 + }, {
  124 + field: 'isUse', title: '是否使用', align: 'center',width: 120,
  125 + templet: function (d) {
  126 + switch (d.isUse) {
  127 + case 0:
  128 + return '否';
  129 + case 1:
  130 + return '是';
  131 + default:
  132 + return '';
  133 + }
  134 + }
  135 + }, {
  136 + field: 'important', title: '重要程度', align: 'center', width: 120,
  137 + templet: function (d) {
  138 + switch (d.important) {
  139 + case 1:
  140 + return '核心';
  141 + case 2:
  142 + return '重要';
  143 + case 3:
  144 + return '一般';
  145 + case 9:
  146 + return '虚拟业务';
  147 + default:
  148 + return '';
  149 + }
  150 + }
  151 + }, {
  152 + field: 'sort', title: '排序', align: 'right', width: 120,
  153 + }])
  154 + if (!mode) {
  155 + cols.push({
  156 + title: '操作', align: 'center', fixed: 'right', width: '10%',
  157 + templet: function (d) {
  158 + if (d.isLeaf) {
  159 + return '' +
  160 + '<div>' +
  161 + '<button data-id="' + d.busId + '" lay-tips="删除" type="button" class="layui-btn layui-btn-xs layui-btn-normal btn-bustype-delete"><i class="layui-icon layui-icon-delete"></i></button>' +
  162 + '<button data-id="' + d.busId + '" lay-tips="资源分配" type="button" class="layui-btn layui-btn-xs layui-btn-normal btn-bustype-res-config"><i class="layui-icon layui-icon-menu-fill"></i></button>' +
  163 + '<button data-id="' + d.busId + '" lay-tips="授权" type="button" class="layui-btn layui-btn-xs layui-btn-normal btn-bustype-authorize"><i class="layui-icon layui-icon-auz"></i></button>' +
  164 + // '<button data-id="' + d.busId + '" data-code="'+ d.busTypeCode +'" lay-tips="乙方运维配置" type="button" class="layui-btn layui-btn-xs layui-btn-normal btn-bustype-yf-config"><i class="layui-icon layui-icon-set-fill"></i></button>' +
  165 + '</div>'
  166 + } else {
  167 + return '' +
  168 + '<div class="layui-row">' +
  169 + '<button data-id="' + d.busId + '" lay-tips="删除" type="button" class="layui-btn layui-btn-xs layui-btn-normal btn-bustype-delete"><i class="layui-icon layui-icon-delete"></i></button>' +
  170 + '<button data-id="' + d.busId + '" lay-tips="授权" type="button" class="layui-btn layui-btn-xs layui-btn-normal btn-bustype-authorize"><i class="layui-icon layui-icon-auz"></i></button>' +
  171 + '</div>'
  172 + }
  173 + }
  174 + });
  175 + } else {
  176 + cols.push({field: 'showType', title: '展示类型', align: 'center',sort:true,width:210,
  177 + templet: function (d) {
  178 + if(d.parentId == '0' && dataBusType.indexOf(d.busId)>-1){
  179 + return '';
  180 + }else{
  181 + //初始化select内容
  182 + var html='<div><select lay-ignore data-index="99" name="showType" class="layui-input resourceType_showType" style="min-width: 150px;display:inline">';
  183 + $.each(showTypeList,function (i,v) {
  184 + if(d.showType == v.value){
  185 + html += '<option value="' + v.value + '" selected>' + v.name + '</option> '
  186 + }else{
  187 + html += '<option value="' + v.value + '">' + v.name + '</option> '
  188 + }
  189 + });
  190 + html+='</select></div>';
  191 + return html;
  192 + }
  193 + }
  194 + });
  195 + cols.push({
  196 + title: '操作', align: 'center', fixed: 'right', width: '10%',
  197 + templet: function (d) {
  198 + if (d.userCount) {
  199 + return '' +
  200 + '<div class="layui-row">' +
  201 + '<button data-id="' + d.busId + '" type="button" class="layui-btn layui-btn-xs btn-bustype-bind hide" lay-tips="未授权,点击授权"><i class="layui-icon layui-icon-link"></i> 添加授权</button>' +
  202 + '<button data-id="' + d.busId + '" type="button" style="margin-left: 0" class="layui-btn layui-btn-xs layui-btn-danger btn-bustype-unbind" lay-tips="已授权,点击解除授权"><i class="layui-icon layui-icon-unlink"></i> 解除授权</button>' +
  203 + '</div>';
  204 + } else {
  205 + return '' +
  206 + '<div class="layui-row">' +
  207 + '<button data-id="' + d.busId + '" type="button" class="layui-btn layui-btn-xs btn-bustype-bind" lay-tips="未授权,点击授权"><i class="layui-icon layui-icon-link"></i> 添加授权</button>' +
  208 + '<button data-id="' + d.busId + '" type="button" style="margin-left: 0" class="layui-btn layui-btn-xs layui-btn-danger btn-bustype-unbind hide" lay-tips="已授权,点击解除授权"><i class="layui-icon layui-icon-unlink"></i> 解除授权</button>' +
  209 + '</div>';
  210 + }
  211 + }
  212 + });
  213 + }
  214 +
  215 + /**
  216 + * 加载业务类型表格
  217 + */
  218 + function loadBusTypeTable() {
  219 + conditions = {
  220 + busTypeName: $('#condition-bustype-name').val() ? $('#condition-bustype-name').val().trim() : '',
  221 + access_token: accessToken,
  222 + cutoverId: cutoverId,
  223 + targetType: targetType,
  224 + username: username,
  225 + page: -1,
  226 + limit: -1
  227 + };
  228 + conditions.limit = -1;
  229 + admin.req({
  230 + url: domainName + '/api-web/manage/bustype/page',
  231 + data: conditions
  232 + }).done(function (response) {
  233 + $.each(response.data,function (i,v) {
  234 + dataBusType.push(v.parentId);
  235 + })
  236 + // 设置总数
  237 + $('#span-bustype-total').html('共 ' + response.data.length + ' 个业务');
  238 + // 渲染表格
  239 + busTypeTable = treeTable.render({
  240 + elem: '#bustype-table',
  241 + data: response.data,
  242 + page: {
  243 + layout: ['count', 'prev', 'page', 'next', 'limit', 'skip'],
  244 + theme: '#1E9FFF'
  245 + },
  246 + tree: {
  247 + iconIndex: mode ? 1 : 2, // 折叠图标显示在第几列
  248 + isPidData: true, // 是否是id、pid形式数据
  249 + idName: 'busId', // id字段名称
  250 + pidName: 'parentId', // pid字段名称
  251 + onlyIconControl: true // 仅允许点击图标折叠
  252 + },
  253 + cols: cols
  254 + });
  255 +
  256 + //回填数据
  257 + if (data && data.username) {
  258 + if (data.username.length == 1) {
  259 + $.ajax({
  260 + type: "get",
  261 + url: domainName + "/api-web/manage/bustype/getBusTypeByUser?access_token=" + accessToken + "&username=" + data.username[0],
  262 + success: function (res) {
  263 + if (res && res.success) {
  264 + var busTypeData = res.data;
  265 + busTypeTable.setChecked(busTypeData.map(item => item.busId))
  266 + }
  267 + },
  268 + })
  269 + }
  270 + }
  271 +
  272 + // 点击编号编辑事件
  273 + $('.btn-bustype-edit').click(function () {
  274 + if ($.inArray('back:bustype:update', checkList) == -1) {
  275 + layer.msg('暂无权限!', {icon: 7, time: 3000});
  276 + return;
  277 + }
  278 + var busTypeCode = $(this).data('code');
  279 + saveBusType(busTypeCode);
  280 + });
  281 + // 删除事件
  282 + $('.btn-bustype-delete').click(function () {
  283 + var busId = $(this).data('id');
  284 + deleteBusTypeByIds([busId]);
  285 + });
  286 + // 授权事件
  287 + $('.btn-bustype-authorize').click(function () {
  288 + loading = layer.load(2);
  289 + var busId = $(this).data('id')
  290 +
  291 + authorizationIndex(busId)
  292 + });
  293 + // 乙方运维配置
  294 + $('.btn-bustype-yf-config').click(function () {
  295 + var busId = $(this).data('id');
  296 + var busTypeCode = $(this).data('code');
  297 + layer.open({
  298 + type: 2
  299 + ,title: "乙方运维配置"
  300 + ,closeBtn: false
  301 + ,area: ['50%', '70%']
  302 + ,btn: ['关闭']
  303 + ,shade: 0.8
  304 + ,id: 'operationMaintenance-config' //设定一个id,防止重复弹出
  305 + ,content:`/vue3/index.html#/operationMaintenance/config?id=${busId}&code=${busTypeCode}`
  306 + , success: function (layero, index) {
  307 + }
  308 + ,yes: function(index, layero){
  309 + layer.closeAll();
  310 + return false;
  311 + }
  312 + });
  313 +
  314 + $(document).on("closeBusWindow", function(){
  315 + layer.closeAll();
  316 + });
  317 +
  318 +
  319 + });
  320 +
  321 + $('.btn-bustype-bind').unbind('click').on('click', function () {
  322 + var $this = $(this);
  323 + var busId = $this.data('id')
  324 +
  325 + layer.load(2);
  326 + admin.req({
  327 + url: domainName + '/api-web/manage/bustype/bindUser/' + busId,
  328 + data: {username},
  329 + success(response) {
  330 + layer.closeAll('loading');
  331 + if (response && response.success) {
  332 + $this.addClass('hide');
  333 + $this.parent().find('.btn-bustype-unbind').removeClass('hide')
  334 + var $child = $('tr[data-pid="' + busId + '"] .btn-bustype-bind');
  335 + $child.addClass('hide')
  336 + $child.parent().find('.btn-bustype-unbind').removeClass('hide')
  337 + } else {
  338 + layer.msg('授权失败!', {icon: 2});
  339 + }
  340 + },
  341 + error() {
  342 + layer.closeAll('loading');
  343 + }
  344 + })
  345 + });
  346 + $('.btn-bustype-unbind').unbind('click').on('click', function () {
  347 + var $this = $(this);
  348 + var busId = $this.data('id')
  349 +
  350 + layer.load(2);
  351 + admin.req({
  352 + url: domainName + '/api-web/manage/bustype/unBindUser/' + busId,
  353 + data: {username},
  354 + success(response) {
  355 + layer.closeAll('loading');
  356 + if (response && response.success) {
  357 + $this.addClass('hide');
  358 + $this.parent().find('.btn-bustype-bind').removeClass('hide')
  359 + } else {
  360 + layer.msg('取消授权失败!', {icon: 2});
  361 + }
  362 + },
  363 + error() {
  364 + layer.closeAll('loading');
  365 + }
  366 + })
  367 + });
  368 + // 资源分配事件
  369 + // $('.btn-bustype-res-config').click(function () {
  370 + // var busId = $(this).data('id');
  371 + // var bustypeReslist = layui.reslist({busId: busId, idSuffix: 1})
  372 + // // 展示资源页面layerindex
  373 + // var bustypeReslayerIndex;
  374 + // common.openWin("template/res/reslist", "当前绑定的资源", {busId: busId, idSuffix: 1}, ["完成", "取消"], function () {
  375 + // layer.close(bustypeReslayerIndex);
  376 + // }, null, ['80%', '90%'],
  377 + // function (layero, layerIndex) {
  378 + // bustypeReslayerIndex = layerIndex;
  379 + // // 新增按钮
  380 + // $("#bustype-reslist-add").click(function () {
  381 + // var reslist = layui.reslist();
  382 + // // 添加绑定页面的layerindex
  383 + // var addResLayerIndex;
  384 + // common.openWin("template/res/reslist", "添加绑定", {}, ["添加", "取消"], function () {
  385 + // loading = layer.load(2);
  386 + // // 当前选中的资源
  387 + // var checks = reslist.getData();
  388 + // // 之前已经选择过的资源
  389 + // var oldResIdList = [];
  390 + // admin.req({
  391 + // url: domainName + '/api-web/manage/bustype/resourceList/' + busId,
  392 + // async: false,
  393 + // error: function () {
  394 + // layer.close(loading);
  395 + // }
  396 + // }).done(function (response) {
  397 + // $.each(response.data, function (index, value) {
  398 + // oldResIdList.push(value.resId);
  399 + // });
  400 + // });
  401 + // // 需要进行插入的资源
  402 + // var inserts = [];
  403 + // var insertCount = 0;
  404 + // var isExistCount = 0;
  405 + // $.each(checks, function (index, value) {
  406 + // if (oldResIdList.indexOf(value.resId) === -1) {
  407 + // inserts.push(value.resId);
  408 + // insertCount++;
  409 + // } else {
  410 + // isExistCount++;
  411 + // }
  412 + // });
  413 + // if (inserts.length === 0) {
  414 + // layer.msg('所选的都已存在,无需重复添加!', {icon: 7, time: 5000});
  415 + // layer.close(loading);
  416 + // return;
  417 + // }
  418 + // // 发送请求添加绑定
  419 + // admin.req({
  420 + // url: domainName + '/api-web/manage/bustype/addResource/' + busId + '?access_token=' + accessToken,
  421 + // type: 'POST',
  422 + // contentType: 'application/json',
  423 + // data: JSON.stringify(inserts),
  424 + // error: function () {
  425 + // layer.close(loading);
  426 + // }
  427 + // }).done(function (response) {
  428 + // layer.close(loading);
  429 + // if (response.success) {
  430 + // layer.msg('添加绑定成功!此次添加了' + insertCount + '个新资源' + (isExistCount > 0 ? ',有' + isExistCount + '个已经存在。' : ''), {icon: 1, time: 5000});
  431 + // layer.close(addResLayerIndex);
  432 + // bustypeReslist.reloadResTable();
  433 + // } else {
  434 + // layer.msg('添加绑定失败!', {icon: 2, time: 3000});
  435 + // }
  436 + // });
  437 + // }, null, ['90%', '80%'], function (layero, layerIndex) {
  438 + // addResLayerIndex = layerIndex
  439 + // });
  440 + // });
  441 + // // 取消绑定按钮
  442 + // $("#bustype-reslist-unbind").click(function () {
  443 + // // 需要取消绑定的资源id集合
  444 + // var deletes = [];
  445 + // $.each(bustypeReslist.getData(), function (index, value) {
  446 + // deletes.push(value.resId);
  447 + // });
  448 + // admin.req({
  449 + // url: domainName + '/api-web/manage/bustype/deleteResource/' + busId + '?access_token=' + accessToken,
  450 + // type: 'POST',
  451 + // contentType: 'application/json',
  452 + // data: JSON.stringify(deletes)
  453 + // }).done(function (response) {
  454 + // if (response.success) {
  455 + // layer.msg('取消绑定成功!', {icon: 1, time: 3000});
  456 + // bustypeReslist.reloadResTable();
  457 + // } else {
  458 + // layer.msg('取消绑定失败!', {icon: 2, time: 3000});
  459 + // }
  460 + // });
  461 + // });
  462 + // });
  463 + // });
  464 +
  465 + //资源分配
  466 + $('.btn-bustype-res-config').click(function () {
  467 + if ($.inArray('back:bustype:resource', checkList) == -1) {
  468 + layer.closeAll();
  469 + layer.msg('暂无权限!', {icon: 7, time: 3000});
  470 + return;
  471 + }
  472 + var busId = $(this).data('id');
  473 + layer.open({
  474 + title: '当前绑定的资源',
  475 + type: 1,
  476 + content: $('#bustype-reslist-table').html(),
  477 + btn: ['完成'],
  478 + area: ['80%', '90%'],
  479 + success: function () {
  480 + // 表格
  481 + var resType = 'all';
  482 + $("#bustype_reslist_resListBizTypes").attr("disabled",true);
  483 + form.render();
  484 + //绑定业务下拉选择数据
  485 + common.bizTypeSelect("bustype_reslist_resListBizTypes",function () {
  486 + $("#bustype_reslist_resListBizTypes").val(busId);
  487 + form.render("select");
  488 + });
  489 + //绑定资源类型下拉选择
  490 + common.resTypeSelect("bustype_reslist_restype",function () {
  491 + form.render("select");
  492 + });
  493 + //回车搜索
  494 + $('#bustype_reslist_keyword').keydown(function (e) {
  495 + if (e.keyCode === 13) {
  496 + reloadTable(resType);
  497 + }
  498 + });
  499 + //选择框搜索事件
  500 + bindSelectEvent();
  501 + //渲染表格
  502 + table.render({
  503 + elem: '#bustype_reslist_resListTable'
  504 + , url: common.domainName + '/api-web/home/res-list/' + resType
  505 + , where: {
  506 + access_token: accessToken,
  507 + resName: $("#bustype_reslist_keyword").val(),
  508 + busId: busId,
  509 + resHealth: $("#bustype_reslist_resStatus").val()
  510 + }
  511 + , height: 'full-300'
  512 + , cellMinWidth: 80
  513 + , page: {
  514 + layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
  515 + , theme: '#1E9FFF'
  516 + }
  517 + , limit: common.limit
  518 + , limits: common.limits
  519 + , cols: [[
  520 + {type: 'checkbox'},
  521 + {type: 'numbers', title: '序号', align: 'center'}
  522 + , {field: 'resName', title: '资源名称', minWidth: 300, align: 'center'}
  523 + , {field: 'ip', title: 'IP地址', align: 'center'}
  524 + , {field: 'admin', title: '负责人', align: 'center'}
  525 + , {field: 'resTypeName', title: '资源类型', align: 'center'}
  526 + , {field: 'healthDesc', title: '资源状态', align: 'center'}
  527 + ]]
  528 + });
  529 + //绑定下拉搜索事件
  530 + function bindSelectEvent() {
  531 + // 资源状态
  532 + form.on('select(bustype_reslist_resStatus)', function(data){
  533 + reloadTable(resType);
  534 + });
  535 + // 资源类型
  536 + form.on('select(bustype_reslist_restype)', function(data){
  537 + resType = data.value;
  538 + reloadTable(resType);
  539 + });
  540 + }
  541 + //刷新表格
  542 + function reloadTable(resType) {
  543 + table.reload('bustype_reslist_resListTable', {
  544 + url: common.domainName + '/api-web/home/res-list/' + (resType ? resType : 'all'),
  545 + where: {
  546 + access_token: accessToken,
  547 + resName: $("#bustype_reslist_keyword").val(),
  548 + busId: busId,
  549 + resHealth: $("#bustype_reslist_resStatus").val()
  550 + }
  551 + });
  552 + }
  553 +
  554 +
  555 + // 新增按钮
  556 + $("#bustype-reslist-add").click(function () {
  557 + var reslist = layui.reslist();
  558 + // 添加绑定页面的layerindex
  559 + var addResLayerIndex;
  560 + common.openWin("template/res/reslist", "添加绑定", {}, ["添加", "取消"], function () {
  561 + loading = layer.load(2);
  562 + // 当前选中的资源
  563 + var checks = reslist.getData();
  564 + if (checks.length ==0) {
  565 + layer.msg('请先选择资源后,再进行添加!', {icon: 7, time: 3000});
  566 + layer.close(loading);
  567 + return;
  568 + }
  569 + // 之前已经选择过的资源
  570 + var oldResIdList = [];
  571 + admin.req({
  572 + url: domainName + '/api-web/manage/bustype/resourceList/' + busId,
  573 + async: false,
  574 + error: function () {
  575 + layer.close(loading);
  576 + }
  577 + }).done(function (response) {
  578 + $.each(response.data, function (index, value) {
  579 + oldResIdList.push(value.resId);
  580 + });
  581 + });
  582 + // 需要进行插入的资源
  583 + var inserts = [];
  584 + var insertCount = 0;
  585 + var isExistCount = 0;
  586 + var resTypes=[];
  587 + var parentIds=[];
  588 + $.each(checks, function (index, value) {
  589 + if (oldResIdList.indexOf(value.resId) === -1) {
  590 + resTypes.push(value.resType);
  591 + parentIds.push(value.parentId);
  592 + inserts.push(value.resId);
  593 + insertCount++;
  594 + } else {
  595 + isExistCount++;
  596 + }
  597 + });
  598 + if (inserts.length === 0) {
  599 + layer.msg('所选的都已存在,无需重复添加!', {icon: 7, time: 5000});
  600 + layer.close(loading);
  601 + return;
  602 + }
  603 + var ArrIndex=[];
  604 + if(resTypes.length>0){
  605 + var identify=0;
  606 + $.each(resTypes,function (i,v) {
  607 + if(v=='MIDDLEWARE_WEBLOGIC' && parentIds[i]==''){
  608 + identify=1;
  609 + ArrIndex.push(i);
  610 + }
  611 + });
  612 + if(identify==1){
  613 + //询问框
  614 + layer.confirm('选择的资源中包含weblogic控制台,是否将控制台下的服务一起分配到当前业务下?', {
  615 + btn: ['是','否'] //按钮
  616 + }, function(){//是
  617 + //获得控制台下所有服务的resID
  618 + //如果选择将控制台下的服务一起分配到当前业务下
  619 + var arrResIds=[];
  620 + $.each(ArrIndex,function (i,v) {
  621 + arrResIds.push(inserts[v]);
  622 + })
  623 + var map={
  624 + resIds: arrResIds.toString()
  625 + };
  626 + admin.req({
  627 + url: common.domainName + '/api-web/bResource/resourceByResId?access_token='+accessToken,
  628 + type:'post',
  629 + data:JSON.stringify(map),
  630 + contentType: "application/json;charset=utf-8",
  631 + async:false,
  632 + error: function () {
  633 + layer.msg('获取控制台下所有服务失败', {icon: 2});
  634 + layer.close(layer.index);
  635 + }
  636 + }).done(function (response) {
  637 + if(response.success && response.data && response.data.length>0){
  638 + $.each(response.data,function (i,v) {
  639 + inserts.push(v.resId);
  640 + insertCount++;
  641 + });
  642 + }
  643 + inserts=Array.from(new Set(inserts));
  644 + isExistCount = insertCount-inserts;
  645 + add(addResLayerIndex,inserts,busId,insertCount,isExistCount,resType);
  646 + layer.close(layer.index);
  647 + })
  648 + }, function(){//否
  649 + add(addResLayerIndex,inserts,busId,insertCount,isExistCount,resType);
  650 + layer.close(layer.index);
  651 + });
  652 + }else{
  653 + add(addResLayerIndex,inserts,busId,insertCount,isExistCount,resType);
  654 + }
  655 + }
  656 +
  657 + }, null, ['90%', '80%'], function (layero, layerIndex) {
  658 + addResLayerIndex = layerIndex
  659 + });
  660 + });
  661 + // 取消绑定按钮
  662 + $("#bustype-reslist-unbind").click(function () {
  663 + // 需要取消绑定的资源id集合
  664 + var deletes = [];
  665 + var resTypes=[];
  666 + var parentIds=[];
  667 + $.each(table.checkStatus('bustype_reslist_resListTable').data, function (index, value) {
  668 + deletes.push(value.resId);
  669 + resTypes.push(value.resType);
  670 + parentIds.push(value.parentId);
  671 + });
  672 + if(deletes.length<1){
  673 + layer.msg('请选择要解除绑定的数据!', {icon: 7, time: 3000});
  674 + layer.close(loading);
  675 + return;
  676 + }
  677 + var ArrIndex=[];
  678 + if(resTypes.length>0){
  679 + var identify=0;
  680 + $.each(resTypes,function (i,v) {
  681 + if(v=='MIDDLEWARE_WEBLOGIC' && parentIds[i]==''){
  682 + identify=1;
  683 + ArrIndex.push(i);
  684 + }
  685 + });
  686 + if(identify==1){
  687 + //询问框
  688 + layer.confirm('选择的资源中包含weblogic控制台,是否将控制台下的服务一起取消?', {
  689 + btn: ['是','否'] //按钮
  690 + }, function(){//是
  691 + //获得控制台下所有服务的resID
  692 + //如果选择将控制台下的服务一起取消
  693 + var arrResIds=[];
  694 + $.each(ArrIndex,function (i,v) {
  695 + arrResIds.push(deletes[v]);
  696 + })
  697 + var map={
  698 + resIds: arrResIds.toString()
  699 + };
  700 + admin.req({
  701 + url: common.domainName + '/api-web/bResource/resourceByResId?access_token='+accessToken,
  702 + type:'post',
  703 + data:JSON.stringify(map),
  704 + contentType: "application/json;charset=utf-8",
  705 + async:false,
  706 + error: function () {
  707 + layer.msg('获取控制台下所有服务失败', {icon: 2});
  708 + layer.close(layer.index);
  709 + }
  710 + }).done(function (response) {
  711 + if(response.success && response.data && response.data.length>0){
  712 + $.each(response.data,function (i,v) {
  713 + deletes.push(v.resId);
  714 + });
  715 + }
  716 + deletes=Array.from(new Set(deletes));
  717 + del(busId,deletes,resType);
  718 + layer.close(layer.index);
  719 + })
  720 + }, function(){//否
  721 + del(busId,deletes,resType);
  722 + layer.close(layer.index);
  723 + });
  724 + }else{
  725 + del(busId,deletes,resType);
  726 + }
  727 + }
  728 +
  729 + });
  730 + },
  731 + yes: function (index) {
  732 + layer.close(index);
  733 + }
  734 + });
  735 + });
  736 + });
  737 + }
  738 +
  739 + //授权页面
  740 + function authorizationIndex(busId) {
  741 + if ($.inArray('back:bustype:impower', checkList) == -1) {
  742 + layer.closeAll();
  743 + layer.msg('暂无权限!', {icon: 7, time: 3000});
  744 + return;
  745 + }
  746 + var params = {
  747 + oldUsers: [],
  748 + bindUrl: '/api-web/manage/bustype/bindUser/' + busId,
  749 + unBindUrl: '/api-web/manage/bustype/unBindUser/' + busId
  750 + };
  751 + // 获取当前资源类型的权限用于回显
  752 + admin.req({
  753 + url: domainName + '/api-web/manage/bustype/getUsersByBusId',
  754 + async: false,
  755 + data: {
  756 + busId: busId
  757 + }
  758 + }).done(function (response) {
  759 + $.each(response.data, function (index, value) {
  760 + params.oldUsers.push(value.userAccount);
  761 + })
  762 + return false;
  763 + });
  764 + layer.close(loading);
  765 + var userlist;
  766 + layer.open({
  767 + title: '授权',
  768 + id: 'busType-role-config-layer',
  769 + type: 1,
  770 + area: ['80%', '90%'],
  771 + btn: ['关闭'],
  772 + scrollbar: false,
  773 + success: function () {
  774 + view(this.id).render('/template/user/userlist').done(function () {
  775 + userlist = layui.userlist(params);
  776 + });
  777 + },
  778 + yes: function (index, layero) {
  779 + layer.close(index);
  780 + }
  781 + });
  782 + }
  783 +
  784 + // 新增按钮
  785 + $('#bustype-create').click(function () {
  786 + if ($.inArray('back:bustype:save', checkList) == -1) {
  787 + layer.msg('暂无权限!', {icon: 7, time: 3000});
  788 + return;
  789 + }
  790 + saveBusType();
  791 + });
  792 +
  793 + // 刷新表格按钮
  794 + $('#btn-bustype-reload-table').click(function () {
  795 + loadBusTypeTable();
  796 + });
  797 +
  798 + /**
  799 + * 新增或者编辑业务类型
  800 + *
  801 + * @param busTypeCode 业务类型编号
  802 + */
  803 + function saveBusType(busTypeCode) {
  804 + // 打开(新增/编辑)窗口
  805 + common.openWin('/baseconfig/bustype/add', '<a class="layui-icon layui-icon-edit win_title_icon"></a>' + busTypeCode ? '编辑' : '新增',
  806 + {busTypeCode: busTypeCode}, ['保存', '取消'], function () {
  807 + $('#btn-bustype-submit').click();
  808 + }, null, ['40%', 'auto']);
  809 + }
  810 +
  811 + function deleteBusTypeByIds(busIds) {
  812 + if ($.inArray('back:bustype:delete', checkList) == -1) {
  813 + layer.msg('暂无权限!', {icon: 7, time: 3000});
  814 + return;
  815 + }
  816 + if (busIds.length == 0) {
  817 + layer.msg('请先选择数据,再点击删除。', {icon: 0, timeout: 3000});
  818 + return;
  819 + }
  820 + layer.confirm('确认要删除吗?', {icon: 3, title: '提示'}, function () {
  821 + loading = layer.load(2);
  822 + admin.req({
  823 + url: domainName + '/api-web/manage/bustype/deleteByIds?access_token=' + accessToken,
  824 + type: 'POST',
  825 + contentType: 'application/json',
  826 + data: JSON.stringify(busIds),
  827 + success: function () {
  828 + layer.close(loading);
  829 + },
  830 + error: function () {
  831 + layer.close(loading);
  832 + }
  833 + }).done(function (response) {
  834 + if (response.success) {
  835 + layer.msg('删除成功!', {icon: 1, time: 3000});
  836 + loadBusTypeTable();
  837 + } else {
  838 + layer.msg('删除失败!', {icon: 2, time: 3000});
  839 + }
  840 + });
  841 + });
  842 + }
  843 + //添加绑定
  844 + function add(addResLayerIndex,inserts,busId,insertCount,isExistCount,resType) {
  845 + // 发送请求添加绑定
  846 + admin.req({
  847 + url: domainName + '/api-web/manage/bustype/addResource/' + busId + '?access_token=' + accessToken,
  848 + type: 'POST',
  849 + async: false,
  850 + contentType: 'application/json',
  851 + data: JSON.stringify(inserts),
  852 + error: function () {
  853 + layer.close(layer.index);
  854 + }
  855 + }).done(function (response) {
  856 + layer.close(loading);
  857 + if (response.success) {
  858 + layer.msg('添加绑定成功!此次添加了' + insertCount + '个新资源(父资源)' + (isExistCount > 0 ? ',有' + isExistCount + '个已经存在。' : ''), {icon: 1, time: 5000});
  859 + layer.close(addResLayerIndex);
  860 + reloadTable(resType,busId);
  861 + } else {
  862 + layer.msg('添加绑定失败!', {icon: 2, time: 3000});
  863 + }
  864 + });
  865 + }
  866 +
  867 + //取消绑定
  868 + function del(busId,deletes,resType) {
  869 + admin.req({
  870 + url: domainName + '/api-web/manage/bustype/deleteResource/' + busId + '?access_token=' + accessToken,
  871 + type: 'POST',
  872 + async: false,
  873 + contentType: 'application/json',
  874 + data: JSON.stringify(deletes)
  875 + }).done(function (response) {
  876 + if (response.success) {
  877 + layer.msg('取消绑定成功!', {icon: 1, time: 3000});
  878 +
  879 + reloadTable(resType,busId);
  880 + } else {
  881 + layer.msg('取消绑定失败!', {icon: 2, time: 3000});
  882 + }
  883 + });
  884 + }
  885 + //获取展示类型的字典数据
  886 + function initShowType(){
  887 + if(mode){//如果不展示字段就不去请求
  888 + admin.req({
  889 + url: domainName + '/api-web/manage/ddic/findSucDdics/DETAILS_POWER'
  890 + , method: 'POST'
  891 + , async: false
  892 + , success: function (res) {
  893 + $.each(res.data, function (i, v) {
  894 + showTypeList.push({
  895 + name: v.ddicName
  896 + ,value: v.ddicCode.substring(v.ddicCode.lastIndexOf("_")+1,v.ddicCode.length)
  897 + })
  898 + });
  899 + }
  900 + });
  901 + }
  902 + }
  903 + //刷新表格
  904 + function reloadTable(resType,busId) {
  905 + table.reload('bustype_reslist_resListTable', {
  906 + url: common.domainName + '/api-web/home/res-list/' + (resType ? resType : 'all'),
  907 + where: {
  908 + access_token: accessToken,
  909 + resName: $("#bustype_reslist_keyword").val(),
  910 + busId: busId,
  911 + resHealth: $("#bustype_reslist_resStatus").val()
  912 + }
  913 + });
  914 + }
  915 + //获取选中的数据
  916 + function getCheckData() {
  917 + if(mode){
  918 + //获取改变的值
  919 + var str='';
  920 + var $tr=$('#bustype-table').next().find('tbody tr');
  921 + $.each($tr,function (i,v) {
  922 + var $btn=$(this).find('.btn-bustype-unbind');
  923 + var showType=$(this).find('.resourceType_showType') && $(this).find('.resourceType_showType').eq(0) && $(this).find('.resourceType_showType').eq(0).val() ? $(this).find('.resourceType_showType').eq(0).val():'<';
  924 + if(!$btn.hasClass('hide')){
  925 + str += $btn.attr("data-id")+'_'+showType+',';
  926 + }
  927 + });
  928 + if(str!=''){
  929 + str=str.substring(0,str.length-1);
  930 + }
  931 + return str;
  932 + }else{
  933 + return busTypeTable.checkStatus(false);
  934 + }
  935 +
  936 + }
  937 +
  938 + return {getData: getCheckData};
  939 + });
  940 +});
  1 +// 业务类型管理
  2 +layui.define(['table', 'form', 'admin', 'layer', 'laytpl', 'common', 'view', 'sessions', 'commonDetail', 'treeTable', 'xmSelect', 'userlist', 'reslist'], function (exports) {
  3 + var $ = layui.$;
  4 + var form = layui.form;
  5 + var layer = layui.layer;
  6 + var admin = layui.admin;
  7 + var table = layui.table;
  8 + var treeTable = layui.treeTable;
  9 + var xmSelect = layui.xmSelect;
  10 + var laytpl = layui.laytpl;
  11 + var view = layui.view;
  12 + var common = layui.common;
  13 + var commonDetail = layui.commonDetail;
  14 + var domainName = common.domainName;
  15 +
  16 + // 对外暴露的接口
  17 + exports('bustypeAdd', function (data) {
  18 + var sessions = layui.sessions;
  19 + var accessToken = sessions.getToken()['access_token'];
  20 + var userSelect = {}
  21 + var opsSelect={}
  22 + initUserSelect();
  23 + //渲染运维负责人
  24 + initUserSelectOps();
  25 + // 加载遮罩
  26 + var loading;
  27 +
  28 +
  29 + var oldBusTypeCode = data && data.busTypeCode ? data.busTypeCode : '';
  30 +
  31 + var busType;
  32 +
  33 + // 父业务下拉框
  34 + admin.req({
  35 + url: domainName + '/api-web/manage/bustype/page',
  36 + data: {
  37 + page: -1,
  38 + limit: -1,
  39 + parentId: '0'
  40 + }
  41 + }).done(function (response) {
  42 + var options = '';
  43 + $.each(response.data, function (i, v) {
  44 + options += ' <option value="' + v.busId + '">' + v.busTypeName + '</option> '
  45 + });
  46 + $('select[name="parentId"]').append(options);
  47 +
  48 + // 如果是新增,就对busType进行初始化
  49 + if (!oldBusTypeCode) {
  50 + busType = {
  51 + busTypeCode: '',
  52 + busTypeName: '',
  53 + busTypeDesc: '',
  54 + admin: '',
  55 + isUse: '',
  56 + important: '',
  57 + sort: '',
  58 + isLeaf: '1'
  59 + }
  60 + form.render();
  61 + } else {
  62 + // 如果是编辑模式,回写数据
  63 + admin.req({
  64 + url: domainName + '/api-web/manage/bustype/page',
  65 + data: {
  66 + page: 1,
  67 + limit: 10,
  68 + busTypeCode: oldBusTypeCode
  69 + }
  70 + }).done(function (response) {
  71 + busType = response.data[0];
  72 + form.val('form-bustype-edit', busType);
  73 + $('form[lay-filter="form-bustype-edit"] input[name="busTypeCode"]').attr('readonly', true);
  74 + setTimeout(function (){
  75 + userSelect.setValue([busType.admin]);
  76 + },2000)
  77 +
  78 + let principal = busType.principal;
  79 + let principalLi = principal ? principal.split(",") : [];
  80 + setTimeout(function (){
  81 + opsSelect.setValue(principalLi);
  82 + },2000)
  83 +
  84 +
  85 + //是否启用 1启用 0不启用
  86 + let isUse = busType.isUse || busType.isUse == 0 ? busType.isUse : 1;
  87 + if (isUse != 1) {//不启用
  88 + layui.jquery('input[name="isUse"]').removeAttr('checked'); //改变开关为 关
  89 + }
  90 + //是否是乙方运维 1是,0不是
  91 + let system_type = busType.isOps || busType.isOps == 0 ? busType.isOps : 1;
  92 + if (system_type != 1) {//不是乙方运维 隐藏项目 是否虚拟不能点击
  93 + layui.jquery('input[name="system_type"]').removeAttr('checked'); //改变开关为 关
  94 + $('#select_principalName').addClass("hide");
  95 + //layui.jquery('input[name="isvirtual"]').removeAttr('disabled');//可以点击
  96 + layui.jquery('input[name="isvirtual"]').attr("disabled", true)//不能点击
  97 + }
  98 + //是否是虚拟 0是,1不是
  99 + let isvirtual = busType.isvirtual || busType.isvirtual == 0 ? busType.isvirtual : 0;
  100 + if (isvirtual != 0) {//不是虚拟
  101 + layui.jquery('input[name="isvirtual"]').removeAttr('checked'); //改变开关为 关
  102 + }
  103 + form.render();
  104 + });
  105 + }
  106 + });
  107 + // 业务类型编号改变判断是否已经存在
  108 + $('#txt-bustype-code').change(function () {
  109 + if (checkBusTypeCodeExist($(this).val())) {
  110 + $(this).val(oldBusTypeCode);
  111 + layer.msg('该编码已存在,请重新输入!', {icon: 2, time: 3000});
  112 + }
  113 + });
  114 + //设置乙方运维项目
  115 + form.on('switch(system_type)', function (obj) {
  116 + //sign=fale 不是乙方运维项目 sign=true 是乙方运维项目
  117 + var sign = obj.elem.checked;
  118 + if (!sign) {//不是乙方运维 下拉框隐藏 是否是虚拟项目可以点击
  119 + $('#select_principalName').addClass("hide");
  120 + opsSelect.setValue([]);
  121 + //layui.jquery('input[name="isvirtual"]').removeAttr('disabled');//可以点击
  122 + //删除原来的组件 新加dom
  123 + $('#isvirtual_ops_switch').empty();//删除子元素
  124 + let html = '<input type="checkbox" lay-skin="switch" name="isvirtual" lay-filter="switch_isVirtual" value="0" lay-text="是|否" disabled/>';
  125 + $('#isvirtual_ops_switch').append(html);//追加子元素
  126 +
  127 + //重新渲染
  128 + form.render();
  129 + } else {//是乙方运维 下拉框展示 只能是虚拟项目 不能更改是否是虚拟项目
  130 + $('#select_principalName').removeClass('hide');
  131 + //layui.jquery('input[name="isvirtual"]').attr("checked", true);//改变状态为开
  132 + //layui.jquery('input[name="isvirtual"]').attr("disabled", true)//不能点击
  133 + layui.jquery('input[name="isvirtual"]').removeAttr('disabled');//可以点击
  134 + //渲染下拉框
  135 + initUserSelectOps();
  136 + //重新渲染
  137 + form.render();
  138 + }
  139 + });
  140 +
  141 + // 绑定表单提交事件
  142 + form.on('submit(bus-type-submit)', function (data) {
  143 + loading = layer.load(2);
  144 + busType = Object.assign(busType, data.field);
  145 + //是否启用 1启用 0不启用
  146 + if (!data.field.isUse) {
  147 + busType.isUse = '0'
  148 + }
  149 + //是否是乙方运维 1是,0不是
  150 + if (!data.field.system_type) {
  151 + busType.system_type = '0'
  152 + }
  153 + //是否是虚拟业务 0是,1不是
  154 + if (!data.field.isvirtual) {
  155 + busType.isvirtual = '1'
  156 + }
  157 + if (busType.parentId == busType.busId) {
  158 + // 防止循环引用
  159 + busType.parentId = '0';
  160 + }
  161 + //获取业务负责人信息
  162 + busType.nickname = userSelect.getValue("name")[0];
  163 + busType.admin = userSelect.getValue("value")[0];
  164 + //获取业务运维负责人
  165 + busType.principalName = opsSelect.getValue("nameStr");
  166 + busType.principal = opsSelect.getValue("valueStr");
  167 + delete busType.select
  168 + admin.req({
  169 + url: domainName + '/api-web/manage/bustype/save?access_token=' + accessToken,
  170 + type: 'POST',
  171 + contentType: 'application/json',
  172 + data: JSON.stringify(busType),
  173 + error: function () {
  174 + layer.close(loading);
  175 + }
  176 + }).done(function (response) {
  177 + layer.close(loading);
  178 + if (response.success) {
  179 + layer.msg('保存成功!', {icon: 1, time: 3000});
  180 + layer.closeAll('page');
  181 + $('#btn-bustype-reload-table').click();
  182 + } else {
  183 + layer.msg('保存失败!', {icon: 2, time: 3000});
  184 + }
  185 + });
  186 + return false;
  187 + });
  188 +
  189 +
  190 + /**
  191 + * 判断该业务类型编号是否已经存在
  192 + *
  193 + * @param busTypeCode 业务类型编号
  194 + * @returns {boolean} 存在: true,不存在: false
  195 + */
  196 + function checkBusTypeCodeExist(busTypeCode) {
  197 + var result = true;
  198 + admin.req({
  199 + url: domainName + '/api-web/manage/bustype/page',
  200 + async: false,
  201 + data: {
  202 + page: 1,
  203 + limit: 10,
  204 + busTypeCode: busTypeCode
  205 + }
  206 + }).done(function (response) {
  207 + if (response.data.length === 0) {
  208 + result = false;
  209 + }
  210 + });
  211 + return result;
  212 + }
  213 +
  214 + //初始化用户下拉列表框
  215 + function initUserSelect() {
  216 + $.ajax({
  217 + url: domainName + '/api-user/users/getAll?access_token=' + accessToken,
  218 + sync: false,
  219 + success: function (res) {
  220 + userSelect = xmSelect.render({
  221 + el: '.adminUser',
  222 + radio: true,
  223 + clickClose: true,
  224 + prop: {
  225 + name: 'nickname',
  226 + value: 'username'
  227 + },
  228 + filterable: true,
  229 + layVerify: 'required',
  230 + layVerType: 'msg',
  231 + data: res,
  232 + })
  233 + }
  234 + })
  235 + }
  236 +
  237 + //初始化用户下拉列表框
  238 + function initUserSelectOps() {
  239 + $.ajax({
  240 + url: domainName + '/api-user/users/getAll?access_token=' + accessToken,
  241 + sync: false,
  242 + success: function (res) {
  243 + opsSelect = xmSelect.render({
  244 + el: '#opsProject-username-select',
  245 + prop: {
  246 + name: 'nickname',
  247 + value: 'username'
  248 + },
  249 + data: res,
  250 + })
  251 + }
  252 + })
  253 + }
  254 +
  255 + //添加表单验证方法
  256 + form.verify({
  257 + sort: function (t) {
  258 + if (t.length >= 7) {
  259 + return '排序必须小于100万';
  260 + }
  261 + }
  262 + });
  263 +
  264 + });
  265 +});
  1 +layui.define(['table', 'form', 'laydate', 'admin', 'layer', 'laytpl', 'common', 'sessions',"commonDetail",'soulTable'], function (exports) {
  2 + var $ = layui.$;
  3 + var form = layui.form;
  4 + var layer = layui.layer;
  5 + var admin = layui.admin;
  6 + var table = layui.table;
  7 + var laydate = layui.laydate;
  8 + var laytpl = layui.laytpl;
  9 + var common = layui.common;
  10 + var commonDetail = layui.commonDetail;
  11 + var domainName = common.domainName;
  12 + var soulTable = layui.soulTable;
  13 + //对外暴露的接口
  14 + exports('historywarning', function () {
  15 + var sessions = layui.sessions;
  16 + var router = layui.router();
  17 + var accessToken = sessions.getToken()['access_token'];
  18 + var sortKey = '';
  19 + var checkList = common.checkPermission(accessToken);
  20 + var alarmNo = router.search.alarmNo;//告警编号
  21 + var bizId='';//业务Id
  22 + var busIdSelect;
  23 + var busTypeList = [];
  24 +
  25 + if (alarmNo) {
  26 + $("#historywarningkw").val(alarmNo);
  27 + }
  28 +
  29 + function initDate() {
  30 + let startMin = {};
  31 + let endMax = {};
  32 + var start = laydate.render({
  33 + elem: '#historywarningStartdate'
  34 + , trigger: 'click'
  35 + ,ready: function(date){
  36 + startMin=start.config.min;
  37 + }
  38 + , done: function (value, date) {
  39 + date.month--;
  40 + end.config.min = date;
  41 + if(value === ''){//点击清空
  42 + end.config.min = startMin;
  43 + }
  44 + form.render();
  45 + reloadTable();
  46 + }
  47 + });
  48 +
  49 + var end = laydate.render({
  50 + elem: '#historywarningEnddate'
  51 + , trigger: 'click'
  52 + ,ready: function(date){
  53 + endMax=end.config.max;
  54 + }
  55 + , done: function (value, date) {
  56 + date.month--;
  57 + start.config.max = date;
  58 + if(value === ''){//点击清空
  59 + start.config.max = endMax;
  60 + }
  61 + form.render();
  62 + reloadTable();
  63 + }
  64 + });
  65 +
  66 + //绑定业务下拉选择数据
  67 + admin.req({
  68 + url: domainName + '/api-web/home/business/findUserBusTypeAll?table=b_alarm_his',
  69 + success: function (response) {
  70 + if (response && response.success) {
  71 + busTypeList = response.data;
  72 + var bizList = response.data.map(item => {
  73 + return {
  74 + name: item.busTypeName,
  75 + value: item.busId,
  76 + parentId: item.parentId
  77 + }
  78 + });
  79 + var bizTree=common.pidToChildren(bizList, 'value', 'parentId');
  80 + // 影响业务下拉框
  81 + busIdSelect = xmSelect.render({
  82 + el: '#historyBisTypeSearchBox',
  83 + name: 'bizId',
  84 + tips: '=所属业务=',
  85 + //开启搜索
  86 + filterable: true,
  87 + clickClose: true,
  88 + initValue: [bizId.split(',')[0]],
  89 + toolbar: {
  90 + show: true,
  91 + list: ['ALL', 'REVERSE', 'CLEAR']
  92 + },
  93 + height: '170px',
  94 + tree: {
  95 + show: true,
  96 + showFolderIcon: true,
  97 + showLine: true,
  98 + strict: true,
  99 + //间距
  100 + indent: 20,
  101 + },
  102 + model: {
  103 + label: {
  104 + type: 'text'
  105 + }
  106 + },
  107 + data: bizTree,
  108 + on: function (data) {
  109 + if (data.arr.length != 0) {
  110 + var str='';
  111 + $.each(data.arr,function (i,v) {
  112 + str+=v.value+',';
  113 + })
  114 + bizId = str.substring(0,str.length-1);
  115 + } else {
  116 + bizId = '';
  117 + }
  118 + form.render();
  119 + reloadTable();
  120 + }
  121 + });
  122 + if(busIdSelect){
  123 + //追加样式
  124 + $('#historyBisTypeSearchBox').find('.xm-body').eq(0).css("width","230px");
  125 + }
  126 + } else {
  127 + layer.msg('获取业务失败', {icon: 2});
  128 + }
  129 + },
  130 + error: function () {
  131 + layer.msg('获取业务失败', {icon: 2});
  132 + }
  133 + });
  134 + $.ajax({
  135 + url: common.domainName + '/api-web/manage/kpi/findKpiInAlarm?access_token='+accessToken+'&tableName=b_alarm_his',
  136 + type: "get",
  137 + success:function (res) {
  138 + var kpis = res.data;
  139 + var html = '<option value="">=指标名称=</option>'
  140 + $.each(kpis,function (i,e) {
  141 + html+='<option value="'+e.kpiId+'">'+e.kpiName+'</option>'
  142 + })
  143 + $("#alarmKpiHisSearchBox").html('');
  144 + $("#alarmKpiHisSearchBox").append(html);
  145 + form.render();
  146 + }
  147 + })
  148 + }
  149 +
  150 +
  151 +
  152 + //回车事件
  153 + $('#historywarningkw, input[name="durationVal"]').keydown(function (e) {
  154 + if (e.keyCode === 13) {
  155 + reloadTable();
  156 + }
  157 + });
  158 +
  159 + //选择框搜索事件
  160 + bindSelectEvent();
  161 +
  162 + initDate();
  163 +
  164 + function initHistoryBtnCLick() {
  165 + //告警恢复
  166 + $("#historyResumeBtn").unbind("click").on("click", function () {
  167 + if ($.inArray('app:alarm:resume', checkList) == -1) {
  168 + layer.msg('暂无权限!', {icon: 7, time: 3000});
  169 + return;
  170 + }
  171 + var ids = [];
  172 + var closeIds = [];
  173 + var data = table.checkStatus('historywarningTable').data;
  174 + var resumeStatus = true;
  175 + if (data.length == 0) {
  176 + layer.msg('请最少选择一项数据', {icon: 7, time: 2000});
  177 + return;
  178 + }
  179 + var msg = "";
  180 + //选中的告警ID放到集合中
  181 + $.each(data, function (i, obj) {
  182 + ids.push(obj.id);
  183 + closeIds.push(obj.closeId);
  184 + });
  185 + if (!resumeStatus) {
  186 + layer.msg(msg, {icon: 7, time: 3000});
  187 + return;
  188 + }
  189 + layer.prompt({title: '恢复说明(必填)', formType: 2}, function (text, index) {
  190 + admin.req({
  191 + url: common.domainName + '/api-web/home/alarm/resume'
  192 + , type: "post"
  193 + , data: {
  194 + ids: ids.toString(),
  195 + reason: text,
  196 + closeId: closeIds.toString(),
  197 + resumeType: '1',//0告警关闭,1历史告警
  198 + access_token: accessToken
  199 + }
  200 + , done: function (res) {
  201 + //如果消除成功,关闭弹出框然后重新加载页面
  202 + if (res.success) {
  203 + layer.close(index);
  204 + layer.msg('告警已恢复!', {icon: 1, time: 3000}, function () {
  205 + reloadTable();
  206 + });
  207 + } else {
  208 + layer.msg('告警恢复失败,请与管理员联系!', {icon: 7, time: 3000});
  209 + }
  210 + }
  211 + });
  212 + })
  213 + });
  214 + }
  215 +
  216 + //渲染表格
  217 + var historywarningTable;
  218 + //获取配置的列
  219 + common.getTableCols({
  220 + domId: 'historywarningTable',
  221 + moduleId: 'historywarning',
  222 + resType: ''
  223 + }, function (retCols) {
  224 + var cols;
  225 + if (retCols) {
  226 + cols = retCols;
  227 + } else {
  228 + cols = [
  229 + {type: 'checkbox', fixed: 'left'}
  230 + , {
  231 + field: 'alarmLevel', title: '级别', align: 'center', width: 120, sort: true,
  232 + templet: `<div>
  233 + {{# if (d.alarmLevel == 3) { }}
  234 + <span class="layui-table-warn" style="width: 100%;">严重</span>
  235 + {{# } else if (d.alarmLevel == 2) { }}
  236 + <span class="layui-table-close" style="width: 100%;">重要</span>
  237 + {{# } else if (d.alarmLevel == 1) { }}
  238 + <span class="layui-table-normal" style="width: 100%;">一般</span>
  239 + {{# } }}
  240 + </div>`
  241 + }
  242 + , {
  243 + field: 'alarmNo', title: '告警编号', align: 'center', width: 140, sort: true,
  244 + }
  245 + , {
  246 + field: 'resName', title: '资源名称', width: 230, sort: true,
  247 + templet: '<div><span data-hiswarn-zymc="{{d.id}}" data-resid="{{d.resId}}" data-restype="{{d.resType}}" data-ip="{{d.ip}}" data-resname="{{d.resName}}" class="layui-table-link">{{d.resName}}</span></div>'
  248 + }
  249 + , {
  250 + field: 'kpiName', title: '指标名称', align: 'center', width: 150, sort: true,
  251 + templet: '#historywarngingKpiNameTpl'
  252 + }
  253 + , {field: 'alarmContent', title: '告警内容', align: 'center', width: 500}
  254 + , {
  255 + field: 'alarmResource', title: '告警来源', align: 'center', minWidth: 100, templet: `<div>
  256 + {{# if (d.alarmResource == 1) { }}
  257 + <div>华为告警</div>
  258 + {{# } else { }}
  259 + <div>监控系统</div>
  260 + {{# } }}
  261 + </div>`
  262 + }
  263 + , {field: 'updateTime', title: '告警时间', align: 'center', minWidth: 180, sort: true}
  264 + , {field: 'alarmTime', title: '首次告警时间', align: 'center', minWidth: 180, sort: true}
  265 + , {field: 'durationStr', title: '持续时间', align: 'center', width: 190}
  266 + , {
  267 + title: '操作', align: 'center', minWidth: 100,
  268 + templet: '<div><span history-data-warn-view="{{d.id}}" class="layui-table-link">查看</span> <span history-data-warn-path="{{d.id}}" class="layui-table-link">轨迹</span></div>'
  269 + }
  270 + ];
  271 + }
  272 +
  273 + historywarningTable = table.render({
  274 + elem: '#historywarningTable'
  275 + , url: domainName + '/api-web/home/alarm/alarmListPage'
  276 + , toolbar: '#hisAlarmtoolbar' //开启头部工具栏,并为其绑定左侧模板
  277 + , defaultToolbar: ['filter']
  278 + , where: {
  279 + access_token: accessToken,
  280 + hisFlag: true,
  281 + kpiName: $("#historywarningkw").val(),
  282 + busId: bizId,
  283 + alarmStatus: $("#historyAlarmStatusSearchBox").val(),
  284 + alarmLevel: $("#historyAlarmLevelSearchBox").val(),
  285 + confirmStatus: $("#historyAlarmConfirmSearchBox").val(),
  286 + beginTime: $("#historywarningStartdate").val(),
  287 + endTime: $("#historywarningEnddate").val(),
  288 + durationVal: $('#his_inline-condition-duration input[name="durationVal"]').val(),
  289 + durationUnit: $('#his_inline-condition-duration select[name="durationUnit"]').val(),
  290 + sortKey: sortKey,
  291 + //alarmKpi: $("#alarmKpiHisSearchBox").val(),
  292 + alarmKpi: $("#alarmKpiHisSearchBox").val()!='KPI97B835A4'?$("#alarmKpiHisSearchBox").val():'',
  293 + isBus:$("#alarmKpiHisSearchBox").val()=='KPI97B835A4'?'Y':'',
  294 + }
  295 + , height: 'full-245'
  296 + , cellMinWidth: 80
  297 + , page: {
  298 + layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
  299 + , theme: '#1E9FFF'
  300 + }
  301 + , even: true
  302 + , drag: {toolbar: false}
  303 + , cols: [cols],
  304 + done: function (res, curr, count) {
  305 + soulTable.render(this)
  306 + initHistoryBtnCLick();
  307 + var groupurl = domainName + '/api-web/home/alarm/countAlarmNumByAlarmLevel?access_token=' + accessToken;
  308 + $.ajax({
  309 + url: groupurl,
  310 + type: 'get',
  311 + data: {
  312 + access_token: accessToken,
  313 + hisFlag: true,
  314 + kpiName: $("#historywarningkw").val(),
  315 + busId: bizId,
  316 + alarmStatus: $("#historyAlarmStatusSearchBox").val(),
  317 + alarmLevel: '',
  318 + confirmStatus: $("#historyAlarmConfirmSearchBox").val(),
  319 + beginTime: $("#historywarningStartdate").val(),
  320 + endTime: $("#historywarningEnddate").val(),
  321 + durationVal: $('#his_inline-condition-duration input[name="durationVal"]').val(),
  322 + durationUnit: $('#his_inline-condition-duration select[name="durationUnit"]').val(),
  323 + sortKey: sortKey,
  324 + //alarmKpi: $("#alarmKpiHisSearchBox").val(),
  325 + alarmKpi: $("#alarmKpiHisSearchBox").val()!='KPI97B835A4'?$("#alarmKpiHisSearchBox").val():'',
  326 + isBus:$("#alarmKpiHisSearchBox").val()=='KPI97B835A4'?'Y':'',
  327 + },
  328 + success: function (res) {
  329 + var map = res.map;
  330 + if (!isEmptyObject(map)) {
  331 + layui.use('laytpl', function () {
  332 + var laytpl = layui.laytpl;
  333 + var getTpl = document.getElementById("his-alarm-count-id-tpl").innerHTML;
  334 + laytpl(getTpl).render(map, function (html) {
  335 + $('#his-alarm-count-id').html(html);
  336 + });
  337 + });
  338 + }
  339 + //告警操作日志
  340 + $('[history-data-warn-view]').unbind("click").on('click', function () {
  341 + admin.req({
  342 + url: common.domainName + '/api-web/home/alarm/info'
  343 + , data: {
  344 + alarmId: $(this).attr('history-data-warn-view'),
  345 + access_token: accessToken
  346 + }
  347 + }).done(function (res) {
  348 + laytpl($('#warnViewWinTpl').html()).render(res.obj, function (html) {
  349 + layer.open({
  350 + area: ['80%', '90%'],
  351 + title: ['告警操作信息', 'font-size:18px;'],
  352 + type: 1,
  353 + content: html
  354 + });
  355 + });
  356 + });
  357 + });
  358 + //告警轨迹
  359 + $('[history-data-warn-path]').unbind("click").on('click', function () {
  360 + var id = $(this).attr('history-data-warn-path');
  361 + var view = layui.view;
  362 + var params = {
  363 + "warnId": id
  364 + };
  365 + view('commonViewModel').render("template/detail/warn_gj").then(function (res) {
  366 + layer.open({
  367 + title: ['告警轨迹', 'font-size:18px;'],
  368 + type: 1,
  369 + area: ['80%', '90%'],
  370 + content: laytpl(res.body).render(JSON.stringify(params))
  371 + });
  372 + });
  373 + });
  374 + //资源名称,查看详细
  375 + $('[data-hiswarn-zymc]').unbind("click").on('click', function () {
  376 + var resId = $(this).data("resid");
  377 + var resType = $(this).data("restype");
  378 + var ip = $(this).data("ip") ? $(this).data("ip") : "";
  379 + var resName = $(this).data("resname");
  380 + var pingEnable = $(this).data("pingenable"); //获取pingEnable的值 joke add 20200619
  381 + var resTypeName = '';
  382 + var adminName = '';
  383 + var manageIp = '';
  384 + var collProtocol = '';
  385 + var sign='false';
  386 + $.ajax({
  387 + url: common.domainName + "/api-web/home/resource/findById?resId="+resId + '&access_token='+ accessToken,
  388 + async: false,
  389 + type:'get',
  390 + success: function (res) {
  391 + sign=res.str;
  392 + var data = res.object;
  393 + resType = data.resType;
  394 + adminName = data.adminName;
  395 + manageIp = data.manageIp;
  396 + collProtocol = data.collProtocol;
  397 + resTypeName = data.resTypeName;
  398 + }
  399 + })
  400 + if(sign=='false'){
  401 + layer.msg('当前用户暂无此资源权限!', {icon: 7, time: 3000});
  402 + return false;
  403 + }
  404 + let title = resName;
  405 + if (title && title !== '') {
  406 + title += '|';
  407 + }
  408 + if (resTypeName && resType !== 'HOST_X86SERVER') {
  409 + title += resTypeName + '|';
  410 + }
  411 + if (ip) {
  412 + if (resType === 'HOST_X86SERVER') {
  413 + if (collProtocol && (collProtocol.split(",").length > 1 || collProtocol === 'SSH')) {
  414 + title += '应用IP-' + ip + '|';
  415 + }
  416 + } else {
  417 + title += ip + '|';
  418 + }
  419 + }
  420 + if (resType === 'HOST_X86SERVER' && collProtocol && collProtocol.indexOf('SNMP') !== -1 ) {
  421 + if (manageIp) {
  422 + title += '管理IP-' + manageIp + '|';
  423 + }
  424 + }
  425 + if (adminName) {
  426 + title += adminName + '|';
  427 + }
  428 + if (title.length > 0) {
  429 + title = title.substr(0, title.length - 1);
  430 + }
  431 + if (pingEnable == '2') { //如果pingEnable为2,则进入ping状态详情页面
  432 + commonDetail.openNewWin('template/detail/pingIndex', title, {'resId': resId}, false);
  433 + } else { //否则进入监控详情页面
  434 + commonDetail.openDetail(resId, resType, title);
  435 + }
  436 + });
  437 + //指标性能曲线图
  438 + $(' [data-warn-zbmc]').unbind("click").on('click', function () {
  439 + var name = $(this).data("name");
  440 + var params = {
  441 + resId: $(this).data("resid"),
  442 + kpiId: $(this).data("kpi"),
  443 + flag: $(this).data("flag"),
  444 + name: name,
  445 + warning: $(this).data("warning"),
  446 + ident: $(this).data("ident"),
  447 + trend: $(this).data("trend")
  448 + };
  449 + common.openLineChart(name, params);
  450 + });
  451 + //表格排序监听 joke add 20200408
  452 + table.on('sort(historywarningTable)', function (obj) {
  453 + //有些时候,你可能需要根据当前排序的字段,重新向服务端发送请求,从而实现服务端排序,如:
  454 + if (obj.type != null) {
  455 + sortKey = obj.field + ' ' + obj.type;
  456 + } else {
  457 + sortKey = '';
  458 + }
  459 + reloadTable('sort');
  460 + })
  461 + //点击严重重要一般统计告警
  462 + $("#his-alarm-count-id").find(".warn-count-item").unbind("click").on("click", function () {
  463 + var alarmLevel = $(this).attr("alarm-level");
  464 + if (alarmLevel != '' && alarmLevel != null && alarmLevel != undefined) {
  465 + $("#historyAlarmLevelSearchBox").val(alarmLevel)
  466 + layui.form.render('select');
  467 + reloadTable();
  468 + } else {
  469 + $("#historyAlarmLevelSearchBox").val("");
  470 + layui.form.render('select');
  471 + reloadTable();
  472 + }
  473 + });
  474 + //更改告警级别颜色
  475 + setColourLevel();
  476 + }
  477 + });
  478 + //触发拖动列事件,参数为保存按钮的id
  479 + common.dragCols("historywarning_cols_save");
  480 +
  481 + //保存列顺序
  482 + $("#historywarning_cols_save").unbind("click").on("click", function () {
  483 + var params = {
  484 + domId: 'historywarningTable',
  485 + moduleId: 'historywarning',
  486 + resType: '',
  487 + cols: JSON.stringify(historywarningTable.config.cols)
  488 + }
  489 + common.saveTableCols(params,0);
  490 + });
  491 + }
  492 + });
  493 + });
  494 +
  495 + //更改告警级别颜色
  496 + function setColourLevel() {
  497 + //获取告警等级
  498 + let alarmLevel = $("#historyAlarmLevelSearchBox").val();
  499 + $('#his_alarm_serious').css("color","#666");
  500 + $('#his_alarm_important').css("color","#666");
  501 + $('#his_alarm_commonly').css("color","#666");
  502 + switch (alarmLevel) {
  503 + case "3"://严重告警
  504 + $('#his_alarm_serious').css("color","#D81E06");
  505 + break;
  506 + case "2"://重要告警
  507 + $('#his_alarm_important').css("color","#FF7E00");
  508 + break;
  509 + case "1"://一般告警
  510 + $('#his_alarm_commonly').css("color","#1e9fff");
  511 + break;
  512 + default://其他 空或无
  513 + break;
  514 + }
  515 + }
  516 +
  517 + function isEmptyObject(e) {
  518 + var t;
  519 + for (t in e)
  520 + return !1;
  521 + return !0
  522 + }
  523 +
  524 +
  525 + //绑定下拉搜索事件
  526 + function bindSelectEvent() {
  527 + form.on('select(alarmKpiHisSearch)', function (data) {
  528 + reloadTable();
  529 + });
  530 + // 告警状态
  531 + form.on('select(historyAlarmStatusSearch)', function (data) {
  532 + reloadTable();
  533 + });
  534 + //告警级别
  535 + form.on('select(historyAlarmLevelSearch)', function (data) {
  536 + reloadTable();
  537 + });
  538 + // 告警确认
  539 + form.on('select(historyAlarmConfirmSearch)', function (data) {
  540 + reloadTable();
  541 + });
  542 + }
  543 +
  544 + //刷新表格
  545 + function reloadTable(type) {
  546 + if (type != 'sort'){
  547 + sortKey = '';
  548 + }
  549 + historywarningTable.reload({
  550 + page: {
  551 + curr: 1
  552 + }
  553 + ,where: {
  554 + access_token: accessToken,
  555 + kpiName: $("#historywarningkw").val(),
  556 + busId: bizId,
  557 + alarmStatus: $("#historyAlarmStatusSearchBox").val(),
  558 + alarmLevel: $("#historyAlarmLevelSearchBox").val(),
  559 + confirmStatus: $("#historyAlarmConfirmSearchBox").val(),
  560 + beginTime: $("#historywarningStartdate").val(),
  561 + endTime: $("#historywarningEnddate").val(),
  562 + durationVal: $('#his_inline-condition-duration input[name="durationVal"]').val(),
  563 + durationUnit: $('#his_inline-condition-duration select[name="durationUnit"]').val(),
  564 + sortKey: sortKey,
  565 + //alarmKpi: $("#alarmKpiHisSearchBox").val(),
  566 + alarmKpi: $("#alarmKpiHisSearchBox").val()!='KPI97B835A4'?$("#alarmKpiHisSearchBox").val():'',
  567 + isBus:$("#alarmKpiHisSearchBox").val()=='KPI97B835A4'?'Y':'',
  568 + }
  569 + });
  570 + }
  571 +
  572 + /* //获取告警统计信息
  573 + function getAlarmCount() {
  574 + admin.req({
  575 + url: common.domainName + "/api-web/home/alarm/countByAlarmLevel?hisFlag=true"
  576 + , type: "get"
  577 + , done: function (data) {
  578 + var alarms = data.data;
  579 + if (data.code === 0) {
  580 + let total = 0;
  581 + $.each(alarms,function (i,v) {
  582 + if(v.alarmLevel<4){
  583 + total+=v.alarmNum;
  584 + }
  585 + if(v.alarmLevel == 3){//严重告警
  586 + $("#history_alarm_serious").text(v.alarmNum);
  587 + }
  588 + if(v.alarmLevel == 2){//重要告警
  589 + $("#history_alarm_important").text(v.alarmNum);
  590 + }
  591 + if(v.alarmLevel == 1){//一般告警
  592 + $("#history_alarm_commonly").text(v.alarmNum);
  593 + }
  594 + });
  595 + $("#history_alarm_total").text(total);
  596 + } else {
  597 + console.log(data.msg);
  598 + }
  599 + }
  600 + });
  601 + }*/
  602 +
  603 +
  604 + form.render(null, 'historywarning-form');
  605 +
  606 + (function () {
  607 + var autoBtn = $('#historywarningAutoFlush');
  608 + var timer = null;
  609 +
  610 + function autoFlush(target) {
  611 + var el = target.find('span');
  612 + var checked = target.find('input').prop('checked');
  613 + localStorage.setItem('auto__flush', checked);
  614 +
  615 + function fn() {
  616 + var second = el.data('second');
  617 + var checked = target.find('input').prop('checked');
  618 + if (!checked) {
  619 + return;
  620 + }
  621 + --second;
  622 + el.data('second', second);
  623 + el.html(second + '秒');
  624 +
  625 + timer = setTimeout(fn, 1000);
  626 + if (second <= 0) {
  627 + clearTimeout(timer);
  628 + reloadTable()
  629 + $(el).data('second', 60);
  630 + $(el).text("60秒")
  631 + fn();
  632 + //layui.index.render();
  633 + }
  634 + }
  635 +
  636 + if (checked) {
  637 + timer = setTimeout(fn, 1000);
  638 + } else {
  639 + clearTimeout(timer);
  640 + }
  641 + }
  642 +
  643 + /*autoBtn.change(function () {
  644 + autoFlush(autoBtn);
  645 + });*/
  646 + form.on("checkbox(hisWarnActiveAutoFlush)",function (data) {
  647 + autoFlush(autoBtn);
  648 + })
  649 +
  650 + var auto = localStorage.getItem('auto__flush')
  651 + auto = auto ? auto : false;
  652 + autoBtn.find('input').prop('checked', auto);
  653 +
  654 + autoFlush(autoBtn);
  655 +
  656 + admin.on('hash(*)', function (router) {
  657 + if (router.href === '/historywarning') {
  658 + autoFlush(autoBtn);
  659 + } else {
  660 + clearTimeout(timer);
  661 + }
  662 + });
  663 + })();
  664 +
  665 + });
  666 +
  667 +});
  1 +/**
  2 +* @desc 华为云网络设备(防火墙、交换机)
  3 +* @author wangfeng
  4 +* @date 2020/2/4 14:36
  5 +**/
  6 +layui.define(['commonDetail','common'], function (exports) {
  7 + var commonDetail = layui.commonDetail;
  8 + var common = layui.common;
  9 + //对外暴露的接口
  10 + exports('huawei_cloud_nethardware', function (data) {
  11 + var resId = '';
  12 + var resType = '';
  13 + var showFlag = common.getUrlParam("show");
  14 + if(showFlag && showFlag == '0'){
  15 + resId = common.getUrlParam("resId");
  16 + resType = common.getUrlParam("resType");
  17 + }else{
  18 + resId = data.resId;
  19 + resType = data.resType;
  20 + }
  21 + commonDetail.bindTips();
  22 + //基本信息
  23 + //2020-02-07 xwx屏蔽:设备序列号,IPV6地址 与李腾飞确认采集不到,屏蔽
  24 + var jbxxKpi = "KPIE13DD9A3,KPIF74D9D2B,KPIFABFD741,KPIB718ADEC,KPI5858832B,KPI2DC9105C,KPI7E81DFB5,KPI6F17667E, KPIF21A9F60, KPI81BAB2C4, KPI5364695E, KPI14E5F9B4, KPIC70A1E3D";
  25 +
  26 + reload()
  27 +
  28 + //渲染页面
  29 + function reload() {
  30 + //基本信息
  31 + commonDetail.renderTextCols("hauwei_cloude_nethardware_baseinfo",resId,jbxxKpi,2);
  32 + //维保信息 joke add 20200528
  33 + commonDetail.renderMaintenanceInfo('hauwei_cloude_nethardware_wbinfo',resId,resType);
  34 + //CPU平均使用率
  35 + commonDetail.renderGauge("hauwei_cloude_nethardware_cpurate",resId,"KPI961A9688");
  36 + //内存平均使用率
  37 + commonDetail.renderGauge("hauwei_cloude_nethardware_memrate",resId,"KPIE78B29FF");
  38 + // commonDetail.renderCircular("hauwei_cloude_nethardware_memrate",resId,"KPIE78B29FF","内存平均使用率","%");
  39 + //响应时长
  40 + commonDetail.renderLineCharat("hauwei_cloude_nethardware_responestimes",resId,"KPI7480987F","响应时长","");
  41 + //活动告警
  42 + commonDetail.renderActiveAlarms("hauwei_cloude_nethardware_activealarms",resId);
  43 + }
  44 +
  45 + //定时任务
  46 + var timer = setInterval(function () {
  47 + reload()
  48 + },commonDetail.timerTime);
  49 + commonDetail.detailTimer.push(timer);
  50 +
  51 + });
  52 +});