EarlyWarningManagementIndex.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. function viewModel() {
  2. this.ID = "";
  3. this.init = function () {
  4. //预警处理
  5. $('#Handle').click(function () {
  6. var row = $('#treegrid').datagrid('getSelected');
  7. if (row != null) {
  8. if (row.预警状态显示 === "已处理") {
  9. top.ZLPMS.Msg("当前预警已经处理完成", 0);
  10. return;
  11. }
  12. top.ZLPMS.OpenWindowSuccess({
  13. title: '预警处理',
  14. url: '/CloudMonitor/WarningProcessing',
  15. area: ['1000px', '570px'],
  16. success: function (layero) {
  17. var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法:
  18. iframeWin.InitPage(row);
  19. },
  20. yes: function (index, layero) {
  21. //提交表单
  22. Forms.Submit(index, layero);
  23. }
  24. });
  25. }
  26. else {
  27. top.ZLPMS.Msg("请选择一行记录后执行操作", 0);
  28. }
  29. });
  30. //批量预警处理
  31. $('#HandleAll').click(function () {
  32. top.ZLPMS.OpenWindowSuccess({
  33. title: '批量处理',
  34. url: '/CloudMonitor/BatchWarningProcessing?ProId=' + (window.proId||""),
  35. area: ['1000px', '570px'],
  36. success: function (layero) {
  37. var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法:
  38. iframeWin.InitPage();
  39. },
  40. yes: function (index, layero) {
  41. //提交表单
  42. Forms.Submit(index, layero);
  43. }
  44. });
  45. });
  46. /**查看服务器 */
  47. $('#ViewServer').click(function () {
  48. var row = $('#treegrid').datagrid('getSelected');
  49. if (row != null) {
  50. if (row.服务器ID == null) {
  51. return;
  52. }
  53. top.ZLPMS.OpenWindowSuccess({
  54. title: '预警处理',
  55. url: '/CloudMonitor/ServerInfo?serverId='+row.服务器ID,
  56. area: ['1500px', '650px'],
  57. success: function (layero) {
  58. },
  59. yes: function (index, layero) {
  60. }
  61. });
  62. }
  63. else {
  64. top.ZLPMS.Msg("请选择一行记录后执行操作", 0);
  65. }
  66. });
  67. //更多条件
  68. $("#btn-more").bind("click", function () {
  69. var that = this;
  70. //多窗口模式,层叠置顶
  71. index = layer.open({
  72. type: 1
  73. , id: "one"
  74. , title: '条件'
  75. , area: ['800px', '250px']
  76. , shade: 0
  77. , anim: 1
  78. , shadeClose: true
  79. , maxmin: true
  80. , shade: 0.3
  81. , offset: '50px'
  82. , content: $("#inteform")
  83. , btn: ['确认', '关闭']
  84. , yes: function () {
  85. InitTable();
  86. layer.close(index);
  87. }
  88. , btn2: function () {
  89. layer.close(index);
  90. }
  91. , zIndex: 1 //重点1
  92. });
  93. })
  94. //未及时处理预警
  95. $("#notTimely").bind("click", function () {
  96. top.ZLPMS.OpenWindowSuccess({
  97. title: '未及时处理预警查看',
  98. url: '/CloudMonitor/UnprocessedEarlyWarningManagementIndex',
  99. area: ['90vw', '90vh'],
  100. success: function (layero) {
  101. var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法:
  102. },
  103. yes: function (index, layero) {
  104. }
  105. });
  106. })
  107. //渠道
  108. $("#QDID").combobox({
  109. url: '/Problem/GetChannelByAuth',
  110. valueField: 'ID',
  111. textField: '名称',
  112. limitToList: true,
  113. onChange: function (value) {
  114. $("#XMID").combobox({
  115. url: '/PersonManager/GetProject?id=' + value,
  116. valueField: 'ID',
  117. textField: '名称',
  118. limitToList: true,
  119. })
  120. }
  121. })
  122. //项目
  123. $("#XMID").combobox({
  124. url: '/Problem/GetProjectByInfo',
  125. valueField: 'ID',
  126. textField: '名称',
  127. limitToList: true,
  128. })
  129. //预警类型
  130. $("#YJLXID").combobox({
  131. url: '/ProManager/GetEarlyWarningType',
  132. valueField: 'ID',
  133. textField: '显示名',
  134. limitToList: true
  135. })
  136. //状态
  137. $("#ZT").combobox({
  138. url: '/ProManager/GetWarningProcessingStatu',
  139. valueField: 'ID',
  140. textField: '显示名',
  141. limitToList: true,
  142. value:1
  143. })
  144. //处理详情点击
  145. $("#timeline").on("click", ".timelineDetail", function () {
  146. let Id = $(this).attr("data-Id");
  147. var row = $('#treegrid').datagrid('getSelected');
  148. let timelineRow = timeline.find(o => o.ID == Id);
  149. top.ZLPMS.OpenWindowSuccess({
  150. title: '预警处理情况',
  151. url: '/CloudMonitor/WarningProcessing',
  152. area: ['1000px', '570px'],
  153. success: function (layero) {
  154. var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法:
  155. iframeWin.InitPage(row, timelineRow);
  156. },
  157. yes: function (index, layero) {
  158. top.ZLPMS.CloseWindow(index);
  159. }
  160. });
  161. })
  162. InitTable();
  163. }
  164. };
  165. let timeline = [];
  166. function InitTable(notTimely = false) {
  167. var params = ZLPMS.FormToObject('inteform');
  168. if (notTimely) {
  169. params.WCLZT = "红色,橙色";
  170. }
  171. if (window.proId != null && window.proId != 'null') {
  172. params.XMID = window.proId;
  173. //处理界面显示
  174. $("#userAccount").remove();
  175. $("#btn-more").css("display", "none");
  176. $("#notTimely").css("display", "none");
  177. } else {
  178. params.CONTENT = $("#userAccount").val();
  179. }
  180. //初始化树形表格
  181. $("#treegrid").datagrid({
  182. url: '/CloudMonitor/GetServerAlertBySearch',
  183. idField: 'ID',
  184. queryParams: params,
  185. //data: data,
  186. method: 'POST',
  187. fit: true,
  188. pageSize: 0,
  189. toolbar: window.proId != null ? "" : "#Channeltb",
  190. rownumbers: true,
  191. //底部显示分页工具栏
  192. pagination: false,
  193. //列名称
  194. columns: [[
  195. { field: '项目名称', title: '项目', width: 100 },
  196. { field: '渠道名称', title: '渠道', width: 100 },
  197. { field: '预警类型显示', title: '预警类型', width: 120, align: 'center' },
  198. { field: '异常说明', title: '异常说明', width: 350, align: 'left' },
  199. {
  200. field: '创建时间', title: '初次预警时间', width: 150, align: 'center', formatter: ZLPMS.formatterData
  201. },
  202. { field: '最后上报时间', title: '最后上报时间', width: 150, align: 'center', formatter: ZLPMS.formatterData },
  203. {
  204. field: '预警次数', title: '预警次数', width: 100, align: 'center'
  205. },
  206. {
  207. field: '服务器IP', title: 'IP', width: 100, align: 'center'
  208. },
  209. { field: '服务器类型显示', title: '服务器类型', width: 100, align: 'center' },
  210. { field: '负责人', title: '负责人', width: 100, align: 'center' },
  211. {
  212. field: '预警等级显示', title: '预警等级', width: 100, align: 'center',
  213. formatter: function (value, rowData, index) {
  214. let className = "";
  215. if (rowData.预警状态显示 == "已处理") {
  216. className = "Normal";
  217. } else {
  218. switch (rowData.预警等级显示) {
  219. case "橙色预警": {
  220. className = "Warning";
  221. break
  222. }
  223. case "红色预警": {
  224. className = "Serious";
  225. break
  226. }
  227. }
  228. }
  229. return `<div class="${className}">${value}</div>`;
  230. }
  231. },
  232. {
  233. field: '预警状态显示', title: '状态', width: 100, align: 'center',
  234. formatter: function (value, rowData, index) {
  235. return `<div class="">${value}</div>`;
  236. } },
  237. { field: '处理时间', title: '处理时间', width: 150, align: 'center', formatter: ZLPMS.formatterData }
  238. ]],
  239. singleSelect: true,
  240. onClickRow: function (index, row) {
  241. if (row.预警状态 !=1)
  242. Loading(row.ID);
  243. },
  244. onSelectAll: function (rows) {
  245. }
  246. });
  247. }
  248. //提交表单信息
  249. var Forms = {
  250. Submit: function (index, layero) {
  251. var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法:
  252. //调用子页面的方法,得到子页面返回的ids
  253. var param = iframeWin.GetData();
  254. if (!param) return;
  255. if (param != null) {
  256. if (param.创建时间 == "") {
  257. top.ZLPMS.Msg("请填写处理时间");
  258. return;
  259. }
  260. if (param.处理人 == "") {
  261. top.ZLPMS.Msg("请填写处理人");
  262. return;
  263. }
  264. if (param.处理状态 == "") {
  265. top.ZLPMS.Msg("请选择处理状态");
  266. return;
  267. }
  268. //提交表单信息到具体得页面
  269. var url = '/CloudMonitor/InsertServerAlertProcess';
  270. $.post(url, param, function (data) {
  271. if (data == "1") {
  272. top.ZLPMS.CloseWindow(index);
  273. top.ZLPMS.Msg("保存成功");
  274. //刷新页面
  275. List.Reload();
  276. }
  277. else {
  278. ZLPMS.Msg(data.msg, 2);
  279. }
  280. });
  281. }
  282. }
  283. };
  284. //重新刷新页面 7
  285. var List = {
  286. //重新加载页面所有信息
  287. Reload: function () {
  288. $('#treegrid').datagrid('reload');
  289. }
  290. };
  291. //删除
  292. var Doajax = function (data) {
  293. $.ajax({
  294. url: `/CloudMonitor/DeleteCustomAlertById?id=${data.ID}`,
  295. method: 'GET',
  296. success: function (data) {
  297. if (data == "1") {
  298. top.ZLPMS.Msg("删除成功");
  299. //刷新页面
  300. List.Reload();
  301. }
  302. else {
  303. top.ZLPMS.Msg("删除失败");
  304. List.Reload();
  305. }
  306. }
  307. });
  308. }
  309. //加载时间轴
  310. function Loading(alertId) {
  311. if (!alertId) {
  312. return;
  313. }
  314. if ($("#processPanel").css("display") !="block")
  315. $(".panel-header").click()
  316. timeline = ZLPMS.GetAPi(`/CloudMonitor/GetServerAlertProcessByAlertId?alertId=${alertId}`);
  317. $("#timeline").html("");
  318. let html = "";
  319. for (var i = 0; i < timeline.length; i++) {
  320. let d = timeline[i];
  321. html += "<li class='layui-timeline-item timelineDetail' data-Id='" + d.ID + "'><i class='layui-icon layui-timeline-axis'>&#xe617;</i><div class='layui-timeline-content layui-text'><h3 class='layui-timeline-title'> <span style='margin-right:15px'>"
  322. + (d.处理人 == null ? "" : d.处理人) + "</span><span style='margin-right:15px;color:#00b8ff'>"
  323. + d.处理状态显示 + "</span><span style='margin-right:15px;color:#a2a2a2'>"
  324. + d.创建时间 + "</span></h3><p style='font-size:15px;width:350px;word-break: break-word;color:#a2a2a2'><br>"
  325. + (d.处理说明 == null ? "" : d.处理说明) + "</p></div></li>";
  326. }
  327. $("#timeline").html(html);
  328. }
  329. //回车提交查询
  330. function Enter_Submit() {
  331. InitTable();
  332. }