如洲 陈
2 天以前 900e4776223c2a42d8859fc8cd635c13ffcfb3b5
pages/QC/THJ/Add.vue
@@ -15,8 +15,8 @@
               <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.customerNo"/>
               <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>
@@ -209,7 +209,8 @@
               returnNo: "", // 退货编号(用于参数传递)
               createBy: "",
               createDate: "",
               customerNo: "", // 客户编号
               customerNo: "", // 客户编号(兼容保留)
               customerName: "", // 客户名称
               returnOrderNo: "", // 退货单号
               returnQty: "", // 退货数量
               returnReason: "", // 退货原因
@@ -299,7 +300,6 @@
         init() {
            console.log("init方法开始执行,formData.id:", this.formData.id);
            return this.$post({
               url: "/THJ/getPage",
               data: {
@@ -308,7 +308,6 @@
                  limit: 1,
               }
            }).then(res => {
               console.log("getPage API调用成功");
               let data = res.data.tbBillList[0];
               if (data) {
@@ -410,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({
@@ -433,7 +430,6 @@
            });
         },
         getTable() {
            console.log("开始重新获取检验项目");
            this.$post({
               url: "/THJ/setInspectItem",
               data: {
@@ -441,22 +437,16 @@
                  updateBy: this.$loginInfo.account
               }
            }).then(res => {
               console.log("setInspectItem API调用成功");
               // 存储过程执行成功,刷新页面数据
               this.init().then(() => {
                  console.log("init方法执行成功");
                  this.$showMessage("检验项目已更新");
               }).catch(error => {
                  console.log("init方法执行异常:", error);
                  this.$showMessage("检验项目已更新,但刷新数据失败");
               }).finally(() => {
                  // 确保状态正确重置
                  this.isSubmitting = false;
                  this.$forceUpdate();
                  console.log("getTable完成,强制重置isSubmitting为false");
               });
            }).catch(error => {
               console.log("setInspectItem API调用失败:", error);
               // 存储过程执行失败,显示错误信息
               this.$showMessage(error.message || "获取检验项目失败");
               // 不改变 isShowTable 状态,保持按钮可见
@@ -464,7 +454,6 @@
               // 确保状态正确重置
               this.isSubmitting = false;
               this.$forceUpdate();
               console.log("getTable失败,强制重置isSubmitting为false");
            });
         },
@@ -542,9 +531,9 @@
            }).then(res => {
               let data = res.data.tbBillList[0];
               if (!data) {
                     if (!data) {
                  this.formData.customerNo = "";
                        this.formData.customerName = "";
                  // 保持退货明细中的信息,不从后端覆盖
                  // this.formData.returnOrderNo = "";
                  // this.formData.returnQty = "";
@@ -553,8 +542,8 @@
                  this.tableData = [];
                  return;
               }
               //不为空时赋值
               this.formData.customerNo = data.customerNo;
                     //不为空时赋值
                     this.formData.customerName = data.customerName || this.formData.customerName;
               // 如果后端返回了更完整的信息,则使用后端的
               if (data.returnOrderNo) this.formData.returnOrderNo = data.returnOrderNo;
               if (data.returnQty) this.formData.returnQty = data.returnQty;
@@ -614,16 +603,15 @@
         // 执行提交
         performSubmit() {
            this.isSubmitting = true;
            console.log("开始提交,isSubmitting设置为true");
            console.log("提交参数:", {
               releaseNo: this.formData.releaseNo,
               userNo: this.$loginInfo?.account || this.formData.createBy || "系统用户"
            });
            
            // 获取当前用户,如果获取不到则使用默认值
            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: {
@@ -631,11 +619,6 @@
                  userNo: currentUser
               }
            }).then(res => {
               console.log("=== 进入.then()块 ===");
               console.log("API响应:", res);
               console.log("响应状态:", res.status);
               console.log("响应消息:", res.message);
               console.log("响应数据:", res.data);
               
               // 检查多种可能的响应格式
               let status = res.status;
@@ -647,23 +630,19 @@
                  message = res.data.message || res.message;
               }
               
               console.log("最终状态:", status);
               console.log("最终消息:", message);
               
               if (status === 0) {
                  this.$showMessage("提交成功");
                  // 成功立即复位
                  this.isSubmitting = false;
                  this.$forceUpdate();
               } else {
                  this.$showMessage("提交失败:" + (message || "未知错误"));
                  // 失败即时复位提交状态,避免按钮一直显示提交中
                  this.isSubmitting = false;
                  this.$forceUpdate();
               }
               // 无论成功还是失败都刷新页面数据
               this.init().catch(error => {
                  console.log("init方法执行异常:", error);
               });
            }).catch(error => {
               console.log("=== 进入.catch()块 ===");
               console.log("API调用异常:", error);
               console.log("错误类型:", typeof error);
               console.log("错误详情:", error);
               
               let errorMessage = "未知错误";
               if (error.message) {
@@ -675,24 +654,18 @@
               }
               
               this.$showMessage("提交失败:" + errorMessage);
               // 异常时也立即复位
               this.isSubmitting = false;
               this.$forceUpdate();
               // 即使出现异常也刷新页面数据
               this.init().catch(error => {
                  console.log("init方法执行异常:", error);
               });
            }).finally(() => {
               console.log("=== 进入.finally()块 ===");
               clearTimeout(resetTimer);
               this.isSubmitting = false;
               console.log("提交完成,isSubmitting设置为false");
               // 强制更新视图
               this.$forceUpdate();
               
               // 备用刷新机制:延迟刷新页面数据
               setTimeout(() => {
                  console.log("执行备用刷新机制");
                  this.init().catch(error => {
                     console.log("备用刷新失败:", error);
                  });
               }, 1000);
            });
         },
      },
@@ -700,7 +673,6 @@
         //每次进入页面都会执行的方法
         // 重置提交状态,防止状态卡住
         this.isSubmitting = false;
         console.log("onShow: 重置isSubmitting为false");
         
         // 如果formData.id为空,尝试从URL参数中获取
         if (!this.formData.id) {