| | |
| | | import { useCompRef } from '/@/utils/types'; |
| | | import { convertListToTree, debounce, travelTree } from '/@/utils/util'; |
| | | import { SupervisorPublished, supervisorPublishedMap } from '/@/views/project/yw/lowCode/sqlAmis/types'; |
| | | import { OptClassificationMap, classificationEnum } from '/@/views/types/metrics'; |
| | | //#region ====================== 左侧树数据,tree init ====================== |
| | | const leftTreeRef = useCompRef(LeftTreeByMgr); |
| | | const treeLoading = ref(false); |
| | |
| | | const updateSampleListsAndGroupNames = (tree_Data, work_Data) => { |
| | | let new_tree_Data = []; |
| | | tree_Data.forEach((node, index) => { |
| | | if (node.group_type == OptClassificationMap[classificationEnum.Knowledge]) { |
| | | new_tree_Data.push(node); |
| | | } |
| | | new_tree_Data.push(node); |
| | | }); |
| | | // 为每个节点关联工作流数据 |
| | | new_tree_Data.forEach((node) => { |
| | |
| | | ParentID: 'p_group_id', |
| | | Children: 'children', |
| | | }); |
| | | |
| | | // 合并子节点的工作流列表,并更新组名 |
| | | byParentData.forEach((item) => { |
| | | const updatedByParentData = byParentData.reduce((accumulator, item) => { |
| | | // 处理子节点,累加sampleList |
| | | if (item.children && item.children.length > 0) { |
| | | item.sampleList = item.children.reduce((acc, child_node) => acc.concat(child_node.sampleList), []); |
| | | item.children.forEach((child_node) => { |
| | | item.sampleList = item.sampleList.concat(child_node.sampleList); |
| | | }); |
| | | } |
| | | // 移除旧的计数并添加新的计数 |
| | | item.group_name = item.group_name.replace(/ \([^)]*\)$/, '') + ` (${item.sampleList.length})`; |
| | | }); |
| | | // 将当前项添加到累加器中 |
| | | accumulator.push(item); |
| | | // 返回累加器 |
| | | return accumulator; |
| | | }, []); // 初始化累加器为空数组 |
| | | |
| | | return byParentData; |
| | | return updatedByParentData; |
| | | }; |
| | | // 插入一条数据时调用 |
| | | const addDataAndRecalculateGroupNames = (new_tree_Data, work_Data, newWorkData) => { |