|
/**
|
*
|
*入库管理功能
|
*
|
**/
|
|
var PurManager = {
|
InTable: undefined,
|
Server: function () {
|
var config = (function () {
|
var URL_Add = "/Business/PurchaseAjax/Add";
|
|
var URL_LoadDetail = "/Business/PurchaseAjax/LoadDetail";
|
var URL_AddProduct = "/Business/PurchaseAjax/AddProduct";
|
var URL_DelProduct = "/Business/PurchaseAjax/DelProduct";
|
var URL_UpdateProduct = "/Business/PurchaseAjax/UpdateProduct";
|
|
|
var URL_GetList = "/Business/PurchaseAjax/GetPurchaseList";
|
var URL_GetDetail = "/Business/PurchaseAjax/GetPurchaseDetail";
|
var URL_Delete = "/Business/PurchaseAjax/Delete";
|
var URL_Close = "/Business/PurchaseAjax/Close";
|
var URL_Audite = "/Business/PurchaseAjax/Audite";
|
var URL_ToExcel = "/Business/PurchaseAjax/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,
|
};
|
})();
|
|
//数据操作服务
|
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 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,
|
}
|
|
})($, config);
|
return dataServer;
|
},
|
PageClick: function (PageIndex, PageSize) {
|
$.jBox.tip("正在努力加载数据...", "loading");
|
var Server = PurManager.Server();
|
var search = PurManager.GetSearch();
|
search["PageIndex"] = PageIndex;
|
search["PageSize"] = PageSize;
|
|
Server.GetList(search, function (result) {
|
$.jBox.closeTip();
|
if (result.Code == 1) {
|
PurManager.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 = PurManager.Server();
|
var search = PurManager.GetSearch();
|
search["PageIndex"] = PageIndex;
|
search["PageSize"] = PageSize;
|
Server.GetList(search, function (result) {
|
$.jBox.closeTip();
|
if (result.Code == 1) {
|
PurManager.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 += '<a class="edit dis" href="javascript:void(0)">编辑 </a>';
|
html += '<a class="audit dis" href="javascript:void(0)">审核 </a>';
|
html += '<a class="delete dis" href="javascript:void(0)">删除 </a>';
|
//}
|
html += '<a class="view" href="javascript:void(0)">查看</a> ';
|
html += '<a class="print" href="javascript:void(0)">打印</a> ';
|
return html;
|
}
|
},
|
{
|
title: '订单号', name: 'PurchaseNo', width: 125, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '项目号', name: 'ItemNo', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '项目名称', name: 'ItemName', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
//{
|
// title: '供应商', name: 'CusName', width: 150, 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: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return git.JsonToDateTime(data);
|
}
|
},
|
|
{
|
title: '完成时间', name: 'FinishTime', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return git.JsonToDateTime(data);
|
}
|
},
|
{
|
title: '审核状态', name: 'AuditFlag', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '审核人', name: 'AuditUser', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '审核时间', name: 'AuditTime', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return git.JsonToDateTime(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,
|
nowrap: true,
|
height: ht
|
});
|
//绑定编辑 删除事件
|
PurManager.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: PurManager.PageClick });
|
}
|
},
|
BindEvent: function () {
|
|
this.InTable.on('loadSuccess', function (e, data) {
|
LoadBtn.SetBtn();
|
});
|
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.PurchaseNo;
|
window.location.href = "/Business/Purchase/Add?PurchaseNo=" + SN;
|
//} else {
|
// $.jBox.tip("该订单不能编辑", "warn");
|
//}
|
} else if ($(e.target).is("a.audit")) {
|
var PurchaseNo = item.PurchaseNo;
|
var AuditFlag = item.AuditFlag;
|
if (AuditFlag == "已审核") {
|
$.jBox.tip("该项目已审核,无需再审核", "warn");
|
return false;
|
}
|
PurManager.Detail(PurchaseNo, "Audit");
|
//var submit = function (v, h, f) {
|
// if (v) {
|
// var list = [];
|
// list.push(PurchaseNo);
|
// var param = {};
|
// param["list"] = JSON.stringify(list);
|
// if (f.AuditMat == "Yes")
|
// param["Operation"] = "AD02";
|
// else if (f.AuditMat == "No")
|
// param["Operation"] = "AD03";
|
// var Server = PurManager.Server();
|
// Server.Audite(param, function (result) {
|
// $.jBox.tip(result.Message, "success");
|
// var pageSize = $("#mypager").pager("GetPageSize");
|
// PurManager.PageClick(1, pageSize);
|
// });
|
// }
|
//};
|
//var html = "<div style='padding: 20px; text-align: center'><input type='radio' name='AuditMat' class= 'input-medium' value = 'Yes' style='margin:0px 5px;'/>通过 <input type='radio' name='AuditMat' class= 'input-medium' value = 'No' style='margin:0px 5px 0px 20px;'/>拒绝</div> ";
|
|
//$.jBox(html, { title: "审核物料", buttons: { "确定": true, "取消": false }, submit: submit });
|
} else if ($(e.target).is("a.view")) {
|
var SN = item.PurchaseNo;
|
PurManager.Detail(SN, "View");
|
} else if ($(e.target).is("a.delete")) {
|
//if (item.Statu == "等待执行" || item.Statu == "等待下发") {
|
var SN = item.PurchaseNo;
|
var submit = function (v, h, f) {
|
if (v == "ok") {
|
var list = [];
|
list.push(SN);
|
var param = {};
|
param["list"] = JSON.stringify(list);
|
var Server = PurManager.Server();
|
Server.Delete(param, function (result) {
|
if (result.Code == 1) {
|
var pageSize = $("#mypager").pager("GetPageSize");
|
PurManager.PageClick(1, pageSize);
|
} else {
|
$.jBox.tip(result.Message, "success");
|
}
|
});
|
}
|
}
|
$.jBox.confirm("该操作将删除该订单所有数据,确定要删除吗?", "提示", submit);
|
//}
|
} else if ($(e.target).is("a.print")) {
|
//var SN = item.OrdNo;
|
|
var SN = item.PurchaseNo;
|
window.location.href = "/Business/Purchase/ReportShow?ReportNo=采购单2&OrdNo=" + SN;
|
}
|
});
|
|
|
|
},
|
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].PurchaseNo);
|
}
|
}
|
}
|
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 searchBar = $("div[data-condition='search']");
|
|
var PurchaseNo = searchBar.find("input[name='PurchaseNo']").val();
|
var ItemNo = searchBar.find("input[name='ItemNo']").val();
|
var ItemName = searchBar.find("input[name='ItemName']").val();
|
var Audit = searchBar.find("select[name='Audit']").val();
|
|
var BeCreateTime = searchBar.find("input[name='BeCreateTime']").val();
|
var EnCreateTime = searchBar.find("input[name='EnCreateTime']").val();
|
|
var BeFinishTime = searchBar.find("input[name='BeFinishTime']").val();
|
var EnFinishTime = searchBar.find("input[name='EnFinishTime']").val();
|
|
var search = {};
|
|
search["PurchaseNo"] = PurchaseNo;
|
search["ItemNo"] = ItemNo;
|
search["ItemName"] = ItemName;
|
search["AuditFlag"] = Audit;
|
|
search["BeCreateTime"] = BeCreateTime;
|
search["EnCreateTime"] = EnCreateTime;
|
|
search["BeFinishTime"] = BeFinishTime;
|
search["EnFinishTime"] = EnFinishTime;
|
|
|
return search;
|
},
|
Detail: function (PurchaseNo, Commad) {
|
var submit = function (v, h, f) {
|
if (v == "1") {
|
|
var submit = function (v, h, f) {
|
if (v) {
|
var list = [];
|
list.push(PurchaseNo);
|
var param = {};
|
param["list"] = JSON.stringify(list);
|
param["Operation"] = "AD02"; //审核通过
|
param["Reason"] = Reason;
|
var Server = PurManager.Server();
|
Server.Audite(param, function (result) {
|
if (result.Code == 1) {
|
var pageSize = $("#mypager").pager("GetPageSize");
|
PurManager.PageClick(1, pageSize);
|
$.jBox.close();
|
} else {
|
$.jBox.tip(result.Message, "info");
|
}
|
});
|
}
|
|
}
|
|
var html = "<div style='padding: 20px; text-align: center'>您确定通过该订单审核吗?</div> ";
|
|
$.jBox(html, { title: "提示信息", buttons: { "确定": true, "取消": false }, submit: submit });
|
} else if (v == "2") {
|
|
|
var submit = function (v, h, f) {
|
if (v) {
|
var list = [];
|
list.push(PurchaseNo);
|
var param = {};
|
param["list"] = JSON.stringify(list);
|
param["Operation"] = "AD03"; //审核不通过
|
//param["Reason"] = Reason;
|
var Server = PurManager.Server();
|
Server.Audite(param, function (result) {
|
if (result.Code == 1) {
|
var pageSize = $("#mypager").pager("GetPageSize");
|
PurManager.PageClick(1, pageSize);
|
$.jBox.close();
|
} else {
|
$.jBox.tip(result.Message, "success");
|
}
|
});
|
}
|
|
|
}
|
var html = "<div style='padding: 20px; text-align: center'>您确定不通过该订单审核吗?</div> ";
|
|
$.jBox(html, { title: "提示信息", buttons: { "确定": true, "取消": false }, submit: submit });
|
|
} else if (v == "3") {
|
//打印
|
} else if (v == "4") {
|
$.jBox.close();
|
}
|
return false;
|
}
|
|
var TabGrid = undefined;
|
var SetTable = function (h, result) {
|
var cols = [
|
{
|
title: '物料编码', name: 'MatNo', width: 70, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '物料名称', name: 'MatName', width: 120, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '规格型号', name: 'PackFormat', width: 150, 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: 'Demo_21', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '单台数量', name: 'Quant_Unit', width: 60, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '总数量', name: 'Quant_Total', width: 60, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '采购数量', name: 'Quant_Buy', width: 60, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '采购人员', name: 'BuyUser', width: 60, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '备注', name: 'Demo_11', width: 350, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
|
];
|
|
if (TabGrid == undefined) {
|
var ht = masterUI.MMGridHeight();
|
TabGrid = h.find('#tabDetail').mmGrid({
|
cols: cols,
|
items: result.Result.List,
|
checkCol: false,
|
nowrap: true,
|
height: 200
|
});
|
} 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,5);
|
}
|
|
var PageClick = function (h,PageIndex, PageSize) {
|
var Server = PurManager.Server();
|
var search = {};
|
search["PurchaseNo"] = PurchaseNo;
|
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 (Commad == "View") {
|
$.jBox.open("get:/Business/Purchase/Detail?PurchaseNo=" + PurchaseNo, "采购单详细", 850, 480, {
|
buttons: { "关闭": 4 }, submit: submit, loaded: function (h) {
|
load(h);
|
}
|
});
|
}
|
else if (Commad == "Audit") {
|
$.jBox.open("get:/Business/Purchase/Detail?PurchaseNo=" + PurchaseNo, "采购单审核", 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");
|
|
if (command == "Add") {
|
window.location.href = "/Business/Purchase/Add";
|
} else if (command == "Edit") {
|
var list = PurManager.GetRows();
|
if (list.length == 0) {
|
$.jBox.tip("请选择要编辑的项", "warn");
|
return false;
|
}
|
var item = list[0];
|
//if (item.Statu == "等待执行" || item.Statu == "等待下发"){
|
var SN = item.PurchaseNo;
|
window.location.href = "/Business/Purchase/Add?PurchaseNo=" + SN;
|
//} else {
|
// $.jBox.tip("该订单不能编辑", "warn");
|
//}
|
} else if (command == "Delete") {
|
var submit = function (v, h, f) {
|
if (v == "ok") {
|
var list = PurManager.GetSelect();
|
if (list.length == 0) {
|
$.jBox.tip("请选择要删除的项", "warn");
|
return false;
|
}
|
var param = {};
|
param["list"] = JSON.stringify(list);
|
var Server = PurManager.Server();
|
Server.Delete(param, function (result) {
|
if (result.Code == 1) {
|
var pageSize = $("#mypager").pager("GetPageSize");
|
PurManager.PageClick(1, pageSize);
|
} else {
|
$.jBox.tip(result.Message, "warn");
|
}
|
});
|
}
|
}
|
$.jBox.confirm("该操作将删除该订单所有数据,确定要删除吗?", "提示", submit);
|
|
} else if (command == "Excel") {
|
var Server = PurManager.Server();
|
var search = PurManager.GetSearch();
|
Server.ToExcel(search, function (result) {
|
|
if (result.Code == 1000) {
|
var path = unescape(result.Message);
|
window.location.href = path;
|
} else {
|
$.jBox.info(result.Message, "提示");
|
}
|
});
|
} else if (command == "Refresh") {
|
PurManager.Refresh();
|
} else if (command == "Audit") {
|
PurManager.Audit();
|
} else if (command == "CloseBill") {
|
PurManager.Close();
|
}
|
|
});
|
|
//搜索 高级搜索按钮
|
var searchBar = $("div[data-condition='search']");
|
searchBar.find("a[data-command='search']").click(function () {
|
PurManager.PageClick(1, 10);
|
});
|
|
|
//监听回车事件,用于扫描
|
searchBar.find("input[name='OrdNo']").keydown(function (event) {
|
if (event.keyCode == 13) {
|
var value = $(this).val();
|
if (!git.IsEmpty(value)) {
|
PurManager.PageClick(1, 10);
|
setTimeout(function () {
|
searchBar.find("input[name='ItemNo']").val("");
|
searchBar.find("input[name='ItemNo']").focus();
|
}, 300);
|
}
|
}
|
});
|
|
//窗体加载获得焦点
|
//searchBar.find("input[name='ItemNo']").focus();
|
//加载默认数据
|
PurManager.PageClick(1, 10);
|
}
|
}
|
|
|
|
var PurProduct = {
|
Init: function () {
|
|
//初始化绑定事件
|
$("div.formbtn").find("button.btn").click(function (event) {
|
var command = $(this).attr("data-command");
|
if (command == "Add") {
|
PurProduct.AddProduct("", "Add");
|
} else if (command == "Save") {
|
var param = PurProduct.GetModel();
|
if (!param) {
|
return false;
|
}
|
var Server = PurManager.Server();
|
Server.Add(param, function (result) {
|
if (result.Code == 1) {
|
window.location.href = "/Business/Purchase/GetList";
|
} else {
|
$.jBox.tip(result.Message);
|
}
|
});
|
|
} else if (command == "Cancel") {
|
window.location.href = "/Business/Purchase/GetList";
|
} else if (command == "SetBuyUser") {
|
var list = [];
|
|
if (PurProduct.TabGrid != undefined) {
|
var rows = PurProduct.TabGrid.selectedRows();
|
if (rows != undefined && rows.length > 0) {
|
for (var i = 0; i < rows.length; i++) {
|
|
list.push(rows[i].MatNo);
|
|
}
|
}
|
}
|
|
|
if (list.length == 0) {
|
$.jBox.tip("请选择要操作的项", "warn");
|
return false;
|
}
|
|
var submit = function (v, h, f) {
|
if (v) {
|
var BuyUser = $("input[name='sBuyUser']").val();
|
|
if (git.IsEmpty(BuyUser)) {
|
$.jBox.tip("指定的采购人员不可为空", "warn")
|
return false;
|
}
|
|
var param = {};
|
param["list"] = JSON.stringify(list);
|
//param["Operation"] = "SetBuyUser";
|
param["setBuyUser"] = BuyUser;
|
|
var para = {}
|
param["ajaxdata"] = JSON.stringify(param);;
|
|
var Server = PurManager.Server();
|
Server.UpdateProduct(param, function (result) {
|
$.jBox.tip(result.Message, "success");
|
//var pageSize = $("#mypager").pager("GetPageSize");
|
PurProduct.PageClick(1, 5);
|
});
|
}
|
};
|
var html = "<div style='padding: 20px; text-align: center'><input type='text' name='sBuyUser' class= 'input-medium' /></div> ";
|
|
$.jBox(html, { title: "指定采购员", buttons: { "确定": true, "取消": false }, submit: submit });
|
}
|
});
|
|
////选择供应商
|
//$("input[name='CusNum']").SupplierDialog({
|
// Mult: false, callBack: function (result) {
|
// if (result != undefined) {
|
// $("input[name='CusNum']").val(result.CusNum);
|
// $("input[name='CusName']").val(result.CusName);
|
// $("input[name='Contacts']").val(result.Contacts);
|
// $("input[name='Phone']").val(result.Phone);
|
|
// //如果值发生变化
|
// $("input[name='CusNum']").unbind("change").bind("change", function () {
|
// var value = $(this).val();
|
// if (value != result.SupNum) {
|
// $("input[name='CusSnNum']").val();
|
// $("input[name='CusName']").val();
|
// $("input[name='Contacts']").val();
|
// $("input[name='Phone']").val();
|
// }
|
// });
|
// }
|
// }
|
//});
|
|
////自动提示供应商搜索
|
//$("input[name='CusNum']").autocomplete({
|
// paramName: "CusNum",
|
// url: '/BasicInfo/CustomerAjax/Auto',
|
// showResult: function (value, data) {
|
// var row = JSON.parse(value);
|
// return '<span>' + row.CusNum + " " + row.CusName + '</span>';
|
// },
|
// onItemSelect: function (item) {
|
|
// },
|
// maxItemsToShow: 5,
|
// selectedCallback: function (selectItem) {
|
// $("input[name='CusNum']").val(selectItem.CusNum);
|
// $("input[name='CusName']").val(selectItem.CusName);
|
// $("input[name='Contacts']").val(selectItem.Contacts);
|
// $("input[name='Phone']").val(selectItem.Phone);
|
// }
|
//});
|
|
|
PurProduct.PageClick(1, 10);
|
},
|
PageClick: function (PageIndex, PageSize) {
|
var Server = PurManager.Server();
|
var search = {};
|
search["PageIndex"] = PageIndex;
|
search["PageSize"] = PageSize;
|
Server.LoadDetail(search, function (result) {
|
PurProduct.SetTable(result);
|
});
|
},
|
SetTable: function (result) {
|
var cols = [
|
{
|
title: '物料编码', name: 'MatNo', width: 120, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '物料名称', name: 'MatName', width: 150, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '品牌', name: 'Demo_21', width: 150, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '规格型号', name: 'PackFormat', width: 150, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '计量单位', name: 'Unit', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '单台数量', name: 'Quant_Unit', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '总数量', name: 'Quant_Total', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '采购数量', name: 'Quant_Buy', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '采购人员', name: 'BuyUser', width: 80, 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;
|
}
|
},
|
|
{
|
title: '操作', name: 'Operation', width: 120, align: 'left', lockWidth: false, renderer: function (data, item, rowIndex) {
|
var html = "";
|
html += '<a class="edit" href="javascript:void(0)">编辑</a> ';
|
html += '<a class="delete" href="javascript:void(0)">删除</a> ';
|
return html;
|
}
|
},
|
];
|
|
if (this.TabGrid == undefined) {
|
var ht = masterUI.MMGridHeight();
|
this.TabGrid = $("#tabList").mmGrid({
|
multiSelect: true,
|
cols: cols,
|
items: result.Result.List,
|
checkCol: true,
|
nowrap: true,
|
height: ht
|
});
|
PurProduct.BindTableEvent();
|
} else {
|
this.TabGrid.load(result.Result.List);
|
}
|
|
var pageInfo = result.PageInfo;
|
if (pageInfo != undefined) {
|
$("#mypager").pager({ pagenumber: pageInfo.PageIndex, recordCount: pageInfo.RowCount, pageSize: pageInfo.PageSize, buttonClickCallback: PurProduct.PageClick });
|
}
|
},
|
BindTableEvent: function () {
|
this.TabGrid.off("cellSelected").on("cellSelected", function (e, item, rowIndex, colIndex) {
|
if ($(e.target).is("a.delete")) {
|
var MatNo = item.MatNo;
|
var submit = function (v, h, f) {
|
if (v == "ok") {
|
|
var param = {};
|
param["MatNo"] = MatNo;
|
var Server = PurManager.Server();
|
Server.DelProduct(param, function (result) {
|
if (result.Code == 1) {
|
var pageSize = $("#mypager").pager("GetPageSize");
|
PurProduct.PageClick(1, pageSize);
|
} else {
|
$.jBox.tip(result.Message, "warn");
|
}
|
});
|
}
|
}
|
$.jBox.confirm("确定要删除吗?", "提示", submit);
|
} else if ($(e.target).is("a.edit")) {
|
var MatNo = item.MatNo;
|
PurProduct.AddProduct(MatNo,"Eidt");
|
}
|
});
|
},
|
AddProduct: function (MatNo,Operation) {
|
var submit = function (v, h, f) {
|
if (v) {
|
|
var MatNo = h.find("input[name='MatNo']").val();
|
var MatName = h.find("input[name='MatName']").val();
|
var PackFormat = h.find("input[name='PackFormat']").val();
|
var Unit = h.find("input[name='Unit']").val();
|
var Quant_Unit = h.find("input[name='Quant_Unit']").val();
|
var Quant_Total = h.find("input[name='Quant_Total']").val();
|
var Quant_Buy = h.find("input[name='Quant_Buy']").val();
|
var BuyUser = h.find("input[name='BuyUser']").val();
|
var Demo1 = h.find("input[name='Demo1']").val();
|
var Demo = h.find("input[name='Demo']").val();
|
|
if (git.IsEmpty(MatNo) || git.IsEmpty(MatNo)) {
|
$.jBox.tip("请选择物料编码", "warn");
|
return false;
|
}
|
if (git.IsEmpty(MatName) || git.IsEmpty(MatName)) {
|
$.jBox.tip("请选择物料名称", "warn");
|
return false;
|
}
|
|
if (git.IsEmpty(PackFormat) || git.IsEmpty(PackFormat)) {
|
$.jBox.tip("请选择物料规格型号", "warn");
|
return false;
|
}
|
|
if (git.IsEmpty(Unit) || git.IsEmpty(Unit)) {
|
$.jBox.tip("请选择物料计量单位", "warn");
|
return false;
|
}
|
|
if (git.checkNum(Quant_Unit)) {
|
$.jBox.tip("单台数量必须为数字", "warn");
|
return false;
|
}
|
|
if (git.checkNum(Quant_Total)) {
|
$.jBox.tip("总数量必须为数字", "warn");
|
return false;
|
}
|
|
if (git.checkNum(Quant_Buy)) {
|
$.jBox.tip("采购数量必须为数字", "warn");
|
return false;
|
}
|
|
if (parseInt(Quant_Buy)> parseInt(Quant_Total))
|
{
|
$.jBox.tip("采购数量不可大与总数量", "warn");
|
return false;
|
}
|
|
var param = {};
|
param["MatNo"] = MatNo;
|
param["MatName"] = MatName;
|
param["PackFormat"] = PackFormat;
|
param["Unit"] = Unit;
|
param["Quant_Unit"] = Quant_Unit;
|
param["Quant_Total"] = Quant_Total;
|
param["Quant_Buy"] = Quant_Buy;
|
param["BuyUser"] = BuyUser;
|
param["Demo"] = Demo;
|
param["Demo1"] = Demo1;
|
param["Operation"] = Operation;
|
|
var entity = {};
|
entity["Entity"] = JSON.stringify(param);
|
|
var Server = PurManager.Server();
|
Server.AddProduct(entity, function (result) {
|
if (result.Code == 1) {
|
PurProduct.PageClick(1, 5);
|
} else {
|
$.jBox.tip(result.Message, "warn");
|
}
|
});
|
}
|
}
|
|
//对话框加载之后回调事件
|
var load = function (h) {
|
h.find("input[name='MatNo']").ProductDialog({
|
Mult: false,
|
callBack: function (result) {
|
h.find("input[name='MatNo']").val(result.MatNo);
|
h.find("input[name='MatName']").val(result.MatName);
|
h.find("input[name='PackFormat']").val(result.PackFormat);
|
h.find("input[name='Unit']").val(result.UnitFrist);
|
//h.find("input[name='Unit']").val(result.UnitFrist);
|
h.find("input[name='Demo1']").val(result.Demo1);
|
//h.find("input[name='PlanQuant']").val(result.PlanQuant);
|
//h.find("input[name='Demo']").val(result.Demo);
|
}
|
});
|
|
|
|
//h.find("input[name='MatNo']").autocomplete({
|
// paramName: "MatNo",
|
// url: '/MatAjax/Auto',
|
// showResult: function (value, data) {
|
// var row = JSON.parse(value);
|
// return '<span>' + row.MatNo + " " + row.MatName + '</span>';
|
// },
|
// onItemSelect: function (item) {
|
|
// },
|
// maxItemsToShow: 5,
|
// selectedCallback: function (selectItem) {
|
// $("input[name='MatNo']").val(selectItem.MatNo);
|
// $("input[name='MatName']").val(selectItem.MatName);
|
// $("input[name='PackFormat']").val(selectItem.PackFormat);
|
// $("input[name='Unit']").val(selectItem.UnitFrist);
|
// $("input[name='Demo1']").val(selectItem.Demo1);
|
// }
|
//});
|
|
}
|
|
|
if (git.IsEmpty(MatNo)) {
|
$.jBox.open("get:/Business/Purchase/AddProduct", "新增产品", 350, 510, { buttons: { "确定": true, "关闭": false }, submit: submit, loaded: load });
|
} else {
|
$.jBox.open("get:/Business/Purchase/AddProduct?MatNo=" + MatNo, "编辑产品", 350, 510, { buttons: { "确定": true, "关闭": false }, submit: submit, loaded: load });
|
}
|
},
|
GetModel: function () {
|
|
|
var PurchaseNo = $("input[name='PurchaseNo']").val();
|
var ItemNo = $("input[name='ItemNo']").val();
|
var ItemName = $("input[name='ItemName']").val();
|
var FinishTime = $("input[name='FinishTime']").val();
|
//var Contacts = $("input[name='Contacts']").val();
|
//var Phone = $("input[name='Phone']").val();
|
var Demo = $("input[name='Remark']").val();
|
|
//校验
|
//if (git.IsEmpty(ItemNo)) {
|
// $.jBox.tip("请输入采购单项目编号", "warn");
|
// return false;
|
//}
|
|
if (git.IsEmpty(ItemName)) {
|
$.jBox.tip("请输入采购单项目名称", "warn");
|
return false;
|
}
|
|
if (git.IsEmpty(FinishTime)) {
|
$.jBox.tip("请输入采购单完成时间", "warn");
|
return false;
|
}
|
|
var param = {};
|
|
param["PurchaseNo"] = PurchaseNo;
|
param["ItemNo"] = ItemNo;
|
param["ItemName"] = ItemName;
|
param["FinishTime"] = FinishTime;
|
//param["Contacts"] = Contacts;
|
//param["Phone"] = Phone;
|
param["Demo"] = Demo;
|
|
var entity = {};
|
|
entity["Entity"] = JSON.stringify(param);
|
|
return entity;
|
}
|
}
|