From 3682ad63b5bdb47228325dea1efe2bb9069254a5 Mon Sep 17 00:00:00 2001
From: yyb <995253665@qq.com>
Date: 星期一, 11 五月 2026 15:53:18 +0800
Subject: [PATCH] 合格出库扫销售二维码进行发货

---
 src/pages/inventoryManagement/scanOut/index.vue |  128 +++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 125 insertions(+), 3 deletions(-)

diff --git a/src/pages/inventoryManagement/scanOut/index.vue b/src/pages/inventoryManagement/scanOut/index.vue
index 8359451..69b9d07 100644
--- a/src/pages/inventoryManagement/scanOut/index.vue
+++ b/src/pages/inventoryManagement/scanOut/index.vue
@@ -28,7 +28,7 @@
 
           <text class="module-label">鍚堟牸鍑哄簱</text>
 
-          <text class="module-desc">鎵弿鍚堟牸鍝佽繘琛岄鐢ㄥ嚭搴�</text>
+          <text class="module-desc">鎵弿鍚堟牸鍝佽繘琛岄鐢ㄥ嚭搴擄紝閿�鍞壂鐮佸彂璐�</text>
 
         </view>
 
@@ -225,7 +225,19 @@
 
                   @click="cancelForm">杩斿洖</u-button>
 
-        <u-button class="footer-confirm-btn"
+        <u-button v-if="showSalesShipButton"
+
+                  class="footer-confirm-btn"
+
+                  :loading="submitLoading"
+
+                  :disabled="salesShipButtonDisabled"
+
+                  @click="handleSalesShipFromScan">鍙戣揣</u-button>
+
+        <u-button v-else
+
+                  class="footer-confirm-btn"
 
                   :loading="submitLoading"
 
@@ -247,7 +259,12 @@
 
   import PageHeader from "@/components/PageHeader.vue";
 
-  import { productList as salesProductList } from "@/api/salesManagement/salesLedger";
+  import {
+    productList as salesProductList,
+    getSalesLedgerWithProducts,
+  } from "@/api/salesManagement/salesLedger";
+
+  import { canLedgerShip, executeSalesLedgerShip, getLedgerShippingLabel } from "@/utils/salesLedgerShip";
 
   import modal from "@/plugins/modal";
 
@@ -281,7 +298,24 @@
   /** 浜岀淮鐮佷腑鐨勫彴璐︿富閿� id */
   const scanLedgerId = ref(null);
 
+  /** 鍚堟牸鍑哄簱+閿�鍞爜锛氱敤浜庛�屽彂璐с�嶆寜閽笌鍙拌处绾ф牎楠岋紙涓庨攢鍞彴璐︿竴鑷达級 */
+  const salesLedgerSnapshotForShip = ref(null);
+
   const submitLoading = ref(false);
+
+  const showSalesShipButton = computed(
+    () =>
+      showForm.value &&
+      type.value === QUALITY_TYPE.qualified &&
+      contractKind.value === CONTRACT_KIND.sales
+  );
+
+  const salesShipButtonDisabled = computed(() => {
+    if (!showSalesShipButton.value) return false;
+    const snap = salesLedgerSnapshotForShip.value;
+    if (!snap) return false;
+    return !canLedgerShip(snap);
+  });
 
   const submitConfigByScene = createSubmitConfig(scanLedgerId);
 
@@ -568,6 +602,8 @@
 
       return formatProductStockStatus(item.productStockStatus);
 
+    if (row.key === "ledgerShippingStatus") return getLedgerShippingLabel(item);
+
     if (row.key === "heavyBox") return formatHeavyBox(item.heavyBox);
 
     if (row.key === "remainingQuantity") {
@@ -633,6 +669,8 @@
     contractKind.value = CONTRACT_KIND.sales;
 
     scanLedgerId.value = null;
+
+    salesLedgerSnapshotForShip.value = null;
 
     expandedByIndex.value = {};
 
@@ -724,6 +762,62 @@
       modal.closeLoading();
 
       console.error("鎵爜鍑哄簱鎻愪氦澶辫触", e);
+
+    } finally {
+
+      submitLoading.value = false;
+
+    }
+
+  };
+
+  const handleSalesShipFromScan = async () => {
+
+    if (scanLedgerId.value == null || scanLedgerId.value === "") {
+
+      modal.msgError("缂哄皯璁㈠崟淇℃伅锛岃閲嶆柊鎵爜");
+
+      return;
+
+    }
+
+    if (salesLedgerSnapshotForShip.value && !canLedgerShip(salesLedgerSnapshotForShip.value)) return;
+
+    submitLoading.value = true;
+
+    try {
+
+      modal.loading("鍔犺浇涓�...");
+
+      let ledgerRow = salesLedgerSnapshotForShip.value;
+
+      if (!ledgerRow?.id) {
+
+        ledgerRow = await getSalesLedgerWithProducts({ id: scanLedgerId.value, type: 1 });
+
+      }
+
+      modal.closeLoading();
+
+      if (!ledgerRow?.id) {
+
+        modal.msgError("鑾峰彇鍙拌处澶辫触");
+
+        return;
+
+      }
+
+      const { productData: _pd, ...ledgerForShip } = ledgerRow;
+
+      await executeSalesLedgerShip(ledgerForShip);
+
+    } catch (e) {
+
+      modal.closeLoading();
+
+      console.error("鎵爜鍙戣揣澶辫触", e);
+
+      modal.msgError("鑾峰彇鍙拌处澶辫触");
 
     } finally {
 
@@ -900,9 +994,35 @@
 
         showForm.value = true;
 
+        if (type.value === QUALITY_TYPE.qualified && kind === CONTRACT_KIND.sales) {
+
+          salesLedgerSnapshotForShip.value = null;
+
+          getSalesLedgerWithProducts({ id: scanData.id, type: 1 })
+
+            .then(res => {
+
+              salesLedgerSnapshotForShip.value = res;
+
+            })
+
+            .catch(() => {
+
+              salesLedgerSnapshotForShip.value = null;
+
+            });
+
+        } else {
+
+          salesLedgerSnapshotForShip.value = null;
+
+        }
+
       } else {
 
         scanLedgerId.value = null;
+
+        salesLedgerSnapshotForShip.value = null;
 
         modal.msgError("鏈煡璇㈠埌鏄庣粏鏁版嵁");
 
@@ -914,6 +1034,8 @@
 
       scanLedgerId.value = null;
 
+      salesLedgerSnapshotForShip.value = null;
+
       console.error("澶勭悊鎵爜缁撴灉澶辫触", error);
 
       modal.msgError("鎵爜澶勭悊澶辫触锛岃閲嶈瘯");

--
Gitblit v1.9.3