From dbfb045ad92072e880104e13fddb4dc7574499a1 Mon Sep 17 00:00:00 2001
From: fcx <2246384483@qq.com>
Date: 星期五, 19 十二月 2025 13:56:02 +0800
Subject: [PATCH] 1.给SJ获取检验项目添加防抖
---
pages/QC/SJ/detail.vue | 148 ++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 128 insertions(+), 20 deletions(-)
diff --git a/pages/QC/SJ/detail.vue b/pages/QC/SJ/detail.vue
index 5852394..c2acbf4 100644
--- a/pages/QC/SJ/detail.vue
+++ b/pages/QC/SJ/detail.vue
@@ -40,15 +40,16 @@
<view class="info-label">妫�楠屾暟</view>
<view class="info-value">{{ formData.levelNum }}</view>
</view>
- <view v-if="formData.minValue" class="info-item">
+ <!-- 淇锛氫娇鐢ㄦ洿鍑嗙‘鐨勫垽鏂潯浠讹紝閬垮厤0琚鍒や负falsy -->
+ <view v-if="formData.minValue != null" class="info-item">
<view class="info-label">涓嬮檺</view>
<view class="info-value">{{ formData.minValue }}</view>
</view>
- <view v-if="formData.standardValue" class="info-item">
+ <view v-if="formData.standardValue != null" class="info-item">
<view class="info-label">鏍囧噯鍊�</view>
<view class="info-value">{{ formData.standardValue }}</view>
</view>
- <view v-if="formData.maxValue" class="info-item">
+ <view v-if="formData.maxValue != null" class="info-item">
<view class="info-label">涓婇檺</view>
<view class="info-value">{{ formData.maxValue }}</view>
</view>
@@ -69,11 +70,11 @@
<view class="section-header">妫�楠岀粨鏋�</view>
<view class="section-body">
<view class="info-grid">
- <view v-if="formData.result" class="info-item">
+ <view v-if="formData.result != null" class="info-item">
<view class="info-label">棰勮缁撴灉</view>
<view class="info-value">{{ formData.result }}</view>
</view>
- <view v-if="formData.remarks" class="info-item">
+ <view v-if="formData.remarks != null" class="info-item">
<view class="info-label">澶囨敞</view>
<view class="info-value danger">{{ formData.remarks }}</view>
</view>
@@ -85,7 +86,8 @@
<view class="section">
<view class="section-header">妫�楠岀粨鏋滃綍鍏�</view>
<view class="section-body">
- <view v-if="!formData.maxValue && !formData.minValue" class="info-item edit">
+ <!-- 淇锛氫娇鐢ㄦ洿鍑嗙‘鐨勫垽鏂潯浠讹紝閬垮厤0琚鍒や负falsy -->
+ <view v-if="formData.maxValue == null && formData.minValue == null" class="info-item edit">
<view class="info-label" style="color: #F56C6C">鎻愮ず</view>
<view class="info-value" style="color: #F56C6C">娌℃湁鏈�澶у�煎拰鏈�灏忓�兼椂濉啓0锛堟湭閫氳繃妫�楠岋級鎴�1锛堥�氳繃妫�楠岋級</view>
</view>
@@ -102,7 +104,7 @@
</button>
<input v-if="(tableData.length < formData.levelNum)" v-model="formData.fcheckResu" class="result-input"
placeholder="璇疯緭鍏ユ楠岀粨鏋�..." type="number"/>
- <button v-if="(tableData.length < formData.levelNum)" class="btn primary-btn" @click="submit">淇濆瓨缁撴灉
+ <button v-if="(tableData.length < formData.levelNum)" class="btn primary-btn" @click="submit" style="margin: 0px;">淇濆瓨缁撴灉
</button>
</view>
</view>
@@ -110,20 +112,21 @@
<!-- 鍝嶅簲寮忚璁$殑绗簩涓緭鍏ョ粍 -->
<view class="input-group input2">
<view class="input-wrapper">
- <button class="btn upload-btn" @click="chooseImage">
+ <button class="btn upload-btn" @click="chooseImage ">
<uni-icons type="upload" size="16" color="#fff"></uni-icons>
涓婁紶/鏌ョ湅鍥剧墖
</button>
- <button v-if="current" class="btn upload-btn" @click="saveRemarks">
+ <button v-if="current" class="btn upload-btn" @click="saveRemarks ">
<uni-icons type="compose" size="16" color="#fff"></uni-icons>
澶囨敞
</button>
</view>
<view class="input-wrapper" style="margin-top: 15px;">
- <input v-if="(tableData.length < formData.levelNum)" v-model="formData.fcheckResu" class="result-input"
+ <input v-if="(tableData.length < formData.levelNum)" v-model="formData.fcheckResu" class="result-input"
placeholder="璇疯緭鍏ユ楠岀粨鏋�..." type="number"/>
- <button v-if="(tableData.length < formData.levelNum) && current" class="btn primary-btn" @click="submit">淇濆瓨缁撴灉
- </button>
+
+ <button v-if="tableData.length < formData.levelNum" class="btn primary-btn" @click="submit" style="margin: 0px;" >淇濆瓨缁撴灉
+ </button>
</view>
</view>
</view>
@@ -215,6 +218,42 @@
}
},
methods: {
+ // 妫�鏌ユ墍鏈夋楠岄」鐩槸鍚﹀凡瀹屾垚
+ checkAllItemsCompleted() {
+ this.$post({
+ url: "/SJ/getQSItems",
+ data: {
+ pid: this.gid,
+ }
+ }).then(res => {
+ if (res.data && res.data.tbBillList) {
+ const allItems = res.data.tbBillList;
+ // 妫�鏌ユ槸鍚︽墍鏈夐」鐩兘涓嶆槸"鏈畬鎴�"鐘舵��
+ const allCompleted = allItems.every(item => item.result !== '鏈畬鎴�');
+
+ if (allCompleted) {
+ // 鎵�鏈夐」鐩凡瀹屾垚锛屼笉鑷姩璺宠浆锛岀敤鎴锋墜鍔ㄨ繑鍥�
+ // const pages = getCurrentPages();
+ // if (pages.length >= 2) {
+ // const prevPage = pages[pages.length - 2];
+ // const route = '/' + prevPage.route;
+ // const options = prevPage.options;
+ // let query = '';
+ // for (let key in options) {
+ // query += `${key}=${options[key]}&`;
+ // }
+ // query = query.slice(0, -1);
+ // setTimeout(() => {
+ // uni.redirectTo({
+ // url: query ? `${route}?${query}` : route
+ // });
+ // }, 1000);
+ // }
+ }
+ }
+ });
+ },
+
// 鍒囨崲鏍囩椤�
switchTab(index, id) {
this.currentTab = index;
@@ -242,6 +281,15 @@
return 0;
}
});
+
+ // 鏍规嵁褰撳墠id鏌ユ壘瀵瑰簲鐨勬爣绛剧储寮曪紙鍙傝�僉LJ瀹炵幇锛�
+ const foundIndex = this.tabs.findIndex(tab => tab.id == this.id); // 浣跨敤==鑰岄潪===锛岄伩鍏嶇被鍨嬩笉鍖归厤
+ if (foundIndex !== -1) {
+ this.currentTab = foundIndex;
+ } else {
+ // 濡傛灉娌℃壘鍒帮紝榛樿璺宠浆鍒扮涓�涓爣绛�
+ this.currentTab = 0;
+ }
} else {
// 娌℃湁椤圭洰鏃惰嚦灏戞坊鍔犲綋鍓嶉」鐩埌鏍囩
this.tabs = [{id: this.id, projName: this.formData.projName || '褰撳墠椤圭洰'}];
@@ -266,8 +314,8 @@
let count = this.formData.levelNum;
let fstand = "鈭�";
- //鏈夋渶澶у�煎拰鏈�灏忓�煎氨鏍规嵁鏄惁绗﹀悎鏍囧噯鍊兼洿鏂板垽瀹氱粨鏋滐紝娌℃湁鏈�澶у�煎拰鏈�灏忓�煎氨鏍规嵁鏄惁閫氳繃妫�楠屽垽瀹氱粨鏋�
- if (this.formData.maxValue && this.formData.minValue) {
+ // 淇锛氫娇鐢ㄦ洿鍑嗙‘鐨勫垽鏂潯浠讹紝閬垮厤0琚鍒や负falsy
+ if (this.formData.maxValue != null && this.formData.minValue != null) {
if (!this.formData.fcheckResu) {
this.$showMessage("璇疯緭鍏ユ楠屽��");
@@ -319,9 +367,38 @@
}).then(res => {
this.formData.fcheckResu = null;
this.$showMessage("淇濆瓨鎴愬姛");
- this.refreshResult();
+
// 閲嶆柊鍔犺浇鏍囩椤逛互鏇存柊鐘舵��
this.loadTabItems();
+
+ // 绛夊緟tabs鏇存柊鍚�,鏌ユ壘涓嬩竴涓湭瀹屾垚鐨勯」鐩�
+ this.$nextTick(() => {
+ // 鏌ユ壘涓嬩竴涓湭瀹屾垚鐨勯」鐩�
+ const nextUnfinishedIndex = this.tabs.findIndex((tab, index) =>
+ index > this.currentTab && tab.result === '鏈畬鎴�'
+ );
+
+ if (nextUnfinishedIndex !== -1) {
+ // 鎵惧埌浜嗕笅涓�涓湭瀹屾垚鐨勯」鐩�,璺宠浆杩囧幓
+ this.currentTab = nextUnfinishedIndex;
+ this.id = this.tabs[nextUnfinishedIndex].id;
+ this.refreshResult();
+ } else {
+ // 娌℃湁涓嬩竴涓湭瀹屾垚鐨�,浠庡ご鏌ユ壘绗竴涓湭瀹屾垚鐨�
+ const firstUnfinishedIndex = this.tabs.findIndex(tab => tab.result === '鏈畬鎴�');
+ if (firstUnfinishedIndex !== -1) {
+ this.currentTab = firstUnfinishedIndex;
+ this.id = this.tabs[firstUnfinishedIndex].id;
+ this.refreshResult();
+ } else {
+ // 鎵�鏈夐」鐩兘宸插畬鎴�,鍒锋柊褰撳墠椤圭洰
+ this.refreshResult();
+ }
+ }
+ });
+
+ // 妫�鏌ユ槸鍚︽墍鏈夋楠岄」鐩兘宸插畬鎴�
+ this.checkAllItemsCompleted();
})
},
@@ -338,7 +415,8 @@
this.isShowImg = true;
this.base64Image = 'data:image/jpeg;base64,' + this.formData.imageData;
}
- if (this.formData.maxValue && this.formData.minValue && this.formData.standardValue) {
+ // 淇锛氫娇鐢ㄦ洿鍑嗙‘鐨勫垽鏂潯浠讹紝閬垮厤0琚鍒や负falsy
+ if (this.formData.maxValue != null && this.formData.minValue != null && this.formData.standardValue != null) {
this.isNumber = true;
}
})
@@ -370,7 +448,8 @@
let fstand = "鈭�";
- if (this.formData.maxValue && this.formData.minValue) {
+ // 淇锛氫娇鐢ㄦ洿鍑嗙‘鐨勫垽鏂潯浠讹紝閬垮厤0琚鍒や负falsy
+ if (this.formData.maxValue != null && this.formData.minValue != null) {
if (!this.editData.fcheckResu) {
this.$showMessage("璇疯緭鍏ユ楠屽��");
@@ -398,9 +477,13 @@
this.editData.fcheckResu = 1
}
+ // 鏀硅繘鍚庣殑閫昏緫锛氭牴鎹楠岀粨鏋滃�兼潵鍒ゆ柇鍚堟牸涓庡惁
if (this.editData.fcheckResu == 0 || this.editData.fcheckResu == 1) {
+ // 0琛ㄧず涓嶅悎鏍硷紝1琛ㄧず鍚堟牸
if (this.editData.fcheckResu == 0) {
fstand = "脳";
+ } else {
+ fstand = "鈭�";
}
} else {
this.$showMessage("鏃犳爣鍑嗗�兼椂锛屾楠岀粨鏋滃彧鑳戒负0鎴�1!");
@@ -426,6 +509,9 @@
this.refreshResult();//鍒锋柊椤甸潰
// 閲嶆柊鍔犺浇鏍囩椤逛互鏇存柊鐘舵��
this.loadTabItems();
+
+ // 妫�鏌ユ槸鍚︽墍鏈夋楠岄」鐩兘宸插畬鎴�
+ this.checkAllItemsCompleted();
})
},
numberEdit(item) {
@@ -453,6 +539,9 @@
this.refreshResult(); //鍒锋柊椤甸潰
// 閲嶆柊鍔犺浇鏍囩椤逛互鏇存柊鐘舵��
this.loadTabItems();
+
+ // 妫�鏌ユ槸鍚︽墍鏈夋楠岄」鐩兘宸插畬鎴�
+ this.checkAllItemsCompleted();
})
},
// 涓婁紶鍥剧墖
@@ -466,7 +555,8 @@
this.remarks = this.formData.remarks;
},
editRemarks() {
- if (this.remarks) {
+ // 鍏佽淇濆瓨绌哄瓧绗︿覆鎴栫┖鏍硷紝鍙鏌ユ槸鍚︿负null鎴杣ndefined
+ if (this.remarks !== null && this.remarks !== undefined) {
//saveRemarksGid
this.$post({
url: "/SJ/saveRemarksPid",
@@ -487,14 +577,16 @@
},
// 鍒ゆ柇鏁板瓧鏄惁鍦ㄨ寖鍥村唴
isInRange(value) {
- if (!this.formData.maxValue || !this.formData.minValue) return true;
+ // 淇锛氫娇鐢ㄦ洿鍑嗙‘鐨勫垽鏂潯浠讹紝閬垮厤0琚鍒や负falsy
+ if (this.formData.maxValue == null || this.formData.minValue == null) return true;
const numValue = parseFloat(value);
return numValue >= parseFloat(this.formData.minValue) &&
numValue <= parseFloat(this.formData.maxValue);
},
// 鑾峰彇鏁板瓧缁撴灉鐨勬牱寮忕被
getNumberResultClass(value) {
- if (!this.formData.maxValue || !this.formData.minValue) return 'number-normal';
+ // 淇锛氫娇鐢ㄦ洿鍑嗙‘鐨勫垽鏂潯浠讹紝閬垮厤0琚鍒や负falsy
+ if (this.formData.maxValue == null || this.formData.minValue == null) return 'number-normal';
return this.isInRange(value) ? 'number-pass' : 'number-fail';
},
// 鑾峰彇鐘舵�佺粨鏋滅殑鏍峰紡绫�
@@ -653,6 +745,15 @@
border: none;
border-radius: 4px;
}
+
+ .primary-btn {
+ height: 45px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border: none;
+ border-radius: 4px;
+ }
}
}
@@ -721,6 +822,13 @@
&.primary-btn {
background-color: $primary-color;
color: #fff;
+ height: 45px;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ border: none;
+ border-radius: 4px;
+ padding: 0 20px;
}
&.cancel-btn {
--
Gitblit v1.9.3