|
|
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 '<div style="background-color:' + color + ';">' + data + '</div>'
|
////return '<div style="background-color:green;width:100%;height:100%"><span>aaaa</span></div>'
|
}
|
},
|
{
|
title: '显示屏ip地址', name: 'LedIP', width: 140, align: 'center', lockWidth: false, sortable: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '工位号', name: 'StationNum', width: 50, align: 'center', lockWidth: false, sortable: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: 'PLC偏移量', name: 'PlcPos', width: 100, align: 'center', lockWidth: false, sortable: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: 'WCS偏移量', name: 'WcsPos', width: 100, align: 'center', lockWidth: false, sortable: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '流程字类型', name: 'PosType', width: 100, align: 'center', lockWidth: false, sortable: false, renderer: function (data, item, rowIndex) {
|
return data;
|
}
|
},
|
{
|
title: '操作', name: 'ID', width: 100, align: 'left', lockWidth: false, renderer: function (data, item, rowIndex) {
|
var html = "";
|
html += '<a class="edit dis" href="javascript:void(0)">编辑 </a>';
|
html += '<a class="xiangqing dis" href="javascript:void(0)">详情 </a>';
|
return html;
|
}
|
},
|
];
|
|
|
if (this.UserGrid == undefined) {
|
this.UserGrid = $("#tabList").mmGrid({
|
cols: cols,
|
items: result.Result.List,
|
checkCol: true,
|
nowrap: true,
|
fullWidthRows: true,
|
remoteSort: true,
|
multiSelect: false,
|
height: ht
|
});
|
//绑定事件
|
ConveyorInfoManager.BindEvent();
|
} else {
|
this.UserGrid.load(result.Result.List);
|
}
|
var pageInfo = result.PageInfo;
|
if (pageInfo != undefined) {
|
$("#mypager").pager({ pagenumber: pageInfo.PageIndex, recordCount: pageInfo.RowCount, pageSize: pageInfo.PageSize, buttonClickCallback: ConveyorInfoManager.PageClick });
|
}
|
},
|
BindEvent: function () {
|
|
this.UserGrid.off("loadSuccess").on('loadSuccess', function (e, data) {
|
LoadBtn.SetBtn();
|
|
});
|
|
|
//编辑删除事件都绑定
|
this.UserGrid.off("cellSelected").on("cellSelected", function (e, item, rowIndex, colIndex) {
|
if ($(e.target).is("a.run")) {
|
var id = item.Id;
|
var submit = function (v, h, f) {
|
if (v === "ok") {
|
var list = [];
|
list.push(id);
|
var param = {};
|
param["list"] = JSON.stringify(list);
|
var Server = ConveyorInfoManager.Server();
|
Server.Run(param, function (result) {
|
$.jBox.tip(result.Message, "success");
|
var pageSize = $("#mypager").pager("GetPageSize");
|
ConveyorInfoManager.PageClick(1, pageSize);
|
});
|
}
|
}
|
$.jBox.confirm("执行当前输送线会关闭当前输送线其他物料类型信息,确定要执行当前信息吗?", "提示", submit);
|
} else if ($(e.target).is("a.del")) {
|
var id = item.Id;
|
var submit = function (v, h, f) {
|
if (v === "ok") {
|
var list = [];
|
list.push(id);
|
var param = {};
|
param["list"] = JSON.stringify(list);
|
var Server = ConveyorInfoManager.Server();
|
Server.Delete(param, function (result) {
|
$.jBox.tip(result.Message, "success");
|
var pageSize = $("#mypager").pager("GetPageSize");
|
ConveyorInfoManager.PageClick(1, pageSize);
|
});
|
}
|
}
|
$.jBox.confirm("确定要删除当前信息吗?", "提示", submit);
|
} else if ($(e.target).is("a.jiePi")) {
|
var id = item.Id;
|
console.log(id);
|
var submit = function (v, h, f) {
|
if (v === "ok") {
|
var list = [];
|
list.push(id);
|
var param = {};
|
param["list"] = JSON.stringify(list);
|
console.log(param)
|
var Server = ConveyorInfoManager.Server();
|
Server.JiePi(param, function (result) {
|
$.jBox.tip(result.Message, "success");
|
var pageSize = $("#mypager").pager("GetPageSize");
|
ConveyorInfoManager.PageClick(1, pageSize);
|
});
|
}
|
}
|
$.jBox.confirm("确定当前信息结批吗?", "提示", submit);
|
} else if ($(e.target).is("a.xiangqing")) {
|
var ID = item.Id;
|
ConveyorInfoManager.Dialog(ID, "XiangQing");
|
} else if ($(e.target).is("a.edit")) {
|
var ID = item.Id;
|
ConveyorInfoManager.Dialog(ID, "Edit");
|
}
|
});
|
},
|
GetSelect: function () {
|
var list = [];
|
if (this.UserGrid != undefined) {
|
var rows = this.UserGrid.selectedRows();
|
if (rows != undefined && rows.length > 0) {
|
for (var i = 0; i < rows.length; i++) {
|
list.push(rows[i].UserCode);
|
}
|
}
|
}
|
return list;
|
},
|
GetSearch: function () {
|
|
var searchBar = $("div[data-condition='search']");
|
|
var StationNum = searchBar.find("input[name='StationNum']").val();
|
var Text = searchBar.find("input[name='Text']").val();
|
|
var search = {};
|
search["StationNum"] = StationNum;
|
search["Text"] = Text;
|
|
return search;
|
},
|
ToolBar: function () {
|
|
//工具栏按钮点击事件
|
$("div.toolbar").find("a.btn").click(function () {
|
var command = $(this).attr("data-command");
|
|
if (command === "Add") {
|
ConveyorInfoManager.Dialog(undefined, command);
|
}
|
});
|
|
//搜索
|
var searchBar = $("div[data-condition='search']");
|
searchBar.find("a[data-command='search']").click(function () {
|
ConveyorInfoManager.PageClick(1, 15);
|
});
|
|
////监听回车事件,用于扫描
|
//$("input[name='UserCode']").keydown(function (event) {
|
// if (event.keyCode == 13) {
|
// var value = $(this).val(); UserChangePass
|
// if (!git.IsEmpty(value)) {
|
// ConveyorInfoManager.PageClick(1, 15);
|
// setTimeout(function () {
|
// $("input[name='UserCode']").val("");
|
// $("input[name='UserCode']").focus();
|
// }, 300);
|
// }
|
// }
|
//});
|
|
//$("input[name='UserCode']").focus();
|
//加载默认数据
|
ConveyorInfoManager.PageClick(1, 15);
|
}
|
};
|