From 29399d5258c1cd9b498884e065f8a2dab4403027 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期四, 23 四月 2026 11:22:03 +0800
Subject: [PATCH] 。

---
 src/api/productionPlan/productionPlan.js          |    8 +-
 src/views/productionPlan/productionPlan/index.vue |  200 ++++++++++++-------------------------------------
 2 files changed, 55 insertions(+), 153 deletions(-)

diff --git a/src/api/productionPlan/productionPlan.js b/src/api/productionPlan/productionPlan.js
index a284f21..70139e7 100644
--- a/src/api/productionPlan/productionPlan.js
+++ b/src/api/productionPlan/productionPlan.js
@@ -39,15 +39,15 @@
 // 鐢熶骇璁″垝-鏂板淇敼
 export function productionPlanAdd(query) {
   return request({
-    url: "/productionPlan",
+    url: "/productionPlan/updateProductionPlan",
     method: "post",
     data: query,
   });
 }
 export function productionPlanUpdate(query) {
   return request({
-    url: "/productionPlan",
-    method: "put",
+    url: "/productionPlan/updateProductionPlan",
+    method: "post",
     data: query,
   });
 }
@@ -63,7 +63,7 @@
 // 鍚堝苟涓嬪彂
 export function productionPlanCombine(query) {
   return request({
-    url: "/productionPlan/combine",
+    url: "/productionPlan/updateProductionPlan",
     method: "post",
     data: query,
   });
diff --git a/src/views/productionPlan/productionPlan/index.vue b/src/views/productionPlan/productionPlan/index.vue
index 53a99f5..197d05c 100644
--- a/src/views/productionPlan/productionPlan/index.vue
+++ b/src/views/productionPlan/productionPlan/index.vue
@@ -329,120 +329,17 @@
   import { getToken } from "@/utils/auth";
   import { useDict } from "@/utils/dict";
   import { useRouter } from "vue-router";
-  // import {
-  //   productionPlanListPage,
-  //   loadProdData,
-  //   exportProductionPlan,
-  //   productionPlanAdd,
-  //   productionPlanUpdate,
-  //   productionPlanDelete,
-  //   productionPlanCombine,
-  // } from "@/api/productionPlan/productionPlan.js";
+  import {
+    productionPlanListPage,
+    loadProdData,
+    exportProductionPlan,
+    productionPlanAdd,
+    productionPlanUpdate,
+    productionPlanDelete,
+    productionPlanCombine,
+  } from "@/api/productionPlan/productionPlan.js";
 
-  // Mock data and functions
-  const productionPlanListPage = params => {
-    console.log("Mock productionPlanListPage called with:", params);
-    return Promise.resolve({
-      data: {
-        records: [
-          {
-            id: 1,
-            dataSourceType: 1,
-            applyNo: "SQ20260422001",
-            customerName: "妯℃嫙瀹㈡埛A",
-            productName: "鏉挎潗",
-            model: "100*200*300",
-            materialCode: "MAT001",
-            quantity: 100,
-            volume: 50,
-            status: 0,
-            assignedQuantity: 0,
-            length: 100,
-            width: 200,
-            height: 300,
-            startDate: "2026-04-22",
-            endDate: "2026-04-25",
-            strength: "C20",
-            remarkOne: "澶囨敞1",
-            remarkTwo: "澶囨敞2",
-          },
-          {
-            id: 2,
-            dataSourceType: 2,
-            applyNo: "SQ20260422002",
-            customerName: "妯℃嫙瀹㈡埛B",
-            productName: "鐮屽潡",
-            model: "200*200*600",
-            materialCode: "MAT002",
-            quantity: 200,
-            volume: 80,
-            status: 1,
-            assignedQuantity: 30,
-            length: 200,
-            width: 200,
-            height: 600,
-            startDate: "2026-04-23",
-            endDate: "2026-04-26",
-            strength: "C25",
-            remarkOne: "澶囨敞1",
-            remarkTwo: "澶囨敞2",
-          },
-          {
-            id: 3,
-            dataSourceType: 1,
-            applyNo: "SQ20260422003",
-            customerName: "妯℃嫙瀹㈡埛C",
-            productName: "鐮屽潡",
-            model: "240*115*53",
-            materialCode: "MAT003",
-            quantity: 1000,
-            volume: 1.46,
-            status: 2,
-            assignedQuantity: 1.46,
-            length: 240,
-            width: 115,
-            height: 53,
-            startDate: "2026-04-20",
-            endDate: "2026-04-21",
-            strength: "MU10",
-            remarkOne: "宸蹭笅鍙戞暟鎹�",
-            remarkTwo: "",
-          },
-        ],
-        total: 3,
-      },
-    });
-  };
-
-  const loadProdData = () => {
-    console.log("Mock loadProdData called");
-    return Promise.resolve({ code: 200, msg: "鍚屾鎴愬姛" });
-  };
-
-  const exportProductionPlan = () => {
-    console.log("Mock exportProductionPlan called");
-    return Promise.resolve();
-  };
-
-  const productionPlanAdd = payload => {
-    console.log("Mock productionPlanAdd called with:", payload);
-    return Promise.resolve({ code: 200, msg: "鏂板鎴愬姛" });
-  };
-
-  const productionPlanUpdate = payload => {
-    console.log("Mock productionPlanUpdate called with:", payload);
-    return Promise.resolve({ code: 200, msg: "淇敼鎴愬姛" });
-  };
-
-  const productionPlanDelete = ids => {
-    console.log("Mock productionPlanDelete called with ids:", ids);
-    return Promise.resolve({ code: 200, msg: "鍒犻櫎鎴愬姛" });
-  };
-
-  const productionPlanCombine = payload => {
-    console.log("Mock productionPlanCombine called with:", payload);
-    return Promise.resolve({ code: 200, msg: "鍚堝苟涓嬪彂鎴愬姛" });
-  };
+  // Mock data and functions removed
   import PIMTable from "./components/PIMTable.vue";
   // import {
   //   modelListPage,
@@ -652,6 +549,7 @@
             // 鍗曠嫭涓嬪彂鎿嶄綔
             // 璁剧疆琛ㄥ崟鏁版嵁
             strengthError.value = "";
+            mergeForm.id = null; // Creation
             mergeForm.ids = [row.id];
             mergeForm.materialCode = row.materialCode;
             mergeForm.productName = row.productName || "";
@@ -664,6 +562,11 @@
             mergeForm.planCompleteTime = row.planCompleteTime || "";
             mergeForm.productMaterialId = row.productMaterialId || "";
             mergeForm.strength = row.strength || "";
+            mergeForm.applyNo = row.applyNo || "";
+            mergeForm.requiredDate = dayjs().format("YYYY-MM-DD HH:mm:ss");
+            mergeForm.promisedDeliveryDate = dayjs().format(
+              "YYYY-MM-DD HH:mm:ss"
+            );
             sumAssignedQuantity.value = mergeForm.totalAssignedQuantity;
             // 鎵撳紑寮圭獥
             isShowNewModal.value = true;
@@ -697,16 +600,28 @@
   const isShowNewModal = ref(false);
   // 鍚堝苟涓嬪彂琛ㄥ崟鏁版嵁
   const mergeForm = reactive({
+    id: null,
     materialCode: "",
     productName: "",
     model: "",
-    length: 0,
-    width: 0,
-    height: 0,
+    unit: "",
+    ids: [],
     totalAssignedQuantity: 0,
     planCompleteTime: "",
-    strength: "",
     productMaterialId: "",
+    strength: "",
+    mpsNo: "",
+    requiredDate: "",
+    remark: "",
+    productModelId: "",
+    qtyRequired: 0,
+    state: "",
+    issued: true,
+    source: "",
+    isAudit: "",
+    promisedDeliveryDate: "",
+    applyNo: "",
+    status: 1,
   });
 
   // 瀵煎叆鐩稿叧
@@ -1052,6 +967,7 @@
     sumAssignedQuantity.value = totalAssignedQuantity;
     console.log(totalAssignedQuantity);
     // 璁剧疆琛ㄥ崟鏁版嵁
+    mergeForm.id = null; // Creation
     mergeForm.materialCode = selectedserialNo.value;
     mergeForm.productName = productName;
     mergeForm.model = firstRow.model || "";
@@ -1063,6 +979,9 @@
     mergeForm.productMaterialId = firstRow.productMaterialId || "";
     mergeForm.strength = firstStrength;
     mergeForm.ids = selectedRows.value.map(row => row.id);
+    mergeForm.applyNo = firstRow.applyNo || "";
+    mergeForm.requiredDate = dayjs().format("YYYY-MM-DD HH:mm:ss");
+    mergeForm.promisedDeliveryDate = dayjs().format("YYYY-MM-DD HH:mm:ss");
 
     // 鎵撳紑寮圭獥
     isShowNewModal.value = true;
@@ -1100,6 +1019,7 @@
     );
     const payload = {
       ...mergeForm,
+      id: mergeForm.id || null, // Ensure id is present, null for creation
       strength: strengthItem ? strengthItem.label : mergeForm.strength,
     };
     productionPlanCombine(payload)
@@ -1281,41 +1201,23 @@
           proxy.$modal.msgError("鏂规暟涓嶈兘涓�0");
           return;
         }
-        if (form.v === "add") {
-          payload.id = null;
-        }
         const payload = { ...form };
-        if (operationType.value === "add") {
+        const isAdd = operationType.value === "add";
+        if (isAdd) {
           payload.id = null;
-          productionPlanAdd(payload)
-            .then(() => {
-              proxy.$modal.msgSuccess(
-                operationType.value === "add" ? "鏂板鎴愬姛" : "淇敼鎴愬姛"
-              );
-              dialogVisible.value = false;
-              getList();
-            })
-            .catch(() => {
-              proxy.$modal.msgError(
-                operationType.value === "add" ? "鏂板澶辫触" : "淇敼澶辫触"
-              );
-            });
         }
-        if (operationType.value === "edit") {
-          productionPlanUpdate(payload)
-            .then(() => {
-              proxy.$modal.msgSuccess(
-                operationType.value === "add" ? "鏂板鎴愬姛" : "淇敼鎴愬姛"
-              );
-              dialogVisible.value = false;
-              getList();
-            })
-            .catch(() => {
-              proxy.$modal.msgError(
-                operationType.value === "add" ? "鏂板澶辫触" : "淇敼澶辫触"
-              );
-            });
-        }
+
+        const apiCall = isAdd ? productionPlanAdd : productionPlanUpdate;
+
+        apiCall(payload)
+          .then(() => {
+            proxy.$modal.msgSuccess(isAdd ? "鏂板鎴愬姛" : "淇敼鎴愬姛");
+            dialogVisible.value = false;
+            getList();
+          })
+          .catch(() => {
+            proxy.$modal.msgError(isAdd ? "鏂板澶辫触" : "淇敼澶辫触");
+          });
       }
     });
   };

--
Gitblit v1.9.3