From 2eec8bc72cae5d80e0f7b02c3f213e7d58687a2c Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期四, 28 五月 2026 13:39:45 +0800
Subject: [PATCH] Merge branch 'dev_NEW_pro' of http://114.132.189.42:9002/r/product-inventory-management into dev_NEW_pro

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

diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index dad6a26..6fef889 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -106,7 +106,7 @@
                                prop="specificationModel" />
               <el-table-column label="鍗曚綅"
                                prop="unit" />
-                               <el-table-column label="鍏ュ簱瀹℃牳鐘舵��"
+              <el-table-column label="鍏ュ簱瀹℃牳鐘舵��"
                                prop="stockInApprovalStatus"
                                width="120">
                 <template #default="scope">
@@ -776,9 +776,9 @@
   // 鑾峰彇鍏ュ簱鐘舵�佹爣绛剧被鍨�
   const getStockInStatusType = status => {
     const typeMap = {
-      "寰呭叆搴�": "info", // 寰呭叆搴� - 鐏拌壊
-      "鍏ュ簱涓�": "warning", // 鍏ュ簱涓� - 姗欒壊
-      "瀹屽叏鍏ュ簱": "success", // 瀹屽叏鍏ュ簱 - 缁胯壊
+      寰呭叆搴�: "info", // 寰呭叆搴� - 鐏拌壊
+      鍏ュ簱涓�: "warning", // 鍏ュ簱涓� - 姗欒壊
+      瀹屽叏鍏ュ簱: "success", // 瀹屽叏鍏ュ簱 - 缁胯壊
     };
     return typeMap[status] || "";
   };
@@ -786,9 +786,9 @@
   // 鑾峰彇鍏ュ簱瀹℃牳鐘舵�佹爣绛剧被鍨�
   const getStockInApprovalStatusType = status => {
     const typeMap = {
-      "寰呭叆搴�": "info", // 寰呭叆搴� - 鐏拌壊
-      "鍏ュ簱涓�": "warning", // 鍏ュ簱涓� - 姗欒壊
-      "瀹屽叏鍏ュ簱": "success", // 瀹屽叏鍏ュ簱 - 缁胯壊
+      寰呭叆搴�: "info", // 寰呭叆搴� - 鐏拌壊
+      鍏ュ簱涓�: "warning", // 鍏ュ簱涓� - 姗欒壊
+      瀹屽叏鍏ュ簱: "success", // 瀹屽叏鍏ュ簱 - 缁胯壊
     };
     return typeMap[status] || "";
   };
@@ -923,7 +923,7 @@
     },
     rules: {
       purchaseContractNumber: [
-        { required: true, message: "璇疯緭鍏�", trigger: "blur" },
+        { required: false, message: "璇疯緭鍏�", trigger: "blur" },
       ],
       projectName: [
         { required: true, message: "璇疯緭鍏ラ」鐩悕绉�", trigger: "blur" },
@@ -1274,7 +1274,7 @@
   const openForm = async (type, row) => {
     // 缂栬緫鏃舵鏌ュ叆搴撶姸鎬侊紝瀹屽叏鍏ュ簱鏃朵笉鑳界紪杈�
     if (type === "edit" && row) {
-      if (row.stockInStatus === '瀹屽叏鍏ュ簱') {
+      if (row.stockInStatus === "瀹屽叏鍏ュ簱") {
         proxy.$modal.msgWarning("瀹屽叏鍏ュ簱鐘舵�佺殑璁板綍涓嶈兘缂栬緫");
         return;
       }
@@ -1306,18 +1306,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 +1314,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 +1390,7 @@
 
   // 鎻愪氦琛ㄥ崟
   const submitForm = () => {
-    proxy.$refs["formRef"].validate(valid => {
+    proxy.$refs["formRef"].validate(async valid => {
       if (valid) {
         if (productData.value.length > 0) {
           // 鏂板鏃讹紝闇�瑕佷粠姣忎釜浜у搧瀵硅薄涓垹闄� id 瀛楁
@@ -1428,6 +1420,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 +1450,7 @@
   // 鎵撳紑浜у搧寮规
   const openProductForm = async (type, row, index) => {
     // 缂栬緫鏃舵鏌ヤ骇鍝佸叆搴撳鏍哥姸鎬侊紝瀹屽叏鍏ュ簱鏃朵笉鑳界紪杈�
-    if (type === "edit" && row && row.stockInApprovalStatus === '瀹屽叏鍏ュ簱') {
+    if (type === "edit" && row && row.stockInApprovalStatus === "瀹屽叏鍏ュ簱") {
       proxy.$modal.msgWarning("瀹屽叏鍏ュ簱鐘舵�佺殑浜у搧涓嶈兘缂栬緫");
       return;
     }
@@ -1633,7 +1639,7 @@
     }
     // 妫�鏌ラ�変腑鐨勪骇鍝佷腑鏄惁鏈夊畬鍏ㄥ叆搴撶殑
     const hasFullyStocked = productSelectedRows.value.some(
-      row => row.stockInApprovalStatus === '瀹屽叏鍏ュ簱'
+      row => row.stockInApprovalStatus === "瀹屽叏鍏ュ簱"
     );
     if (hasFullyStocked) {
       proxy.$modal.msgWarning("閫変腑鐨勪骇鍝佷腑鍖呭惈瀹屽叏鍏ュ簱鐨勪骇鍝侊紝鏃犳硶鍒犻櫎");
@@ -1852,7 +1858,7 @@
       contractNo: form.value.salesLedgerId,
     });
     if (code == 200) {
-      productData.value = data;
+      productData.value = data || [];
     }
   };
 

--
Gitblit v1.9.3