From e1669bfd21fb445d3cd755290d28c900c5a3a831 Mon Sep 17 00:00:00 2001 From: xwt <2740516069@qq.com> Date: 星期二, 03 六月 2025 14:27:20 +0800 Subject: [PATCH] 搜索框添加物料规格,增加批量NG --- pages/QC/LLJ/detail.vue | 173 ++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 files changed, 145 insertions(+), 28 deletions(-) diff --git a/pages/QC/LLJ/detail.vue b/pages/QC/LLJ/detail.vue index af7cc9e..9f4e0d5 100644 --- a/pages/QC/LLJ/detail.vue +++ b/pages/QC/LLJ/detail.vue @@ -108,6 +108,17 @@ <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-wrapper"> + <input v-model="batchInput" type="text" class="result-input" + placeholder="鏍煎紡锛歄K-3 鎴� NG-3锛堣鍕夸慨鏀圭粨鏋滀负鏁板瓧鐨勫�硷級" placeholder-class="placeholder" + @input="validateBatchInput" @blur="validateBatchInput" /> + <button :disabled="!isBatchInputValid" :class="{ 'btn-disabled': !isBatchInputValid }" + style="margin: 0px;background-color: #3498db;color:#ffffff ;" class="btn primary-btn" + @tap="batchUpdateResults">鎵归噺淇敼</button> + </view> + <view v-if="batchInputError" class="error-message">{{ batchInputError }}</view> + </view> <view class="input-group input1"> <view class="input-wrapper"> @@ -127,10 +138,10 @@ @tap="saveResult">淇濆瓨缁撴灉</button> </view> </view> - + <view class="input-group input2"> <view class="input-wrapper"> - + <button class="btn upload-btn" @tap="chooseImage"> <uni-icons type="upload" size="16" color="#fff"></uni-icons> 涓婁紶/鏌ョ湅鍥剧墖 @@ -141,7 +152,7 @@ </button> </view> <view class="input-wrapper" style="margin-top: 15px;"> - + <input v-if="(tableData.length < formData.checkQyt)" @input="search($event)" v-model="inputTxt" type="text" class="result-input" placeholder="璇疯緭鍏ユ楠岀粨鏋�..." placeholder-class="placeholder" /> @@ -157,7 +168,8 @@ <view v-if="tableData.length>0" class="table-container"> <view class="table-header"> <view class="th">缂栧彿</view> - <view class="th">妫�楠岀粨鏋�<i style="color: rgb(0 212 68);" v-if="!(tableData.length < formData.checkQyt)">锛堣緭鍏ュ凡瀹屾垚锛�</i></view> + <view class="th">妫�楠岀粨鏋�<i style="color: rgb(0 212 68);" + v-if="!(tableData.length < formData.checkQyt)">锛堣緭鍏ュ凡瀹屾垚锛�</i></view> <view class="th" v-if="current">鎿嶄綔</view> </view> @@ -168,7 +180,7 @@ {{ item.fcheckResu }} </view> </view> - <view class="td" v-if="current" > + <view class="td" v-if="current"> <button v-if="!isNumber" class="btn danger-btn" @tap="toggleResult(item)"> {{ editResult(item.fcheckResu) }} </button> @@ -228,16 +240,95 @@ showPopup: false, editData: {}, inputTxt: '', - formID:'', - releaseNo:'', - current:false + formID: '', + releaseNo: '', + current: false, + batchInput: '', + batchInputError: '', + isBatchInputValid: false } }, methods: { - switchTab(index,mainIds) { + switchTab(index, mainIds) { this.currentTab = index this.mainId = mainIds; this.refreshResult(); + + }, + validateBatchInput() { + const input = this.batchInput.trim(); + if (!input) { + this.batchInputError = ''; + this.isBatchInputValid = false; + return; + } + + // 楠岃瘉鏍煎紡锛歄K-鏁板瓧 鎴� NG-鏁板瓧 + const match = input.match(/^(OK|NG)-(\d+)$/); + if (!match) { + this.batchInputError = '鏍煎紡閿欒锛岃杈撳叆锛歄K-鏁板瓧 鎴� NG-鏁板瓧'; + this.isBatchInputValid = false; + return; + } + + const count = parseInt(match[2]); + if (count <= 0 || count > this.tableData.length) { + this.batchInputError = `鏁伴噺蹇呴』鍦� 1-${this.tableData.length} 涔嬮棿`; + this.isBatchInputValid = false; + return; + } + + + this.batchInputError = ''; + this.isBatchInputValid = true; + }, + + // 鎵归噺鏇存柊妫�楠岀粨鏋� + batchUpdateResults() { + if (!this.isBatchInputValid) return; + + const [status, countStr] = this.batchInput.split('-'); + const count = parseInt(countStr); + + if (this.tableData.length > 0) { + const firstItem = this.tableData[0]; + const isNumber = /^-?\d+(\.\d+)?$/.test(firstItem.fcheckResu); + if (isNumber) { + this.$showMessage("涓嶈兘鎵归噺淇敼鏁板瓧绫诲瀷鐨勭粨鏋�"); + return; + } + } + let updatedCount = 0; + const requests = []; + for (let i = 0; i < count; i++) { + const item = this.tableData[i]; + const fstand = status === 'OK' ? '鈭�' : '脳'; + const fcheckResu = status; + + requests.push(this.$post({ + url: "/LLJ/UpdateQSItemDetail", + data: { + id: item.id, + mainId: this.formData.id, + releaseNo: this.formData.releaseNo, + fstand: fstand, + fcheckResu: fcheckResu, + updateBy: this.$loginInfo.account, + } + })); + } + + Promise.all(requests) + .then(() => { + this.$showMessage(`鎴愬姛灏嗗墠${count}涓粨鏋滀慨鏀逛负${status}`); + this.batchInput = ''; + this.batchInputError = ''; + this.isBatchInputValid = false; + this.refreshResult(); // 鍒锋柊缁撴灉 + }) + .catch(error => { + this.$showMessage(`鎵归噺淇敼澶辫触: ${error.message}`); + }); }, //妫�娴嬭緭鍏ユ鐨勮緭鍏ワ紝骞剁粰鍙橀噺璧嬪�� search(event) { @@ -359,7 +450,7 @@ //fupAllow fdownAllow standardValue if (this.formData.fupAllow && this.formData.fdownAllow && this.formData.fstand) { this.isNumber = true; - }else{ + } else { this.isNumber = false; } }) @@ -475,10 +566,10 @@ let params = options; this.mainId = params["mainId"]; this.refreshResult(); - this.formID= params["formID"]; - this.releaseNo= params["releaseNo"]; - this.currentTab=parseInt(params["index"]); - this.current=params["current"] === 'true' ? true : false; + this.formID = params["formID"]; + this.releaseNo = params["releaseNo"]; + this.currentTab = parseInt(params["index"]); + this.current = params["current"] === 'true' ? true : false; this.$post({ url: "/LLJ/getJYItem", data: { @@ -497,7 +588,7 @@ return 0; } }); - this.tabs = tableData; + this.tabs = tableData; // if (this.tableData.length === 0) { // this.isShowTable = true; // } @@ -505,7 +596,12 @@ this.set(item, 'current', this.current); }); console.log(this.tableData); + + }) + this.$nextTick(() => { + this.validateBatchInput(); + }); } } </script> @@ -745,20 +841,41 @@ background-color: #3498db; color: white; } - .input1{ - display: block; - } - .input2{ - display: none; - } + + .input1 { + display: block; + } + + .input2 { + display: none; + } + /* 鍝嶅簲寮忚璁� */ @media (max-width: 500px) { - .input1{ - display: none; - } - .input2{ - display: block; - } + .input1 { + display: none; + } + + .input2 { + display: block; + } } - + + .error-message { + color: $danger-color; + font-size: 12px; + margin-top: 4px; + } + + .input-group:first-child { + .result-input { + border-color: $primary-color; + box-shadow: 0 0 0 2px rgba($primary-color, 0.2); + } + } + + .btn-disabled { + opacity: 0.6; + cursor: not-allowed; + } </style> \ No newline at end of file -- Gitblit v1.9.3