var myChart;var cHeight=50;function initProfile(){$("#submitquery").click(function(e){location.href="#mainblock";if(myChart){myChart.clear()}refreshBoard()});initDevices();refreshBoard();return"作业看板"}function initDevices(){$("#deviceselect").html("");$.ajaxSettings.async=false;$.post("queryReport",{type:"undodevices"},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)})}document.getElementById("deviceselect").options.add(new Option("未排产","未排产"));$("#deviceselect").val("未排产")});$.ajaxSettings.async=true}function refreshBoard(e){var t=$("#deviceselect").val();var o=0;var r={tooltip:{formatter:function(e){return[e.marker+e.value[14]+"："+e.value[9]+""+""+"",e.marker+""+e.value[12]+" :"+e.value[10]+"",e.marker+e.value[15]+"："+e.value[8].slice(0,10)+""].join("<br />")}},title:{text:"",left:"left"},legend:{data:["bar","error"]},dataZoom:[{type:"slider",filterMode:"weakFilter",showDataShadow:false,top:0,height:5,borderColor:"transparent",backgroundColor:"#e2e2e2",handleIcon:"M10.7,11.9H9.3c-4.9,0.3-8.8,4.4-8.8,9.4c0,5,3.9,9.1,8.8,9.4h1.3c4.9-0.3,8.8-4.4,8.8-9.4C19.5,16.3,15.6,12.2,10.7,11.9z M13.3,24.4H6.7v-1.2h6.6z M13.3,22H6.7v-1.2h6.6z M13.3,19.6H6.7v-1.2h6.6z",handleSize:20,handleStyle:{shadowBlur:6,shadowOffsetX:1,shadowOffsetY:2,shadowColor:"#aaa"},labelFormatter:""},{type:"inside",filterMode:"weakFilter"}],grid:{},xAxis:{min:o,scale:true,axisLabel:{formatter:function(e){return(Math.max(0,e-o)/24).toFixed(0)+" 天"}}},yAxis:{},series:[{type:"custom",renderItem:renderItem,itemStyle:{normal:{opacity:.8}},encode:{x:[1,2],y:0},label:{normal:{show:true,position:"insideLeft",distance:5,align:"left",verticalAlign:"middle",rotate:0,formatter:function(e){return[""+""+"."+e.name.slice(-4)+"{f2|"+e.value[3]+"}",e.value[12]+"{f3|"+e.value[13]+"}"].join("\n")},borderColor:"rgb(199,86,83)",borderWidth:1,borderRadius:5,padding:2,color:"#000",shadowBlur:2,shadowColor:"#888",shadowOffsetX:0,shadowOffsetY:2,lineHeight:20,fontSize:12,rich:{f1:{color:"white",padding:5},f2:{backgroundColor:"#339911",color:"#fff",borderRadius:15,padding:5},f3:{backgroundColor:"#009999",color:"#fff",borderRadius:15,padding:4}}}},markLine:{silent:true}}]};var i=[];var a=[];var s=[];var n=[];var d={};var l;r.title.text="单元任务分布";$.ajaxSettings.async=false;$.post("queryReport",{type:"workers",device:t},function(e){var t=JSON.parse(e);if(t["msg"]==="ok"){var r=0;t.workers.forEach(function(e){s.push(e.设备);var t={};t.yAxis=r;a.push(t);d[e.设备]={i:r,d:0};r++})}});$.post("queryReport",{type:"undotasks",device:t,limit:e},function(e){var t=JSON.parse(e);if(t["msg"]==="ok"){t.tasks.forEach(function(e){var t={};t.sb=e.设备;t.bh=e.单据编号;t.wg=e.预计完工日期;t.zc=e.最迟交货期;t.xh=e.排产序号;t.gs=e.总工时定额;t.cq=e.是否超期;t.dd=e.销售订单;t.th=e.图号;t.zz="("+e.追踪号+")";t.sl=e.辅助数量;t.mc=e.产品名称;t.dm="销售订单";t.jm="交货期";n.push(t)})}});$.ajaxSettings.async=true;var c;n.forEach(function(e){var t=0;var r=1;var a=1;if(d[e.sb]){t=d[e.sb].i;c=o+d[e.sb].d;l=e.gs*a;d[e.sb].d+=l+r}i.push({name:e.bh,value:[t,c,c+l,e.gs,e.bh,e.sb,e.xh,e.cq,e.zc,e.dd,e.th,e.zz,e.mc,e.sl,e.dm,e.jm],itemStyle:{normal:{color:"#7b9ce1"}}})});var h=(s.length+8)*(cHeight+10);r.grid.height=h-180;r.dataZoom[0].top=h-80;r.yAxis.data=s;r.series[0].data=i;r.series[0].markLine.data=a;var f=document.getElementById("main");f.setAttribute("style","height:"+h+"px;");myChart=echarts.init(f);myChart.setOption(r)}function renderItem(e,t){var r=t.value(0);var a=t.coord([t.value(1),r]);var o=t.coord([t.value(2),r]);o[0]=o[0]-a[0]<1?a[0]+70:o[0];var i=50;i=i>50?50:i;var s=t.value(7)===1?"#bd6d6c":"#fff";return{type:"rect",shape:echarts.graphic.clipRectByRect({x:a[0],y:a[1]-i/2,width:o[0]-a[0],height:i},{x:e.coordSys.x,y:e.coordSys.y,width:e.coordSys.width,height:e.coordSys.height}),style:t.style({fill:s,stroke:"#999",lineWidth:2,shadowBlur:8,shadowOffsetX:3,shadowOffsetY:3,shadowColor:"rgba(0,0,0,0.3)"})}}