var myChart;var cHeight=20;var defdate="2018-12-01";function initProfile(){$("#submitquery").click(function(e){location.href="#mainblock";myChart.clear();refreshBoard()});initDevices();$("#datetimepicker").datetimepicker({minView:2,pickerPosition:"top-right",format:"yyyy-mm-dd",todayHighlight:true,autoclose:true,todayBtn:true,language:"zh-CN"});$("#datetimepicker").val(defdate);refreshBoard();return"开工率"}function initDevices(){$("#deviceselect").html("");$.post("queryReport",{type:"devices"},function(e){var t=JSON.parse(e);if(t["msg"]==="ok"){document.getElementById("deviceselect").options.add(new Option("",""));t.devices.forEach(function(e){var t=new Option(e.设备,e.设备);document.getElementById("deviceselect").options.add(t)})}})}function refreshBoard(){var e=$("#deviceselect").val();var t=$("#datetimepicker").val();var i=[];var a=[];$.ajaxSettings.async=false;$.post("queryReport",{type:"workrate",device:e,startdate:t},function(e){var t=JSON.parse(e);if(t["msg"]==="ok"){t.costs.forEach(function(e){i.push(e.设备);a.push(e.完成工时.toFixed(0))})}});$.ajaxSettings.async=true;var r=(i.length+1)*(cHeight+10);var o={title:{text:"设备开工率",subtext:"-开始于"+t},tooltip:{trigger:"axis",axisPointer:{type:"shadow"}},legend:{data:["完成工时"]},grid:{left:"3%",right:"4%",bottom:"3%",containLabel:true},xAxis:{type:"value",boundaryGap:[0,.01]},yAxis:{type:"category",data:i},series:[{name:"完成工时",type:"bar",label:{normal:{show:true,position:"right"}},data:a}]};document.getElementById("main").setAttribute("style","height:"+r+"px;");myChart=echarts.init(document.getElementById("main"));myChart.setOption(o)}