工作流管理相关

This commit is contained in:
2026-08-06 09:31:34 +08:00
parent a951f864f4
commit cb8effc769
4 changed files with 48 additions and 10 deletions
+13 -7
View File
@@ -30,7 +30,7 @@
<!-- 中间VueFlow 画布节点库在画布内 -->
<div class="flow-wrapper">
<NodeLibraryPanel
:node-library-groups="filteredNodeLibraryGroups"
:node-library-groups="nodeLibraryGroups"
:collapsed="nodeLibraryCollapsed"
@update:collapsed="nodeLibraryCollapsed = $event"
@add-node="addNodeFromLibrary"
@@ -108,6 +108,7 @@ import SkillSelector from './component/SkillSelector.vue';
interface NodeData {
label?: string;
nodeCode?: string;
desc?: string;
formConfig?: any[];
modelConfig?: any;
skillName?: string;
@@ -124,10 +125,6 @@ const JUDGE_KEYWORDS = ['判断', 'judge', 'condition', 'if', 'branch', 'gateway
const nodeLibraryGroups = ref<NodeLibraryGroup[]>([]);
const nodeLibraryCollapsed = ref(false);
const filteredNodeLibraryGroups = computed(() => {
return nodeLibraryGroups.value;
});
// 节点配置映射:nodeCode -> 节点配置
const nodeConfigMap = computed(() => {
const map = new Map<
@@ -243,6 +240,11 @@ const onConnect = (connection: Connection) => {
const onNodeClick = (event: { node: Node<NodeData, any, string> }) => {
selectedNode.value = event.node;
// 同步选择器预选项,避免展示上一个节点的模型/技能
const mc = event.node.data?.modelConfig;
selectedModelData.value = mc?.modelName ? { modelName: mc.modelName, modelType: mc.modelType } : null;
const sk = event.node.data?.skillName;
selectedSkillData.value = sk ? { name: sk } : null;
};
const updateSelectedNode = (updatedNode: Node<NodeData, any, string>) => {
@@ -444,6 +446,7 @@ const getNodeLibrary = async () => {
nodeLibraryGroups.value = res.data?.groups || [];
} catch {
nodeLibraryGroups.value = [];
ElMessage.error('节点库加载失败');
}
};
@@ -469,7 +472,7 @@ const addNodeFromLibrary = (nodeCode: string, nodeName: string) => {
id: `node-${++nodeId}`,
type: 'default',
position: { x: spawnX, y: spawnY },
data: { label: nodeName, nodeCode, patchLayout: false },
data: { label: nodeName, nodeCode, desc: '', patchLayout: false },
style: { background: '#fff', border: '2px solid #3b82f6', borderRadius: '8px', padding: '10px 20px' },
},
]);
@@ -547,6 +550,7 @@ const loadWorkflowFromDsl = (dsl: any) => {
data: {
label: n.name || '',
nodeCode: n.nodeCode,
desc: n.desc || '',
formConfig: n.formConfig || null,
modelConfig: n.modelConfig || null,
skillName: n.skillName || null,
@@ -605,14 +609,16 @@ const confirmSaveWorkflow = async () => {
return;
}
const startNode = nodes.value.find((n) => isStartNode(n));
const workflowDsl = {
version: '1.0.0',
startNodeId: nodes.value[0]?.id || '',
startNodeId: startNode?.id || '',
nodes: nodes.value.map((n) => ({
id: n.id,
nodeCode: n.data?.nodeCode || 'unknown',
name: n.data?.label || '',
type: n.type || 'default',
desc: n.data?.desc || null,
skillName: n.data?.skillName || null,
patchLayout: n.data?.patchLayout || false,
config: {