From d741e7a7ad7de5045e5c6b6145d9da1783cadecd Mon Sep 17 00:00:00 2001
From: heshaofeng <heshaofeng@hnkhzn.com>
Date: 星期二, 13 一月 2026 09:55:03 +0800
Subject: [PATCH] Merge branch 'htq20251215' of http://115.159.85.185:8098/r/ZhongRui/ALDbanyunxiangmu into htq20251215

---
 项目代码/WIDESEA_WMSClient/src/extension/outbound/extend/NoStockOut.vue |  619 ++++++++++++++++++++++++++++++++------------------------
 1 files changed, 352 insertions(+), 267 deletions(-)

diff --git "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/NoStockOut.vue" "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/NoStockOut.vue"
index d058411..157c95f 100644
--- "a/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/NoStockOut.vue"
+++ "b/\351\241\271\347\233\256\344\273\243\347\240\201/WIDESEA_WMSClient/src/extension/outbound/extend/NoStockOut.vue"
@@ -8,57 +8,56 @@
       title="铏氭嫙鍑哄叆搴�"
       class="custom-vol-box"
     >
+      <!-- 鎻愪氦閬僵灞傦細瑕嗙洊鏁翠釜寮圭獥鍐呭鍖哄煙 -->
+      <div class="submit-mask" v-show="submitLoading">
+        <div class="mask-content">
+          <el-loading-spinner class="loading-icon" />
+          <span class="loading-text">姝e湪鎻愪氦鍑哄簱锛岃绋嶅��...</span>
+        </div>
+      </div>
+
       <div>
-        <!-- 鍗曟嵁閫夋嫨鍖哄煙锛堝彲杈撳叆鎼滅储锛� -->
-        <el-form :inline="true" :model="orderForm" style="margin-bottom: 20px; align-items: flex-end;">
-          <el-form-item label="鍑哄簱鍗曟嵁:" name="outboundOrderId">
-            <el-select
-              v-model="orderForm.outboundOrderId"
-              placeholder="璇烽�夋嫨鎴栨壂鎻忓嚭搴撳崟鎹彿"
+        <!-- 鍗曟嵁杈撳叆鍖哄煙锛堟敮鎸佹壂鐮侊級 -->
+        <el-form 
+          :inline="true" 
+          :model="orderForm" 
+          style="margin-bottom: 20px; align-items: flex-end;"
+          @submit.prevent
+        >
+          <el-form-item label="鍑哄簱鍗曟嵁:" name="outboundOrderNo">
+            <el-input
+              v-model="orderForm.outboundOrderNo"
+              placeholder="璇疯緭鍏ユ垨鎵弿鍑哄簱鍗曟嵁鍙�"
               clearable
               style="width: 220px; margin-right: 10px;"
-              @change="handleOrderChange"
-              @visible-change="handleOutboundVisibleChange"
-              :loading="loading"
-              filterable
-              :filter-method="filterOutboundOrders"
-              @input="handleOutboundScanInput"  
-              ref="outboundSelectRef"        
-            >
-              <el-option
-                v-for="order in filteredOutboundOrders"
-                :key="order.id"
-                :label="order.orderNo"
-                :value="order.id"
-              ></el-option>
-            </el-select>
+              @input="handleOutboundInput"
+              @keyup.enter="validateOutboundOrder"
+              ref="outboundInputRef"
+              :disabled="loading || submitLoading"
+            ></el-input>
           </el-form-item>
-          <el-form-item label="閲囪喘鍗曟嵁:" name="purchaseOrderId">
-            <el-select
-              v-model="orderForm.purchaseOrderId"
-              placeholder="璇烽�夋嫨鎴栨壂鎻忛噰璐崟鎹彿"
+          <el-form-item label="閲囪喘鍗曟嵁:" name="purchaseOrderNo">
+            <el-input
+              v-model="orderForm.purchaseOrderNo"
+              placeholder="鎵爜鏉$爜鍚庤嚜鍔ㄥ~鍏�"
               clearable
               style="width: 220px; margin-right: 10px;"
-              @change="handleOrderChange"
-              @visible-change="handlePurchaseVisibleChange"
-              :loading="loading"
-              filterable
-              :filter-method="filterPurchaseOrders"
-              @input="handlePurchaseScanInput" 
-              ref="purchaseSelectRef"
-            >
-              <el-option
-                v-for="order in filteredPurchaseOrders"
-                :key="order.id"
-                :label="order.orderNo"
-                :value="order.id"
-              ></el-option>
-            </el-select>
+              @input="handlePurchaseInput"
+              readonly
+              ref="purchaseInputRef"
+              :disabled="submitLoading"
+            ></el-input>
           </el-form-item>
         </el-form>
 
         <!-- 涓婃柟杈撳叆妗� -->
-        <el-form :inline="true" :model="formData" ref="formRef" style="margin-bottom: 20px; align-items: flex-end;">
+        <el-form 
+          :inline="true" 
+          :model="formData" 
+          ref="formRef" 
+          style="margin-bottom: 20px; align-items: flex-end;"
+          @submit.prevent  
+        >
           <el-form-item
             label="鎵弿鏉$爜:"
             style="width: 80%"
@@ -69,10 +68,10 @@
               ref="barcodeInputRef"
               v-model="formData.barcode"
               placeholder="璇蜂娇鐢ㄦ壂鐮佹灙鎵弿鏉$爜锛屾垨鎵嬪姩杈撳叆"
-              @keyup.enter="handleScan"
+              @keydown.enter="debouncedHandleScan" 
               autofocus
               class="custom-input"
-              :disabled="!orderForm.outboundOrderId || !orderForm.purchaseOrderId"
+              :disabled="!orderForm.outboundOrderNo || loading || submitLoading"
             ></el-input>
           </el-form-item>
           <el-form-item>
@@ -81,14 +80,14 @@
               size="small" 
               @click="handleScan" 
               class="custom-button"
-              :disabled="!orderForm.outboundOrderId || !orderForm.purchaseOrderId || loading"
+              :disabled="!orderForm.outboundOrderNo || loading || submitLoading"
             >
               <Search /> 纭鎵弿
             </el-button>
           </el-form-item>
         </el-form>
 
-        <!-- 涓嬫柟鏄剧ず妗� -->
+        <!-- 涓嬫柟鏄剧ず妗嗭紙鐩存帴娓叉煋鍚庣杩斿洖鐨勬暟缁勶級 -->
         <div class="scan-list">
           <el-card shadow="hover" style="margin-bottom: 10px; border: none;" class="custom-card">
             <div class="card-header">
@@ -97,19 +96,48 @@
             <div class="card-body">
               <el-scrollbar height="400px" class="custom-scrollbar">
                 <transition-group name="barcode-item-transition">
-                  <div class="barcode-item" v-for="(item, index) in scannedBarcodes" :key="item.barcode" :data-index="index">
-                    <span class="barcode-text">{{ index + 1 }}. {{ item.barcode }}</span>
+                  <div class="barcode-item" v-for="(item, index) in scannedBarcodes" :key="`${item.barcode}-${index}`" :data-index="index">
+                    <div class="barcode-detail">
+                      <div class="detail-row">
+                        <span class="label">鏉$爜锛�</span>
+                        <span class="value">{{ item.barcode || '-' }}</span>
+                      </div>
+                      <div class="detail-row">
+                        <span class="label">鐗╂枡缂栫爜锛�</span>
+                        <span class="value">{{ item.materielCode || '-' }}</span>
+                      </div>
+                      <div class="detail-row">
+                        <span class="label">鐗╂枡鍚嶇О锛�</span>
+                        <span class="value">{{ item.materielName || '-' }}</span>
+                      </div>
+                      <div class="detail-row">
+                        <span class="label">鎵规鍙凤細</span>
+                        <span class="value">{{ item.batchNo || '-' }}</span>
+                      </div>
+                      <div class="detail-row">
+                        <span class="label">鏉$爜鏁伴噺锛�</span>
+                        <span class="value">{{ item.orderQuantity || item.quantity || 0 }}</span>
+                      </div>
+                      <div class="detail-row">
+                        <span class="label">渚涘簲鍟嗙紪鐮侊細</span>
+                        <span class="value">{{ item.supplyCode || '-' }}</span>
+                      </div>
+                      <div class="detail-row">
+                        <span class="label">閲囪喘鍗曞彿锛�</span>
+                        <span class="value">{{ item.purchaseOrderNo || '-' }}</span>
+                      </div>
+                    </div>
                     <el-button
                       class="delete-btn"
                       @click="removeItem(index, item.barcode)"
                       icon="Delete"
                       circle
-                      :disabled="loading"
+                      :disabled="loading || submitLoading"
                     ></el-button>
                   </div>
                 </transition-group>
                 <div class="empty-tip" v-if="scannedBarcodes.length === 0">
-                  <span>鏆傛棤鎵弿璁板綍锛岃鍏堥�夋嫨鍗曟嵁鍚庢壂鎻忔潯鐮�</span>
+                  <span>鏆傛棤鎵弿璁板綍锛岃鍏堣緭鍏ュ嚭搴撳崟鎹悗鎵弿鏉$爜</span>
                 </div>
               </el-scrollbar>
             </div>
@@ -123,12 +151,22 @@
             type="primary" 
             size="small" 
             @click="submit" 
-            :disabled="scannedBarcodes.length === 0 || !orderForm.outboundOrderId || !orderForm.purchaseOrderId || loading" 
+            :disabled="scannedBarcodes.length === 0 || !orderForm.outboundOrderNo || loading || submitLoading" 
             class="submit-btn"
           >
             <Check /> 鎻愪氦鍑哄簱
           </el-button>
-          <el-button type="text" size="small" @click="showDetailBox = false" class="cancel-btn" :disabled="loading">
+          <el-button 
+            type="text" 
+            size="small" 
+            @click="(e) => {
+              e.stopPropagation();
+              e.preventDefault();
+              showDetailBox = false;
+            }" 
+            class="cancel-btn" 
+            :disabled="loading || submitLoading"
+          >
             鍙栨秷
           </el-button>
         </div>
@@ -140,6 +178,7 @@
 <script setup>
 import { ref, reactive, onMounted, nextTick } from 'vue';
 import { ElMessage } from 'element-plus';
+import { Search, Check } from '@element-plus/icons-vue';
 
 import VolBox from "@/components/basic/VolBox.vue";
 import http from '@/api/http';
@@ -147,253 +186,243 @@
 // 鍝嶅簲寮忔暟鎹�
 const showDetailBox = ref(false);
 const orderForm = reactive({
-  outboundOrderId: "",
-  purchaseOrderId: ""
+  outboundOrderNo: "",
+  purchaseOrderNo: ""
 });
 const formData = reactive({
   barcode: "",
 });
 const scannedBarcodes = ref([]);
-const outboundOrders = ref([]);
-const purchaseOrders = ref([]);
-const filteredOutboundOrders = ref([]);
-const filteredPurchaseOrders = ref([]);
 const loading = ref(false);
+// 鏂板锛氭彁浜や笓灞瀕oading鐘舵�侊紝鎺у埗閬僵灞傛樉绀�
+const submitLoading = ref(false);
 
 // 妯℃澘寮曠敤
 const formRef = ref(null);
 const barcodeInputRef = ref(null);
-const outboundSelectRef = ref(null); // 鏂板锛氬嚭搴撳崟select鐨剅ef
-const purchaseSelectRef = ref(null); // 鏂板锛氶噰璐崟select鐨剅ef
+const outboundInputRef = ref(null);
+const purchaseInputRef = ref(null);
 
-// 鐢ㄤ簬闃叉杈撳叆浜嬩欢鍜宑hange浜嬩欢鍐茬獊鐨勯攣
-const isProcessingScan = ref(false);
-
-// 缁勪欢鎸傝浇鏃跺垵濮嬪寲杩囨护鍚庣殑鍒楄〃
+// 缁勪欢鎸傝浇鏃惰仛鐒﹀埌鍑哄簱鍗曡緭鍏ユ
 onMounted(() => {
-  filteredOutboundOrders.value = [...outboundOrders.value];
-  filteredPurchaseOrders.value = [...purchaseOrders.value];
+  nextTick(() => {
+    outboundInputRef.value?.focus();
+  });
 });
+
+// 绠�鍗曢槻鎶栧嚱鏁�
+const debounce = (fn, delay = 100) => {
+  let timer = null;
+  return (...args) => {
+    if (timer) clearTimeout(timer);
+    timer = setTimeout(() => {
+      fn.apply(this, args);
+    }, delay);
+  };
+};
 
 // 鎵撳紑寮圭獥
 const open = () => {
   showDetailBox.value = true;
   scannedBarcodes.value = [];
   formData.barcode = "";
-  orderForm.outboundOrderId = "";
-  orderForm.purchaseOrderId = "";
+  orderForm.outboundOrderNo = "";
+  orderForm.purchaseOrderNo = "";
+  submitLoading.value = false; // 鎵撳紑寮圭獥鏃堕噸缃彁浜oading
   nextTick(() => {
-    barcodeInputRef.value?.focus();
-  });
-};
-
-// 鍔犺浇鍑哄簱鍗曟嵁鍒楄〃
-const loadOutboundOrders = async () => {
-  if (outboundOrders.value.length > 0) return;
-  try {
-    loading.value = true;
-    const res = await http.get("/api/OutboundPicking/GetAvailablePickingOrders");
-    
-    if (res.code === 0) {
-      outboundOrders.value = res.data.map(orderNo => ({
-        id: orderNo,
-        orderNo: orderNo
-      }));
-      filteredOutboundOrders.value = [...outboundOrders.value];
-    } else {
-      ElMessage.error("鍔犺浇鍑哄簱鍗曟嵁澶辫触锛�" + (res.message || '鏈煡閿欒'));
-    }
-  } catch (error) {
-    ElMessage.error("鍔犺浇鍑哄簱鍗曟嵁寮傚父锛�" + error.message);
-  } finally {
-    loading.value = false;
-  }
-};
-
-// 鍔犺浇閲囪喘鍗曟嵁鍒楄〃
-const loadPurchaseOrders = async () => {
-  if (purchaseOrders.value.length > 0) return;
-  try {
-    loading.value = true;
-    const res = await http.get("/api/OutboundPicking/GetAvailablePurchaseOrders");
-    
-    if (res.status === true) {
-      purchaseOrders.value = res.data.map(orderNo => ({
-        id: orderNo,
-        orderNo: orderNo
-      }));
-      filteredPurchaseOrders.value = [...purchaseOrders.value];
-    } else {
-      ElMessage.error("鍔犺浇閲囪喘鍗曟嵁澶辫触锛�" + (res.message || '鏈煡閿欒'));
-    }
-  } catch (error) {
-    ElMessage.error("鍔犺浇閲囪喘鍗曟嵁寮傚父锛�" + error.message);
-  } finally {
-    loading.value = false;
-  }
-};
-
-// 鍑哄簱鍗曟嵁杩囨护鏂规硶
-const filterOutboundOrders = (value) => {
-  if (!value) {
-    filteredOutboundOrders.value = [...outboundOrders.value];
-  } else {
-    const lowerValue = value.toLowerCase();
-    filteredOutboundOrders.value = outboundOrders.value.filter(order => 
-      order.orderNo.toLowerCase().includes(lowerValue)
-    );
-  }
-};
-
-// 閲囪喘鍗曟嵁杩囨护鏂规硶
-const filterPurchaseOrders = (value) => {
-  if (!value) {
-    filteredPurchaseOrders.value = [...purchaseOrders.value];
-  } else {
-    const lowerValue = value.toLowerCase();
-    filteredPurchaseOrders.value = purchaseOrders.value.filter(order => 
-      order.orderNo.toLowerCase().includes(lowerValue)
-    );
-  }
-};
-
-// 鍑哄簱鍗曟嵁涓嬫媺妗嗘樉绀�/闅愯棌鏃惰Е鍙�
-const handleOutboundVisibleChange = (visible) => {
-  if (visible) {
-    loadOutboundOrders();
-  } else {
-    // 褰撲笅鎷夋鍏抽棴鏃讹紝濡傛灉鏄壂鎻忔搷浣滃鑷寸殑锛屾竻绌鸿緭鍏ユ
-    if (isProcessingScan.value) {
-        nextTick(() => {
-            outboundSelectRef.value?.clearInput();
-            isProcessingScan.value = false;
-        });
-    }
-  }
-};
-
-// 閲囪喘鍗曟嵁涓嬫媺妗嗘樉绀�/闅愯棌鏃惰Е鍙�
-const handlePurchaseVisibleChange = (visible) => {
-  if (visible) {
-    loadPurchaseOrders();
-  } else {
-    // 褰撲笅鎷夋鍏抽棴鏃讹紝濡傛灉鏄壂鎻忔搷浣滃鑷寸殑锛屾竻绌鸿緭鍏ユ
-    if (isProcessingScan.value) {
-        nextTick(() => {
-            purchaseSelectRef.value?.clearInput();
-            isProcessingScan.value = false;
-        });
-    }
-  }
-};
-
-// 鍗曟嵁閫夋嫨鍙樺寲鏃惰Е鍙�
-const handleOrderChange = () => {
-  // 濡傛灉鏄墜鍔ㄩ�夋嫨锛屽垯涓嶆竻绌鸿緭鍏ユ
-  isProcessingScan.value = false;
-  
-  scannedBarcodes.value = [];
-  nextTick(() => {
-    barcodeInputRef.value?.focus();
+    outboundInputRef.value?.focus(); // 鎵撳紑寮圭獥浠嶈仛鐒﹀嚭搴撳崟杈撳叆妗�
   });
 };
 
 /**
- * 澶勭悊鍑哄簱鍗曟壂鎻忚緭鍏�
- * @param {string} scanText - 鎵弿鏋緭鍏ョ殑鏂囨湰
+ * 楠岃瘉鍑哄簱鍗曟嵁鍙风殑鏈夋晥鎬�
+ * 鏍稿績淇敼锛氶獙璇佹垚鍔熷悗鐩存帴鑱氱劍鏉$爜鎵弿妗嗭紝澶辫触鍒欒仛鐒﹀洖鍑哄簱鍗曡緭鍏ユ
  */
-const handleOutboundScanInput = async (scanText) => {
-  // 閬垮厤澶勭悊绌哄瓧绗︿覆鎴栫敱change浜嬩欢瑙﹀彂鐨勫唴閮ㄦ搷浣�
-  if (!scanText || isProcessingScan.value) return;
-
-  // 鏌ユ壘瀹屽叏鍖归厤鐨勮鍗�
-  const matchedOrder = outboundOrders.value.find(order => order.orderNo === scanText);
-
-  if (matchedOrder) {
-    isProcessingScan.value = true; // 鏍囪涓烘鍦ㄥ鐞嗘壂鎻�
-    // 鎵嬪姩璧嬪��
-    orderForm.outboundOrderId = matchedOrder.id;
-    ElMessage.success(`鎴愬姛閫夋嫨鍑哄簱鍗曪細${matchedOrder.orderNo}`);
-    
-    // 寤惰繜鑱氱劍鍒颁笅涓�涓緭鍏ユ锛岀‘淇濊祴鍊煎畬鎴�
-    setTimeout(() => {
-        purchaseSelectRef.value?.focus();
-    }, 100);
-  }
-  // 濡傛灉娌℃湁鍖归厤椤癸紝涓嶅仛浠讳綍浜嬶紝璁〆l-select淇濇寔杩囨护鐘舵�侊紝鐢ㄦ埛鍙互鎵嬪姩閫夋嫨
-};
-
-/**
- * 澶勭悊閲囪喘鍗曟壂鎻忚緭鍏�
- * @param {string} scanText - 鎵弿鏋緭鍏ョ殑鏂囨湰
- */
-const handlePurchaseScanInput = async (scanText) => {
-  if (!scanText || isProcessingScan.value) return;
-
-  const matchedOrder = purchaseOrders.value.find(order => order.orderNo === scanText);
-
-  if (matchedOrder) {
-    isProcessingScan.value = true; // 鏍囪涓烘鍦ㄥ鐞嗘壂鎻�
-    orderForm.purchaseOrderId = matchedOrder.id;
-    ElMessage.success(`鎴愬姛閫夋嫨閲囪喘鍗曪細${matchedOrder.orderNo}`);
-    
-    setTimeout(() => {
-        barcodeInputRef.value?.focus();
-    }, 100);
-  }
-};
-
-
-// 鎵弿鏉$爜澶勭悊
-const handleScan = async () => {
-  if (!formRef.value) return;
-  await formRef.value.validateField('barcode');
-
-  const barcode = formData.barcode.trim();
-  
-  if (scannedBarcodes.value.some(item => item.barcode === barcode)) {
-    ElMessage.warning(`鏉$爜 ${barcode} 宸叉壂鎻忚繃锛岃鍕块噸澶嶆壂鎻廯);
-    formData.barcode = "";
-    nextTick(() => barcodeInputRef.value?.focus());
+const validateOutboundOrder = async () => {
+  const outboundOrderNo = orderForm.outboundOrderNo.trim();
+  if (!outboundOrderNo) {
     return;
   }
 
   try {
     loading.value = true;
-    const res = await http.post("/api/OutboundPicking/BarcodeValidate", {
-      outOder: orderForm.outboundOrderId,
-      inOder: orderForm.purchaseOrderId,
-      barCode: barcode
-    });
+    const res = await http.post(
+      `/api/OutboundPicking/GetAvailablePickingOrders?outOrder=`+ outboundOrderNo,
+      "楠岃瘉鍑哄簱鍗曟嵁鍙蜂腑..."
+    );
 
-    if (res.status === true) {
-      scannedBarcodes.value.push({ barcode });
-      ElMessage.success("鎵弿鎴愬姛");
-      formData.barcode = "";
-    } else {
-      ElMessage.error("鎵弿澶辫触锛�" + (res.message || '楠岃瘉澶辫触'));
+    if (res.status !== true) {
+      // 楠岃瘉澶辫触锛氭竻绌鸿緭鍏ユ锛屾彁绀洪敊璇紝鑱氱劍鍥炲嚭搴撳崟杈撳叆妗�
+      orderForm.outboundOrderNo = "";
+      ElMessage.error(res.message || "鍑哄簱鍗曟嵁鍙烽獙璇佸け璐ワ紝璇锋鏌ュ崟鎹彿鏄惁姝g‘");
+      nextTick(() => {
+        outboundInputRef.value?.focus(); // 澶辫触鑱氱劍鍑哄簱鍗曡緭鍏ユ
+      });
+      return;
     }
+
+    // 楠岃瘉鎴愬姛锛氭彁绀虹敤鎴凤紝鐩存帴鑱氱劍鏉$爜鎵弿妗嗭紙鏍稿績淇敼锛�
+    ElMessage.success("鍑哄簱鍗曟嵁鍙烽獙璇侀�氳繃");
+    nextTick(() => {
+      barcodeInputRef.value?.focus(); // 鎴愬姛鐩存帴璺宠浆鍒版潯鐮佹壂鎻忔
+    });
   } catch (error) {
-    ElMessage.error("鎵弿楠岃瘉寮傚父锛�" + error.message);
+    // 鎺ュ彛寮傚父锛氭竻绌鸿緭鍏ユ锛屾彁绀洪敊璇紝鑱氱劍鍥炲嚭搴撳崟杈撳叆妗�
+    orderForm.outboundOrderNo = "";
+    ElMessage.error(`鍑哄簱鍗曟嵁鍙烽獙璇佸紓甯革細${error.message || "缃戠粶閿欒锛岃閲嶈瘯"}`);
+    nextTick(() => {
+      outboundInputRef.value?.focus(); // 寮傚父鑱氱劍鍑哄簱鍗曡緭鍏ユ
+    });
   } finally {
     loading.value = false;
-    nextTick(() => barcodeInputRef.value?.focus());
   }
 };
 
-// 绉婚櫎鍗曟潯鎵弿璁板綍
+// 鍑哄簱鍗曡緭鍏ュ鐞�
+const handleOutboundInput = (value) => {
+  if (value && value.trim()) {
+    // 鍙繚鐣欏嚭搴撳崟鍙锋牸寮忛獙璇侀�昏緫
+  }
+};
+
+// 閲囪喘鍗曡緭鍏ュ鐞�
+const handlePurchaseInput = (value) => {
+  if (value && value.trim()) {
+    // 鍙繚鐣欓噰璐崟鍙锋牸寮忛獙璇侀�昏緫
+  }
+};
+
+// 鑱氱劍鏉$爜杈撳叆妗嗭紙澶嶇敤鍑芥暟锛�
+const focusBarcodeInputDirectly = () => {
+  if (orderForm.outboundOrderNo.trim()) {
+    barcodeInputRef.value?.focus();
+  } else {
+    ElMessage.warning("璇峰厛杈撳叆鏈夋晥鐨勫嚭搴撳崟鎹彿");
+  }
+};
+
+/**
+ * 鏍规嵁鏉$爜鏌ヨ閲囪喘鍗曞彿
+ */
+const getPurchaseOrderByBarcode = async (barcode) => {
+  const res = await http.post(`/api/OutboundPicking/GetPurchaseOrderByBarcode?barCode=${encodeURIComponent(barcode)}`, "鏌ヨ閲囪喘鍗曞彿涓�...");
+
+  if (res.status !== true) {
+    throw new Error(res.message || "鏌ヨ閲囪喘鍗曞彿澶辫触");
+  }
+
+  let purchaseOrderNo = '';
+  if (Array.isArray(res.data) && res.data.length > 0) {
+    purchaseOrderNo = res.data[0].purchaseOrderNo || res.data[0].orderId;
+  } else {
+    purchaseOrderNo = res.data?.purchaseOrderNo || res.data?.orderId;
+  }
+
+  return purchaseOrderNo;
+};
+
+// 鎵弿鏉$爜鏍稿績閫昏緫
+const handleScan = async () => {
+  if (!formRef.value) return;
+  await formRef.value.validateField('barcode');
+
+  const barcode = formData.barcode.trim();
+  const outboundOrderNo = orderForm.outboundOrderNo.trim();
+
+  // 鏉$爜鍘婚噸
+  const isDuplicate = scannedBarcodes.value.some(item => item.barcode === barcode);
+  if (isDuplicate) {
+    ElMessage.warning(`鏉$爜銆�${barcode}銆戝凡瀛樺湪锛屾棤闇�閲嶅鎵弿`);
+    formData.barcode = "";
+    nextTick(() => barcodeInputRef.value?.focus()); // 鍘婚噸鍚庝粛鑱氱劍鏉$爜妗�
+    return;
+  }
+
+  try {
+    loading.value = true;
+
+    // 姝ラ1锛氭煡璇㈤噰璐崟鍙�
+    const purchaseOrderNo = await getPurchaseOrderByBarcode(barcode);
+    if (purchaseOrderNo) {
+      orderForm.purchaseOrderNo = purchaseOrderNo;
+    } else {
+      ElMessage.info("鏈煡璇㈠埌璇ユ潯鐮佸搴旂殑閲囪喘鍗曞彿锛岀户缁獙璇佹潯鐮佹湁鏁堟��");
+      formData.barcode = ""; // 鏂板锛氶獙璇佸け璐ユ椂娓呯┖杈撳叆妗�
+      nextTick(() => barcodeInputRef.value?.focus()); // 鏂板锛氳仛鐒︽潯鐮佽緭鍏ユ
+    }
+
+    // 姝ラ2锛氶獙璇佹潯鐮佸苟鑾峰彇鐗╂枡淇℃伅
+    const validateRes = await http.post("/api/OutboundPicking/BarcodeValidate", {
+      outOder: outboundOrderNo,
+      inOder: purchaseOrderNo || orderForm.purchaseOrderNo,
+      barCode: barcode
+    });
+
+    if (validateRes.status === true) {
+      if (!Array.isArray(validateRes.data) || validateRes.data.length === 0) {
+        ElMessage.warning("璇ユ潯鐮侀獙璇佹垚鍔燂紝浣嗘湭杩斿洖鐗╂枡淇℃伅");
+        formData.barcode = ""; // 鏂板锛氭棤鐗╂枡淇℃伅鏃朵篃娓呯┖杈撳叆妗�
+        nextTick(() => barcodeInputRef.value?.focus()); // 鏂板锛氳仛鐒︽潯鐮佹
+      } else {
+        const newItems = validateRes.data.map(item => ({
+          barcode: item.barcode || '',
+          materielCode: item.materielCode || '',
+          materielName: item.materielName || '',
+          batchNo: item.batchNo || '',
+          orderQuantity: item.orderQuantity || item.quantity || 0,
+          supplyCode: item.supplyCode || '',
+          purchaseOrderNo: purchaseOrderNo || ''
+        }));
+        scannedBarcodes.value.push(...newItems);
+        ElMessage.success(`鎵弿鎴愬姛锛屾柊澧� ${newItems.length} 鏉$墿鏂欎俊鎭紝绱 ${scannedBarcodes.value.length} 鏉);
+        formData.barcode = "";
+      }
+    } else {
+      ElMessage.error("鎵弿澶辫触锛�" + (validateRes.message || '鏉$爜楠岃瘉澶辫触'));
+      formData.barcode = ""; // 鏂板锛氶獙璇佸け璐ユ椂娓呯┖杈撳叆妗�
+      nextTick(() => barcodeInputRef.value?.focus()); // 鏂板锛氳仛鐒︽潯鐮佽緭鍏ユ
+    }
+  } catch (error) {
+    ElMessage.error(error.message);
+    formData.barcode = ""; // 淇濈暀锛氭帴鍙e紓甯告椂娓呯┖
+    // 鏂板锛氬紓甯告椂涔熷己鍒惰仛鐒︽潯鐮佹
+    nextTick(() => barcodeInputRef.value?.focus());
+  } finally {
+    loading.value = false;
+    // 鎵弿瀹屾垚鍚庡缁堣仛鐒︽潯鐮佽緭鍏ユ锛堟柟渚胯繛缁壂鎻忥級
+    nextTick(() => {
+      barcodeInputRef.value?.focus();
+      if (barcodeInputRef.value?.input) {
+        barcodeInputRef.value.input.select = () => {};
+      }
+    });
+  }
+};
+
+// 甯﹂槻鎶栫殑鎵弿澶勭悊
+const debouncedHandleScan = debounce(async (e) => {
+  e.stopPropagation();
+  e.preventDefault();
+  await handleScan();
+}, 100);
+
+// 绉婚櫎鍗曟潯璁板綍
 const removeItem = async (index, barcode) => {
   try {
     loading.value = true;
+    const currentItem = scannedBarcodes.value[index];
     const res = await http.post("/api/OutboundPicking/DeleteBarcode", {
-      outOder: orderForm.outboundOrderId,
-      inOder: orderForm.purchaseOrderId,
+      outOder: orderForm.outboundOrderNo,
+      inOder: currentItem?.purchaseOrderNo || orderForm.purchaseOrderNo,
       barCode: barcode
     });
 
     if (res.status === true) {
       scannedBarcodes.value.splice(index, 1);
       ElMessage.success("鍒犻櫎鎴愬姛");
+      if (scannedBarcodes.value.length === 0) {
+        orderForm.purchaseOrderNo = "";
+      }
     } else {
       ElMessage.error("鍒犻櫎澶辫触锛�" + (res.message || '鍒犻櫎澶辫触'));
     }
@@ -401,6 +430,8 @@
     ElMessage.error("鍒犻櫎鏉$爜寮傚父锛�" + error.message);
   } finally {
     loading.value = false;
+    // 鍒犻櫎鍚庝粛鑱氱劍鏉$爜杈撳叆妗�
+    nextTick(() => barcodeInputRef.value?.focus());
   }
 };
 
@@ -408,28 +439,37 @@
 const submit = async () => {
   if (scannedBarcodes.value.length === 0) {
     ElMessage.warning("璇峰厛鎵弿鑷冲皯涓�鏉℃潯鐮�");
+    nextTick(() => barcodeInputRef.value?.focus()); // 鎻愪氦澶辫触鑱氱劍鏉$爜妗�
     return;
   }
 
   const barcodes = scannedBarcodes.value.map(item => item.barcode);
+  const purchaseOrderNos = [...new Set(scannedBarcodes.value.map(item => item.purchaseOrderNo).filter(Boolean))];
 
   try {
-    loading.value = true;
+    // 寮�鍚彁浜oading锛屾樉绀洪伄缃╁眰
+    submitLoading.value = true;
     const res = await http.post("/api/OutboundPicking/NoStockOutSubmit", {
-      OutOderSubmit: orderForm.outboundOrderId,
-      InOderSubmit: orderForm.purchaseOrderId,
+      OutOderSubmit: orderForm.outboundOrderNo,
+      InOderSubmit: purchaseOrderNos.join(',') || '',
       BarCodeSubmit: barcodes
     });
 
     if (res.status === true) {
       ElMessage.success("鍑哄簱鎻愪氦鎴愬姛");
       showDetailBox.value = false;
+      scannedBarcodes.value = [];
+      orderForm.purchaseOrderNo = "";
     } else {
       ElMessage.error("鍑哄簱鎻愪氦澶辫触锛�" + (res.message || '鎻愪氦澶辫触'));
+      nextTick(() => barcodeInputRef.value?.focus()); // 鎻愪氦澶辫触鑱氱劍鏉$爜妗�
     }
   } catch (error) {
     ElMessage.error("鍑哄簱鎻愪氦寮傚父锛�" + error.message);
+    nextTick(() => barcodeInputRef.value?.focus()); // 寮傚父鑱氱劍鏉$爜妗�
   } finally {
+    // 鍏抽棴鎻愪氦loading锛岄殣钘忛伄缃╁眰
+    submitLoading.value = false;
     loading.value = false;
   }
 };
@@ -441,7 +481,7 @@
 </script>
 
 <style scoped>
-/* 鍏抽敭锛氬畾涔夊垪琛ㄩ」鐨勮繃娓″姩鐢� */
+/*杩囨浮鍔ㄧ敾 */
 .barcode-item-transition-enter-active,
 .barcode-item-transition-leave-active {
   transition: all 0.3s ease;
@@ -454,9 +494,35 @@
   opacity: 0;
   transform: translateX(30px);
 }
-/* 纭繚鍒犻櫎鏃跺叾浠栧厓绱犲钩婊戜笂绉� */
 .barcode-item-transition-move {
   transition: transform 1s ease;
+}
+
+/* 鏂板锛氭彁浜ら伄缃╁眰鏍峰紡 */
+.submit-mask {
+  position: absolute;
+  top: 0;
+  left: 0;
+  width: 100%;
+  height: 100%;
+  background-color: rgba(255, 255, 255, 0.85);
+  display: flex;
+  justify-content: center;
+  align-items: center;
+  z-index: 100;
+  border-radius: inherit;
+}
+.mask-content {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+  gap: 12px;
+  color: #409eff;
+  font-size: 15px;
+}
+.loading-icon {
+  font-size: 24px;
+  animation: el-loading-circle 1.5s linear infinite;
 }
 
 .scan-list {
@@ -490,7 +556,6 @@
   padding: 0;
 }
 
-/* 鑷畾涔夋粴鍔ㄦ潯 */
 .custom-scrollbar :deep(.el-scrollbar__thumb) {
   background: rgba(0, 0, 0, 0.2);
   border-radius: 4px;
@@ -507,26 +572,47 @@
 .barcode-item {
   display: flex;
   justify-content: space-between;
-  align-items: center;
-  padding: 10px 15px;
+  align-items: flex-start;
+  padding: 15px;
   border-bottom: 1px solid #f7f7f7;
   transition: background-color 0.2s ease;
 }
 .barcode-item:hover {
   background-color: #fafafa;
 }
-/* 涓哄鏁拌娣诲姞杞诲井鐨勮儗鏅壊锛屽寮哄彲璇绘�� */
 .barcode-item:nth-child(odd) {
   background-color: #f9f9f9;
 }
-.barcode-text {
+.barcode-detail {
   flex: 1;
+  display: grid;
+  grid-template-columns: repeat(4, 1fr);
+  gap: 8px 15px;
   font-size: 14px;
-  color: #666;
-  transition: color 0.2s;
 }
-.barcode-item:hover .barcode-text {
-  color: #409eff;
+@media (max-width: 1200px) {
+  .barcode-detail {
+    grid-template-columns: repeat(3, 1fr);
+  }
+}
+@media (max-width: 992px) {
+  .barcode-detail {
+    grid-template-columns: repeat(2, 1fr);
+  }
+}
+.detail-row {
+  display: flex;
+  align-items: center;
+}
+.label {
+  color: #999;
+  margin-right: 5px;
+  white-space: nowrap;
+}
+.value {
+  color: #666;
+  flex: 1;
+  word-break: break-all;
 }
 
 .delete-btn {
@@ -534,6 +620,8 @@
   font-size: 16px;
   transition: all 0.2s;
   opacity: 0.7;
+  margin-left: 10px;
+  flex-shrink: 0;
 }
 .barcode-item:hover .delete-btn {
   opacity: 1;
@@ -559,7 +647,6 @@
   color: #dcdfe6;
 }
 
-/* 鑷畾涔夎緭鍏ユ */
 .custom-input :deep(.el-input__inner) {
   border-radius: 6px;
   border-color: #e4e7ed;
@@ -572,7 +659,6 @@
   box-shadow: 0 0 0 3px rgba(64, 158, 255, 0.1);
 }
 
-/* 鑷畾涔夋寜閽� */
 .custom-button {
   border-radius: 6px;
   height: 36px;
@@ -611,7 +697,6 @@
 </style>
 
 <style>
-/* 鍏ㄥ眬鏍峰紡閮ㄥ垎淇濇寔涓嶅彉 */
 .text-button:hover {
   background-color: #f0f9eb !important;
 }

--
Gitblit v1.9.3