|
|
|
|
@ -27,7 +27,7 @@ |
|
|
|
|
node-key="id" |
|
|
|
|
@node-click="handleNodeClick" |
|
|
|
|
@node-contextmenu="handleNodeRightClick" |
|
|
|
|
:default-expand-all="true" |
|
|
|
|
:default-expand-all="false" |
|
|
|
|
:expand-on-click-node="false" |
|
|
|
|
/> |
|
|
|
|
<div |
|
|
|
|
@ -372,10 +372,6 @@ |
|
|
|
|
placeholder="请输入" |
|
|
|
|
style="width: 100%" |
|
|
|
|
></el-input> |
|
|
|
|
<!-- <el-select v-model="scope.row.tool" placeholder="请选择" clearable filterable> |
|
|
|
|
<el-option label="是" value="1"></el-option> |
|
|
|
|
<el-option label="否" value="2"></el-option> |
|
|
|
|
</el-select> --> |
|
|
|
|
</el-form-item> |
|
|
|
|
</template> |
|
|
|
|
</el-table-column> |
|
|
|
|
@ -585,7 +581,9 @@ export default { |
|
|
|
|
formRules4: { |
|
|
|
|
moldCode: [{ required: true, message: '请输入', trigger: ['change', 'submit'] }], |
|
|
|
|
}, |
|
|
|
|
treeNodes: {}, //选中组织树节点信息 |
|
|
|
|
treeNodes: { |
|
|
|
|
rawData: {}, |
|
|
|
|
}, //选中组织树节点信息 |
|
|
|
|
parentData: {}, //选中父节点的数据 |
|
|
|
|
partInfoData: {}, //零件信息 |
|
|
|
|
tempId: 0, |
|
|
|
|
@ -765,20 +763,48 @@ export default { |
|
|
|
|
getModelDetailList({ Id: this.modelLevel }).then(res => { |
|
|
|
|
const templateData = res.data.data.proDetailVOList; |
|
|
|
|
const existing = [...this.form1.tableData1]; |
|
|
|
|
const baseIndex = existing.length; |
|
|
|
|
|
|
|
|
|
// 将模板中的工序数据映射为表格所需格式 |
|
|
|
|
const mappedData = templateData.map((item, index) => { |
|
|
|
|
// 如果模板中的字段和表格字段一致,可直接使用;否则需转换 |
|
|
|
|
if (item.modelProjectList.length > 0) { |
|
|
|
|
item.modelProjectList = item.modelProjectList.map(project => { |
|
|
|
|
project.id = null; |
|
|
|
|
return project; |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
// ✅ 映射检验项目列表 |
|
|
|
|
const projectList = (item.modelProjectList || []).map(project => ({ |
|
|
|
|
id: null, |
|
|
|
|
trialNo: this.getProcessNo([], index), |
|
|
|
|
projectCode: project.projectCode, |
|
|
|
|
projectName: project.projectName, |
|
|
|
|
projectStandard: project.projectStandard, |
|
|
|
|
projectStandardName: project.projectStandardName, |
|
|
|
|
proHours: project.proHours || 0, |
|
|
|
|
prepareHours: project.prepareHours || 0, |
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
// ✅ 映射量具列表 |
|
|
|
|
const measuringToolList = (item.measuringToolList || []).map(tool => ({ |
|
|
|
|
id: null, |
|
|
|
|
trialNo: this.getProcessNo([], index), |
|
|
|
|
testType: tool.testType, |
|
|
|
|
tool: tool.tool, |
|
|
|
|
toolSize: tool.toolSize, |
|
|
|
|
toolInfo: tool.toolInfo, |
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
// ✅ 映射工装列表 |
|
|
|
|
const moldToolList = (item.moldToolList || []).map(mold => ({ |
|
|
|
|
id: null, |
|
|
|
|
trialNo: this.getProcessNo([], index), |
|
|
|
|
moldCode: mold.moldCode, |
|
|
|
|
moldName: mold.moldName, |
|
|
|
|
isPrint: mold.isPrint, |
|
|
|
|
printNo: mold.printNo, |
|
|
|
|
testFixtureNo: mold.testFixtureNo, |
|
|
|
|
})); |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
id: null, // 新增时通常设为 null |
|
|
|
|
processNo: this.getProcessNo(this.form1.tableData1), // 自动生成工序号 |
|
|
|
|
// processNo: item.processNo, |
|
|
|
|
ppsId: item.ppsId + '', // 假设模板中有 ppsId 或 id |
|
|
|
|
id: null, |
|
|
|
|
_tempId: `temp_${Date.now()}_${index}`, // 临时唯一标识 |
|
|
|
|
processNo: this.getProcessNo(existing, index), |
|
|
|
|
ppsId: item.ppsId + '', |
|
|
|
|
processName: item.processName, |
|
|
|
|
caId: item.caId + '', |
|
|
|
|
craftName: item.craftName, |
|
|
|
|
@ -786,34 +812,65 @@ export default { |
|
|
|
|
proHours: item.proHours || '', |
|
|
|
|
setoutHours: item.setoutHours || '', |
|
|
|
|
isMain: item.isMain || '0', |
|
|
|
|
processProjectList: item.modelProjectList || [], |
|
|
|
|
// 其他字段按需补充... |
|
|
|
|
// ✅ 将子数据关联到工序 |
|
|
|
|
processProjectList: projectList, |
|
|
|
|
measuringToolList: measuringToolList, |
|
|
|
|
moldToolList: moldToolList, |
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
// 赋值(方式1)或追加(方式2) |
|
|
|
|
this.form1.tableData1 = [...existing, ...mappedData]; // 追加模式 |
|
|
|
|
|
|
|
|
|
// 追加模式 |
|
|
|
|
this.form1.tableData1 = [...existing, ...mappedData]; |
|
|
|
|
this.modelLevelLoading = false; |
|
|
|
|
let query_ = { |
|
|
|
|
dsPart: this.partInfoData, //零件信息 |
|
|
|
|
craft: this.treeNodes.rawData, //工艺信息 |
|
|
|
|
processList: this.form1.tableData1, //工序集合 |
|
|
|
|
processDeleteIds: this.form1.deleteIds, //删除ids |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
authorizedAccomplish2(query_) |
|
|
|
|
.then(res => { |
|
|
|
|
this.$message.success('保存成功'); |
|
|
|
|
this.craftLoading = false; |
|
|
|
|
this.getDetails(); |
|
|
|
|
}) |
|
|
|
|
.catch(err => { |
|
|
|
|
this.craftLoading = false; |
|
|
|
|
}); |
|
|
|
|
// ✅ 更新左侧树形结构(不调用接口) |
|
|
|
|
this.updateTreeStructure(mappedData); |
|
|
|
|
|
|
|
|
|
// this.$message.success('模板导入成功'); |
|
|
|
|
this.$message.success('模板导入成功,请检查后手动保存'); |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
// ✅ 新增:更新树形结构方法 |
|
|
|
|
updateTreeStructure(mappedData) { |
|
|
|
|
// 1. 更新当前选中节点的 processList |
|
|
|
|
if (this.treeLeave === 2) { |
|
|
|
|
this.treeNodes.processList = this.form1.tableData1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 2. 更新 data 树形结构中对应的工艺节点 |
|
|
|
|
const updateTreeNode = nodes => { |
|
|
|
|
for (let node of nodes) { |
|
|
|
|
if (node.level === 2 && node.id === this.treeNodes.id) { |
|
|
|
|
// 更新工艺节点的 processList |
|
|
|
|
node.processList = this.form1.tableData1; |
|
|
|
|
|
|
|
|
|
// 更新子节点(工序) |
|
|
|
|
node.children = this.form1.tableData1.map(process => ({ |
|
|
|
|
id: process.id || process._tempId || `process_${Date.now()}_${Math.random()}`, |
|
|
|
|
label: process.processName || '未知工序', |
|
|
|
|
level: 3, |
|
|
|
|
rawData: { |
|
|
|
|
processInfo: process, |
|
|
|
|
projectList: process.processProjectList || [], |
|
|
|
|
measuringToolList: process.measuringToolList || [], |
|
|
|
|
moldToolList: process.moldToolList || [], |
|
|
|
|
}, |
|
|
|
|
children: (process.processProjectList || []).map(project => ({ |
|
|
|
|
id: project.id || `project_${Date.now()}_${Math.random()}`, |
|
|
|
|
label: project.projectName || '未知项目', |
|
|
|
|
level: 4, |
|
|
|
|
disabled: true, |
|
|
|
|
rawData: project, |
|
|
|
|
})), |
|
|
|
|
})); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (node.children && node.children.length > 0) { |
|
|
|
|
updateTreeNode(node.children); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
updateTreeNode(this.data); |
|
|
|
|
}, |
|
|
|
|
// 获取零件信息详情数据 |
|
|
|
|
async getDetails() { |
|
|
|
|
this.treeLoading = true; |
|
|
|
|
@ -879,7 +936,7 @@ export default { |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const formatCraftLabel = craftInfo => { |
|
|
|
|
return `${craftInfo.roamNo || '临时工艺'}-${craftInfo.craftNo || '工艺文件'}`; |
|
|
|
|
return `${craftInfo.roamNo || '临时工艺'}-${craftInfo.craftNo || 'C000000'}`; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const tree = [ |
|
|
|
|
@ -1096,9 +1153,9 @@ export default { |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// 获取工序号 |
|
|
|
|
getProcessNo(table) { |
|
|
|
|
const len = table; |
|
|
|
|
let processNo = (len.length + 1) * 5; |
|
|
|
|
getProcessNo(table, index = 0) { |
|
|
|
|
const len = table.length; |
|
|
|
|
let processNo = (len + index + 1) * 5; |
|
|
|
|
|
|
|
|
|
if (processNo.toString().length === 1) { |
|
|
|
|
processNo = '000' + processNo; |
|
|
|
|
@ -1445,7 +1502,11 @@ export default { |
|
|
|
|
.then(res => { |
|
|
|
|
this.$message.success('保存成功'); |
|
|
|
|
this.craftLoading = false; |
|
|
|
|
this.getDetails(); |
|
|
|
|
if (this.treeLeave == 1) { |
|
|
|
|
this.getDetails(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.updateTreeAfterSave(res.data.data); |
|
|
|
|
}) |
|
|
|
|
.catch(err => { |
|
|
|
|
this.craftLoading = false; |
|
|
|
|
@ -1481,7 +1542,12 @@ export default { |
|
|
|
|
saveProcessProjectSave(query_).then(res => { |
|
|
|
|
this.$message.success('保存成功'); |
|
|
|
|
this.craftLoading = false; |
|
|
|
|
this.getDetails(); |
|
|
|
|
// ✅ 更新工序节点下的项目数据 |
|
|
|
|
if (this.treeLeave === 3) { |
|
|
|
|
this.treeNodes.rawData.projectList = this.form2.tableData2; |
|
|
|
|
this.updateTreeNodeProject(); |
|
|
|
|
this.refreshTableData(); // ✅ 刷新右侧表格 |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
@ -1498,7 +1564,12 @@ export default { |
|
|
|
|
saveProcessMeasuringTool(query_).then(res => { |
|
|
|
|
this.$message.success('保存成功'); |
|
|
|
|
this.craftLoading = false; |
|
|
|
|
this.getDetails(); |
|
|
|
|
// ✅ 更新工序节点下的量具数据 |
|
|
|
|
if (this.treeLeave === 3) { |
|
|
|
|
this.treeNodes.rawData.measuringToolList = this.form3.tableData3; |
|
|
|
|
this.updateTreeNodeProject(); |
|
|
|
|
this.refreshTableData(); // ✅ 刷新右侧表格 |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
@ -1515,12 +1586,118 @@ export default { |
|
|
|
|
saveProcessMoldTool(query_).then(res => { |
|
|
|
|
this.$message.success('保存成功'); |
|
|
|
|
this.craftLoading = false; |
|
|
|
|
this.getDetails(); |
|
|
|
|
// ✅ 更新工序节点下的工装数据 |
|
|
|
|
if (this.treeLeave === 3) { |
|
|
|
|
this.treeNodes.rawData.moldToolList = this.form4.tableData4; |
|
|
|
|
this.updateTreeNodeProject(); |
|
|
|
|
this.refreshTableData(); // ✅ 刷新右侧表格 |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
// ✅ 保存后更新树结构(不调用接口) |
|
|
|
|
updateTreeAfterSave(saveData) { |
|
|
|
|
// 1. 更新当前选中节点的 rawData |
|
|
|
|
if (this.treeLeave === 1 && saveData) { |
|
|
|
|
console.log('updateTreeAfterSave', this.treeNodes); |
|
|
|
|
// this.treeNodes.rawData = { ...this.treeNodes.rawData, ...saveData }; |
|
|
|
|
} |
|
|
|
|
if (this.treeLeave === 2 && saveData) { |
|
|
|
|
this.treeNodes.rawData = { ...this.treeNodes.rawData, ...saveData }; |
|
|
|
|
this.treeNodes.processList = this.form1.tableData1; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 2. 更新 data 树形结构中对应的工艺节点 |
|
|
|
|
const updateTreeNode = nodes => { |
|
|
|
|
for (let node of nodes) { |
|
|
|
|
if (node.level === 2 && node.id === this.treeNodes.id) { |
|
|
|
|
// 更新工艺节点信息 |
|
|
|
|
if (saveData) { |
|
|
|
|
node.rawData = { ...node.rawData, ...saveData }; |
|
|
|
|
node.label = `${saveData.roamNo || '临时工艺'}-${saveData.craftNo || '工艺文件'}`; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 更新工序子节点 |
|
|
|
|
node.processList = this.form1.tableData1; |
|
|
|
|
node.children = this.form1.tableData1.map(process => ({ |
|
|
|
|
id: process.id || `process_${Date.now()}_${Math.random()}`, |
|
|
|
|
label: process.processName || '未知工序', |
|
|
|
|
level: 3, |
|
|
|
|
rawData: { |
|
|
|
|
processInfo: process, |
|
|
|
|
projectList: process.processProjectList || [], |
|
|
|
|
measuringToolList: process.measuringToolList || [], |
|
|
|
|
moldToolList: process.moldToolList || [], |
|
|
|
|
}, |
|
|
|
|
children: (process.processProjectList || []).map(project => ({ |
|
|
|
|
id: project.id || `project_${Date.now()}_${Math.random()}`, |
|
|
|
|
label: project.projectName || '未知项目', |
|
|
|
|
level: 4, |
|
|
|
|
disabled: true, |
|
|
|
|
rawData: project, |
|
|
|
|
})), |
|
|
|
|
})); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (node.children && node.children.length > 0) { |
|
|
|
|
updateTreeNode(node.children); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
updateTreeNode(this.data); |
|
|
|
|
|
|
|
|
|
// ✅ 3. 刷新右侧表格数据(从树结构同步) |
|
|
|
|
this.refreshTableData(); |
|
|
|
|
}, |
|
|
|
|
refreshTableData() { |
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
if (this.treeLeave === 2) { |
|
|
|
|
// 工艺节点:刷新工序表格 |
|
|
|
|
this.form1.tableData1 = [...(this.treeNodes.processList || [])]; |
|
|
|
|
} else if (this.treeLeave === 3) { |
|
|
|
|
// 工序节点:刷新项目、量具、工装表格 |
|
|
|
|
const { projectList, measuringToolList, moldToolList } = this.treeNodes.rawData; |
|
|
|
|
this.form2.tableData2 = [...(projectList || [])]; |
|
|
|
|
this.form3.tableData3 = [...(measuringToolList || [])]; |
|
|
|
|
this.form4.tableData4 = [...(moldToolList || [])]; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
// ✅ 更新工序节点下的项目数据 |
|
|
|
|
updateTreeNodeProject() { |
|
|
|
|
const updateTreeNode = nodes => { |
|
|
|
|
for (let node of nodes) { |
|
|
|
|
if (node.level === 3 && node.id === this.treeNodes.id) { |
|
|
|
|
node.rawData = { |
|
|
|
|
...node.rawData, |
|
|
|
|
projectList: this.form2.tableData2, |
|
|
|
|
measuringToolList: this.form3.tableData3, |
|
|
|
|
moldToolList: this.form4.tableData4, |
|
|
|
|
}; |
|
|
|
|
// 更新项目子节点 |
|
|
|
|
node.children = (this.form2.tableData2 || []).map(project => ({ |
|
|
|
|
id: project.id || `project_${Date.now()}_${Math.random()}`, |
|
|
|
|
label: project.projectName || '未知项目', |
|
|
|
|
level: 4, |
|
|
|
|
disabled: true, |
|
|
|
|
rawData: project, |
|
|
|
|
})); |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
if (node.children && node.children.length > 0) { |
|
|
|
|
updateTreeNode(node.children); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
updateTreeNode(this.data); |
|
|
|
|
|
|
|
|
|
// ✅ 刷新右侧表格 |
|
|
|
|
this.refreshTableData(); |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
</script> |
|
|
|
|
|