| | |
| | | <i class="ywifont ywicon-ceshi !text-[20px] text-blue-400 cursor-pointer" @click="openChatTest(scope.row)"></i> |
| | | </el-tooltip> |
| | | <el-tooltip effect="dark" content="工作流设计" placement="top"> |
| | | <i class="ywifont ywicon-jiegousheji !text-[15px] text-blue-400 cursor-pointer" @click="gotoFlowDesign(scope.row)"></i> |
| | | <i |
| | | class="ywifont ywicon-jiegousheji !text-[15px] text-blue-400 cursor-pointer" |
| | | @click="gotoFlowDesign(scope.row)" |
| | | ></i> |
| | | </el-tooltip> |
| | | <el-tooltip effect="dark" content="工作流设计" placement="top"> |
| | | <i class="ywifont ywicon-jiegousheji !text-[15px] text-blue-400 cursor-pointer" @click="gotoFlowDesign(scope.row)"></i> |
| | | </el-tooltip> |
| | | |
| | | <el-tooltip effect="dark" content="删除" placement="top"> |
| | | <i |
| | | class="ywifont ywicon-shanchu !text-[17px] text-red-400 cursor-pointer" |
| | |
| | | import AHMContainer from '/@/components/layout/AHMContainer.vue'; |
| | | import LeftTreeByMgr from '/@/components/tree/leftTreeByMgr.vue'; |
| | | import { useQueryTable } from '/@/hooks/useQueryTable'; |
| | | import router from '/@/router'; |
| | | 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'; |
| | | import { gotoRoute } from '/@/utils/route'; |
| | | import router from '/@/router'; |
| | | //#region ====================== 左侧树数据,tree init ====================== |
| | | const leftTreeRef = useCompRef(LeftTreeByMgr); |
| | | const treeLoading = ref(false); |
| | |
| | | //#region ====================== 工作流列表 ====================== |
| | | const workFlowDataLoading = ref(false); |
| | | const isFormulaTableDrag = ref(false); |
| | | const workFlowTableData = ref([]); |
| | | const tree_update_data = ref([]); |
| | | const work_update_data = ref([]); |
| | | const tableData = ref([]); |
| | | //获取场景list |
| | | const initData = async () => { |
| | | const [treeData, workData] = await Promise.all([agentGroupApi.getSceneGroupTreeByPost(), get_workflow_agent_list()]); |
| | | const tree_Data = treeData.groups ?? []; |
| | | const work_Data = workData.values ?? []; |
| | | let result = []; |
| | | let new_tree_Data = []; |
| | | tree_Data.forEach((node, index) => { |
| | | if (node.group_type == OptClassificationMap[classificationEnum.Knowledge]) { |
| | | new_tree_Data.push(node); |
| | | } |
| | | }); |
| | | |
| | | new_tree_Data.forEach((node, index) => { |
| | | node.sampleList = []; |
| | | work_Data.forEach((work, index) => { |
| | | if (node.group_id == work.agent_group) { |
| | | let work_obj = { |
| | | ...work, |
| | | published: work.published, |
| | | create_user: work.create_user, |
| | | create_time: work.create_time, |
| | | prompt: work.supervisor.prompt, |
| | | note: work.note, |
| | | }; |
| | | node.sampleList.push(work_obj); |
| | | } |
| | | }); |
| | | if (node.p_group_id) { |
| | | node.group_name = `${node.group_name} (${node.sampleList.length})`; |
| | | } |
| | | }); |
| | | |
| | | const byParentData = convertListToTree(new_tree_Data, { |
| | | ID: 'group_id', |
| | | ParentID: 'p_group_id', |
| | | Children: 'children', |
| | | }); |
| | | byParentData.forEach((item) => { |
| | | if (item.children && item.children.length > 0) { |
| | | item.children.forEach((child_node) => { |
| | | item.sampleList = item.sampleList.concat(child_node.sampleList); |
| | | }); |
| | | } |
| | | result.push(item); |
| | | |
| | | item.group_name = `${item.group_name} (${item.sampleList.length})`; |
| | | }); |
| | | listLeftData.value = byParentData; |
| | | const firstListTreeNode = byParentData[0]; |
| | | tree_update_data.value = tree_Data; |
| | | work_update_data.value = work_Data; |
| | | const byParent_Data = updateSampleListsAndGroupNames(tree_Data, work_Data); |
| | | listLeftData.value = byParent_Data; |
| | | const firstListTreeNode = byParent_Data[0]; |
| | | tableData.value = firstListTreeNode.sampleList; |
| | | currentNode.value = firstListTreeNode; |
| | | }; |
| | | |
| | | // 删除一条数据 |
| | | const deleteCurrentFormulaRow = (row: any) => { |
| | | ElMessageBox.confirm(`确定删除工作流:【${row.title}】?`, '提示', { |
| | | confirmButtonText: '确定', |
| | |
| | | ElMessage.success('删除工作流成功'); |
| | | const index = tableData.value.findIndex((d) => d.id === row.id); |
| | | tableData.value.splice(index, 1); |
| | | work_update_data.value = work_update_data.value.filter((work) => work.id !== row.id); |
| | | removeDataAndRecalculateGroupNames(tree_update_data.value, work_update_data.value, row.id); |
| | | } else { |
| | | ElMessage.error('删除工作流失败' + (res?.json_msg ? `,${JSON.stringify(res.json_msg)}` : '')); |
| | | } |
| | | }); |
| | | }; |
| | | // 更新树形结构和工作流列表 |
| | | const updateSampleListsAndGroupNames = (tree_Data, work_Data) => { |
| | | let new_tree_Data = []; |
| | | tree_Data.forEach((node, index) => { |
| | | new_tree_Data.push(node); |
| | | }); |
| | | // 为每个节点关联工作流数据 |
| | | new_tree_Data.forEach((node) => { |
| | | node.sampleList = work_Data |
| | | .filter((work) => work.agent_group === node.group_id) |
| | | .map((work) => ({ |
| | | ...work, |
| | | published: work.published, |
| | | create_user: work.create_user, |
| | | create_time: work.create_time, |
| | | prompt: work.supervisor.prompt, |
| | | note: work.note, |
| | | })); |
| | | if (node.p_group_id) { |
| | | node.group_name = node.group_name.replace(/ \([^)]*\)$/, '') + ` (${node.sampleList.length})`; |
| | | } |
| | | }); |
| | | |
| | | const changeExample = (item) => { |
| | | openChatTest(item); |
| | | // 将列表转换为树形结构 |
| | | const byParentData = convertListToTree(new_tree_Data, { |
| | | ID: 'group_id', |
| | | ParentID: 'p_group_id', |
| | | Children: 'children', |
| | | }); |
| | | const updatedByParentData = byParentData.reduce((accumulator, item) => { |
| | | // 处理子节点,累加sampleList |
| | | if (item.children && item.children.length > 0) { |
| | | 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 updatedByParentData; |
| | | }; |
| | | // 插入一条数据时调用 |
| | | const addDataAndRecalculateGroupNames = (new_tree_Data, work_Data, newWorkData) => { |
| | | // 添加新数据到 work_Data |
| | | work_Data.push(newWorkData); |
| | | // 重新计算工作流列表和组名 |
| | | return updateSampleListsAndGroupNames(new_tree_Data, work_Data); |
| | | }; |
| | | // 删除一条数据时调用 |
| | | const removeDataAndRecalculateGroupNames = (new_tree_Data, work_Data, workIdToRemove) => { |
| | | // 过滤掉要删除的数据 |
| | | work_Data = work_Data.filter((work) => work.id !== workIdToRemove); |
| | | // 重新计算工作流列表和组名 |
| | | return updateSampleListsAndGroupNames(new_tree_Data, work_Data); |
| | | }; |
| | | |
| | | //#endregion |
| | |
| | | }; |
| | | |
| | | const updateOpt = (formValue) => { |
| | | console.log('🚀 ~ formValue:', formValue); |
| | | travelTree(tableData.value, (value, index, array) => { |
| | | if (value.group_id === formValue.group_id) { |
| | | if (value.id === formValue.id) { |
| | | array[index] = { |
| | | ...array[index], |
| | | ...formValue, |
| | |
| | | }; |
| | | //新增一条信息 |
| | | const insertOpt = (newData) => { |
| | | tableData.value.unshift({ ...newData }); |
| | | const itemToAdd = { |
| | | ...newData, |
| | | supervisor: { |
| | | ...newData.supervisor, // 保留原有的 supervisor 属性 |
| | | prompt: newData.prompt, // 但确保 prompt 是最新的 |
| | | }, |
| | | }; |
| | | tableData.value.unshift(itemToAdd); |
| | | addDataAndRecalculateGroupNames(tree_update_data.value, work_update_data.value, itemToAdd); |
| | | }; |
| | | //#endregion |
| | | |
| | |
| | | const gotoFlowDesign = (row) => { |
| | | router.push({ |
| | | name: 'FlowApp', |
| | | query:{ |
| | | id:row.id |
| | | } |
| | | query: { |
| | | id: row.id, |
| | | }, |
| | | }); |
| | | }; |
| | | //#endregion |