$(function () { initICSTime(); initICSDialog(); initICSCombobox(); initICSTable(); initICSClick(); }); function initICSTime() { var date = new Date(); var year = date.getFullYear(); var month = date.getMonth() + 1; var day = date.getDate(); var dateBeginStr = year + '-' + (month >= 10 ? '' : '0') + month + '-' + (day >= 10 ? '' : '0') + day; var dateEndStr = year + '-' + (month >= 10 ? '' : '0') + month + '-' + (day >= 10 ? '' : '0') + day; $('#searchICStimeBegin').val(dateBeginStr); $('#searchICStimeEnd').val(dateEndStr); } function initICSCombobox() { var $option = $(''); var $inspectOrgId = $('#searchICSInspectOrgId'); var $inspectObjectType = $('#searchICSInspectObjectType'); var $inspectType = $('#searchICSInspectType'); $inspectOrgId.empty(); $inspectObjectType.empty(); $inspectType.empty(); var data = ajaxSame('../../GlobalM/Org/GetDropDownListOrg', null, 'post', 'json'); if (typeof (data) == 'string') data = $.parseJSON(data); for (var i in data) { if (data[i].Id == -1) { $option = $(''); } else { $option = $(''); } $inspectOrgId.append($option); } var data = ajaxSame('../../GlobalM/Statement/GetInspectObjectType', null, 'post', 'json'); for (var i in data) { if (data[i].Id == -1) { $option = $(''); } else { $option = $(''); } $inspectObjectType.append($option); } var data = ajaxSame('../../GlobalM/Statement/GetInspectType', null, 'post', 'json'); for (var i in data) { if (data[i].Id == -1) { $option = $(''); } else { $option = $(''); } $inspectType.append($option); } } function initICSTable() { var param = getICSSearchParam(); console.info(param); $('#tabICSTable').datagrid({ singleSelect: false, url: '../../GlobalM/Statement/GetICS', singleSelect: true, queryParams: param, idField: 'Attention', animate: true, pagination: true, rownumbers: true, pagePosition: 'bottom', pageSize: 100, pageNumber: 1, fitColumns: true, pageList: [100, 200, 300, 500, 1000], //toolbar: '#tabICSSearch', //数据格式 columns: [[ { title: '时间区间', width: 160, field: 'Attention', }, { title: '点检类别Id', field: 'InspectTypeId', hidden: true, }, { title: '点检类别', width: 80, field: 'InspectTypeName', }, { title: '设备类别Id', field: 'InspectObjectTypeId', hidden: true, }, { title: '设备类别', width: 80, field: 'InspectObjectTypeName', }, { title: '应点检', width: 80, field: 'PlanNeed', }, { title: '未点检', width: 80, field: 'LastCheck', }, { title: '已点检', width: 80, field: 'HasCheck', }, { title: '点检OK', width: 80, field: 'CheckedOK', }, { title: '现场维修OK', width: 80, field: 'CanRepair', }, { title: '维修中', width: 80, field: 'InRepair', }, { title: '维修完成', width: 80, field: 'OKRepair', }, ]], loadFilter: function (data) { if (data.Code == 200) { loadECharts(data.Extend); return data; } else { if (data.Message=='') { } else { show(data.Message); } } }, }); } function loadECharts(data) { console.info(data); var series = new Array(); $('#divShowICS').empty(); var $div = $('
'); $('#divShowICS').append($div); for (var i in data.EChartsSeriesArr) { var temp = data.EChartsSeriesArr[i]; var objectTypeName = temp.InspectObjectTypeName; var isShow = true; if (temp.name == "未点检") { isShow = true; } else { isShow = false; } var serie = { name: temp.name, type: temp.type, stack: temp.stack, data: temp.data, label: { normal: { show: isShow, position: "top", textStyle: { color: "black" }, formatter: objectTypeName } }, }; series.push(serie); } var myChart = echarts.init(document.getElementById('divEChartsICS')); var option; option = { tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, legend: { data: data.LegendData }, grid: { left: '0%', right: '0%', bottom: '0%', containLabel: true }, xAxis: [{ type: 'category', data: data.xAxisData }], yAxis: [{ type: 'value' }], series: series }; myChart.setOption(option); } function initICSClick() { //点击查询按钮 $('#btnICSSearch').click(function () { var param = getICSSearchParam(); $('#tabICSTable').datagrid('reload', param); }); //点击未完成详情按钮 $('#btnICSSearchDetail').click(function () { var rows = $('#tabICSTable').datagrid('getSelections'); if (rows.length != 1) { show('请选择任意一行!'); return; } var param = { InspectObjectTypeId: rows[0].InspectObjectTypeId, InspectTypeId: rows[0].InspectTypeId, Attention: rows[0].Attention, }; console.info(param); $('#ICSDialog').dialog({ closed: false, }); $('#tabICSDialogTable').datagrid({ url: '../../GlobalM/Statement/GetNeedCheckDetail', queryParams: param, loadFilter: function (data) { console.info(data); if (data.Code == 200) { return data; } else { show(data.Message); } }, }); }); } function getICSSearchParam() { var timeBegin = $('#searchICStimeBegin').val(); var timeEnd = $('#searchICStimeEnd').val(); var inspectObjectType = $('#searchICSInspectObjectType').val(); var inspectType = $('#searchICSInspectType').val(); var OrgId = $('#searchICSInspectOrgId').val(); var param = { TimeBegin: timeBegin, TimeEnd: timeEnd, InspectObjectTypeId: inspectObjectType, InspectTypeId: inspectType, OrgId: OrgId } return param; } //初始化提示框 function initICSDialog() { $('#ICSDialog').dialog({ closed: true,//默认关闭状态 closable: false,//不提供关闭页面 top: 10, //left: 10, resizable: false,//是否可改变窗口大小 modal: true,//模式化窗口,打开其他地方不可点击 buttons: [{ text: '关闭', iconCls: 'icon-cancel', handler: function () { $('#ICSDialog').dialog({closed: true,}); } }], }); $('#tabICSDialogTable').datagrid({ singleSelect: false, //url: '../../GlobalM/Statement/GetICS', singleSelect: true, //queryParams: param, closable:true, idField: 'InspectObjectId', animate: true, pagination: true, rownumbers: true, pagePosition: 'bottom', pageSize: 10, pageNumber: 1, fitColumns: true, pageList: [5, 10, 20,50,100,200,500,1000], //toolbar: '#tabICSSearch', //数据格式 columns: [[ { title: 'Id', width: 160, field: 'InspectObjectId', hidden: true, }, { title: '组织名称', width: 160, field: 'OrgName', }, { title: '设备类别', width: 80, field: 'InspectObjectTypeName', }, { title: '设备编码', width: 80, field: 'InspectObjectCode', }, { title: '设备名称', width: 80, field: 'InspectObjectName', }, { title: '设备位置', width: 80, field: 'InspectLocation', }, { title: '设备频率', width: 80, field: 'InspectFrequency', }, { title: '设备状态', width: 80, field: 'InspectObjectStatusId', formatter: function (value, row, index) { if (value == '1') { return '使用中' } else if (value == '2') { return '备用中' } else if (value == '3') { return '维修中' } else if (value == '4') { return '闲置中' } else if (value == '5') { return '报废' } } }, ]], }); }