From 7465eb431e134576b4c9c43103c9fc6f918d1696 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期三, 20 五月 2026 17:37:21 +0800
Subject: [PATCH] fix: 每个工序添加投入重量字段

---
 src/views/productionManagement/workOrder/components/GranulationForm.vue |   68 ++++++++++++++++++++++++++++++++-
 1 files changed, 65 insertions(+), 3 deletions(-)

diff --git a/src/views/productionManagement/workOrder/components/GranulationForm.vue b/src/views/productionManagement/workOrder/components/GranulationForm.vue
index a35fae8..de53579 100644
--- a/src/views/productionManagement/workOrder/components/GranulationForm.vue
+++ b/src/views/productionManagement/workOrder/components/GranulationForm.vue
@@ -1,5 +1,5 @@
 <script setup lang="ts">
-import {computed, onMounted, reactive, ref} from "vue";
+import {computed, onMounted, reactive, ref, watch} from "vue";
 import {userListNoPageByTenantId} from "@/api/system/user.js";
 import {ElMessage} from "element-plus";
 import {addProductMain} from "@/api/productionManagement/workOrder.js";
@@ -20,7 +20,12 @@
   row: {
     type: Object,
     default: () => ({}),
-  }
+  },
+  /** 宸ュ崟 BOM 鎶曞叆閲嶉噺锛屽洖鏄惧埌銆屾姇鍏ラ噸閲忋�� */
+  bomInputQty: {
+    type: Number,
+    default: null,
+  },
 });
 
 const emits = defineEmits(["update:isShow", "refreshData"]);
@@ -121,6 +126,7 @@
       confirmName: undefined,
     },
     remark: undefined, // 澶囨敞
+    inputWeight: undefined, // 鎶曞叆閲嶉噺(KG)
   }
 })
 
@@ -228,10 +234,29 @@
   });
 };
 
+const resolveBomInputQty = () => {
+  const bom = props.bomInputQty ?? props.row?.bomInputQty;
+  if (bom === null || bom === undefined || bom === "") {
+    return null;
+  }
+  const n = Number(bom);
+  return Number.isFinite(n) ? n : null;
+};
+
+const applyBomInputWeight = () => {
+  const n = resolveBomInputQty();
+  if (n !== null) {
+    formData.otherData.inputWeight = n;
+  }
+};
+
 const initData = () => {
   if (!props.isEdit) {
     formData.otherData = JSON.parse(props.row.otherData || '{}');
     formData.quantity = props.row.quantity;
+    if (formData.otherData.inputWeight === undefined || formData.otherData.inputWeight === null || formData.otherData.inputWeight === "") {
+      applyBomInputWeight();
+    }
   } else {
     const row = props.row;
     formData.planQuantity = row.planQuantity
@@ -239,8 +264,32 @@
     formData.workOrderId = row.id
     formData.reportWork = row.reportWork
     formData.productMainId = row.productMainId
+    applyBomInputWeight();
   }
 }
+
+watch(
+  () => props.isShow,
+  (show) => {
+    if (show) {
+      initData();
+    }
+  }
+);
+
+watch(
+  () => [props.bomInputQty, props.row?.bomInputQty],
+  () => {
+    if (!props.isShow) return;
+    if (props.isEdit) {
+      applyBomInputWeight();
+      return;
+    }
+    if (formData.otherData.inputWeight === undefined || formData.otherData.inputWeight === null || formData.otherData.inputWeight === "") {
+      applyBomInputWeight();
+    }
+  }
+);
 
 const displayValue = (value: any) => {
   return value === undefined || value === null || value === "" ? "-" : value;
@@ -771,7 +820,7 @@
           </td>
         </tr>
         <tr>
-          <td class="label"  colspan="2" rowspan="4">閫犵矑</td>
+          <td class="label"  colspan="2" rowspan="5">閫犵矑</td>
           <td class="label"  colspan="6">
             <span>寮�濮嬫椂闂达細</span>
             <el-date-picker
@@ -836,6 +885,19 @@
           </td>
         </tr>
         <tr>
+          <td colspan="12">
+            <span>鎶曞叆閲嶉噺(KG)锛�</span>
+            <el-input-number
+                v-if="props.isEdit"
+                v-model="formData.otherData.inputWeight"
+                :controls="false"
+                style="width: 100%"
+                placeholder="璇疯緭鍏�"
+            />
+            <span v-else class="view-value">{{ displayValue(formData.otherData.inputWeight) }}</span>
+          </td>
+        </tr>
+        <tr>
           <td class="label" colspan="6">
             <span>浜у嚭鎬绘暟 锛�</span>
             <el-input  v-if="props.isEdit" v-model="formData.quantity" placeholder="璇疯緭鍏�">

--
Gitblit v1.9.3