From a32e60bf3366bf3b2d8d0d53b8257290acfb3d4e Mon Sep 17 00:00:00 2001
From: huminmin <mac@MacBook-Pro.local>
Date: 星期五, 12 六月 2026 10:26:58 +0800
Subject: [PATCH] 班次配置,夜班不限制时间顺序

---
 src/views/procurementManagement/procurementLedger/index.vue |  408 +++++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 files changed, 376 insertions(+), 32 deletions(-)

diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index dad6a26..cab2a26 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -66,6 +66,9 @@
     </div>
     <div class="table_list">
       <div style="display: flex;justify-content: flex-end;margin-bottom: 20px;">
+        <el-button type="success"
+                   plain
+                   @click="handleBatchGenerate">鎵归噺鐢熸垚鏁版嵁</el-button>
         <el-button type="primary"
                    @click="openForm('add')">鏂板鍙拌处</el-button>
         <el-button type="primary"
@@ -106,7 +109,7 @@
                                prop="specificationModel" />
               <el-table-column label="鍗曚綅"
                                prop="unit" />
-                               <el-table-column label="鍏ュ簱瀹℃牳鐘舵��"
+              <el-table-column label="鍏ュ簱瀹℃牳鐘舵��"
                                prop="stockInApprovalStatus"
                                width="120">
                 <template #default="scope">
@@ -122,6 +125,12 @@
                                prop="availableQuality" />
               <el-table-column label="閫�璐ф暟閲�"
                                prop="returnQuality" />
+              <el-table-column label="杩愯垂鍗曚环(鍏�)"
+                               prop="freightUnitPrice"
+                               :formatter="formattedNumber" />
+              <el-table-column label="鎬昏繍璐�(鍏�)"
+                               prop="totalFreight"
+                               :formatter="formattedNumber" />
               <el-table-column label="绋庣巼(%)"
                                prop="taxRate" />
               <el-table-column label="鍚◣鍗曚环(鍏�)"
@@ -186,6 +195,14 @@
                          width="100"
                          prop="paymentMethod"
                          show-overflow-tooltip />
+        <el-table-column label="杞︾墝鍙�"
+                         prop="carPlateNumber"
+                         width="140"
+                         show-overflow-tooltip />
+        <el-table-column label="杩愯緭鍗曚綅/涓汉"
+                         prop="transportUnitOrPerson"
+                         width="180"
+                         show-overflow-tooltip />
         <el-table-column label="鍚堝悓閲戦(鍏�)"
                          prop="contractAmount"
                          width="200"
@@ -212,6 +229,11 @@
                        type="primary"
                        @click="openForm('edit', scope.row)"
                        :disabled="scope.row.stockInStatus === '瀹屽叏鍏ュ簱'">缂栬緫
+            </el-button>
+            <el-button link
+                       type="primary"
+                       :disabled="scope.row.approvalStatus !== 3 || scope.row.stockInStatus === '瀹屽叏鍏ュ簱'"
+                       @click="handleStockIn(scope.row)">鍏ュ簱
             </el-button>
             <el-button link
                        type="primary"
@@ -306,6 +328,24 @@
                               type="date"
                               placeholder="璇烽�夋嫨"
                               clearable />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="30">
+          <el-col :span="12">
+            <el-form-item label="杞︾墝鍙凤細"
+                          prop="carPlateNumber">
+              <el-input v-model="form.carPlateNumber"
+                        placeholder="璇疯緭鍏�"
+                        clearable />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="杩愯緭鍗曚綅/涓汉锛�"
+                          prop="transportUnitOrPerson">
+              <el-input v-model="form.transportUnitOrPerson"
+                        placeholder="璇疯緭鍏�"
+                        clearable />
             </el-form-item>
           </el-col>
         </el-row>
@@ -410,6 +450,14 @@
           <el-table-column label="鏁伴噺"
                            prop="quantity"
                            width="70" />
+          <el-table-column label="杩愯垂鍗曚环(鍏�)"
+                           prop="freightUnitPrice"
+                           :formatter="formattedNumber"
+                           width="150" />
+          <el-table-column label="鎬昏繍璐�(鍏�)"
+                           prop="totalFreight"
+                           :formatter="formattedNumber"
+                           width="150" />
           <el-table-column label="搴撳瓨棰勮鏁伴噺"
                            prop="warnNum"
                            width="120"
@@ -608,7 +656,32 @@
                                style="width: 100%"
                                v-model="productForm.quantity"
                                placeholder="璇疯緭鍏�"
-                               @change="mathNum" />
+                               @change="handleQuantityChange" />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-row :gutter="30">
+          <el-col :span="12">
+            <el-form-item label="杩愯垂鍗曚环(鍏�)锛�"
+                          prop="freightUnitPrice">
+              <el-input-number v-model="productForm.freightUnitPrice"
+                               :precision="2"
+                               :step="0.1"
+                               :min="0"
+                               clearable
+                               style="width: 100%"
+                               @change="handleFreightUnitPriceChange" />
+            </el-form-item>
+          </el-col>
+          <el-col :span="12">
+            <el-form-item label="鎬昏繍璐�(鍏�)锛�"
+                          prop="totalFreight">
+              <el-input-number v-model="productForm.totalFreight"
+                               :precision="2"
+                               :step="0.1"
+                               :min="0"
+                               clearable
+                               style="width: 100%" />
             </el-form-item>
           </el-col>
         </el-row>
@@ -679,6 +752,86 @@
         </el-row>
       </el-form>
     </FormDialog>
+    <!-- 鍏ュ簱寮圭獥 -->
+    <FormDialog v-model="stockInDialogVisible"
+                title="鍏ュ簱纭"
+                :width="'90%'"
+                @close="stockInDialogVisible = false"
+                @confirm="submitStockIn"
+                @cancel="stockInDialogVisible = false">
+      <el-form :model="stockInForm"
+               label-width="120px"
+               label-position="top">
+        <el-row :gutter="20">
+          <el-col :span="12">
+            <el-form-item label="閲囪喘鍚堝悓鍙�">
+              <el-input v-model="stockInForm.purchaseContractNumber"
+                        disabled />
+            </el-form-item>
+          </el-col>
+        </el-row>
+        <el-table :data="stockInForm.details"
+                  border>
+          <el-table-column align="center"
+                           label="搴忓彿"
+                           type="index"
+                           width="60" />
+          <el-table-column label="浜у搧澶х被"
+                           prop="productCategory"
+                           show-overflow-tooltip />
+          <el-table-column label="瑙勬牸鍨嬪彿"
+                           prop="specificationModel"
+                           show-overflow-tooltip />
+          <el-table-column label="鍗曚綅"
+                           prop="unit"
+                           width="70" />
+          <el-table-column label="寰呭叆搴撴暟閲�"
+                           prop="availableQuality"
+                           width="100" />
+          <el-table-column label="鏈鍏ュ簱鏁伴噺"
+                           width="130">
+            <template #default="scope">
+              <el-input-number v-model="scope.row.inboundQuantity"
+                               :step="0.01"
+                               :min="0"
+                               :max="scope.row.availableQuality"
+                               @change="handleInboundChange(scope.row)"
+                               controls-position="right"
+                               style="width: 100%" />
+            </template>
+          </el-table-column>
+          <el-table-column label="鏄惁鍚按"
+                           width="100"
+                           align="center">
+            <template #default="scope">
+              <el-switch v-model="scope.row.isContainsWater"
+                         @change="handleInboundChange(scope.row)" />
+            </template>
+          </el-table-column>
+          <el-table-column label="鍚按閲�(%)"
+                           width="130">
+            <template #default="scope">
+              <el-input-number v-if="scope.row.isContainsWater"
+                               v-model="scope.row.waterContent"
+                               :precision="2"
+                               :step="0.1"
+                               :min="0"
+                               :max="100"
+                               @change="handleInboundChange(scope.row)"
+                               controls-position="right"
+                               style="width: 100%" />
+              <span v-else>--</span>
+            </template>
+          </el-table-column>
+          <el-table-column label="瀹為檯鍏ュ簱鏁伴噺"
+                           width="130">
+            <template #default="scope">
+              <span style="font-weight: bold; color: #409EFF;">{{ scope.row.actualInboundQuantity }}</span>
+            </template>
+          </el-table-column>
+        </el-table>
+      </el-form>
+    </FormDialog>
     <FileList v-if="fileListDialogVisible"
               v-model:visible="fileListDialogVisible"
               record-type="purchase_ledger"
@@ -721,6 +874,8 @@
     getOptions,
     getPurchaseTemplateList,
     delPurchaseTemplate,
+    batchGeneratePurchaseInboundSteps,
+    manualStockIn,
   } from "@/api/procurementManagement/procurementLedger.js";
   import useFormData from "@/hooks/useFormData.js";
   const FileList = defineAsyncComponent(() =>
@@ -741,18 +896,23 @@
   const tableLoading = ref(false);
   const recordId = ref();
   const fileListDialogVisible = ref(false);
+  // 鍏ュ簱寮圭獥鐩稿叧
+  const stockInDialogVisible = ref(false);
+  const stockInLoading = ref(false);
+  const stockInForm = reactive({
+    purchaseLedgerId: null,
+    purchaseContractNumber: "",
+    details: [],
+  });
   const page = reactive({
     current: 1,
     size: 100,
   });
   const total = ref(0);
   const fileList = ref([]);
-  import useUserStore from "@/store/modules/user";
   import { modelList, productTreeList } from "@/api/basicData/product.js";
   import dayjs from "dayjs";
   import FileUpload from "@/components/AttachmentUpload/file/index.vue";
-
-  const userStore = useUserStore();
 
   // 璁㈠崟瀹℃壒鐘舵�佹樉绀烘枃鏈�
   const approvalStatusText = {
@@ -776,9 +936,9 @@
   // 鑾峰彇鍏ュ簱鐘舵�佹爣绛剧被鍨�
   const getStockInStatusType = status => {
     const typeMap = {
-      "寰呭叆搴�": "info", // 寰呭叆搴� - 鐏拌壊
-      "鍏ュ簱涓�": "warning", // 鍏ュ簱涓� - 姗欒壊
-      "瀹屽叏鍏ュ簱": "success", // 瀹屽叏鍏ュ簱 - 缁胯壊
+      寰呭叆搴�: "info", // 寰呭叆搴� - 鐏拌壊
+      鍏ュ簱涓�: "warning", // 鍏ュ簱涓� - 姗欒壊
+      瀹屽叏鍏ュ簱: "success", // 瀹屽叏鍏ュ簱 - 缁胯壊
     };
     return typeMap[status] || "";
   };
@@ -786,9 +946,9 @@
   // 鑾峰彇鍏ュ簱瀹℃牳鐘舵�佹爣绛剧被鍨�
   const getStockInApprovalStatusType = status => {
     const typeMap = {
-      "寰呭叆搴�": "info", // 寰呭叆搴� - 鐏拌壊
-      "鍏ュ簱涓�": "warning", // 鍏ュ簱涓� - 姗欒壊
-      "瀹屽叏鍏ュ簱": "success", // 瀹屽叏鍏ュ簱 - 缁胯壊
+      寰呭叆搴�: "info", // 寰呭叆搴� - 鐏拌壊
+      鍏ュ簱涓�: "warning", // 鍏ュ簱涓� - 姗欒壊
+      瀹屽叏鍏ュ簱: "success", // 瀹屽叏鍏ュ簱 - 缁胯壊
     };
     return typeMap[status] || "";
   };
@@ -918,12 +1078,14 @@
       supplierName: "",
       supplierId: "",
       paymentMethod: "",
+      carPlateNumber: "",
+      transportUnitOrPerson: "",
       executionDate: "",
       isChecked: false,
     },
     rules: {
       purchaseContractNumber: [
-        { required: true, message: "璇疯緭鍏�", trigger: "blur" },
+        { required: false, message: "璇疯緭鍏�", trigger: "blur" },
       ],
       projectName: [
         { required: true, message: "璇疯緭鍏ラ」鐩悕绉�", trigger: "blur" },
@@ -958,6 +1120,8 @@
       specificationModel: "",
       unit: "",
       quantity: "",
+      freightUnitPrice: "",
+      totalFreight: "",
       taxInclusiveUnitPrice: "",
       taxRate: "",
       taxInclusiveTotalPrice: "",
@@ -1075,7 +1239,12 @@
   };
 
   const formattedNumber = (row, column, cellValue) => {
-    return parseFloat(cellValue).toFixed(2);
+    if (cellValue === undefined || cellValue === null || cellValue === "") {
+      return "0.00";
+    }
+    const num = Number(cellValue);
+    if (Number.isNaN(num)) return "0.00";
+    return num.toFixed(2);
   };
   // 鏌ヨ鍒楄〃
   /** 鎼滅储鎸夐挳鎿嶄綔 */
@@ -1186,6 +1355,8 @@
     return proxy.summarizeTable(
       param,
       [
+        "freightUnitPrice",
+        "totalFreight",
         "taxInclusiveUnitPrice",
         "taxInclusiveTotalPrice",
         "taxExclusiveTotalPrice",
@@ -1234,6 +1405,106 @@
     productSelectedRows.value = selectedRows;
   };
   const expandedRowKeys = ref([]);
+
+  // 鍏ュ簱澶勭悊
+  const handleStockIn = async row => {
+    stockInForm.purchaseLedgerId = row.id;
+    stockInForm.purchaseContractNumber = row.purchaseContractNumber;
+    stockInForm.details = [];
+
+    try {
+      proxy.$modal.loading("姝e湪鍔犺浇浜у搧淇℃伅...");
+      const res = await productList({ salesLedgerId: row.id, type: 2 });
+      if (res.code === 200) {
+        // 杩囨护鎺夊凡缁忓畬鍏ㄥ叆搴撶殑浜у搧锛堝鏋滄湁杩欎釜鐘舵�佺殑璇濓紝鎴栬�呯洿鎺ユ樉绀烘墍鏈夊彲鐢ㄦ暟閲忓ぇ浜�0鐨勪骇鍝侊級
+        stockInForm.details = (res.data || [])
+          .filter(item => (item.availableQuality || 0) > 0)
+          .map(item => ({
+            ...item,
+            inboundQuantity: item.availableQuality || 0, // 榛樿鍏ュ簱鍏ㄩ儴鍙敤鏁伴噺
+            isContainsWater: false,
+            waterContent: 0,
+            actualInboundQuantity: item.availableQuality || 0,
+          }));
+
+        if (stockInForm.details.length === 0) {
+          proxy.$modal.msgWarning("璇ュ悎鍚屼笅娌℃湁鍙叆搴撶殑浜у搧璁板綍");
+          return;
+        }
+        stockInDialogVisible.value = true;
+      }
+    } catch (error) {
+      console.error("鍔犺浇浜у搧鍒楄〃澶辫触:", error);
+      proxy.$modal.msgError("鍔犺浇浜у搧鍒楄〃澶辫触");
+    } finally {
+      proxy.$modal.closeLoading();
+    }
+  };
+
+  // 璁$畻瀹為檯鍏ュ簱鏁伴噺
+  const handleInboundChange = row => {
+    if (row.isContainsWater) {
+      // 瀹為檯鍏ュ簱 = 鏈鍏ュ簱鏁伴噺 * (1 - 鍚按閲�/100)
+      row.actualInboundQuantity = Number(
+        (row.inboundQuantity * (1 - (row.waterContent || 0) / 100)).toFixed(2)
+      );
+    } else {
+      row.actualInboundQuantity = row.inboundQuantity;
+    }
+  };
+
+  const submitStockIn = async () => {
+    if (stockInForm.details.length === 0) {
+      proxy.$modal.msgWarning("璇烽�夋嫨鍏ュ簱浜у搧");
+      return;
+    }
+
+    // 楠岃瘉鍏ュ簱鏁伴噺
+    const invalid = stockInForm.details.some(
+      item => !item.inboundQuantity || item.inboundQuantity <= 0
+    );
+    if (invalid) {
+      proxy.$modal.msgWarning("璇疯緭鍏ユ湁鏁堢殑鍏ュ簱鏁伴噺");
+      return;
+    }
+
+    const overLimit = stockInForm.details.some(
+      item => item.inboundQuantity > item.availableQuality
+    );
+    if (overLimit) {
+      proxy.$modal.msgWarning("鍏ュ簱鏁伴噺涓嶈兘瓒呰繃鍙敤鏁伴噺");
+      return;
+    }
+
+    try {
+      stockInLoading.value = true;
+      const params = {
+        purchaseLedgerId: stockInForm.purchaseLedgerId,
+        details: stockInForm.details.map(item => ({
+          id: item.id,
+          inboundQuantity: Number(item.inboundQuantity),
+          isContainsWater: !!item.isContainsWater,
+          waterContent: item.isContainsWater ? Number(item.waterContent || 0) : 0,
+          actualInboundQuantity: Number(item.actualInboundQuantity),
+        })),
+      };
+
+      const res = await manualStockIn(params);
+      if (res.code === 200) {
+        proxy.$modal.msgSuccess("鍏ュ簱鎴愬姛");
+        stockInDialogVisible.value = false;
+        getList(); // 鍒锋柊鍒楄〃
+      } else {
+        proxy.$modal.msgError(res.msg || "鍏ュ簱澶辫触");
+      }
+    } catch (error) {
+      console.error("鍏ュ簱鎻愪氦澶辫触:", error);
+      proxy.$modal.msgError("鍏ュ簱鎻愪氦澶辫触");
+    } finally {
+      stockInLoading.value = false;
+    }
+  };
+
   // 灞曞紑琛�
   const expandChange = async (row, expandedRows) => {
     if (expandedRows.length > 0) {
@@ -1268,13 +1539,14 @@
       "taxInclusiveUnitPrice",
       "taxInclusiveTotalPrice",
       "taxExclusiveTotalPrice",
+      "totalFreight",
     ]);
   };
   // 鎵撳紑寮规
   const openForm = async (type, row) => {
     // 缂栬緫鏃舵鏌ュ叆搴撶姸鎬侊紝瀹屽叏鍏ュ簱鏃朵笉鑳界紪杈�
     if (type === "edit" && row) {
-      if (row.stockInStatus === '瀹屽叏鍏ュ簱') {
+      if (row.stockInStatus === "瀹屽叏鍏ュ簱") {
         proxy.$modal.msgWarning("瀹屽叏鍏ュ簱鐘舵�佺殑璁板綍涓嶈兘缂栬緫");
         return;
       }
@@ -1306,18 +1578,7 @@
 
       form.value.entryDate = getCurrentDate();
 
-      if (type === "add") {
-        // 鏂板鏃剁敓鎴愰噰璐悎鍚屽彿
-        try {
-          const purchaseNoRes = await createPurchaseNo();
-          if (purchaseNoRes?.data) {
-            form.value.purchaseContractNumber = purchaseNoRes.data;
-          }
-        } catch (error) {
-          console.error("鐢熸垚閲囪喘鍚堝悓鍙峰け璐�:", error);
-          proxy.$modal.msgWarning("鐢熸垚閲囪喘鍚堝悓鍙峰け璐�");
-        }
-      } else if (type === "edit" && row?.id) {
+      if (type === "edit" && row?.id) {
         // 缂栬緫鏃跺姞杞芥暟鎹�
         currentId.value = row.id;
         try {
@@ -1325,7 +1586,10 @@
           form.value = { ...purchaseRes, stockInStatus: row.stockInStatus };
           fileList.value = purchaseRes.storageBlobVOS || [];
           // 浣跨敤 productList 鎺ュ彛鑾峰彇浜у搧鍒楄〃锛屼互鑾峰彇鍏ュ簱瀹℃牳鐘舵��
-          const productRes = await productList({ salesLedgerId: row.id, type: 2 });
+          const productRes = await productList({
+            salesLedgerId: row.id,
+            type: 2,
+          });
           productData.value = productRes.data || [];
         } catch (error) {
           console.error("鍔犺浇閲囪喘鍙拌处鏁版嵁澶辫触:", error);
@@ -1398,7 +1662,7 @@
 
   // 鎻愪氦琛ㄥ崟
   const submitForm = () => {
-    proxy.$refs["formRef"].validate(valid => {
+    proxy.$refs["formRef"].validate(async valid => {
       if (valid) {
         if (productData.value.length > 0) {
           // 鏂板鏃讹紝闇�瑕佷粠姣忎釜浜у搧瀵硅薄涓垹闄� id 瀛楁
@@ -1428,6 +1692,20 @@
           delete submitData.id;
         }
 
+        // 濡傛灉閲囪喘鍚堝悓鍙蜂负绌猴紝鍒欐牴鎹綍鍏ユ棩鏈熻嚜鍔ㄧ敓鎴�
+        if (!submitData.purchaseContractNumber) {
+          try {
+            const purchaseNoRes = await createPurchaseNo(submitData.entryDate);
+            if (purchaseNoRes?.data) {
+              submitData.purchaseContractNumber = purchaseNoRes.data;
+            }
+          } catch (error) {
+            console.error("鐢熸垚閲囪喘鍚堝悓鍙峰け璐�:", error);
+            proxy.$modal.msgWarning("鐢熸垚閲囪喘鍚堝悓鍙峰け璐�");
+            return;
+          }
+        }
+
         addOrEditPurchase(submitData).then(res => {
           proxy.$modal.msgSuccess("鎻愪氦鎴愬姛");
           closeDia();
@@ -1444,7 +1722,7 @@
   // 鎵撳紑浜у搧寮规
   const openProductForm = async (type, row, index) => {
     // 缂栬緫鏃舵鏌ヤ骇鍝佸叆搴撳鏍哥姸鎬侊紝瀹屽叏鍏ュ簱鏃朵笉鑳界紪杈�
-    if (type === "edit" && row && row.stockInApprovalStatus === '瀹屽叏鍏ュ簱') {
+    if (type === "edit" && row && row.stockInApprovalStatus === "瀹屽叏鍏ュ簱") {
       proxy.$modal.msgWarning("瀹屽叏鍏ュ簱鐘舵�佺殑浜у搧涓嶈兘缂栬緫");
       return;
     }
@@ -1468,6 +1746,12 @@
     if (type === "edit") {
       // 澶嶅埗琛屾暟鎹�
       productForm.value = { ...row };
+      if (productForm.value.freightUnitPrice === undefined) {
+        productForm.value.freightUnitPrice = "";
+      }
+      if (productForm.value.totalFreight === undefined) {
+        productForm.value.totalFreight = "";
+      }
 
       // 濡傛灉鏄粠妯℃澘鍔犺浇鐨勬暟鎹紝鍙兘娌℃湁 productId 鍜� productModelId
       // 闇�瑕佹牴鎹� productCategory 鍜� specificationModel 鏉ユ煡鎵惧搴旂殑 ID
@@ -1532,6 +1816,34 @@
       // 鏈�鍚庡啀绛夊緟涓�娆� DOM 鏇存柊锛岀‘淇濇墍鏈夋暟鎹兘宸茶缃�
       await nextTick();
     }
+    computeTotalFreight();
+  };
+
+  const computeTotalFreight = () => {
+    const hasQuantity =
+      productForm.value.quantity !== "" &&
+      productForm.value.quantity !== null &&
+      productForm.value.quantity !== undefined;
+    const hasFreightUnitPrice =
+      productForm.value.freightUnitPrice !== "" &&
+      productForm.value.freightUnitPrice !== null &&
+      productForm.value.freightUnitPrice !== undefined;
+    if (!hasQuantity || !hasFreightUnitPrice) return;
+
+    const quantity = Number(productForm.value.quantity);
+    const freightUnitPrice = Number(productForm.value.freightUnitPrice);
+    if (!Number.isFinite(quantity) || !Number.isFinite(freightUnitPrice)) return;
+
+    productForm.value.totalFreight = (quantity * freightUnitPrice).toFixed(2);
+  };
+
+  const handleQuantityChange = () => {
+    mathNum();
+    computeTotalFreight();
+  };
+
+  const handleFreightUnitPriceChange = () => {
+    computeTotalFreight();
   };
   const getProductOptions = () => {
     return productTreeList().then(res => {
@@ -1601,8 +1913,9 @@
           submitProductEdit();
         } else {
           if (productOperationType.value === "add") {
-            productData.value.push({ ...productForm.value });
+            console.log("productForm.value---", productForm.value);
             console.log("productData.value---", productData.value);
+            productData.value.push({ ...productForm.value });
           } else {
             productData.value[productOperationIndex.value] = {
               ...productForm.value,
@@ -1633,7 +1946,7 @@
     }
     // 妫�鏌ラ�変腑鐨勪骇鍝佷腑鏄惁鏈夊畬鍏ㄥ叆搴撶殑
     const hasFullyStocked = productSelectedRows.value.some(
-      row => row.stockInApprovalStatus === '瀹屽叏鍏ュ簱'
+      row => row.stockInApprovalStatus === "瀹屽叏鍏ュ簱"
     );
     if (hasFullyStocked) {
       proxy.$modal.msgWarning("閫変腑鐨勪骇鍝佷腑鍖呭惈瀹屽叏鍏ュ簱鐨勪骇鍝侊紝鏃犳硶鍒犻櫎");
@@ -1709,6 +2022,37 @@
           proxy.$modal.msgSuccess("鍒犻櫎鎴愬姛");
           getList();
         });
+      })
+      .catch(() => {
+        proxy.$modal.msg("宸插彇娑�");
+      });
+  };
+
+  const handleBatchGenerate = async () => {
+    if (selectedRows.value.length === 0) {
+      proxy.$modal.msgWarning("璇烽�夋嫨鏁版嵁");
+      return;
+    }
+    const ids = selectedRows.value.map(item => item.id);
+
+    ElMessageBox.confirm("纭鎵归噺鐢熸垚鏁版嵁锛�", "鎵归噺鐢熸垚", {
+      confirmButtonText: "纭",
+      cancelButtonText: "鍙栨秷",
+      type: "info",
+    })
+      .then(() => {
+        proxy.$modal.loading("姝e湪鎵归噺鐢熸垚鏁版嵁锛岃绋嶅��...");
+        batchGeneratePurchaseInboundSteps({ ids })
+          .then(res => {
+            proxy.$modal.msgSuccess("鎵归噺鐢熸垚鎴愬姛");
+            getList();
+          })
+          .catch(() => {
+            proxy.$modal.msgError("鎵归噺鐢熸垚澶辫触");
+          })
+          .finally(() => {
+            proxy.$modal.closeLoading();
+          });
       })
       .catch(() => {
         proxy.$modal.msg("宸插彇娑�");
@@ -1852,7 +2196,7 @@
       contractNo: form.value.salesLedgerId,
     });
     if (code == 200) {
-      productData.value = data;
+      productData.value = data || [];
     }
   };
 

--
Gitblit v1.9.3