From 1bcee828a3340d5f5642b3dbcf4cd9733072b7aa Mon Sep 17 00:00:00 2001
From: 啊鑫 <t2856754968@163.com>
Date: 星期一, 21 七月 2025 14:24:35 +0800
Subject: [PATCH] LLJ检验结果录入优化:添加自动保存和回车保存功能

---
 pages/QC/LLJ/detail.vue |  166 ++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 144 insertions(+), 22 deletions(-)

diff --git a/pages/QC/LLJ/detail.vue b/pages/QC/LLJ/detail.vue
index 925e9db..41783ec 100644
--- a/pages/QC/LLJ/detail.vue
+++ b/pages/QC/LLJ/detail.vue
@@ -7,12 +7,14 @@
 		</view>
 
 		<!-- 鏍囩鏍� -->
-		<view class="tabs">
-			<view v-for="(tab, index) in tabs" :key="index" class="tab" :class="{active: currentTab === index}"
-				@tap="switchTab(index,tab.id)">
-				{{ tab.fcheckItem }}
+		<scroll-view class="tabs" scroll-x="true" :show-scrollbar="false">
+			<view class="tabs-container">
+				<view v-for="(tab, index) in tabs" :key="index" class="tab" :class="{active: currentTab === index}"
+					@tap="switchTab(index,tab.id)">
+					{{ tab.fcheckItem }}
+				</view>
 			</view>
-		</view>
+		</scroll-view>
 		<view class="tab-content">
 			<!-- 鍩烘湰淇℃伅 -->
 			<view class="section">
@@ -101,9 +103,9 @@
 						<view class="info-label">涓嶈壇鎻忚堪</view>
 						<view class="info-value danger">{{formData.funit}}</view>
 					</view>
-					<view v-if="formData.meom!=null" class="result-ng">
-						<view class="info-label">澶囨敞</view>
-						<view class="info-value danger">{{formData.meom}}</view>
+					<view class="result-ng">
+					    <view class="info-label">澶囨敞</view>
+					    <view class="info-value danger">{{formData.meom}}</view>
 					</view>
 				</view>
 			</view>
@@ -112,7 +114,7 @@
 			<view class="section">
 				<view class="section-header">妫�楠岀粨鏋滃綍鍏�</view>
 				<view class="section-body">
-					<view class="input-group" v-if="tableData.length >= formData.checkQyt">
+					<view class="input-group" v-if="tableData.length >= formData.checkQyt && formData.fstand == null">
 						<view class="input-wrapper">
 							<input v-model="batchInput" type="text" class="result-input"
 								placeholder="鏍煎紡锛歄K-3 鎴� NG-3锛堣鍕夸慨鏀圭粨鏋滀负鏁板瓧鐨勫�硷級" placeholder-class="placeholder"
@@ -138,8 +140,21 @@
 								<uni-icons type="compose" size="16" color="#fff"></uni-icons>
 								澶囨敞
 							</button>
-							<input v-if="(tableData.length < formData.checkQyt)" @input="search($event)"
-								v-model="inputTxt" type="text" class="result-input" placeholder="璇疯緭鍏ユ楠岀粨鏋�..."
+							<input v-if="(tableData.length < formData.checkQyt) && formData.fupAllow && formData.fdownAllow"
+								@input="onNumberInput"
+								@confirm="onEnterSave"
+								v-model="formData.fcheckResu"
+								type="text"
+								class="result-input"
+								placeholder="璇疯緭鍏ユ楠岀粨鏋�..."
+								placeholder-class="placeholder" />
+							<input v-else
+								@input="search($event)"
+								@confirm="onEnterSave"
+								v-model="inputTxt"
+								type="text"
+								class="result-input"
+								placeholder="璇疯緭鍏ユ楠岀粨鏋�..."
 								placeholder-class="placeholder" />
 							<button v-if="(tableData.length < formData.checkQyt)"
 								style="margin: 0px;background-color: #3498db;color:#ffffff ;" class="btn primary-btn"
@@ -168,6 +183,7 @@
 						<view class="input-wrapper" style="margin-top: 15px;">
 
 							<input v-if="(tableData.length < formData.checkQyt)" @input="search($event)"
+								@confirm="onEnterSave"
 								v-model="inputTxt" type="text" class="result-input" placeholder="璇疯緭鍏ユ楠岀粨鏋�..."
 								placeholder-class="placeholder" />
 							<button v-if="(tableData.length < formData.checkQyt)"
@@ -230,7 +246,7 @@
 			        </form>
 			    </view>
 			</view>
-			<view v-if="showPopup" class="overlay">
+			<view v-if="showMeom" class="overlay">
 				<view class="popup">
 					<h3>淇敼妫�楠岀粨鏋�</h3>
 					<form :modelValue="editData">
@@ -239,7 +255,7 @@
 							<input class="form-input" type="text" v-model="editData.fcheckResu" />
 						</view>
 						<button type="warn" @click="eidt">淇敼</button>
-						<button @click="showPopup = !showPopup">鍙栨秷</button>
+						<button @click="showMeom = !showMeom">鍙栨秷</button>
 					</form>
 				</view>
 			</view>
@@ -275,10 +291,77 @@
 				isBatchInputValid: false,
 				funit:'',
 				meomPopup: false,
+				showMeom:false,
 				meom: '',
+				autoSaveTimer: null, // 鑷姩淇濆瓨瀹氭椂鍣�
 			}
 		},
 		methods: {
+			// 闃叉姈鑷姩淇濆瓨鏂规硶
+			autoSaveResult() {
+				// 娓呴櫎涔嬪墠鐨勫畾鏃跺櫒
+				if (this.autoSaveTimer) {
+					clearTimeout(this.autoSaveTimer);
+				}
+				
+				// 璁剧疆鏂扮殑瀹氭椂鍣紝1绉掑悗鑷姩淇濆瓨
+				this.autoSaveTimer = setTimeout(() => {
+					// 妫�鏌ユ槸鍚﹀凡缁忚揪鍒版楠屾暟閲忎笂闄�
+					if (this.tableData.length >= this.formData.checkQyt) {
+						return;
+					}
+					
+					// 楠岃瘉杈撳叆骞朵繚瀛�
+					if (this.validateAndSave()) {
+						this.saveResult();
+					}
+				}, 2000);
+			},
+			
+			// 楠岃瘉杈撳叆鏄惁鏈夋晥
+			validateAndSave() {
+				// 鏈変笂涓嬮檺鐨勬儏鍐�
+				if (this.formData.fupAllow && this.formData.fdownAllow) {
+					const value = this.formData.fcheckResu;
+					if (!value || value.trim() === '') {
+						return false;
+					}
+					
+					// 楠岃瘉鏄惁涓烘湁鏁堟暟瀛�
+					if (isNaN(parseFloat(value)) || !/^-?\d+(\.\d+)?$/.test(value)) {
+						return false;
+					}
+					
+					return true;
+				} else {
+					// 鏃犱笂涓嬮檺鐨勬儏鍐碉紝妫�楠岀粨鏋滃瓨鍌ㄥ湪 formData.fcheckResu 涓�
+					const value = this.formData.fcheckResu;
+					if (!value || value.trim() === '') {
+						return false;
+					}
+					
+					return true;
+				}
+			},
+			
+			// 澶勭悊鍥炶溅閿繚瀛樹簨浠�
+			onEnterSave() {
+				// 妫�鏌ユ槸鍚﹀凡缁忚揪鍒版楠屾暟閲忎笂闄�
+				if (this.tableData.length >= this.formData.checkQyt) {
+					this.$showMessage("宸茶揪鍒版楠屾暟閲忎笂闄�");
+					return;
+				}
+				
+				// 娓呴櫎鑷姩淇濆瓨瀹氭椂鍣�
+				if (this.autoSaveTimer) {
+					clearTimeout(this.autoSaveTimer);
+					this.autoSaveTimer = null;
+				}
+				
+				// 鐩存帴淇濆瓨缁撴灉
+				this.saveResult();
+			},
+			
 			switchTab(index, mainIds) {
 				this.currentTab = index
 				this.mainId = mainIds;
@@ -363,6 +446,21 @@
 			//妫�娴嬭緭鍏ユ鐨勮緭鍏ワ紝骞剁粰鍙橀噺璧嬪��
 			search(event) {
 				this.formData.fcheckResu = event.detail.value;
+				this.inputTxt = event.detail.value;
+				
+				// 瑙﹀彂鑷姩淇濆瓨
+				this.autoSaveResult();
+			},
+			onNumberInput(e) {
+				// 鍙厑璁歌緭鍏ユ暟瀛楀拰灏忔暟鐐�
+				let val = e.detail.value.replace(/[^\d.]/g, '');
+				// 鍙厑璁镐竴涓皬鏁扮偣
+				val = val.replace(/\.{2,}/g, '.');
+				val = val.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.');
+				this.formData.fcheckResu = val;
+				
+				// 瑙﹀彂鑷姩淇濆瓨
+				this.autoSaveResult();
 			},
 			toggleResult(item) {
 				let fstand = "鈭�";
@@ -413,7 +511,11 @@
 						this.$showMessage("璇疯緭鍏ユ纭殑妫�楠屽��");
 						return;
 					}
-
+					
+					if (!/^-?\d+(\.\d+)?$/.test(this.formData.fcheckResu)) {
+					            this.$showMessage("璇疯緭鍏ユ纭殑鏁板�硷紒");
+					            return;
+					}
 					if (parseFloat(this.formData.fcheckResu) >= parseFloat(this.formData.fdownAllow) && parseFloat(this
 							.formData
 							.fcheckResu) <= parseFloat(this.formData.fupAllow)) {
@@ -483,6 +585,7 @@
 					} else {
 						this.isNumber = false;
 					}
+					
 				})
 			},
 			editResult(fcheckResu) {
@@ -494,20 +597,23 @@
 			},
 			toDetail(item) {
 				this.showPopup = !this.showPopup;
+				this.showMeom = !this.showMeom;
 				this.editData = item;
+				
 			},
 			upMeom() {
 			    this.meomPopup = true;
-			    this.meom = this.formData.meom || ''; // 鍒濆鍖栧娉ㄥ��
+			    
 			},
 			editMeom() {
 			    // 淇濆瓨澶囨敞淇℃伅
-			    if (this.Meom) {
+			    if (this.meom) {
 			        this.$post({
 			            url: "/LLJ/saveRemarksPid",
 			            data: {
 			                pid: this.formData.id,
-			                remarks: this.meom
+			                meom: this.meom,
+							
 			            }
 			        }).then(res => {
 			            if (res.data.tbBillList > 0) {
@@ -534,7 +640,7 @@
 			},
 			editRemarks() {
 				if (this.remarks) {
-					//saveRemarksGid
+					
 					this.$post({
 						url: "/LLJ/saveRemarksPid",
 						data: {
@@ -641,7 +747,7 @@
 				data: {
 					id: this.formID,
 					releaseNo: this.releaseNo,
-					meom:this.meom
+					
 				}
 			}).then(res1 => {
 				let tableData = res1.data.tbBillList
@@ -669,6 +775,14 @@
 			this.$nextTick(() => {
 				this.validateBatchInput();
 			});
+		},
+		
+		// 椤甸潰鍗歌浇鏃舵竻闄ゅ畾鏃跺櫒
+		onUnload() {
+			if (this.autoSaveTimer) {
+				clearTimeout(this.autoSaveTimer);
+				this.autoSaveTimer = null;
+			}
 		}
 	}
 </script>
@@ -703,17 +817,25 @@
 	}
 
 	.tabs {
-		display: flex;
 		background-color: $bg-color;
 		border-bottom: 1px solid $border-color;
+		width: 100%;
+		white-space: nowrap;
+
+		.tabs-container {
+			display: flex;
+			min-width: 100%;
+		}
 
 		.tab {
-			flex: 1;
+			flex: none;
+			min-width: 120px;
 			text-align: center;
-			padding: 12px 0;
+			padding: 12px 16px;
 			border-right: 1px solid $border-color;
 			color: #666;
 			transition: all 0.3s;
+			white-space: nowrap;
 
 			&:last-child {
 				border-right: none;

--
Gitblit v1.9.3