var BarCodeManager = { PrintHtml: "", LogStoreList: undefined, Server: function () { var config = (function () { var URL_GetPalletNoList = "/BasicInfo/BarCodeAjax/GetPalletNoList"; var URL_GetPosList = "/BasicInfo/BarCodeAjax/GetPosList"; return { URL_GetPalletNoList: URL_GetPalletNoList, URL_GetPosList: URL_GetPosList, }; })(); //数据操作服务 var dataServer = (function ($, config) { //查询分页列表 var GetPalletNoList = function (data, callback) { $.gitAjax({ url: config.URL_GetPalletNoList, data: { ajaxdata: JSON.stringify(data) }, type: "post", dataType: "json", success: function (result) { if (callback != undefined && typeof callback == "function") { callback(result); } } }); } var GetPosList = function (callback) { $.gitAjax({ url: config.URL_GetPosList, //data: { ajaxdata: JSON.stringify(data) }, type: "post", dataType: "json", success: function (result) { if (callback != undefined && typeof callback == "function") { callback(result); } } }); } return { GetPalletNoList: GetPalletNoList, GetPosList: GetPosList, } })($, config); return dataServer; }, Print: function (printhtml) { var selfhtml = window.document.body.innerHTML;//获取当前页的html window.document.body.innerHTML = printhtml; window.print(); window.document.body.innerHTML = selfhtml; location.reload(); }, Prints: function (printhtml) { window.document.body.innerHTML = printhtml; window.print(); }, GetOneCodePic: function (code) { var printhtml; BarCodeManager.PreViewBarCode(1, code); printhtml = document.getElementById("printArea").innerHTML; BarCodeManager.Print(printhtml + printhtml); }, GetMulCodePic: function (type, count, SpecificationType) { var param = {}; param["count"] = count; param["type"] = type; param["SpecificationType"] = SpecificationType; BarCodeManager.Server().GetPalletNoList(param, function (result) { if (result.Code == 1) { var printhtml = ""; var selfhtml = window.document.body.innerHTML;//获取当前页的html for (var i = 0; i < result.Result.List.length; i++) { BarCodeManager.PreViewBarCode(2, result.Result.List[i].code); printhtml += document.getElementById("printArea").innerHTML; } BarCodeManager.Print(printhtml + printhtml); } else { $.jBox.tip(result.Message, "warn"); } }); }, GetMulPosCodePic: function (list) { var printhtml = ""; for (var i = 0; i < list.length; i++) { BarCodeManager.PreViewBarCode(3, list[i]); printhtml += document.getElementById("printArea1").innerHTML; } BarCodeManager.Print(printhtml); }, PreViewBarCode: function (index, code) { if (index == 1) $("#bcTarget").empty().barcode(code, "code128", { barWidth: 3, barHeight: 130, fontSize: 18, showHRI: true }); if (index == 2) $("#bcTarget").empty().barcode(code, "code128", { barWidth: 3, barHeight: 120, fontSize: 18, showHRI: true }); if (index == 3) $("#bcTarget1").empty().barcode(code, "code128", { barWidth: 3, barHeight: 120, fontSize: 18, showHRI: true }); }, PageClick: function () { var Server = BarCodeManager.Server(); Server.GetPosList(function (result) { $.jBox.closeTip(); if (result.Code == 1) { BarCodeManager.SetTable(result); } else { $.jBox.tip(result.Message, "warn"); } }); }, SetTable: function (result) { var cols = [ { title: '库位编码', name: 'LocationCode', width: 160, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) { return data; } }, { title: '排', name: 'LRow', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) { return data; } }, { title: '列', name: 'LColumn', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) { return data; } }, { title: '层', name: 'LLayer', width: 100, align: 'center', lockWidth: false, renderer: function (data, item, rowIndex) { return data; } }, { title: '操作', name: 'OrdNo', width: 40, align: 'left', lockWidth: false, renderer: function (data, item, rowIndex) { var html = ""; html += '打印标签 '; return html; } }, ]; var ht = masterUI.MMGridHeight(); if (this.LogStoreList == undefined) { this.LogStoreList = $("#tabList").mmGrid({ cols: cols, items: result.Result.List, checkCol: true, nowrap: true, fullWidthRows: true, multiSelect: true, height: ht+40 }); //绑定编辑 删除事件 BarCodeManager.BindEvent(); } else { this.LogStoreList.load(result.Result.List); } var pageInfo = result.PageInfo; if (pageInfo != undefined) { $("#mypager").pager({ pagenumber: pageInfo.PageIndex, recordCount: pageInfo.RowCount, pageSize: pageInfo.PageSize, buttonClickCallback: PalletEmptyInManager.PageClick }); } }, BindEvent: function () { this.LogStoreList.off("cellSelected").on("cellSelected", function (e, item, rowIndex, colIndex) { if ($(e.target).is("a.print")) { var locationCode = item.LocationCode; var list = []; list.push(locationCode); BarCodeManager.GetMulPosCodePic(list); location.reload(); } }); }, GetSelect: function () { var list = []; if (this.LogStoreList != undefined) { var rows = this.LogStoreList.selectedRows(); if (rows != undefined && rows.length > 0) { for (var i = 0; i < rows.length; i++) { list.push(rows[i].LocationCode); } } } return list; }, GetRows: function () { var list = []; if (this.LogStoreList != undefined) { var rows = this.LogStoreList.selectedRows(); if (rows != undefined && rows.length > 0) { for (var i = 0; i < rows.length; i++) { list.push(rows[i]); } } } return list; }, ToolBar: function () { var searchBar = $("div[data-condition='search']"); // 库位打印 searchBar.find("a[data-command='PosPrint']").click(function () { var list = BarCodeManager.GetSelect(); if (list.length <= 0) { $.jBox.tip("请选择要打印的库位!", "提示"); return false; } if (list.length >= 20) { $.jBox.tip("一次打印应少于20个标签!", "提示"); return false; } BarCodeManager.GetMulPosCodePic(list); }); // 无护栏托盘码打印 searchBar.find("a[data-command='MulPrintB']").click(function () { BarCodeManager.GetMulCodePic("B", 1); }); // 有护栏托盘码打印 searchBar.find("a[data-command='MulPrint']").click(function () { var SpecificationType = $("select[name='Specification']").val(); if (SpecificationType == "") { $.jBox.tip("请选择托盘护栏高度!", "提示"); return false; } BarCodeManager.GetMulCodePic("A", 1, SpecificationType); }); // 单个条码打印 searchBar.find("a[data-command='SinglePrint']").click(function () { var PalletNo = $("input[name='PalletNo']").val(); if (git.IsEmpty(PalletNo)) { $.jBox.tip("条码内容不能为空", "提示"); $("input[name='PalletNo']").val(""); return false; } BarCodeManager.GetOneCodePic(PalletNo); $("input[name='PalletNo']").val(""); }); BarCodeManager.PageClick(); }, }