/**
*
*出库管理功能
*
**/
var ErpOutManager = {
InTable: undefined,
Server: function () {
var config = (function () {
var URL_Add = "/Business/ErpOutAjax/Add";
var URL_LoadDetail = "/Business/ErpOutAjax/LoadDetail";
var URL_AddProduct = "/Business/ErpOutAjax/AddProduct";
var URL_DelProduct = "/Business/ErpOutAjax/DelProduct";
var URL_UpdateProduct = "/Business/ErpOutAjax/UpdateProduct";
var URL_GetList = "/Business/ErpOutAjax/GetErpOutList";
var URL_GetDetail = "/Business/ErpOutAjax/GetDetail";
var URL_Delete = "/Business/ErpOutAjax/Delete";
var URL_Out = "/Business/ErpOutAjax/Out";
var URL_Close = "/Business/ErpOutAjax/Close";
var URL_Audite = "/Business/ErpOutAjax/Audit";
var URL_ToExcel = "/Business/ErpOutAjax/ToExcel";
return {
URL_GetList: URL_GetList,
URL_GetDetail: URL_GetDetail,
URL_LoadDetail: URL_LoadDetail,
URL_AddProduct: URL_AddProduct,
URL_DelProduct: URL_DelProduct,
URL_UpdateProduct: URL_UpdateProduct,
URL_Add: URL_Add,
URL_Delete: URL_Delete,
URL_Close: URL_Close,
URL_Audite: URL_Audite,
URL_ToExcel: URL_ToExcel,
URL_Out: URL_Out,
};
})();
//数据操作服务
var dataServer = (function ($, config) {
//查询分页列表
var Add = function (data, callback) {
$.gitAjax({
url: config.URL_Add,
data: data,
type: "post",
dataType: "json",
success: function (result) {
if (callback != undefined && typeof callback == "function") {
callback(result);
}
}
});
}
var LoadDetail = function (data, callback) {
$.gitAjax({
url: config.URL_LoadDetail,
data: { ajaxdata: JSON.stringify(data) },
type: "post",
dataType: "json",
success: function (result) {
if (callback != undefined && typeof callback == "function") {
callback(result);
}
}
});
}
var AddProduct = function (data, callback) {
$.gitAjax({
url: config.URL_AddProduct,
data: data,
type: "post",
dataType: "json",
success: function (result) {
if (callback != undefined && typeof callback == "function") {
callback(result);
}
}
});
}
var DelProduct = function (data, callback) {
$.gitAjax({
url: config.URL_DelProduct,
data: data,
type: "post",
dataType: "json",
success: function (result) {
if (callback != undefined && typeof callback == "function") {
callback(result);
}
}
});
}
var UpdateProduct = function (data, callback) {
$.gitAjax({
url: config.URL_UpdateProduct,
data: data,
type: "post",
dataType: "json",
success: function (result) {
if (callback != undefined && typeof callback == "function") {
callback(result);
}
}
});
}
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 GetDetail = function (data, callback) {
$.gitAjax({
url: config.URL_GetDetail,
data: { ajaxdata: JSON.stringify(data) },
type: "post",
dataType: "json",
success: function (result) {
if (callback != undefined && typeof callback == "function") {
callback(result);
}
}
});
}
var Out = function (data, callback) {
$.gitAjax({
url: config.URL_Out,
data: data,
type: "post",
dataType: "json",
success: function (result) {
if (callback != undefined && typeof callback == "function") {
callback(result);
}
}
});
}
var Delete = function (data, callback) {
$.gitAjax({
url: config.URL_Delete,
data: data,
type: "post",
dataType: "json",
success: function (result) {
if (callback != undefined && typeof callback == "function") {
callback(result);
}
}
});
}
var Close = function (data, callback) {
$.gitAjax({
url: config.URL_Close,
data: data,
type: "post",
dataType: "json",
success: function (result) {
if (callback != undefined && typeof callback == "function") {
callback(result);
}
}
});
}
var Audite = function (data, callback) {
$.gitAjax({
url: config.URL_Audite,
data: { ajaxdata: JSON.stringify(data) },
type: "post",
dataType: "json",
success: function (result) {
if (callback != undefined && typeof callback == "function") {
callback(result);
}
}
});
}
var ToExcel = function (data, callback) {
$.gitAjax({
url: config.URL_ToExcel,
data: data,
type: "post",
dataType: "json",
success: function (result) {
if (callback != undefined && typeof callback == "function") {
callback(result);
}
}
});
}
return {
Add: Add,
LoadDetail: LoadDetail,
AddProduct: AddProduct,
DelProduct: DelProduct,
UpdateProduct: UpdateProduct,
GetList: GetList,
GetDetail: GetDetail,
Delete: Delete,
Close: Close,
Audite: Audite,
ToExcel: ToExcel,
Out: Out,
}
})($, config);
return dataServer;
},
PageClick: function (PageIndex, PageSize) {
$.jBox.tip("正在努力加载数据...", "loading");
var Server = ErpOutManager.Server();
var search = ErpOutManager.GetSearch();
search["PageIndex"] = PageIndex;
search["PageSize"] = PageSize;
Server.GetList(search, function (result) {
$.jBox.closeTip();
if (result.Code == 1) {
ErpOutManager.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 = ErpOutManager.Server();
var search = ErpOutManager.GetSearch();
search["PageIndex"] = PageIndex;
search["PageSize"] = PageSize;
Server.GetList(search, function (result) {
$.jBox.closeTip();
if (result.Code == 1) {
ErpOutManager.SetTable(result);
} else {
$.jBox.tip(result.Message, "warn");
}
});
},
SetTable: function (result) {
var cols = [
{
title: '操作', name: 'OrdNo', width: 150, align: 'left', lockWidth: false, renderer: function (data, item, rowIndex) {
var html = "";
if (item.Statu == "等待执行" || item.Statu == "等待下发") {
html += '查看 ';
html += '编辑 ';
html += '出库 ';
html += '删除 ';
html += '打印 ';
} else {
html += '查看 ';
html += '打印 ';
}
return html;
}
},
{
title: '订单号', name: 'OrdNo', width: 125, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '通道口', name: 'AccessName', width: 125, 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: 'CompletionTime', width: 150, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
//return git.JsonToDateTime(data);
return data;
}
},
{
title: '创建人', name: 'CreateUser', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '创建时间', name: 'CreateTime', width: 150, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
//return git.JsonToDateTime(data);
return data;
}
},
{
title: '修改人', name: 'UpdateUser', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '修改时间', name: 'UpdateTime', width: 150, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '备注', name: 'Demo', width: 350, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
];
if (this.InTable == undefined) {
var ht = masterUI.MMGridHeight();
this.InTable = $("#tabList").mmGrid({
cols: cols,
items: result.Result.List,
checkCol: true,
multiSelect: false,
nowrap: true,
height: ht
});
//绑定编辑 删除事件
ErpOutManager.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: ErpOutManager.PageClick });
}
},
BindEvent: function () {
this.InTable.off("cellSelected").on("cellSelected", function (e, item, rowIndex, colIndex) {
if ($(e.target).is("a.edit")) {
var SN = item.OrdNo;
if (item.Statu == "等待执行" || item.Statu == "等待下发") {
var SN = item.OrdNo;
//window.location.href = "/Business/ErpOut/Add?OrdNo=" + SN;
ErpOutDetail.AddProduct(SN, '', item.Statu);
} else {
$.jBox.tip("该订单不能编辑", "warn");
}
} else if ($(e.target).is("a.audit")) {
var SN = item.OrdNo;
ErpOutManager.Detail(SN, "Audit");
} else if ($(e.target).is("a.view")) {
var SN = item.OrdNo;
ErpOutManager.Detail(SN, "View");
} else if ($(e.target).is("a.out")) {
if (item.Statu == "正在执行" || item.Statu == "执行完成") {
$.jBox.confirm("该订单数据正在执行或执行完成,不可重复出库!", "提示", submit1);
} else if (item.Statu == "等待执行") {
var SN = item.OrdNo;
var AccessCode = item.AccessCode;
var submit1 = function (v, h, f) {
if (v == "ok") {
var list = [];
list.push(SN);
var param = {};
param["list"] = JSON.stringify(list);
param["AccessCode"] = AccessCode;
var Server = ErpOutManager.Server();
Server.Out(param, function (result) {
if (result.Code == 1) {
var pageSize = $("#mypager").pager("GetPageSize");
ErpOutManager.PageClick(1, pageSize);
} else {
$.jBox.tip(result.Message, "success");
}
});
}
}
$.jBox.confirm("该操作将出库该订单所有托盘,确定要出库吗?", "提示", submit1);
}
}
else if ($(e.target).is("a.delete")) {
if (item.Statu == "正在执行" || item.Statu == "执行完成") {
$.jBox.confirm("该订单数据正在执行或执行完成,不可删除!", "提示", submit);
} else if (item.Statu == "等待执行" || item.Statu == "等待下发") {
var SN = item.OrdNo;
var submit = function (v, h, f) {
if (v == "ok") {
var list = [];
list.push(SN);
var param = {};
param["list"] = JSON.stringify(list);
var Server = ErpOutManager.Server();
Server.Delete(param, function (result) {
if (result.Code == 1) {
var pageSize = $("#mypager").pager("GetPageSize");
ErpOutManager.PageClick(1, pageSize);
} else {
$.jBox.tip(result.Message, "success");
}
});
}
}
$.jBox.confirm("该操作将删除该订单所有数据,确定要删除吗?", "提示", submit);
}
} else if ($(e.target).is("a.print")) {
// if (item.AuditFlag == "已审核") {
var SN = item.OrdNo;
$.jBox.open("get:/Business/ErpOut/ReportShow?ReportNo=出库单&OrdNo=" + SN, "打印", 1150, 700);
//window.location.href = "/Business/ErpOut/ReportShow?ReportNo=出库单&OrdNo=" + SN;
// }
// else { $.jBox.tip("该订单还未审核,或审核未通过,不可 编辑", "warn"); }
}
});
this.InTable.on('loadSuccess', function (e, data) {
LoadBtn.SetBtn();
});
},
GetSelect: function () {
var list = [];
if (this.InTable != undefined) {
var rows = this.InTable.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.InTable != undefined) {
var rows = this.InTable.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["OrdNo"] = searchBar.find("input[name='OrdNo']").val();
search["Statu"] = searchBar.find("select[name='Statu']").val();
search["AccessCode"] = searchBar.find("select[name='AccessCode']").val();
search["BatchNo"] = searchBar.find("input[name='BatchNo']").val();
search["BatchDemo"] = searchBar.find("input[name='BatchDemo']").val();
search["MatNo"] = searchBar.find("input[name='MatNo']").val();
search["MatName"] = searchBar.find("input[name='MatName']").val();
search["LingNo"] = searchBar.find("input[name='LingNo']").val();
search["TuNo"] = searchBar.find("input[name='TuNo']").val();
search["BeginTime"] = searchBar.find("input[name='BeginTime']").val();
search["EndTime"] = searchBar.find("input[name='EndTime']").val();
return search;
},
Detail: function (OrdNo, Command) {
var submit = function (v, h, f) {
if (v == "1") {
var list = [];
list.push(OrdNo);
var param = {};
param["list"] = JSON.stringify(list);
param["Operation"] = "AD02"; //审核不通过
var Server = ErpOutManager.Server();
Server.Audite(param, function (result) {
if (result.Code == 1) {
var pageSize = $("#mypager").pager("GetPageSize");
ErpOutManager.PageClick(1, pageSize);
$.jBox.close();
} else {
$.jBox.tip(result.Message, "info");
}
});
} else if (v == "2") {
var list = [];
list.push(OrdNo);
var param = {};
param["list"] = JSON.stringify(list);
param["Operation"] = "AD03"; //审核不通过
var Server = ErpOutManager.Server();
Server.Audite(param, function (result) {
if (result.Code == 1) {
var pageSize = $("#mypager").pager("GetPageSize");
ErpOutManager.PageClick(1, pageSize);
$.jBox.close();
} else {
$.jBox.tip(result.Message, "success");
}
});
} else if (v == "3") {
//打印
} else if (v == "4") {
$.jBox.close();
}
return false;
}
var TabGrid = undefined;
var SetTable = function (h, result) {
var cols = [
{
title: '生产令号', name: 'LingNo', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '图号', name: 'TuNo', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '序号', name: 'PageNo', width: 60, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '物料编码', name: 'MatCode', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '物料名称', name: 'MatName', width: 160, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '规格型号', name: 'PackFormat', width: 260, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '合格证', name: 'Certificate', width: 260, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '实出数量', name: 'CurQuant', width: 70, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '单位', name: 'Unit', width: 60, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '库位地址', name: 'LocationCode', width: 120, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '托盘号', name: 'Palno', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '领料人', name: 'PickerUser', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '备 注', name: 'Demo', width: 120, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
}
];
if (TabGrid == undefined) {
TabGrid = h.find('#tabDetail').mmGrid({
cols: cols,
items: result.Result.List,
checkCol: false,
nowrap: true,
height: 250
});
} else {
TabGrid.load(result.Result.List);
}
var pageInfo = result.PageInfo;
if (pageInfo != undefined) {
$("#myDetailPager").pager({ pagenumber: pageInfo.PageIndex, recordCount: pageInfo.RowCount, pageSize: pageInfo.PageSize, buttonClickCallback: function (PageIdex, PageSize) { PageClick(h, PageIdex, PageSize); } });
}
}
var load = function (h) {
PageClick(h, 1, 50);
}
var PageClick = function (h, PageIndex, PageSize) {
var Server = ErpOutManager.Server();
var search = {};
search["OrdNo"] = OrdNo;
if (PageIndex == undefined) {
PageIndex = h.find('#myDetailPager').pager("GetCurrent");
search["PageIndex"] = pageIndex;
}
else
search["PageIndex"] = PageIndex;
if (PageSize == undefined) {
PageSize = h.find('#myDetailPager').pager("GetCurrent");
search["PageSize"] = PageSize;
}
else
search["PageSize"] = PageSize;
Server.GetDetail(search, function (result) {
if (result.Code == 1) {
SetTable(h, result);
} else {
$.jBox.tip(result.Message, "warn");
}
});
}
if (Command == "View") {
$.jBox.open("get:/Business/ErpOut/Detail?OrdNo=" + OrdNo, "出库单详细", 850, 480, {
buttons: { "关闭": 4 }, submit: submit, loaded: function (h) {
load(h);
}
});
} else if (Command == "Audit") {
$.jBox.open("get:/Business/ErpOut/Detail?OrdNo=" + OrdNo, "入库单详细", 850, 480, {
buttons: { "审核通过": 1, "审核不通过": 2, "关闭": 4 }, submit: submit, loaded: function (h) {
load(h);
}
});
}
},
ToolBar: function () {
//工具栏按钮点击事件
$("div.toolbar").find("a.btn").click(function () {
var command = $(this).attr("data-command");
switch (command) {
case "Add":
ErpOutDetail.AddProduct();
break;
case "Input":
$('#excelFile').click();
break;
default: break;
}
});
//搜索 高级搜索按钮
var searchBar = $("div[data-condition='search']");
searchBar.find("a[data-command='search']").click(function () {
ErpOutManager.PageClick(1, 50);
});
$('#excelFile').on('change', function () {
ErpOutManager.ImportExcel();
});
//窗体加载获得焦点
searchBar.find("input[name='OrdNo']").focus();
//加载默认数据
ErpOutManager.PageClick(1, 50);
},
ImportExcel: function () {
var formData = new FormData();
var filename = $("#excelFile")[0].files[0];
if (filename == null || filename == "" || filename == "undefined") {
$.jBox.tip("请选择文件", "warn");
return;
} else {
formData.append('file', $("#excelFile")[0].files[0]); //将文件转成二进制形式
$.ajax({
type: "post",
url: "/Business/ErpOut/ExcelToUpload",//"/文件名/控制器名/控制器内方法"
async: false,
contentType: false, //这个一定要写
processData: false, //这个也一定要写,不然会报错
data: formData,
dataType: 'json', //返回类型
success: function (data) {
var submit = function () {
window.location.href = "/Business/ErpOut/Index";
}
$.jBox.confirm(data, "提示", submit);
},
})
}
},
}
var ErpOutDetail = {
Servers: function (URL, data, callback) {
$.gitAjax({
url: URL,
data: data,
type: "post",
dataType: "json",
success: function (result) {
callback(result);
}
});
},
BindTable: undefined,
BindTableEvent: function (staut) {
ErpOutDetail.BindTable.off("cellSelected").on("cellSelected", function (e, item, rowIndex, colIndex) {
if ($(e.target).is("a.delete")) {
var StoreGuid = item.StoreGuid;
var Guid = item.Guid;
var submit = function (v, h, f) {
if (v == "ok") {
var param = {};
param["StoreGuid"] = StoreGuid;
param["Guid"] = Guid;
ErpOutDetail.Servers("/Business/ErpOutAjax/DelProduct",
{ ajaxdata: JSON.stringify(param) },
function (result) {
if (result.Code == 1) {
var pageSize = $("#mypager1").pager("GetPageSize");
ErpOutDetail.SetTable(result);
} else {
$.jBox.tip(result.Message, "warn");
}
})
}
}
$.jBox.confirm("确定要删除吗?", "提示", submit);
}
else if ($(e.target).is("a.edit")) {
$('div.controls').find("#MatGuid").val(item.MatGuid);
$('div.controls').find("#StoreGuid").val(item.StoreGuid);
$('div.controls').find("#MatNo").val(item.MatNo);
$('div.controls').find("#CurQuant").val(item.CurQuant);
$('div.controls').find("#MatName").val(item.MatName);
$('div.controls').find("#Guid").val(item.Guid);
// 若属性没值不清空文本框
if (!git.IsEmpty(item.PickerUser)) {
$('div.controls').find("#PickerUser").val(item.PickerUser);
}
if (!git.IsEmpty(item.DetailDemo)) {
$('div.controls').find("#DetailDemo").val(item.DetailDemo);
}
}
});
},
SetTable: function (result) {
ErpOutDetail.BindTable.load(result.Result.List);
ErpOutDetail.BindTableEvent();
},
InitTable: function () {
var cols = [
{
title: '操作', name: 'Guid', width: 60, align: 'left', lockWidth: false, renderer: function (data, item, rowIndex) {
var html = "";
html += '编辑 ';
html += '删除 ';
return html;
}
},
{
title: '生产令号', name: 'LingNo', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '批次号', name: 'BatchNo', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '批次描述', name: 'BatchDemo', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '图号', name: 'TuNo', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '序号', name: 'PageNo', width: 60, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '合格证', name: 'Certificate', width: 60, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '物料编码', name: 'MatNo', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '物料名称', name: 'MatName', width: 180, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '出库数', name: 'CurQuant', width: 50, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '类型', name: 'MayType', width: 60, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '库位地址', name: 'LocationCode', width: 60, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '领料人', name: 'PickerUser', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
{
title: '备 注', name: 'DetailDemo', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
return data;
}
},
];
{
ErpOutDetail.BindTable = $("#tabList1").mmGrid({
cols: cols,
items: null,
indexCol: true,
checkCol: false,
nowrap: true,
height: 365
});
//绑定编辑 删除事件
ErpOutDetail.BindTableEvent();
}
},
EventBind: function () {
$('div.controls').find("#btnBind").click(function () {
// 物料编码验证
if (git.IsEmpty($('div.controls').find("#MatNo").val()) ||
git.IsEmpty($('div.controls').find("#MatGuid").val()) ||
git.IsEmpty($('div.controls').find("#StoreGuid").val())) {
$.jBox.tip("物料编码不能为空", "warn");
return false;
}
if (!git.checkInteger($('div.controls').find("#CurQuant").val())) {
$.jBox.tip("总数必须为数字", "warn");
return false;
}
if (git.IsEmpty($('div.controls').find("#CurQuant").val())) {
$.jBox.tip("总数不允许为空", "warn");
return false;
}
var param = {};
param["Guid"] = $('div.controls').find("#Guid").val();
param["MatGuid"] = $('div.controls').find("#MatGuid").val();
param["StoreGuid"] = $('div.controls').find("#StoreGuid").val();
param["CurQuant"] = $('div.controls').find("#CurQuant").val();
param["PickerUser"] = $('div.controls').find("#PickerUser").val();
param["DetailDemo"] = $('div.controls').find("#DetailDemo").val();
// 判断物料是否存在
ErpOutDetail.Servers("/Business/ErpOutAjax/IsCheckMatNum",
{ ajaxdata: JSON.stringify(param) }, function (result) {
if (result == null) {
$.jBox.tip("出库数量输入有误!", "warn");
return false;
}
else {
ErpOutDetail.Servers("/Business/ErpOutAjax/AddMat",
{ ajaxdata: JSON.stringify(param) },
function (result) {
if (result.Code == 1) {
ErpOutDetail.SetTable(result);
$('div.controls').find("#Guid").val("");
$('div.controls').find("#MatNo").val("");
$('div.controls').find("#MatName").val("");
$('div.controls').find("#MatGuid").val("");
$('div.controls').find("#StoreGuid").val("");
$('div.controls').find("#CurQuant").val("");
} else {
$.jBox.tip(result.Message, "warn");
}
})
}
});
});
ErpOutDetail.InitTable();
ErpOutDetail.Servers("/Business/ErpOutAjax/Init",
{ aaa: "" }, function (result) {
if (result.Code == 1) {
ErpOutDetail.SetTable(result);
} else {
$.jBox.tip(result.Message, "warn");
}
});
},
AddProduct: function (OrdNo, LingNo, Status, demo) {
var submit = function (v, h, f) {
if (v) {
var bl = true;
var data = {};
data["OrdNo"] = OrdNo;
data["Statu"] = Status;
data["AccessCode"] = h.find("select[name='AccessCode']").val();
data["Demo"] = h.find('input[name="Demo"]').val();
var PickerUser = h.find('input[name="PickerUser"]').val();
$.gitAjax({
async: false,
url: "/Business/ErpOutAjax/Add",
data: { entity: JSON.stringify(data), pickerUser: PickerUser },
type: "post",
dataType: "json",
success: function (result) {
if (result.Code == 1) {
// 刷新主页面
ErpOutManager.PageClick(1, 15);
}
else {
bl = false;
$.jBox.tip(result.Message, "warn");
}
}
});
return bl;
}
}
//对话框加载之后回调事件
var load = function (h) {
if (OrdNo != null) {
var entity = {};
entity["OrdNo"] = OrdNo;
entity["PageIndex"] = 1;
entity["PageSize"] = 10;
ErpOutDetail.Servers("/Business/ErpOutAjax/GetDetail",
{ ajaxdata: JSON.stringify(entity) },
function (result) {
if (result.Code == 1) {
//debugger
$('div.controls').find("#OrdNo").val(OrdNo);
//$('div.controls').find("#Demo").val(result.Result.List[0].Demo);
//$('div.controls').find("#BatchNo").val(result.Result.List[0].BatchNo);
//$('div.controls').find("#BatchDemo").val(result.Result.List[0].BatchDemo);
ErpOutDetail.SetTable(result);
} else {
$.jBox.tip(result.Message, "warn");
}
});
}
// 加载已选物料
h.find("input[name='MatNo']").SelMatDialog({
Mult: false,
callBack: function () {
ErpOutDetail.Servers("/Business/ErpOutAjax/GetMatNos",
{ ajaxdata: "" }, function (result) {
if (result != null) {
if (result.Code == 1) {
// 查询成功,绑定Table
ErpOutDetail.SetTable(result);
}
else {
$.jBox.tip("请选择出库物料!", "warn");
}
}
});
}
});
h.find("input[name='MatNo']").keydown(function (event) {
if (event.keyCode == 13) {
var value = $(this).val();
if (!git.IsEmpty(value)) {
//liudl 此处获取物料编码 10-04号
//ErpOutManager.DataInteractWay("/Business/ErpOutAjax/GetMatNos",
ErpOutDetail.Servers("/Business/ErpOutAjax/GetMatNo",
{
aaa: JSON.stringify({
MatNo: value,
PageIndex: 1,
PageSize: 10
})
},
function (result) {
//debugger
if (result != null) {
$('div.controls').find("#MatGuid").val(result.Result.Mat[0].MatGuid);
$('div.controls').find("#MatNo").val(result.Result.Mat[0].MatNo);
$('div.controls').find("#MatName").val(result.Result.Mat[0].MatName);
$('div.controls').find("#MatType").val(result.Result.Mat[0].MatType);
$('div.controls').find("#StoreGuid").val(result.Result.Mat[0].StoreGuid);
console.log(result.Result.Mat.length);
for (var i = 0; i < result.Result.Mat.length; i++) {
ErpOutDetail.Servers("/Business/ErpOutAjax/SelMatNos", { aaa: result.Result.Mat[i].StoreGuid },
function (result) {
if (result != null) {
if (result.Code == 1) {
// 查询成功,绑定Table
ErpOutDetail.SetTable(result);
}
else {
$.jBox.tip("请输入正确的出库物料!", "warn");
}
}
});
}
} else {
$('div.controls').find("#MatGuid").val("");
$('div.controls').find("#MatName").val("");
$('div.controls').find("#MatType").val("");
$.jBox.tip("物料编码不存在!", "warn");
}
});
h.find("input[name='LingNo']").focus();
}
}
});
}
//debugger
if (git.IsEmpty(OrdNo)) {
$.jBox.open("get:/Business/ErpOut/SetErpOutDetail", "新增出库单", 800, 590, { buttons: { "确定": true, "关闭": false }, top: '6%', submit: submit, loaded: load });
}
else {
var para = {};
para["OrdNo"] = OrdNo;
$.jBox.open("get:/Business/ErpOut/SetErpOutDetail?OrdNo=" + OrdNo, "编辑出库单", 800, 590, {
buttons: { "确定": true, "关闭": false }, top: '6%', submit: submit, loaded: load
});
//ErpOutDetail.Servers("/Business/ErpOutAjax/CheckOrdStatus",
// { ajaxdata: JSON.stringify(para) },
// function (result) {
// if (result.Code == 1) {
// $.jBox.open("get:/Business/ErpOut/SetErpOutDetail?OrdNo=" + OrdNo, "编辑出库单", 800, 590, { buttons: { "确定": true, "关闭": false }, top: '6%', submit: submit, loaded: load });
// } else {
// $.jBox.tip(result.Message, "warn");
// return false;
// }
//});
}
},
}