diff --git a/src/api/mes/baseStructureBom/types.ts b/src/api/mes/baseStructureBom/types.ts index 3b663b7..fa95f44 100644 --- a/src/api/mes/baseStructureBom/types.ts +++ b/src/api/mes/baseStructureBom/types.ts @@ -233,4 +233,9 @@ export interface BaseStructureBomTreeVO { */ label: string; + /** + * 子集 + */ + children: []; + } diff --git a/src/views/mes/baseStructureBom/index.vue b/src/views/mes/baseStructureBom/index.vue index c86dd58..cfaf9b6 100644 --- a/src/views/mes/baseStructureBom/index.vue +++ b/src/views/mes/baseStructureBom/index.vue @@ -270,13 +270,22 @@ const getTreeSelect = async () => { treeLoading.value = true; loading.value = true; const res = await structureBomTreeSelect(); - // alert(JSON.stringify(res)) - structureBomOptions.value = res.data; + // structureBomOptions.value = res.data; + const initialTree: BaseStructureBomTreeVO = { + id: 1, + parentId: -1, + materialTypeId: 0, + label: "制造BOM结构", + children: res.data + }; + structureBomOptions.value.push(initialTree); if (queryParams.value.parentId === null || queryParams.value.parentId === undefined) { - const topStructureBom = structureBomOptions.value.find(item => item.id === -1); - queryParams.value.parentId = -1; - parentMaterialTypeName.value = topStructureBom.label; + const topStructureBom = structureBomOptions.value.find(item => item.parentId === -1); + if (topStructureBom != null){ + parentMaterialTypeName.value = topStructureBom.label; + } + queryParams.value.parentId = 1; parentParentMaterialTypeName.value = "顶级"; } @@ -305,10 +314,10 @@ const getList = async () => { const handleNodeClick = (data: BaseStructureBomTreeVO) => { queryParams.value.parentId = data.id; parentMaterialTypeName.value = data.label; - if (data.parentId === 0) { + if (data.parentId === -1) { parentParentMaterialTypeName.value = "顶级"; - } else if (data.parentId === -1) { - parentParentMaterialTypeName.value = "BOM结构"; + } else if (data.parentId === 1) { + parentParentMaterialTypeName.value = "制造BOM结构"; } else { const findMaterialType = materialTypeOptions.value.find(item => item.matrialTypeId === data.parentId); parentParentMaterialTypeName.value = findMaterialType.matrialTypeName;