From 900e4776223c2a42d8859fc8cd635c13ffcfb3b5 Mon Sep 17 00:00:00 2001
From: 如洲 陈 <1278080563@qq.com>
Date: 星期二, 30 九月 2025 11:12:13 +0800
Subject: [PATCH] 出库检优化

---
 pages/QC/THJ/Add.vue |  125 +++++++++++++++++++++++++++++------------
 1 files changed, 89 insertions(+), 36 deletions(-)

diff --git a/pages/QC/THJ/Add.vue b/pages/QC/THJ/Add.vue
index 63a5e3a..01b1d66 100644
--- a/pages/QC/THJ/Add.vue
+++ b/pages/QC/THJ/Add.vue
@@ -14,10 +14,10 @@
 					<label class="form-label">鍒涘缓鏃堕棿:</label>
 					<input class="form-input" disabled="true" type="text" v-model="formData.createDate" />
 				</view>
-				<!-- <view class="form-group">
-		  <label class="form-label">瀹㈡埛鍚嶇О:</label>
-		  <input class="form-input" disabled="true" type="text" v-model="formData.customerName"/>
-		</view> -->
+				<view class="form-group">
+					<label class="form-label">瀹㈡埛鍚嶇О:</label>
+					<input class="form-input" disabled="true" type="text" v-model="formData.customerName"/>
+				</view>
 				<view class="form-group">
 					<label class="form-label">閫�璐у崟鍙�:</label>
 					<input class="form-input" disabled="true" type="text" v-model="formData.returnOrderNo" />
@@ -209,7 +209,8 @@
 					returnNo: "", // 閫�璐х紪鍙凤紙鐢ㄤ簬鍙傛暟浼犻�掞級
 					createBy: "",
 					createDate: "",
-					customerName: "",
+					customerNo: "", // 瀹㈡埛缂栧彿锛堝吋瀹逛繚鐣欙級
+					customerName: "", // 瀹㈡埛鍚嶇О
 					returnOrderNo: "", // 閫�璐у崟鍙�
 					returnQty: "", // 閫�璐ф暟閲�
 					returnReason: "", // 閫�璐у師鍥�
@@ -299,7 +300,7 @@
 
 
 			init() {
-				this.$post({
+				return this.$post({
 					url: "/THJ/getPage",
 					data: {
 						id: this.formData.id,
@@ -383,6 +384,7 @@
 					}
 				}).catch(err => {
 					this.$showMessage("鑾峰彇鏁版嵁澶辫触");
+					throw err; // 閲嶆柊鎶涘嚭閿欒锛岀‘淇漃romise閾炬纭鐞�
 				});
 			},
 			toDetail(item) {
@@ -407,22 +409,20 @@
 			},
 
 			editRemarks() {
-				if (this.remarks) {
-					//saveRemarksGid
-					this.$post({
-						url: "/THJ/saveRemarksGid",
-						data: {
-							gid: this.formData.id,
-							remarks: this.remarks
-						}
-					}).then(res => {
-						if (res.data.tbBillList > 0) {
-							this.formData.remarks = this.remarks;
-							this.remarksPopup = !this.remarksPopup;
-							this.$showMessage("淇濆瓨鎴愬姛");
-						}
-					})
-				}
+				// 鍏佽娓呯┖涓嶅悎鏍兼弿杩帮細鍚庣鎺ユ敹绌哄瓧绗︿覆
+				this.$post({
+					url: "/THJ/saveRemarksGid",
+					data: {
+						gid: this.formData.id,
+						remarks: this.remarks || ""
+					}
+				}).then(res => {
+					if (res.data.tbBillList > 0) {
+						this.formData.remarks = this.remarks || "";
+						this.remarksPopup = !this.remarksPopup;
+						this.$showMessage("淇濆瓨鎴愬姛");
+					}
+				})
 			},
 			toImage() {
 				uni.navigateTo({
@@ -437,14 +437,23 @@
 						updateBy: this.$loginInfo.account
 					}
 				}).then(res => {
-					// 瀛樺偍杩囩▼鎵ц鎴愬姛锛屽埛鏂伴〉闈㈡暟鎹�
-					this.init();
-					this.$showMessage("妫�楠岄」鐩凡鏇存柊");
+					this.init().then(() => {
+						this.$showMessage("妫�楠岄」鐩凡鏇存柊");
+					}).catch(error => {
+						this.$showMessage("妫�楠岄」鐩凡鏇存柊锛屼絾鍒锋柊鏁版嵁澶辫触");
+					}).finally(() => {
+						// 纭繚鐘舵�佹纭噸缃�
+						this.isSubmitting = false;
+						this.$forceUpdate();
+					});
 				}).catch(error => {
 					// 瀛樺偍杩囩▼鎵ц澶辫触锛屾樉绀洪敊璇俊鎭�
 					this.$showMessage(error.message || "鑾峰彇妫�楠岄」鐩け璐�");
 					// 涓嶆敼鍙� isShowTable 鐘舵�侊紝淇濇寔鎸夐挳鍙
 					this.tableData = [];
+					// 纭繚鐘舵�佹纭噸缃�
+					this.isSubmitting = false;
+					this.$forceUpdate();
 				});
 			},
 
@@ -522,9 +531,9 @@
 				}).then(res => {
 					let data = res.data.tbBillList[0];
 
-					if (!data) {
+							if (!data) {
 
-						this.formData.customerName = "";
+								this.formData.customerName = "";
 						// 淇濇寔閫�璐ф槑缁嗕腑鐨勪俊鎭紝涓嶄粠鍚庣瑕嗙洊
 						// this.formData.returnOrderNo = "";
 						// this.formData.returnQty = "";
@@ -533,8 +542,8 @@
 						this.tableData = [];
 						return;
 					}
-					//涓嶄负绌烘椂璧嬪��
-					this.formData.customerName = data.customerName;
+							//涓嶄负绌烘椂璧嬪��
+							this.formData.customerName = data.customerName || this.formData.customerName;
 					// 濡傛灉鍚庣杩斿洖浜嗘洿瀹屾暣鐨勪俊鎭紝鍒欎娇鐢ㄥ悗绔殑
 					if (data.returnOrderNo) this.formData.returnOrderNo = data.returnOrderNo;
 					if (data.returnQty) this.formData.returnQty = data.returnQty;
@@ -598,6 +607,11 @@
 				// 鑾峰彇褰撳墠鐢ㄦ埛锛屽鏋滆幏鍙栦笉鍒板垯浣跨敤榛樿鍊�
 				const currentUser = this.$loginInfo?.account || this.formData.createBy || "绯荤粺鐢ㄦ埛";
 				
+				// 鐩存帴浣跨敤API璋冪敤锛屼笉浣跨敤Promise.race
+				const resetTimer = setTimeout(() => {
+					this.isSubmitting = false;
+					this.$forceUpdate();
+				}, 1000);
 				this.$post({
 					url: "/THJ/submitTHJResultByProcedure",
 					data: {
@@ -605,22 +619,61 @@
 						userNo: currentUser
 					}
 				}).then(res => {
-					if (res.status === 0) {
+					
+					// 妫�鏌ュ绉嶅彲鑳界殑鍝嶅簲鏍煎紡
+					let status = res.status;
+					let message = res.message;
+					
+					// 濡傛灉澶栧眰娌℃湁status锛屾鏌ata涓殑status
+					if (status === undefined && res.data) {
+						status = res.data.status;
+						message = res.data.message || res.message;
+					}
+					
+					
+					if (status === 0) {
 						this.$showMessage("鎻愪氦鎴愬姛");
-						// 鎻愪氦鎴愬姛鍚庡埛鏂伴〉闈㈡暟鎹�
-						this.init();
+						// 鎴愬姛绔嬪嵆澶嶄綅
+						this.isSubmitting = false;
+						this.$forceUpdate();
 					} else {
-						this.$showMessage("鎻愪氦澶辫触锛�" + res.message);
+						this.$showMessage("鎻愪氦澶辫触锛�" + (message || "鏈煡閿欒"));
+						// 澶辫触鍗虫椂澶嶄綅鎻愪氦鐘舵�侊紝閬垮厤鎸夐挳涓�鐩存樉绀烘彁浜や腑
+						this.isSubmitting = false;
+						this.$forceUpdate();
 					}
 				}).catch(error => {
-					this.$showMessage("鎻愪氦澶辫触锛�" + (error.message || "鏈煡閿欒"));
-				}).finally(() => {
+					
+					let errorMessage = "鏈煡閿欒";
+					if (error.message) {
+						errorMessage = error.message;
+					} else if (typeof error === 'string') {
+						errorMessage = error;
+					} else if (error.response) {
+						errorMessage = `鏈嶅姟鍣ㄩ敊璇�: ${error.response.status}`;
+					}
+					
+					this.$showMessage("鎻愪氦澶辫触锛�" + errorMessage);
+					// 寮傚父鏃朵篃绔嬪嵆澶嶄綅
 					this.isSubmitting = false;
+					this.$forceUpdate();
+					// 鍗充娇鍑虹幇寮傚父涔熷埛鏂伴〉闈㈡暟鎹�
+					this.init().catch(error => {
+					});
+				}).finally(() => {
+					clearTimeout(resetTimer);
+					this.isSubmitting = false;
+					// 寮哄埗鏇存柊瑙嗗浘
+					this.$forceUpdate();
+					
 				});
-			}
+			},
 		},
 		onShow() {
 			//姣忔杩涘叆椤甸潰閮戒細鎵ц鐨勬柟娉�
+			// 閲嶇疆鎻愪氦鐘舵�侊紝闃叉鐘舵�佸崱浣�
+			this.isSubmitting = false;
+			
 			// 濡傛灉formData.id涓虹┖锛屽皾璇曚粠URL鍙傛暟涓幏鍙�
 			if (!this.formData.id) {
 				// 灏濊瘯浠庡綋鍓嶉〉闈RL涓幏鍙杋d鍙傛暟

--
Gitblit v1.9.3