Files
T-DAS/Epost.TestToolsWeb/Views/Home/Index.cshtml

389 lines
13 KiB
Plaintext
Raw Normal View History

2023-01-13 15:30:20 +08:00
@{
ViewBag.Title = "设备控制";
}
<div id="mainRight" class="mainRight">
<div class="tit">设备控制</div>
<div class="main">
<div class="sbControl">
<a href="javascript:;" id="Clear" onclick="ClearALL()">
<p id="ClearImg" class="imgWrap"><img src="~/Content/imgs/manage_p34.png" /></p>
<p class="p_txt">初始化</p>
</a>
<a href="javascript:;" id="Test">
<p id="TestStart" class="NewimgWrap"><img src="~/Content/imgs/manage_p31.png" /></p>
<p class="p_txt">设备检测</p>
</a>
<a href="javascript:;" id="TestEnd">
<p class="NewimgWrap" id="P_TestEnd"> <img src="~/Content/imgs/manage_p30.png" /></p>
<p class="p_txt">检测结束</p>
</a>
<a href="javascript:;" id="startWork">
<p class="NewimgWrap" id="StartWork"><img src="~/Content/imgs/manage_p32.png" /></p>
<p class="p_txt">开始作业</p>
</a>
<a href="javascript:;" onclick="EndWork()" id="clsWork">
<p class="imgWrap" id="CloseWork"><img src="~/Content/imgs/manage_p33.png" /></p>
<p class="p_txt">结束作业</p>
</a>
</div>
</div>
<div id="doing" style="text-align:center;width:50px; margin-top:-200px; z-index:9999"></div>
<div class="copyRight" style="color:red; font-weight:bold; font-size:18px;"><label id="showMessage" name="showMessage" class="showMessage"></label></div>
<input type="hidden" id="isClear" value="@ViewBag.isClear" />
<input type="hidden" id="isWork" value="@ViewBag.isWork" />
@*<div class="copyRight">Copyright © 2018京ICP备10011451号 &nbsp;&nbsp; 版权所有:上海驿传物流科技有限公司</div>*@
</div>
<script src="~/Scripts/angular/angular.min.js"></script>
<script src="~/Scripts/pagination/tm.pagination.js"></script>
<script src="~/Scripts/angular-list/Index.js"></script>
<script type="text/javascript">
$(document).keyup(function (event) {
if (event.keyCode == 13) {
SubmitForm();
}
});
function SubmitForm() {
$.ajax({
type: "POST",
url: '@Url.Action("StartWork", "Home")',
dataType: "json",
beforeSend: function (XMLHttpRequest) {
$("#doing").html("<img src='/Content/imgs/timg.gif' width='100px';>");
},
success: function (data) {
if (data.Success) {
// $("#showMessage").text("箱号:" + barcode + "正在拣货!");
$("#barcode").val("");
$("#barcode")[0].focus();
}
else {
$("#showMessage").text(data.Message);
$("#barcode").val("");
$("#barcode")[0].focus();
}
},
// 请求完成后的回调函数 (请求成功或失败之后均调用)
complete: function (XMLHttpRequest, textStatus) {
$("#doing").empty();
},
// 请求失败时调用此函数。
error: function (XMLHttpRequest, textStatus, errorThrown) {
$("#doing").empty();
}
});
}
function ClearALL() {
$.ajax({
type: "POST",
url: '@Url.Action("ClearALL", "Home")',
dataType: "json",
beforeSend: function (XMLHttpRequest) {
$("#doing").html("<img src='/Content/imgs/timg.gif' width='100px';>");
},
success: function (data) {
if (data.Success) {
$("#showMessage").text("初始化成功!");
isClearFN();
}
else {
$("#showMessage").text(data.Message);
}
},
// 请求完成后的回调函数 (请求成功或失败之后均调用)
complete: function (XMLHttpRequest, textStatus) {
$("#doing").empty();
},
// 请求失败时调用此函数。
error: function (XMLHttpRequest, textStatus, errorThrown) {
$("#doing").empty();
}
});
} function TestStart() {
$.ajax({
type: "POST",
url: '@Url.Action("TestStart", "Home")',
dataType: "json",
beforeSend: function (XMLHttpRequest) {
$("#doing").html("<img src='/Content/imgs/timg.gif' width='100px';>");
},
success: function (data) {
if (data.Success) {
$("#showMessage").text("设备检测!");
$("#Test").removeAttr("onclick");
$("#startWork").removeAttr("onclick");
var imgClass = $("#TestStart");
imgClass.removeClass("imgWrap");
imgClass.addClass("NewimgWrap");
var imgClass = $("#StartWork");
imgClass.removeClass("imgWrap");
imgClass.addClass("NewimgWrap");
}
else {
$("#showMessage").text("失败!");
}
},
// 请求完成后的回调函数 (请求成功或失败之后均调用)
complete: function (XMLHttpRequest, textStatus) {
$("#doing").empty();
},
// 请求失败时调用此函数。
error: function (XMLHttpRequest, textStatus, errorThrown) {
$("#doing").empty();
}
});
}
function TestEnd() {
$.ajax({
type: "POST",
url: '@Url.Action("TestEnd", "Home")',
dataType: "json",
beforeSend: function (XMLHttpRequest) {
$("#doing").html("<img src='/Content/imgs/timg.gif' width='100px';>");
},
success: function (data) {
if (data.Success) {
$("#showMessage").text("检测结束!");
$("#startWork").attr("onclick", "StartWork();");
$("#Test").attr("onclick", "TestStart();");
var imgClass = $("#StartWork");
imgClass.removeClass("NewimgWrap");
imgClass.addClass("imgWrap");
var imgClass = $("#TestStart");
imgClass.removeClass("NewimgWrap");
imgClass.addClass("imgWrap");
}
else {
$("#showMessage").text("失败!");
}
}
,
// 请求完成后的回调函数 (请求成功或失败之后均调用)
complete: function (XMLHttpRequest, textStatus) {
$("#doing").empty();
},
// 请求失败时调用此函数。
error: function (XMLHttpRequest, textStatus, errorThrown) {
$("#doing").empty();
}
});
}
function StartWork() {
$("#startWork").removeAttr("onclick");
$("#Test").removeAttr("onclick");
$("#TestEnd").removeAttr("onclick");
$("#Clear").removeAttr("onclick");
$.ajax({
type: "POST",
url: '@Url.Action("StartWork", "Home")',
dataType: "json",
beforeSend: function (XMLHttpRequest) {
$("#doing").html("<img src='/Content/imgs/timg.gif' width='200px';>");
},
success: function (data) {
if (data.Success) {
$("#showMessage").text("开始作业!");
isWorkFN();
}
else {
$("#showMessage").text("开始作业失败!");
}
}
,
// 请求完成后的回调函数 (请求成功或失败之后均调用)
complete: function (XMLHttpRequest, textStatus) {
$("#doing").empty();
},
// 请求失败时调用此函数。
error: function (XMLHttpRequest, textStatus, errorThrown) {
$("#doing").empty();
}
});
}
function EndWork() {
$("#clsWork").removeAttr("onclick");
$.ajax({
type: "POST",
url: '@Url.Action("EndWork", "Home")',
dataType: "json",
beforeSend: function (XMLHttpRequest) {
$("#doing").html("<img src='/Content/imgs/timg.gif' width='200px';>");
},
success: function (data) {
if (data.Success) {
$("#showMessage").text("结束作业!");
$("#Clear").attr("onclick", "ClearALL();");
var imgClass = $("#ClearImg");
imgClass.removeClass("NewimgWrap");
imgClass.addClass("imgWrap");
}
else {
$("#showMessage").text("失败!");
}
}
,
// 请求完成后的回调函数 (请求成功或失败之后均调用)
complete: function (XMLHttpRequest, textStatus) {
$("#doing").empty();
},
// 请求失败时调用此函数。
error: function (XMLHttpRequest, textStatus, errorThrown) {
$("#doing").empty();
}
});
}
function CloseWork() {
$.ajax({
type: "POST",
url: '@Url.Action("Close", "Home")',
dataType: "json",
beforeSend: function (XMLHttpRequest) {
$("#doing").html("<img src='/Content/imgs/timg.gif' width='200px';>");
},
success: function (data) {
if (data.Success) {
CloseWebPage();
}
else {
$("#showMessage").text("失败!");
}
}
,
// 请求完成后的回调函数 (请求成功或失败之后均调用)
complete: function (XMLHttpRequest, textStatus) {
$("#doing").empty();
},
// 请求失败时调用此函数。
error: function (XMLHttpRequest, textStatus, errorThrown) {
$("#doing").empty();
}
});
}
function CloseWebPage() {
if (navigator.userAgent.indexOf("MSIE") > 0) {
if (navigator.userAgent.indexOf("MSIE 6.0") > 0) {
window.opener = null;
window.close();
} else {
window.open('', '_top');
window.top.close();
}
}
else if (navigator.userAgent.indexOf("Firefox") > 0 || navigator.userAgent.indexOf("Chrome") > 0) {
//window.location.href = 'about:blank ';
window.location.href = "about:blank";
window.close();
}
else {
window.opener = null;
window.open('', '_self');
window.close();
}
}
function isClearFN() {
var imgClass = $("#ClearImg");
imgClass.removeClass("imgWrap");
imgClass.addClass("NewimgWrap");
$("#Clear").removeAttr("onclick");
$("#startWork").attr("onclick", "StartWork();");
$("#Test").attr("onclick", "TestStart();");
$("#TestEnd").attr("onclick", "TestEnd();");
$("#clsWork").attr("onclick", "EndWork();");
var imgClass = $("#StartWork");
imgClass.removeClass("NewimgWrap");
imgClass.addClass("imgWrap");
var imgClass = $("#P_TestEnd");
imgClass.removeClass("NewimgWrap");
imgClass.addClass("imgWrap");
var imgClass = $("#TestStart");
imgClass.removeClass("NewimgWrap");
imgClass.addClass("imgWrap");
}
function isWorkFN() {
var imgClass = $("#StartWork");
imgClass.removeClass("imgWrap");
imgClass.addClass("NewimgWrap");
var imgClass = $("#P_TestEnd");
imgClass.removeClass("imgWrap");
imgClass.addClass("NewimgWrap");
var imgClass = $("#TestStart");
imgClass.removeClass("imgWrap");
imgClass.addClass("NewimgWrap");
var imgClass = $("#ClearImg");
imgClass.removeClass("imgWrap");
imgClass.addClass("NewimgWrap");
}
$(function () {
var clear= $("#isClear").val();
var work= $("#isWork").val();
if (clear == 1) {
isClearFN();
}
if (work == 1) { isWorkFN(); }
});
</script>