import { CCPrintingAPI } from 'static/js/CCPrintingAPI.min.vue.js'
GetPrinters: function () {
var cfgData = new Object;
cfgData.XAction = "Printers";
cfgData.XOpenId = m_OpenId;
cfgData.XTokens = m_Tokens;
CCPrintingAPI.Excute(cfgData,
XTimeout => { },
XFail => {
this.mytipsmessage = 'API可(kě)能未安裝或未啓動, ' + XFail;
},
XSuccess => {
var d = new Date;
this.timetick = d.getTime();
var apiResult = JSON.parse(XSuccess.trim());
if (apiResult.Status == "1") {
if (apiResult.Message.length > 1) {
this.options = [];
for (var i = 1; i < apiResult.Message.length; i++) {
var op = new Object;
op.text = apiResult.Message[i];
op.value = apiResult.Message[i];
this.options.push(op);
}
/*設置上(shàng)次使用的打印機*/
this.selected = this.options[0].value;
}
} else {
if (apiResult.Message.length > 1)
this.mytipsmessage = apiResult.Message[0] + " : " + apiResult.Message[1];
else
this.mytipsmessage = apiResult.Message[0];
}
}
);
}
Print: function (arr) {
var cfgData = new Object;
cfgData.XAction = "Print"
cfgData.XOpenId = m_OpenId;
cfgData.XTokens = m_Tokens;
/*指定打印機*/
cfgData.PrinterName = this.selected;
/*模闆方式,0-客戶端模闆,1-遠程模闆,
2-如果本地模闆存在,使用本地,不存在使用遠程模闆,3-不使用模闆*/
cfgData.TemplateMode = "1";
/*遠程模闆URL或本地模闆的文件夾*/
cfgData.TemplateURL = "http://img.51321.cn/web/chicore/VPrinting/API";
//cfgData.TemplateURL = "E:\\臨時(shí)數(shù)據\\打印\\打印樣本\\API标簽模闆";
/*模闆文件名*/
cfgData.TemplateName = "Label1-Receipt.Lblx";
/*打印數(shù)據的類型,0-數(shù)組,1-Json數(shù)組,元素為(wèi)JSON對象,字段:值*/
cfgData.PrintDataType = 1;
/*傳遞打印數(shù)據 Json數(shù)組*/ /*內(nèi)容不允許 半角的逗号及半角的分隔符*/
cfgData.PrintData = JSON.stringify(arr);
/*打印 發送給打印機進行(xíng)打印*/
CCPrintingAPI.Excute(cfgData,
XTimeout => { },
XFail => {
this.mytipsmessage = 'API可(kě)能未安裝或未啓動, ' + XFail;
},
XSuccess => {
var d = new Date;
this.timetick = d.getTime();
var apiResult = JSON.parse(XSuccess.trim());
if (apiResult.Status == "1") {
var smsg = apiResult.Message[0];
if (apiResult.Message.length > 1)
smsg += " : " + apiResult.Message[1]
this.mytipsmessage = smsg;
} else {
if (apiResult.Message.length > 1)
this.mytipsmessage = apiResult.Message[0] + " : " + apiResult.Message[1];
else
this.mytipsmessage = apiResult.Message[0];
}
}
);
}
Print1:function(){
var arr = [
{"orderid":"2023030919103001","pname":"電(diàn)源适配器(qì)24V 2.5A","orderdate":"2023/03/09 19:10:31","sn":"81322","qty":"6"},
{"orderid":"2023030919103001","pname":"LED光源","orderdate":"2023/03/09 19:10:30","sn":"49267","qty":"3"},
{"orderid":"2023030919103001","pname":"CCXt标簽打印機","orderdate":"2023/03/09 18:07:11","sn":"35178","qty":"1"}
];
Print(arr);
}
Print2:function(){
var arr = [
{"orderid":"2023030919103001","pname":"電(diàn)源适配器(qì)24V 2.5A","orderdate":"2023/03/09 19:10:31","sn":"81322","qty":"6"},
{"orderid":"2023030919103001","pname":"LED光源","orderdate":"2023/03/09 19:10:30","sn":"49267","qty":"3"},
{"orderid":"2023030919103001","pname":"CCXt标簽打印機","orderdate":"2023/03/09 18:07:11","sn":"35178","qty":"1"},
{"orderid":"2023030919103002","pname":"HW手機Mate90","orderdate":"2023/03/09 18:07:07","sn":"69092","qty":"5"},
{"orderid":"2023030919103002","pname":"CCPrintingAPI許可(kě)證","orderdate":"2023/03/09 18:07:06","sn":"47505","qty":"10"},
{"orderid":"2023030919103002","pname":"UGEE顯示器(qì)","orderdate":"2023/03/09 17:18:15","sn":"26612","qty":"7"},
{"orderid":"2023030919103002","pname":"MBOX MUSIC Play","orderdate":"2023/03/09 17:18:10","sn":"75149","qty":"2"},
{"orderid":"2023030919103002","pname":"鴻蒙Harmony","orderdate":"2023/03/09 17:18:05","sn":"51926","qty":"4"}
];
Print(arr);
}
Print3:function(){
var arr = [
{"orderid":"2023030919103001","pname":"電(diàn)源适配器(qì)24V 2.5A","orderdate":"2023/03/09 19:10:31","sn":"81322","qty":"6"},
{"orderid":"2023030919103001","pname":"LED光源","orderdate":"2023/03/09 19:10:30","sn":"49267","qty":"3"},
{"orderid":"2023030919103001","pname":"CCXt标簽打印機","orderdate":"2023/03/09 18:07:11","sn":"35178","qty":"1"},
{"orderid":"2023030919103002","pname":"HW手機Mate90","orderdate":"2023/03/09 18:07:07","sn":"69092","qty":"5"},
{"orderid":"2023030919103002","pname":"CCPrintingAPI許可(kě)證","orderdate":"2023/03/09 18:07:06","sn":"47505","qty":"10"},
{"orderid":"2023030919103002","pname":"UGEE顯示器(qì)","orderdate":"2023/03/09 17:18:15","sn":"26612","qty":"7"},
{"orderid":"2023030919103002","pname":"MBOX MUSIC Play","orderdate":"2023/03/09 17:18:10","sn":"75149","qty":"2"},
{"orderid":"2023030919103002","pname":"鴻蒙Harmony","orderdate":"2023/03/09 17:18:05","sn":"51926","qty":"4"},
{"orderid":"2023030919103003","pname":"PCB ROHS 線路闆","orderdate":"2023/03/09 17:18:03","sn":"97951","qty":"6"},
{"orderid":"2023030919103003","pname":"GPTX 工業打印機","orderdate":"2023/03/09 17:18:01","sn":"54115","qty":"8"}
];
Print(arr);
}
Printpreview: function (arr) {
this.myhid = '';
this.mytipsmessage = '';
this.timetick = '';
var cfgData = new Object;
cfgData.XAction = "Print"
cfgData.XOpenId = m_OpenId;
cfgData.XTokens = m_Tokens;
cfgData.Preview = "3";
/*指定打印機*/
cfgData.PrinterName = this.selected;
/*模闆方式,0-客戶端模闆,1-遠程模闆,
2-如果本地模闆存在,使用本地,不存在使用遠程模闆,3-不使用模闆*/
cfgData.TemplateMode = "1";
/*遠程模闆URL或本地模闆的文件夾*/
cfgData.TemplateURL = "http://img.51321.cn/web/chicore/VPrinting/API";
//cfgPrintSettings.TemplateURL = "E:\\臨時(shí)數(shù)據\\打印\\打印樣本\\API标簽模闆";
/*模闆文件名183601-100X100*/
cfgData.TemplateName = "Label1-Receipt.Lblx";
/*打印數(shù)據的類型,0-數(shù)組,1-Json數(shù)組,元素為(wèi)JSON對象,字段:值*/
cfgData.PrintDataType = 1;
/*傳遞打印數(shù)據 Json數(shù)組*/ /*內(nèi)容不允許 半角的逗号及半角的分隔符*/
cfgData.PrintData = JSON.stringify(arr);
/*打印 發送給打印機進行(xíng)打印*/
CCPrintingAPI.Excute(cfgData,
XTimeout => { },
XFail => {
this.mytipsmessage = 'API可(kě)能未安裝或未啓動, ' + XFail;
},
XSuccess => {
var d = new Date;
this.timetick = d.getTime();
var apiResult = JSON.parse(XSuccess.trim());
if (apiResult.Status == "1") {
var smsg = apiResult.Message[0];
if (apiResult.Message.length > 1)
smsg += " : " + apiResult.Message[1]
this.mytipsmessage = "";
} else {
if (apiResult.Message.length > 1)
this.mytipsmessage = apiResult.Message[0] + " : " + apiResult.Message[1];
else
this.mytipsmessage = apiResult.Message[0];
}
}
);
}
Printpreview1:function(){
var arr = [
{"orderid":"2023030919103001","pname":"電(diàn)源适配器(qì)24V 2.5A","orderdate":"2023/03/09 19:10:31","sn":"81322","qty":"6"},
{"orderid":"2023030919103001","pname":"LED光源","orderdate":"2023/03/09 19:10:30","sn":"49267","qty":"3"},
{"orderid":"2023030919103001","pname":"CCXt标簽打印機","orderdate":"2023/03/09 18:07:11","sn":"35178","qty":"1"}
];
Printpreview(arr);
}