| | |
| | | |
| | | }, |
| | | printerLabel() { |
| | | console.log('测试打印'); |
| | | const formatDate = (date = new Date()) => |
| | | date.toISOString().split('T')[0]; |
| | | const formatDate = new Date().toISOString().split('T')[0]; |
| | | printer.setLineSpacing({ |
| | | spacing: 1.2 |
| | | }); |
| | |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '打印日期:'+this.formatDate()+'\r\n' |
| | | content: '打印日期:'+formatDate+'\r\n' |
| | | }); |
| | | printer.printQR2({ |
| | | text: this.barCodeInfo['条码编号'], |
| | |
| | | fontSize: 2, |
| | | isBold: false, |
| | | isUnderLine: false, |
| | | content: '打印日期:'+this.formatDate()+'\r\n' |
| | | content: '打印日期:'+formatDate+'\r\n' |
| | | }); |
| | | printer.printQR2({ |
| | | text: this.barCodeSplitInfo[0]['HBarCode'], |
| | |
| | | line_length: 5 |
| | | }); |
| | | printer.printGoToNextMark(); |
| | | console.log('测试打印QR结束'); |
| | | }, |
| | | printerLabel2() { |
| | | console.log('测试打印'); |
| | | const formatDate = (date = new Date()) => |
| | | 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' |
| | | +'打印日期:'+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' |
| | | +'打印日期:'+formatDate+'\r\n'+this.barCodeSplitInfo[0]['HBarCode']+'\r\n' |
| | | |
| | | , |
| | | }) |
| | | printer.setLineSpacing({ |
| | | spacing: 1.2 |
| | | }); |
| | | |
| | | printer.setUnwindPaperLen({ length: 60 }); |
| | | printer.setFontSize({ |
| | | fontSize: 1 |
| | | }); |
| | | //打印母标签 |
| | | 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' |
| | | }); |
| | | 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' |
| | | }); |
| | | 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' |
| | | }); |
| | | 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: '打印日期:'+formatDate+'\r\n' |
| | | }); |
| | | printer.printQR2({ |
| | | text: this.barCodeInfo['条码编号'], |
| | | height: 120, |
| | | offset: 3 |
| | | }); |
| | | printer.printLine({ |
| | | line_length: 5 |
| | | }); |
| | | printer.printGoToNextMark(); |
| | | console.log('测试打印QR结束'); |
| | | }, |
| | | doRequest(url, data, resFunction, errFunction, method) { |
| | |
| | | title: '拆分数量不得为空!' |
| | | }); |
| | | } |
| | | if (parseFloat(this.barCodeInfoMeta.splitNum) > parseFloat(this.barCodeInfo['数量'])) { |
| | | if (parseFloat(this.barCodeInfoMeta.splitNum) > parseFloat(this.barCodeInfo['条码剩余数量'])) { |
| | | return uni.showToast({ |
| | | icon: 'none', |
| | | title: '拆分数量不能大于条码原数量!' |
| | |
| | | }); |
| | | |
| | | //更新原先条码数量 |
| | | this.barCodeInfo['剩余数量'] = this.barCodeInfo['数量'] - this.barCodeInfoMeta.splitNum; |
| | | this.barCodeInfo['剩余数量'] = this.barCodeInfo['条码剩余数量'] - this.barCodeInfoMeta.splitNum; |
| | | |
| | | // 拆码成功,禁用拆码按钮,放开生成按钮 |
| | | this.cantSplit = true; |
| | |
| | | return acc + obj["HSplitNum"] |
| | | }, 0) |
| | | |
| | | if (sum > this.barCodeInfo["HQty"]) { |
| | | if (sum > this.barCodeInfo["条码剩余数量"]) { |
| | | return uni.showToast({ |
| | | icon: 'none', |
| | | title: '拆码数量和不得大于条码数量' |
| | |
| | | }); |
| | | return; |
| | | } |
| | | |
| | | this.isPrinting = true; |
| | | |
| | | try { |
| | | let HBarCodeNoStr = `${this.barCodeSplitInfo[0]['HBarCode']}`; |
| | | console.log('获取数据', HBarCodeNoStr); |
| | | |
| | | // 显示打印中状态 |
| | | uni.showLoading({ |
| | | title: '打印中...', |
| | | mask: true |
| | | }); |
| | | |
| | | // 获取打印数据 |
| | | const printData = await new Promise((resolve, reject) => { |
| | | uni.request({ |
| | | url: this.serverUrl + '/Sc_BarCode/GetSplitBarCode_SubList', |
| | | data: { |
| | | HBarCodeNo: HBarCodeNoStr |
| | | }, |
| | | success: (res) => { |
| | | if (res.data.count == 1) { |
| | | resolve(res.data.data[0]); |
| | | } else { |
| | | reject(new Error(res.data.Message || '未找到打印数据')); |
| | | } |
| | | }, |
| | | fail: (err) => { |
| | | reject(new Error('接口请求失败')); |
| | | } |
| | | }); |
| | | }); |
| | | |
| | | const item = printData; |
| | | |
| | | // 等待打印组件更新 |
| | | await this.$nextTick(); |
| | | |
| | | |
| | | // 打印成功后重置状态 |
| | | uni.hideLoading(); |
| | | this.printerLabel();//打印 |
| | | this.isPrinting = false; |
| | | } catch (error) { |
| | | console.error('打印失败:', error); |
| | | uni.hideLoading(); |
| | | this.isPrinting = false; |
| | | |
| | | uni.showToast({ |
| | |
| | | duration: 2000 |
| | | }); |
| | | //成功后设置状态 |
| | | //self.isPrinting = false; |
| | | self.isPrinting = false; |
| | | //this.resetButtonState(); |
| | | } else if (e.key == 3) { |
| | | //self.isPrinting = false; |
| | | self.isPrinting = false; |
| | | uni.showToast({ |
| | | title: '缺纸', |
| | | duration: 2000 |