function startTime(time) { const nowTimeDate = new Date(time); return nowTimeDate.setHours(0, 0, 0, 0); } function endTime(time) { const nowTimeDate = new Date(time); return nowTimeDate.setHours(23, 59, 59, 999); } function getTodayStartTimeAndEndTime(time) { time = time ? time : new Date(); return { startTime: new Date(time.setHours(0, 0, 0, 0)), endTime: new Date(time.setHours(23, 59, 59, 999)), }; } function getCurrentWeekStartTimeAndEndTime(time) { const current = time ? time : new Date(); // current是本周的第几天 let nowDayOfWeek = current.getDay(); if (nowDayOfWeek === 0) nowDayOfWeek = 7; const dayNum = 1 * 24 * 60 * 60 * 1000; // 获取本周星期一的时间,星期一作为一周的第一天 const firstDate = new Date(current.valueOf() - (nowDayOfWeek - 1) * dayNum); // 获取本周星期天的时间,星期天作为一周的最后一天 const lastDate = new Date(new Date(firstDate).valueOf() + 6 * dayNum); return { startTime: new Date(startTime(firstDate)), endTime: new Date(endTime(lastDate)), }; } function viewModel() { this.ID = ""; this.init = function () { //setInterval(function () { // InitTable(); //}, 1000*60); //更多条件 $("#btn-more").bind("click", function () { var that = this; //多窗口模式,层叠置顶 index = layer.open({ type: 1 , id: "one" , title: '条件' , area: ['800px', '350px'] , shade: 0 , anim: 1 , shadeClose: true , maxmin: true , shade: 0.3 , offset: '50px' , content: $("#inteform") , btn: ['确认', '关闭'] , yes: function () { InitTable(); layer.close(index); } , btn2: function () { layer.close(index); } , zIndex: 1 //重点1 }); }) //渠道 $("#QDID").combobox({ url: '/Problem/GetChannelByAuth', valueField: 'ID', textField: '名称', limitToList: true, onChange: function (value) { $("#XMID").combobox({ url: '/PersonManager/GetProject?id=' + value, valueField: 'ID', textField: '名称', limitToList: true, }) } }) //项目 $("#XMID").combobox({ url: '/Problem/GetProjectByInfo', valueField: 'ID', textField: '名称', limitToList: true, }) //指标类型 $("#ZBLX").combobox({ url: '/ProManager/GetIndicatorInformationType', valueField: 'ID', textField: '显示名', limitToList: true }) //指标状态 $("#ZT").combobox({ url: '/ProManager/GetIndicatorInformationStatu', valueField: 'ID', textField: '显示名', limitToList: true, value:"2" }) $("#SJDXZ").combobox({ data: [{ "ID": 0, "名称": "当天", }, { "ID": 3, "名称": "昨天", }, { "ID": 4, "名称": "近三天", }, { "ID": 1, "名称": "本周", }, { "ID": 2, "名称": "本月", }, { "ID": -1, "名称": "自定义", }], valueField: 'ID', textField: '名称', limitToList: true, value: "0", onChange: function (value, index) { if (value == -1) { //自定义时间 $(".Custom").css("display", ""); } else { //定时 $(".Custom").css("display", "none"); } } }) //刷新 $('#Ref').click(function () { InitTable(); }); InitTable(); } }; function InitTable() { var params = ZLPMS.FormToObject('inteform'); params.CONTENT = $("#userAccount").val(); //时间 let type = $("#SJDXZ").val(); let sTime = ""; let eTime = ""; switch (type) { case "0": { //本日 sTime = new Date().format("yyyy-MM-ddT00:00:00"); eTime = new Date().format("yyyy-MM-ddT23:59:59"); break; } case "1": { //本周 sTime = getCurrentWeekStartTimeAndEndTime().startTime.format("yyyy-MM-ddThh:mm:ss"); eTime = getCurrentWeekStartTimeAndEndTime().endTime.format("yyyy-MM-ddThh:mm:ss"); break; } case "2": { //本月 sTime = new Date().format("yyyy-MM-01T00:00:00"); eTime = new Date().format("yyyy-MM-ddThh:mm:ss"); break; } case "3": { //昨天 var day1 = new Date(); day1.setTime(day1.getTime() - 24 * 60 * 60 * 1000); sTime = new Date(day1).format("yyyy-MM-ddT00:00:00"); eTime = new Date(day1).format("yyyy-MM-ddT23:59:59"); break; } case "4": { //近三天 var day1 = new Date(); day1.setTime(day1.getTime() - 24 * 60 * 60 * 1000 * 3); sTime = new Date(day1).format("yyyy-MM-ddT00:00:00"); eTime = new Date().format("yyyy-MM-ddThh:mm:ss"); break; } case "-1": { //自定义 sTime = $("#KSSJ").val(); eTime = $("#JSSJ").val(); break; } } params.KSSJ = sTime; params.JSSJ = eTime; //初始化树形表格 $("#treegrid").datagrid({ url: '/CloudMonitor/GetPushIndexData', idField: 'ID', queryParams: params, method: 'POST', fit: true, pageSize: 20, toolbar: '#Channeltb', rownumbers: true, //底部显示分页工具栏 pagination: true, collapsible: true, //列名称 columns: [[ { field: '渠道名称', title: '渠道', width: 180 }, { field: '项目名称', title: '项目', width: 180, align: 'center' }, { field: '服务器IP', title: '服务器IP', width: 120 }, { field: '类型显示', title: '指标类型', width: 120 }, { field: '创建时间', title: '上传时间', width: 150, formatter: ZLPMS.formatterData }, { field: '预警ID', title: '是否预警', width: 100, align: 'center', formatter: function (value, rowData, index) { if (value) { return "报警" } } }, { field: '状态', title: '状态', width: 100, align: 'center', formatter: function (value, rowData, index) { switch (value) { case 1: { return '正常'; } default: { return '异常'; } } } } ]], singleSelect: true, onClickRow: function (index, row) { if (row.状态 != 1) { $("#MS").html(row.上报原始数据); } else { try { var json = JSON.parse(row.上报原始数据); $("#MS").html(JSON.stringify(json, null, 4)); } catch (ex) { $("#MS").html(row.上报原始数据); } } } }); } //提交表单信息 var Forms = { Submit: function (index, layero) { var iframeWin = ZLPMS.GetChildFrame(layero);//得到iframe页的窗口对象,执行iframe页的方法: //调用子页面的方法,得到子页面返回的ids var param = iframeWin.Forms.PostData(); }, //读取数据 PostData: function () { //执行提交验证 var r = $("#ff").form('validate'); if (r) { var param = ZLPMS.FormToObject('ff'); return param; } return null; } }; //重新刷新页面 7 var List = { //重新加载页面所有信息 Reload: function () { InitTable(); } }; //回车提交查询 function Enter_Submit() { InitTable(); }