From 14a3a0f312a69ccb70e530f7aa25ac9bda07d007 Mon Sep 17 00:00:00 2001
From: whycq <913841844@qq.com>
Date: 星期六, 26 十月 2024 09:09:02 +0800
Subject: [PATCH] ###

---
 pages/out/checkOut.vue |   80 ++++++++++++++++++++++++++++++++++++----
 1 files changed, 72 insertions(+), 8 deletions(-)

diff --git a/pages/out/checkOut.vue b/pages/out/checkOut.vue
index c51f9c1..12f0565 100644
--- a/pages/out/checkOut.vue
+++ b/pages/out/checkOut.vue
@@ -3,8 +3,9 @@
 		<view class="code">
 			<view class="item">
 				<view class="code-decs">绠卞彿:</view>
-				<input type="text" placeholder=" 鎵爜 / 杈撳叆" v-model="barcode" :focus="barcodeFocus"
-					@input="barcodeInput()">
+				<textarea style="background-color: #f0f0f0;max-height: 100rpx;padding: 4px;margin: 4px;"
+					type="textarea" placeholder=" 鎵爜 / 杈撳叆" maxlength="1000" v-model="barcode" :focus="barcodeFocus" 
+					@input="analysis()" />
 			</view>
 		</view>
 		<view class="mat-list-title">
@@ -155,13 +156,76 @@
 				this.msgType1 = type
 				this.$refs.message.open()
 			},
-			// barcode input 浜嬩欢
-			barcodeInput() {
+			analysis() {
 				let _this = this
-				let newBarcode =  this.barcode
-				let barcode =  this.barcode.split(" ")
-				this.targetBatch = barcode[1].slice(3)
-				this.barcode = barcode[1].slice(3)
+				var matObj= {
+					rollNo: '', // 鍗峰彿
+					boxNo: '', // 绠卞彿
+					specs: '', // 瑙勬牸
+					length: '', // 闀垮害
+					netWeight: '', // 鍑�閲�
+					grossWeight: '', // 姣涢噸 
+					splices: '', // 鎺ュご 涓�
+				}
+				// 鍒涘缓涓�涓� Map 瀵硅薄
+				const resultMap = new Map();
+				
+				// 浣跨敤鎹㈣绗︿綔涓哄垎闅旂鍒嗗壊瀛楃涓�
+				const lines = this.barcode.split('\n');
+				console.log(lines);
+				lines.forEach(line => {
+				    // 浣跨敤涓枃鍐掑彿浣滀负鍒嗛殧绗�
+				    const match = line.split('锛�');
+				    if (match.length === 2) {
+				        const key = match[0].trim(); // 涓枃閮ㄥ垎浣滀负閿�
+				        const value = match[1].trim(); // 鍚庨潰鐨勫瓧绗︿覆浣滀负鍊�
+				        resultMap.set(key, value); // 灏嗛敭鍊煎瀛樺叆 Map
+				    }
+				});
+				
+				// 杈撳嚭缁撴灉
+				console.log(resultMap);
+				
+				
+				
+				// 濡傛灉闇�瑕佸皢 Map 杞崲涓烘櫘閫氬璞�
+				const resultObject = Object.fromEntries(resultMap);
+				console.log(resultObject.鍑�閲�);
+				console.log(lines);
+				matObj.rollNo = resultObject.鍗峰彿
+				matObj.boxNo = resultObject.绠卞彿
+				matObj.specs = resultObject.瑙勬牸
+				matObj.length = resultObject.闀垮害
+				matObj.netWeight = resultObject.鍑�閲�
+				matObj.grossWeight = resultObject.姣涢噸
+				matObj.splices = resultObject.鎺ュご
+				
+				console.log(matObj);
+				this.barcodeInput(matObj)
+				// this.checkMatObj(matObj)
+				this.barcodeFocus = false;
+				this.matFocus = false;
+				setTimeout(() => {
+					this.matnr = '';
+					this.matFocus = true;
+				}, 100);
+			},
+			checkMatObj(mat) {
+				var len = this.dataList.length
+				var add = true 
+				for	(let k of this.dataList) {
+					if (mat.boxNo == k.boxNo) {
+						add = false
+					}
+				}
+				if (add) {
+					this.dataList.unshift(mat)
+				}
+			},
+			// barcode input 浜嬩欢
+			barcodeInput(code) {
+				let _this = this
+				let newBarcode =  code
 				uni.request({
 					url: _this.baseUrl + '/mobile/wrkDetl/search/batch/auth',
 					header: {'token': uni.getStorageSync('token')},

--
Gitblit v1.9.1