function query_time(start_time, end_time) {
this.start_time = start_time;
this.end_time = end_time;
}
var t = new query_time();
var currentPage_task = 1;//当前页
var recordsCount_task = 17;//每页条数
var totalPages_task = 1;//总页数
var currentPage_taskout = 1;//当前页
var recordsCount_taskout = 17;//每页条数
var totalPages_taskout = 1;//总页数
$(function () {
getQueryTime(t);
var currentPage = 1;//当前页
var recordsCount = 17;//每页条数
//获取默认日志数据
getLogData(t.start_time, t.end_time, "", "", recordsCount, currentPage);
//获取所有任务
var totalPages = 10;//总页数
getTaskData("", "", null, null, recordsCount_task, currentPage_task);//查询入库任务
getTaskOutData("", "", null, null, recordsCount_taskout, currentPage_taskout);//查询出库任务
$("#page").bootstrapPaginator({
bootstrapMajorVersion: 3, //对应的bootstrap版本
currentPage: currentPage, //当前页数
numberOfPages: 10, //每次显示页数
totalPages: totalPages, //总页数
shouldShowPage: true,//是否显示该按钮
useBootstrapTooltip: true,
//点击事件
onPageClicked: function (event, originalEvent, type, page) {
//console.log("点击页数时,触发该函数, type: " + type + " page: " + page);
var tr_type = $('#TrackType').val();
var user_data = $('input[name="user_data"]').val();
getQueryTime(t);
getLogData(t.start_time, t.end_time, user_data, tr_type, recordsCount, page);
getTotalPage(t.start_time, t.end_time, user_data, tr_type, recordsCount, page);
},
onPageChanged: function (e, oldPage, newPage) {
//console.log("当页面改变时,触发该函数, old: " + oldPage + " new: " + newPage);
}
});
//入库
$("#page-task").bootstrapPaginator({
bootstrapMajorVersion: 3, //对应的bootstrap版本
currentPage: currentPage_task, //当前页数
numberOfPages: 10, //每次显示页数
totalPages: totalPages_task, //总页数
shouldShowPage: true,//是否显示该按钮
useBootstrapTooltip: true,
onPageClicked: function (event, originalEvent, type, page) {
RefrashTaskInfo(page);
},
onPageChanged: function (e, oldPage, newPage) { }
});
//出库
$("#page-taskout").bootstrapPaginator({
bootstrapMajorVersion: 3, //对应的bootstrap版本
currentPage: currentPage_task, //当前页数
numberOfPages: 10, //每次显示页数
totalPages: totalPages_taskout, //总页数
shouldShowPage: true,//是否显示该按钮
useBootstrapTooltip: true,
onPageClicked: function (event, originalEvent, type, page) {
RefrashTaskOutInfo(page);
},
onPageChanged: function (e, oldPage, newPage) { }
});
});
function cacheFunction()
{
var q0 = "WebDev.WebServer40,VSPEC_WCS";
$.ajax({
type: "post",
url: "../../AJAX/GetAGVInfo.ashx",
data: { action: "Killprocess", q0: q0 },
async: false,
success: function (msg) {}
});
}
function RefrashTaskInfo(page) { //刷新当前入库任务
var task_bill = $('input[name="task_bill"]').val();
var task_barcode = $('input[name="task_barcode"]').val();
var task_type = $('#task_type').val();
var task_state = $('#task_state').val();
getTaskData(task_bill, task_barcode, task_type, task_state, recordsCount_task, page);
getTaskTotalPage(task_bill, task_barcode, task_type, task_state, recordsCount_task, page);
}
//获取日志数据
function getLogData(str0, str1, str2, str3, str4, str5) {
$.ajax({
type: "post",
url: "/AJAX/OPCServiceOperation.ashx",
data: { action: "GetLogInfo", q0: str0, q1: str1, q2: str2, q3: str3, q4: str4, q5: str5 },//q0: "2018-6-15 15:06:19", q1: "2018-6-22 15:06:52", q2: "", q3: "Successed", q4: "17", q5: newPage
async: false,
success: function (msg) {
if (msg.length > 0) {
$('.LogInfo-Tb tr:gt(0)').empty();
var json = JSON.parse(msg);
for (var i = 0; i < json.length; i++) {
var dt = eval(json[i].EventDate.replace(/\/Date\((\d+)\)\//gi, "new Date($1)"));
$("
" + (i + 1) + " | " + dt.toLocaleString() + " | " + json[i].UserData + " | " + json[i].TrackType + " | "
+ json[i].Extension1 + " | " + json[i].TrackOperator + " |
").appendTo(".LogInfo-Tb");
}
} else {
$('.LogInfo-Tb tr:gt(0)').empty();
//swal("无数据!", msg, "error");
}
}
});
}
//获取日志总页数
function getTotalPage(str0, str1, str2, str3, str4, str5) {
$.ajax({
type: "post",
url: "/AJAX/OPCServiceOperation.ashx",
data: { action: "getTotalPage", q0: str0, q1: str1, q2: str2, q3: str3, q4: str4, q5: str5 },
async: false,
success: function (msg) {
if (msg > 0) {
$("#page").bootstrapPaginator({ totalPages: Number(msg) });
}
}
});
}
//获取日志查询时间段
function getQueryTime(t) {
var default_time = $('#my-datepicker').val();
if ("" != default_time && null != default_time) {
var times = default_time.trim().split(' - ');
if (times.length > 0) {
t.start_time = times[0];
t.end_time = times[1];
}
} else {
t.start_time = "";
t.end_time = "";
}
}
//获取入库任务数据
function getTaskData(bill, barcode, type, state, recordCount, currentPage) {
$.ajax({
type: "post",
url: "/AJAX/OPCServiceOperation.ashx",
data: { action: "GetTaskInfo", q0: bill, q1: barcode, q2: type, q3: state, q4: recordCount, q5: currentPage },
async: false,
success: function (msg) {
if (msg.length > 0) {
// TASKNUMBER
$('.task-query-tb tr:gt(0)').remove();
var json = JSON.parse(msg);
for (var i = 0; i < json.length; i++) {
var number = json[i].TASKNUMBER;
var dt = eval(json[i].CREATETIME.replace(/\/Date\((\d+)\)\//gi, "new Date($1)"));
$('' + json[i].SEQUENCENUMBER + ' | ' +
''+ json[i].BARCODE + ' | ' + json[i].SOURCEADDRESSID + ' | ' + json[i].TARGETADDRESSID + ' | ' + json[i].DisplayTaskType + ' | '
+ json[i].DisplayTaskState + ' | ' + json[i].DisplayEquipment + ' | '+ json[i].CONTAINERID + ' | ' + json[i].ITEMID + ' | '
+ json[i].QTY + ' | ' + dt.toLocaleString() + ' |
').appendTo(".task-query-tb");
$('.task-query-tb tr:eq(' + (i + 1) + ') #delete').attr("disabled", true);
if ($('#thisModel').val() == "ExceptionMode")
{
$('.task-query-tb tr:eq(' + (i + 1) + ') #delete').attr("disabled", false);
}
//if (json[i].SEQUENCENUMBER != "主任务")
//{
// $('.task-query-tb tr:eq(' + (i + 1) + ') #action').attr("disabled", true);
//}
}
} else {
$('.task-query-tb tr:gt(0)').remove();
//swal("无数据!", msg, "error");
}
}
});
}
// ***************************************************************************************************************************
//按序列发送入库任务
function sendEquipmentTask(tasknum) {
if (null != tasknum && "" != tasknum) {
swal({
title: "确定执行命令吗?",
text: "你将无法恢复到执行前的状态!",
type: "warning",
showCancelButton: true,
confirmbuttoncolor: "#dd6b55",
confirmbuttontext: "确定执行!",
confirmButtonText: '执行',
cancelButtonText: '取消',
closeonconfirm: false
},
function () {
$.ajax({
type: "post",
url: "/ajax/SendTaskInfoOperation.ashx",
data: { action: "sendTask", q0: "", q1: tasknum },
async: false,
success: function (msg) {
if ("" == msg) {
swal("成功!", "命令已下发", "success");
RefrashTaskInfo(currentPage_task);
//if ($('.task-query-tb tr:eq(1) #action').val() != "完成") {
// $('.task-query-tb tr:eq(1) #action').val("完成");
// $('.task-query-tb tr:eq(1) input').removeClass("btn-info");
// $('.task-query-tb tr:eq(1) input').addClass("btn-danger");
//}
//clearuser();
} else {
swal("失败!", msg, "error");
}
}
});
});
} else {
swal("失败!", "未获取到任务号", "error");
}
}
//获取入库任务总页数
function getTaskTotalPage(bill, barcode, type, state, recordCount, currentPage) {
$.ajax({
type: "post",
url: "/AJAX/OPCServiceOperation.ashx",
data: { action: "getTaskTotalPage", q0: bill, q1: barcode, q2: type, q3: state, q4: recordCount, q5: currentPage },
async: false,
success: function (msg) {
if (msg > 0) {
$("#page-task").bootstrapPaginator({ totalPages: Number(msg) });
}
}
});
}
function getUser() {
var user = $('#currentUser').val();
return user;
}
//删除任务
function delThisTask(tasknum,index) {
if (null != tasknum && "" != tasknum) {
swal({
title: "确定删除当前任务吗?",
text: "你将无法恢复到执行前的状态!",
type: "warning",
showCancelButton: true,
confirmbuttoncolor: "#dd6b55",
confirmbuttontext: "确定删除!",
confirmButtonText: '删除',
cancelButtonText: '取消',
closeonconfirm: false
},
function () {
$.ajax({
type: "post",
url: "/ajax/SendTaskInfoOperation.ashx",
data: { action: "delHandTask", q0: getUser(), q1: tasknum },
async: false,
success: function (msg) {
if ("" == msg) {
swal("成功!", "当前任务已删除", "success");
if (index == 1) {
RefrashTaskInfo(currentPage_task);
}
if (index == 2)
{
RefrashTaskOutInfo(currentPage_task);
}
//clearuser();
} else {
swal("失败!", msg, "error");
}
}
});
});
} else {
swal("失败!", "未获取到任务号", "error");
}
}
// ***************************************************************************************************************************
//获取出库任务数据
function getTaskOutData(bill, barcode, type, state, recordCount, currentPage) {
$.ajax({
type: "post",
url: "/AJAX/OPCServiceOperation.ashx",
data: { action: "GetTaskOutInfo", q0: bill, q1: barcode, q2: type, q3: state, q4: recordCount, q5: currentPage },
async: false,
success: function (msg) {
if (msg.length > 0) {
// TASKNUMBER
$('.taskout-query-tb tr:gt(0)').remove();
var json = JSON.parse(msg);
for (var i = 0; i < json.length; i++) {
var number = json[i].TASKNUMBER;
var dt = eval(json[i].CREATETIME.replace(/\/Date\((\d+)\)\//gi, "new Date($1)"));
$('' + json[i].SEQUENCENUMBER + ' | '
+ json[i].BARCODE + ' | ' + json[i].SOURCEADDRESSID + ' | ' + json[i].TARGETADDRESSID + ' | ' + json[i].DisplayTaskType + ' | '
+ json[i].DisplayTaskState + ' | ' + json[i].DisplayEquipment + ' | ' + json[i].CONTAINERID + ' | ' + json[i].ITEMID + ' | '
+ json[i].QTY + ' | ' + dt.toLocaleString() + ' |
').appendTo(".taskout-query-tb");
$('.taskout-query-tb tr:eq(' + (i + 1) + ') #delete').attr("disabled", true);
if ($('#thisModel').val() == "ExceptionMode") {
$('.taskout-query-tb tr:eq(' + (i + 1) + ') #delete').attr("disabled", false);
}
//if (i > 0) {
// $('.taskout-query-tb tr:eq(' + (i + 1) + ') input').attr("disabled", "disabled");
//}
//if (json[i].SEQUENCENUMBER != "主任务") {
// $('.taskout-query-tb tr:eq(' + (i + 1) + ') #action').attr("disabled", true);
//}
}
} else {
$('.taskout-query-tb tr:gt(0)').remove();
//swal("无数据!", msg, "error");
}
}
});
}
function RefrashTaskOutInfo(page) { //刷新当前出库库任务
var task_bill = $('input[name="taskout_bill"]').val();
var task_barcode = $('input[name="taskout_barcode"]').val();
var task_type = $('#taskout_type').val();
var task_state = $('#taskout_state').val();
getTaskOutData(task_bill, task_barcode, task_type, task_state, recordsCount_taskout, page);
getTaskOutTotalPage(task_bill, task_barcode, task_type, task_state, recordsCount_taskout, page);
}
//按序列发送出库任务
function sendEquipmentTaskOut(tasknum) {
if (null != tasknum && "" != tasknum) {
swal({
title: "确定执行命令吗?",
text: "你将无法恢复到执行前的状态!",
type: "warning",
showCancelButton: true,
confirmbuttoncolor: "#dd6b55",
confirmbuttontext: "确定执行!",
confirmButtonText: '执行',
cancelButtonText: '取消',
closeonconfirm: false
},
function () {
$.ajax({
type: "post",
url: "/ajax/SendTaskInfoOperation.ashx",
data: { action: "sendTask", q0: "", q1: tasknum },
async: false,
success: function (msg) {
if ("" == msg) {
swal("成功!", "命令已下发", "success");
RefrashTaskOutInfo(currentPage_taskout);
//if ($('.taskout-query-tb tr:eq(1) input').val() != "完成") {
// $('.taskout-query-tb tr:eq(1) input').val("完成");
// $('.taskout-query-tb tr:eq(1) input').removeClass("btn-info");
// $('.taskout-query-tb tr:eq(1) input').addClass("btn-danger");
//}
//clearuser();
} else {
setTimeout(function () { swal("失败", msg, "error"); }, 100);
//swal("失败!", msg, "error");
}
}
});
});
} else {
swal("失败!", "未获取到任务号", "error");
}
}
//获取出库任务总页数
function getTaskOutTotalPage(bill, barcode, type, state, recordCount, currentPage) {
$.ajax({
type: "post",
url: "/AJAX/OPCServiceOperation.ashx",
data: { action: "getTaskOutTotalPage", q0: bill, q1: barcode, q2: type, q3: state, q4: recordCount, q5: currentPage },
async: false,
success: function (msg) {
if (msg > 0) {
$("#page-taskout").bootstrapPaginator({ totalPages: Number(msg) });
}
}
});
}