From d01658c63cd541fe4ea5cec5c4bd7f23b9408cdb Mon Sep 17 00:00:00 2001
From: 647556386 <647556386@qq.com>
Date: 星期六, 18 十月 2025 15:04:56 +0800
Subject: [PATCH] 前端,pda,后端接口更改,新增,优化

---
 吉安PDA/pages/stash/boxing.vue |  232 ++++++++++++++++++++++++++++++++++------------------------
 1 files changed, 136 insertions(+), 96 deletions(-)

diff --git "a/\345\220\211\345\256\211PDA/pages/stash/boxing.vue" "b/\345\220\211\345\256\211PDA/pages/stash/boxing.vue"
index 06517fe..c7ce770 100644
--- "a/\345\220\211\345\256\211PDA/pages/stash/boxing.vue"
+++ "b/\345\220\211\345\256\211PDA/pages/stash/boxing.vue"
@@ -18,24 +18,11 @@
 							<uni-easyinput type="text" :placeholder="Testplaceholder" ref='midInput'
 								v-model="Initiallife" />
 						</uni-forms-item>
-						<!-- <uni-forms-item>
-							<checkbox checked="check">鏄惁婊$洏</checkbox>
-						</uni-forms-item> -->
 						<uni-forms-item>
 							<button @click="submit" type="primary" size="default" style="margin-top: 2%;">缁勭洏</button>
 						</uni-forms-item>
 					</uni-forms>
 					<uni-list>
-						<!-- <uni-list-item direction="column" v-for="item in matTotal" :key="item.matCode">
-							<template v-slot:body>
-								<view class="uni-list-box">
-									<view class="uni-content">
-										<view class="uni-title-sub uni-ellipsis-2">鐗╂枡缂栫爜锛歿{item.matCode}}</view>
-										<view class="uni-title-sub uni-ellipsis-2">鏁伴噺锛歿{item.matQuantity}}</view>
-									</view>
-								</view>
-							</template>
-						</uni-list-item> -->
 						<uni-list-item direction="column" v-for="(item,index) in matInfos" :key="index">
 							<template v-slot:body>
 								<view class="uni-list-box">
@@ -46,7 +33,17 @@
 										<view class="uni-title-sub uni-ellipsis-2">閲囪喘鍗曞彿锛歿{item.purchaseOrderNo}}</view>
 										<view class="uni-note">鐗╂枡缂栫爜锛歿{item.materielCode}}</view>
 										<view class="uni-note">鎵规鍙凤細{{item.lotNo}}</view>
-										<view class="uni-note">鏁伴噺锛歿{item.quantity}}</view>
+										<!-- 鏁伴噺缂栬緫妗� -->
+										<view class="uni-note" style="display: flex; align-items: center; gap: 10rpx;">
+											鏁伴噺锛�
+											<uni-easyinput 
+												type="number" 
+												min="1" 
+												style="width: 150rpx; display: inline-block;"
+												v-model="item.editableQuantity" 
+												@input="handleQuantityChange(item)"
+											/>
+										</view>
 										<view class="uni-note">鐢熶骇鏃ユ湡锛歿{item.productionDate}}</view>
 										<view class="uni-note">鏈夋晥鏈燂細{{item.effectiveDate}}</view>
 									</view>
@@ -122,7 +119,17 @@
 										<view class="uni-title-sub uni-ellipsis-2">閲囪喘鍗曞彿锛歿{item.purchaseOrderNo}}</view>
 										<view class="uni-note">鐗╂枡缂栫爜锛歿{item.materielCode}}</view>
 										<view class="uni-note">鎵规鍙凤細{{item.lotNo}}</view>
-										<view class="uni-note">鏁伴噺锛歿{item.quantity}}</view>
+										<!-- 鏁伴噺缂栬緫妗� -->
+										<view class="uni-note" style="display: flex; align-items: center; gap: 10rpx;">
+											鏁伴噺锛�
+											<uni-easyinput 
+												type="number" 
+												min="1" 
+												style="width: 150rpx; display: inline-block;"
+												v-model="item.editableQuantity" 
+												@input="handlePkQuantityChange(item)"
+											/>
+										</view>
 										<view class="uni-note">鐢熶骇鏃ユ湡锛歿{item.productionDate}}</view>
 										<view class="uni-note">鏈夋晥鏈燂細{{item.effectiveDate}}</view>
 									</view>
@@ -205,10 +212,17 @@
 			this.getData();
 		},
 		methods: {
-			// voiceSpeech(src) {
-			// 	innerAudioContext.src = src; // '../../static/success.mp3';
-			// 	innerAudioContext.play();
-			// },
+			// 缁勭洏椤垫暟閲忓彉鏇存牎楠�
+			handleQuantityChange(item) {
+				// 纭繚鏁伴噺涓烘鏁存暟
+				item.editableQuantity = item.editableQuantity ? Math.max(1, parseInt(item.editableQuantity)) : 1;
+			},
+
+			// 鍏ュ钩搴撻〉鏁伴噺鍙樻洿鏍¢獙
+			handlePkQuantityChange(item) {
+				item.editableQuantity = item.editableQuantity ? Math.max(1, parseInt(item.editableQuantity)) : 1;
+			},
+			
 			//wms鍏ュ钩搴�
 			pksubmit() {
 				if (this.pkmatInfos.length == 0) {
@@ -218,9 +232,14 @@
 					})
 					return;
 				}
-				this.$u.post('/api/InboundOrder/WMSInPinKu?warehouseId=' + this.warehouseId, this
-					.pksns).then(res => {
-					debugger
+				
+				// 鍑嗗鎻愪氦鏁版嵁锛屽寘鍚紪杈戝悗鐨勬暟閲�
+				const submitData = this.pkmatInfos.map(item => ({
+					serialNumber: item.serialNumber,
+					quantity: item.editableQuantity
+				}));
+				
+				this.$u.post('/api/InboundOrder/WMSInPinKu?warehouseId=' + this.warehouseId, submitData).then(res => {
 					if (res.status) {
 						this.$refs.uToast.show({
 							title: "鍏ュ簱鎴愬姛",
@@ -237,45 +256,49 @@
 					}
 				})
 			},
+			
 			pksnInput() {
 				this.$nextTick(() => {
-					if (this.pkmaterSn != "") {
+					if (!this.pkmaterSn) return;
+
+					// 寤惰繜100ms纭繚鎵爜瀹屾垚
+					setTimeout(() => {
 						this.focus = false;
-						var matSn = this.pkmaterSn;
-						setTimeout(() => {
+
+						// 鏍¢獙鍐呯鐮佸畬鏁存��
+						const requiredFields = ['M:', 'BS:', 'DM:', 'DE:', 'Q:', 'PO:', 'DN:'];
+						const hasAllFields = requiredFields.every(field => this.pkmaterSn.includes(field));
+						if (!hasAllFields) {
+							this.$refs.uToast.show({
+								title: "鍐呯鐮佷笉瀹屾暣锛岃閲嶆柊鎵弿",
+								type: "error"
+							});
 							this.pkmaterSn = "";
-						}, 10);
+							return;
+						}
+
+						const matSn = this.pkmaterSn;
+						this.pkmaterSn = "";
+
 						this.$u.post('/api/MaterielInfo/CodeAnalysis?serNum=' + matSn, {}).then((res) => {
 							if (res.status) {
-								this.pksns.push(res.data.serialNumber);
-								this.pkmatInfos.push(res.data);
-								if (!res.status) {
-									this.$refs.uToast.show({
-										title: res.message,
-										type: "error"
-									})
-									// setTimeout(() => {
-									// 	this.voiceSpeech('../../static/fail.mp3');
-									// }, 100);
-									return;
-								}
-								// setTimeout(() => {
-								// 	this.voiceSpeech('../../static/success.mp3');
-								// }, 100);
-								return;
+								// 鏂板鍙紪杈戞暟閲忓瓧娈�
+								const tempData = res.data;
+								tempData.editableQuantity = tempData.quantity;
+								
+								this.pksns.push(tempData.serialNumber);
+								this.pkmatInfos.push(tempData);
 							} else {
 								this.$refs.uToast.show({
 									title: res.message,
 									type: "error"
 								})
-								// setTimeout(() => {
-								// 	this.voiceSpeech('../../static/fail.mp3');
-								// }, 100);
 							}
 						})
-					}
+					}, 100);
 				})
 			},
+			
 			//瑙g洏
 			releasebox() {
 				if (this.value.length == 0) {
@@ -315,6 +338,7 @@
 					}
 				})
 			},
+			
 			releaseboxInput() {
 				this.$nextTick(() => {
 					if (this.value.length == 0) {
@@ -361,7 +385,6 @@
 			},
 
 			updateFocus() {
-				debugger
 				this.$nextTick(() => {
 					this.materSn = '';
 					if (!this.focus) {
@@ -369,13 +392,14 @@
 					}
 				});
 			},
+			
 			barcodeFocus() {
-				debugger
 				this.barcode = '';
 				if (this.focus) {
 					this.focus = false;
 				}
 			},
+			
 			getData() {
 				var postData = {
 					MainData: {
@@ -391,6 +415,7 @@
 					}
 				})
 			},
+			
 			onClickItem(e) {
 				this.focus = false;
 				this.addressFocus = false;
@@ -401,77 +426,75 @@
 					}
 				}
 			},
+			
 			barcodeInput() {
 				this.$nextTick(function(x) {
 					if (this.barcode.length > 0) {
-						// if (this.barcode.substring(0, 1) == 'A' || this.barcode.substring(0, 2) == 'TP') {
 						this.focus = true;
-						// } else {
-						// 	this.$refs.uToast.show({
-						// 		title: "鎵爜閿欒,璇锋壂鎻忔墭鐩樼爜",
-						// 		type: "error"
-						// 	})
-						// }
 					}
 				})
 			},
+			
 			snInput() {
 				this.$nextTick(() => {
-					if (this.warehouseId == 6 || this.warehouseId == 2 || this.warehouseId == 3) {
-						if (this.sns.length > 0) {
-							this.sns = [];
-						}
-					}
-					if (this.materSn != "") {
+					if (!this.materSn) return;
+
+					// 寤惰繜100ms纭繚鎵爜瀹屾垚
+					setTimeout(() => {
 						this.focus = false;
+						
+						// 浠撳簱11鐨勭壒娈婂鐞�
 						if(this.warehouseId==11){
 							this.materSn=this.materSn.replace(/,SC.*/, '');
 						}
-						if (this.materSn.split(',').length != 6) {
+						
+						// 鏍¢獙鍐呯鐮佸畬鏁存��
+						const requiredFields = ['M:', 'BS:', 'DM:', 'DE:', 'Q:', 'PO:', 'DN:'];
+						const hasAllFields = requiredFields.every(field => this.materSn.includes(field));
+						if (!hasAllFields) {
+							this.$refs.uToast.show({
+								title: "鍐呯鐮佷笉瀹屾暣锛岃閲嶆柊鎵弿",
+								type: "error"
+							});
 							this.materSn = "";
 							return;
 						}
-						var matSn = this.materSn;
-						//setTimeout(() => {
+
+						// 浠撳簱鐗瑰畾閫昏緫
+						if (this.warehouseId == 6 || this.warehouseId == 2 || this.warehouseId == 3) {
+							if (this.sns.length > 0) {
+								this.sns = [];
+							}
+						}
+
+						const matSn = this.materSn;
 						this.materSn = "";
-						//}, 10);
+
 						this.$u.post('/api/MaterielInfo/CodeAnalysis?serNum=' + matSn, {}).then((res) => {
 							this.Testcheck = false;
 							if (res.status) {
-								this.sns.push(res.data.serialNumber);
-								if (this.warehouseId == 6 || this.warehouseId == 2 || this.warehouseId ==
-									3) {
+								// 鏂板鍙紪杈戞暟閲忓瓧娈�
+								const tempData = res.data;
+								tempData.editableQuantity = tempData.quantity;
+								
+								this.sns.push(tempData.serialNumber);
+								if (this.warehouseId == 6 || this.warehouseId == 2 || this.warehouseId == 3) {
 									if (this.matInfos.length > 0) {
 										this.matInfos = [];
 									}
 								}
-								this.matInfos.push(res.data);
-								if (!res.status) {
-									this.$refs.uToast.show({
-										title: res.message,
-										type: "error"
-									})
-									// setTimeout(() => {
-									// 	this.voiceSpeech('../../static/fail.mp3');
-									// }, 100);
-									return;
-								}
-								// setTimeout(() => {
-								// 	this.voiceSpeech('../../static/success.mp3');
-								// }, 100);
+								this.matInfos.push(tempData);
 							} else {
 								this.$refs.uToast.show({
 									title: res.message,
 									type: "error"
 								})
-								// setTimeout(() => {
-								// 	this.voiceSpeech('../../static/fail.mp3');
-								// }, 100);
 							}
 						})
-					}
+					}, 100);
 				})
 			},
+			
 			inbound() {
 				if (this.inboundBarcode == "") {
 					this.$refs.uToast.show({
@@ -521,6 +544,7 @@
 					})
 				})
 			},
+			
 			inputChangebarcode() {
 				this.addressFocus = false;
 				this.$nextTick(function(x) {
@@ -537,18 +561,16 @@
 							}
 						};
 						this.$u.post('/api/StockInfo/StockQueryData', postData).then(res => {
-							// this.stockInfo = [];
 							this.stockInfoDetail = [];
 							if (res.status) {
-								// this.stockInfo = res.data,
 								this.stockInfoDetail = res.data.details
 								//鑾峰彇鎬绘暟閲�
+								this.Summmary = 0;
 								this.stockInfoDetail.forEach(item => {
 									this.Summmary += item.stockQuantity;
 								});
 							} else {
 								this.$refs.uToast.show({
-									// title: "鏈壘鍒版墭鐩樹俊鎭�",
 									title: res.message,
 									type: "error"
 								})
@@ -557,10 +579,17 @@
 					}
 				})
 			},
+			
 			deleteList(res) {
 				this.matInfos.splice(res, 1);
 				this.sns.splice(res, 1);
 			},
+			
+			pkdeleteList(res) {
+				this.pkmatInfos.splice(res, 1);
+				this.pksns.splice(res, 1);
+			},
+			
 			submit() {
 				if (this.barcode == "") {
 					this.$refs.uToast.show({
@@ -593,16 +622,27 @@
 						return;
 					}
 				}
+				
+				// 鍑嗗鎻愪氦鏁版嵁锛屽寘鍚紪杈戝悗鐨勬暟閲�
+				const submitSns = this.matInfos.map(item => ({
+					serialNumber: item.serialNumber,
+					quantity: item.editableQuantity
+				}));
+				
 				if (this.warehouseId == 2) { //娌瑰ⅷ浠撳簱鍖篒D
-					this.sn = this.sns[0];
-					for (var i = 0; i < this.Initiallife - 1; i++) {
-						this.sns.push(this.sn);
+					// 鐗规畩澶勭悊淇濇寔涓嶅彉锛屼絾浣跨敤缂栬緫鍚庣殑鏁伴噺
+					const firstItem = this.matInfos[0];
+					for (var i = 0; i < firstItem.editableQuantity - 1; i++) {
+						submitSns.push({
+							serialNumber: firstItem.serialNumber,
+							quantity: 1
+						});
 					}
 				}
-				let url = 'palletCode=' + this.barcode + '&initiallife=' + this.Initiallife + '&warehouseId=' + this
-					.warehouseId;
+				
+				let url = 'palletCode=' + this.barcode + '&initiallife=' + this.Initiallife + '&warehouseId=' + this.warehouseId;
 
-				this.$u.post('/api/InboundOrder/ManualMaterielGroup?' + url, this.sns).then(res => {
+				this.$u.post('/api/InboundOrder/ManualMaterielGroup?' + url, submitSns).then(res => {
 					this.Testcheck = false;
 					if (res.status) {
 						this.$refs.uToast.show({
@@ -647,4 +687,4 @@
 	.headerstyle {
 		width: 90%;
 	}
-</style>
\ No newline at end of file
+</style>

--
Gitblit v1.9.3