var myChart;function initLines(){$("#submitlines").click(function(t){refreshLines()});myChart=echarts.init(document.getElementById("canvas-holder"));refreshLines();return"业绩图表"}function refreshLines(){var t={};t.svid="v11b67a7d0be41ce";t.ovid="v5bc601c8c1b4c39";$.post("queryReport",{type:"localsalelines",pp:JSON.stringify(t)},function(t){var e=JSON.parse(t);if(e.msg!=="ok"){drawDemoLines()}else{drawLines(e)}})}function drawDemoLines(){var t=dateFtt("yyyy-MM",new Date);var e=[];var a=new Date("2019-08-01");e.push(dateFtt("yyyy-MM",a));while(t!==dateFtt("yyyy-MM",a)){a.setMonth(a.getMonth()+1);e.push(dateFtt("yyyy-MM",a))}var n=[];var r=[];e.forEach(function(t){n.push((Math.random()*1e3).toFixed(2));r.push((Math.random()*1e3).toFixed(2))});e.push(".");var i={title:{text:"业绩(万元)"},tooltip:{trigger:"axis"},legend:{data:["销售","出库"]},grid:{left:"3%",right:"4%",bottom:"3%",containLabel:true},toolbox:{feature:{saveAsImage:{}}},xAxis:{type:"category",boundaryGap:false,data:e},yAxis:{type:"value"},series:[{name:"销售",type:"line",data:n},{name:"出库",type:"line",data:r}]};myChart.setOption(i)}function drawLines(t){var e=(new Date).getFullYear()-1;var n=1e4;var a=dateFtt("yyyy-MM",new Date);var r=[];var i=new Date(e+"-01-01");r.push(dateFtt("yyyy-MM",i));while(a!==dateFtt("yyyy-MM",i)){i.setMonth(i.getMonth()+1);r.push(dateFtt("yyyy-MM",i))}var s=[],o="销售";var y=[],l="出库";r.forEach(function(e){var a=false;t.gains.forEach(function(t){if(t.年月===e){s.push((t.金额/n).toFixed(2));a=true}o=t.title||o});if(!a){s.push(0)}a=false;t.outs.forEach(function(t){if(t.年月===e){y.push((t.金额/n).toFixed(2));a=true}l=t.title||l});if(!a){y.push(0)}});r.push(".");var u={title:{text:"业绩(万元)"},tooltip:{trigger:"axis"},legend:{data:[o,l]},grid:{left:"3%",right:"4%",bottom:"3%",containLabel:true},toolbox:{feature:{saveAsImage:{}}},xAxis:{type:"category",boundaryGap:false,data:r},yAxis:{type:"value"},series:[{name:o,type:"line",data:s},{name:l,type:"line",data:y}]};myChart.setOption(u)}function dateFtt(t,e){var a={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3),S:e.getMilliseconds()};if(/(y+)/.test(t)){t=t.replace(RegExp.$1,(e.getFullYear()+"").substr(4-RegExp.$1.length))}for(var n in a){if(new RegExp("("+n+")").test(t)){t=t.replace(RegExp.$1,RegExp.$1.length===1?a[n]:("00"+a[n]).substr((""+a[n]).length))}}return t}