旧版报表、仓库
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.
 
 
 
 
 

330 lines
9.9 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());
}, 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)
await QueryDataAsync($('#cbxWorkshop').val())
}
//车间下拉选项事件
$('#cbxWorkshop').on('change', function () {
console.log('车间选项变成:' + $('#cbxWorkshop').val())
QueryDataAsync($('#cbxWorkshop').val());
var title = /\d*$/.exec($('#cbxWorkshop').val())[0]
title = title.replace(/\b0*/, '')
$('#wotitle').text(title)
})
async function QueryDataAsync(paraworkshop) {
try {
let dddd = await FetchApi("Twohours", { workshop: paraworkshop });
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)
}
if (ele.station == "lamination") {
let lamination = handleary(ele.res)
iniChart('rptlamination', '叠层', lamination);
}
if (ele.station == "layup") {
let layup = handleary(ele.res)
iniChart('rptlayup', '层压', layup);
}
if (ele.station == "inspectionafterlayup") {
let inspectionafterlayup = handleary(ele.res)
iniChart('rptinspectionafterlayup', '层压后检验', inspectionafterlayup);
}
if (ele.station == "frame") {
let frame = handleary(ele.res)
iniChart('rptframe', '装框', frame);
}
if (ele.station == "clean") {
let clean = handleary(ele.res)
iniChart('rptclean', '清洗', clean);
}
if (ele.station == "IV") {
let iv = handleary(ele.res)
iniChart('rptiv', 'IV测试', iv);
}
if (ele.station == "EL") {
let el = handleary(ele.res)
iniChart('rptel', 'EL测试', el);
}
if (ele.station == "fullinspection") {
let el = handleary(ele.res)
iniChart('rptfullinspection', '全检', el);
}
})
}
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;
}
function iniChart(eleid, title, data) {
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"]
,
crosshair: true
},
yAxis: {
min: 0,
title: {
text: '组件数量'
},
//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
},
exporting: { enabled: false },
plotOptions: {
column: {
borderWidth: 0,
dataLabels: {
enabled: true //设置显示对应y的值
}
},
},
series: [{
data: data,
cursor: 'pointer',
events: {
click: function (e) {
console.log(e.point);
var cou = e.point.category;
var nat = this.name;
var bgtm =
alert('');
funGroupColumn(cou, nat, bgtm, endtm); //单击事件触发的方法
}
}
}],
legend: {
enabled: false
},
});
}
function funGroupColumn(cou, nat, bgtm, endtm) {
var str = "你的查询Action方法";
winopen(str, "****", 600, 600);//内部封装弹窗方法,具体按照你的框架来定
}