123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297 |
- 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();
- }
|