You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
603 lines
24 KiB
603 lines
24 KiB
|
|
|
|
$(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("<option value='" + ele.area_code + "'>" + ele.descriptions + "</option>")
|
|
})
|
|
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("<option value='" + ele.line_id + "'>" + ele.descriptions + "</option>")
|
|
})
|
|
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: '<span style="font-size:10px">{point.key}</span><table>',
|
|
pointFormat: '<tr><td style="color:{series.color};padding:0">{series.name}: </td>' +
|
|
'<td style="padding:0"><b>{point.y:.1f} mm</b></td></tr>',
|
|
footerFormat: '</table>',
|
|
shared: true,
|
|
useHTML: true,
|
|
enabled: false
|
|
},
|
|
exporting: { enabled: false },
|
|
plotOptions: {
|
|
column: {
|
|
borderWidth: 0,
|
|
dataLabels: {
|
|
enabled: true //设置显示对应y的值
|
|
}
|
|
}
|
|
|
|
},
|
|
series: [{
|
|
|
|
data: data,
|
|
cursor: 'pointer',
|
|
events: {
|
|
click: function (e) {
|
|
var cou = e.point.category;
|
|
console.log(i);
|
|
if (i == 0) {
|
|
let $ul = $("<ul id='BT'></ul>");
|
|
console.log(e.pageX);
|
|
mX = e.pageX;
|
|
mY = e.pageY;
|
|
//distance = calculateDistance($element, mX, mY);
|
|
console.log(mX + "~~" + mY);
|
|
$ul.css({
|
|
'width': "125px",
|
|
'height': "auth",
|
|
'position': "absolute",
|
|
'padding': "0",
|
|
'margin': "0",
|
|
'left': eval(mX -125) + "px",
|
|
'top': eval(mY - 20) + "px",
|
|
'background-color': "#bbdfff",
|
|
'list-style':"none"
|
|
})
|
|
|
|
//$("#" + eleid).parent().append($ul);
|
|
console.log(eleid);
|
|
console.log(e.point);
|
|
console.log(this);
|
|
|
|
//$("#" + eleid).parent().append($("<li style='width:120px;height:50px';>焊接机1-1 : 35 </li>"));
|
|
//$("#" + eleid + " .highcharts-series-group rect").eq(cou / 2).append($("<li style='width:50px;height:50px'></li>"));
|
|
var nat = this.name;
|
|
var bgtm = e.point.category - 2;
|
|
console.log(bgtm);
|
|
if (bgtm.toString().length == 1) {
|
|
bgtm = "0" + bgtm;
|
|
}
|
|
var endtm = e.point.category;
|
|
var date = new Date();
|
|
var year = date.getFullYear();
|
|
var month = date.getMonth()+1;
|
|
var data = date.getDate();
|
|
var bt = year + "-" + month + "-" + data + " " + bgtm + ":00:00";
|
|
var et = year + "-" + month + "-" + data + " " + endtm + ":00:00";
|
|
var workshop = $("#wotitle").text();
|
|
var line = $("#woline").text();
|
|
console.log(e.point.y);
|
|
if (title == '层压后检验') {
|
|
|
|
$ul.css({
|
|
'width': "300px",
|
|
'height': "300px",
|
|
'left': eval(mX + 20) + "px",
|
|
'top': eval(mY - 150) + "px",
|
|
})
|
|
console.log(e.point.y);
|
|
if (e.point.y != 0) {
|
|
$("body").append($ul);
|
|
info();
|
|
async function info() {
|
|
let stationinfos = await FetchApi("Inspection", { bt: bt, et: et, workshop: workshop, line: line })
|
|
console.log(stationinfos);
|
|
station = await stationinfos.json();
|
|
console.log(station.info);
|
|
var Inspection = [];
|
|
for (var i = 0; i < station.info.length; i++) {
|
|
Inspection[i] = [];
|
|
Inspection[i][0] = station.info[i].defect_type_desc;
|
|
Inspection[i][1] = station.info[i].number;
|
|
}
|
|
console.log(Inspection);
|
|
var chart = Highcharts.chart('BT', {
|
|
chart: {
|
|
type: 'pie',
|
|
options3d: {
|
|
enabled: true,
|
|
alpha: 45,
|
|
beta: 0
|
|
}
|
|
},
|
|
title: {
|
|
text: false
|
|
},
|
|
tooltip: {
|
|
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
|
|
},
|
|
exporting: {
|
|
enabled: false
|
|
},
|
|
plotOptions: {
|
|
pie: {
|
|
allowPointSelect: true,
|
|
cursor: 'pointer',
|
|
depth: 35,
|
|
dataLabels: {
|
|
enabled: true,
|
|
format: '{point.name}:{point.y}'
|
|
}
|
|
}
|
|
},
|
|
series: [{
|
|
type: 'pie',
|
|
name: '浏览器占比',
|
|
data: Inspection
|
|
}]
|
|
});
|
|
}
|
|
}
|
|
//title = '层压后检';
|
|
//if (e.point.y != 0) {
|
|
// info();
|
|
// async function info() {
|
|
// let stationinfos = await FetchApi("StationInfos", { station: title, bt: bt, et: et, workshop: workshop, line: line })
|
|
// console.log(stationinfos);
|
|
// station = await stationinfos.json();
|
|
// console.log(station.info);
|
|
// _.each(station.info, function (ele, index, list) {
|
|
|
|
// $ul.append("<li style='border-bottom: 1px solid white'>" + ele.wks_desc + ":" + ele.WksNbr + "</li>")
|
|
// })
|
|
// }
|
|
//}
|
|
|
|
} else if (title == 'IV测试') {
|
|
if (e.point.y != 0) {
|
|
$("body").append($ul);
|
|
info();
|
|
async function info() {
|
|
let stationinfos = await FetchApi("IVtest", { bt: bt, et: et, workshop: workshop, line: line })
|
|
console.log(stationinfos);
|
|
station = await stationinfos.json();
|
|
console.log(station.info);
|
|
_.each(station.info, function (ele, index, list) {
|
|
|
|
$ul.append("<li style='border-bottom: 1px solid white'>" + ele.wks_id + ":" + ele.number + "</li>")
|
|
})
|
|
}
|
|
}
|
|
} else if (title == 'EL测试') {
|
|
$ul.css({
|
|
'width': "300px",
|
|
'height': "300px",
|
|
'left': eval(mX - 310) + "px",
|
|
'top': eval(mY - 150) + "px",
|
|
})
|
|
if (e.point.y != 0) {
|
|
$("body").append($ul);
|
|
info();
|
|
async function info() {
|
|
let stationinfos = await FetchApi("ELtest", { bt: bt, et: et, workshop: workshop, line: line })
|
|
console.log(stationinfos);
|
|
station = await stationinfos.json();
|
|
console.log(station.info);
|
|
var data = [];
|
|
for (var i = 0; i < station.info.length; i++) {
|
|
data[i] = [];
|
|
data[i][0] = station.info[i].el_grade;
|
|
data[i][1] = station.info[i].number;
|
|
}
|
|
console.log(data);
|
|
var chart = Highcharts.chart('BT', {
|
|
chart: {
|
|
type: 'pie',
|
|
options3d: {
|
|
enabled: true,
|
|
alpha: 45,
|
|
beta: 0
|
|
}
|
|
},
|
|
title: {
|
|
text: false
|
|
},
|
|
tooltip: {
|
|
pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
|
|
},
|
|
exporting: {
|
|
enabled: false
|
|
},
|
|
plotOptions: {
|
|
pie: {
|
|
allowPointSelect: true,
|
|
cursor: 'pointer',
|
|
depth: 35,
|
|
dataLabels: {
|
|
enabled: true,
|
|
format: '{point.name}:{point.y}'
|
|
}
|
|
}
|
|
},
|
|
series: [{
|
|
type: 'pie',
|
|
name: '浏览器占比',
|
|
data: data
|
|
}]
|
|
});
|
|
}
|
|
}
|
|
} else {
|
|
if (e.point.y != 0) {
|
|
$("body").append($ul);
|
|
info();
|
|
async function info() {
|
|
let stationinfos = await FetchApi("StationInfos", { station: title, bt: bt, et: et, workshop: workshop, line: line })
|
|
console.log(stationinfos);
|
|
station = await stationinfos.json();
|
|
console.log(station.info);
|
|
_.each(station.info, function (ele, index, list) {
|
|
|
|
$ul.append("<li style='border-bottom: 1px solid white'>" + ele.wks_desc + ":" + ele.WksNbr + "</li>")
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
i++;
|
|
$("#" + eleid + " .highcharts-series-group rect").eq(cou / 2).mouseleave(function () {
|
|
i = 0;
|
|
console.log(i);
|
|
$("body").children('ul').remove();
|
|
});
|
|
}
|
|
}
|
|
}],
|
|
legend: {
|
|
enabled: false
|
|
},
|
|
});
|
|
}
|
|
|