修改相关方法

This commit is contained in:
2023-10-09 20:56:07 +08:00
parent ca8a203a99
commit 0367ba7be0
+45 -22
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 旋转角度,可选值:0、90、180、270,表示绘图板的旋转角度
* @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 旋转角度,可选值:0、90、180、270
*/
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"));
}
}
}();