From deb0a2b84b5a6a7dc916b1a4e625f32c00c87ade Mon Sep 17 00:00:00 2001
From: buhuazhen <hua100783@gmail.com>
Date: 星期二, 27 一月 2026 09:17:25 +0800
Subject: [PATCH] fix(出库): 处理MES缺失的物料并优化扫码逻辑

---
 src/pages/outbound/materialOutbound.vue |  104 +++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 75 insertions(+), 29 deletions(-)

diff --git a/src/pages/outbound/materialOutbound.vue b/src/pages/outbound/materialOutbound.vue
index bfb7a63..876d241 100644
--- a/src/pages/outbound/materialOutbound.vue
+++ b/src/pages/outbound/materialOutbound.vue
@@ -7,14 +7,14 @@
             type="icon"
             icon="scan"
             color="#0d867f"
-            @click="openScan"
             style="color: #0d867f"
+            @click="openScan"
           ></wd-button>
         </template>
       </CardTitle>
 
       <!-- 褰撳墠鐗╂枡淇℃伅 -->
-      <view class="material-info" v-if="currentMaterial">
+      <view v-if="currentMaterial" class="material-info">
         <wd-card custom-class="info-card">
           <view class="info-compact">
             <view class="icon_box">
@@ -55,26 +55,28 @@
               <text class="outbound_item_label">鐢熶骇鎵规鍙凤細</text>
               <text class="outbound_item_value">{{ item.monofilamentNumber || "-" }}</text>
             </view>
-            <view class="outbound_item_row">
-              <text class="outbound_item_label">瑙勬牸鍨嬪彿锛�</text>
-              <text class="outbound_item_value">{{ item.model || "-" }}</text>
-            </view>
-            <view class="outbound_item_row">
-              <text class="outbound_item_label">閲嶉噺锛�</text>
-              <text class="outbound_item_value">{{ item.weight || "-" }} kg</text>
-            </view>
-            <view class="outbound_item_row">
-              <text class="outbound_item_label">鍘傚锛�</text>
-              <text class="outbound_item_value">{{ item.clienteleName || "-" }}</text>
-            </view>
-            <view class="outbound_item_row">
-              <text class="outbound_item_label">娈甸暱锛�</text>
-              <text class="outbound_item_value">{{ item.actuallyLength || "-" }} M</text>
-            </view>
-            <view class="outbound_item_row">
-              <text class="outbound_item_label">鐢熶骇鏃ユ湡锛�</text>
-              <text class="outbound_item_value">{{ item.productionDate || "-" }}</text>
-            </view>
+            <template v-if="!item.isMesMissing">
+              <view class="outbound_item_row">
+                <text class="outbound_item_label">瑙勬牸鍨嬪彿锛�</text>
+                <text class="outbound_item_value">{{ item.model || "-" }}</text>
+              </view>
+              <view class="outbound_item_row">
+                <text class="outbound_item_label">閲嶉噺锛�</text>
+                <text class="outbound_item_value">{{ item.weight || "-" }} kg</text>
+              </view>
+              <view class="outbound_item_row">
+                <text class="outbound_item_label">鍘傚锛�</text>
+                <text class="outbound_item_value">{{ item.clienteleName || "-" }}</text>
+              </view>
+              <view class="outbound_item_row">
+                <text class="outbound_item_label">娈甸暱锛�</text>
+                <text class="outbound_item_value">{{ item.actuallyLength || "-" }} M</text>
+              </view>
+              <view class="outbound_item_row">
+                <text class="outbound_item_label">鐢熶骇鏃ユ湡锛�</text>
+                <text class="outbound_item_value">{{ item.productionDate || "-" }}</text>
+              </view>
+            </template>
           </view>
         </view>
         <view class="outbound_item_action">
@@ -91,7 +93,7 @@
 
     <!-- 搴曢儴鎸夐挳 -->
     <view v-if="goodsList.length > 0" class="outbound_footer">
-      <wd-button block @click="handleOutbound" style="background: #0d867f">
+      <wd-button block style="background: #0d867f" @click="handleOutbound">
         <text class="text-[#fff]">鍑哄簱</text>
       </wd-button>
     </view>
@@ -124,6 +126,19 @@
 // 鏍煎紡鍖栨椂闂�
 const formatTime = (date: Date) => {
   return dayjs(date).format("YYYY-MM-DD HH:mm:ss");
+};
+
+const handleMonofilamentNumber = (value?: string) => {
+  if (!value) return "";
+  if (!value.includes("-")) {
+    if (value.length < 3) {
+      toast.error("鍗曚笣缂栧彿闀垮害涓嶈冻锛屾棤娉曟坊鍔� '-'");
+      return "";
+    }
+    const insertIndex = value.length - 3;
+    return `${value.slice(0, insertIndex)}-${value.slice(insertIndex)}`;
+  }
+  return value;
 };
 
 // 鐩存帴鎵爜
@@ -168,7 +183,7 @@
       let scanData;
       try {
         scanData = JSON.parse(scanText);
-      } catch (e) {
+      } catch {
         toast.error("浜岀淮鐮佹牸寮忛敊璇�");
         return;
       }
@@ -228,13 +243,43 @@
       }
 
       // 璋冪敤鎷変笣鎺ュ彛锛欸ET /mes/app/getTagByLsMonofilamentNumber?monofilamentNumber=xxxx
-      const { data } = await OutboundApi.getTagByLsMonofilamentNumber({
-        monofilamentNumber,
-      });
+      let data;
+      try {
+        const response = await OutboundApi.getTagByLsMonofilamentNumber({
+          monofilamentNumber,
+        });
+        data = response.data;
+      } catch {
+        data = null;
+      }
 
       const list = Array.isArray(data) ? data : data ? [data] : [];
       if (!list.length) {
-        toast.error("鏈煡璇㈠埌鏉$爜淇℃伅");
+        const formattedMonofilamentNumber = handleMonofilamentNumber(monofilamentNumber);
+        if (!formattedMonofilamentNumber) {
+          return;
+        }
+        const newItem = {
+          id: monofilamentNumber || "-",
+          contractNo: "鏈湪mes涓敓浜�",
+          monofilamentNumber: formattedMonofilamentNumber,
+          model: "-",
+          weight: "-",
+          clienteleName: "-",
+          actuallyLength: "-",
+          productionDate: "-",
+          type: "",
+          devicemodel: "",
+          state: "",
+          projectId: "",
+          productuser: "",
+          rawData: null,
+          scanCode: scanText,
+          scanTime: formatTime(new Date()),
+          isMesMissing: true,
+        };
+        goodsList.value.push(newItem);
+        toast.success("鎵爜鎴愬姛");
         return;
       }
 
@@ -370,6 +415,7 @@
         const requestData = goodsList.value.map((item) => ({
           outPutId: item.id,
           projectId: item.projectId || "",
+          monofilamentNumber: item.monofilamentNumber || "",
         }));
 
         // 鎸夊嚭搴撳崟鏄庣粏鏋勫缓璇锋眰浣�
@@ -425,7 +471,7 @@
   try {
     // 濡傛灉鏄紪鐮佽繃鐨勶紙鍖呭惈 %锛夛紝decode 涓�娆★紱鍚﹀垯鐩存帴杩斿洖
     return val.includes("%") ? decodeURIComponent(val) : val;
-  } catch (e) {
+  } catch {
     return val;
   }
 };

--
Gitblit v1.9.3