/* *2018-08-17 *小件盒包装纸100x150 */ var LODOP; //声明为全局变量 function prn1_print(html,qrcode) { CreateOneFormPage(html,qrcode); console.log(html); LODOP.PRINT(); }; function prn1_preview(html,qrcode) { CreateOneFormPage(html,qrcode); LODOP.PREVIEW(); }; function CreateOneFormPage(html,qrcode){ LODOP.SET_LICENSES("","152A06E8F6CBD6AC1F213ABFCB0D8604","C94CEE276DB2187AE6B65D56B3FC2848",""); LODOP=getLodop(); LODOP.PRINT_INIT("河南中烟小件二维码打码"); LODOP.SET_PRINT_STYLE("FontSize",16); LODOP.SET_PRINT_STYLE("Bold",1); //LODOP.ADD_PRINT_TEXT(30,40,350,45,"浙江美浓世纪集团有限公司"); LODOP.ADD_PRINT_HTM(30,30,350,500,html); LODOP.SET_PRINT_STYLEA(1,"AngleOfPageInside",90); LODOP.SET_PRINT_STYLEA(0,"QRCodeErrorLevel","M"); LODOP.ADD_PRINT_BARCODE(120,410,'40mm','40mm',"QRCode",qrcode); }; function dateFamite(date) { return '20'+date.substr(0, 2)+'/'+date.substr(2, 2)+'/'+date.substr(4, 2); } function changetime(time) { var gtime=20000000; var times=parseInt(time)+parseInt(gtime); return times; } function getBathINo(code_cp1,bath_id) { var bath_no; if(bath_id.length<6){ bath_no=code_cp1.substr(0, 6); for(i=0;i<(6-bath_id.length);i++){ bath_no=bath_no+'0'; } } bath_no= bath_no+bath_id; return bath_no; } //小件云打印数据处理 function small_v2_print(result) { //data=result; //console.log(data.length); //var p=1; //for(j in data['smalllabel']) { // for(k in data['smalllabel'][j]){ var html = template(document.getElementById('tpl').innerHTML, { /*custom_name: data['smalllabel'][j][k]['custom_name'],*/ product_name:"红金龙(硬红火之舞)", // manufacture_date:data['smalllabel'][j][k]['manufacture_date'], manufacture_date:"190304", total:"4000", // print_date:data['smalllabel'][j][k]['print_date'], print_date:"190304", bach_no:"20198763"/*getBathINo(data['smalllabel'][j][k]['code_cp1'],data['smalllabel'][j][k]['bath_id'])*/, spec: "245mm*98mm", jianyan: '合 格', s_flow: "123",//Number(data['smalllabel'][j][k]['banhao'].substr(6, 6)) +'-'+ (data['smalllabel'][j][k]['id']>44091?Number(data['smalllabel'][j][k]['code_cp2'].substr(12, 6)):Number(data['smalllabel'][j][k]['code_cp1'].substr(6, 6))), flow: '12', baozhuang:'32', jianyanhao: '22', benbaobanhao:'22'/*Number(data['smalllabel'][j][k]['banhao'].substr(6, 6))*/, ziliangpihao:"8765", supplier_name: "浙江美浓世纪集团有限公司", //qcode: './static/qrcode/none.png',//为了表格撑开 }); var qrcode='9202032522022311A111901292119012550040335'; for(i=0;i<1;i++){ //console.log(i); //console.log(123456); //console.log(html); /*if(p==1){ console.log(p); prn1_preview(html,qrcode);//预览 p=p+1; } */ if(true){ //为测试服务器,预览 prn1_preview(html,qrcode);//预览 }else if(window.location.host=="dm.7in6.com"){ //为正式服务器,打印 prn1_print(html,qrcode);//打印 }else{ prn1_preview(html,qrcode);//打印 } // document.getElementById('wp').innerHTML = html; } // } // } }; function toSubmit(){ console.log('ok'); //请求接口 $.ajax({ type:"POST", url:"2.php", success: function(result){ //判断返回值,弹出用户提示 small_v2_print(result); }, error: function(e){ swal("","网络延迟,稍后操作."); } }) }