$(document).ready(function () { //iniChart('rptweld'); //iniChart('rptweld1'); //iniChart('rptweld2'); //QueryData().then(data => console.log(data)); //console.log(QueryData("M02","M15")); console.log('aa'); $(window).bind("load resize", HandleBoxHeight); SetBoxHeight(); setInterval(function () { QueryDataAsync($('#cbxWorkshop').val(), $('#cbxLine').val()); }, 1800000); //时间卡关 //addHints(); startIntro(); showsidebar(); }); document.onreadystatechange = subSomething;//当页面加载状态改变的时候执行这个方法. function subSomething() { if (document.readyState == 'complete') //当页面加载状态 { setTimeout(function () { //_runResizeHandlers(); SetBoxHeight(); QueryWorkshop() //handleIframeContent(); }, 1000); // wait 50ms until window resize finishes. } } function showsidebar() { $('#rightsidebar').addClass('control-sidebar-open') setTimeout(function () { $('#rightsidebar').removeClass('control-sidebar-open') }, 1000) } function startIntro() { var intro = introJs(); intro.setOptions({ steps: [ { element: document.querySelector('#dashtitle'), intro: "点击选择查询条件", }, //{ // element: document.querySelectorAll('#step2')[0], // intro: "Ok, wasn't that fun?", // position: 'right' //}, //{ // element: '#step3', // intro: 'More features, more fun.', // position: 'left' //}, //{ // element: '#step4', // intro: "Another step.", // position: 'bottom' //}, //{ // element: '#step5', // intro: 'Get it, use it.' //} ], //showButtons: false, showBullets: false, }); intro.start(); setTimeout( function () { intro.exit() }, 3000) //intro.exit() } function addHints() { intro = introJs(); //intro.setOptions({ // hints: [ // { // element: document.querySelector('#dashtitle'), // hint: "点击选择查询条件7", // hintPosition: 'top-middle', // hintButtonLabel:`mklnjk` // } // ] //}) intro.setOptions({ hints: [ { element: '#dashtitle', hint: "点击选择查询条件", }, ] }); intro.setOption("hintButtonLabel", "OK"); //introJs().setOption("hintButtonLabel", "OK") //intro.onhintsadded(function () { // console.log('all hints added'); //}); //intro.onhintclick(function (hintElement, item, stepId) { // console.log('hint clicked', hintElement, item, stepId); //}); //intro.onhintclose(function (stepId) { // console.log('hint closed', stepId); //}); intro.addHints(); } function SetBoxHeight() { var h = window.innerHeight || document.documentElement.clientHeight || document.body.clientHeight; var contentmargin = 30 * 2; var boxmargintop = (3 + 3 + 20) * 3 var height = (h - contentmargin - boxmargintop) / 3; //var aaa = window["innerHeight"]; $('.rpt').css("height", height + "px"); } function HandleBoxHeight() { var resize1; $(window).resize(function () { if (resize1) { clearTimeout(resize1); } resize1 = setTimeout(function () { //_runResizeHandlers(); SetBoxHeight(); //handleIframeContent(); }, 100); // wait 50ms until window resize finishes. }); } function handleary(getdata) { var chartary = []; var completionary = ["00", "02", "04", "06", "08", "10", "12", "14", "16", "18", "20", "22"]; _.each(completionary, function (ele, index, ary) { var findres = _.find(getdata, function (item, index, obj) { var timet; if (item.times.toString().length == 1) { timet = '0' + item.times; } else { timet = item.times; } return timet == ele; }); if (findres == undefined) { chartary.push(0) } else { chartary.push(findres.qty) } }) return chartary; } async function QueryWorkshop() { let workshop = await FetchApi("QueryWorkshop", {}) workshop = await workshop.json(); $('#cbxWorkshop').empty() _.each(workshop.info, function (ele, index, list) { $('#cbxWorkshop').append("") }) console.log(workshop) console.log('query workshop end') var title = /\d*$/.exec($('#cbxWorkshop').val())[0] title = title.replace(/\b0*/, '') $('#wotitle').text(title) QueryLine($('#cbxWorkshop').val()) //await QueryDataAsync($('#cbxWorkshop').val()) } //车间下拉选项事件 $('#cbxWorkshop').on('change', function () { console.log('车间选项变成:' + $('#cbxWorkshop').val()) QueryLine($('#cbxWorkshop').val()) //QueryDataAsync($('#cbxWorkshop').val()); var title = /\d*$/.exec($('#cbxWorkshop').val())[0] title = title.replace(/\b0*/, '') $('#wotitle').text(title); }) //线别下拉选项事件 $('#cbxLine').on('change', function () { console.log('车间选项变成:' + $('#cbxLine').val()) //QueryLine($('#cbxLine').val()) //QueryDataAsync($('#cbxWorkshop').val()); var title = /\d*$/.exec($('#cbxLine').val())[0] title = title.replace(/\b0*/, '') $('#woline').text(title); QueryDataAsync($('#cbxWorkshop').val(), $('#cbxLine').val()); }) async function QueryLine(workshop) { let AreaLine = await FetchApi("SearchLine", {workshop:workshop}) AreaLine = await AreaLine.json(); $('#cbxLine').empty(); _.each(AreaLine, function (ele, index, list) { $('#cbxLine').append("") }) console.log(workshop) console.log('query Line end') var title = /\d*$/.exec($('#cbxLine').val())[0] title = title.replace(/\b0*/, '') $('#woline').text(title); await QueryDataAsync($('#cbxWorkshop').val(), $('#cbxLine').val()); } async function QueryDataAsync(paraworkshop, arealine) { var stand = []; fetch("/api/SiteCapacityStand/SiteCapacityStand", { method: "post", headers: { "Accept": "application/json, text/plain, */*", "Content-Type": "application/json" }, body: JSON.stringify({ workshop: paraworkshop, line: arealine}) }).then( (res) => { return res.json() } ).then( (res) => { console.log(res); stand = res.result; trycatch(stand[0]); //setInterval(function () { trycatch(stand[0]) },60000); } ).catch( (ex) => { config.fail(ex) } ) //var stand = { weld: 100, laminate: 100, lamination: 100, laminatedInspection: 100, frame: 100, rinse: 100, eltest: 100, ivtest: 100, complete: 100 }; //trycatch(stand) async function trycatch(stand) { console.log(stand); try { let dddd = await FetchApi("TwohoursLine", { workshop: paraworkshop, line: arealine }); dddd = await dddd.json(); console.log(dddd); _.each(dddd, function (ele, index, ary) { if (ele.station == "weld") { let weld = handleary(ele.res) iniChart('rptweld', '焊接', weld,stand.weld) } if (ele.station == "lamination") { let lamination = handleary(ele.res) iniChart('rptlamination', '叠层', lamination, stand.laminate); } if (ele.station == "layup") { let layup = handleary(ele.res) iniChart('rptlayup', '层压', layup, stand.lamination); } if (ele.station == "inspectionafterlayup") { let inspectionafterlayup = handleary(ele.res) iniChart('rptinspectionafterlayup', '层压后检验', inspectionafterlayup, stand.laminatedInspection); } if (ele.station == "frame") { let frame = handleary(ele.res) iniChart('rptframe', '装框', frame,stand.frame); } if (ele.station == "clean") { let clean = handleary(ele.res) iniChart('rptclean', '清洗', clean,stand.rinse); } if (ele.station == "IV") { let iv = handleary(ele.res) iniChart('rptiv', 'IV测试', iv,stand.ivtest); } if (ele.station == "EL") { let el = handleary(ele.res) iniChart('rptel', 'EL测试', el,stand.eltest); } if (ele.station == "fullinspection") { let el = handleary(ele.res) iniChart('rptfullinspection', '全检', el, stand.complete); } }) } catch (err) { console.log(err); } } } function FetchApi(funname, para) { return fetch("/api/Orders/" + funname + "", { method: "post", headers: { "Accept": "application/json, text/plain, */*", "Content-Type": "application/json" }, body: JSON.stringify(para) }) } function QueryData(workshop, sitename) { let response = fetch("/api/Report/Dashboard/QueryData", { method: "post", headers: { "Accept": "application/json, text/plain, */*", 'Content-Type': 'application/json' }, body: JSON.stringify({ workshop: workshop, sitename: sitename }) }) return response; } var i = 0; function iniChart(eleid, title, data,stand) { var chart = Highcharts.chart(eleid, { chart: { type: 'column' }, credits: { enabled: false }, title: { text: title }, subtitle: { //text: '数据来源: WorldClimate.com' }, xAxis: { categories: //["00:00", "02:00", "04:00", "06:00", "08:00", "10:00", "12:00", "14:00", "16:00", "18:00", "20:00", "22:00"] ["00", "02", "04", "06", "08", "10", "12", "14", "16", "18", "20", "22"] , crosshair: true }, yAxis: { min: 0, //max:Number(stand)+10, title: { text: '组件数量' }, plotLines: [{ //一条延伸到整个绘图区的线,标志着轴中一个特定值。 color: 'red', dashStyle: 'Dash', //Dash,Dot,Solid,默认Solid width: 1.5, value: stand, //x轴显示位置,一个标记为1 zIndex: 5 }], //tickPositions: [0, 50, 100, 150, 200], //stackLabels: { // 堆叠数据标签 // enabled: true, // style: { // fontWeight: 'bold', // color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray' // } //} }, tooltip: { // head + 每个 point + footer 拼接成完整的 table headerFormat: '{point.key}
{series.name}: | ' + '{point.y:.1f} mm |