| | |
| | | :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> |
| | |
| | | </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" |
| | |
| | | <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"> |
| | |
| | | <!-- 文本类型 --> |
| | | <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"> |
| | |
| | | <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] || []" |
| | |
| | | <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" /> |
| | |
| | | <!-- 其他类型 --> |
| | | <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"> |
| | |
| | | </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> |
| | |
| | | <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" |
| | |
| | | <!-- 日期类型 --> |
| | | <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]" |
| | |
| | | import { |
| | | productionRecordAdd, |
| | | productionRecordAddSubmit, |
| | | productionRecordEditSubmit, |
| | | } from "@/api/productionManagement/productProcessRoute.js"; |
| | | import { userListNoPage } from "@/api/system/user.js"; |
| | | import { getInfo } from "@/api/login.js"; |
| | |
| | | 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); |
| | |
| | | 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 = { |
| | |
| | | processExplained: "", |
| | | files: [], |
| | | consumables: {}, |
| | | delFileIds: [], // 存储要删除的文件id |
| | | }; |
| | | } |
| | | return form.processInfo[processId]; |
| | |
| | | }; |
| | | |
| | | // 获取消耗品数量,默认为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]; |
| | | }; |
| | | |
| | | // 处理文件预览 |
| | |
| | | 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); |
| | | |
| | |
| | | Authorization: `Bearer ${getToken()}`, |
| | | }, |
| | | }); |
| | | console.log(uploadRes); |
| | | if (uploadRes.code === 200) { |
| | | const tempId = uploadRes.data.tempId; |
| | | // 将tempId存储到file对象中 |
| | |
| | | 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) { |
| | | // 按sourceSort分组参数 |
| | | 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,因为getProcessStructures返回的item.id是bomId |
| | | 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) { |
| | |
| | | |
| | | // 构建请求参数 |
| | | const order = orderList.value.find(item => item.id === form.orderId); |
| | | console.log(order, "order"); |
| | | const submitParams = { |
| | | productOrderId: form.orderId, |
| | | productId: order ? order.productId : null, |
| | |
| | | const processInfo = getProcessInfo(process.processId); |
| | | const paramGroups = form.paramGroups[process.processId] || []; |
| | | const productionProductRouteItemParamDtoList = []; |
| | | |
| | | // 添加参数组 |
| | | paramGroups.forEach((group, index) => { |
| | | Object.entries(group).forEach(([paramId, value]) => { |
| | |
| | | ) |
| | | : 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, |
| | | }); |
| | | } |
| | | }); |
| | |
| | | |
| | | // 添加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({ |
| | |
| | | }); |
| | | } |
| | | }); |
| | | |
| | | 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; |
| | | }); |
| | | } |
| | | } |
| | | }); |
| | | }; |
| | |
| | | loadUsers(); |
| | | getCurrentUser(); |
| | | |
| | | if (data.id) { |
| | | if (form.type === "edit") { |
| | | // 编辑时设置表单数据 |
| | | Object.assign(form, data); |
| | | // 设置orderId |
| | | orderId.value = data.orderId || ""; |
| | | orderId.value = form.orderId || ""; |
| | | // 如果有订单ID,加载工序和参数 |
| | | if (data.orderId) { |
| | | if (form.orderId) { |
| | | // 模拟选择订单的操作,触发数据加载 |
| | | setTimeout(() => { |
| | | handleOrderChange(data.orderId); |
| | | handleOrderChange(form.orderId); |
| | | }, 100); |
| | | } |
| | | } else { |