| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312 |
- /*
- *2018-08-17
- *小件盒包装纸100x150
- */
- var LODOP; //声明为全局变量
- function prn1_print(html,qrcode,l_flow) {
- CreateOneFormPage(html,qrcode,l_flow);
- // console.log(html);
- LODOP.PRINT();
- };
- function prn1_preview(html,qrcode,l_flow) {
- CreateOneFormPage(html,qrcode,l_flow);
- LODOP.PREVIEW();
- };
- function CreateOneFormPage(html,qrcode,l_flow){
- LODOP.SET_LICENSES("","152A06E8F6CBD6AC1F213ABFCB0D8604","C94CEE276DB2187AE6B65D56B3FC2848","");
- LODOP=getLodop();
- LODOP.PRINT_INIT("河南中烟大件二维码打码");
- LODOP.SET_PRINT_STYLE("FontSize",16);
- LODOP.SET_PRINT_STYLE("Bold",1);
- LODOP.SET_PRINT_PAGESIZE(1, 1000, 1500, "CreateCustomPage");
- // LODOP.ADD_PRINT_TEXT(30,40,350,45,"浙江美浓世纪集团有限公司");
- // LODOP.SET_PRINT_MODE("PRINT_SETUP_PROGRAM",true);//设置打印维护窗口关闭后是否返回程序代码
- // LODOP.SET_PREVIEW_WINDOW(1,1,1,800,800,"预览.直接打印");
- LODOP.ADD_PRINT_HTM(15,20,350,545,html);
- // LODOP.SET_PRINT_STYLEA(0,"QRCodeErrorLevel","M");
- // LODOP.ADD_PRINT_BARCODE(330,70,'70mm','70mm',"QRCode",qrcode);
- // LODOP.ADD_PRINT_TEXT(400,310,65,80,"大件号"+l_flow);
- // LODOP.SET_PRINT_STYLEA(0,"FontName","宋体");
- // LODOP.SET_PRINT_STYLEA(0,"FontSize",13);
- // LODOP.SET_PRINT_STYLEA(0,"FontColor","#000000");
- // LODOP.SET_PRINT_STYLEA(0,"Bold",1);
- // LODOP.SET_PRINT_STYLEA(0,"Alignment",2);
- };
- 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_v011_print(supplier_name,matter_name,product_code,sqrcd,print_code,temple,numnum) {
- var date = new Date();
- var today = date.toLocaleDateString();
- var year = date.getFullYear();
- year = year.toString().substring(2,4)
- var month = date.getMonth() + 1;
- var day = date.getDate();
- month = (month > 9) ? month : ("0" + month);
- day = (day < 10) ? ("0" + day) : day;
- var riqi = year +''+ month +''+ day;
- var sqrcd1 = (Array(5).join(0) + sqrcd).slice(-3);
- numnum1 = (Array(5).join(0) + numnum).slice(-3);
- var qrcode ='AB'+'92'+temple+'0'+print_code+('000'+product_code)+riqi+numnum1+riqi+'000001'+'000000'+'2'+'0000'+riqi+'0000000000';
- $.ajax({
- url: "/index.php?s=/Admin/Qcode/getproduct",
- type: 'post',
- dataType: 'json',
- data: {'code':product_code, 'type':2, 'qrcode':qrcode},
- success: function (data) {
- var main_unit = data.main_unit;
- var sec_unit = data.sec_unit;
- var proportion = data.proportion*sqrcd;
- var pCode = data.pCode;
- var html = template(document.getElementById('tpl').innerHTML, {
- product_name: matter_name,
- manufacture_date:today,
- spec:'',
- ziliangpihao:qrcode,
- pici:riqi,
- l_flow:1,
- supplier_name: supplier_name,
- numn: sqrcd,//配盘数
- qcode: './static/qrcode/none.png',//为了表格撑开
- main_unit:main_unit,//主单位
- sec_unit:sec_unit,//辅单位
- proportion:numnum,//数量
- pCode:pCode,//二维码
- });
- var l_flow=1;
- prn1_preview(html,qrcode,l_flow);
- },
- });
- }
- //小件云打印数据处理
- /*function small_v011_print(result,type,idList,reptQty,sign_type) {
- data=result;
- var p=0;
- var flag = 0;
- for(j in data['largrlabel']) {
- for(k in data['largrlabel'][j]){
- if (data['largrlabel'][j][k]['code'].substr(76,10)=='0000000000'){
- var pici = data['largrlabel'][j][k]['code'].substr(66,10).replace(/\b(0+)/gi,"");
- }else{
- 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,"");
- }
- if (data['largrlabel'][j][k]['proportion']){
- var proportion = data['largrlabel'][j][k]['numn']*data['largrlabel'][j][k]['proportion'];
- }else{
- var proportion = '';
- }
- var html = template(document.getElementById('tpl').innerHTML, {
- product_name: data['largrlabel'][j][k]['matter_name'],
- manufacture_date:dateFamite(data['largrlabel'][j][k]['manufacture_date']),
- total:data['largrlabel'][j][k]['box_num'],
- l_flow:data['largrlabel'][j][k]['l_flow'],
- bach_no:data['largrlabel'][j][k]['bach_num'] /!*getBathINo(data['largrlabel'][j][k]['code_cp1'],data['largrlabel'][j][k]['bath_id'])*!/,
- spec: data['largrlabel'][j][k]['matter_size'],
- ziliangpihao:data['largrlabel'][j][k]['code'],
- pici:pici,
- supplier_name: data['largrlabel'][j][k]['supplier_name'],
- numn: data['largrlabel'][j][k]['numn'],
- qcode: './static/qrcode/none.png',//为了表格撑开
- main_unit:data['largrlabel'][j][k]['main_unit'],
- sec_unit:data['largrlabel'][j][k]['sec_unit'],
- proportion:proportion,
- });
- var qrcode=data['largrlabel'][j][k]['code'];
- var l_flow=qrcode.substr(53,6).replace(/\b(0+)/gi,"");
- /!*if (data['num']>1 && status==1){
- //打印多份
- for(i=0;i<data['num'];i++){
- if (!flag){
- //第一次,预览、打印
- if(window.location.host=="dm-test.7in6.com"){
- //为测试服务器,预览
- prn1_preview(html,qrcode,l_flow);//预览
- }else if(window.location.host=="dm.7in6.com"){
- //prn1_preview(html,qrcode);//预览
- //为正式服务器,打印
- prn1_print(html,qrcode,l_flow);//打印
- }else{
- prn1_preview(html,qrcode,l_flow);//打印
- LODOP.On_Return=function(TaskID,Value){
- flag = Value};
- }
- }else if (flag){
- console.log(flag)
- //第二次及以后,直接打印
- if(window.location.host=="dm-test.7in6.com"){
- //为测试服务器,预览
- prn1_preview(html,qrcode,l_flow);//预览
- }else if(window.location.host=="dm.7in6.com"){
- //prn1_preview(html,qrcode);//预览
- //为正式服务器,打印
- prn1_print(html,qrcode,l_flow);//打印
- }else{
- prn1_print(html,qrcode,l_flow);//打印
- }
- }
- }
- }else if (data['num']=1 && status!=1) {
- }else if (data['num']>1 && status!=1) {
- }else{
- //打印次数为1,未多选
- if(window.location.host=="dm-test.7in6.com"){
- //为测试服务器,预览
- prn1_preview(html,qrcode,l_flow);//预览
- }else if(window.location.host=="dm.7in6.com"){
- //prn1_preview(html,qrcode);//预览
- //为正式服务器,打印
- prn1_print(html,qrcode,l_flow);//打印
- }else{
- prn1_preview(html,qrcode,l_flow);//打印
- }
- }*!/
- if (!flag){
- prn1_preview(html,qrcode,l_flow);//预览
- LODOP.On_Return=function(TaskID,Value){
- p = Value;
- if (p>=1){
- $.ajax({
- url: "index.php?s=/Admin/NewQcode/rePrintTg",
- type: "POST",
- dataType: "json",
- data: {
- "type": type,
- "idList": idList,
- "reptQty": reptQty,
- "sign_type": sign_type,
- "status": 1,
- },
- error:function (XMLHttpRequest, textStatus, errorThrown){
- $.messager.alert('系统提示', '数据加载错误,请刷新重试!', 'error');
- return false;
- }
- })
- }
- }
- flag++;
- }
- }
- }
- var cint = setInterval(function (){
- if (p==1){
- clearInterval(cint);
- flag = 0;
- for(j in data['largrlabel']) {
- for(k in data['largrlabel'][j]){
- if (data['largrlabel'][j][k]['code'].substr(76,10)=='0000000000'){
- var pici = data['largrlabel'][j][k]['code'].substr(66,10).replace(/\b(0+)/gi,"");
- }else{
- 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,"");
- }
- if (data['largrlabel'][j][k]['proportion']){
- var proportion = data['largrlabel'][j][k]['numn']*data['largrlabel'][j][k]['proportion'];
- }else{
- var proportion = '';
- }
- var html = template(document.getElementById('tpl').innerHTML, {
- product_name: data['largrlabel'][j][k]['matter_name'],
- manufacture_date:dateFamite(data['largrlabel'][j][k]['manufacture_date']),
- total:data['largrlabel'][j][k]['box_num'],
- l_flow:data['largrlabel'][j][k]['l_flow'],
- bach_no:data['largrlabel'][j][k]['bach_num'] /!*getBathINo(data['largrlabel'][j][k]['code_cp1'],data['largrlabel'][j][k]['bath_id'])*!/,
- spec: data['largrlabel'][j][k]['matter_size'],
- ziliangpihao:data['largrlabel'][j][k]['code'],
- pici:pici,
- supplier_name: data['largrlabel'][j][k]['supplier_name'],
- numn: data['largrlabel'][j][k]['numn'],
- qcode: './static/qrcode/none.png',//为了表格撑开
- main_unit:data['largrlabel'][j][k]['main_unit'],
- sec_unit:data['largrlabel'][j][k]['sec_unit'],
- proportion:proportion,
- });
- var qrcode=data['largrlabel'][j][k]['code'];
- var l_flow=qrcode.substr(53,6).replace(/\b(0+)/gi,"");
- for(i=0;i<data['num'];i++){
- if (!flag){
- flag++;
- }else{
- prn1_print(html,qrcode,l_flow);//打印
- flag++;
- }
- // document.getElementById('wp').innerHTML = html;
- }
- }
- }
- }
- },2000)
- };*/
- function toSubmit(){
- // console.log('ok');
- //请求接口
- $.ajax({
- type:"POST",
- url:"2.php",
- success: function(result){
- //判断返回值,弹出用户提示
- small_v011_print(result);
- },
- error: function(e){
- swal("","网络延迟,稍后操作.");
- }
- })
- }
|