From 2a92b8a223d4875737b8062d177505263abcb6a3 Mon Sep 17 00:00:00 2001
From: spring <2396852758@qq.com>
Date: 星期四, 21 五月 2026 17:31:50 +0800
Subject: [PATCH] fix: 投入数量编辑不成功,现在投入数量记录参数不能被删除

---
 src/views/productionManagement/workOrder/components/ProductionRecordForm.vue |   23 ++++++++++++++++++-----
 src/views/productionManagement/workOrder/index.vue                           |    8 +++++---
 src/views/productionManagement/productionRecords/index.vue                   |    8 ++++++++
 3 files changed, 31 insertions(+), 8 deletions(-)

diff --git a/src/views/productionManagement/productionRecords/index.vue b/src/views/productionManagement/productionRecords/index.vue
index 7422fa3..13f5d13 100644
--- a/src/views/productionManagement/productionRecords/index.vue
+++ b/src/views/productionManagement/productionRecords/index.vue
@@ -83,6 +83,10 @@
 const { proxy } = getCurrentInstance();
 const { parameter_tyep } = proxy.useDict("parameter_tyep");
 
+/** 绯荤粺鍐呯疆鍙傛暟銆屾姇鍏ラ噸閲忋�嶏紝涓嶅彲缂栬緫銆佸垹闄� */
+const isLockedParam = (row) =>
+  String(row?.parameterItem ?? "").trim() === "鎶曞叆閲嶉噺";
+
 const tableColumn = ref([
   { label: "鍙傛暟缂栫爜", prop: "code" },
   { label: "鍙傛暟椤�", prop: "parameterItem" },
@@ -113,11 +117,13 @@
       {
         name: "缂栬緫",
         type: "text",
+        disabled: (row) => isLockedParam(row),
         clickFun: (row) => showEditModal(row),
       },
       {
         name: "鍒犻櫎",
         type: "text",
+        disabled: (row) => isLockedParam(row),
         clickFun: (row) => handleDeleteRow(row),
       },
     ],
@@ -166,11 +172,13 @@
 };
 
 const showEditModal = (row) => {
+  if (isLockedParam(row)) return;
   record.value = { ...row };
   isShowEditModal.value = true;
 };
 
 const handleDeleteRow = (row) => {
+  if (isLockedParam(row)) return;
   proxy.$modal
     .confirm(`鏄惁纭鍒犻櫎鍙傛暟缂栫爜涓�"${row.code}"鐨勬暟鎹紵`)
     .then(() => del([row.id]))
diff --git a/src/views/productionManagement/workOrder/components/ProductionRecordForm.vue b/src/views/productionManagement/workOrder/components/ProductionRecordForm.vue
index 9ab62b0..10bfc44 100644
--- a/src/views/productionManagement/workOrder/components/ProductionRecordForm.vue
+++ b/src/views/productionManagement/workOrder/components/ProductionRecordForm.vue
@@ -93,13 +93,19 @@
   weightItem.value = Number(((qty * coeff) / 1000).toFixed(4));
 };
 
-/** 闈炴垚鍨嬶細鎶曞叆閲嶉噺鍙栧伐鍗� bomInputQty */
-const syncBomInputWeight = () => {
+/** 闈炴垚鍨嬶細鎶曞叆閲嶉噺鍙栧伐鍗� bomInputQty锛堜粎鍥炴樉锛屼笉瑕嗙洊鐢ㄦ埛宸茬紪杈戠殑鍊硷級 */
+const syncBomInputWeight = (force = false) => {
   if (props.isFormingProcess) return;
   const weightItem = formData.list.find(isInputWeightItem);
   if (!weightItem) return;
   const bom = props.bomInputQty;
   if (bom === null || bom === undefined || Number.isNaN(Number(bom))) {
+    return;
+  }
+  const current = weightItem.value;
+  const isEmpty =
+    current === null || current === undefined || current === "";
+  if (!force && !isEmpty) {
     return;
   }
   weightItem.value = Number(bom);
@@ -113,15 +119,22 @@
   }
 };
 
+const cloneParamList = (list) =>
+  JSON.parse(JSON.stringify(list || []));
+
 const initData = () => {
-  formData.list = props.list || [];
+  formData.list = cloneParamList(props.list);
   formData.list.forEach(item => {
     if (item.value === undefined) {
       item.value = null;
     }
   });
   loadDeviceName();
-  syncInputWeight();
+  if (props.isFormingProcess) {
+    syncFormingInputWeight();
+  } else {
+    syncBomInputWeight(true);
+  }
 };
 
 const submitData = async () => {
@@ -139,7 +152,7 @@
     () => {
       initData();
     },
-    {immediate: true, deep: true}
+    {immediate: true}
 );
 
 watch(
diff --git a/src/views/productionManagement/workOrder/index.vue b/src/views/productionManagement/workOrder/index.vue
index af2c030..7e31c8d 100644
--- a/src/views/productionManagement/workOrder/index.vue
+++ b/src/views/productionManagement/workOrder/index.vue
@@ -598,9 +598,11 @@
     return;
   }
   reportForm.quantity = num;
-  nextTick(() => {
-    productionRecordFormRef.value?.syncInputWeight?.();
-  });
+  if (isFormingProcess.value) {
+    nextTick(() => {
+      productionRecordFormRef.value?.syncInputWeight?.();
+    });
+  }
 };
 
 // 澶勭悊鎶ュ簾鏁伴噺

--
Gitblit v1.9.3