|
|
|
@ -8,6 +8,8 @@ |
|
|
|
@node-click="handleNodeClick" |
|
|
|
@node-click="handleNodeClick" |
|
|
|
:default-expand-all="true" |
|
|
|
:default-expand-all="true" |
|
|
|
:expand-on-click-node="false" |
|
|
|
:expand-on-click-node="false" |
|
|
|
|
|
|
|
node-key="id" |
|
|
|
|
|
|
|
ref="tree" |
|
|
|
/> |
|
|
|
/> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="process-right" v-loading="treeLoading"> |
|
|
|
<div class="process-right" v-loading="treeLoading"> |
|
|
|
@ -885,7 +887,11 @@ export default { |
|
|
|
.then(res => { |
|
|
|
.then(res => { |
|
|
|
this.treeLoading = false; |
|
|
|
this.treeLoading = false; |
|
|
|
this.data = this.transformCraftTree(res.data.data); |
|
|
|
this.data = this.transformCraftTree(res.data.data); |
|
|
|
this.calculateTableHeight(); |
|
|
|
// this.calculateTableHeight(); |
|
|
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
|
|
this.autoSelectFirstProcess(); |
|
|
|
|
|
|
|
this.calculateTableHeight(); |
|
|
|
|
|
|
|
}); |
|
|
|
this.partInfoData = res.data.data; |
|
|
|
this.partInfoData = res.data.data; |
|
|
|
}) |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
.catch(err => { |
|
|
|
@ -896,9 +902,15 @@ export default { |
|
|
|
transformCraftTree(responseData) { |
|
|
|
transformCraftTree(responseData) { |
|
|
|
const { partInfo, craftList } = responseData; |
|
|
|
const { partInfo, craftList } = responseData; |
|
|
|
const partCode = partInfo?.partCode || '未知零件'; |
|
|
|
const partCode = partInfo?.partCode || '未知零件'; |
|
|
|
|
|
|
|
const generateId = (prefix, id, fallback) => { |
|
|
|
|
|
|
|
return ( |
|
|
|
|
|
|
|
id || `${prefix}_${fallback}_${Date.now()}_${Math.random().toString(36).substr(2, 9)}` |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const tree = [ |
|
|
|
const tree = [ |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
id: generateId('part', partInfo.id, partCode), |
|
|
|
label: partCode, |
|
|
|
label: partCode, |
|
|
|
disabled: true, |
|
|
|
disabled: true, |
|
|
|
rawData: { |
|
|
|
rawData: { |
|
|
|
@ -909,6 +921,7 @@ export default { |
|
|
|
children: (craftList || []).map(craft => { |
|
|
|
children: (craftList || []).map(craft => { |
|
|
|
const { craftInfo, processList = [] } = craft; |
|
|
|
const { craftInfo, processList = [] } = craft; |
|
|
|
return { |
|
|
|
return { |
|
|
|
|
|
|
|
id: generateId('craft', craftInfo.id, craftInfo.craftNo), |
|
|
|
...craft, |
|
|
|
...craft, |
|
|
|
label: `${craftInfo?.reworkOrder || '返工单'}`, |
|
|
|
label: `${craftInfo?.reworkOrder || '返工单'}`, |
|
|
|
rawData: craftInfo, |
|
|
|
rawData: craftInfo, |
|
|
|
@ -921,6 +934,7 @@ export default { |
|
|
|
process.processInfo.name || |
|
|
|
process.processInfo.name || |
|
|
|
process.processInfo.processName || |
|
|
|
process.processInfo.processName || |
|
|
|
'未知工序'; |
|
|
|
'未知工序'; |
|
|
|
|
|
|
|
const ppsNo = process.processInfo.ppsNo || process.processInfo.processNo; |
|
|
|
|
|
|
|
|
|
|
|
// 将 projectList 转为第四级子节点 |
|
|
|
// 将 projectList 转为第四级子节点 |
|
|
|
const projectChildren = (process.projectList || []).map(project => ({ |
|
|
|
const projectChildren = (process.projectList || []).map(project => ({ |
|
|
|
@ -928,9 +942,11 @@ export default { |
|
|
|
label: project.projectName || '未知检验项目', // 👈 显示项目名称 |
|
|
|
label: project.projectName || '未知检验项目', // 👈 显示项目名称 |
|
|
|
disabled: true, // 通常项目不可点击 |
|
|
|
disabled: true, // 通常项目不可点击 |
|
|
|
isProjectNode: true, // 可选:标记类型,便于后续处理 |
|
|
|
isProjectNode: true, // 可选:标记类型,便于后续处理 |
|
|
|
|
|
|
|
id: generateId('project', project.id, project.projectCode), |
|
|
|
})); |
|
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
return { |
|
|
|
return { |
|
|
|
|
|
|
|
id: generateId('process', process.id, process.processNo), |
|
|
|
...process, |
|
|
|
...process, |
|
|
|
label: ppsNo + '-' + ppsName, |
|
|
|
label: ppsNo + '-' + ppsName, |
|
|
|
rawData: { |
|
|
|
rawData: { |
|
|
|
@ -951,8 +967,36 @@ export default { |
|
|
|
}), |
|
|
|
}), |
|
|
|
}, |
|
|
|
}, |
|
|
|
]; |
|
|
|
]; |
|
|
|
|
|
|
|
console.log(tree,'tree'); |
|
|
|
return tree; |
|
|
|
return tree; |
|
|
|
}, |
|
|
|
}, |
|
|
|
|
|
|
|
autoSelectFirstProcess() { |
|
|
|
|
|
|
|
if (!this.data || this.data.length === 0) return; |
|
|
|
|
|
|
|
if(this.data[0].children.length>0){ |
|
|
|
|
|
|
|
let rootNode = this.data[0].children[0]; |
|
|
|
|
|
|
|
this.handleNodeClick(rootNode, { |
|
|
|
|
|
|
|
level: 2, |
|
|
|
|
|
|
|
parent: { |
|
|
|
|
|
|
|
data: null, |
|
|
|
|
|
|
|
isRoot: true, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
this.$nextTick(() => { |
|
|
|
|
|
|
|
if (this.$refs.tree) { |
|
|
|
|
|
|
|
this.$refs.tree.setCurrentKey(rootNode.id); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// const rootNode = this.data[0]; |
|
|
|
|
|
|
|
// this.handleNodeClick(rootNode, { |
|
|
|
|
|
|
|
// level: 1, |
|
|
|
|
|
|
|
// parent: { |
|
|
|
|
|
|
|
// data: null, |
|
|
|
|
|
|
|
// isRoot: true, |
|
|
|
|
|
|
|
// }, |
|
|
|
|
|
|
|
// }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}, |
|
|
|
// 组织树点击 |
|
|
|
// 组织树点击 |
|
|
|
handleNodeClick(nodes, node, self) { |
|
|
|
handleNodeClick(nodes, node, self) { |
|
|
|
if (nodes.disabled) { |
|
|
|
if (nodes.disabled) { |
|
|
|
|