From cdc6decaadbc0abbe46167a0796fa7f701443d7f Mon Sep 17 00:00:00 2001
From: xwt <2740516069@qq.com>
Date: 星期五, 05 九月 2025 13:14:35 +0800
Subject: [PATCH] llj优化

---
 pages/QC/LLJ/detail.vue |  126 +++++++++++++++++++++++++++++++++++++++---
 1 files changed, 117 insertions(+), 9 deletions(-)

diff --git a/pages/QC/LLJ/detail.vue b/pages/QC/LLJ/detail.vue
index 147675f..0b40165 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">
@@ -139,14 +141,22 @@
 								澶囨敞
 							</button>
 							<input v-if="(tableData.length < formData.checkQyt) && formData.fupAllow && formData.fdownAllow"
+								ref="numberInput"
+								:focus="isFocus"
 								@input="onNumberInput"
+								@confirm="onEnterSave"
+								@blur="isFocus = false"
 								v-model="formData.fcheckResu"
 								type="text"
 								class="result-input"
 								placeholder="璇疯緭鍏ユ楠岀粨鏋�..."
 								placeholder-class="placeholder" />
 							<input v-else
+								ref="textInput"
+								:focus="isFocus"
 								@input="search($event)"
+								@confirm="onEnterSave"
+								@blur="isFocus = false"
 								v-model="inputTxt"
 								type="text"
 								class="result-input"
@@ -178,7 +188,10 @@
 						 
 						<view class="input-wrapper" style="margin-top: 15px;">
 
-							<input v-if="(tableData.length < formData.checkQyt)" @input="search($event)"
+							<input v-if="(tableData.length < formData.checkQyt)" 
+								ref="textInput2"
+								@input="search($event)"
+								@confirm="onEnterSave"
 								v-model="inputTxt" type="text" class="result-input" placeholder="璇疯緭鍏ユ楠岀粨鏋�..."
 								placeholder-class="placeholder" />
 							<button v-if="(tableData.length < formData.checkQyt)"
@@ -288,9 +301,76 @@
 				meomPopup: false,
 				showMeom:false,
 				meom: '',
+				autoSaveTimer: null, // 鑷姩淇濆瓨瀹氭椂鍣�
+				isFocus: false, // 鏂板锛屾帶鍒惰緭鍏ユ鑱氱劍
 			}
 		},
 		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;
@@ -375,6 +455,10 @@
 			//妫�娴嬭緭鍏ユ鐨勮緭鍏ワ紝骞剁粰鍙橀噺璧嬪��
 			search(event) {
 				this.formData.fcheckResu = event.detail.value;
+				this.inputTxt = event.detail.value;
+				
+				// 瑙﹀彂鑷姩淇濆瓨
+				this.autoSaveResult();
 			},
 			onNumberInput(e) {
 				// 鍙厑璁歌緭鍏ユ暟瀛楀拰灏忔暟鐐�
@@ -383,6 +467,9 @@
 				val = val.replace(/\.{2,}/g, '.');
 				val = val.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.');
 				this.formData.fcheckResu = val;
+				
+				// 瑙﹀彂鑷姩淇濆瓨
+				this.autoSaveResult();
 			},
 			toggleResult(item) {
 				let fstand = "鈭�";
@@ -478,6 +565,11 @@
 					this.$showMessage("淇濆瓨鎴愬姛");
 					this.refreshResult();
 					this.inputTxt = '';
+					// 浣跨敤 isFocus 鎺у埗鑱氱劍锛屽吋瀹瑰绔�
+					this.isFocus = false;
+					this.$nextTick(() => {
+						this.isFocus = true;
+					});
 				})
 
 			},
@@ -697,6 +789,14 @@
 			this.$nextTick(() => {
 				this.validateBatchInput();
 			});
+		},
+		
+		// 椤甸潰鍗歌浇鏃舵竻闄ゅ畾鏃跺櫒
+		onUnload() {
+			if (this.autoSaveTimer) {
+				clearTimeout(this.autoSaveTimer);
+				this.autoSaveTimer = null;
+			}
 		}
 	}
 </script>
@@ -731,17 +831,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