achao 2 年之前
父节点
当前提交
204ec8d96e
共有 1 个文件被更改,包括 175 次插入77 次删除
  1. 175 77
      pages/erpbusiness/sendCommand.vue

+ 175 - 77
pages/erpbusiness/sendCommand.vue

@@ -159,10 +159,10 @@
 		methods: {
 
 			clearBlue() {
-				
+
 				let tmp = this.Bluetooth;
 				uni.closeBLEConnection({
-					deviceId:tmp.BLEInformation.deviceId
+					deviceId: tmp.BLEInformation.deviceId
 				})
 				tmp.BLEInformation.deviceId = ''
 				this.$store.commit('BLEInformationSet', tmp);
@@ -171,7 +171,7 @@
 				// 	icon: 'none'
 				// })
 				uni.navigateBack({
-					delta:1
+					delta: 1
 				})
 			},
 			goToList() {
@@ -205,178 +205,212 @@
 				//编号
 				// command.rowSpace(10);
 				if (that.gridList.qualityNo) {
+					command.setText(that.gridList.qualityNo.substring(that.gridList.qualityNo.length - 3));
 					command.bold(3); //加粗
 					command.setFontSize(36); //字体大小
 					command.setSelectJustification(1) //居中
 					command.rowSpace(200);
-					command.setText(that.gridList.qualityNo.substring(that.gridList.qualityNo.length - 3));
-				} else {
-					uni.showToast('编号错误!')
+					command.setPrint();
+					// command.rowSpace(60);
+					// command.bold(0); //取消加粗
+					// command.setFontSize(0); //正常字体
 				}
 
 
-				command.setPrint();
-				command.rowSpace(60);
-				command.bold(0); //取消加粗
-				command.setFontSize(0); //正常字体
-
 				// 标题
+
+				command.setText("粮食质检单");
 				command.bold(1); //加粗
-				command.setFontSize(16); //字体大小
 				command.setSelectJustification(1) //居中
+				command.rowSpace(60);
 				// command.rowSpace(10);
-				command.setText("粮食质检单");
 				command.setPrint();
-				command.rowSpace(60);
-				command.bold(0); //取消加粗
-				command.setFontSize(0); //正常字体
+
 				// 二维码
-				command.rowSpace(60);
 				command.setSelectSizeOfModuleForQRCode(5);
 				command.setSelectErrorCorrectionLevelForQRCode(7)
 				command.setStoreQRCodeData(that.gridList.compId + '&' + that.gridList.qualityNo + '&' + that.gridList
 					.warehouseId);
+				command.rowSpace(60);
 				command.setPrintQRCode();
+
 				//客户姓名
+
+				command.setText("客户姓名:" + that.gridList.customerName);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("客户姓名:" + that.gridList.customerName);
 				command.setPrint();
 				//客户身份证
+
+				command.setText("客户身份证:" + that.gridList.customerNumberCard);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("客户身份证:" + that.gridList.customerNumberCard);
 				command.setPrint();
+
 				//客户电话
+
+				command.setText("客户电话:" + that.gridList.customerPhone);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("客户电话:" + that.gridList.customerPhone);
 				command.setPrint();
+
 				//车牌号
+
+				command.setText("车牌号:" + that.gridList.carNumber);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("车牌号:" + that.gridList.carNumber);
 				command.setPrint();
+
 				if (that.gridList.boxNo) {
 					//箱号
+
+					command.setText("箱号-1:" + that.gridList.boxNo);
 					command.setSelectJustification(0); //居左
 					command.setLeftMargin(30)
-					command.setText("箱号-1:" + that.gridList.boxNo);
 					command.setPrint();
 				}
 				if (that.gridList.boxNoOther) {
 					//箱号
+
+					command.setText("箱号-2:" + that.gridList.boxNoOther);
 					command.setSelectJustification(0); //居左
 					command.setLeftMargin(30)
-					command.setText("箱号-2:" + that.gridList.boxNoOther);
 					command.setPrint();
 				}
 				if (that.gridList.titleNo) {
 					//封号
+
+					command.setText("封号-1:" + that.gridList.titleNo);
 					command.setSelectJustification(0); //居左
 					command.setLeftMargin(30)
-					command.setText("封号-1:" + that.gridList.titleNo);
 					command.setPrint();
 				}
 				if (that.gridList.titleNoOther) {
 					//封号
+
+					command.setText("封号-2:" + that.gridList.titleNoOther);
 					command.setSelectJustification(0); //居左
 					command.setLeftMargin(30)
-					command.setText("封号-2:" + that.gridList.titleNoOther);
 					command.setPrint();
 				}
 				//仓位号
+
+				command.setText("仓位号:" + that.gridList.binNumber);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("仓位号:" + that.gridList.binNumber);
 				command.setPrint();
 				//收货单位
+
+				command.setText("收货单位:" + that.gridList.compName);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("收货单位:" + that.gridList.compName);
 				command.setPrint();
 				//联系人
+
+				command.setText("联系人:" + that.gridList.person);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("联系人:" + that.gridList.person);
 				command.setPrint();
+
 				//联系电话
+
+				command.setText("联系电话:" + that.gridList.personPhone);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("联系电话:" + that.gridList.personPhone);
 				command.setPrint();
+
 				//货名
+				command.setText("货名:" + that.gridList.goodsName);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("货名:" + that.gridList.goodsName);
 				command.setPrint();
+
 				//类型
+
+				command.setText("类型:" + that.gridList.type);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("类型:" + that.gridList.type);
 				command.setPrint();
+
 				//容量
+
+				command.setText("容量(克/升):" + that.gridList.bulkDensity);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("容量(克/升):" + that.gridList.bulkDensity);
 				command.setPrint();
+
 				//不完善粒
+
+				command.setText("不完善粒(%):" + that.gridList.imperfectGrain);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("不完善粒(%):" + that.gridList.imperfectGrain);
 				command.setPrint();
+
 				//等级
+
+				command.setText("等级:" + that.gridList.grade);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("等级:" + that.gridList.grade);
 				command.setPrint();
+
 				//水分
+				command.setText("水分(%):" + that.gridList.waterContent);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("水分(%):" + that.gridList.waterContent);
 				command.setPrint();
 				//热损伤
+
+				command.setText("热损伤(%):" + that.gridList.jiaorenli);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("热损伤(%):" + that.gridList.jiaorenli);
 				command.setPrint();
 				//单价
-				command.setSelectJustification(0); //居左
-				command.setLeftMargin(30)
 				if (that.gridList.type == '潮粮') {
 					command.setText("单价(元/公斤):" + that.gridList.tidalGrainPrice);
-				} else {
+					command.setPrint();
 				}
-				command.setPrint();
-				//杂质
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
+
+				//杂质
+
 				command.setText("杂质(%):" + that.gridList.impurity);
+				command.setSelectJustification(0); //居左
+				command.setLeftMargin(30)
 				command.setPrint();
+
 				//霉变粒
+
+				command.setText("霉变粒(%):" + that.gridList.mildewGrain);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("霉变粒(%):" + that.gridList.mildewGrain);
 				command.setPrint();
+
 				//购粮性质
+				command.setText("购粮性质:" + that.gridList.natureOfGrainPurchase);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("购粮性质:" + that.gridList.natureOfGrainPurchase);
 				command.setPrint();
+
 				//仓位号
+
+				command.setText("仓位号:" + that.gridList.binNumber);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("仓位号:" + that.gridList.binNumber);
 				command.setPrint();
+
 				//囤位号
+
+				command.setText("囤位号:" + that.gridList.storageTagNo);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("囤位号:" + that.gridList.storageTagNo);
 				command.setPrint();
+
 				//质检员
+
+				command.setText("质检员:" + that.gridList.qualityInspector);
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("质检员:" + that.gridList.qualityInspector);
 				command.setPrint();
 				//客户签名
 				// command.rowSpace(100);
@@ -386,9 +420,10 @@
 				// command.setPrint();
 				// command.rowSpace(100);
 				//收货单位签名或盖章
+
+				command.setText("收货单位签名或盖章:");
 				command.setSelectJustification(0); //居左
 				command.setLeftMargin(30)
-				command.setText("收货单位签名或盖章:");
 				command.setPrintAndFeed(150);
 				command.setPrintAndFeedRow(10);
 				that.isReceiptSend = true;
@@ -400,15 +435,26 @@
 			//准备发送,根据每次发送字节数来处理分包数量
 			prepareSend(buff) {
 				console.log(buff);
-				let that = this
-				let time = that.oneTimeData
-				let looptime = parseInt(buff.length / time);
-				let lastData = parseInt(buff.length % time);
-				console.log(looptime + "---" + lastData)
-				this.looptime = looptime + 1;
-				this.lastData = lastData;
-				this.currentTime = 1;
-				that.Send(buff)
+				// let that = this
+				// let time = that.oneTimeData
+				// let looptime = parseInt(buff.length / time);
+				// let lastData = parseInt(buff.length % time);
+				// console.log(looptime + "---" + lastData)
+				// this.looptime = looptime + 1;
+				// this.lastData = lastData;
+				// this.currentTime = 1;
+				// that.Send(buff)
+				var that = this;
+				var time = that.oneTimeData;
+				var looptime = parseInt(buff.length / time);
+				var lastData = parseInt(buff.length % time); //console.log(looptime + "---" + lastData)
+
+				that.setData({
+					looptime: looptime + 1,
+					lastData: lastData,
+					currentTime: 1
+				});
+				that.Send(buff);
 			},
 			//查询打印机状态
 			queryStatus() {
@@ -442,46 +488,98 @@
 					}
 				}
 				console.log("第" + currentTime + "次发送数据大小为:" + buf.byteLength)
+
 				let {
 					BLEInformation
 				} = that.Bluetooth;
 
-				plus.bluetooth.writeBLECharacteristicValue({
+				uni.writeBLECharacteristicValue({
 					deviceId: BLEInformation.deviceId,
-					serviceId: BLEInformation.writeServiceId,
+				 serviceId: BLEInformation.writeServiceId,
 					characteristicId: BLEInformation.writeCharaterId,
 					value: buf,
 					success: function(res) {
-						console.log(res)
+						if (currentTime <= loopTime) {
+							// wx.showLoading({
+							//   title: '传输中...',
+							// })
+						} else {
+							uni.showToast({
+				 			title: '已打印第' + currentPrint + '张成功'
+				  	});
+						} //console.log(res)
 					},
 					fail: function(e) {
-						console.log(e)
-					},
+						uni.showToast({
+							title: '打印第' + currentPrint + '张失败',
+							icon: 'none'
+						}); //console.log(e)
+				 },
 					complete: function() {
-						currentTime++
+						currentTime++;
+
 						if (currentTime <= loopTime) {
-							that.currentTime = currentTime;
-							that.Send(buff)
+							that.setData({
+								currentTime: currentTime
+							});
+							that.Send(buff);
 						} else {
-							uni.showToast({
-								title: '已打印第' + currentPrint + '张',
-							})
 							if (currentPrint == printNum) {
-								that.looptime = 0;
-								that.lastData = 0;
-								that.currentTime = 1;
-								that.isReceiptSend = false;
-								that.isLabelSend = false;
-								that.currentPrint = 1;
+								that.setData({
+									looptime: 0,
+									lastData: 0,
+									currentTime: 1,
+									isReceiptSend: false,
+									currentPrint: 1
+								});
 							} else {
 								currentPrint++;
-								that.currentPrint = currentPrint;
-								that.currentTime = 1;
-								that.Send(buff)
+								that.setData({
+									currentPrint: currentPrint,
+									currentTime: 1
+								});
+								that.Send(buff);
 							}
 						}
 					}
-				})
+				});
+
+				// plus.bluetooth.writeBLECharacteristicValue({
+				// 	deviceId: BLEInformation.deviceId,
+				// 	serviceId: BLEInformation.writeServiceId,
+				// 	characteristicId: BLEInformation.writeCharaterId,
+				// 	value: buf,
+				// 	success: function(res) {
+				// 		console.log(res)
+				// 	},
+				// 	fail: function(e) {
+				// 		console.log(e)
+				// 	},
+				// 	complete: function() {
+				// 		currentTime++
+				// 		if (currentTime <= loopTime) {
+				// 			that.currentTime = currentTime;
+				// 			that.Send(buff)
+				// 		} else {
+				// 			uni.showToast({
+				// 				title: '已打印第' + currentPrint + '张',
+				// 			})
+				// 			if (currentPrint == printNum) {
+				// 				that.looptime = 0;
+				// 				that.lastData = 0;
+				// 				that.currentTime = 1;
+				// 				that.isReceiptSend = false;
+				// 				that.isLabelSend = false;
+				// 				that.currentPrint = 1;
+				// 			} else {
+				// 				currentPrint++;
+				// 				that.currentPrint = currentPrint;
+				// 				that.currentTime = 1;
+				// 				that.Send(buff)
+				// 			}
+				// 		}
+				// 	}
+				// })
 			},
 			buffBindChange: function(res) { //更改打印字节数
 				let index = res.detail.value