工艺模块,推送bom 推送工艺校验等 :页面完全完善

This commit is contained in:
tzy1042411602 2024-12-27 17:25:48 +08:00
parent 89ebffaf86
commit b4d34c812f
3 changed files with 140 additions and 207 deletions

View File

@ -73,12 +73,12 @@ export function onSave(list) {
data: list,
})
.then((response) => {
return response;
})
.catch((error) => {
console.error('Error saving route:', error);
throw error;
console.error('Error saving route:', error);
throw error;
});
}
@ -109,11 +109,14 @@ export function updateProcessPlan(rooteProdet) {
export function generatePDFs(rooteProdet) {
return request({
url: '/system/route/generatePDFs',
method: 'post',
method: 'get',
params: { rooteProdet },
responseType: 'blob',
headers:{ 'Content-Type': 'application/json; application/octet-stream'},
});
}
// 获取物料BOM信息后端返回物料BOM信息集合
export function getBomInfo(materialCode, materialName, productionOrderNo) {
return request({
@ -121,7 +124,7 @@ export function getBomInfo(materialCode, materialName, productionOrderNo) {
method: 'post',
params: {
materialCode,
materialName,
materialName,
productionOrderNo // 添加生产订单号参数
}
})
@ -130,7 +133,7 @@ export function getBomInfo(materialCode, materialName, productionOrderNo) {
// 新增BOM
export function addBom(data) {
return request({
url: '/system/bom',
url: '/system/materialbom',
method: 'post',
data: data
})
@ -139,7 +142,7 @@ export function addBom(data) {
// 修改BOM
export function updateBom(data) {
return request({
url: '/system/bom',
url: '/system/materialbom',
method: 'put',
data: data
})
@ -148,7 +151,7 @@ export function updateBom(data) {
// 删除BOM
export function deleteBom(id) {
return request({
url: '/system/bom/' + id,
url: '/system/materialbom/' + id,
method: 'delete'
})
}
@ -168,4 +171,4 @@ export function listMaterial(query) {
method: 'get',
params: query
})
}
}

View File

@ -290,7 +290,7 @@ export default {
handleDetail(productionOrderNo) {
//
this.$router.push({
path: '/tool/route', //
path: '/route/route', //
query: { productionOrderNo: productionOrderNo } // query
});
},

View File

@ -42,9 +42,6 @@
v-hasPermi="['system:route:export']">导出
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="info" plain icon="el-icon-refresh" size="mini" @click="refreshAllStock">刷新库存</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="info" plain icon="el-icon-upload2" size="mini" @click="handleImport"
v-hasPermi="['system:details:import']">导入工艺
@ -66,7 +63,7 @@
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="info" plain icon="el-icon-upload" size="mini" @click="generatePDFs"
<el-button type="info" plain icon="el-icon-upload" size="mini" @click="generatePDFs1"
v-hasPermi="['system:details:import']">生成PDF
</el-button>
</el-col>
@ -116,13 +113,9 @@
<el-table-column label="工序号" width="60" align="center" prop="processNo" />
<el-table-column label="工作中心" width="150" align="center">
<template slot-scope="scope">
<el-form-item v-if="scope.row.id < 0 || scope.row.isEdit"
:prop="'routeList.' + scope.$index + '.workCenter'">
<el-select
v-model="scope.row.workCenter"
placeholder="工作中心"
clearable
@change="(val) => handleWorkCenterChange(scope)">
<el-form-item v-if="scope.row.isEdit" :prop="'routeList.' + scope.$index + '.workCenter'">
<el-select v-model="scope.row.workCenter" placeholder="工作中心" clearable
@change="() => handleWorkCenterChange(scope)"> <!-- 修改这里 -->
<el-option label="机一工段" value="机一工段"></el-option>
<el-option label="机二工段" value="机二工段"></el-option>
<el-option label="机三工段" value="机三工段"></el-option>
@ -131,6 +124,7 @@
<el-option label="铆焊工段" value="铆焊工段"></el-option>
<el-option label="电钳工段" value="电钳工段"></el-option>
<el-option label="委外中心" value="委外中心"></el-option>
</el-select>
</el-form-item>
<span v-else>{{ scope.row.workCenter }}</span>
@ -160,13 +154,11 @@
</template>
</el-table-column>
<el-table-column label="工序控制" width="220" align="center">
<!-- 工序控制列 -->
<el-table-column label="工序控制码" width="220" align="center">
<template slot-scope="scope">
<el-form-item v-if="scope.row.id < 0 || scope.row.isEdit"
:prop="'routeList.' + scope.$index + '.processControl'">
<el-select v-model="scope.row.processControl" placeholder="工序控制" clearable
:disabled="isProcessControlDisabled(scope.row, scope.$index)"
@change="handleProcessControlChange(scope.row, scope.$index)">
<el-form-item v-if="scope.row.isEdit" :prop="'routeList.' + scope.$index + '.processControl'">
<el-select v-model="scope.row.processControl" placeholder="请选择工序控制码" clearable>
<el-option label="汇报+免检" value="汇报+免检"></el-option>
<el-option label="委外+质量" value="委外+质量"></el-option>
<el-option label="汇报+质量" value="汇报+质量"></el-option>
@ -368,7 +360,7 @@
<el-row>
<el-col :span="12">
<el-form-item label="工序控制" prop="processControl">
<el-select v-model="form.processControl" placeholder="请选择工序控制" clearable>
<el-select v-model="form.processControl" placeholder="请选择工序控制" clearable>
<el-option label="汇报+免检" value="汇报+免检"></el-option>
<el-option label="委外+质量" value="委外+质量"></el-option>
<el-option label="汇报+质量" value="汇报+质量"></el-option>
@ -589,7 +581,7 @@ import {
addRoute,
updateRoute,
getDistinctProjectCodes,
updateProcessPlan, generatePDFs, updateBom, addBom
updateProcessPlan, generatePDFs, updateBom, addBom, deleteBom
} from "@/api/system/route";
import upload from "svg-sprite-loader/examples/custom-runtime-generator/build/main";
import { getToken } from "../../../utils/auth";
@ -598,6 +590,8 @@ import Bomfrom from './bomfrom'
import { getProcessInfoList, pushRouteBom, onSave, getBomInfo } from "@/api/system/route";
import { listMaterial } from "@/api/system/material";
import axios from 'axios';
export default {
name: "",
components: {
@ -792,25 +786,27 @@ export default {
id: 0,//ID
//
rules: {
workCenter: [
{ required: true, message: "工作中心不能为空", trigger: "blur" }
],
processName: [
{ required: true, message: "工序名称不能为空", trigger: "blur" }
],
//
materialCode: [
{ required: true, message: "物料编码不能为空", trigger: "blur" }
],
materialName: [
{ required: true, message: "物料名称不能为空", trigger: "blur" }
],
material: [
{ required: true, message: "材质不能为空", trigger: "blur" }
],
discWeight: [
{ required: true, message: "单重不能为空", trigger: "blur" }
],
id: [
{ required: true, message: "主键ID不能为空", trigger: "blur" }
],
routeDescription: [
{ required: true, message: "工艺路线描述不能为空", trigger: "blur" }
],
materialCode: [
{ required: true, message: "物料编码不能为空", trigger: "blur" }
],
materialName: [
{ required: true, message: "物料名称不能为空", trigger: "blur" }
],
processControl: [ //
{ required: true, message: "工序控制码不能为空", trigger: "blur" }
],
processName: [ //
{ required: true, message: "工序名称不能为空", trigger: "blur" }
],
activityDuration: [ //
{ required: true, message: "活动时长不能为空", trigger: "blur" }
]
},
bomDialogVisible: false,
bomDialogTitle: '',
@ -880,6 +876,10 @@ export default {
// productionOrderNo
this.setTotalWeight();
this.getList();
// routeDescription
if (newVal) {
this.queryParams.routeDescription = newVal;
}
}
},
mounted() {
@ -897,25 +897,54 @@ export default {
}
},
methods: {
//
handleWorkCenterChange(scope) {
const { row, $index } = scope;
// "+"
if (row.workCenter === '委外中心') {
row.processControl = '委外+质量';
} else {
// "+"
this.setProcessControl(row, $index);
}
},
//
handleProcessControlChange(row, index) {
//
const validControl = this.validateProcessControl(row, index);
if (!validControl.valid) {
this.$message.warning(validControl.message);
//
row.processControl = validControl.correctValue;
const { row } = scope;
const currentIndex = this.form.routeList.findIndex(item => item === row);
//
//
console.log("工作中心变化:", row.workCenter);
},
//
validateProcessControl(row, index) {
//
if (row.workCenter === '委外中心' && row.processControl !== '委外+质量') {
return {
valid: false,
message: '委外中心的工序控制必须为"委外+质量"',
correctValue: '委外+质量'
};
}
if (index > 0) {
const previousRow = this.form.routeList[index - 1];
if (previousRow.workCenter === row.workCenter &&
previousRow.workCenter !== '委外中心' &&
row.processControl !== '汇报+免检') {
return {
valid: false,
message: '与上道工序工作中心相同时,工序控制应为"汇报+免检"',
correctValue: '汇报+免检'
};
}
}
return { valid: true };
},
//
handleRowEdit(scope) {
//
scope.row.originalData = JSON.parse(JSON.stringify(scope.row));
//
this.$set(scope.row, 'isEdit', true);
//
if (scope.row.workCenter === '委外中心') {
this.$set(scope.row, 'processControl', '委外+质量');
}
},
@ -926,39 +955,17 @@ export default {
//
setProcessControl(row, index) {
console.log('进入setProcessControl方法'); //
if (row.workCenter === '委外中心') {
// +
console.log('设置委外+质量'); //
this.$set(row, 'processControl', '委外+质量');
} else if (this.shouldBeAutoFreeInspection(row, index)) {
// +
console.log('设置汇报+免检'); //
this.$set(row, 'processControl', '汇报+免检');
}
},
//
validateProcessControl(row, index) {
//
if (row.workCenter === '委外中心') {
if (row.processControl !== '委外+质量') {
return {
valid: false,
message: '委外中心的工序控制必须为"委外+质量"',
correctValue: '委外+质量'
};
}
return { valid: true };
}
//
if (this.shouldBeAutoFreeInspection(row, index) && row.processControl !== '汇报+免检') {
return {
valid: false,
message: '与上序工作中心相同时,工序控制应为"汇报+免检"',
correctValue: '汇报+免检'
};
}
return { valid: true };
},
//
shouldBeAutoFreeInspection(row, index) {
if (!row.parentId || index === 0 || row.workCenter === '委外中心') {
@ -985,55 +992,7 @@ export default {
/* // 查询单个物料库存
async handleMaterialSelect(materialCode) {
if (!materialCode) return;
//
const row = this.form.routeList.find(item => item.materialCode === materialCode);
if (row) {
this.$set(row, 'loadingStock', true);
}
try {
const response = await listMaterial({
materialCode: materialCode
});
if (response.rows && response.rows.length > 0) {
const material = response.rows[0];
//
if (row) {
this.$set(row, 'stock', material.singleWeight || 0);
}
}
} catch (error) {
console.error('查询库存失败:', error);
this.$message.error('查询库存失败');
} finally {
if (row) {
this.$set(row, 'loadingStock', false);
}
}
},*/
//
//
async refreshAllStock() {
this.loading = true;
try {
const promises = this.form.routeList
.filter(row => row.materialCode) //
.map(row => this.handleMaterialSelect(row.materialCode));
await Promise.all(promises);
this.$message.success('库存刷新完成');
} catch (error) {
console.error('批量刷新库存失败:', error);
this.$message.error('部分库存刷新失败');
} finally {
this.loading = false;
}
},
/** 导入时间按钮操作 */
handleImportTime() {
this.timeUpload.title = "导入时间";
@ -1205,8 +1164,6 @@ export default {
}
});
},
//
@ -1275,11 +1232,9 @@ export default {
const response = await listRoute(this.queryParams);
this.form.routeList = response.rows;
this.total = response.total;
//
await this.refreshAllStock();
} catch (error) {
console.error('获取数据失败:', error);
this.$message.error('数据加载失败');
} finally {
this.loading = false;
}
@ -1409,16 +1364,15 @@ export default {
},
/**推送工艺 */
async pushRouteBom() {
//
const productionOrderNo = this.$route.query.productionOrderNo;
if (!productionOrderNo) {
this.$modal.msgError("未获取到生产订单号,请检查!");
return;
}
try {
//
await this.$confirm(
@ -1430,7 +1384,6 @@ export default {
type: 'warning'
}
);
// loading
const loading = this.$loading({
lock: true,
@ -1438,10 +1391,8 @@ export default {
spinner: 'el-icon-loading',
background: 'rgba(0, 0, 0, 0.7)'
});
//
this.reset();
//
const timeout = 600000; // 10
const timeoutPromise = new Promise((_, reject) => {
@ -1449,17 +1400,29 @@ export default {
reject(new Error('推送操作超时,请检查后台处理状态'));
}, timeout);
});
// API
const response = await Promise.race([
pushRouteBom(productionOrderNo),
timeoutPromise
]);
//
if (response && response.data) {
this.form = response.data;
}
//
const { duplicateRoutes, failedRoutes, successfulRoutes } = response;
//
const duplicateCodes = duplicateRoutes.join(', ');
const failedCodes = failedRoutes.map(route => route.materialCode).join(', ');
const successfulCodes = successfulRoutes.map(route => route.materialCode).join(', ');
//
this.$alert(`
<div><strong>成功 (${successfulRoutes.length}):</strong></div>
<div style="margin-left: 20px;">${successfulCodes || '无'}</div>
<div><strong>失败 (${failedRoutes.length}):</strong></div>
<div style="margin-left: 20px;">${failedCodes || '无'}</div>
<div><strong>重复 (${duplicateRoutes.length}):</strong></div>
<div style="margin-left: 20px;">${duplicateCodes || '无'}</div>
`, '推送完成', {
dangerouslyUseHTMLString: true,
confirmButtonText: '确定'
});
//
await this.getList();
@ -1467,14 +1430,6 @@ export default {
// loading
loading.close();
//
this.$notify({
title: '推送成功',
message: `工艺路线[${productionOrderNo}]推送完成`,
type: 'success',
duration: 5000
});
} catch (error) {
//
console.error('[推送工艺失败]:', error);
@ -1496,7 +1451,7 @@ export default {
this.loading = false;
}
},
/** 更新计划间*/
/** 更新计划<EFBFBD><EFBFBD><EFBFBD>间*/
updateProcessPlan(row) {
//
this.loading = true;
@ -1526,8 +1481,7 @@ export default {
this.loading = false;
});
},
/** 更新计划时间*/
generatePDFs(row) {
generatePDFs1(row) {
//
this.loading = true;
// reset
@ -1539,8 +1493,14 @@ export default {
// API
generatePDFs(rooteProdet)
.then(response => {
//
this.form = response;
let blob = new Blob([response], {type: 'application/zip'})
let url = window.URL.createObjectURL(blob)
const link = document.createElement('a') // a
link.href = url
link.download = rooteProdet+'.zip' //
link.click()
URL.revokeObjectURL(url) //
//
this.$modal.msgSuccess("生成" + rooteProdet + "的PDF 成功 ");
//
@ -1548,8 +1508,8 @@ export default {
})
.catch(error => {
//
this.$modal.msgError("更新,请重试!");
console.error('更新工序计划失败:', error);
this.$modal.msgError("生成PDF失败,请重试!");
console.error('生成PDF失败:', error);
})
.finally(() => {
//
@ -1560,23 +1520,15 @@ export default {
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
this.$refs.form.validate(valid => {
if (valid) {
//
const processControlValid = this.validateAllProcessControls();
if (!processControlValid.valid) {
this.$message.error(processControlValid.message);
return;
}
//
this.buttonLoading = true;
if (this.form.id != null) {
updateRoute(this.form).then(response => {
this.$modal.msgSuccess("修改成功");
this.open = false;
this.getList();
this.reset();
}).finally(() => {
this.buttonLoading = false;
});
@ -1585,28 +1537,17 @@ export default {
this.$modal.msgSuccess("新增成功");
this.open = false;
this.getList();
this.reset();
}).finally(() => {
this.buttonLoading = false;
});
}
} else {
this.$message.error("请填写必填项");
}
});
},
//
validateAllProcessControls() {
for (const row of this.form.routeList) {
if (row.children) {
for (let i = 0; i < row.children.length; i++) {
const validResult = this.validateProcessControl(row.children[i], i);
if (!validResult.valid) {
return validResult;
}
}
}
}
return { valid: true };
},
/** 删除按钮操作 */
handleDelete(scope) {
const ids = [scope.row.id];
@ -1638,7 +1579,7 @@ export default {
this.bomDialogTitle = '新增BOM';
this.bomForm = {
id: undefined,
projectNumber: this.currentMaterial.productionOrderNo, // 使
projectNumber: this.currentMaterial.productionOrderNo, // 使<EFBFBD><EFBFBD>
materialCode: '',
materialName: '',
materialType: '',
@ -1734,17 +1675,6 @@ export default {
this.bomForm.unit = item.classificationName;
}
},
//
handleRowEdit(scope) {
//
scope.row.originalData = JSON.parse(JSON.stringify(scope.row));
//
this.$set(scope.row, 'isEdit', true);
},
//
cancelEdit(scope) {
//
@ -1752,14 +1682,14 @@ export default {
// 退
this.$set(scope.row, 'isEdit', false);
},
//
onSaveRow(scope) {
//
this.loading = true;
//
const row = scope.row;
//
const saveData = {
id: row.id,
parentId: row.parentId,