tg_small_v2.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. /*
  2. *2018-08-17
  3. *小件盒包装纸100x150
  4. */
  5. var LODOP; //声明为全局变量
  6. function prn1_print(html,qrcode) {
  7. CreateOneFormPage(html,qrcode);
  8. console.log(html);
  9. LODOP.PRINT();
  10. };
  11. function prn1_preview(html,qrcode) {
  12. CreateOneFormPage(html,qrcode);
  13. LODOP.PREVIEW();
  14. };
  15. function CreateOneFormPage(html,qrcode){
  16. LODOP.SET_LICENSES("","152A06E8F6CBD6AC1F213ABFCB0D8604","C94CEE276DB2187AE6B65D56B3FC2848","");
  17. LODOP=getLodop();
  18. LODOP.PRINT_INIT("河南中烟小件二维码打码");
  19. LODOP.SET_PRINT_STYLE("FontSize",16);
  20. LODOP.SET_PRINT_STYLE("Bold",1);
  21. //LODOP.ADD_PRINT_TEXT(30,40,350,45,"浙江美浓世纪集团有限公司");
  22. LODOP.ADD_PRINT_HTM(30,30,350,500,html);
  23. LODOP.SET_PRINT_STYLEA(1,"AngleOfPageInside",90);
  24. LODOP.SET_PRINT_STYLEA(0,"QRCodeErrorLevel","M");
  25. LODOP.ADD_PRINT_BARCODE(120,410,'40mm','40mm',"QRCode",qrcode);
  26. };
  27. function dateFamite(date) {
  28. return '20'+date.substr(0, 2)+'/'+date.substr(2, 2)+'/'+date.substr(4, 2);
  29. }
  30. function changetime(time) {
  31. var gtime=20000000;
  32. var times=parseInt(time)+parseInt(gtime);
  33. return times;
  34. }
  35. function getBathINo(code_cp1,bath_id) {
  36. var bath_no;
  37. if(bath_id.length<6){
  38. bath_no=code_cp1.substr(0, 6);
  39. for(i=0;i<(6-bath_id.length);i++){
  40. bath_no=bath_no+'0';
  41. }
  42. }
  43. bath_no= bath_no+bath_id;
  44. return bath_no;
  45. }
  46. //小件云打印数据处理
  47. function small_v2_print(result) {
  48. //data=result;
  49. //console.log(data.length);
  50. //var p=1;
  51. //for(j in data['smalllabel']) {
  52. // for(k in data['smalllabel'][j]){
  53. var html = template(document.getElementById('tpl').innerHTML, {
  54. /*custom_name: data['smalllabel'][j][k]['custom_name'],*/
  55. product_name:"红金龙(硬红火之舞)",
  56. // manufacture_date:data['smalllabel'][j][k]['manufacture_date'],
  57. manufacture_date:"190304",
  58. total:"4000",
  59. // print_date:data['smalllabel'][j][k]['print_date'],
  60. print_date:"190304",
  61. bach_no:"20198763"/*getBathINo(data['smalllabel'][j][k]['code_cp1'],data['smalllabel'][j][k]['bath_id'])*/,
  62. spec: "245mm*98mm",
  63. jianyan: '合 格',
  64. 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))),
  65. flow: '12',
  66. baozhuang:'32',
  67. jianyanhao: '22',
  68. benbaobanhao:'22'/*Number(data['smalllabel'][j][k]['banhao'].substr(6, 6))*/,
  69. ziliangpihao:"8765",
  70. supplier_name: "浙江美浓世纪集团有限公司",
  71. //qcode: './static/qrcode/none.png',//为了表格撑开
  72. });
  73. var qrcode='9202032522022311A111901292119012550040335';
  74. for(i=0;i<1;i++){
  75. //console.log(i);
  76. //console.log(123456);
  77. //console.log(html);
  78. /*if(p==1){
  79. console.log(p);
  80. prn1_preview(html,qrcode);//预览
  81. p=p+1;
  82. }
  83. */
  84. if(true){
  85. //为测试服务器,预览
  86. prn1_preview(html,qrcode);//预览
  87. }else if(window.location.host=="dm.7in6.com"){
  88. //为正式服务器,打印
  89. prn1_print(html,qrcode);//打印
  90. }else{
  91. prn1_preview(html,qrcode);//打印
  92. }
  93. // document.getElementById('wp').innerHTML = html;
  94. }
  95. // }
  96. // }
  97. };
  98. function toSubmit(){
  99. console.log('ok');
  100. //请求接口
  101. $.ajax({
  102. type:"POST",
  103. url:"2.php",
  104. success: function(result){
  105. //判断返回值,弹出用户提示
  106. small_v2_print(result);
  107. },
  108. error: function(e){
  109. swal("","网络延迟,稍后操作.");
  110. }
  111. })
  112. }