var PalletEmptyInManager = {
|
EmptyPalletTable: undefined,
|
Servers: function (URL, data, callback) {
|
$.gitAjax({
|
url: URL,
|
data: data,
|
type: "post",
|
dataType: "json",
|
success: function (result) {
|
callback(result);
|
}
|
});
|
},
|
Server: function () {
|
var config = (function () {
|
var URL_GetList = "/Business/IPalletEmptyInAjax/GetList";
|
var URL_Add = "/Business/IPalletEmptyInAjax/Add";
|
var URL_Del = "/Business/IPalletEmptyInAjax/Del";
|
var URL_ErpIn = "/Business/IPalletEmptyInAjax/ErpIn";
|
var URL_ErpClose = "/Business/IPalletEmptyInAjax/ErpClose";
|
var URL_CheckStatus = "/Business/IPalletEmptyInAjax/CheckStatus";
|
return {
|
URL_GetList: URL_GetList,
|
URL_Add: URL_Add,
|
URL_Del: URL_Del,
|
URL_ErpIn:URL_ErpIn,
|
URL_ErpClose: URL_ErpClose,
|
URL_CheckStatus: URL_CheckStatus,
|
};
|
})();
|
|
//数据操作服务
|
var dataServer = (function ($, config) {
|
|
//查询分页列表
|
var GetList = function (data, callback) {
|
$.gitAjax({
|
url: config.URL_GetList,
|
data: { ajaxdata: JSON.stringify(data) },
|
type: "post",
|
dataType: "json",
|
success: function (result) {
|
if (callback != undefined && typeof callback == "function") {
|
callback(result);
|
}
|
}
|
});
|
}
|
|
var Add = function (data, callback) {
|
$.gitAjax({
|
url: config.URL_Add,
|
data: { ajaxdata: JSON.stringify(data) },
|
type: "post",
|
dataType: "json",
|
success: function (result) {
|
if (callback != undefined && typeof callback == "function") {
|
callback(result);
|
}
|
}
|
});
|
}
|
|
var Del = function (data, callback) {
|
$.gitAjax({
|
url: config.URL_Del,
|
data: { ajaxdata: JSON.stringify(data) },
|
type: "post",
|
dataType: "json",
|
success: function (result) {
|
if (callback != undefined && typeof callback == "function") {
|
callback(result);
|
}
|
}
|
});
|
}
|
|
var ErpIn = function (data, callback) {
|
$.gitAjax({
|
url: config.URL_ErpIn,
|
data: { ajaxdata: JSON.stringify(data) },
|
type: "post",
|
dataType: "json",
|
success: function (result) {
|
if (callback != undefined && typeof callback == "function") {
|
callback(result);
|
}
|
}
|
});
|
}
|
|
var ErpClose = function (data, callback) {
|
$.gitAjax({
|
url: config.URL_ErpClose,
|
data: { ajaxdata: JSON.stringify(data) },
|
type: "post",
|
dataType: "json",
|
success: function (result) {
|
if (callback != undefined && typeof callback == "function") {
|
callback(result);
|
}
|
}
|
});
|
}
|
var CheckStatus = function (data, callback) {
|
$.gitAjax({
|
url: config.URL_CheckStatus,
|
data: { ajaxdata: JSON.stringify(data) },
|
type: "post",
|
dataType: "json",
|
success: function (result) {
|
if (callback != undefined && typeof callback == "function") {
|
callback(result);
|
}
|
}
|
});
|
}
|
return {
|
|
GetList: GetList,
|
Add: Add,
|
Del: Del,
|
ErpIn: ErpIn,
|
ErpClose: ErpClose,
|
CheckStatus:CheckStatus,
|
|
}
|
})($, config);
|
return dataServer;
|
},
|
PageClick: function (PageIndex, PageSize) {
|
$.jBox.tip("正在努力加载数据...", "loading");
|
var Server = PalletEmptyInManager.Server();
|
var search = PalletEmptyInManager.GetSearch();
|
search["PageIndex"] = PageIndex;
|
search["PageSize"] = PageSize;
|
|
Server.GetList(search, function (result) {
|
//debugger
|
$.jBox.closeTip();
|
if (result.Code == 1) {
|
PalletEmptyInManager.SetTable(result);
|
} else {
|
$.jBox.tip(result.Message, "warn");
|
}
|
});
|
},
|
Refresh: function () {
|
var PageSize = $("#mypager").pager("GetPageSize");
|
var PageIndex = $("#mypager").pager("GetCurrent");
|
$.jBox.tip("正在努力加载数据...", "loading");
|
var Server = PalletEmptyInManager.Server();
|
var search = PalletEmptyInManager.GetSearch();
|
search["PageIndex"] = PageIndex;
|
search["PageSize"] = PageSize;
|
Server.GetList(search, function (result) {
|
$.jBox.closeTip();
|
if (result.Code == 1) {
|
PalletEmptyInManager.SetTable(result);
|
} else {
|
$.jBox.tip(result.Message, "warn");
|
}
|
});
|
},
|
SetTable: function (result) {
|
var cols = [
|
|
{
|
title: '托盘码', name: 'Palno', width: 120, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '托盘数量', name: 'PalCount', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '指定库位', name: 'LocationCode', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '状态', name: 'Statu', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
|
{
|
title: '创建者', name: 'CreateUser', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '创建时间', name: 'CreateTime', width: 200, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '备注', name: 'Demo', width: 260, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '操作', name: 'OrdNo', width: 80, align: 'left', lockWidth: false, renderer: function (data, item, rowIndex) {
|
var html = "";
|
if (item.Statu == "等待执行") {
|
html += '<a class="edit dis" href="javascript:void(0)">编辑</a> ';
|
html += '<a class="del dis" href="javascript:void(0)">删除</a> ';
|
}
|
return html;
|
}
|
},
|
];
|
var ht = masterUI.MMGridHeight();
|
if (this.EmptyPalletTable == undefined) {
|
this.EmptyPalletTable = $("#tabList").mmGrid({
|
cols: cols,
|
items: result.Result.List,
|
checkCol: true,
|
fullWidthRows: true,
|
nowrap: true,
|
height: ht
|
});
|
//绑定编辑 删除事件
|
PalletEmptyInManager.BindEvent();
|
}
|
else {
|
this.EmptyPalletTable.load(result.Result.List);
|
}
|
|
var pageInfo = result.PageInfo;
|
if (pageInfo != undefined) {
|
$("#mypager").pager({ pagenumber: pageInfo.PageIndex, recordCount: pageInfo.RowCount, pageSize: pageInfo.PageSize, buttonClickCallback: PalletEmptyInManager.PageClick });
|
}
|
},
|
BindEvent: function () {
|
|
this.EmptyPalletTable.on('loadSuccess', function (e, data) {
|
LoadBtn.SetBtn();
|
});
|
|
this.EmptyPalletTable.off("cellSelected").on("cellSelected", function (e, item, rowIndex, colIndex) {
|
if ($(e.target).is("a.del")) {
|
if (item.Statu == "等待执行") {
|
var Guid = item.Guid;
|
var LocationCode = item.LocationCode;
|
|
|
var submit = function (v, h, f){
|
if (v == "ok") {
|
//// 验证单据状态并删除数据
|
PalletEmptyInManager.Servers("/Business/IPalletEmptyInAjax/IsCheckStatu",
|
{ Guid: Guid, LocationCode: LocationCode }, function (result) {
|
if (result != null) {
|
$.jBox.tip(result.Message, "warn");
|
}
|
|
PalletEmptyInManager.PageClick(1, 50);
|
});
|
}
|
}
|
|
$.jBox.confirm("确定要删除吗?", "提示", submit);
|
}
|
}
|
else if ($(e.target).is("a.edit")) {
|
var Guid = item.Guid;
|
var Palno = item.Palno;
|
var PalCount = item.PalCount;
|
var Demo = item.Demo;
|
var Addre = item.LocationCode;
|
if (item.Statu != "等待执行") {
|
jBox.tip("状态不允许编辑", "warn");
|
return false;
|
}
|
|
PalletEmptyInManager.Add(Guid, Palno, PalCount, Demo, Addre);
|
}
|
});
|
},
|
GetSelect: function () {
|
var list = [];
|
if (this.EmptyPalletTable != undefined) {
|
var rows = this.EmptyPalletTable.selectedRows();
|
if (rows != undefined && rows.length > 0) {
|
for (var i = 0; i < rows.length; i++) {
|
list.push(rows[i].OrdNo);
|
}
|
}
|
}
|
return list;
|
},
|
GetRows: function () {
|
var list = [];
|
if (this.EmptyPalletTable != undefined) {
|
var rows = this.EmptyPalletTable.selectedRows();
|
if (rows != undefined && rows.length > 0) {
|
for (var i = 0; i < rows.length; i++) {
|
list.push(rows[i]);
|
}
|
}
|
}
|
return list;
|
},
|
GetSearch: function () {
|
var search = {};
|
var searchBar = $("div[data-condition='search']");
|
search["Palno"] = searchBar.find("input[name='PalletNo']").val();
|
search["BeginTime"] = searchBar.find("input[name='BeginTime']").val();
|
search["EndTime"] = searchBar.find("input[name='EndTime']").val();
|
return search;
|
},
|
Add: function (Guid, Palno, PalCount, Demo, Addre) {
|
|
var submit = function (v, h, f) {
|
if (v) {
|
var PalletNo = h.find("input[name='PalletNo']").val();
|
var PalletCount = h.find("input[name='PalletCount']").val();
|
var Demo = h.find("input[name='Demo']").val();
|
|
if (git.IsEmpty(PalletNo)) {
|
$.jBox.tip("托盘码不能为空", "warn");
|
return false;
|
}
|
if (!git.checkStrLength(PalletNo)) {
|
$.jBox.tip("托盘码长度异常,请将输入法切换为英文,重新扫码!", "warn");
|
return false;
|
}
|
if (!git.checkInteger(PalletCount)) {
|
$.jBox.tip("数量必须为数字", "warn");
|
return false;
|
}
|
if (git.IsEmpty(PalletCount)) {
|
$.jBox.tip("数量不能为空", "warn");
|
return false;
|
}
|
|
var param = {};
|
param["Guid"] = Guid;
|
param["Palno"] = PalletNo;
|
param["PalCount"] = PalletCount;
|
param["LocationCode"] = h.find("input[name='Addre']").val();;
|
param["Demo"] = Demo;
|
|
|
// 验证托盘码是否重复使用 liudl
|
PalletEmptyInManager.Servers("/Business/IPalletEmptyInAjax/CheckPalletNo",
|
{ ajaxdata: JSON.stringify(param) }, function (result) {
|
if (result.Code == -1) {
|
$.jBox.tip(result.Message, "warn");
|
return false;
|
}
|
else
|
{
|
var Server = PalletEmptyInManager.Server();
|
Server.Add(param, function (result) {
|
if (result.Code == 1) {
|
PalletEmptyInManager.PageClick(1, 50);
|
} else {
|
$.jBox.tip(result.Message, "warn");
|
}
|
});
|
$.jBox.close();
|
}
|
});
|
return false;
|
}
|
else {
|
$.jBox.close();
|
}
|
}
|
|
//对话框加载之后回调事件
|
var load = function (h) {
|
$("div.controls").find("input[name='Addre']").SelAddre({
|
Mult: false,
|
TargetStore: $('select[name="StorageNum"]'),
|
TargetSup: $('input[name="SupNum"]'),
|
callBack: function (result) {
|
$("div.controls").find("input[name='Addre']").val(result.LocationCode);
|
}
|
});
|
|
var param = {};
|
|
param["PalletCount"] = PalCount;
|
param["PalletNo"] = Palno;
|
|
$('div.controls').find("#PalletNo").val(Palno);
|
if (!git.IsEmpty(Palno)) {
|
$('div.controls').find("#PalletNo").attr("Disabled", "Disabled");
|
}
|
$('div.controls').find("#Addre").val(Addre);
|
$('div.controls').find("#PalletCount").val(PalCount);
|
$('div.controls').find("#Demo").val(Demo);
|
}
|
|
if (git.IsEmpty(Palno)) {
|
$.jBox.open("get:/Business/IPalletEmptyIn/Add", "空托入库", 400, 270, { buttons: { "确定": true, "关闭": false }, submit: submit, loaded: load });
|
} else {
|
$.jBox.open("get:/Business/IPalletEmptyIn/Add", "空托入库", 400, 270, { buttons: { "确定": true, "关闭": false }, submit: submit, loaded: load });
|
}
|
},
|
Del: function () {
|
debugger
|
var submit = function (v, h, f) {
|
if (v == "ok") {
|
debugger
|
var list = PalletEmptyInManager.GetRows();
|
|
if (list.length == 0) {
|
$.jBox.tip("请选择要删除的项", "warn");
|
return false;
|
}
|
var item = list[0];
|
|
if (item.Statu == "正在执行" || item.Statu == "执行完成") {
|
$.jBox.tip("该托盘正在执行入库操作,不可删除!", "warn");
|
return false;
|
}
|
|
var param = {};
|
param["Id"] = item.Id;
|
param["PalletNo"] = item.PalletNo;
|
param["PalletCount"] = item.PalletCount;
|
var Server = PalletEmptyInManager.Server();
|
Server.Del(param, function (result) {
|
if (result.Code == 1) {
|
debugger
|
var pageSize = $("#mypager").pager("GetPageSize");
|
PalletEmptyInManager.PageClick(1, pageSize);
|
} else {
|
$.jBox.tip(result.Message, "warn");
|
}
|
});
|
}
|
}
|
$.jBox.confirm("该操作将解除托盘与物料绑定关系,确定要删除吗?", "提示", submit);
|
},
|
ErpIn: function (PalletNo) {
|
debugger
|
var Server = PalletEmptyInManager.Server();
|
|
Server.ErpIn(PalletNo, function (result) {
|
debugger
|
$.jBox.closeTip();
|
if (result.Code == 1) {
|
PalletEmptyInManager.SetTable(result);
|
} else {
|
$.jBox.tip(result.Message, "warn");
|
}
|
});
|
},
|
ErpClose: function (PalletNo) {
|
debugger
|
var Server = PalletEmptyInManager.Server();
|
|
Server.ErpClose(PalletNo, function (result) {
|
debugger
|
$.jBox.closeTip();
|
if (result.Code == 1) {
|
PalletEmptyInManager.SetTable(result);
|
} else {
|
$.jBox.tip(result.Message, "warn");
|
}
|
});
|
},
|
ToolBar: function () {
|
//工具栏按钮点击事件
|
$("div.toolbar").find("a.btn").click(function () {
|
var command = $(this).attr("data-command");
|
|
if (command == "Add") {
|
PalletEmptyInManager.Add();
|
}
|
|
});
|
|
//搜索 高级搜索按钮
|
var searchBar = $("div[data-condition='search']");
|
searchBar.find("a[data-command='search']").click(function () {
|
PalletEmptyInManager.PageClick(1, 50);
|
});
|
|
//加载默认数据
|
PalletEmptyInManager.PageClick(1, 50);
|
}
|
}
|