From 5384750e59bbb27c54e090100429c48eaba46df0 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期四, 20 十一月 2025 10:15:20 +0800
Subject: [PATCH] fix: 完成拉丝自检、原材料自检优化

---
 src/api/product/attachment.ts |   22 ++++++++++++++++------
 1 files changed, 16 insertions(+), 6 deletions(-)

diff --git a/src/api/product/attachment.ts b/src/api/product/attachment.ts
index 56ce2c1..f745ec9 100644
--- a/src/api/product/attachment.ts
+++ b/src/api/product/attachment.ts
@@ -13,6 +13,7 @@
   // 涓婁紶鍗曚釜闄勪欢鏂囦欢
   uploadSingleFile(filePath: string) {
     return new Promise<BaseResult<any>>((resolve, reject) => {
+      console.log("寮�濮嬩笂浼犳枃浠�:", filePath);
       uni.uploadFile({
         url: `${baseApi}/app/addAttachmentFiles`,
         filePath: filePath,
@@ -21,35 +22,44 @@
           Authorization: getToken() ? `Bearer ${getToken()}` : "",
         },
         success: (uploadRes) => {
+          console.log("涓婁紶鍝嶅簲:", uploadRes);
           try {
             const result = JSON.parse(uploadRes.data) as BaseResult<any>;
+            console.log("瑙f瀽鍚庣殑缁撴灉:", result);
             // 涓氬姟鐘舵�佺爜 00000 琛ㄧず鎴愬姛
             if (result.code === ResultCodeEnum.SUCCESS) {
               resolve(result);
             } else {
               // 鍏朵粬涓氬姟澶勭悊澶辫触
+              const errorMsg = result.msg || "鏂囦欢涓婁紶澶辫触";
+              console.error("涓婁紶澶辫触:", errorMsg, result);
               uni.showToast({
-                title: result.msg || "鏂囦欢涓婁紶澶辫触",
+                title: errorMsg,
                 icon: "none",
               });
               reject({
-                message: result.msg || "涓氬姟澶勭悊澶辫触",
+                message: errorMsg,
                 code: result.code,
               });
             }
           } catch (e) {
-            reject(e);
+            console.error("瑙f瀽涓婁紶鍝嶅簲澶辫触:", e, uploadRes.data);
+            reject({
+              message: "瑙f瀽涓婁紶鍝嶅簲澶辫触",
+              error: e,
+            });
           }
         },
         fail: (error) => {
-          console.log("upload fail error", error);
+          console.error("涓婁紶璇锋眰澶辫触:", error);
+          const errorMsg = error.errMsg || "鏂囦欢涓婁紶璇锋眰澶辫触";
           uni.showToast({
-            title: "鏂囦欢涓婁紶璇锋眰澶辫触",
+            title: errorMsg,
             icon: "none",
             duration: 2000,
           });
           reject({
-            message: "鏂囦欢涓婁紶璇锋眰澶辫触",
+            message: errorMsg,
             error,
           });
         },

--
Gitblit v1.9.3