var ctx=$("meta[name='ctx']").attr("content"); /** * 批次打印 * * @param bthId * 批次id * @param tgTp * 大小签类别 * @param rePrn * 重复打印次数 * * @returns true:打印成功;false:打印失败 */ function printBth(bthId, tgTp, rePrn) { $('body').loading(); $.ajax({ type : "POST", url : ctx+"/scm/supplier/tgPrn/printBth", data : { "bthId" : bthId, "tgTp" : tgTp }, success : function(msg) { //$('body').loadend(); return PrintLabel(msg, rePrn); }, error : function() { $('body').loadend(); return false; }, dataType : "json" }); } /** * 勾选打印同一批次的标签 * * @param tgIds * 使用,分割的标签ids * @param tgTp * 大小签类别 * @param rePrn * 重复打印次数 * * @returns true:打印成功;false:打印失败 */ function printTg(tgIds, tgTp, rePrn) { /* alert("tgIds:" + tgIds); */ //$('body').loading(); $.ajax({ type : "POST", url : ctx+"/scm/supplier/tgPrn/printTg", data : { "tgIds" : tgIds, "tgTp" : tgTp }, dataType : "json", success : function(msg) { //$('body').loadend(); return PrintLabel(msg, rePrn); }, error : function() { $('body').loadend(); return false; }, }); } function printAly(alyTgDtlsId, rePrn) { /* alert("tgIds:" + tgIds); */ //$('body').loading(); $.ajax({ type : "POST", url : ctx+"/scm/supplier/tgPrn/printAly", data : { "alyTgDtlsId" : alyTgDtlsId, "reptQty":rePrn }, dataType : "json", success : function(msg) { //$('body').loadend(); return PrintLabel(msg, rePrn); }, error : function() { $('body').loadend(); return false; }, }); } /** * 标签打印方法,仅在主页面使用会加在滚动条,打印完成后会关闭滚动条 * * @param dataSource * 数据json串:{tgTmpl:"",scmTag:["1","2"]} * @param rePrn * 重复打印次数 * * @returns */ function PrintLabel(data, rePrn) { // openProgress(); //$('body').loading(); try { var LableTemplate = data.lableTemplate; var tags = data.lableData; if(LableTemplate!=null && tags!=null){ var obj = new ActiveXObject("PrintComponent.Simple"); obj.GetReportTemplate(LableTemplate); if (typeof (rePrn) == 'undefined') { rePrn = 1; } else { rePrn = parseInt(rePrn); } if (tags != null && tags.length > 0) { for (var i = 0; i < tags.length; i++) { var LableData = tags[i]; for (var j = 0; j < rePrn; j++) { obj.PrintGeneric(LableData); } } } } } catch (e) { alert('打印机加载错误,请检查IE设置!'); $('body').loadend(); return false; } $('body').loadend(); return true; }