From f84e425bb9debb5f2af8e417bf07d2a2b0077609 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期二, 28 四月 2026 17:00:03 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/dev_NEW_pro' into dev_NEW_pro

---
 src/views/productionPlan/productionPlan/index.vue |  892 +++++++++++++++++-----------------------------------------
 1 files changed, 269 insertions(+), 623 deletions(-)

diff --git a/src/views/productionPlan/productionPlan/index.vue b/src/views/productionPlan/productionPlan/index.vue
index 53a99f5..757eef7 100644
--- a/src/views/productionPlan/productionPlan/index.vue
+++ b/src/views/productionPlan/productionPlan/index.vue
@@ -2,16 +2,19 @@
   <div class="app-container">
     <div class="search_form">
       <el-form :model="searchForm"
+               ref="queryRef"
                :inline="true">
         <!-- 绠�鍖栫増鎼滅储鏉′欢 -->
-        <el-form-item label="浜у搧鍚嶇О:">
-          <el-input v-model="searchForm.productName"
+        <el-form-item label="涓荤敓浜ц鍒掑彿:"
+                      prop="mpsNo">
+          <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="闇�姹傛棩鏈熻寖鍥�:"
+                      prop="dateRange">
           <el-date-picker v-model="searchForm.dateRange"
                           type="daterange"
                           range-separator="鑷�"
@@ -21,7 +24,8 @@
                           style="width: 240px;"
                           @change="handleQuery" />
         </el-form-item>
-        <el-form-item label="涓嬪彂鐘舵��:">
+        <el-form-item label="涓嬪彂鐘舵��:"
+                      prop="status">
           <el-select v-model="searchForm.status"
                      placeholder="璇烽�夋嫨鐘舵��"
                      clearable
@@ -36,36 +40,22 @@
           </el-select>
         </el-form-item>
         <!-- 灞曞紑鐗堟悳绱㈡潯浠� -->
-        <template v-if="searchFormExpanded">
-          <el-form-item label="瀹㈡埛鍚嶇О:">
-            <el-input v-model="searchForm.customerName"
-                      placeholder="璇疯緭鍏�"
-                      clearable
-                      style="width: 160px;"
-                      @keyup.enter="handleQuery" />
-          </el-form-item>
-          <el-form-item label="浜у搧瑙勬牸:">
-            <el-input v-model="searchForm.model"
-                      placeholder="璇疯緭鍏�"
-                      clearable
-                      style="width: 160px;"
-                      @keyup.enter="handleQuery" />
-          </el-form-item>
-          <el-form-item label="鐗╂枡缂栫爜:">
-            <el-input v-model="searchForm.materialCode"
-                      placeholder="璇疯緭鍏�"
-                      clearable
-                      style="width: 160px;"
-                      @keyup.enter="handleQuery" />
-          </el-form-item>
-          <el-form-item label="鐢宠鍗曠紪鍙�:">
-            <el-input v-model="searchForm.applyNo"
-                      placeholder="璇疯緭鍏�"
-                      clearable
-                      style="width: 160px;"
-                      @keyup.enter="handleQuery" />
-          </el-form-item>
-        </template>
+        <el-form-item label="浜у搧鍚嶇О:"
+                      prop="productName">
+          <el-input v-model="searchForm.productName"
+                    placeholder="璇疯緭鍏�"
+                    clearable
+                    style="width: 160px;"
+                    @keyup.enter="handleQuery" />
+        </el-form-item>
+        <el-form-item label="浜у搧瑙勬牸:"
+                      prop="model">
+          <el-input v-model="searchForm.model"
+                    placeholder="璇疯緭鍏�"
+                    clearable
+                    style="width: 160px;"
+                    @keyup.enter="handleQuery" />
+        </el-form-item>
         <el-form-item>
           <el-button type="primary"
                      @click="handleQuery">鎼滅储</el-button>
@@ -73,9 +63,6 @@
                      @click="handleReset">閲嶇疆</el-button>
           <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"
@@ -86,16 +73,6 @@
       </el-form>
       <div>
       </div>
-    </div>
-    <div class="search-header">
-      <el-button type="text"
-                 @click="toggleSearchForm">
-        <el-icon>
-          <ArrowUp v-if="searchFormExpanded" />
-          <ArrowDown v-else />
-        </el-icon>
-        {{ searchFormExpanded ? '鏀惰捣鎼滅储鏉′欢' : '灞曞紑鎼滅储鏉′欢' }}
-      </el-button>
     </div>
     <div class="table_list">
       <PIMTable rowKey="id"
@@ -108,11 +85,15 @@
                 :selectable="isSelectable"
                 @selection-change="handleSelectionChange"
                 @pagination="pagination">
-        <template #quantity="{ row }">
-          {{ row.quantity || '-' }}<span style="color:rgb(63, 95, 211)"> 鍧�</span>
+        <template #qtyRequired="{ row }">
+          {{ row.qtyRequired || '-' }}<span style="color:rgba(12, 46, 40, 0.76)"> {{ row.unit || '鏂�' }}</span>
         </template>
-        <template #volume="{ row }">
-          {{ row.volume || '-' }}<span style="color:rgba(12, 46, 40, 0.76)"> 鏂�</span>
+        <template #salesContractNo="{ row }">
+          <el-button type="primary"
+                     text
+                     link
+                     @click="showDetail(row)">{{ row.salesContractNo }}
+          </el-button>
         </template>
       </PIMTable>
     </div>
@@ -125,25 +106,15 @@
                label-width="120px">
         <el-row :gutter="20">
           <el-col :span="10">
-            <el-form-item label="鐗╂枡缂栫爜">
-              <div class="info-display">{{ mergeForm.materialCode || '-' }}</div>
-            </el-form-item>
-          </el-col>
-          <el-col :span="10">
             <el-form-item label="浜у搧鍚嶇О">
               <el-tag class="info-display">{{ mergeForm.productName || '-' }}</el-tag>
             </el-form-item>
           </el-col>
         </el-row>
         <el-row :gutter="20">
-          <el-col :span="10">
+          <el-col>
             <el-form-item label="浜у搧瑙勬牸">
               <div class="info-display">{{ mergeForm.model || '-' }}</div>
-            </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>
@@ -153,32 +124,13 @@
                           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-form-item label="鐢熶骇鏁伴噺">
           <el-input-number v-model="mergeForm.totalAssignedQuantity"
                            :min="0"
                            :max="sumAssignedQuantity"
                            @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,19 +161,15 @@
                :model="form"
                :rules="rules"
                label-width="120px">
-        <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 label="涓荤敓浜ц鍒掑彿"
+                      prop="mpsNo">
+          <el-input v-model="form.mpsNo"
+                    disabled
+                    placeholder="鏂板鍚庤嚜鍔ㄧ敓鎴�" />
         </el-form-item>
         <el-form-item label="浜у搧鍚嶇О"
-                      prop="productMaterialId">
-          <el-tree-select v-model="form.productMaterialId"
+                      prop="productId">
+          <el-tree-select v-model="form.productId"
                           placeholder="璇烽�夋嫨"
                           clearable
                           :data="productOptions"
@@ -231,10 +179,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 +191,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,98 +238,33 @@
 </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";
+  import {
+    productionPlanListPage,
+    productionPlanAdd,
+    productionPlanUpdate,
+    productionPlanDelete,
+    productionPlanCombine,
+  } from "@/api/productionPlan/productionPlan.js";
+  import { productTreeList, modelListPage } from "@/api/basicData/product.js";
+  import PIMTable from "./components/PIMTable.vue";
+  import ImportDialog from "@/components/Dialog/ImportDialog.vue";
 
-  // 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 { proxy } = getCurrentInstance();
+  const router = useRouter();
 
   const loadProdData = () => {
     console.log("Mock loadProdData called");
@@ -424,71 +276,36 @@
     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: "鍚堝苟涓嬪彂鎴愬姛" });
-  };
-  import PIMTable from "./components/PIMTable.vue";
-  // import {
-  //   modelListPage,
-  //   productTreeList,
-  //   productTreeListQuery,
-  // } from "@/api/basicData/newProduct.js";
-
-  const { proxy } = getCurrentInstance();
-  const router = useRouter();
+  // const productionPlanCombine = payload => {
+  //   console.log("Mock productionPlanCombine called with:", payload);
+  //   return Promise.resolve({ code: 200, msg: "鍚堝苟涓嬪彂鎴愬姛" });
+  // };
 
   const tableColumn = ref([
     {
-      label: "鏁版嵁鏉ユ簮",
-      width: "100px",
-      prop: "dataSourceType",
+      label: "涓荤敓浜ц鍒掑彿",
+      prop: "mpsNo",
+      width: "150px",
+    },
+    {
+      label: "鏉ユ簮",
+      prop: "source",
+      width: "150px",
       dataType: "tag",
       formatType: params => {
-        const typeMap = {
-          2: "warning",
-          1: "primary",
-        };
-        return typeMap[params] || "info";
+        return params == "閿�鍞�" ? "primary" : "info";
       },
-      formatData: cell => (cell == 1 ? "閽夐拤鍚屾" : "鎵嬪姩鏂板"),
+      formatData: params => {
+        return params == "閿�鍞�" ? "閿�鍞�" : "鍐呴儴";
+      },
     },
-    {
-      label: "鐢宠鍗曠紪鍙�",
-      prop: "applyNo",
-      width: "150px",
-    },
-    {
-      label: "瀹㈡埛鍚嶇О",
-      prop: "customerName",
-      width: "150px",
-    },
+
     {
       label: "浜у搧鍚嶇О",
       prop: "productName",
       width: "200px",
       dataType: "tag",
       formatType: params => {
-        // const typeMap = {
-        //   鏉挎潗: "primary",
-        //   鐮屽潡: "warning",
-        // };
-        // return typeMap[params] || "info";
         return "primary";
       },
     },
@@ -499,30 +316,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 => {
@@ -543,88 +353,83 @@
       },
     },
     {
-      label: "宸蹭笅鍙戞柟鏁�",
-      prop: "assignedQuantity",
-      width: "150px",
+      label: "宸蹭笅鍙戞暟閲�",
+      prop: "quantityIssued",
+      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",
-      width: "150px",
-      prop: "remarkOne",
+      label: "閿�鍞悎鍚屽彿",
+      prop: "salesContractNo",
+      width: "200px",
+      dataType: "slot",
+      slot: "salesContractNo",
     },
     {
-      label: "澶囨敞 2",
+      label: "瀹㈡埛鍚嶇О",
+      prop: "customerName",
       width: "150px",
-      prop: "remarkTwo",
     },
-
+    {
+      label: "椤圭洰鍚嶇О",
+      prop: "projectName",
+      width: "150px",
+    },
+    {
+      label: "澶囨敞",
+      width: "150px",
+      prop: "remark",
+    },
     {
       dataType: "action",
       label: "鎿嶄綔",
       align: "center",
       fixed: "right",
-      width: 300,
+      width: 250,
       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);
+          },
+        },
+        {
+          name: "涓嬪彂",
+          type: "text",
+          showHide: row => {
+            return row.status != 2;
+          },
+          clickFun: row => {
+            mergeForm.productName = row.productName || "";
+            mergeForm.model = row.model || "";
+            mergeForm.totalAssignedQuantity =
+              Number(row.qtyRequired || 0) - Number(row.quantityIssued || 0);
+            mergeForm.planCompleteTime = row.requiredDate || "";
+            mergeForm.productId = row.productId || "";
+            mergeForm.ids = [row.id];
+            sumAssignedQuantity.value =
+              Number(row.qtyRequired || 0) - Number(row.quantityIssued || 0);
+            isShowNewModal.value = true;
           },
         },
         {
@@ -638,44 +443,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.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 || "";
-            sumAssignedQuantity.value = mergeForm.totalAssignedQuantity;
-            // 鎵撳紑寮圭獥
-            isShowNewModal.value = true;
-          },
-        },
-        // {
-        //   name: "杩借釜杩涘害",
-        //   type: "text",
-        //   clickFun: row => {
-        //     handleTrackProgress(row);
-        //   },
-        // },
       ],
     },
   ]);
@@ -697,16 +464,11 @@
   const isShowNewModal = ref(false);
   // 鍚堝苟涓嬪彂琛ㄥ崟鏁版嵁
   const mergeForm = reactive({
-    materialCode: "",
     productName: "",
     model: "",
-    length: 0,
-    width: 0,
-    height: 0,
     totalAssignedQuantity: 0,
     planCompleteTime: "",
-    strength: "",
-    productMaterialId: "",
+    productId: "",
   });
 
   // 瀵煎叆鐩稿叧
@@ -723,54 +485,29 @@
   const operationType = ref("add"); // add | edit
   const productOptions = ref([]);
   const specificationOptions = ref([]);
+  const queryRef = ref(null);
   const formRef = ref(null);
-  // 鑾峰彇寮哄害瀛楀吀
-  const { block_strength } = useDict("block_strength");
   const form = reactive({
     id: undefined,
-    applyNo: "",
-    customerName: "",
-    productMaterialId: undefined,
-    productMaterialSkuId: undefined,
+    mpsNo: "",
+    productId: 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({
-    applyNo: [{ required: true, message: "璇疯緭鍏ョ敵璇峰崟缂栧彿", trigger: "blur" }],
-    customerName: [
-      { required: true, message: "璇疯緭鍏ュ鎴峰悕绉�", trigger: "blur" },
-    ],
-    productMaterialSkuId: [
+    productId: [{ required: true, message: "璇烽�夋嫨浜у搧", trigger: "change" }],
+    productModelId: [
       { 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,
-      },
+    qtyRequired: [{ required: true, message: "璇疯緭鍏ユ暟閲�", trigger: "blur" }],
+    requiredDate: [
+      { required: true, message: "璇烽�夋嫨闇�姹傛棩鏈�", trigger: "change" },
     ],
   });
 
@@ -781,7 +518,6 @@
       path: "/productionPlan/trackProgress",
       query: {
         id: row.id,
-        applyNo: row.applyNo,
         productName: row.productName,
         model: row.model,
       },
@@ -793,40 +529,35 @@
   };
 
   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;
     // 鏌ユ壘閫変腑鐨勪骇鍝佸悕绉�
-    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;
           }
@@ -835,49 +566,36 @@
       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: "",
-      applyNo: "",
+      status: "",
       dateRange: [],
     },
     searchFormExpanded: false,
@@ -898,12 +616,14 @@
 
   /** 閲嶇疆鎸夐挳鎿嶄綔 */
   const handleReset = () => {
+    if (proxy.resetForm) {
+      proxy.resetForm("queryRef");
+    }
     Object.assign(searchForm.value, {
-      customerName: "",
+      mpsNo: "",
       productName: "",
       model: "",
-      materialCode: "",
-      applyNo: "",
+      status: "",
       dateRange: [],
     });
     page.current = 1;
@@ -920,16 +640,18 @@
 
     // 閬嶅巻琛ㄦ牸鏁版嵁锛屾寜浜у搧绫诲埆姹囨��
     tableData.value.forEach(row => {
-      const category = row.materialCode;
+      const category = row.productName || "鏈煡浜у搧";
       if (!summary[category]) {
         summary[category] = {
           materialCode: category,
           totalAssignedQuantity: 0,
         };
       }
-      summary[category].totalAssignedQuantity += (
-        Number(row.volume) - Number(row.assignedQuantity)
-      ).toFixed(4);
+      summary[category].totalAssignedQuantity += Number(
+        (Number(row.qtyRequired || 0) - Number(row.quantityIssued || 0)).toFixed(
+          4
+        )
+      );
     });
 
     // 杞崲涓烘暟缁勬牸寮�
@@ -940,13 +662,14 @@
     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.length > 0 ? params.dateRange[0] : "";
+    params.requiredDateEnd =
+      params.dateRange && params.dateRange.length > 1 ? params.dateRange[1] : "";
     delete params.dateRange;
     productionPlanListPage(params)
       .then(res => {
         tableLoading.value = false;
-
         tableData.value = res.data.records;
         page.total = res.data.total;
         // 璁$畻浜у搧绫诲埆姹囨�荤粺璁�
@@ -957,61 +680,43 @@
       });
   };
 
-  // 閫変腑鐨勫簭鍒楀彿
-  const selectedserialNo = ref("");
+  // 閫変腑鐨勪骇鍝佽鏍糏D
+  const selectedProductModelId = ref("");
 
   // 琛ㄦ牸閫夋嫨鏁版嵁
   const handleSelectionChange = selection => {
     selectedRows.value = selection;
-    // 濡傛灉鏈夐�変腑鐨勮锛岃褰曠涓�涓�変腑琛岀殑搴忓垪鍙�
+    // 濡傛灉鏈夐�変腑鐨勮锛岃褰曠涓�涓�変腑琛岀殑浜у搧瑙勬牸ID
     if (selection.length > 0) {
-      selectedserialNo.value = selection[0].materialCode;
+      selectedProductModelId.value = selection[0].productModelId;
     } else {
-      // 濡傛灉娌℃湁閫変腑鐨勮锛屾竻绌哄簭鍒楀彿
-      selectedserialNo.value = "";
+      // 濡傛灉娌℃湁閫変腑鐨勮锛屾竻绌轰骇鍝佽鏍糏D
+      selectedProductModelId.value = "";
     }
   };
 
   // 鍒ゆ柇琛屾槸鍚﹀彲閫夋嫨
   const isSelectable = row => {
-    // 璁$畻鍓╀綑鏂规暟
-    const remainingVolume = (row.volume || 0) - (row.assignedQuantity || 0);
-    // 濡傛灉鍓╀綑鏂规暟灏忎簬绛変簬0锛岀姝㈤�夋嫨
-    if (remainingVolume <= 0) {
+    // 濡傛灉鏄凡涓嬪彂鐘舵�侊紝绂佹鍕鹃��
+    if (row.status == 2) {
+      return false;
+    }
+    // 璁$畻鍓╀綑鏁伴噺
+    const remainingQty = (row.qtyRequired || 0) - (row.quantityIssued || 0);
+    // 濡傛灉鍓╀綑鏁伴噺灏忎簬绛変簬0锛岀姝㈤�夋嫨
+    if (remainingQty <= 0) {
       return false;
     }
     // 濡傛灉娌℃湁閫変腑鐨勮锛屾墍鏈夎閮藉彲閫夋嫨
-    if (!selectedserialNo.value) {
+    if (!selectedProductModelId.value) {
       return true;
     }
-    // 濡傛灉鏈夐�変腑鐨勮锛屽彧鏈夊簭鍒楀彿鐩稿悓鐨勮鎵嶅彲閫夋嫨
-    return row.materialCode === selectedserialNo.value;
+    // 濡傛灉鏈夐�変腑鐨勮锛屽彧鏈変骇鍝佽鏍糏D鐩稿悓鐨勮鎵嶅彲閫夋嫨
+    return row.productModelId === selectedProductModelId.value;
   };
   // 鎷夊彇鏁版嵁鎸夐挳鎿嶄綔
   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 = () => {
@@ -1020,87 +725,52 @@
       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 = "閫夋嫨鐨勭爩鍧楀己搴︿笉涓�鑷达紝璇烽噸鏂伴�夋嫨";
-      }
-    }
-
-    // 璁$畻鎬诲埗閫犳暟閲�
+    // 璁$畻鎬诲埗閫犳暟閲� (榛樿qtyRequired鐨勫拰)
     const totalAssignedQuantity = selectedRows.value.reduce((sum, row) => {
-      return (
-        sum +
-        (row.volume == null
-          ? 0
-          : Number(Number(row.volume) - Number(row.assignedQuantity).toFixed(4)))
-      );
+      return sum + Number(row.qtyRequired || 0) - Number(row.quantityIssued || 0);
     }, 0);
     sumAssignedQuantity.value = totalAssignedQuantity;
     console.log(totalAssignedQuantity);
     // 璁剧疆琛ㄥ崟鏁版嵁
-    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.planCompleteTime = firstRow.requiredDate || "";
+    mergeForm.productId = firstRow.productId || "";
     mergeForm.ids = selectedRows.value.map(row => row.id);
 
     // 鎵撳紑寮圭獥
     isShowNewModal.value = true;
   };
+  const showDetail = row => {
+    router.push({
+      path: "/salesManagement/salesLedger",
+      query: {
+        salesContractNo: row.salesContractNo,
+      },
+    });
+  };
 
   // 澶勭悊鍚堝苟涓嬪彂鎻愪氦
   const handleMergeSubmit = () => {
     if (mergeForm.totalAssignedQuantity === 0) {
-      ElMessage.warning("璇疯緭鍏ョ敓浜ф柟鏁�");
+      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);
-    }, 0);
 
     // 楠岃瘉totalAssignedQuantity涓嶈兘澶т簬鎬绘柟鏁�
     if (mergeForm.totalAssignedQuantity > sumAssignedQuantity.value) {
-      ElMessage.error("鐢熶骇鏂规暟涓嶈兘澶т簬褰撳墠璁$畻鐨勬�诲��");
+      ElMessage.error("鐢熶骇鏁伴噺涓嶈兘澶т簬褰撳墠璁$畻鐨勬�诲��");
       return;
     }
 
     console.log(mergeForm, "mergeForm");
-    const strengthItem = block_strength.value.find(
-      item => item.id === mergeForm.strength
-    );
     const payload = {
       ...mergeForm,
-      strength: strengthItem ? strengthItem.label : mergeForm.strength,
     };
     productionPlanCombine(payload)
       .then(res => {
@@ -1202,23 +872,17 @@
   const handleAdd = () => {
     operationType.value = "add";
     Object.assign(form, {
-      applyNo: "",
-      customerName: "",
+      id: undefined,
+      mpsNo: "",
       productName: "",
-      productMaterialId: undefined,
-      productMaterialSkuId: undefined,
+      productId: 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();
@@ -1229,27 +893,20 @@
     operationType.value = "edit";
     Object.assign(form, {
       id: row.id,
-      applyNo: row.applyNo || "",
-      customerName: row.customerName || "",
+      mpsNo: row.mpsNo || "",
       productName: row.productName || "",
-      productMaterialId: row.productMaterialId || undefined,
-      productMaterialSkuId: row.productMaterialSkuId || undefined,
+      productId: row.productId || 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();
-    fetchSpecificationOptions(row.productMaterialId);
+    fetchSpecificationOptions(row.productId);
   };
 
   // 鍒犻櫎
@@ -1277,43 +934,32 @@
   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;
-        }
-        if (form.v === "add") {
-          payload.id = null;
         }
         const payload = { ...form };
         if (operationType.value === "add") {
           payload.id = null;
           productionPlanAdd(payload)
             .then(() => {
-              proxy.$modal.msgSuccess(
-                operationType.value === "add" ? "鏂板鎴愬姛" : "淇敼鎴愬姛"
-              );
+              proxy.$modal.msgSuccess("鏂板鎴愬姛");
               dialogVisible.value = false;
               getList();
             })
             .catch(() => {
-              proxy.$modal.msgError(
-                operationType.value === "add" ? "鏂板澶辫触" : "淇敼澶辫触"
-              );
+              proxy.$modal.msgError("鏂板澶辫触");
             });
         }
         if (operationType.value === "edit") {
           productionPlanUpdate(payload)
             .then(() => {
-              proxy.$modal.msgSuccess(
-                operationType.value === "add" ? "鏂板鎴愬姛" : "淇敼鎴愬姛"
-              );
+              proxy.$modal.msgSuccess("淇敼鎴愬姛");
               dialogVisible.value = false;
               getList();
             })
             .catch(() => {
-              proxy.$modal.msgError(
-                operationType.value === "add" ? "鏂板澶辫触" : "淇敼澶辫触"
-              );
+              proxy.$modal.msgError("淇敼澶辫触");
             });
         }
       }
@@ -1434,7 +1080,6 @@
       }
 
       // 鏁板�煎瓧娈垫牱寮�
-      .quantity-cell,
       .volume-cell,
       .dimension-cell {
         font-weight: 600;
@@ -1542,6 +1187,7 @@
     color: #303133;
     font-size: 14px;
     min-height: 32px;
+    width: 100%;
     display: flex;
     align-items: center;
   }

--
Gitblit v1.9.3