| | |
| | | <view class="left">条码编号:</view> |
| | | <view class="right"> |
| | | <input :focus="HBarCodeFocus" v-model="barCodeInfoMeta.barCodeNo" placeholder="请扫描条码" |
| | | @confirm="searchbarCodeInfo" /> |
| | | @confirm="searchbarCodeInfo" /> |
| | | </view> |
| | | <view> |
| | | <uni-icons type="scan" |
| | |
| | | :disabled="cantGenerate">生成</button> |
| | | <button type="default" :class="cantPrint ? 'btn-disabled' : 'btn-c'" @click="PrintHBarCode" |
| | | :disabled="cantPrint">打印</button> |
| | | <button type="primary" @click="printerLabel2">测试打印2</button> |
| | | <button type="primary" @click="printerLabel2">测试打印2</button> |
| | | </view> |
| | | </view> |
| | | <view class="divide"></view> |
| | |
| | | <view class="dWetail"> |
| | | <text>物料编码:</text>{{barCodeInfo['物料代码'] || ''}} |
| | | </view> |
| | | |
| | | |
| | | <view class="detail"> |
| | | <text>规格型号:</text>{{barCodeInfo['规格型号'] || ''}} |
| | | </view> |
| | |
| | | </view> |
| | | <view class="over" v-if="barCodeSplitInfo.length == 0">暂无数据</view> |
| | | <view class="over" v-if="barCodeSplitInfo.length != 0">已到底</view> |
| | | |
| | | |
| | | </view> |
| | | </template> |
| | | |
| | |
| | | const printer = uni.requireNativePlugin('LcPrinter'); |
| | | const modal = uni.requireNativePlugin('modal'); |
| | | var globalEvent = uni.requireNativePlugin('globalEvent'); |
| | | |
| | | |
| | | // 在全局定义一个变量来标识是否已经初始化 |
| | | var isPrinterInitialized = false; |
| | | |
| | |
| | | splitNum: "", |
| | | billMaker: getUserInfo().Czymc, |
| | | }, |
| | | base64:"", |
| | | barCodeInfo: {//原条码信息 |
| | | base64: "", |
| | | barCodeInfo: { //原条码信息 |
| | | |
| | | }, |
| | | barCodeSplitInfo: [],//拆码信息 |
| | | barCodeSplitInfo: [], //拆码信息 |
| | | cantGenerate: true, // 生成按钮初始禁用 |
| | | cantPrint: true, // 打印按钮初始禁用 |
| | | cantSplit: false, // 拆码按钮初始可用 |
| | | HBarCodeFocus: false, |
| | | isPrinting:false, |
| | | isPrinting: false, |
| | | printInfo: "" //打印 |
| | | }; |
| | | }, |
| | |
| | | printer.setConcentration({ //设置打印浓度。font_level 取值范围:1~39。 |
| | | level: 39 |
| | | }); |
| | | |
| | | |
| | | }, |
| | | printerLabel() { |
| | | const formatDate = new Date().toISOString().split('T')[0]; |
| | | printer.setLineSpacing({ |
| | | spacing: 1.2 |
| | | }); |
| | | |
| | | printer.setUnwindPaperLen({ length: 60 }); |
| | | |
| | | printer.setUnwindPaperLen({ |
| | | length: 60 |
| | | }); |
| | | printer.setFontSize({ |
| | | fontSize: 1 |
| | | }); |
| | |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '供应商名称:'+this.barCodeInfo['供应商']+'\r\n' |
| | | content: '供应商名称:' + this.barCodeInfo['供应商'] + '\r\n' |
| | | }); |
| | | |
| | | |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize:2, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '物料代码:'+this.barCodeInfo['物料代码']+'\r\n' |
| | | content: '物料代码:' + this.barCodeInfo['物料代码'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '物料简称:'+this.barCodeInfo['物料简称']+'\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize:2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '数量:'+this.barCodeInfo['剩余数量']+'\r\n' |
| | | content: '物料简称:' + this.barCodeInfo['物料简称'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '工号:'+this.barCodeInfo['工号']+'\r\n' |
| | | content: '数量:' + this.barCodeInfo['剩余数量'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '生产日期:'+this.barCodeInfo['生产日期']+'\r\n' |
| | | content: '工号:' + this.barCodeInfo['工号'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '流水号:'+this.barCodeInfo['流水号']+'\r\n' |
| | | content: '生产日期:' + this.barCodeInfo['生产日期'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '打印日期:'+formatDate+'\r\n' |
| | | content: '流水号:' + this.barCodeInfo['流水号'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '打印日期:' + formatDate + '\r\n' |
| | | }); |
| | | printer.printQR2({ |
| | | text: this.barCodeInfo['条码编号'], |
| | |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '供应商名称:'+this.barCodeInfo['供应商']+'\r\n' |
| | | content: '供应商名称:' + this.barCodeInfo['供应商'] + '\r\n' |
| | | }); |
| | | |
| | | |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize:2, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '物料代码:'+this.barCodeInfo['物料代码']+'\r\n' |
| | | content: '物料代码:' + this.barCodeInfo['物料代码'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '物料简称:'+this.barCodeInfo['物料简称']+'\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize:2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '数量:'+this.barCodeSplitInfo[0]['HSplitNum']+'\r\n' |
| | | content: '物料简称:' + this.barCodeInfo['物料简称'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '工号:'+this.barCodeInfo['工号']+'\r\n' |
| | | content: '数量:' + this.barCodeSplitInfo[0]['HSplitNum'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '生产日期:'+this.barCodeInfo['生产日期']+'\r\n' |
| | | content: '工号:' + this.barCodeInfo['工号'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '流水号:'+this.barCodeInfo['流水号']+'\r\n' |
| | | content: '生产日期:' + this.barCodeInfo['生产日期'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '打印日期:'+formatDate+'\r\n' |
| | | content: '流水号:' + this.barCodeInfo['流水号'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '打印日期:' + formatDate + '\r\n' |
| | | }); |
| | | printer.printQR2({ |
| | | text: this.barCodeSplitInfo[0]['HBarCode'], |
| | |
| | | }, |
| | | printerLabel2() { |
| | | console.log('测试打印'); |
| | | const formatDate =new Date().toISOString().split('T')[0]; |
| | | const formatDate = new Date().toISOString().split('T')[0]; |
| | | console.log(formatDate) |
| | | CommonUtils.showTips({ |
| | | message:'母标签\r\n'+'供应商名称:'+this.barCodeInfo['供应商']+'\r\n'+'物料代码:'+this.barCodeInfo['物料代码']+'\r\n'+'物料简称:'+this.barCodeInfo['物料简称']+'\r\n' |
| | | +'数量:'+this.barCodeInfo['剩余数量']+'\r\n'+'工号:'+this.barCodeInfo['工号']+'\r\n'+'生产日期:'+this.barCodeInfo['生产日期']+'\r\n'+'流水号:'+this.barCodeInfo['流水号']+'\r\n' |
| | | +'打印日期:'+formatDate+'\r\n'+this.barCodeInfo['条码编号']+'\r\n' |
| | | +'子标签\r\n'+'供应商名称:'+this.barCodeInfo['供应商']+'\r\n'+'物料代码:'+this.barCodeInfo['物料代码']+'\r\n'+'物料简称:'+this.barCodeInfo['物料简称']+'\r\n' |
| | | +'数量:'+this.barCodeSplitInfo[0]['HSplitNum']+'\r\n'+'工号:'+this.barCodeInfo['工号']+'\r\n'+'生产日期:'+this.barCodeInfo['生产日期']+'\r\n'+'流水号:'+this.barCodeInfo['流水号']+'\r\n' |
| | | +'打印日期:'+formatDate+'\r\n'+this.barCodeSplitInfo[0]['HBarCode']+'\r\n' |
| | | |
| | | , |
| | | message: '母标签\r\n' + '供应商名称:' + this.barCodeInfo['供应商'] + '\r\n' + '物料代码:' + this.barCodeInfo[ |
| | | '物料代码'] + '\r\n' + '物料简称:' + this.barCodeInfo['物料简称'] + '\r\n' + |
| | | '数量:' + this.barCodeInfo['剩余数量'] + '\r\n' + '工号:' + this.barCodeInfo['工号'] + '\r\n' + |
| | | '生产日期:' + this.barCodeInfo['生产日期'] + '\r\n' + '流水号:' + this.barCodeInfo['流水号'] + '\r\n' + |
| | | '打印日期:' + formatDate + '\r\n' + this.barCodeInfo['条码编号'] + '\r\n' + |
| | | '子标签\r\n' + '供应商名称:' + this.barCodeInfo['供应商'] + '\r\n' + '物料代码:' + this.barCodeInfo[ |
| | | '物料代码'] + '\r\n' + '物料简称:' + this.barCodeInfo['物料简称'] + '\r\n' + |
| | | '数量:' + this.barCodeSplitInfo[0]['HSplitNum'] + '\r\n' + '工号:' + this.barCodeInfo['工号'] + |
| | | '\r\n' + '生产日期:' + this.barCodeInfo['生产日期'] + '\r\n' + '流水号:' + this.barCodeInfo['流水号'] + |
| | | '\r\n' + |
| | | '打印日期:' + formatDate + '\r\n' + this.barCodeSplitInfo[0]['HBarCode'] + '\r\n' |
| | | |
| | | , |
| | | }) |
| | | printer.setLineSpacing({ |
| | | spacing: 1.2 |
| | | }); |
| | | |
| | | printer.setUnwindPaperLen({ length: 60 }); |
| | | |
| | | printer.setUnwindPaperLen({ |
| | | length: 60 |
| | | }); |
| | | printer.setFontSize({ |
| | | fontSize: 1 |
| | | }); |
| | |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '供应商名称:'+this.barCodeInfo['供应商']+'\r\n' |
| | | content: '供应商名称:' + this.barCodeInfo['供应商'] + '\r\n' |
| | | }); |
| | | |
| | | |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize:2, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '物料代码:'+this.barCodeInfo['物料代码']+'\r\n' |
| | | content: '物料代码:' + this.barCodeInfo['物料代码'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '物料简称:'+this.barCodeInfo['物料简称']+'\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize:2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '数量:'+this.barCodeInfo['剩余数量']+'\r\n' |
| | | content: '物料简称:' + this.barCodeInfo['物料简称'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '工号:'+this.barCodeInfo['工号']+'\r\n' |
| | | content: '数量:' + this.barCodeInfo['剩余数量'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '生产日期:'+this.barCodeInfo['生产日期']+'\r\n' |
| | | content: '工号:' + this.barCodeInfo['工号'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '流水号:'+this.barCodeInfo['流水号']+'\r\n' |
| | | content: '生产日期:' + this.barCodeInfo['生产日期'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '打印日期:'+formatDate+'\r\n' |
| | | content: '流水号:' + this.barCodeInfo['流水号'] + '\r\n' |
| | | }); |
| | | printer.printText2({ |
| | | offset: 1, |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '打印日期:' + formatDate + '\r\n' |
| | | }); |
| | | printer.printQR2({ |
| | | text: this.barCodeInfo['条码编号'], |
| | |
| | | count |
| | | } = res1 |
| | | if (count > 0) { |
| | | |
| | | |
| | | this.barCodeInfo = data[0] |
| | | this.barCodeSplitInfo = [] |
| | | // 扫描条码后重置按钮状态 |
| | | this.resetButtonState(); |
| | | |
| | | }else{ |
| | | |
| | | } else { |
| | | CommonUtils.showTips({ |
| | | message: "该条码不存在:"+this.barCodeInfoMeta.barCodeNo, |
| | | message: "该条码不存在:" + this.barCodeInfoMeta.barCodeNo, |
| | | }) |
| | | this.barCodeInfoMeta.barCodeNo=""; |
| | | this.barCodeInfoMeta.barCodeNo = ""; |
| | | } |
| | | }, |
| | | (err) => { |
| | |
| | | }, |
| | | (err) => { |
| | | CommonUtils.showTips({ |
| | | message: "条码拆码出现错误"+err, |
| | | message: "条码拆码出现错误" + err, |
| | | }) |
| | | console.error(err) |
| | | } |
| | |
| | | }); |
| | | } |
| | | let msg = |
| | | `${this.barCodeInfoMeta["barCodeNo"]};${this.barCodeInfoMeta["splitNum"]};${JSON.stringify(this.barCodeSplitInfo)};${this.billMaker}` |
| | | `${this.barCodeInfoMeta["barCodeNo"]};${this.barCodeInfoMeta["splitNum"]};${JSON.stringify(this.barCodeSplitInfo)};${this.barCodeInfoMeta["billMaker"]}` |
| | | this.doRequest( |
| | | "/Sc_BarCode/SplitBarCode_Save", { |
| | | msg: msg |
| | |
| | | this.cantGenerate = true; |
| | | this.cantPrint = false; |
| | | this.cantSplit = true; |
| | | this.barCodeInfoMeta.barCodeNo="";//清空输入框 |
| | | this.barCodeInfoMeta.barCodeNo = ""; //清空输入框 |
| | | uni.showToast({ |
| | | title: '生成成功!' |
| | | }); |
| | |
| | | (err) => { |
| | | console.log(err) |
| | | CommonUtils.showTips({ |
| | | message: "条码生成出现错误"+err, |
| | | message: "条码生成出现错误" + err, |
| | | }) |
| | | |
| | | |
| | | }, |
| | | "POST" |
| | | ) |
| | |
| | | this.isPrinting = true; |
| | | |
| | | try { |
| | | this.printerLabel();//打印 |
| | | this.printerLabel(); //打印 |
| | | } catch (error) { |
| | | console.error('打印失败:', error); |
| | | this.isPrinting = false; |
| | |
| | | // 页面初始化时设置按钮状态 |
| | | this.resetButtonState(); |
| | | // 添加打印状态监听 |
| | | if(!isPrinterInitialized){ |
| | | if (!isPrinterInitialized) { |
| | | const self = this; |
| | | globalEvent.addEventListener('onPrintCallback', function(e) { |
| | | uni.showToast({ |
| | |
| | | } |
| | | //初始化打印 |
| | | this.initPrinter(); |
| | | |
| | | |
| | | }, |
| | | onReady() { |
| | | |
| | | |
| | | }, |
| | | onUnload() { |
| | | // 调用同步方法 |
| | | |
| | | |
| | | } |
| | | } |
| | | </script> |