From 0ff188212d1ce203f8e755a10f6caaad5b5d639c Mon Sep 17 00:00:00 2001
From: liding <756868258@qq.com>
Date: 星期四, 21 五月 2026 15:39:49 +0800
Subject: [PATCH] feat(inventory): 添加成品库存管理功能支持 - 在导入组件中新增 isFinishedProduct 属性以区分成品和半成品 - 修改库存导入接口路径,根据产品类型传递参数标识 - 更新模板下载接口,传入产品类型参数 - 调整记录表格中的来源列,直接使用 recordTypeName 字段显示 - 在导出库存数据时增加产品类型参数过滤 - 为合格库存页面添加成品类型参数配置 - 在记录页面的导出功能中集成产品类型参数传递

---
 src/views/productionManagement/workOrder/components/ProductionRecordForm.vue |  102 ++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 100 insertions(+), 2 deletions(-)

diff --git a/src/views/productionManagement/workOrder/components/ProductionRecordForm.vue b/src/views/productionManagement/workOrder/components/ProductionRecordForm.vue
index 908e637..9ab62b0 100644
--- a/src/views/productionManagement/workOrder/components/ProductionRecordForm.vue
+++ b/src/views/productionManagement/workOrder/components/ProductionRecordForm.vue
@@ -16,6 +16,21 @@
   labelWidth: {
     type: Number,
     default: 120
+  },
+  /** 鏈鐢熶骇鏁伴噺锛堟垚鍨嬪伐搴忕敤浜庤绠楁姇鍏ラ噸閲忥級 */
+  quantity: {
+    type: Number,
+    default: null
+  },
+  /** 褰撳墠宸ュ簭鏄惁涓恒�屾垚鍨嬨�� */
+  isFormingProcess: {
+    type: Boolean,
+    default: false
+  },
+  /** 宸ュ崟 BOM 鎶曞叆閲嶉噺锛岄潪鎴愬瀷宸ュ簭鍥炴樉鍒般�屾姇鍏ラ噸閲忋�� */
+  bomInputQty: {
+    type: Number,
+    default: null
   }
 });
 
@@ -49,6 +64,55 @@
   deviceOptions.value = data;
 };
 
+const normalizeUnit = (unit) => String(unit ?? "").trim().toLowerCase();
+
+const isInputWeightItem = (item) =>
+  String(item?.parameterItem ?? "").includes("鎶曞叆閲嶉噺") &&
+  normalizeUnit(item?.unit) === "kg";
+
+const isBlankCoeffItem = (item) =>
+  String(item?.parameterItem ?? "").includes("鐢熷澂绯绘暟") &&
+  normalizeUnit(item?.unit) === "g";
+
+/** 鎶曞叆閲嶉噺(KG) = 鏈鐢熶骇鏁伴噺 脳 鐢熷澂绯绘暟(g) / 1000 */
+const syncFormingInputWeight = () => {
+  if (!props.isFormingProcess) return;
+  const weightItem = formData.list.find(isInputWeightItem);
+  if (!weightItem) return;
+
+  const qty = Number(props.quantity);
+  const coeffItem = formData.list.find(isBlankCoeffItem);
+  const coeff = coeffItem?.value === null || coeffItem?.value === undefined || coeffItem?.value === ""
+    ? NaN
+    : Number(coeffItem.value);
+
+  if (!Number.isFinite(qty) || qty < 1 || !Number.isFinite(coeff)) {
+    return;
+  }
+
+  weightItem.value = Number(((qty * coeff) / 1000).toFixed(4));
+};
+
+/** 闈炴垚鍨嬶細鎶曞叆閲嶉噺鍙栧伐鍗� bomInputQty */
+const syncBomInputWeight = () => {
+  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;
+  }
+  weightItem.value = Number(bom);
+};
+
+const syncInputWeight = () => {
+  if (props.isFormingProcess) {
+    syncFormingInputWeight();
+  } else {
+    syncBomInputWeight();
+  }
+};
+
 const initData = () => {
   formData.list = props.list || [];
   formData.list.forEach(item => {
@@ -56,7 +120,8 @@
       item.value = null;
     }
   });
-  loadDeviceName()
+  loadDeviceName();
+  syncInputWeight();
 };
 
 const submitData = async () => {
@@ -77,8 +142,41 @@
     {immediate: true, deep: true}
 );
 
+watch(
+    () => [props.quantity, props.isFormingProcess],
+    () => {
+      if (props.isFormingProcess) {
+        syncFormingInputWeight();
+      }
+    }
+);
+
+watch(
+    () => {
+      const coeffItem = formData.list.find(isBlankCoeffItem);
+      return coeffItem?.value;
+    },
+    () => {
+      if (props.isFormingProcess) {
+        syncFormingInputWeight();
+      }
+    }
+);
+
+watch(
+    () => [props.bomInputQty, props.isFormingProcess],
+    () => {
+      if (!props.isFormingProcess) {
+        syncBomInputWeight();
+      }
+    }
+);
+
 defineExpose({
-  submitData
+  submitData,
+  syncFormingInputWeight,
+  syncBomInputWeight,
+  syncInputWeight
 })
 </script>
 

--
Gitblit v1.9.3