From d1a8061067e21463d8544be8bd840984596ed4a9 Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期四, 02 一月 2025 16:08:42 +0800 Subject: [PATCH] 工作流查看 --- src/views/project/yw/dataManage/workFlowMgr/WorkFlowIndex.vue | 201 +++++++++++++++++++++++++++++++++++++------------- 1 files changed, 148 insertions(+), 53 deletions(-) diff --git a/src/views/project/yw/dataManage/workFlowMgr/WorkFlowIndex.vue b/src/views/project/yw/dataManage/workFlowMgr/WorkFlowIndex.vue index bea9012..79c0890 100644 --- a/src/views/project/yw/dataManage/workFlowMgr/WorkFlowIndex.vue +++ b/src/views/project/yw/dataManage/workFlowMgr/WorkFlowIndex.vue @@ -52,7 +52,9 @@ :data="displayTableData" highlight-current-row > + <el-table-column type="index" label="搴忓彿" width="55" fixed="left" align="center"></el-table-column> <el-table-column prop="title" label="宸ヤ綔娴佸悕绉�" fixed="left" show-overflow-tooltip align="left" /> + <el-table-column prop="prompt" width="280" label="宸ヤ綔娴佹彁绀�" show-overflow-tooltip align="center"> </el-table-column> <el-table-column prop="published" width="120" label="鍙戝竷鐘舵��" show-overflow-tooltip align="center"> <template #default="scope"> @@ -61,10 +63,15 @@ }}</el-tag> </template> </el-table-column> + <el-table-column label="璋冪敤鏂瑰紡" prop="inner_call" width="100" show-overflow-tooltip> + <template #default="scope"> + {{ scope.row.inner_call === 'Y' ? '鍐呴儴' : '澶栭儴' }} + </template> + </el-table-column> <el-table-column prop="create_user" width="100" label="鍒涘缓鑰�" show-overflow-tooltip align="center" /> <el-table-column prop="create_time" width="180" label="鍒涘缓鏃堕棿" show-overflow-tooltip align="center" /> <el-table-column prop="note" width="180" label="璇存槑" show-overflow-tooltip align="center" /> - <el-table-column label="鎿嶄綔" width="120" fixed="right" show-overflow-tooltip align="center"> + <el-table-column label="鎿嶄綔" width="180" fixed="right" show-overflow-tooltip align="center"> <template #default="scope"> <div class="space-x-2.5"> <el-tooltip effect="dark" content="缂栬緫" placement="top"> @@ -77,6 +84,31 @@ <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-yulan !text-[16px] text-blue-400 cursor-pointer" + @click="gotoFlowView(scope.row)" + ></i> + </el-tooltip> + <el-tooltip + effect="dark" + :content="scope.row.published === SupervisorPublished.Y ? '鍙栨秷鍙戝竷' : '鍙戝竷'" + placement="top" + > + <i + class="ywifont !text-[20px] cursor-pointer" + :class="[ + scope.row.published === SupervisorPublished.Y ? 'ywicon-quxiaofabu text-red-400' : 'ywicon-fabu text-blue-400', + ]" + @click=" + publishStatusChange( + scope.row.published === SupervisorPublished.Y ? SupervisorPublished.N : SupervisorPublished.Y, + scope.row.id, + scope.$index + ) + " ></i> </el-tooltip> @@ -127,7 +159,12 @@ import { computed, nextTick, onMounted, ref } from 'vue'; import OptDlg from './optDlg/OptDlg.vue'; import * as agentGroupApi from '/@/api/ai/agentGroup'; -import { check_workflow_agent_validate, delete_workflow_agent, get_workflow_agent_list } from '/@/api/workflow/index'; +import { + check_workflow_agent_validate, + delete_workflow_agent, + get_workflow_agent_list, + publish_workflow_agent, +} from '/@/api/workflow/index'; import Chat from '/@/components/chat/Chat.vue'; import AHMContainer from '/@/components/layout/AHMContainer.vue'; import LeftTreeByMgr from '/@/components/tree/leftTreeByMgr.vue'; @@ -136,7 +173,6 @@ 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); @@ -154,62 +190,23 @@ //#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: '纭畾', @@ -224,14 +221,72 @@ 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 @@ -266,7 +321,15 @@ }; //鏂板涓�鏉′俊鎭� 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 @@ -323,8 +386,40 @@ }, }); }; + +const gotoFlowView = (row) => { + router.push({ + name: 'FlowAppView', + query: { + id: row.id, + }, + }); +}; //#endregion +//#region ====================== 鏀瑰彉鍙戝竷鐘舵�� ====================== +const publishStatusChange = async (published: SupervisorPublished, id, index) => { + const res = await publish_workflow_agent( + { + agent_id: id, + publish: published, + }, + { + loading: false, + } + ); + const origin = published === SupervisorPublished.Y ? SupervisorPublished.N : SupervisorPublished.Y; + const final = res.publish ?? origin; + if (final === origin) { + ElMessage.warning('鎿嶄綔澶辫触' + (res.fail_msg ? `锛�${res.fail_msg}` : '')); + return; + } + + tableData.value[index].published = final; + + published === SupervisorPublished.Y ? ElMessage.success('鍙戝竷鎴愬姛') : ElMessage.info('宸插彇娑堝彂甯�'); +}; +//#endregion onMounted(async () => { initData(); }); -- Gitblit v1.9.3