var ConveyorInfoManager = { UserGrid: undefined, Server: function () { var config = (function () { var URL_GetList = "/ConveyorInfoAjax/GetConveyorInfoRecordList"; var URL_Add = "/ConveyorInfoAjax/AddConveyorInfo"; var URL_Run = "/ConveyorInfoAjax/RunConveyorInfo"; var URL_JiePi = "/ConveyorInfoAjax/JiePiConveyorInfo"; var URL_Delete = "/ConveyorInfoAjax/DelConveyorInfo"; return { URL_GetList: URL_GetList, URL_Delete: URL_Delete, URL_Run: URL_Run, URL_Add: URL_Add, URL_JiePi: URL_JiePi, }; })(); //数据操作服务 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 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 Run = function (data, callback) { $.gitAjax({ url: config.URL_Run, data: 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 JiePi = function (data, callback) { $.gitAjax({ url: config.URL_JiePi, data: data, type: "post", dataType: "json", success: function (result) { if (callback != undefined && typeof callback == "function") { callback(result); } } }); } return { GetList: GetList, Delete: Delete, Run: Run, Add: Add, JiePi: JiePi } })($, config); return dataServer; }, Dialog: function (ID, Command) { var submit = function (v, h, f) { if (v) { var TaskNo = h.find('input[name="TaskNo"]').val(); var PalletNo = h.find('input[name="PalletNo"]').val(); var StartLocatNo = h.find('input[name="StartLocatNo"]').val(); var EndLocatNo = h.find('input[name="EndLocatNo"]').val(); var WcsPos = h.find('input[name="WcsPos"]').val(); if (git.IsEmpty(TaskNo)) { $.jBox.tip("请输入任务号", "warn"); return false; } if (git.IsEmpty(StartLocatNo)) { $.jBox.tip("请输入起始工位", "warn"); return false; } if (git.IsEmpty(EndLocatNo)) { $.jBox.tip("请输入目的工位", "warn"); return false; } if (git.IsEmpty(WcsPos)) { $.jBox.tip("请输入控制字", "warn"); return false; } var param = {}; param["Operation"] = Command; param["TaskNo"] = TaskNo; param["PalletNo"] = PalletNo; param["StartLocatNo"] = StartLocatNo; param["EndLocatNo"] = EndLocatNo; param["WcsPos"] = WcsPos; param["Id"] = ID; var Server = ConveyorInfoManager.Server(); Server.Add(param, function(result) { if (result.Code == 1) { var pageSize = $("#mypager").pager("GetPageSize"); var pageIndex = $("#mypager").pager("GetCurrent"); if (Command == "Add") { ConveyorInfoManager.PageClick(1, pageSize); } else if (Command == "Edit") { ConveyorInfoManager.Refresh(); } } else { $.jBox.tip(result.Message, "warn"); } }); } } console.log(Command); if (Command === "Add") { $.jBox.open("get:/Wcs/ConveyorInfo/AddConveyorInfo", "新增", 310, 320, { buttons: { "确定": true, "关闭": false }, submit: submit }); } else if (Command === "Edit") { $.jBox.open("get:/Wcs/ConveyorInfo/AddConveyorInfo?Id=" + ID, "编辑", 310, 320, { buttons: { "确定": true, "关闭": false }, submit: submit }); } else if (Command == "XiangQing") { //详情 $.jBox.open("get:/Wcs/ConveyorInfo/ConveyDetail?Id=" + ID, "详情", 620, 350, { buttons: { "关闭": false } }); } }, PageClick: function (PageIndex, PageSize) { $.jBox.tip("正在努力加载数据...", "loading"); var Server = ConveyorInfoManager.Server(); var search = ConveyorInfoManager.GetSearch(); search["PageIndex"] = PageIndex; search["PageSize"] = PageSize; //console.log(JSON.stringify(search)); Server.GetList(search, function (result) { ConveyorInfoManager.SetTable(result); $.jBox.closeTip(); }); }, Refresh: function () { var PageSize = $("#mypager").pager("GetPageSize"); var PageIndex = $("#mypager").pager("GetCurrent"); $.jBox.tip("正在努力加载数据...", "loading"); var Server = ConveyorInfoManager.Server(); var search = ConveyorInfoManager.GetSearch(); search["PageIndex"] = PageIndex; search["PageSize"] = PageSize; Server.GetList(search, function (result) { ConveyorInfoManager.SetTable(result); $.jBox.closeTip(); }); }, SetTable: function (result) { var ht = masterUI.MMGridHeight(); var cols = [ { title: '描述', name: 'Text', width: 140, align: 'center', lockWidth: false, sortable: false, renderer: function (data, item, rowIndex) { return data; } }, { title: '设备级别', name: 'Level', width: 100, align: 'center', lockWidth: false, sortable: false, renderer: function (data, item, rowIndex) { var str = ""; switch (data) { case "0": str = "IP级别"; break; case "1": str = "DB区域级别"; break; case "2": str = "工位号级别"; break; } return str; } }, { title: 'PLCIP地址', name: 'IP', width: 100, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) { return data; } }, { title: 'PLC状态', name: 'PlcStatusVal', width: 100, align: 'center', lockWidth: false, sortable: true, renderer: function (data, item, rowIndex) { var color = "#FFFFFF"; switch (data) { case "有货,不可放货": color = "#66CDAA"; break; case "空闲": color = "#228B22"; break; case "申请储位": color = "#2E8B57"; break; case "出库完成": color = "#8B8B7A"; break; case "堆垛机可以取货": color = "#8B6914"; break; case "堆垛机可以放货": color = "#CDAA7D"; break; case "连接PLC失败": color = "#FF0000"; break; default: } return '