工艺模块,推送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

@ -109,11 +109,14 @@ export function updateProcessPlan(rooteProdet) {
export function generatePDFs(rooteProdet) { export function generatePDFs(rooteProdet) {
return request({ return request({
url: '/system/route/generatePDFs', url: '/system/route/generatePDFs',
method: 'post', method: 'get',
params: { rooteProdet }, params: { rooteProdet },
responseType: 'blob',
headers:{ 'Content-Type': 'application/json; application/octet-stream'},
}); });
} }
// 获取物料BOM信息后端返回物料BOM信息集合 // 获取物料BOM信息后端返回物料BOM信息集合
export function getBomInfo(materialCode, materialName, productionOrderNo) { export function getBomInfo(materialCode, materialName, productionOrderNo) {
return request({ return request({
@ -130,7 +133,7 @@ export function getBomInfo(materialCode, materialName, productionOrderNo) {
// 新增BOM // 新增BOM
export function addBom(data) { export function addBom(data) {
return request({ return request({
url: '/system/bom', url: '/system/materialbom',
method: 'post', method: 'post',
data: data data: data
}) })
@ -139,7 +142,7 @@ export function addBom(data) {
// 修改BOM // 修改BOM
export function updateBom(data) { export function updateBom(data) {
return request({ return request({
url: '/system/bom', url: '/system/materialbom',
method: 'put', method: 'put',
data: data data: data
}) })
@ -148,7 +151,7 @@ export function updateBom(data) {
// 删除BOM // 删除BOM
export function deleteBom(id) { export function deleteBom(id) {
return request({ return request({
url: '/system/bom/' + id, url: '/system/materialbom/' + id,
method: 'delete' method: 'delete'
}) })
} }

View File

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

View File

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