Files
Web_AUTSDATA_Mvc_Prod/AUTS.Web/Plugin/HIndex.js
2025-11-20 13:11:05 +08:00

475 lines
16 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
var ProductionInterval;
// 显示在线设备
let typeall = 0;
function showservicelist(type) {
$("#ServiceList").show();
switch (type) {
case '1':
if (typeall == 1) {
$('.NoOnline').hide();
typeall = 0;
} else {
$('.NoOnline').hide();
$('.Online').toggle();
}
break;
case '2':
if (typeall == 1) {
$('.Online').hide();
typeall = 0;
} else {
$('.Online').hide();
$('.NoOnline').toggle();
}
break;
default:
if (typeall == 0) {
$('.Online').show();
$('.NoOnline').show();
typeall = 1;
} else {
typeall = 0;
$('.Online').hide();
$('.NoOnline').hide();
}
break;
}
}
/// 首页上次用户选择
let TodayProductions_old_select = null;
$(document).ready(function () {
sessionStorage.setItem("BarCode", "");
sessionStorage.setItem("orderProduct", "");
sessionStorage.setItem("OInteriorID", "");
sessionStorage.setItem("ProjectID", "");
//gotoDetailPartialNew();
if ($(document).width() <= 764) {
$("#orderInfoNum *").css("font-size", "13px");
$("select *").css("font-size", "13px");
$("select").css("padding", "0px");
}
// 订单信息
OInternalInfo();
/// 首页上次用户选择
TodayProductions_old_select = localStorage.getItem("TodayProductions_old_select") || "";
let speedySreach_old_select = localStorage.getItem("speedySreach_old_select") || "";
if (TodayProductions_old_select != "") {
TodayProductions_old_select = JSON.parse(TodayProductions_old_select)
if (speedySreach_old_select == "") {
$("#end").bind().val(TodayProductions_old_select.EndTime);
$("#start").bind().val(TodayProductions_old_select.startTime);
} else {
speedySreach(speedySreach_old_select, false)
}
$("#projectList").val(TodayProductions_old_select.projectID);
$("#projectList").change();
//// 点击样式
//$('#index_speedySreach' + index_speedySreach).trigger("focus");
//// 模拟点击
// $("#end").change();
} else {
todayData();
}
TodayProduction();
ServiceList();
});
//快捷查询
// 0 今天 3 天 7天 30天 全部
function speedySreach(num, ischange = true) {
num = Number(num);
setTimeout(function () {
localStorage.setItem("speedySreach_old_select", num);
}, 200);
$(".index_speedySreach").attr("class", "btn btn-default btn-sm index_speedySreach");
$("#index_speedySreach" + num).attr("class", "btn btn-primary btn-sm index_speedySreach");
if (num == -1) {
$("#start").bind().val("2021/10/1");
$("#end").val(formatDate(new Date(new Date().setDate(new Date().getDate()))));
if (ischange) {
$("#end").change();
}
return;
}
$("#start").val(formatDate(new Date(new Date().setDate(new Date().getDate() - num))));
$("#end").val(formatDate(new Date(new Date().setDate(new Date().getDate()))));
if (ischange) {
$("#end").change();
}
}
function formatDate(time) {
var date = new Date(time);
var year = date.getFullYear(),
month = date.getMonth() + 1,//月份是从0开始的
day = date.getDate(),
hour = date.getHours(),
min = date.getMinutes(),
sec = date.getSeconds();
var newTime = year + '/' +
month + '/'
+ day //+ ' ' +
//hour + ':' +
//min + ':' +
//sec;
return newTime;
}
//指定时间
$("#end").change(function (e) {//右
localStorage.setItem("speedySreach_old_select", "");
TodayProduction();
todayData();
})
$("#start").change(function (e) {//左
localStorage.setItem("speedySreach_old_select", "");
TodayProduction();
todayData();
});
//选择机型
$("#projectList").bind().change(function () {
//OrderList
if (TodayProductions_old_select == null) {
$("#OrderList").val("0");
todayData();
}
GetOrderList();
});
// 获取机型订单
function GetOrderList() {
var projectID = $("#projectList").val();
let resdata = { "projectID": projectID };
$.ajax({
url: "/app/Home/GetOrderList",
// async: true,
type: "post",
data: resdata,
success: function (data) {
$("#OrderList").html(data);
if (TodayProductions_old_select != null) {
$("#OrderList").val(TodayProductions_old_select.OrderInternalID);
TodayProductions_old_select = null;
todayData();
}
}, error: function (xhr, textStatus, errorThrown) {
$.toastr.error('网络异常,请稍后再试。', {
time: 3000,
position: 'top-center'
});
}
});
}
function todayData(back) {
var finishTime = $("#end").bind().val();
var startTime = $("#start").bind().val();
var projectID = $("#projectList").val();
var OrderInternalID = $("#OrderList").val();
var resdata = { "projectID": projectID, "OrderInternalID": OrderInternalID, "startTime": startTime, "EndTime": finishTime };
//$.toastr.info('查询中', {
// time:9999,
// position: 'top-center'
//});
$.ajax({
url: "/app/Home/GetTodayData",
type: "post",
//async: false,
data: resdata,
success: function (data) {
localStorage.setItem("TodayProductions_old_select", JSON.stringify(resdata));
//$(".toastr-info").hide();
if (currentTime - lastTime < diff) {
$.toastr.success('查询成功', {
time: 3000,
position: 'top-center'
});
}
$("#SnInfo").html(data);
if (back != null) {
back();
}
}, error: function (xhr, textStatus, errorThrown) {
//$(".toastr-info").hide();
$.toastr.error('网络异常,请稍后再试。', {
time: 3000,
position: 'top-center'
});
}
});
}
//// 产能显示
function Showtable(e) {
$(e).next().toggle();
}
function TodayProduction() {
return;
var finishTime = $("#end").bind().val();
var startTime = $("#start").bind().val();
$.cookie("startTime", startTime, { expires: 7 });
$.cookie("endTime", finishTime, { expires: 7 });
var projectID = $("#projectList").val();
let resdata = { "projectID": projectID, "startTime": startTime, "EndTime": finishTime };
$.ajax({
url: "/app/Home/TodayProductions",
// async: true,
type: "post",
data: resdata,
success: function (data) {
localStorage.setItem("TodayProductions_old_select", JSON.stringify(resdata));
$("#orderInfo").html(data);
$.toastr.success('查询成功', {
time: 1500,
position: 'top-center'
});
}, error: function (xhr, textStatus, errorThrown) {
$.toastr.error('网络异常,请稍后再试。', {
time: 3000,
position: 'top-center'
});
}
});
}
function OInternalInfo() {
$.ajax({
url: "/app/Home/OInternalInfo",
// async: true,
type: "post",
dataType: "json",
success: function (data) {
//console.log(data);
$("#Confirm").html($("#Confirm").html() + "<strong>" + data.Confirm + "</strong>");
$("#BarCode").html($("#BarCode").html() + "<strong>" + data.BarCode + "</strong>");
$("#Scheduling").html($("#Scheduling").html() + "<strong>" + data.Scheduling + "</strong>");
$("#Yield").html($("#Yield").html() + "<strong>" + data.Yield + "</strong>");
$("#prodCompletion").html($("#prodCompletion").html() + "<strong>" + data.prodCompletion + "</strong>");
$("#Accomplish").html($("#Accomplish").html() + "<strong>" + data.Accomplish + "</strong>");
$(".orderCount").html("(" + data.orderCount + ")");
}
});
}
function getOInternal(status) {
window.location.href = "/App/Order/OrderInternalList?Status=" + status;
}
function gotoDetailPartialNew() {
// Ajax提交数据
$.ajax({
url: "/app/Order/GetOrdersPlannedSpeed",
type: "post",
dataType: "json",
success: function (res) { // 请求成功后的回调函数其中的参数data为controller返回的map,也就是说然后通过data这个参数取JSON数据中的值
if (res.Status == 200) {
$("#ordersPlannedSpeedBox_Content").empty();
if (res.Data) {
//填充数据
var jsonArray = res.Data;
var headArray = [];
//循环取字段名
for (var i in jsonArray[0]) {
headArray[headArray.length] = i;
}
var div = document.getElementById("ordersPlannedSpeedBox_Content");
var table = document.createElement("table");
table.id = "new_table";
table.setAttribute("class", "table table-striped table-bordered table-hover dataTables-example");
var theadH = document.createElement("thead");
var thead = document.createElement("tr");
//表头 从1开始 忽略ID
for (var count = 1; count < headArray.length; count++) {
var td = document.createElement("th");
td.innerHTML = headArray[count];
thead.appendChild(td);
}
theadH.appendChild(thead);
table.appendChild(theadH);
var theadY = document.createElement("tbody");
//表格数据
for (var tableRowNo = 0; tableRowNo < jsonArray.length; tableRowNo++) {
var tr = document.createElement("tr");
tr.setAttribute("onclick", "clickaction(" + jsonArray[tableRowNo]["ID"] + ")")
//从1开始 忽略ID
for (var headCount = 1; headCount < headArray.length; headCount++) {
var cell = document.createElement("td");
cell.innerHTML = jsonArray[tableRowNo][headArray[headCount]];
tr.appendChild(cell);
}
theadY.appendChild(tr);
table.appendChild(theadY);
}
div.appendChild(table);
} else { }
}
},
});
};
function clickaction(id) {
GetOrderInfo(id);
OrdersPlannedSpeedDetails(id);
}
function OrdersPlannedSpeedDetails(id) {
// Ajax提交数据
$.ajax({
url: "/App/Order/GetOrdersPlannedSpeedDetails",
type: "POST",
// async: true,
data: { "id": id },
dataType: "JSON",
success: function (res) { // 请求成功后的回调函数其中的参数data为controller返回的map,也就是说然后通过data这个参数取JSON数据中的值
if (res.Status == 200) {
$("#detailsBox_Content").empty();
if (res.Data) {
//填充数据
var jsonArray = res.Data;
var headArray = [];
//循环取字段名
for (var i in jsonArray[0]) {
headArray[headArray.length] = i;
}
var div = document.getElementById("detailsBox_Content");
var table = document.createElement("table");
table.id = "new_table2";
table.setAttribute("class", "table table-striped table-bordered table-hover dataTables-example");
var theadH = document.createElement("thead");
var thead = document.createElement("tr");
//表头 从1开始 忽略ID
for (var count = 0; count < headArray.length; count++) {
var td = document.createElement("th");
td.innerHTML = headArray[count];
thead.appendChild(td);
}
theadH.appendChild(thead);
table.appendChild(theadH);
var theadY = document.createElement("tbody");
//表格数据
for (var tableRowNo = 0; tableRowNo < jsonArray.length; tableRowNo++) {
var tr = document.createElement("tr");
tr.setAttribute("onclick", "clickaction(" + jsonArray[tableRowNo]["ID"] + ")")
//从1开始 忽略ID
for (var headCount = 0; headCount < headArray.length; headCount++) {
var cell = document.createElement("td");
cell.innerHTML = jsonArray[tableRowNo][headArray[headCount]];
tr.appendChild(cell);
}
theadY.appendChild(tr);
table.appendChild(theadY);
}
div.appendChild(table);
} else { }
}
},
});
}
function GetOrderInfo(id) {
//$("#orderInfo_Box").empty();
$.ajax({
cache: true,
// async: true,
data: { "id": id },
url: "/app/Order/OrdersInfo",
success: function (data) {
$('#orderInfo_Box').html(data);
}
});
}
///获取设备
function ServiceList(back = null) {
$.ajax({
url: "/app/Home/ServiceList",
//async: true,
type: "post",
//dataType: "json",
success: function (data) {
let display = $("#ServiceList").css("display") || null;
let NoOnline = $(".NoOnline").css("display") || null;
let Online = $(".Online").css("display") || null;
$("#ServiceListdata").html(data);
if (display != null) {
$("#ServiceList").css("display", display)
$(".Online").css("display", Online)
$(".NoOnline").css("display", NoOnline)
}
if (back != null) {
back();
}
}
});
}
///15s自動刷新
$(document).on('mouseover', function () {
lastTime = new Date().getTime();
});
let currentTime = new Date().getTime(),
lastTime = new Date().getTime(),
diff = 15000;
let timering = 0;
let timer = setInterval(function () {
if (timering < 0) {
return;
}
currentTime = new Date().getTime();
if (currentTime - lastTime > diff) {
//-- clearInterval(timer);
timering = -3;
ServiceList(function () {
timering++;
if (timering == -1) {
lastTime = new Date().getTime();
timering = 0;
}
});
todayData(function () {
timering++;
if (timering == -1) {
lastTime = new Date().getTime();
timering = 0;
}
});
}
}, 1000);