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/VoltageSortingForm.vue | 64 ++++++++++
src/views/productionManagement/workOrder/components/ProductionRecordForm.vue | 102 ++++++++++++++++
src/views/productionManagement/workOrder/index.vue | 28 ++++
src/views/productionManagement/workOrder/components/CopperPrintingForm.vue | 66 ++++++++++
src/views/productionManagement/workOrder/components/GranulationForm.vue | 68 ++++++++++
5 files changed, 319 insertions(+), 9 deletions(-)
diff --git a/src/views/productionManagement/workOrder/components/CopperPrintingForm.vue b/src/views/productionManagement/workOrder/components/CopperPrintingForm.vue
index 0a27bd0..7f8581a 100644
--- a/src/views/productionManagement/workOrder/components/CopperPrintingForm.vue
+++ b/src/views/productionManagement/workOrder/components/CopperPrintingForm.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 dayjs from "dayjs";
import {userListNoPageByTenantId} from "@/api/system/user.js";
import {getDeviceLedger} from "@/api/equipmentManagement/ledger.js";
@@ -22,7 +22,12 @@
row: {
type: Object,
default: () => ({}),
- }
+ },
+ /** 宸ュ崟 BOM 鎶曞叆閲嶉噺锛屽洖鏄惧埌銆屾姇鍏ラ噸閲忋�� */
+ bomInputQty: {
+ type: Number,
+ default: null,
+ },
});
const emits = defineEmits(["update:isShow", "refreshData"]);
@@ -83,6 +88,7 @@
copperFiringTime: undefined, // 鐑ч摐杩涚倝鏃堕棿
steelFiringTime: undefined, // 鐑ч挗鍑虹倝鏃堕棿
weight: undefined, // 閲嶉噺锛坘g/pos锛�
+ inputWeight: undefined, // 鎶曞叆閲嶉噺(KG)
copperSmeltingTemperatureProfile: undefined, // 鐑ч摐娓╁害鏇茬嚎
remark: undefined, // 澶囨敞
}
@@ -183,11 +189,30 @@
});
};
+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;
formData.scrapQty = props.row.scrapQty;
+ if (formData.otherData.inputWeight === undefined || formData.otherData.inputWeight === null || formData.otherData.inputWeight === "") {
+ applyBomInputWeight();
+ }
} else {
const row = props.row;
formData.planQuantity = row.planQuantity
@@ -195,8 +220,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;
@@ -446,6 +495,19 @@
<span v-else class="view-value">{{ displayValue(formData.otherData.steelFiringTime) }}</span>
</td>
</tr>
+ <tr class="report-row report-row--double">
+ <td class="label" colspan="2">鎶曞叆閲嶉噺(KG)</td>
+ <td colspan="19" class="cell-field">
+ <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 class="report-row report-row--triple">
<td class="label" colspan="2">鐑ч摐浜у嚭</td>
<td colspan="5" class="cell-field">
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="璇疯緭鍏�">
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>
diff --git a/src/views/productionManagement/workOrder/components/VoltageSortingForm.vue b/src/views/productionManagement/workOrder/components/VoltageSortingForm.vue
index caa127d..4a9b3f4 100644
--- a/src/views/productionManagement/workOrder/components/VoltageSortingForm.vue
+++ b/src/views/productionManagement/workOrder/components/VoltageSortingForm.vue
@@ -22,7 +22,12 @@
row: {
type: Object,
default: () => ({}),
- }
+ },
+ /** 宸ュ崟 BOM 鎶曞叆閲嶉噺锛屽洖鏄惧埌銆屾姇鍏ラ噸閲忋�� */
+ bomInputQty: {
+ type: Number,
+ default: null,
+ },
});
const emits = defineEmits(["update:isShow", "refreshData"]);
@@ -56,6 +61,7 @@
userId: undefined, // 浣滀笟鍛�
userName: undefined, // 浣滀笟鍛�
exceptionDealResult: undefined, // 寮傚父澶勭悊缁撴灉
+ inputWeight: undefined, // 鎶曞叆閲嶉噺(KG)
}
})
@@ -183,12 +189,31 @@
otherData.quantity = normalizeGearArray(otherData.quantity);
};
+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 || '{}');
initGearArrays();
formData.quantity = props.row.quantity;
formData.scrapQty = props.row.scrapQty;
+ if (formData.otherData.inputWeight === undefined || formData.otherData.inputWeight === null || formData.otherData.inputWeight === "") {
+ applyBomInputWeight();
+ }
} else {
const row = props.row;
formData.planQuantity = row.planQuantity
@@ -198,8 +223,32 @@
formData.productMainId = row.productMainId
initGearArrays();
syncOutputQuantity();
+ 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();
+ }
+ }
+);
watch(
() => formData.otherData.quantity.map((val) => val),
@@ -376,6 +425,19 @@
</td>
</tr>
<tr>
+ <td class="label" colspan="2">鎶曞叆閲嶉噺(KG)</td>
+ <td colspan="16" class="cell-field">
+ <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="2">鏈夋棤宸ョ▼寮傚父</td>
<td colspan="10">
<div v-if="props.isEdit" style="display: flex; align-items: center; width: 100%;">
diff --git a/src/views/productionManagement/workOrder/index.vue b/src/views/productionManagement/workOrder/index.vue
index 1592ffd..af2c030 100644
--- a/src/views/productionManagement/workOrder/index.vue
+++ b/src/views/productionManagement/workOrder/index.vue
@@ -297,6 +297,9 @@
<ProductionRecordForm
ref="productionRecordFormRef"
:list="processParamList"
+ :quantity="reportForm.quantity"
+ :is-forming-process="isFormingProcess"
+ :bom-input-qty="reportBomInputQty"
/>
</el-form>
<template #footer>
@@ -312,6 +315,7 @@
v-model:isShow="copperPrintingFormVisible"
:isEdit="true"
:row="currentReportRowData"
+ :bom-input-qty="reportBomInputQty"
@refreshData="getList"
/>
<VoltageSortingForm
@@ -319,6 +323,7 @@
v-model:isShow="voltageSortingFormVisible"
:isEdit="true"
:row="currentReportRowData"
+ :bom-input-qty="reportBomInputQty"
@refreshData="getList"
/>
<GranulationForm
@@ -326,13 +331,14 @@
v-model:isShow="granulationFormVisible"
:isEdit="true"
:row="currentReportRowData"
+ :bom-input-qty="reportBomInputQty"
@refreshData="getList"
/>
</div>
</template>
<script setup>
-import { onMounted, ref, nextTick } from "vue";
+import { onMounted, ref, nextTick, computed } from "vue";
import { ElMessageBox } from "element-plus";
import dayjs from "dayjs";
import {
@@ -592,6 +598,9 @@
return;
}
reportForm.quantity = num;
+ nextTick(() => {
+ productionRecordFormRef.value?.syncInputWeight?.();
+ });
};
// 澶勭悊鎶ュ簾鏁伴噺
@@ -619,6 +628,20 @@
reportForm.scrapQty = num;
};
const currentReportRowData = ref(null);
+
+const isFormingProcess = computed(
+ () => currentReportRowData.value?.processName === "鎴愬瀷"
+);
+
+const reportBomInputQty = computed(() => {
+ const bom = currentReportRowData.value?.bomInputQty;
+ if (bom === null || bom === undefined || bom === "") {
+ return null;
+ }
+ const n = Number(bom);
+ return Number.isFinite(n) ? n : null;
+});
+
const page = reactive({
current: 1,
size: 100,
@@ -812,6 +835,9 @@
});
reportDialogVisible.value = true;
+ nextTick(() => {
+ productionRecordFormRef.value?.syncInputWeight?.();
+ });
};
const openWorkOrderFiles = (row) => {
--
Gitblit v1.9.3