Trim online variables from workflow selector
This commit is contained in:
+41
-485
@@ -2,28 +2,26 @@
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import {
|
||||
AppWindow,
|
||||
BookOpen,
|
||||
Bot,
|
||||
ChevronDown,
|
||||
ChevronRight,
|
||||
CircleHelp,
|
||||
ClipboardCheck,
|
||||
Code,
|
||||
Combine,
|
||||
Database,
|
||||
FileText,
|
||||
Globe,
|
||||
HelpCircle,
|
||||
LayoutDashboard,
|
||||
LayoutTemplate,
|
||||
ListChecks,
|
||||
MessageSquareText,
|
||||
Play,
|
||||
ArrowDown,
|
||||
ArrowRight,
|
||||
ChatLineRound,
|
||||
Check,
|
||||
Coin,
|
||||
Collection,
|
||||
Connection,
|
||||
Cpu,
|
||||
DataAnalysis,
|
||||
Document,
|
||||
Finished,
|
||||
Guide,
|
||||
Help,
|
||||
Link,
|
||||
MagicStick,
|
||||
Operation,
|
||||
Search,
|
||||
Snowflake,
|
||||
Square,
|
||||
} from '@vben/icons';
|
||||
Switch,
|
||||
VideoPlay,
|
||||
} from '@element-plus/icons-vue';
|
||||
import { $t } from '@vben/locales';
|
||||
|
||||
import { useVueFlow } from '@vue-flow/core';
|
||||
@@ -41,52 +39,29 @@ const collapsedNodes = ref<Set<string>>(new Set());
|
||||
|
||||
// 定义不同节点的图标
|
||||
const icons: any = {
|
||||
start: Play,
|
||||
llm: Bot,
|
||||
http: Globe,
|
||||
code: Code,
|
||||
template: LayoutTemplate,
|
||||
end: Square,
|
||||
db_query: Database,
|
||||
db_insert: Database,
|
||||
db_update: Database,
|
||||
db_delete: Database,
|
||||
db_sql: Database,
|
||||
// 对话流节点
|
||||
question: HelpCircle,
|
||||
choice: ListChecks,
|
||||
message: MessageSquareText,
|
||||
confirm: CircleHelp,
|
||||
// Snowflake Cortex 节点
|
||||
snowflake_cortex_llm: Snowflake,
|
||||
snowflake_cortex_analyst: Snowflake,
|
||||
// 循环节点
|
||||
loop: Play,
|
||||
// 合并节点
|
||||
merge: Combine,
|
||||
// 表单节点
|
||||
form_basic_info: FileText,
|
||||
form_database_design: Database,
|
||||
form_database_create: Database,
|
||||
// 应用节点
|
||||
app_create: AppWindow,
|
||||
app_design: LayoutDashboard,
|
||||
app_settings: LayoutDashboard,
|
||||
app_update: LayoutDashboard,
|
||||
// 仪表盘节点
|
||||
dashboard_basic_info: LayoutDashboard,
|
||||
dashboard_design: LayoutDashboard,
|
||||
dashboard_create: LayoutDashboard,
|
||||
dashboard_publish: LayoutDashboard,
|
||||
// 系统总结节点
|
||||
system_summary: ClipboardCheck,
|
||||
// 子流程节点
|
||||
subflow: Play,
|
||||
// 知识库检索节点
|
||||
knowledge_retrieval: BookOpen,
|
||||
start: VideoPlay,
|
||||
llm: MagicStick,
|
||||
http: Link,
|
||||
code: Cpu,
|
||||
template: Document,
|
||||
end: Finished,
|
||||
db_query: Coin,
|
||||
db_insert: Coin,
|
||||
db_update: Coin,
|
||||
db_delete: Coin,
|
||||
db_sql: Coin,
|
||||
question: Help,
|
||||
choice: Operation,
|
||||
message: ChatLineRound,
|
||||
confirm: Check,
|
||||
snowflake_cortex_llm: DataAnalysis,
|
||||
snowflake_cortex_analyst: DataAnalysis,
|
||||
loop: Switch,
|
||||
merge: Connection,
|
||||
subflow: Guide,
|
||||
knowledge_retrieval: Collection,
|
||||
};
|
||||
|
||||
// 获取当前节点的父循环节点(如果存在)
|
||||
const getParentLoopNode = (nodeId: string) => {
|
||||
const currentNode = nodes.value.find((n) => n.id === nodeId);
|
||||
if (currentNode?.parentNode) {
|
||||
@@ -139,92 +114,6 @@ const availableNodes = computed(() => {
|
||||
|
||||
// 根据节点类型获取输出变量 schema
|
||||
switch (node.type) {
|
||||
case 'app_create': {
|
||||
variables = [
|
||||
{
|
||||
key: 'app_id',
|
||||
label: $t('ai-platform.workflow.editor.variableSelector.appId'),
|
||||
},
|
||||
{
|
||||
key: 'app_code',
|
||||
label: $t('ai-platform.workflow.editor.variableSelector.appCode'),
|
||||
},
|
||||
{
|
||||
key: 'app_name',
|
||||
label: $t('ai-platform.workflow.editor.variableSelector.appName'),
|
||||
},
|
||||
{
|
||||
key: 'success',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.createSuccess',
|
||||
),
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'app_design': {
|
||||
variables = [
|
||||
{
|
||||
key: 'design_content',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.designContent',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'design_title',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.designTitle',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'confirmed',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.isConfirmed',
|
||||
),
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'app_settings': {
|
||||
variables = [
|
||||
{
|
||||
key: 'settings',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.appSettings',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'confirmed',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.isConfirmed',
|
||||
),
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'app_update': {
|
||||
variables = [
|
||||
{
|
||||
key: 'update_success',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.updateSuccess',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'config_id',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.configId',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'update_message',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.updateMessage',
|
||||
),
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'choice': {
|
||||
const choiceVar = node.data.variable_name || 'user_choice';
|
||||
variables = [
|
||||
@@ -280,96 +169,6 @@ const availableNodes = computed(() => {
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'dashboard_basic_info': {
|
||||
variables = [
|
||||
{
|
||||
key: 'dashboard_basic_info',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.dashboardBasicInfo',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'dashboard_name',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.dashboardName',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'dashboard_code',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.dashboardCode',
|
||||
),
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'dashboard_create': {
|
||||
variables = [
|
||||
{
|
||||
key: 'dashboard_id',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.dashboardId',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'dashboard_code',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.dashboardCode',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'page_meta',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.pageMeta',
|
||||
),
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'dashboard_design': {
|
||||
variables = [
|
||||
{
|
||||
key: 'page_config',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.pageConfig',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'design_title',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.designTitle',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'confirmed',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.isConfirmed',
|
||||
),
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'dashboard_publish': {
|
||||
variables = [
|
||||
{
|
||||
key: 'menu_id',
|
||||
label: $t('ai-platform.workflow.editor.variableSelector.menuId'),
|
||||
},
|
||||
{
|
||||
key: 'route_path',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.routePath',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'publish_result',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.publishResult',
|
||||
),
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'db_delete': {
|
||||
const deleteOutputVar = node.data.output_variable || 'delete_result';
|
||||
variables = [
|
||||
@@ -460,205 +259,6 @@ const availableNodes = computed(() => {
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'form_basic_info': {
|
||||
variables = [
|
||||
{
|
||||
key: 'form_basic_info',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.formBasicInfoObj',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'form_name',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.formName',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'form_code',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.formCode',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'form_type',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.formType',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'form_description',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.formDescription',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'form_sort',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.formSort',
|
||||
),
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'form_create': {
|
||||
variables = [
|
||||
{
|
||||
key: 'form_id',
|
||||
label: $t('ai-platform.workflow.editor.variableSelector.formId'),
|
||||
},
|
||||
{
|
||||
key: 'form_code',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.formCode',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'form_meta',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.formMeta',
|
||||
),
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'form_database_create': {
|
||||
variables = [
|
||||
{
|
||||
key: 'creation_result',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.creationResult',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'all_tables_ready',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.allTablesReady',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'created_count',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.createdCount',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'error_count',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.errorCount',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'schema_name',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.schemaName',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'table_name',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.tableName',
|
||||
),
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'form_database_design': {
|
||||
variables = [
|
||||
{
|
||||
key: 'database_design',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.dbDesignObj',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'table_name',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.tableName',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'field_count',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.fieldCount',
|
||||
),
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'form_list_design': {
|
||||
variables = [
|
||||
{
|
||||
key: 'list_config',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.listConfig',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'query_field_count',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.queryFieldCount',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'column_count',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.columnCount',
|
||||
),
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'form_publish': {
|
||||
variables = [
|
||||
{
|
||||
key: 'menu_id',
|
||||
label: $t('ai-platform.workflow.editor.variableSelector.menuId'),
|
||||
},
|
||||
{
|
||||
key: 'route_path',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.routePath',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'publish_result',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.publishResult',
|
||||
),
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'form_ui_design': {
|
||||
variables = [
|
||||
{
|
||||
key: 'form_ui_design',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.formUiDesign',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'form_code',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.formCode',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'field_count',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.fieldCount',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'group_count',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.groupCount',
|
||||
),
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'http': {
|
||||
variables = [
|
||||
{
|
||||
@@ -885,23 +485,6 @@ const availableNodes = computed(() => {
|
||||
),
|
||||
isSystem: true,
|
||||
},
|
||||
{
|
||||
key: 'application_id',
|
||||
label: $t('ai-platform.workflow.editor.variableSelector.appId'),
|
||||
isSystem: true,
|
||||
},
|
||||
{
|
||||
key: 'application_code',
|
||||
label: $t('ai-platform.workflow.editor.variableSelector.appCode'),
|
||||
isSystem: true,
|
||||
},
|
||||
{
|
||||
key: 'form_code',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.formCode',
|
||||
),
|
||||
isSystem: true,
|
||||
},
|
||||
];
|
||||
// 加上自定义变量
|
||||
variables.push(
|
||||
@@ -965,33 +548,6 @@ const availableNodes = computed(() => {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'system_summary': {
|
||||
variables = [
|
||||
{
|
||||
key: 'summary',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.summaryData',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'total_forms',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.totalForms',
|
||||
),
|
||||
},
|
||||
{
|
||||
key: 'has_app',
|
||||
label: $t('ai-platform.workflow.editor.variableSelector.hasApp'),
|
||||
},
|
||||
{
|
||||
key: 'has_dashboard',
|
||||
label: $t(
|
||||
'ai-platform.workflow.editor.variableSelector.hasDashboard',
|
||||
),
|
||||
},
|
||||
];
|
||||
break;
|
||||
}
|
||||
case 'template': {
|
||||
const templateOutputVar =
|
||||
node.data.output_variable || 'template_result';
|
||||
@@ -1107,7 +663,7 @@ const handleSelect = (nodeId: string, variable: string) => {
|
||||
@click="toggleNodeCollapse(node.id)"
|
||||
>
|
||||
<component
|
||||
:is="isNodeCollapsed(node.id) ? ChevronRight : ChevronDown"
|
||||
:is="isNodeCollapsed(node.id) ? ArrowRight : ArrowDown"
|
||||
class="text-muted-foreground size-3 shrink-0"
|
||||
/>
|
||||
<component
|
||||
|
||||
Reference in New Issue
Block a user