From 13d28048c9dc91bd0cb290252cad5b76a31b13cb Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期四, 23 四月 2026 14:41:52 +0800
Subject: [PATCH] 暂存生产计划

---
 src/api/productionPlan/productionPlan.js          |    8 
 src/views/productionPlan/productionPlan/index.vue |  622 ++++++++++++++++----------------------------------------
 2 files changed, 182 insertions(+), 448 deletions(-)

diff --git a/src/api/productionPlan/productionPlan.js b/src/api/productionPlan/productionPlan.js
index 70139e7..5bcff27 100644
--- a/src/api/productionPlan/productionPlan.js
+++ b/src/api/productionPlan/productionPlan.js
@@ -39,7 +39,7 @@
 // 鐢熶骇璁″垝-鏂板淇敼
 export function productionPlanAdd(query) {
   return request({
-    url: "/productionPlan/updateProductionPlan",
+    url: "/productionPlan/addProductionPlan",
     method: "post",
     data: query,
   });
@@ -47,7 +47,7 @@
 export function productionPlanUpdate(query) {
   return request({
     url: "/productionPlan/updateProductionPlan",
-    method: "post",
+    method: "put",
     data: query,
   });
 }
@@ -55,7 +55,7 @@
 // 鐢熶骇璁″垝-鍒犻櫎
 export function productionPlanDelete(data) {
   return request({
-    url: "/productionPlan",
+    url: "/productionPlan/deleteProductionPlan",
     method: "delete",
     data,
   });
@@ -63,7 +63,7 @@
 // 鍚堝苟涓嬪彂
 export function productionPlanCombine(query) {
   return request({
-    url: "/productionPlan/updateProductionPlan",
+    url: "/productionPlan/combine",
     method: "post",
     data: query,
   });
diff --git a/src/views/productionPlan/productionPlan/index.vue b/src/views/productionPlan/productionPlan/index.vue
index 197d05c..182a351 100644
--- a/src/views/productionPlan/productionPlan/index.vue
+++ b/src/views/productionPlan/productionPlan/index.vue
@@ -4,14 +4,14 @@
       <el-form :model="searchForm"
                :inline="true">
         <!-- 绠�鍖栫増鎼滅储鏉′欢 -->
-        <el-form-item label="浜у搧鍚嶇О:">
-          <el-input v-model="searchForm.productName"
+        <el-form-item label="涓荤敓浜ц鍒掑彿:">
+          <el-input v-model="searchForm.mpsNo"
                     placeholder="璇疯緭鍏�"
                     clearable
                     style="width: 160px;"
                     @keyup.enter="handleQuery" />
         </el-form-item>
-        <el-form-item label="璁″垝鏃ユ湡鑼冨洿:">
+        <el-form-item label="闇�姹傛棩鏈熻寖鍥�:">
           <el-date-picker v-model="searchForm.dateRange"
                           type="daterange"
                           range-separator="鑷�"
@@ -37,8 +37,8 @@
         </el-form-item>
         <!-- 灞曞紑鐗堟悳绱㈡潯浠� -->
         <template v-if="searchFormExpanded">
-          <el-form-item label="瀹㈡埛鍚嶇О:">
-            <el-input v-model="searchForm.customerName"
+          <el-form-item label="浜у搧鍚嶇О:">
+            <el-input v-model="searchForm.productName"
                       placeholder="璇疯緭鍏�"
                       clearable
                       style="width: 160px;"
@@ -74,11 +74,6 @@
           <el-button type="primary"
                      @click="handleAdd">鏂板</el-button>
           <el-button type="warning"
-                     @click="getLoadProdData"
-                     :loading="loadProdDataLoading">鎷夊彇鏁版嵁</el-button>
-          <el-button type="warning"
-                     @click="handleMerge">鍚堝苟涓嬪彂</el-button>
-          <el-button type="warning"
                      @click="handleImport">瀵煎叆</el-button>
           <el-button type="warning"
                      @click="handleExport">瀵煎嚭</el-button>
@@ -108,11 +103,8 @@
                 :selectable="isSelectable"
                 @selection-change="handleSelectionChange"
                 @pagination="pagination">
-        <template #quantity="{ row }">
-          {{ row.quantity || '-' }}<span style="color:rgb(63, 95, 211)"> 鍧�</span>
-        </template>
-        <template #volume="{ row }">
-          {{ row.volume || '-' }}<span style="color:rgba(12, 46, 40, 0.76)"> 鏂�</span>
+        <template #qtyRequired="{ row }">
+          {{ row.qtyRequired || '-' }}<span style="color:rgba(12, 46, 40, 0.76)"> {{ row.unit || '鏂�' }}</span>
         </template>
       </PIMTable>
     </div>
@@ -142,9 +134,6 @@
             </el-form-item>
           </el-col>
           <el-col :span="10">
-            <el-form-item label="闀�*瀹�*楂�">
-              <div class="info-display">{{ mergeForm.length || '-' }}*{{ mergeForm.width || '-' }}*{{ mergeForm.height || '-' }}</div>
-            </el-form-item>
           </el-col>
         </el-row>
         <el-form-item label="璁″垝瀹屾垚鏃堕棿">
@@ -153,21 +142,6 @@
                           value-format="YYYY-MM-DD"
                           style="width: 100%" />
         </el-form-item>
-        <el-form-item label="寮哄害"
-                      v-if="mergeForm.productName === '鐮屽潡'">
-          <div v-if="strengthError"
-               class="strength-error"
-               style="color: red; margin-bottom: 8px;">{{ strengthError }}</div>
-          <el-select v-model="mergeForm.strength"
-                     placeholder="璇烽�夋嫨寮哄害"
-                     style="width: 100%"
-                     required>
-            <el-option v-for="item in block_strength"
-                       :key="item.id"
-                       :label="item.label"
-                       :value="item.id" />
-          </el-select>
-        </el-form-item>
         <el-form-item label="鐢熶骇鏂规暟">
           <el-input-number v-model="mergeForm.totalAssignedQuantity"
                            :min="0"
@@ -175,10 +149,6 @@
                            @change="onBlur"
                            style="width: 100%" />
         </el-form-item>
-        <!-- <el-form-item label="澶囨敞">
-          <el-input v-model="mergeForm.remark"
-                    type="textarea" />
-        </el-form-item> -->
       </el-form>
       <template #footer>
         <span class="dialog-footer">
@@ -209,15 +179,15 @@
                :model="form"
                :rules="rules"
                label-width="120px">
+        <el-form-item label="涓荤敓浜ц鍒掑彿"
+                      prop="mpsNo">
+          <el-input v-model="form.mpsNo"
+                    placeholder="璇疯緭鍏ヤ富鐢熶骇璁″垝鍙�" />
+        </el-form-item>
         <el-form-item label="鐢宠鍗曠紪鍙�"
                       prop="applyNo">
           <el-input v-model="form.applyNo"
                     placeholder="璇疯緭鍏ョ敵璇峰崟缂栧彿" />
-        </el-form-item>
-        <el-form-item label="瀹㈡埛鍚嶇О"
-                      prop="customerName">
-          <el-input v-model="form.customerName"
-                    placeholder="璇疯緭鍏ュ鎴峰悕绉�" />
         </el-form-item>
         <el-form-item label="浜у搧鍚嶇О"
                       prop="productMaterialId">
@@ -231,10 +201,11 @@
                           style="width: 100%" />
         </el-form-item>
         <el-form-item label="浜у搧瑙勬牸"
-                      prop="productMaterialSkuId">
-          <el-select v-model="form.productMaterialSkuId"
+                      prop="productModelId">
+          <el-select v-model="form.productModelId"
                      @change="handleChangeSpecification"
                      filterable
+                     style="width: 100%"
                      placeholder="璇烽�夋嫨">
             <el-option v-for="item in specificationOptions"
                        :key="item.id"
@@ -242,71 +213,39 @@
                        :value="item.id" />
           </el-select>
         </el-form-item>
-        <el-form-item label="鍧楁暟"
-                      prop="quantity">
-          <el-input-number v-model="form.quantity"
+        <el-form-item label="鎵�闇�鏁伴噺"
+                      prop="qtyRequired">
+          <el-input-number v-model="form.qtyRequired"
                            :min="0"
-                           placeholder="璇疯緭鍏ュ潡鏁�" />
+                           style="width: 100%"
+                           placeholder="璇疯緭鍏ユ暟閲�" />
         </el-form-item>
-        <el-form-item label="鏂规暟"
-                      prop="volume">
-          <el-input-number v-model="form.volume"
-                           :min="0"
-                           placeholder="璇疯緭鍏ユ柟鏁�" />
+        <el-form-item label="鍗曚綅"
+                      prop="unit">
+          <el-input v-model="form.unit"
+                    placeholder="璇疯緭鍏ュ崟浣�" />
         </el-form-item>
-        <el-form-item label="闀�"
-                      prop="length">
-          <el-input-number v-model="form.length"
-                           :min="0"
-                           placeholder="璇疯緭鍏ラ暱搴�" />
-        </el-form-item>
-        <el-form-item label="瀹�"
-                      prop="width">
-          <el-input-number v-model="form.width"
-                           :min="0"
-                           placeholder="璇疯緭鍏ュ搴�" />
-        </el-form-item>
-        <el-form-item label="楂�"
-                      prop="height">
-          <el-input-number v-model="form.height"
-                           :min="0"
-                           placeholder="璇疯緭鍏ラ珮搴�" />
-        </el-form-item>
-        <el-form-item label="璁″垝寮�濮嬫棩鏈�"
-                      prop="startDate">
-          <el-date-picker v-model="form.startDate"
+        <el-form-item label="闇�姹傛棩鏈�"
+                      prop="requiredDate">
+          <el-date-picker v-model="form.requiredDate"
                           type="date"
                           value-format="YYYY-MM-DD"
-                          placeholder="璇烽�夋嫨璁″垝寮�濮嬫棩鏈�" />
+                          style="width: 100%"
+                          placeholder="璇烽�夋嫨闇�姹傛棩鏈�" />
         </el-form-item>
-        <el-form-item label="璁″垝缁撴潫鏃ユ湡"
-                      prop="endDate">
-          <el-date-picker v-model="form.endDate"
+        <el-form-item label="鎵胯鏃ユ湡"
+                      prop="promisedDeliveryDate">
+          <el-date-picker v-model="form.promisedDeliveryDate"
                           type="date"
                           value-format="YYYY-MM-DD"
-                          placeholder="璇烽�夋嫨璁″垝缁撴潫鏃ユ湡" />
+                          style="width: 100%"
+                          placeholder="璇烽�夋嫨鎵胯鏃ユ湡" />
         </el-form-item>
-        <el-form-item label="寮哄害"
-                      prop="strength"
-                      v-if="form.productName === '鐮屽潡'">
-          <el-select v-model="form.strength"
-                     placeholder="璇烽�夋嫨寮哄害"
-                     style="width: 100%">
-            <el-option v-for="item in block_strength"
-                       :key="item.label"
-                       :label="item.label"
-                       :value="item.label" />
-          </el-select>
-        </el-form-item>
-        <el-form-item label="澶囨敞 1"
-                      prop="remarkOne">
-          <el-input v-model="form.remarkOne"
-                    placeholder="璇疯緭鍏ュ娉� 1" />
-        </el-form-item>
-        <el-form-item label="澶囨敞 2"
-                      prop="remarkTwo">
-          <el-input v-model="form.remarkTwo"
-                    placeholder="璇疯緭鍏ュ娉� 2" />
+        <el-form-item label="澶囨敞"
+                      prop="remark">
+          <el-input v-model="form.remark"
+                    type="textarea"
+                    placeholder="璇疯緭鍏ュ娉�" />
         </el-form-item>
       </el-form>
       <template #footer>
@@ -321,49 +260,53 @@
 </template>
 
 <script setup>
-  import { onMounted, ref, reactive, getCurrentInstance, toRefs } from "vue";
+  import {
+    reactive,
+    ref,
+    onMounted,
+    toRefs,
+    getCurrentInstance,
+    computed,
+  } from "vue";
+  import { useRouter } from "vue-router";
+  import dayjs from "dayjs";
   import { ElMessage } from "element-plus";
   import { ArrowUp, ArrowDown } from "@element-plus/icons-vue";
-  import dayjs from "dayjs";
-  import ImportDialog from "@/components/Dialog/ImportDialog.vue";
   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";
-
-  // Mock data and functions removed
+  import { productTreeList, modelListPage } from "@/api/basicData/product.js";
   import PIMTable from "./components/PIMTable.vue";
-  // import {
-  //   modelListPage,
-  //   productTreeList,
-  //   productTreeListQuery,
-  // } from "@/api/basicData/newProduct.js";
+  import ImportDialog from "@/components/Dialog/ImportDialog.vue";
 
   const { proxy } = getCurrentInstance();
   const router = useRouter();
 
+  const loadProdData = () => {
+    console.log("Mock loadProdData called");
+    return Promise.resolve({ code: 200, msg: "鍚屾鎴愬姛" });
+  };
+
+  const exportProductionPlan = () => {
+    console.log("Mock exportProductionPlan called");
+    return Promise.resolve();
+  };
+
+  const productionPlanCombine = payload => {
+    console.log("Mock productionPlanCombine called with:", payload);
+    return Promise.resolve({ code: 200, msg: "鍚堝苟涓嬪彂鎴愬姛" });
+  };
+
   const tableColumn = ref([
     {
-      label: "鏁版嵁鏉ユ簮",
-      width: "100px",
-      prop: "dataSourceType",
-      dataType: "tag",
-      formatType: params => {
-        const typeMap = {
-          2: "warning",
-          1: "primary",
-        };
-        return typeMap[params] || "info";
-      },
-      formatData: cell => (cell == 1 ? "閽夐拤鍚屾" : "鎵嬪姩鏂板"),
+      label: "涓荤敓浜ц鍒掑彿",
+      prop: "mpsNo",
+      width: "150px",
     },
     {
       label: "鐢宠鍗曠紪鍙�",
@@ -371,8 +314,8 @@
       width: "150px",
     },
     {
-      label: "瀹㈡埛鍚嶇О",
-      prop: "customerName",
+      label: "鐗╂枡缂栫爜",
+      prop: "materialCode",
       width: "150px",
     },
     {
@@ -381,11 +324,6 @@
       width: "200px",
       dataType: "tag",
       formatType: params => {
-        // const typeMap = {
-        //   鏉挎潗: "primary",
-        //   鐮屽潡: "warning",
-        // };
-        // return typeMap[params] || "info";
         return "primary";
       },
     },
@@ -396,30 +334,23 @@
       className: "spec-cell",
     },
     {
-      label: "鐗╂枡缂栫爜",
-      prop: "materialCode",
-      width: "150px",
+      label: "鍗曚綅",
+      prop: "unit",
+      width: "100px",
     },
     {
-      label: "鍧楁暟",
-      prop: "quantity",
-      align: "right",
-      dataType: "slot",
-      slot: "quantity",
-    },
-    {
-      label: "鏂规暟",
-      prop: "volume",
+      label: "鎵�闇�鏁伴噺",
+      prop: "qtyRequired",
       width: "150px",
       align: "right",
       dataType: "slot",
-      slot: "volume",
+      slot: "qtyRequired",
       className: "volume-cell",
     },
     {
       label: "涓嬪彂鐘舵��",
       prop: "status",
-      width: "150px",
+      width: "120px",
       className: "status-cell",
       dataType: "tag",
       formatType: params => {
@@ -440,85 +371,44 @@
       },
     },
     {
-      label: "宸蹭笅鍙戞柟鏁�",
+      label: "宸蹭笅鍙戞暟閲�",
       prop: "assignedQuantity",
-      width: "150px",
+      width: "120px",
       className: "spec-cell",
-      formatData: cell => (cell ? `${cell}鏂筦 : 0),
+      // formatData: (cell, row) => (cell ? `${cell}${row.unit || "鏂�"}` : 0),
     },
     {
-      label: "闀�",
-      prop: "length",
-      className: "dimension-cell",
-      formatData: cell => (cell ? `${cell}mm` : ""),
-    },
-    {
-      label: "瀹�",
-      prop: "width",
-      className: "dimension-cell",
-      formatData: cell => (cell ? `${cell}mm` : ""),
-    },
-    {
-      label: "楂�",
-      prop: "height",
-      className: "dimension-cell",
-      formatData: cell => (cell ? `${cell}mm` : ""),
-    },
-    // {
-    //   label: "娴佹按鍙�",
-    //   prop: "serialNo",
-    //   width: "150px",
-    //   className: "code-cell",
-    // },
-    {
-      label: "璁″垝寮�濮嬫棩鏈�",
-      prop: "startDate",
-      width: "150px",
+      label: "闇�姹傛棩鏈�",
+      prop: "requiredDate",
+      width: "160px",
       className: "date-cell",
       formatData: cell => (cell ? dayjs(cell).format("YYYY-MM-DD") : ""),
     },
     {
-      label: "璁″垝缁撴潫鏃ユ湡",
-      prop: "endDate",
-      width: "150px",
+      label: "鎵胯鏃ユ湡",
+      prop: "promisedDeliveryDate",
+      width: "160px",
       className: "date-cell",
       formatData: cell => (cell ? dayjs(cell).format("YYYY-MM-DD") : ""),
     },
     {
-      label: "寮哄害",
-      prop: "strength",
-      formatData: cell => {
-        if (!cell) return "";
-        const strengthItem = block_strength.value.find(item => item.id === cell);
-        return strengthItem ? strengthItem.label : cell;
-      },
-    },
-
-    {
-      label: "澶囨敞 1",
+      label: "澶囨敞",
       width: "150px",
-      prop: "remarkOne",
+      prop: "remark",
     },
-    {
-      label: "澶囨敞 2",
-      width: "150px",
-      prop: "remarkTwo",
-    },
-
     {
       dataType: "action",
       label: "鎿嶄綔",
       align: "center",
       fixed: "right",
-      width: 300,
+      width: 150,
       operation: [
         {
           name: "缂栬緫",
           type: "primary",
           link: true,
           showHide: row => {
-            return row.status == 0 && row.dataSourceType != 1;
-            //status锛�0锛氬緟涓嬪彂锛�1锛氶儴鍒嗕笅鍙戯紝2锛氬凡涓嬪彂
+            return row.status == 0;
           },
           clickFun: row => {
             handleEdit(row);
@@ -535,50 +425,6 @@
             handleDelete(row);
           },
         },
-        {
-          name: "涓嬪彂",
-          type: "text",
-          showHide: row => {
-            // 璁$畻鍓╀綑鏂规暟
-            const remainingVolume =
-              (row.volume || 0) - (row.assignedQuantity || 0);
-            // 濡傛灉鍓╀綑鏂规暟灏忎簬绛変簬0锛岀姝㈤�夋嫨
-            return remainingVolume > 0;
-          },
-          clickFun: row => {
-            // 鍗曠嫭涓嬪彂鎿嶄綔
-            // 璁剧疆琛ㄥ崟鏁版嵁
-            strengthError.value = "";
-            mergeForm.id = null; // Creation
-            mergeForm.ids = [row.id];
-            mergeForm.materialCode = row.materialCode;
-            mergeForm.productName = row.productName || "";
-            mergeForm.model = row.model || "";
-            mergeForm.length = row.length || 0;
-            mergeForm.width = row.width || 0;
-            mergeForm.height = row.height || 0;
-            mergeForm.totalAssignedQuantity =
-              (Number(row.volume) - Number(row.assignedQuantity)).toFixed(4) || 0;
-            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;
-          },
-        },
-        // {
-        //   name: "杩借釜杩涘害",
-        //   type: "text",
-        //   clickFun: row => {
-        //     handleTrackProgress(row);
-        //   },
-        // },
       ],
     },
   ]);
@@ -600,28 +446,12 @@
   const isShowNewModal = ref(false);
   // 鍚堝苟涓嬪彂琛ㄥ崟鏁版嵁
   const mergeForm = reactive({
-    id: null,
     materialCode: "",
     productName: "",
     model: "",
-    unit: "",
-    ids: [],
     totalAssignedQuantity: 0,
     planCompleteTime: "",
     productMaterialId: "",
-    strength: "",
-    mpsNo: "",
-    requiredDate: "",
-    remark: "",
-    productModelId: "",
-    qtyRequired: 0,
-    state: "",
-    issued: true,
-    source: "",
-    isAudit: "",
-    promisedDeliveryDate: "",
-    applyNo: "",
-    status: 1,
   });
 
   // 瀵煎叆鐩稿叧
@@ -639,53 +469,33 @@
   const productOptions = ref([]);
   const specificationOptions = ref([]);
   const formRef = ref(null);
-  // 鑾峰彇寮哄害瀛楀吀
-  const { block_strength } = useDict("block_strength");
   const form = reactive({
     id: undefined,
+    mpsNo: "",
     applyNo: "",
-    customerName: "",
     productMaterialId: undefined,
-    productMaterialSkuId: undefined,
+    productModelId: undefined,
     productName: "",
     model: "",
     materialCode: "",
-    quantity: 0,
-    volume: 0,
-    length: 0,
-    width: 0,
-    height: 0,
-    startDate: "",
-    endDate: "",
-    status: "",
-    strength: "",
-    remarkOne: "",
-    remarkTwo: "",
+    qtyRequired: 0,
+    unit: "鏂�",
+    requiredDate: "",
+    promisedDeliveryDate: "",
+    remark: "",
   });
   const rules = reactive({
+    mpsNo: [{ required: true, message: "璇疯緭鍏ヤ富鐢熶骇璁″垝鍙�", trigger: "blur" }],
     applyNo: [{ required: true, message: "璇疯緭鍏ョ敵璇峰崟缂栧彿", trigger: "blur" }],
-    customerName: [
-      { required: true, message: "璇疯緭鍏ュ鎴峰悕绉�", trigger: "blur" },
-    ],
-    productMaterialSkuId: [
-      { required: true, message: "璇烽�夋嫨浜у搧瑙勬牸", trigger: "change" },
-    ],
-    volume: [{ required: true, message: "璇疯緭鍏ユ柟鏁�", trigger: "blur" }],
     productMaterialId: [
       { required: true, message: "璇烽�夋嫨浜у搧", trigger: "change" },
     ],
-    strength: [
-      {
-        validator: (rule, value, callback) => {
-          if (form.productName === "鐮屽潡" && !value) {
-            callback(new Error("鐮屽潡浜у搧鐨勫己搴︿负蹇呭~椤�"));
-          } else {
-            callback();
-          }
-        },
-        trigger: ["blur", "change"],
-        required: false,
-      },
+    productModelId: [
+      { required: true, message: "璇烽�夋嫨浜у搧瑙勬牸", trigger: "change" },
+    ],
+    qtyRequired: [{ required: true, message: "璇疯緭鍏ユ暟閲�", trigger: "blur" }],
+    requiredDate: [
+      { required: true, message: "璇烽�夋嫨闇�姹傛棩鏈�", trigger: "change" },
     ],
   });
 
@@ -708,40 +518,36 @@
   };
 
   const fetchProductOptions = () => {
-    // return productTreeList({ type: 2 }).then(res => {
-    //   productOptions.value = convertIdToValue(res.data);
-    //   return res;
-    // });
+    return productTreeList().then(res => {
+      productOptions.value = convertIdToValue(res || []);
+    });
   };
 
   const convertIdToValue = data => {
     return data.map(item => {
       const newItem = {
-        value: `config_${item.configId}`, // 浣跨敤config_鍓嶇紑纭繚鍞竴鎬�
-        label: item.configName,
-        disabled: item.materialList.length === 0,
+        value: item.id,
+        label: item.label,
       };
-      if (item.materialList && item.materialList.length > 0) {
-        newItem.children = item.materialList.map(material => ({
-          value: material.id, // 浣跨敤material鐨刬d浣滀负value
-          label: material.productName, // 浣跨敤materialName浣滀负label
-        }));
+      if (item.children && item.children.length > 0) {
+        newItem.children = convertIdToValue(item.children);
       }
-
       return newItem;
     });
   };
 
   const handleProductChange = value => {
-    form.productMaterialSkuId = undefined;
+    form.productModelId = undefined;
+    form.model = undefined;
+    form.materialCode = undefined;
     // 鏌ユ壘閫変腑鐨勪骇鍝佸悕绉�
-    const findProductName = (options, value) => {
+    const findProductName = (options, val) => {
       for (const option of options) {
-        if (option.value === value) {
+        if (option.value === val) {
           return option.label;
         }
         if (option.children) {
-          const found = findProductName(option.children, value);
+          const found = findProductName(option.children, val);
           if (found) {
             return found;
           }
@@ -750,45 +556,35 @@
       return "";
     };
     form.productName = findProductName(productOptions.value, value);
-    // 瑙﹀彂寮哄害瀛楁楠岃瘉
-    if (formRef.value) {
-      formRef.value.validateField("strength");
-    }
     fetchSpecificationOptions(value);
   };
 
   const fetchSpecificationOptions = productId => {
     specificationOptions.value = [];
     if (productId) {
-      // modelListPage({ productId: productId, size: -1, current: -1 }).then(res => {
-      //   specificationOptions.value = res.data.records;
-      // });
+      modelListPage({ id: productId, size: 1000, current: 1 }).then(res => {
+        specificationOptions.value = res.records || [];
+      });
     }
   };
 
   const handleChangeSpecification = value => {
     form.materialCode = undefined;
+    form.model = undefined;
+    form.unit = "";
     const selectedModel = specificationOptions.value.find(
       item => item.id === value
     );
     if (selectedModel) {
       form.materialCode = selectedModel.materialCode;
-      // 瑙f瀽瑙勬牸瀛楃涓茶幏鍙栭暱瀹介珮
-      const model = selectedModel.model;
-      if (model) {
-        const dimensions = model.match(/^(\d+)\*(\d+)\*(\d+)$/);
-        if (dimensions && dimensions.length === 4) {
-          form.length = parseInt(dimensions[1]);
-          form.width = parseInt(dimensions[2]);
-          form.height = parseInt(dimensions[3]);
-        }
-      }
+      form.model = selectedModel.model;
+      form.unit = selectedModel.unit || "鏂�";
     }
   };
 
   const data = reactive({
     searchForm: {
-      customerName: "",
+      mpsNo: "",
       productName: "",
       model: "",
       materialCode: "",
@@ -814,7 +610,7 @@
   /** 閲嶇疆鎸夐挳鎿嶄綔 */
   const handleReset = () => {
     Object.assign(searchForm.value, {
-      customerName: "",
+      mpsNo: "",
       productName: "",
       model: "",
       materialCode: "",
@@ -843,7 +639,7 @@
         };
       }
       summary[category].totalAssignedQuantity += (
-        Number(row.volume) - Number(row.assignedQuantity)
+        Number(row.qtyRequired) - Number(row.assignedQuantity)
       ).toFixed(4);
     });
 
@@ -855,13 +651,12 @@
     tableLoading.value = true;
     // 鏋勯�犳悳绱㈠弬鏁�
     const params = { ...searchForm.value, ...page };
-    params.startDate = params.dateRange ? params.dateRange[0] : "";
-    params.endDate = params.dateRange ? params.dateRange[1] : "";
+    params.requiredDateStart = params.dateRange ? params.dateRange[0] : "";
+    params.requiredDateEnd = params.dateRange ? params.dateRange[1] : "";
     delete params.dateRange;
     productionPlanListPage(params)
       .then(res => {
         tableLoading.value = false;
-
         tableData.value = res.data.records;
         page.total = res.data.total;
         // 璁$畻浜у搧绫诲埆姹囨�荤粺璁�
@@ -889,10 +684,10 @@
 
   // 鍒ゆ柇琛屾槸鍚﹀彲閫夋嫨
   const isSelectable = row => {
-    // 璁$畻鍓╀綑鏂规暟
-    const remainingVolume = (row.volume || 0) - (row.assignedQuantity || 0);
-    // 濡傛灉鍓╀綑鏂规暟灏忎簬绛変簬0锛岀姝㈤�夋嫨
-    if (remainingVolume <= 0) {
+    // 璁$畻鍓╀綑鏁伴噺
+    const remainingQty = (row.qtyRequired || 0) - (row.assignedQuantity || 0);
+    // 濡傛灉鍓╀綑鏁伴噺灏忎簬绛変簬0锛岀姝㈤�夋嫨
+    if (remainingQty <= 0) {
       return false;
     }
     // 濡傛灉娌℃湁閫変腑鐨勮锛屾墍鏈夎閮藉彲閫夋嫨
@@ -904,29 +699,7 @@
   };
   // 鎷夊彇鏁版嵁鎸夐挳鎿嶄綔
   const loadProdDataLoading = ref(false);
-  const getLoadProdData = () => {
-    // 鏄剧ず鍔犺浇鎻愮ず
-    loadProdDataLoading.value = true;
-    proxy.$modal.loading("姝e湪鎷夊彇鏁版嵁锛岃绋嶅��...");
-
-    loadProdData()
-      .then(res => {
-        proxy.$modal.closeLoading();
-        getList();
-        proxy.$modal.msgSuccess("鏁版嵁鎷夊彇鎴愬姛");
-      })
-      .catch(err => {
-        proxy.$modal.closeLoading();
-        console.error("鎷夊彇澶辫触:", err);
-        proxy.$modal.msgError("鏁版嵁鎷夊彇澶辫触锛岃閲嶈瘯");
-      })
-      .finally(() => {
-        loadProdDataLoading.value = false;
-      });
-  };
   const sumAssignedQuantity = ref(0);
-  // 鍝嶅簲寮忔暟鎹�
-  const strengthError = ref("");
 
   // 澶勭悊鍚堝苟涓嬪彂鎸夐挳鐐瑰嚮
   const handleMerge = () => {
@@ -935,53 +708,30 @@
       return;
     }
     console.log(selectedRows.value);
-    // 妫�鏌ュ己搴︿竴鑷存��
     const firstRow = selectedRows.value[0];
     const productName = firstRow.productName || "";
-    let strengthConsistent = true;
-    let firstStrength = firstRow.strength || "";
-    strengthError.value = "";
-
-    if (productName === "鐮屽潡") {
-      for (const row of selectedRows.value) {
-        if (row.strength !== firstStrength) {
-          strengthConsistent = false;
-          break;
-        }
-      }
-
-      if (!strengthConsistent) {
-        strengthError.value = "閫夋嫨鐨勭爩鍧楀己搴︿笉涓�鑷达紝璇烽噸鏂伴�夋嫨";
-      }
-    }
 
     // 璁$畻鎬诲埗閫犳暟閲�
     const totalAssignedQuantity = selectedRows.value.reduce((sum, row) => {
       return (
         sum +
-        (row.volume == null
+        (row.qtyRequired == null
           ? 0
-          : Number(Number(row.volume) - Number(row.assignedQuantity).toFixed(4)))
+          : Number(
+              Number(row.qtyRequired) - Number(row.assignedQuantity).toFixed(4)
+            ))
       );
     }, 0);
     sumAssignedQuantity.value = totalAssignedQuantity;
     console.log(totalAssignedQuantity);
     // 璁剧疆琛ㄥ崟鏁版嵁
-    mergeForm.id = null; // Creation
     mergeForm.materialCode = selectedserialNo.value;
     mergeForm.productName = productName;
     mergeForm.model = firstRow.model || "";
-    mergeForm.length = firstRow.length || 0;
-    mergeForm.width = firstRow.width || 0;
-    mergeForm.height = firstRow.height || 0;
     mergeForm.totalAssignedQuantity = totalAssignedQuantity;
     mergeForm.planCompleteTime = firstRow.planCompleteTime || "";
     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;
@@ -993,18 +743,10 @@
       ElMessage.warning("璇疯緭鍏ョ敓浜ф柟鏁�");
       return;
     }
-    // 楠岃瘉鐮屽潡浜у搧鐨勫己搴�
-    if (mergeForm.productName === "鐮屽潡" && !mergeForm.strength) {
-      ElMessage.error("鐮屽潡浜у搧鐨勫己搴︿负蹇呭~椤�");
-      return;
-    }
-    if (mergeForm.productName != "鐮屽潡") {
-      mergeForm.strength = "";
-    }
     console.log(sumAssignedQuantity.value, "sumAssignedQuantity");
-    // 璁$畻褰撳墠閫変腑琛岀殑鎬绘柟鏁�
+    // 璁$畻褰撳墠閫変腑琛岀殑鎬绘暟閲�
     const totalVolume = selectedRows.value.reduce((sum, row) => {
-      return sum + (Number(row.volume) - Number(row.assignedQuantity) || 0);
+      return sum + (Number(row.qtyRequired) - Number(row.assignedQuantity) || 0);
     }, 0);
 
     // 楠岃瘉totalAssignedQuantity涓嶈兘澶т簬鎬绘柟鏁�
@@ -1014,13 +756,8 @@
     }
 
     console.log(mergeForm, "mergeForm");
-    const strengthItem = block_strength.value.find(
-      item => item.id === mergeForm.strength
-    );
     const payload = {
       ...mergeForm,
-      id: mergeForm.id || null, // Ensure id is present, null for creation
-      strength: strengthItem ? strengthItem.label : mergeForm.strength,
     };
     productionPlanCombine(payload)
       .then(res => {
@@ -1122,23 +859,19 @@
   const handleAdd = () => {
     operationType.value = "add";
     Object.assign(form, {
+      id: undefined,
+      mpsNo: "",
       applyNo: "",
-      customerName: "",
       productName: "",
       productMaterialId: undefined,
-      productMaterialSkuId: undefined,
+      productModelId: undefined,
       model: "",
       materialCode: "",
-      quantity: 0,
-      volume: 0,
-      length: 0,
-      width: 0,
-      height: 0,
-      startDate: "",
-      endDate: "",
-      strength: "",
-      remarkOne: "",
-      remarkTwo: "",
+      qtyRequired: 0,
+      unit: "鏂�",
+      requiredDate: "",
+      promisedDeliveryDate: "",
+      remark: "",
     });
     dialogVisible.value = true;
     fetchProductOptions();
@@ -1149,23 +882,18 @@
     operationType.value = "edit";
     Object.assign(form, {
       id: row.id,
+      mpsNo: row.mpsNo || "",
       applyNo: row.applyNo || "",
-      customerName: row.customerName || "",
       productName: row.productName || "",
       productMaterialId: row.productMaterialId || undefined,
-      productMaterialSkuId: row.productMaterialSkuId || undefined,
+      productModelId: row.productModelId || undefined,
       model: row.model || "",
       materialCode: row.materialCode || "",
-      quantity: row.quantity || 0,
-      volume: row.volume || 0,
-      length: row.length || 0,
-      width: row.width || 0,
-      height: row.height || 0,
-      startDate: row.startDate || "",
-      endDate: row.endDate || "",
-      strength: row.strength || "",
-      remarkOne: row.remarkOne || "",
-      remarkTwo: row.remarkTwo || "",
+      qtyRequired: row.qtyRequired || 0,
+      unit: row.unit || "鏂�",
+      requiredDate: row.requiredDate || "",
+      promisedDeliveryDate: row.promisedDeliveryDate || "",
+      remark: row.remark || "",
     });
     dialogVisible.value = true;
     fetchProductOptions();
@@ -1197,27 +925,34 @@
   const handleSubmit = () => {
     formRef.value.validate(valid => {
       if (valid) {
-        if (form.volume === 0) {
-          proxy.$modal.msgError("鏂规暟涓嶈兘涓�0");
+        if (form.qtyRequired === 0) {
+          proxy.$modal.msgError("鏁伴噺涓嶈兘涓�0");
           return;
         }
         const payload = { ...form };
-        const isAdd = operationType.value === "add";
-        if (isAdd) {
+        if (operationType.value === "add") {
           payload.id = null;
+          productionPlanAdd(payload)
+            .then(() => {
+              proxy.$modal.msgSuccess("鏂板鎴愬姛");
+              dialogVisible.value = false;
+              getList();
+            })
+            .catch(() => {
+              proxy.$modal.msgError("鏂板澶辫触");
+            });
         }
-
-        const apiCall = isAdd ? productionPlanAdd : productionPlanUpdate;
-
-        apiCall(payload)
-          .then(() => {
-            proxy.$modal.msgSuccess(isAdd ? "鏂板鎴愬姛" : "淇敼鎴愬姛");
-            dialogVisible.value = false;
-            getList();
-          })
-          .catch(() => {
-            proxy.$modal.msgError(isAdd ? "鏂板澶辫触" : "淇敼澶辫触");
-          });
+        if (operationType.value === "edit") {
+          productionPlanUpdate(payload)
+            .then(() => {
+              proxy.$modal.msgSuccess("淇敼鎴愬姛");
+              dialogVisible.value = false;
+              getList();
+            })
+            .catch(() => {
+              proxy.$modal.msgError("淇敼澶辫触");
+            });
+        }
       }
     });
   };
@@ -1336,7 +1071,6 @@
       }
 
       // 鏁板�煎瓧娈垫牱寮�
-      .quantity-cell,
       .volume-cell,
       .dimension-cell {
         font-weight: 600;

--
Gitblit v1.9.3