tg_small_v011.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  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.SET_PRINT_PAGESIZE(1, 1000, 1500, "CreateCustomPage");
  22. // LODOP.ADD_PRINT_TEXT(30,40,350,45,"浙江美浓世纪集团有限公司");
  23. // LODOP.SET_PRINT_MODE("PRINT_SETUP_PROGRAM",true);//设置打印维护窗口关闭后是否返回程序代码
  24. // LODOP.SET_PREVIEW_WINDOW(1,1,1,800,800,"预览.直接打印");
  25. LODOP.ADD_PRINT_HTM(15,20,350,545,html);
  26. // LODOP.SET_PRINT_STYLEA(0,"QRCodeErrorLevel","M");
  27. // LODOP.ADD_PRINT_BARCODE(330,70,'70mm','70mm',"QRCode",qrcode);
  28. LODOP.ADD_PRINT_TEXT(400,310,65,80,"大件号"+l_flow);
  29. LODOP.SET_PRINT_STYLEA(0,"FontName","宋体");
  30. LODOP.SET_PRINT_STYLEA(0,"FontSize",13);
  31. LODOP.SET_PRINT_STYLEA(0,"FontColor","#000000");
  32. LODOP.SET_PRINT_STYLEA(0,"Bold",1);
  33. LODOP.SET_PRINT_STYLEA(0,"Alignment",2);
  34. };
  35. function dateFamite(date) {
  36. return '20'+date.substr(0, 2)+'-'+date.substr(2, 2)+'-'+date.substr(4, 2);
  37. }
  38. function changetime(time) {
  39. var gtime=20000000;
  40. var times=parseInt(time)+parseInt(gtime);
  41. return times;
  42. }
  43. function getBathINo(code_cp1,bath_id) {
  44. var bath_no;
  45. if(bath_id.length<6){
  46. bath_no=code_cp1.substr(0, 6);
  47. for(i=0;i<(6-bath_id.length);i++){
  48. bath_no=bath_no+'0';
  49. }
  50. }
  51. bath_no= bath_no+bath_id;
  52. return bath_no;
  53. }
  54. //公司名称、辅料名称、辅料编码、配盘数
  55. function small_v011_print(supplier_name,matter_name,product_code,sqrcd,print_code,temple,numnum) {
  56. var date = new Date();
  57. var today = date.toLocaleDateString();
  58. var year = date.getFullYear();
  59. year = year.toString().substring(2,4)
  60. var month = date.getMonth() + 1;
  61. var day = date.getDate();
  62. month = (month > 9) ? month : ("0" + month);
  63. day = (day < 10) ? ("0" + day) : day;
  64. var riqi = year +''+ month +''+ day;
  65. var sqrcd1 = (Array(5).join(0) + sqrcd).slice(-3);
  66. numnum1 = (Array(5).join(0) + numnum).slice(-3);
  67. var qrcode ='AB'+'92'+temple+'0'+print_code+('000'+product_code)+riqi+numnum1+riqi+'000001'+'000000'+'2'+'0000'+riqi+'0000000000';
  68. $.ajax({
  69. url: "/index.php?s=/Admin/Qcode/getproduct",
  70. type: 'post',
  71. dataType: 'json',
  72. data: {'code':product_code, 'type':2, 'qrcode':qrcode},
  73. success: function (data) {
  74. var main_unit = data.main_unit;
  75. var sec_unit = data.sec_unit;
  76. var proportion = data.proportion*sqrcd;
  77. var pCode = data.pCode;
  78. var html = template(document.getElementById('tpl').innerHTML, {
  79. product_name: matter_name,
  80. manufacture_date:today,
  81. spec:'',
  82. ziliangpihao:qrcode,
  83. pici:riqi,
  84. supplier_name: supplier_name,
  85. numn: sqrcd,//配盘数
  86. qcode: './static/qrcode/none.png',//为了表格撑开
  87. main_unit:main_unit,//主单位
  88. sec_unit:sec_unit,//辅单位
  89. proportion:numnum,//数量
  90. pCode:pCode,//二维码
  91. });
  92. var l_flow=1;
  93. prn1_preview(html,qrcode,l_flow);
  94. },
  95. });
  96. }
  97. //小件云打印数据处理
  98. /*function small_v011_print(result,type,idList,reptQty,sign_type) {
  99. data=result;
  100. var p=0;
  101. var flag = 0;
  102. for(j in data['largrlabel']) {
  103. for(k in data['largrlabel'][j]){
  104. if (data['largrlabel'][j][k]['code'].substr(76,10)=='0000000000'){
  105. var pici = data['largrlabel'][j][k]['code'].substr(66,10).replace(/\b(0+)/gi,"");
  106. }else{
  107. var pici = data['largrlabel'][j][k]['code'].substr(66,10).replace(/\b(0+)/gi,"")+'、'+data['largrlabel'][j][k]['code'].substr(76,20).replace(/\b(0+)/gi,"");
  108. }
  109. if (data['largrlabel'][j][k]['proportion']){
  110. var proportion = data['largrlabel'][j][k]['numn']*data['largrlabel'][j][k]['proportion'];
  111. }else{
  112. var proportion = '';
  113. }
  114. var html = template(document.getElementById('tpl').innerHTML, {
  115. product_name: data['largrlabel'][j][k]['matter_name'],
  116. manufacture_date:dateFamite(data['largrlabel'][j][k]['manufacture_date']),
  117. total:data['largrlabel'][j][k]['box_num'],
  118. l_flow:data['largrlabel'][j][k]['l_flow'],
  119. bach_no:data['largrlabel'][j][k]['bach_num'] /!*getBathINo(data['largrlabel'][j][k]['code_cp1'],data['largrlabel'][j][k]['bath_id'])*!/,
  120. spec: data['largrlabel'][j][k]['matter_size'],
  121. ziliangpihao:data['largrlabel'][j][k]['code'],
  122. pici:pici,
  123. supplier_name: data['largrlabel'][j][k]['supplier_name'],
  124. numn: data['largrlabel'][j][k]['numn'],
  125. qcode: './static/qrcode/none.png',//为了表格撑开
  126. main_unit:data['largrlabel'][j][k]['main_unit'],
  127. sec_unit:data['largrlabel'][j][k]['sec_unit'],
  128. proportion:proportion,
  129. });
  130. var qrcode=data['largrlabel'][j][k]['code'];
  131. var l_flow=qrcode.substr(53,6).replace(/\b(0+)/gi,"");
  132. /!*if (data['num']>1 && status==1){
  133. //打印多份
  134. for(i=0;i<data['num'];i++){
  135. if (!flag){
  136. //第一次,预览、打印
  137. if(window.location.host=="dm-test.7in6.com"){
  138. //为测试服务器,预览
  139. prn1_preview(html,qrcode,l_flow);//预览
  140. }else if(window.location.host=="dm.7in6.com"){
  141. //prn1_preview(html,qrcode);//预览
  142. //为正式服务器,打印
  143. prn1_print(html,qrcode,l_flow);//打印
  144. }else{
  145. prn1_preview(html,qrcode,l_flow);//打印
  146. LODOP.On_Return=function(TaskID,Value){
  147. flag = Value};
  148. }
  149. }else if (flag){
  150. console.log(flag)
  151. //第二次及以后,直接打印
  152. if(window.location.host=="dm-test.7in6.com"){
  153. //为测试服务器,预览
  154. prn1_preview(html,qrcode,l_flow);//预览
  155. }else if(window.location.host=="dm.7in6.com"){
  156. //prn1_preview(html,qrcode);//预览
  157. //为正式服务器,打印
  158. prn1_print(html,qrcode,l_flow);//打印
  159. }else{
  160. prn1_print(html,qrcode,l_flow);//打印
  161. }
  162. }
  163. }
  164. }else if (data['num']=1 && status!=1) {
  165. }else if (data['num']>1 && status!=1) {
  166. }else{
  167. //打印次数为1,未多选
  168. if(window.location.host=="dm-test.7in6.com"){
  169. //为测试服务器,预览
  170. prn1_preview(html,qrcode,l_flow);//预览
  171. }else if(window.location.host=="dm.7in6.com"){
  172. //prn1_preview(html,qrcode);//预览
  173. //为正式服务器,打印
  174. prn1_print(html,qrcode,l_flow);//打印
  175. }else{
  176. prn1_preview(html,qrcode,l_flow);//打印
  177. }
  178. }*!/
  179. if (!flag){
  180. prn1_preview(html,qrcode,l_flow);//预览
  181. LODOP.On_Return=function(TaskID,Value){
  182. p = Value;
  183. if (p>=1){
  184. $.ajax({
  185. url: "index.php?s=/Admin/NewQcode/rePrintTg",
  186. type: "POST",
  187. dataType: "json",
  188. data: {
  189. "type": type,
  190. "idList": idList,
  191. "reptQty": reptQty,
  192. "sign_type": sign_type,
  193. "status": 1,
  194. },
  195. error:function (XMLHttpRequest, textStatus, errorThrown){
  196. $.messager.alert('系统提示', '数据加载错误,请刷新重试!', 'error');
  197. return false;
  198. }
  199. })
  200. }
  201. }
  202. flag++;
  203. }
  204. }
  205. }
  206. var cint = setInterval(function (){
  207. if (p==1){
  208. clearInterval(cint);
  209. flag = 0;
  210. for(j in data['largrlabel']) {
  211. for(k in data['largrlabel'][j]){
  212. if (data['largrlabel'][j][k]['code'].substr(76,10)=='0000000000'){
  213. var pici = data['largrlabel'][j][k]['code'].substr(66,10).replace(/\b(0+)/gi,"");
  214. }else{
  215. var pici = data['largrlabel'][j][k]['code'].substr(66,10).replace(/\b(0+)/gi,"")+'、'+data['largrlabel'][j][k]['code'].substr(76,20).replace(/\b(0+)/gi,"");
  216. }
  217. if (data['largrlabel'][j][k]['proportion']){
  218. var proportion = data['largrlabel'][j][k]['numn']*data['largrlabel'][j][k]['proportion'];
  219. }else{
  220. var proportion = '';
  221. }
  222. var html = template(document.getElementById('tpl').innerHTML, {
  223. product_name: data['largrlabel'][j][k]['matter_name'],
  224. manufacture_date:dateFamite(data['largrlabel'][j][k]['manufacture_date']),
  225. total:data['largrlabel'][j][k]['box_num'],
  226. l_flow:data['largrlabel'][j][k]['l_flow'],
  227. bach_no:data['largrlabel'][j][k]['bach_num'] /!*getBathINo(data['largrlabel'][j][k]['code_cp1'],data['largrlabel'][j][k]['bath_id'])*!/,
  228. spec: data['largrlabel'][j][k]['matter_size'],
  229. ziliangpihao:data['largrlabel'][j][k]['code'],
  230. pici:pici,
  231. supplier_name: data['largrlabel'][j][k]['supplier_name'],
  232. numn: data['largrlabel'][j][k]['numn'],
  233. qcode: './static/qrcode/none.png',//为了表格撑开
  234. main_unit:data['largrlabel'][j][k]['main_unit'],
  235. sec_unit:data['largrlabel'][j][k]['sec_unit'],
  236. proportion:proportion,
  237. });
  238. var qrcode=data['largrlabel'][j][k]['code'];
  239. var l_flow=qrcode.substr(53,6).replace(/\b(0+)/gi,"");
  240. for(i=0;i<data['num'];i++){
  241. if (!flag){
  242. flag++;
  243. }else{
  244. prn1_print(html,qrcode,l_flow);//打印
  245. flag++;
  246. }
  247. // document.getElementById('wp').innerHTML = html;
  248. }
  249. }
  250. }
  251. }
  252. },2000)
  253. };*/
  254. function toSubmit(){
  255. // console.log('ok');
  256. //请求接口
  257. $.ajax({
  258. type:"POST",
  259. url:"2.php",
  260. success: function(result){
  261. //判断返回值,弹出用户提示
  262. small_v011_print(result);
  263. },
  264. error: function(e){
  265. swal("","网络延迟,稍后操作.");
  266. }
  267. })
  268. }