From 93d2a0bd19ffb1d86c6807a4d93d0eff580c14f1 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期六, 25 四月 2026 16:39:26 +0800
Subject: [PATCH] 生产计划和生产订单一些修改

---
 src/views/productionManagement/processRoute/processRouteItem/index.vue |  163 ++++++++++++++++++++++++++++++++++++++++++------------
 1 files changed, 126 insertions(+), 37 deletions(-)

diff --git a/src/views/productionManagement/processRoute/processRouteItem/index.vue b/src/views/productionManagement/processRoute/processRouteItem/index.vue
index 6fbaa2c..44fef19 100644
--- a/src/views/productionManagement/processRoute/processRouteItem/index.vue
+++ b/src/views/productionManagement/processRoute/processRouteItem/index.vue
@@ -80,7 +80,7 @@
                        prop="technologyOperationId"
                        width="200">
         <template #default="scope">
-          {{ getProcessName(scope.row.technologyOperationId) || '-' }}
+          {{ scope.row.technologyOperationName || scope.row.operationName || '-' }}
         </template>
       </el-table-column>
       <el-table-column label="鍙傛暟鍒楄〃"
@@ -106,6 +106,13 @@
                        width="100">
         <template #default="scope">
           {{scope.row.isQuality ? "鏄�" : "鍚�"}}
+        </template>
+      </el-table-column>
+      <el-table-column label="鏄惁鐢熶骇"
+                       prop="isProduction"
+                       width="100">
+        <template #default="scope">
+          {{scope.row.isProduction ? "鏄�" : "鍚�"}}
         </template>
       </el-table-column>
       <el-table-column label="鎿嶄綔"
@@ -151,7 +158,7 @@
             <!-- 搴忓彿鍦嗗湀 -->
             <div class="card-header">
               <div class="card-number">{{ index + 1 }}</div>
-              <div class="card-process-name">{{ getProcessName(item.technologyOperationId) || '-' }}</div>
+              <div class="card-process-name">{{ item.technologyOperationName || item.operationName || '-' }}</div>
             </div>
             <!-- 浜у搧淇℃伅 -->
             <div class="card-content">
@@ -166,6 +173,10 @@
                 <el-tag type="primary"
                         class="product-tag"
                         v-if="item.isQuality">璐ㄦ</el-tag>
+                <el-tag type="primary"
+                        class="product-tag"
+                        :style="item.isQuality?'margin-left:8px':''"
+                        v-if="item.isProduction">鐢熶骇</el-tag>
               </div>
               <div v-else
                    class="product-info empty">鏆傛棤浜у搧淇℃伅</div>
@@ -195,7 +206,7 @@
     <div class="section-header"
          style="margin-top: 20px;">
       <div class="section-title">BOM 缁撴瀯</div>
-      <div class="section-actions"
+      <!-- <div class="section-actions"
            v-if="pageType === 'order'">
         <el-button v-if="!bomDataValue.isEdit"
                    type="primary"
@@ -212,7 +223,7 @@
                    :loading="bomDataValue.loading">
           淇濆瓨BOM
         </el-button>
-      </div>
+      </div> -->
     </div>
     <el-table :data="bomTableData"
               border
@@ -220,8 +231,8 @@
               :default-expand-all="true"
               style="width: 100%">
       <el-table-column type="expand">
-        <template #default="props">
-          <el-form ref="form"
+        <template #default>
+          <el-form ref="bomFormRef"
                    :model="bomDataValue">
             <el-table :data="bomDataValue.dataList"
                       row-key="tempId"
@@ -345,7 +356,7 @@
                        prop="model" />
     </el-table>
     <ProductSelectDialog v-if="bomDataValue.showProductDialog"
-                         v-model:model-value="bomDataValue.showProductDialog"
+                         v-model="bomDataValue.showProductDialog"
                          :single="true"
                          @confirm="handleBomProduct" />
     <!-- 鏂板/缂栬緫寮圭獥 -->
@@ -358,10 +369,12 @@
                :rules="rules"
                label-width="120px">
         <el-form-item label="宸ュ簭"
+                      v-if="operationType === 'add' || pageType === 'route'"
                       prop="technologyOperationId">
           <el-select v-model="form.technologyOperationId"
                      placeholder="璇烽�夋嫨宸ュ簭"
                      clearable
+                     @change="processChange"
                      style="width: 100%">
             <el-option v-for="process in processOptions"
                        :key="process.id"
@@ -369,27 +382,47 @@
                        :value="process.id" />
           </el-select>
         </el-form-item>
+        <el-form-item label="宸ュ簭"
+                      v-else>
+          <span>{{ getProcessName(form.technologyOperationId) }}</span>
+        </el-form-item>
         <el-form-item label="浜у搧鍚嶇О"
+                      v-if="operationType === 'add' || pageType === 'route'"
                       prop="productModelId">
           <el-button type="primary"
                      @click="showProductSelectDialog = true">
-            {{ form.productName && form.model 
-              ? `${form.productName} - ${form.model}` 
+            {{ form.productName
+              ? (form.model ? `${form.productName} - ${form.model}` : form.productName)
               : '閫夋嫨浜у搧' }}
           </el-button>
         </el-form-item>
+        <el-form-item label="浜у搧鍚嶇О"
+                      v-else>
+          <span>{{ form.productName }}{{ form.model ? ' - ' + form.model : '' }}</span>
+        </el-form-item>
         <el-form-item label="鍗曚綅"
+                      v-if="operationType === 'add' || pageType === 'route'"
                       prop="unit">
           <el-input v-model="form.unit"
                     :placeholder="form.productModelId ? '鏍规嵁閫夋嫨鐨勪骇鍝佽嚜鍔ㄥ甫鍑�' : '璇峰厛閫夋嫨浜у搧'"
                     clearable
                     :disabled="true" />
         </el-form-item>
+        <el-form-item label="鍗曚綅"
+                      v-else>
+          <span>{{ form.unit }}</span>
+        </el-form-item>
         <el-form-item label="鏄惁璐ㄦ"
                       prop="isQuality">
           <el-switch v-model="form.isQuality"
                      :active-value="true"
-                     inactive-value="false" />
+                     :inactive-value="false" />
+        </el-form-item>
+        <el-form-item label="鏄惁鐢熶骇"
+                      prop="isProduction">
+          <el-switch v-model="form.isProduction"
+                     :active-value="true"
+                     :inactive-value="false" />
         </el-form-item>
       </el-form>
       <template #footer>
@@ -406,7 +439,7 @@
     <!-- 鍙傛暟鍒楄〃瀵硅瘽妗� -->
     <!-- :editable="!routeInfo.status" -->
     <ProcessParamListDialog v-model="showParamListDialog"
-                            :title="`${currentProcess ? (currentProcess.processName || getProcessName(currentProcess.technologyOperationId)) : ''} - 鍙傛暟鍒楄〃`"
+                            :title="`${currentProcess ? (currentProcess.processName || currentProcess.technologyOperationName || currentProcess.operationName) : ''} - 鍙傛暟鍒楄〃`"
                             :route-id="routeId"
                             :order-id="orderId"
                             :process="currentProcess"
@@ -436,7 +469,10 @@
     batchDeleteProcessRouteItem,
     getProcessParamList,
   } from "@/api/productionManagement/processRouteItem.js";
-  import { syncProcessParamItem } from "@/api/productionManagement/processRouteItem.js";
+  import {
+    syncProcessParamItem,
+    syncProcessParamItemOrder,
+  } from "@/api/productionManagement/processRouteItem.js";
   import {
     findProductProcessRouteItemList,
     deleteRouteItem,
@@ -449,8 +485,10 @@
   import { listProcessBom } from "@/api/productionManagement/productionOrder.js";
   import {
     queryList,
+    queryList2,
     addBomDetail,
   } from "@/api/productionManagement/productStructure.js";
+
   import { useRoute } from "vue-router";
   import { ElMessageBox, ElMessage } from "element-plus";
   import Sortable from "sortablejs";
@@ -467,6 +505,7 @@
   const dialogVisible = ref(false);
   const operationType = ref("add"); // add | edit
   const formRef = ref(null);
+  const bomFormRef = ref(null);
   const submitLoading = ref(false);
   const cardsContainer = ref(null);
   const tableRef = ref(null);
@@ -505,6 +544,7 @@
     model: "",
     unit: "",
     isQuality: false,
+    isProduction: false,
   });
 
   const rules = {
@@ -523,17 +563,31 @@
       type: "warning",
     })
       .then(() => {
-        syncProcessParamItem({
-          replaceExisting: true,
-          technologyRoutingOperationId: currentProcess.value.id,
-        }).then(res => {
-          if (res.code === 200) {
-            ElMessage.success("鍚屾鎴愬姛");
-            refreshParamList();
-          } else {
-            ElMessage.error(res.msg || "鍚屾澶辫触");
-          }
-        });
+        if (pageType.value === "order") {
+          syncProcessParamItemOrder({
+            replaceExisting: true,
+            technologyRoutingOperationId: currentProcess.value.id,
+          }).then(res => {
+            if (res.code === 200) {
+              ElMessage.success("鍚屾鎴愬姛");
+              refreshParamList();
+            } else {
+              ElMessage.error(res.msg || "鍚屾澶辫触");
+            }
+          });
+        } else {
+          syncProcessParamItem({
+            replaceExisting: true,
+            technologyRoutingOperationId: currentProcess.value.id,
+          }).then(res => {
+            if (res.code === 200) {
+              ElMessage.success("鍚屾鎴愬姛");
+              refreshParamList();
+            } else {
+              ElMessage.error(res.msg || "鍚屾澶辫触");
+            }
+          });
+        }
       })
       .catch(() => {});
   };
@@ -618,6 +672,7 @@
       model: row.model || "",
       unit: row.unit || "",
       isQuality: row.isQuality,
+      isProduction: row.isProduction,
     };
     dialogVisible.value = true;
   };
@@ -650,15 +705,20 @@
 
   // 浜у搧閫夋嫨
   const handleProductSelect = products => {
+    console.log(products, "===products===");
     if (products && products.length > 0) {
       const product = products[0];
-      form.value.productModelId = product.id;
-      form.value.productName = product.productName;
-      form.value.model = product.model;
-      form.value.unit = product.unit || "";
+      console.log(product, "product");
+      form.value = {
+        ...form.value,
+        productModelId: product.id,
+        productName: product.productName,
+        model: product.model,
+        unit: product.unit || "",
+      };
       showProductSelectDialog.value = false;
       // 瑙﹀彂琛ㄥ崟楠岃瘉
-      formRef.value?.validateField("productModelId");
+      // formRef.value?.validateField("productModelId");
     }
   };
 
@@ -676,11 +736,14 @@
 
           const addPromise = isOrderPage
             ? addRouteItem({
-                productOrderId: orderId.value,
-                productRouteId: routeId.value,
+                productionOrderId: Number(orderId.value),
+                orderRoutingId: Number(routeId.value),
                 technologyOperationId: form.value.technologyOperationId,
+                technologyRoutingId: Number(routeId.value),
+                operationName: getProcessName(form.value.technologyOperationId),
                 productModelId: form.value.productModelId,
                 isQuality: form.value.isQuality,
+                isProduction: form.value.isProduction,
                 dragSort,
               })
             : addOrUpdateProcessRouteItem({
@@ -688,6 +751,7 @@
                 technologyOperationId: form.value.technologyOperationId,
                 productModelId: form.value.productModelId,
                 isQuality: form.value.isQuality,
+                isProduction: form.value.isProduction,
                 dragSort,
               });
 
@@ -711,8 +775,10 @@
             ? addOrUpdateProductProcessRouteItem({
                 id: form.value.id,
                 technologyOperationId: form.value.technologyOperationId,
+                operationName: getProcessName(form.value.technologyOperationId),
                 productModelId: form.value.productModelId,
                 isQuality: form.value.isQuality,
+                isProduction: form.value.isProduction,
               })
             : addOrUpdateProcessRouteItem1({
                 technologyRoutingId: Number(routeId.value),
@@ -720,6 +786,7 @@
                 productModelId: form.value.productModelId,
                 id: form.value.id,
                 isQuality: form.value.isQuality,
+                isProduction: form.value.isProduction,
               });
 
           updatePromise
@@ -749,6 +816,8 @@
       productName: "",
       model: "",
       unit: "",
+      isQuality: false,
+      isProduction: false,
     };
     formRef.value?.resetFields();
   };
@@ -764,7 +833,7 @@
     currentProcess.value = row;
     const query = {
       technologyRoutingOperationId: row.id,
-      orderId: orderId.value,
+      productionOrderId: orderId.value,
     };
 
     const apiPromise =
@@ -944,7 +1013,8 @@
   });
 
   const syncProcessOperationFields = item => {
-    const processId = item.processId ?? item.operationId ?? "";
+    const processId =
+      item.processId ?? item.operationId ?? item.technologyOperationId ?? "";
     if (!processId) {
       item.processId = "";
       return;
@@ -956,7 +1026,11 @@
       option?.name || item.processName || item.operationName || "";
 
     item.processId = processId;
-    item.operationId = processId;
+    if (pageType.value === "order") {
+      item.technologyOperationId = processId;
+    } else {
+      item.operationId = processId;
+    }
     item.processName = processName;
     item.operationName = processName;
   };
@@ -967,6 +1041,14 @@
       syncProcessOperationFields(item);
       if (Array.isArray(item.children) && item.children.length > 0) {
         normalizeTreeData(item.children);
+      }
+    });
+  };
+  const processChange = value => {
+    processOptions.value.forEach(item => {
+      if (item.id == value) {
+        form.value.isQuality = item.isQuality;
+        form.value.isProduction = item.isProduction;
       }
     });
   };
@@ -983,7 +1065,10 @@
 
   const fetchBomData = async () => {
     try {
-      const { data } = await queryList(routeInfo.value.bomId);
+      const isOrderPage = pageType.value === "order";
+      const { data } = await (isOrderPage ? queryList2 : queryList)(
+        routeInfo.value.bomId
+      );
       bomDataValue.value.dataList = data || [];
       normalizeTreeData(bomDataValue.value.dataList);
     } catch (err) {
@@ -1095,7 +1180,8 @@
         productModelId: undefined,
         processId: "",
         processName: "",
-        operationId: "",
+        [pageType.value === "order" ? "technologyOperationId" : "operationId"]:
+          "",
         operationName: "",
         unitQuantity: 1,
         demandedQuantity: 0,
@@ -1130,7 +1216,8 @@
           productModelId: undefined,
           processId: "",
           processName: "",
-          operationId: "",
+          [pageType.value === "order" ? "technologyOperationId" : "operationId"]:
+            "",
           operationName: "",
           unitQuantity: 1,
           demandedQuantity: 0,
@@ -1202,12 +1289,14 @@
 
   const handleSaveBom = () => {
     bomDataValue.value.loading = true;
+    console.log(bomDataValue.value.dataList, "bomDataValue.value.dataList");
+
     normalizeTreeData(bomDataValue.value.dataList);
 
     const valid = validateAllBom();
     if (valid) {
       addBomDetail({
-        bomId: routeInfo.value.bomId,
+        bomId: Number(routeInfo.value.bomId),
         children: buildSubmitTree(bomDataValue.value.dataList || []),
       })
         .then(() => {

--
Gitblit v1.9.3