var CheckTaskManager = {
InTable: undefined,
Server: function (URL, data, callback)
{
$.gitAjax({
url: URL,
data: data,
type: "post",
dataType: "json",
success: function (result) {
callback(result);
}
});
},
ToolBar: function () {
var searchBar = $("div[data-condition='search']");
//窗体加载获得焦点
CheckTaskManager.PageClick(1, 50);
searchBar.find("input[name='CDNo']").focus();
//监听回车事件,用于扫描
searchBar.find("input[name='CDNo']").keydown(function (event) {
if (event.keyCode == 13) {
var value = $(this).val();
if (!git.IsEmpty(value)) {
CheckTaskManager.PageClick(1, 50);
setTimeout(function () {
searchBar.find("input[name='CDNo']").focus();
}, 300);
}
}
});
var searchBar = $("div[data-condition='search']");
searchBar.find("a[data-command='search']").click(function () {
// 调用查询方法,绑定分页信息
CheckTaskManager.PageClick(1, 50);
});
var btnClick = $("div.toolbar");
btnClick.find("a.btn").click(function () {
var command = $(this).attr("data-command");
switch (command) {
case "Add":
break;
case "Delete":
var submit = function (v, h, f) {
if (v == "ok") {
var list = Dictionary.GetSelect();
if (list.length == 0) {
$.jBox.tip("请选择要删除的项", "warn");
return false;
}
var param = {};
param["list"] = JSON.stringify(list);
$.gitAjax({
url: "/DictionaryAjax/DelDictionarys",
data: param,
type: "post",
dataType: "json",
success: function (result) {
// 提示操作信息
$.jBox.tip(result.Message, "success");
var pageSize = $("#mypager").pager("GetPageSize");
Dictionary.PageClick(1, pageSize);
}
});
}
}
$.jBox.confirm("确定要删除吗?", "提示", submit);
default: break;
}
})
},
PageClick: function (PageIndex, PageSize) {
$.jBox.tip("正在努力加载数据...", "loading");
var search = CheckTaskManager.GetSearch();
search["PageIndex"] = PageIndex;
search["PageSize"] = PageSize;
CheckTaskManager.Server("/Business/CheckTaskAjax/GetList", { aaa: JSON.stringify(search) }, function (result) {
$.jBox.closeTip();
if (result != null) {
if (result.Code == 1) {
// 查询成功,绑定Table
CheckTaskManager.SetTable(result);
} else {
$.jBox.tip(result.Message, "warn");
}
}
});
},
GetSearch: function () {
var search = {};
var searchBar = $("div[data-condition='search']");
search["CDNo"] = searchBar.find("input[name='CDNo']").val();
search["Statu"] = searchBar.find("select[name='Statu']").val();
search["LocationCode"] = searchBar.find("input[name='LocationCode']").val();
search["Palno"] = searchBar.find("input[name='Palno']").val();
return search;
},
AutoOrders: function ()
{
var search = CheckTaskManager.GetSearch();
CheckTaskManager.Server("/Business/CheckTaskAjax/AutoOrders",
{ aaa: JSON.stringify(search) }, function (result) {
if (result != null) {
if (result.Code == 1) {
// 查询成功,绑定Table
CheckTaskManager.PageClick(1, 50);
} else {
CheckTaskManager.PageClick(1, 50);
$.jBox.tip(result.Message, "warn");
}
}
});
},
SetTable: function (result){
var cols = [
{
title: '盘库单号', name: 'CDNo', width: 120, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '库位编码', name: 'LocationCode1', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '托盘编码', name: 'Palno1', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '任务状态', name: 'Statu', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '完成时间', name: 'CheckTime', width: 120, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return git.JsonToDateTimeto(data);
}
},
{
title: '执行人', name: 'CheckUser', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '制单时间', name: 'CreatTime', width: 80, hidden: 'true', align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return git.JsonToDateTimeto(data);
}
},
{
title: '制单人', name: 'CreatUser', width: 80, hidden: 'true', align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '操作', name: 'Guid', width: 120, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
var html = "";
if (item.Statu == "等待执行") {
html += '盘点出库 ';
}
html += '编辑 ';
return html;
}
},
];
// 设置Table
if (this.InTable == undefined) {
var ht = masterUI.MMGridHeight();
this.InTable = $("#tabList").mmGrid({
cols: cols,
sortName: 'CDNo',
sortStatus: 'desc',
fullWidthRows: true,
//multiSelect: true,
items: result.Result.List,
//checkCol: true,
indexCol: true,
nowrap: true,
height: ht
});
//绑定事件
CheckTaskManager.BindEvent();
}
else {
this.InTable.load(result.Result.List);
}
// 绑定分页信息,切换分页调用查询方法
var pageInfo = result.PageInfo;
if (pageInfo != undefined) {
$("#mypager").pager({ pagenumber: pageInfo.PageIndex, recordCount: pageInfo.RowCount, pageSize: pageInfo.PageSize, buttonClickCallback: CheckTaskManager.PageClick });
}
},
// 绑定行事件
BindEvent: function () {
this.InTable.on('loadSuccess', function (e, data) { //loadSuccess
LoadBtn.SetBtn();
});
this.InTable.off("cellSelected").on("cellSelected", function (e, item, rowIndex, colIndex) {
var param = {};
param["Guid"] = item.Guid;
param["CDNo"] = item.CDNo;
param["LocationCode1"] = item.LocationCode1;
param["LocationCode2"] = item.LocationCode2;
param["Palno1"] = item.Palno1;
param["Palno2"] = item.Palno2;
// 手动盘点
if ($(e.target).is("a.stocktaking")) {
$.jBox.tip("正在生成出库指令...", "loading");
CheckTaskManager.Server("/Business/CheckTaskAjax/CreateOrder",
{ aaa: item.Guid }, function (result) {
$.jBox.closeTip();
CheckTaskManager.PageClick(1, 50);
if (result != null) {
$.jBox.tip(result.Message, "warn");
}
});
}
// 绑定编辑库区事件
if ($(e.target).is("a.edit")) {
var Guid = item.Guid;
//window.location.href = "/Business/CheckTask/Edit?Guid=" + Guid;
var width = document.body.clientWidth-100;
var height = document.body.clientHeight - 100;
$.jBox.open("get:/Business/CheckTask/Edit?Guid=" + Guid, "编辑", width, height, { buttons: { /*"确定": true,*/ "关闭": false }, top: '10%'});/*, submit: submit */
}
});
},
}