|
|
@@ -114,106 +114,18 @@ export default {
|
|
|
},
|
|
|
methods: {
|
|
|
moreToDo(item){
|
|
|
- //查询是否已经连接蓝牙
|
|
|
let that=this;
|
|
|
- let doList = ['打1个条码', '打2个条码', '打10个条码','打20个条码']
|
|
|
- let doNum = [1,2,10,20]
|
|
|
+ let doList = ['打1个条码', '打2个条码','打5个条码', '打10个条码','打20个条码']
|
|
|
+ let doNum = [1,2,5,10,20]
|
|
|
uni.showActionSheet({
|
|
|
itemList: doList,
|
|
|
success: function (respond) {
|
|
|
let index = respond.tapIndex
|
|
|
- // #ifdef APP-PLUS
|
|
|
+ let currentNum = Number(doNum[index])
|
|
|
|
|
|
- let platform=uni.getSystemInfoSync().platform
|
|
|
- if(platform=='ios'){
|
|
|
- that.$msg('开发中,敬请期待')
|
|
|
- return false
|
|
|
- }
|
|
|
-
|
|
|
- plug.state({},ret=>{
|
|
|
- if(ret.code == 1){
|
|
|
- that.$util.confirmModal({content:'您还没有连接条码机,请先连接'},() => {
|
|
|
- // #ifdef APP-PLUS
|
|
|
- plug.connectUSB({setBackgroundColor:"#2088d2"},ret=>{
|
|
|
- //console.log(ret)
|
|
|
- })
|
|
|
- // #endif
|
|
|
- })
|
|
|
- }else{
|
|
|
- let currentNum = Number(doNum[index])
|
|
|
- if(Number(currentNum)<0){
|
|
|
- this.$msg('请选择打印数量')
|
|
|
- return false
|
|
|
- }
|
|
|
- let price = ''
|
|
|
- if(item.flower == 0){
|
|
|
- price = parseFloat(item.price)
|
|
|
- }
|
|
|
- let data = []
|
|
|
- let label = that.createLable(item.name,item.sn,currentNum,price)
|
|
|
- data.push(label)
|
|
|
- //说明地址 https://ext.dcloud.net.cn/plugin?id=462
|
|
|
- plug.printer({"TSC":data,isArray:true},result=>{
|
|
|
- //console.log(result)
|
|
|
- })
|
|
|
- }
|
|
|
- })
|
|
|
- // #endif
|
|
|
- // #ifdef MP-WEIXIN
|
|
|
- that.$msg('请在App上打印')
|
|
|
- // #endif
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
- //大条码
|
|
|
- createLable(itemName,itemId,num,price){
|
|
|
- //制作条码格式,
|
|
|
- var data=[]; //定义一个数组
|
|
|
- var line={}; //每添加一个,代表一行字
|
|
|
-
|
|
|
- //设置条码纸大小
|
|
|
- line={};
|
|
|
- line.width=40; //mm
|
|
|
- line.height=50; //mm
|
|
|
- line.gap=2; //条码纸之间,间隙长度 mm
|
|
|
- line.page=num; //打印几份
|
|
|
- data.push(line); //每添加一个,代表一行字
|
|
|
-
|
|
|
- //添加文字
|
|
|
- line={};
|
|
|
- line.text= itemName;
|
|
|
- line.rotation=0;
|
|
|
- line.x=290;
|
|
|
- line.y=15;
|
|
|
- line.xscal=2;
|
|
|
- line.yscal=2;
|
|
|
- data.push(line); //每添加一个,代表一行字
|
|
|
-
|
|
|
- if(!this.$util.isEmpty(price)){
|
|
|
- line={};
|
|
|
- line.text= price+'元';
|
|
|
- line.rotation=0;
|
|
|
- line.x=390;
|
|
|
- line.y=180;
|
|
|
- line.xscal=1;
|
|
|
- line.yscal=1;
|
|
|
- data.push(line); //每添加一个,代表一行字
|
|
|
- }
|
|
|
-
|
|
|
- //添加条型码
|
|
|
- line={};
|
|
|
- line.barcode=itemId;
|
|
|
- line.x=290;
|
|
|
- line.y=80;
|
|
|
- line.type="CODE128";
|
|
|
- line.width=2;//条型宽度,这里的宽指的是 条型码 竖条的宽度,不是整个条型码的宽度
|
|
|
- line.height=90;
|
|
|
- line.readable=true;
|
|
|
- line.rotation=0;
|
|
|
- data.push(line);
|
|
|
-
|
|
|
- return data;
|
|
|
- },
|
|
|
searchFn(){
|
|
|
|
|
|
},
|