Эх сурвалжийг харах

feat: 支持人工录入类型规则的工作流显示

- use_entity_value 类型规则显示「人工录入」来源节点
- 添加 manual 类型来源节点支持(图标 ✍️、橙色渐变背景)
- 人工录入类型不显示动作节点,直接连接到输出要素
- 优化 SourceNode 组件,使用 computed 简化标签逻辑
何文松 21 цаг өмнө
parent
commit
fc2b4b185d

+ 21 - 4
frontend/vue-demo/src/components/workflow/RuleWorkflow.vue

@@ -640,8 +640,25 @@ function loadSingleRuleAsWorkflow(rule) {
   let xPos = 50
   const nodeSpacing = 250  // 节点间距
   
-  // 1. 添加来源节点(如果有 inputs)
-  if (rule.inputs && rule.inputs.length > 0) {
+  // 1. 添加来源节点
+  // 对于 use_entity_value(人工录入)类型,添加一个"人工录入"来源节点
+  if (rule.actionType === 'use_entity_value') {
+    newNodes.push({
+      id: sourceId,
+      type: 'source',
+      position: { x: xPos, y },
+      data: {
+        nodeType: 'source',
+        subType: 'manual',
+        label: '人工录入',
+        sourceName: '人工录入',
+        sourceText: '用户手工输入的值'
+      }
+    })
+    lastNodeId = sourceId
+    xPos += nodeSpacing
+  } else if (rule.inputs && rule.inputs.length > 0) {
+    // 其他类型:从 inputs 获取来源
     const input = rule.inputs[0]
     newNodes.push({
       id: sourceId,
@@ -660,8 +677,8 @@ function loadSingleRuleAsWorkflow(rule) {
     xPos += nodeSpacing
   }
   
-  // 2. 添加动作节点(如果不是 quote 类型)
-  if (rule.actionType && rule.actionType !== 'quote') {
+  // 2. 添加动作节点(如果不是 quote 和 use_entity_value 类型)
+  if (rule.actionType && rule.actionType !== 'quote' && rule.actionType !== 'use_entity_value') {
     let prompt = ''
     try {
       prompt = rule.actionConfig ? JSON.parse(rule.actionConfig).prompt : ''

+ 17 - 2
frontend/vue-demo/src/components/workflow/nodes/SourceNode.vue

@@ -11,7 +11,8 @@ const icon = computed(() => {
   const icons = {
     document: '📄',
     attachment: '📎',
-    excerpt: '✂️'
+    excerpt: '✂️',
+    manual: '✍️'
   }
   return icons[props.data.subType] || '📎'
 })
@@ -19,6 +20,16 @@ const icon = computed(() => {
 const nodeClass = computed(() => {
   return `source-node-${props.data.subType || 'attachment'}`
 })
+
+const nodeLabel = computed(() => {
+  const labels = {
+    document: '原文',
+    excerpt: '摘选',
+    attachment: '附件',
+    manual: '人工录入'
+  }
+  return labels[props.data.subType] || '附件'
+})
 </script>
 
 <template>
@@ -27,7 +38,7 @@ const nodeClass = computed(() => {
     
     <div class="node-header">
       <span class="node-icon">{{ icon }}</span>
-      <span class="node-type">{{ data.subType === 'document' ? '原文' : data.subType === 'excerpt' ? '摘选' : '附件' }}</span>
+      <span class="node-type">{{ nodeLabel }}</span>
     </div>
     
     <div class="node-body">
@@ -69,6 +80,10 @@ const nodeClass = computed(() => {
   background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
 }
 
+.source-node-manual {
+  background: linear-gradient(135deg, #ffa726 0%, #fb8c00 100%);
+}
+
 .node-header {
   display: flex;
   align-items: center;