var TaskItemsManager = { InTables: 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']"); //窗体加载获得焦点 TaskItemsManager.PageClick(1, 15); searchBar.find("input[name='MatNo']").focus(); searchBar.find('button[data-command="Search"]').unbind("click").bind("click", function (event) { TaskItemsManager.PageClick(1, 15); }); var btnClick = $("div.toolbar"); btnClick.find("a.btn").click(function () { var command = $(this).attr("data-command"); switch (command) { case "Edit": // 保存按钮 var param = CheckPalno.GetModel(); if (!param) { return false; } var Server = CheckManager.Server(); Server.Add(param, function (result) { if (result.Code == 1) { window.location.href = "/Business/CheckData/Index"; } else { $.jBox.tip(result.Message); } }); break; case "Delete": // 取消按钮 window.location.href = "/Business/CheckTask/Index"; break; default: break; } }) }, PageClick: function (PageIndex, PageSize) { $.jBox.tip("正在努力加载数据...", "loading"); var search = TaskItemsManager.GetSearch(); search["PageIndex"] = PageIndex; search["PageSize"] = PageSize; TaskItemsManager.Server("/Business/CheckTaskAjax/GetItems", { bbb: JSON.stringify(search) }, function (result) { $.jBox.closeTip(); if (result != null) { if (result.Code == 1) { // 查询成功,绑定Table TaskItemsManager.SetTable(result); } $.jBox.tip(result.Message, "warn"); } }); }, GetSearch: function () { var search = {}; var searchBar = $("div[data-condition='search']"); 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["Palno"] = searchBar.find("input[name='Palno1']").val(); return search; }, SetTable: function (result) { var cols = [ { title: '库位地址', name: 'LocationCode', width: 100, 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: 'LingNo', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) { return data; } }, { title: '物料编码', name: 'MatNo', width: 120, 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: 'Quant', width: 80, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) { return data; } }, { titleHtml: '实际数量', name: 'AQuant', width: 80, align: 'center', editable: true, lockWidth: false, renderer: function (data, item, rowIndex) { //return data; var html = ""; html += ''; return html; } }, { title: '包装规格', name: 'PackFormat', width: 160, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) { return data; } }, { title: '计量单位', name: 'UnitFrist', width: 55, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) { return data; } }, { title: '主键ID', name: 'Guid', width: 100, hidden: true, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) { return data; } }, { title: '任务主键ID', name: 'TaskID', width: 100, hidden: true, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) { return data; } }, ]; // 设置Table if (this.InTables == undefined) { var ht = masterUI.MMGridHeight()-70; this.InTables = $("#tabLists").mmGrid({ cols: cols, sortName: 'Palno', sortStatus: 'desc', items: result.Result.List, indexCol:true, nowrap: true, fullWidthRows: true, //indexCol:true, height: ht }); } else { this.InTables.load(result.Result.List); } }, SetItems: function (rowIndex) { if (TaskItemsManager.InTables != undefined) { var rows = TaskItemsManager.InTables.row(rowIndex); if (rows != undefined) { var search = {}; search["Guid"] = rows.Guid; search["AQuant"] = $("#cb" + rowIndex).val(); TaskItemsManager.Server("/Business/CheckTaskAjax/SetItems", { bbb: JSON.stringify(search) }, function (result) { if (result != null) { if (result.Code == -1) { $.jBox.tip(result.Message, "warn"); } } }); } } }, }