From 82f04f7aa82ffa66bb91585128b25b59e6cfcc49 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期六, 25 四月 2026 17:44:34 +0800
Subject: [PATCH] productionOperationTask前缀替换

---
 src/views/productionManagement/processRoute/processRouteItem/index.vue |  202 ++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 160 insertions(+), 42 deletions(-)

diff --git a/src/views/productionManagement/processRoute/processRouteItem/index.vue b/src/views/productionManagement/processRoute/processRouteItem/index.vue
index 6fbaa2c..fd1a6a8 100644
--- a/src/views/productionManagement/processRoute/processRouteItem/index.vue
+++ b/src/views/productionManagement/processRoute/processRouteItem/index.vue
@@ -38,6 +38,15 @@
             <span class="info-value">{{ routeInfo.bomNo || '-' }}</span>
           </div>
         </div>
+        <div class="info-item"
+             v-if="routeInfo.quantity && routeInfo.quantity !== 0">
+          <div class="info-label-wrapper">
+            <span class="info-label">闇�姹傛暟閲�</span>
+          </div>
+          <div class="info-value-wrapper">
+            <span class="info-value">{{ routeInfo.quantity || '-' }}</span>
+          </div>
+        </div>
         <div class="info-item full-width"
              v-if="routeInfo.description">
           <div class="info-label-wrapper">
@@ -80,7 +89,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 +115,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 +167,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 +182,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>
@@ -220,8 +240,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"
@@ -282,6 +302,7 @@
                                      :step="1"
                                      controls-position="right"
                                      style="width: 100%"
+                                     @change="handleUnitQuantityChange(row)"
                                      :disabled="!bomDataValue.isEdit || bomDataValue.dataList.some(item => (item).tempId === row.tempId)" />
                   </el-form-item>
                 </template>
@@ -345,7 +366,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 +379,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 +392,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 +449,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 +479,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 +495,10 @@
   import { listProcessBom } from "@/api/productionManagement/productionOrder.js";
   import {
     queryList,
-    addBomDetail,
+    queryList2,
+    add2,
   } from "@/api/productionManagement/productStructure.js";
+
   import { useRoute } from "vue-router";
   import { ElMessageBox, ElMessage } from "element-plus";
   import Sortable from "sortablejs";
@@ -467,6 +515,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);
@@ -477,6 +526,7 @@
     model: "",
     bomNo: "",
     description: "",
+    quantity: 0,
   });
 
   const processOptions = ref([]);
@@ -505,6 +555,7 @@
     model: "",
     unit: "",
     isQuality: false,
+    isProduction: false,
   });
 
   const rules = {
@@ -523,17 +574,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(() => {});
   };
@@ -592,6 +657,7 @@
       bomNo: route.query.bomNo || "",
       bomId: route.query.bomId || "",
       description: route.query.description || "",
+      quantity: route.query.quantity || 0,
       status: !(route.query.status == 1 || route.query.status === "false"),
     };
     bomTableData.value[0].productName = routeInfo.value.productName;
@@ -618,6 +684,7 @@
       model: row.model || "",
       unit: row.unit || "",
       isQuality: row.isQuality,
+      isProduction: row.isProduction,
     };
     dialogVisible.value = true;
   };
@@ -650,15 +717,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 +748,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 +763,7 @@
                 technologyOperationId: form.value.technologyOperationId,
                 productModelId: form.value.productModelId,
                 isQuality: form.value.isQuality,
+                isProduction: form.value.isProduction,
                 dragSort,
               });
 
@@ -711,8 +787,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 +798,7 @@
                 productModelId: form.value.productModelId,
                 id: form.value.id,
                 isQuality: form.value.isQuality,
+                isProduction: form.value.isProduction,
               });
 
           updatePromise
@@ -749,6 +828,8 @@
       productName: "",
       model: "",
       unit: "",
+      isQuality: false,
+      isProduction: false,
     };
     formRef.value?.resetFields();
   };
@@ -762,15 +843,19 @@
   // 鏌ョ湅鍙傛暟鍒楄〃
   const handleViewParams = row => {
     currentProcess.value = row;
-    const query = {
+    const param = {
+      productionOrderRoutingOperationId: row.id,
+      productionOrderId: orderId.value,
+    };
+    const param1 = {
       technologyRoutingOperationId: row.id,
-      orderId: orderId.value,
+      productionOrderId: orderId.value,
     };
 
     const apiPromise =
       pageType.value === "order"
-        ? findProcessParamListOrder(query)
-        : getProcessParamList(query);
+        ? findProcessParamListOrder(param)
+        : getProcessParamList(param1);
 
     apiPromise
       .then(res => {
@@ -944,7 +1029,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 +1042,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 +1057,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 +1081,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) {
@@ -1081,6 +1182,12 @@
     });
   };
 
+  const handleUnitQuantityChange = row => {
+    if (routeInfo.value.quantity && routeInfo.value.quantity !== 0) {
+      row.demandedQuantity = (row.unitQuantity || 0) * routeInfo.value.quantity;
+    }
+  };
+
   const addchildItem = (item, tempId) => {
     if (item.tempId === tempId) {
       if (!item.children) {
@@ -1095,10 +1202,14 @@
         productModelId: undefined,
         processId: "",
         processName: "",
-        operationId: "",
+        [pageType.value === "order" ? "technologyOperationId" : "operationId"]:
+          "",
         operationName: "",
         unitQuantity: 1,
-        demandedQuantity: 0,
+        demandedQuantity:
+          routeInfo.value.quantity && routeInfo.value.quantity !== 0
+            ? 1 * routeInfo.value.quantity
+            : 0,
         children: [],
         unit: "",
         tempId: new Date().getTime(),
@@ -1130,10 +1241,14 @@
           productModelId: undefined,
           processId: "",
           processName: "",
-          operationId: "",
+          [pageType.value === "order" ? "technologyOperationId" : "operationId"]:
+            "",
           operationName: "",
           unitQuantity: 1,
-          demandedQuantity: 0,
+          demandedQuantity:
+            routeInfo.value.quantity && routeInfo.value.quantity !== 0
+              ? 1 * routeInfo.value.quantity
+              : 0,
           unit: "",
           children: [],
           tempId: new Date().getTime(),
@@ -1202,12 +1317,15 @@
 
   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,
+      add2({
+        // bomId: Number(routeInfo.value.bomId),
+        productionOrderBomId: Number(routeInfo.value.bomId) || null,
         children: buildSubmitTree(bomDataValue.value.dataList || []),
       })
         .then(() => {

--
Gitblit v1.9.3