yyb
2026-05-11 3682ad63b5bdb47228325dea1efe2bb9069254a5
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("扫码处理失败,请重试");