修改相关方法

This commit is contained in:
范大德 2023-10-09 20:56:07 +08:00
parent ca8a203a99
commit 0367ba7be0

View File

@ -1,7 +1,33 @@
var exec = require('cordova/exec');
exports.print = function (arg0, success, error) {
exec(success, error, 'JcPrinter', 'print', [arg0]);
/**
*
* @param {*} data Instance.generateLabelJson()[]
* @param {*} info
* //Z401/B32/B32R/T8为300dpi机型其他机型均为200dpi
{
"printerImageProcessingInfo": {//打印附加信息
"orientation": 0,//旋转角度
"margin": [//边距
0,
0,
0,
0
],
"printQuantity": 1,//用于指定当前页的打印份数。例如如果你需要打印3页第一页打印3份第二页打印2份第三页打印5份那么在3次提交数据时printQuantity值分别应为325。
"horizontalOffset": 0,//水平偏移(暂不生效)
"verticalOffset": 0,//垂直偏移(暂不生效)
"width": 60,//画布宽度单位mm
"height": 40,//画布高度单位mm
"printMultiple": 8,//打印倍率 200dpi的打印机为8300dpi的打印机为11.81
"epc": ""//RFID标签写入数据B32R机器打印RFID标签时填充数据其他场景默认”“
}
}
* @param {*} success
* @param {*} error
*/
exports.print = function (data,info, success, error) {
exec(success, error, 'JcPrinter', 'print', [data,info]);
};
exports.getList = function (arg0, success, error) {
@ -12,9 +38,6 @@ exports.connectPrinter = function (arg0, success, error) {
exec(success, error, 'JcPrinter', 'connectPrinter', [arg0]);
}
exports.generateData = function(instance, success, error){
}
exports.Instance = function(){
/**
@ -26,8 +49,8 @@ exports.Instance = function(){
* @param rotate 旋转角度可选值090180270表示绘图板的旋转角度
* @param fontDir 字体文件路径用于绘制文本时指定字体暂不支持自定义默认即可
*/
function drawEmptyLabel(width, height, rotate,success,error) {
exec(success,error,"JcPrinter","action",["drawEmptyLabel",[width, height, rotate,fontDir||""]]);
async function drawEmptyLabel(width, height, rotate) {
return new Promise((resolve, reject) => exec(resolve,reject,"JcPrinter","action",["drawEmptyLabel",[width, height, rotate,fontDir||""]]));
}
/**
* 绘制文本
@ -48,8 +71,8 @@ exports.Instance = function(){
* @param lineSpace 行间距倍距单位毫米
* @param mFontStyles 字体样式数组长度为4依次表示加粗斜体下划线删除下划线暂不生效
*/
function drawLabelText(x, y, width, height, value,fontFamily, fontSize, rotate, textAlignHorizontal, textAlignVertical, lineModel, letterSpace, lineSpace, mFontStyles,success,error){
exec(success,error,"JcPrinter","action",["drawLabelText",[x, y, width, height, value, fontFamily||"", fontSize, rotate, textAlignHorizontal, textAlignVertical, lineModel, letterSpace, lineSpace, mFontStyles]]);
async function drawLabelText(x, y, width, height, value,fontFamily, fontSize, rotate, textAlignHorizontal, textAlignVertical, lineModel, letterSpace, lineSpace, mFontStyles){
return new Promise((resolve, reject) => exec(resolve,reject,"JcPrinter","action",["drawLabelText",[x, y, width, height, value, fontFamily||"", fontSize, rotate, textAlignHorizontal, textAlignVertical, lineModel, letterSpace, lineSpace, mFontStyles]]));
}
/**
@ -67,8 +90,8 @@ exports.Instance = function(){
* @param textHeight 文本高度单位毫米
* @param textPosition 文本位置可选值0-下方显示1-上方显示2-不显示
*/
function drawLabelBarCode(x, y, width, height, codeType, value, fontSize, rotate, textHeight, textPosition,success,error){
exec(success,error,"JcPrinter","action",["drawLabelBarCode",[x, y, width, height, codeType, value, fontSize, rotate, textHeight, textPosition]]);
async function drawLabelBarCode(x, y, width, height, codeType, value, fontSize, rotate, textHeight, textPosition){
return new Promise((resolve, reject) => exec(resolve,reject,"JcPrinter","action",["drawLabelBarCode",[x, y, width, height, codeType, value, fontSize, rotate, textHeight, textPosition]]));
}
/**
@ -83,8 +106,8 @@ exports.Instance = function(){
* @param codeType 二维码类型可选值31-QR_CODE32-PDF41733-DATA_MATRIX34-AZTEC
* @param rotate 旋转角度可选值090180270
*/
function drawLabelQrCode(x, y, width, height, value, codeType, rotate,success,error){
exec(success,error,"JcPrinter","action",["drawLabelQrCode",[x, y, width, height, value, codeType, rotate]]);
async function drawLabelQrCode(x, y, width, height, value, codeType, rotate){
return new Promise((resolve, reject) => exec(resolve,reject,"JcPrinter","action",["drawLabelQrCode",[x, y, width, height, value, codeType, rotate]]));
}
/**
@ -102,8 +125,8 @@ exports.Instance = function(){
* @param lineType 图形类型可选值1-2-椭圆3-矩形4-圆角矩形
* @param dashWidth 虚线样式数组中包含实线段长度和空线段长度
*/
function drawLabelGraph(x, y, width, height, graphType, rotate, cornerRadius, lineWidth, lineType, dashWidth,success,error){
exec(success,error,"JcPrinter","action",["drawLabelGraph",[x, y, width, height, graphType, rotate, cornerRadius, lineWidth, lineType, dashWidth]]);
async function drawLabelGraph(x, y, width, height, graphType, rotate, cornerRadius, lineWidth, lineType, dashWidth){
return new Promise((resolve, reject) => exec(resolve,reject,"JcPrinter","action",["drawLabelGraph",[x, y, width, height, graphType, rotate, cornerRadius, lineWidth, lineType, dashWidth]]));
}
/**
@ -119,8 +142,8 @@ exports.Instance = function(){
* @param imageProcessingType 处理算法默认1即可
* @param imageProcessingValue 阈值 阈值默认127即可
*/
function drawLabelImage(imageData, x, y, width, height, rotate, imageProcessingType, imageProcessingValue,success,error){
exec(success,error,"JcPrinter","action",["drawLabelImage",[imageData, x, y, width, height, rotate, imageProcessingType, imageProcessingValue]]);
async function drawLabelImage(imageData, x, y, width, height, rotate, imageProcessingType, imageProcessingValue){
return new Promise((resolve, reject) => exec(resolve,reject,"JcPrinter","action",["drawLabelImage",[imageData, x, y, width, height, rotate, imageProcessingType, imageProcessingValue]]));
}
/**
@ -135,12 +158,12 @@ exports.Instance = function(){
* @param lineType 线条类型1:实线2:虚线类型虚实比例1:1
* @param dashWidth 线条为虚线时的宽度包含实线段长度和空线段长度单位毫米
*/
function drawLabelLine(x, y, width, height, rotate, lineType, dashWidth,success,error){
exec(success,error,"JcPrinter","action",["drawLabelLine",[x, y, width, height, rotate, lineType, dashWidth]]);
async function drawLabelLine(x, y, width, height, rotate, lineType, dashWidth){
return new Promise((resolve, reject) => exec(resolve,reject,"JcPrinter","action",["drawLabelLine",[x, y, width, height, rotate, lineType, dashWidth]]));
}
function generateLabelJson(success,error){
exec(success,error,"JcPrinter","generateLabelJson");
async function generateLabelJson(){
return new Promise((resolve, reject) => exec(resolve,reject,"JcPrinter","generateLabelJson"));
}
}
}();