1、通过快捷方式打开Grid++Report报表设计器

2、在空白编辑区,鼠标右键新建报表节中的报表头

3、点击页面设置,纸张设置为自定义,输入对应的宽度和高度

4、调整报表头的宽度和高度,使其满足纸张大小

5、点击工具栏中的插入,选择条形码&二维码

6、默认插入的是条形码,条码类型为Code39

 

 

 

7、如果想要改成二维码,需要将条码类型改为QRCode

 

8、为了使条形码或二维码展示的有意义,需要绑定参数;在参数集合鼠标右键,添加一个参数userCode

 

 

 

 9、再在对应的码文本,点击按钮,设置综合文本

 

 

 10、插入域,选择数据域;引用类型选参数userCode

 

 11、给参数userCode一个默认值,然后预览生成的对象

 

 

后台返回打印的核心代码:

if(isset($verifies)){
$countverifies=count($verifies);
$data['method'] = 'printreport';
$data['ReportType'] = 'gridreport';
$data['ReportName'] = 'WinSale_Pos.grf';
$data['PrinterName'] = $print['name'];
$data['token']='a42ff9e94a3cebb94efaf053d21c3ef5';
///$data['Copies']=$countverifies;
$data['Copies']=1;

$qrcode=[];

$data['Field'][0]['type'] = 'ftString';
$data['Field'][0]['name'] = 'bianma';
// $codes['Fieeld'][$key]['value'] = $val['code'];
$data['Field'][0]['size'] = 10;
$data['Field'][0]['required'] = 'false';


foreach ($verifies as $key=>$val){
// $data['Control'][$key]['type']="AsBarcode";
// $data['Control'][$key]['name']="Barcode1";
// $data['Control'][$key]['value']=rtrim($codes,",");
// $data['Control'][$key]['required']="false";
//
$data['Data'][$key]['bianma'] = $val['code'];

}

}
// var_export($data);die;

}
$data['params']=json_encode($data);
$data['count']=count($verifies);
$data['status']='1';
$data['print_url'] = 'http://'.$print['ip'].':'.$print['port'].'/';

 前端调用的代码:

print_info(data){
let that = this;
Fast.api.ajax({
url: 'shopro/Window/itemDetail',
loading: true,
type: 'GET',
data: {
id:data.id,
order_item_id:data.item[0].id,
type:'dispatch'
},
}, function (ret, e) {
jQuery.support.cors = true; //写到$.ajax $.get $.post 前面 解决 jQuery.Ajax IE8,9 无效(CORS跨域)
$.ajax({
async : false, //循环打印时, async 必须设置为 false,则所有的请求均为同步请求,在没有返回值之前,同步请求将锁住浏览器,用户其它操作必须等待请求完成才可以执行。
url : e.result.print_url,
type : "POST",
contentType: "application/x-www-form-urlencoded", //要这样设置
dataType : "json", //设置为 json 格式
xhrFields: {withCredentials: false},
crossDomain: true,
data : e.result.params,
success: function(data){

if(data.status=="ok"){
if(e.result.count > page) {
// page = page + 1;
// that.print_info(order_id, page);
}else{
this.$message({
message: '打印成功',
type: 'success'
});
// window.location.reload();
}
}else{
this.$message.error('打印失败');
}
},
error: function(data){
this.$message.error('连接HttpPrinter失败');
}
});
})
}


点赞(68)

评论列表 共有 0 条评论

暂无评论
立即
投稿
发表
评论
返回
顶部
{__SCRIPT__}