From 61449dbf92441b41e37c1d519e8662cca998ff6a Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期四, 02 四月 2026 11:45:08 +0800
Subject: [PATCH] fix: 添加批号

---
 src/views/procurementManagement/procurementLedger/index.vue |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/src/views/procurementManagement/procurementLedger/index.vue b/src/views/procurementManagement/procurementLedger/index.vue
index 259f837..7042d47 100644
--- a/src/views/procurementManagement/procurementLedger/index.vue
+++ b/src/views/procurementManagement/procurementLedger/index.vue
@@ -580,6 +580,14 @@
                         disabled />
             </el-form-item>
           </el-col>
+          <el-col :span="24">
+            <el-form-item label="鎵瑰彿锛�"
+                          prop="batchNo">
+              <el-input v-model="productForm.batchNo"
+                        clearable
+                        placeholder="閫夊~锛屽彲杈撳叆鎵瑰彿锛涚暀绌哄皢鑷姩鐢熸垚" />
+            </el-form-item>
+          </el-col>
         </el-row>
         <el-row :gutter="30">
           <el-col :span="12">
@@ -966,6 +974,7 @@
       productModelId: "",
       specificationModel: "",
       materialCode: "",
+      batchNo: "",
       unit: "",
       quantity: "",
       taxInclusiveUnitPrice: "",
@@ -1636,10 +1645,28 @@
       return newItem;
     });
   }
+
+  /** 涓庡簱瀛樻柊澧炰竴鑷达細鏈~鎵瑰彿鏃跺墠绔敓鎴愶紙PH + 鏃堕棿鎴� + 闅忔満鏁帮級 */
+  const generateProductBatchNo = () => {
+    const d = new Date();
+    const pad = (n) => String(n).padStart(2, "0");
+    const ts = `${d.getFullYear()}${pad(d.getMonth() + 1)}${pad(d.getDate())}${pad(d.getHours())}${pad(d.getMinutes())}${pad(d.getSeconds())}`;
+    const r = Math.floor(Math.random() * 10000)
+      .toString()
+      .padStart(4, "0");
+    return `PH${ts}${r}`;
+  };
+
+  const ensureProductBatchNo = () => {
+    const v = (productForm.value.batchNo ?? "").toString().trim();
+    productForm.value.batchNo = v || generateProductBatchNo();
+  };
+
   // 鎻愪氦浜у搧琛ㄥ崟
   const submitProduct = () => {
     proxy.$refs["productFormRef"].validate(valid => {
       if (valid) {
+        ensureProductBatchNo();
         if (operationType.value === "edit") {
           submitProductEdit();
         } else {

--
Gitblit v1.9.3