123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- function viewModel() {
- this.ID = "";
- this.init = function () {
- InitTable();
- }
- };
- function InitTable() {
- var params = {};
- params.WCLZT = "红色,橙色";
- params.ZT = 1;
- //提交表单信息到具体得页面
- var url = '/CloudMonitor/GetServerAlertBySearch';
- $.post(url, params, function (data) {
- const result = separateByWorkHours(data);
- LoadTable($("#treegrid1"), result.workHoursData.sort((a, b) => {
- // 将时间字符串转换为 Date 对象
- const dateA = new Date(a["创建时间"]);
- const dateB = new Date(b["创建时间"]);
- // 进行倒序排序
- return dateB - dateA;
- }));
- LoadTable($("#treegrid2"), result.offWorkHoursData.sort((a, b) => {
- // 将时间字符串转换为 Date 对象
- const dateA = new Date(a["创建时间"]);
- const dateB = new Date(b["创建时间"]);
- // 进行倒序排序
- return dateB - dateA;
- }));
- });
-
-
- }
- function gethours(dateStr) {
- // 以 "HH:MM:SS" 格式处理时间字符串
- const [hours, minutes, seconds] = dateStr.split(':').map(Number);
- return hours;
- }
- function isWithinWorkHours(dateStr, workStartHour, workEndHour) {
- const date = new Date(dateStr);
- const hours = date.getHours();
- // 判断时间是否在工作时间内
- return (hours > workStartHour && hours < workEndHour);
- }
- function separateByWorkHours(data) {
- const workHoursData = [];
- const offWorkHoursData = [];
- try {
- // 定义工作时间的开始和结束时间
- const workStartHour = gethours(window.starTime);
- const workEndHour = gethours(window.endTime);
- data.forEach(item => {
- if (isWithinWorkHours(item["创建时间"], workStartHour, workEndHour)) {
- workHoursData.push(item);
- } else {
- offWorkHoursData.push(item);
- }
- });
- return {
- workHoursData,
- offWorkHoursData
- };
- } catch (e) {
- top.ZLPMS.Msg("当前工作时间定义获取失败");
- return {
- workHoursData:[],
- offWorkHoursData: []
- };
- }
- }
- function LoadTable(ele, data) {
- //初始化树形表格
- ele.datagrid({
- idField: 'ID',
- data: data,
- fit: true,
- pageSize: 0,
- toolbar: window.proId != null ? "" : "#Channeltb",
- rownumbers: true,
- //底部显示分页工具栏
- pagination: false,
- //列名称
- columns: [[
- { field: '项目名称', title: '项目', width: 100 },
- { field: '渠道名称', title: '渠道', width: 100 },
- { field: '预警类型显示', title: '预警类型', width: 120, align: 'center' },
- { field: '异常说明', title: '异常说明', width: 350, align: 'left' },
- {
- field: '创建时间', title: '初次预警时间', width: 150, align: 'center', formatter: ZLPMS.formatterData
- },
- { field: '最后上报时间', title: '最后上报时间', width: 150, align: 'center', formatter: ZLPMS.formatterData },
- {
- field: '预警次数', title: '预警次数', width: 100, align: 'center'
- },
- {
- field: '服务器IP', title: 'IP', width: 100, align: 'center'
- },
- { field: '服务器类型显示', title: '服务器类型', width: 100, align: 'center' },
- { field: '负责人', title: '负责人', width: 100, align: 'center' },
- {
- field: '预警状态显示', title: '状态', width: 100, align: 'center',
- formatter: function (value, rowData, index) {
- let className = "";
- switch (rowData.预警状态显示) {
- case "已处理": {
- className = "Normal";
- break
- }
- case "未处理": {
- className = "Serious";
- break
- }
- default: {
- className = "Warning";
- }
- }
- return `<div class="${className}">${value}</div>`;
- }
- },
- { field: '处理时间', title: '处理时间', width: 150, align: 'center', formatter: ZLPMS.formatterData }
- ]],
- singleSelect: true,
- onClickRow: function (index, row) {
- },
- onSelectAll: function (rows) {
- }
- });
- }
- //提交表单信息
- var Forms = {
- Submit: function (index, layero) {
- var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法:
- //调用子页面的方法,得到子页面返回的ids
- var param = iframeWin.GetData();
- if (!param) return;
- if (param != null) {
- if (param.创建时间 == "") {
- top.ZLPMS.Msg("请填写处理时间");
- return;
- }
- if (param.处理人 == "") {
- top.ZLPMS.Msg("请填写处理人");
- return;
- }
- if (param.处理状态 == "") {
- top.ZLPMS.Msg("请选择处理状态");
- return;
- }
- //提交表单信息到具体得页面
- var url = '/CloudMonitor/InsertServerAlertProcess';
- $.post(url, param, function (data) {
- if (data == "1") {
- top.ZLPMS.CloseWindow(index);
- top.ZLPMS.Msg("保存成功");
- //刷新页面
- List.Reload();
- }
- else {
- ZLPMS.Msg(data.msg, 2);
- }
- });
- }
- }
- };
- //重新刷新页面 7
- var List = {
- //重新加载页面所有信息
- Reload: function () {
- $('#treegrid').datagrid('reload');
- }
- };
- //删除
- var Doajax = function (data) {
- $.ajax({
- url: `/CloudMonitor/DeleteCustomAlertById?id=${data.ID}`,
- method: 'GET',
- success: function (data) {
- if (data == "1") {
- top.ZLPMS.Msg("删除成功");
- //刷新页面
- List.Reload();
- }
- else {
- top.ZLPMS.Msg("删除失败");
- List.Reload();
- }
- }
- });
- }
- //回车提交查询
- function Enter_Submit() {
- InitTable();
- }
|