tg_small_v011.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*
  2. *2018-08-17
  3. *小件盒包装纸100x150
  4. */
  5. var LODOP; //声明为全局变量
  6. function prn1_print(html,qrcode,l_flow) {
  7. CreateOneFormPage(html,qrcode,l_flow);
  8. console.log(html);
  9. LODOP.PRINT();
  10. };
  11. function prn1_preview(html,qrcode,l_flow) {
  12. CreateOneFormPage(html,qrcode,l_flow);
  13. LODOP.PREVIEW();
  14. };
  15. function CreateOneFormPage(html,qrcode,l_flow){
  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(0,"QRCodeErrorLevel","M");
  24. LODOP.ADD_PRINT_BARCODE(320,30,'70mm','70mm',"QRCode",qrcode);
  25. LODOP.ADD_PRINT_TEXT(400,260,80,80,"大件号"+l_flow);
  26. LODOP.SET_PRINT_STYLEA(0,"FontName","宋体");
  27. LODOP.SET_PRINT_STYLEA(0,"FontSize",16);
  28. LODOP.SET_PRINT_STYLEA(0,"FontColor","#000000");
  29. LODOP.SET_PRINT_STYLEA(0,"Bold",1);
  30. };
  31. function dateFamite(date) {
  32. return '20'+date.substr(0, 2)+'/'+date.substr(2, 2)+'/'+date.substr(4, 2);
  33. }
  34. function changetime(time) {
  35. var gtime=20000000;
  36. var times=parseInt(time)+parseInt(gtime);
  37. return times;
  38. }
  39. function getBathINo(code_cp1,bath_id) {
  40. var bath_no;
  41. if(bath_id.length<6){
  42. bath_no=code_cp1.substr(0, 6);
  43. for(i=0;i<(6-bath_id.length);i++){
  44. bath_no=bath_no+'0';
  45. }
  46. }
  47. bath_no= bath_no+bath_id;
  48. return bath_no;
  49. }
  50. //小件云打印数据处理
  51. function small_v010_print(result) {
  52. data=result;
  53. console.log(data);
  54. var p=1;
  55. for(j in data['smalllabel']) {
  56. for(k in data['smalllabel'][j]){
  57. var html = template(document.getElementById('tpl').innerHTML, {
  58. /*custom_name: data['smalllabel'][j][k]['custom_name'],*/
  59. product_name: data['smalllabel'][j][k]['matter_name'],
  60. // manufacture_date:data['smalllabel'][j][k]['manufacture_date'],
  61. manufacture_date:dateFamite(data['smalllabel'][j][k]['manufacture_date']),
  62. total:data['smalllabel'][j][k]['box_num'],
  63. l_flow:data['smalllabel'][j][k]['l_flow'],
  64. // print_date:data['smalllabel'][j][k]['print_date'],
  65. print_date:dateFamite(data['smalllabel'][j][k]['print_date']),
  66. bach_no:data['smalllabel'][j][k]['bach_num'] /*getBathINo(data['smalllabel'][j][k]['code_cp1'],data['smalllabel'][j][k]['bath_id'])*/,
  67. spec: data['smalllabel'][j][k]['matter_size'],
  68. jianyan: '合 格',
  69. s_flow: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))),
  70. flow: '',
  71. baozhuang:'',
  72. jianyanhao: '',
  73. benbaobanhao:''/*Number(data['smalllabel'][j][k]['banhao'].substr(6, 6))*/,
  74. ziliangpihao:data['smalllabel'][j][k]['code'],
  75. supplier_name: data['smalllabel'][j][k]['supplier_name'],
  76. qcode: './static/qrcode/none.png',//为了表格撑开
  77. });
  78. var qrcode=data['smalllabel'][j][k]['code'];
  79. var l_flow=data['smalllabel'][j][k]['l_flow'];
  80. for(i=0;i<data['num'];i++){
  81. //console.log(i);
  82. //console.log(123456);
  83. //console.log(html);
  84. /*if(p==1){
  85. console.log(p);
  86. prn1_preview(html,qrcode);//预览
  87. p=p+1;
  88. }
  89. */
  90. if(window.location.host=="dm-test.7in6.com"){
  91. //为测试服务器,预览
  92. prn1_preview(html,qrcode,l_flow);//预览
  93. }else if(window.location.host=="dm.7in6.com"){
  94. //prn1_preview(html,qrcode);//预览
  95. //为正式服务器,打印
  96. prn1_print(html,qrcode,l_flow);//打印
  97. }else{
  98. prn1_preview(html,qrcode,l_flow);//打印
  99. }
  100. // document.getElementById('wp').innerHTML = html;
  101. }
  102. }
  103. }
  104. };
  105. function toSubmit(){
  106. console.log('ok');
  107. //请求接口
  108. $.ajax({
  109. type:"POST",
  110. url:"2.php",
  111. success: function(result){
  112. //判断返回值,弹出用户提示
  113. small_v010_print(result);
  114. },
  115. error: function(e){
  116. swal("","网络延迟,稍后操作.");
  117. }
  118. })
  119. }