From 8d48fa86c9096f6bac90e83ed779e5a5b62b0fc7 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期二, 24 三月 2026 18:01:47 +0800
Subject: [PATCH] 生产报工模块
---
src/views/productionManagement/productionReporting/reportingDialog.vue | 219 +++++++++++++++++++++++++++++++++++++++++-------------
1 files changed, 165 insertions(+), 54 deletions(-)
diff --git a/src/views/productionManagement/productionReporting/reportingDialog.vue b/src/views/productionManagement/productionReporting/reportingDialog.vue
index adae305..7e079d9 100644
--- a/src/views/productionManagement/productionReporting/reportingDialog.vue
+++ b/src/views/productionManagement/productionReporting/reportingDialog.vue
@@ -305,10 +305,10 @@
:label="`${item.productName} ${item.model}`"
class="form-item">
<div class="consumable-input-group">
- <el-input-number v-model="getProcessInfo(parseInt(activeProcessId)).consumables[item.id]"
+ <el-input-number v-model="getProcessInfo(parseInt(activeProcessId)).consumables[item.bomId]"
:min="0"
- :model-value="getConsumableValue(parseInt(activeProcessId), item.id)"
- @change="val => getProcessInfo(parseInt(activeProcessId)).consumables[item.id] = val"
+ :model-value="getConsumableValue(parseInt(activeProcessId), item.bomId)"
+ @change="val => getProcessInfo(parseInt(activeProcessId)).consumables[item.bomId] = val"
class="consumable-input" />
<span class="consumable-unit">{{ item.unit }}</span>
</div>
@@ -353,7 +353,7 @@
</div>
<div class="card-body">
<div class="param-grid">
- <el-form-item v-for="param in params"
+ <el-form-item v-for="param in params[activeProcessId] || []"
:key="param.id"
:label="param.paramName"
:label-width="120"
@@ -362,9 +362,10 @@
<template v-if="param.paramType == '1'">
<!-- 鏁板瓧绫诲瀷 -->
<div class="param-input-group">
+ <!-- :precision="getPrecision(param.paramFormat)" -->
<el-input-number v-model="form.paramGroups[activeProcessId][index][param.id]"
controls-position="right"
- :precision="getPrecision(param.paramFormat)"
+ :key="param.id"
class="param-input" />
<span v-if="param.unit && param.unit != '/'"
class="param-unit">
@@ -376,6 +377,7 @@
<!-- 鏂囨湰绫诲瀷 -->
<div class="param-input-group">
<el-input v-model="form.paramGroups[activeProcessId][index][param.id]"
+ :key="param.id"
class="param-input" />
<span v-if="param.unit && param.unit != '/'"
class="param-unit">
@@ -388,6 +390,7 @@
<div class="param-input-group">
<el-select v-model="form.paramGroups[activeProcessId][index][param.id]"
placeholder="璇烽�夋嫨"
+ :key="param.id"
class="param-select"
style="width: 100%">
<el-option v-for="option in dictOptions[param.paramFormat] || []"
@@ -406,6 +409,7 @@
<div class="param-input-group">
<el-date-picker :value-format="param.paramFormat"
:format="param.paramFormat"
+ :key="param.id"
:type="param.paramFormat=='YYYY-MM-DD'?'date':'datetime'"
v-model="form.paramGroups[activeProcessId][index][param.id]"
class="param-input" />
@@ -419,6 +423,7 @@
<!-- 鍏朵粬绫诲瀷 -->
<div class="param-input-group">
<el-input v-model="form.paramGroups[activeProcessId][index][param.id]"
+ :key="param.id"
class="param-input" />
<span v-if="param.unit && param.unit != '/'"
class="param-unit">
@@ -453,7 +458,7 @@
</template>
</el-table-column>
<!-- 鍙傛暟鍒� -->
- <el-table-column v-for="param in params"
+ <el-table-column v-for="param in params[activeProcessId] || []"
:key="param.id"
:min-width="200">
<template #header>
@@ -462,20 +467,23 @@
<template #default="{ row }">
<template v-if="param.paramType == '1'">
<!-- 鏁板瓧绫诲瀷 -->
+ <!-- :precision="getPrecision(param.paramFormat)" -->
<el-input-number v-model="row[param.id]"
controls-position="right"
- :precision="getPrecision(param.paramFormat)"
+ :key="param.id"
class="table-input" />
</template>
<template v-else-if="param.paramType == '2'">
<!-- 鏂囨湰绫诲瀷 -->
<el-input v-model="row[param.id]"
+ :key="param.id"
class="table-input" />
</template>
<template v-else-if="param.paramType == '3'">
<!-- 瀛楀吀绫诲瀷 -->
<el-select v-model="row[param.id]"
placeholder="璇烽�夋嫨"
+ :key="param.id"
class="table-select">
<el-option v-for="option in dictOptions[param.paramFormat] || []"
:key="option.dictValue"
@@ -487,6 +495,7 @@
<!-- 鏃ユ湡绫诲瀷 -->
<el-date-picker :value-format="param.paramFormat"
:format="param.paramFormat"
+ :key="param.id"
width="100%"
:type="param.paramFormat=='YYYY-MM-DD'?'date':'datetime'"
v-model="row[param.id]"
@@ -610,6 +619,7 @@
import {
productionRecordAdd,
productionRecordAddSubmit,
+ productionRecordEditSubmit,
} from "@/api/productionManagement/productProcessRoute.js";
import { userListNoPage } from "@/api/system/user.js";
import { getInfo } from "@/api/login.js";
@@ -623,7 +633,9 @@
const route = useRoute();
const data = route.query.data ? JSON.parse(route.query.data) : {};
- const dialogTitle = computed(() => (data.id ? "缂栬緫鎶ュ伐" : "鏂板鎶ュ伐"));
+ const dialogTitle = computed(() =>
+ form.type === "edit" ? "缂栬緫鎶ュ伐" : "鏂板鎶ュ伐"
+ );
const formRef = ref(null);
const isSubmitting = ref(false);
@@ -656,20 +668,23 @@
const useTableView = ref(false); // 鎺у埗鏄惁浣跨敤琛ㄦ牸瑙嗗浘
const form = reactive({
+ type: data.type || "add",
id: data.id || undefined,
- orderId: data.orderId || "",
+ orderId: data.productOrderId || "",
npsNo: data.npsNo || "",
- teamName: data.teamName || "鐧界彮",
+ teamName: data.schedule || data.teamName || "鐧界彮",
materialCode: data.materialCode || "",
productName: data.productName || "",
- specification: data.specification || "",
- outputVolume: data.outputVolume || 0,
- unqualifiedVolume: data.unqualifiedVolume || 0,
- completedVolume: data.completedVolume || 0,
- createBy: data.createBy || "褰撳墠鐧诲綍浜�",
+ specification: data.productModelName || "",
+ outputVolume: data.totalQuantity || data.outputVolume || 0,
+ unqualifiedVolume: data.scrapQty || data.unqualifiedQuantity || 0,
+ completedVolume: data.quantity || data.completedVolume || 0,
+ createBy: data.createBy || data.postName || "褰撳墠鐧诲綍浜�",
createTime: data.createTime || new Date(),
paramGroups: data.paramGroups || {}, // 瀛樺偍姣忎釜宸ュ簭鐨勫弬鏁扮粍
processInfo: data.processInfo || {}, // 瀛樺偍姣忎釜宸ュ簭鐨勫熀鏈俊鎭�
+ productionProductRouteItemDtoList:
+ data.productionProductRouteItemDtoList || [], // 宸ュ簭淇℃伅
});
const rules = {
@@ -783,6 +798,7 @@
processExplained: "",
files: [],
consumables: {},
+ delFileIds: [], // 瀛樺偍瑕佸垹闄ょ殑鏂囦欢id
};
}
return form.processInfo[processId];
@@ -796,12 +812,12 @@
};
// 鑾峰彇娑堣�楀搧鏁伴噺锛岄粯璁や负0
- const getConsumableValue = (processId, itemId) => {
+ const getConsumableValue = (processId, bomId) => {
const processInfo = getProcessInfo(processId);
- if (!processInfo.consumables[itemId]) {
- processInfo.consumables[itemId] = 0;
+ if (!processInfo.consumables[bomId]) {
+ processInfo.consumables[bomId] = 0;
}
- return processInfo.consumables[itemId];
+ return processInfo.consumables[bomId];
};
// 澶勭悊鏂囦欢棰勮
@@ -848,13 +864,16 @@
const processId = parseInt(activeProcessId.value);
if (processId) {
const processInfo = getProcessInfo(processId);
+ // 璁板綍琚垹闄ょ殑鏂囦欢id锛堝彧鏈夌紪杈戞ā寮忎笅鐨勭幇鏈夋枃浠舵墠闇�瑕佽褰曪級
+ if (file.uid && !file.tempId) {
+ processInfo.delFileIds.push(file.uid);
+ }
processInfo.files = fileList;
}
};
// 澶勭悊鏂囦欢鍙樻洿
const handleFileChange = async (file, fileList) => {
- console.log(file, fileList);
const formData = new FormData();
formData.append("file", file.raw);
@@ -867,7 +886,6 @@
Authorization: `Bearer ${getToken()}`,
},
});
- console.log(uploadRes);
if (uploadRes.code === 200) {
const tempId = uploadRes.data.tempId;
// 灏唗empId瀛樺偍鍒癴ile瀵硅薄涓�
@@ -905,16 +923,79 @@
p => p.processId === parseInt(processId)
);
if (process) {
- params.value = process.orderRouteItemParaVos || [];
+ params.value[processId] = process.orderRouteItemParaVos || [];
// 鍒濆鍖栧弬鏁扮粍
if (!form.paramGroups[processId]) {
form.paramGroups[processId] = [];
}
+
+ // 妫�鏌ユ槸鍚︽湁缂栬緫鏁版嵁
+ if (
+ form.productionProductRouteItemDtoList &&
+ form.productionProductRouteItemDtoList.length > 0
+ ) {
+ const editProcess = form.productionProductRouteItemDtoList.find(
+ p => p.processId === parseInt(processId)
+ );
+ if (editProcess && editProcess.productionProductRouteItemParamDtoList) {
+ // 鎸塻ourceSort鍒嗙粍鍙傛暟
+ const paramGroups = {};
+ editProcess.productionProductRouteItemParamDtoList.forEach(param => {
+ if (!param.bomId) {
+ // 鍙鐞嗛潪BOM鍙傛暟
+ const sort = param.sourceSort || 1;
+ if (!paramGroups[sort]) {
+ paramGroups[sort] = {};
+ }
+ paramGroups[sort][param.orderItemParamId] = param.paramValue || "";
+ // 濡傛灉鏄瓧鍏哥被鍨嬪弬鏁帮紝鑾峰彇瀛楀吀鏁版嵁
+ if (param.paramType == "3" && param.paramFormat) {
+ getDictOptions(param.paramFormat);
+ }
+ }
+ });
+
+ // 杞崲涓烘暟缁�
+ form.paramGroups[processId] = Object.values(paramGroups);
+
+ // 鍒濆鍖栧伐搴忓熀鏈俊鎭�
+ if (editProcess) {
+ const processInfo = getProcessInfo(parseInt(processId));
+ processInfo.postName = editProcess.postName || "";
+ processInfo.equipmentMalfunction =
+ editProcess.equipmentMalfunction || "";
+ processInfo.equipmentDisposal = editProcess.equipmentDisposal || "";
+ processInfo.id = editProcess.id || "";
+ processInfo.processExplained = editProcess.processExplained || "";
+ // 澶勭悊鏂囦欢
+ if (editProcess.fileList) {
+ processInfo.files = editProcess.fileList.map(file => ({
+ name: file.fileName,
+ url: file.fileUrl,
+ uid: file.id,
+ }));
+ }
+ // 澶勭悊BOM淇℃伅
+ if (editProcess.productionProductRouteItemParamDtoList) {
+ editProcess.productionProductRouteItemParamDtoList.forEach(
+ param => {
+ if (param.bomId) {
+ // 浣跨敤bomId浣滀负key锛屽洜涓篻etProcessStructures杩斿洖鐨刬tem.id鏄痓omId
+ processInfo.consumables[param.bomId] =
+ param.productValue || 0;
+ }
+ }
+ );
+ }
+ }
+ }
+ }
+
// 濡傛灉娌℃湁鍙傛暟缁勶紝娣诲姞涓�涓粯璁ゅ弬鏁扮粍
if (form.paramGroups[processId].length === 0) {
const defaultGroup = {};
- for (const param of params.value) {
+ for (const param of params.value[processId]) {
defaultGroup[param.id] = param.standardValue || "";
// 濡傛灉鏄瓧鍏哥被鍨嬪弬鏁帮紝鑾峰彇瀛楀吀鏁版嵁
if (param.paramType == "3" && param.paramFormat) {
@@ -962,7 +1043,6 @@
// 鏋勫缓璇锋眰鍙傛暟
const order = orderList.value.find(item => item.id === form.orderId);
- console.log(order, "order");
const submitParams = {
productOrderId: form.orderId,
productId: order ? order.productId : null,
@@ -976,7 +1056,6 @@
const processInfo = getProcessInfo(process.processId);
const paramGroups = form.paramGroups[process.processId] || [];
const productionProductRouteItemParamDtoList = [];
-
// 娣诲姞鍙傛暟缁�
paramGroups.forEach((group, index) => {
Object.entries(group).forEach(([paramId, value]) => {
@@ -990,16 +1069,18 @@
)
: null;
if (param) {
+ console.log(param, "param");
productionProductRouteItemParamDtoList.push({
id: parseInt(paramId),
- standardValue: param.standardValue,
- minValue: param.minValue,
- maxValue: param.maxValue,
+ // standardValue: param.standardValue,
+ // minValue: param.minValue,
+ // maxValue: param.maxValue,
productId: param.productId,
- productValue: value,
+ paramValue: value,
+ // productValue: value,
sourceSort: index + 1,
unit: param.unit,
- isRequired: param.isRequired,
+ // isRequired: param.isRequired,
});
}
});
@@ -1007,11 +1088,10 @@
// 娣诲姞BOM淇℃伅
const structures = getProcessStructures(process.processId);
- console.log(structures, "structures");
structures.forEach(structure => {
const consumableValue = getConsumableValue(
process.processId,
- structure.id
+ structure.bomId
);
if (consumableValue > 0) {
productionProductRouteItemParamDtoList.push({
@@ -1023,35 +1103,66 @@
});
}
});
-
+ const fileIds = [];
+ processInfo.files.forEach(file => {
+ if (file.tempId) {
+ fileIds.push(file.tempId);
+ }
+ });
+ console.log(processInfo, "processInfo");
return {
postName: processInfo.postName,
+ id: processInfo.id,
equipmentMalfunction: processInfo.equipmentMalfunction,
equipmentDisposal: processInfo.equipmentDisposal,
processExplained: processInfo.processExplained,
processId: process.processId,
+ delFileIds: [...(processInfo.delFileIds || [])],
productionProductRouteItemParamDtoList,
- files: processInfo.files.map(file => file.tempId || file.uid),
+ // files: processInfo.files.map(file => file.tempId || file.uid),
+ files: fileIds,
};
}),
};
+ console.log(submitParams, "submitParams");
+ isSubmitting.value = false;
// 璋冪敤API杩涜鎻愪氦
- productionRecordAddSubmit(submitParams)
- .then(res => {
- if (res.code === 200) {
- ElMessage.success(data.id ? "淇敼鎴愬姛" : "鏂板鎴愬姛");
- router.back();
- } else {
- ElMessage.error(res.msg || "鎻愪氦澶辫触");
- }
- })
- .catch(error => {
- ElMessage.error("鎻愪氦澶辫触锛岃绋嶅悗閲嶈瘯");
- console.error("鎻愪氦閿欒:", error);
- })
- .finally(() => {
- isSubmitting.value = false;
- });
+ if (form.type === "edit") {
+ submitParams.productMainId = form.id;
+ productionRecordEditSubmit(submitParams)
+ .then(res => {
+ if (res.code === 200) {
+ ElMessage.success(form.type === "edit" ? "淇敼鎴愬姛" : "鏂板鎴愬姛");
+ router.back();
+ } else {
+ ElMessage.error(res.msg || "鎻愪氦澶辫触");
+ }
+ })
+ .catch(error => {
+ ElMessage.error("鎻愪氦澶辫触锛岃绋嶅悗閲嶈瘯");
+ console.error("鎻愪氦閿欒:", error);
+ })
+ .finally(() => {
+ isSubmitting.value = false;
+ });
+ } else {
+ productionRecordAddSubmit(submitParams)
+ .then(res => {
+ if (res.code === 200) {
+ ElMessage.success(form.type === "edit" ? "淇敼鎴愬姛" : "鏂板鎴愬姛");
+ router.back();
+ } else {
+ ElMessage.error(res.msg || "鎻愪氦澶辫触");
+ }
+ })
+ .catch(error => {
+ ElMessage.error("鎻愪氦澶辫触锛岃绋嶅悗閲嶈瘯");
+ console.error("鎻愪氦閿欒:", error);
+ })
+ .finally(() => {
+ isSubmitting.value = false;
+ });
+ }
}
});
};
@@ -1119,16 +1230,16 @@
loadUsers();
getCurrentUser();
- if (data.id) {
+ if (form.type === "edit") {
// 缂栬緫鏃惰缃〃鍗曟暟鎹�
Object.assign(form, data);
// 璁剧疆orderId
- orderId.value = data.orderId || "";
+ orderId.value = form.orderId || "";
// 濡傛灉鏈夎鍗旾D锛屽姞杞藉伐搴忓拰鍙傛暟
- if (data.orderId) {
+ if (form.orderId) {
// 妯℃嫙閫夋嫨璁㈠崟鐨勬搷浣滐紝瑙﹀彂鏁版嵁鍔犺浇
setTimeout(() => {
- handleOrderChange(data.orderId);
+ handleOrderChange(form.orderId);
}, 100);
}
} else {
--
Gitblit v1.9.3