From 3df96271a67d8b9e2092b6f107c50fa88fc42fed Mon Sep 17 00:00:00 2001 From: zhanghao <774378400@qq.com> Date: Thu, 23 Jul 2026 16:50:58 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E5=91=8A=E8=AD=A6?= =?UTF-8?q?=E8=8A=82=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/flow.js | 19 ++- .../components/params/RecognizeNodeParams.vue | 145 +++++++++++------- src/views/flow/config.js | 7 +- 3 files changed, 104 insertions(+), 67 deletions(-) diff --git a/src/utils/flow.js b/src/utils/flow.js index 4fee791..103e613 100644 --- a/src/utils/flow.js +++ b/src/utils/flow.js @@ -372,7 +372,8 @@ export const transformSdAgentNodeData = (source) => { export const transformRecognizeNodeData = (source) => { // 初始化结果对象 const result = { - nodeParams: [] + nodeParams: [], + alarmRules: [] }; // 遍历每一个顶级节点 @@ -387,7 +388,19 @@ export const transformRecognizeNodeData = (source) => { } if (name === 'alarmRules') { - result[name] = children || []; + if (Array.isArray(item.input)) { + result[name] = item.input; + return; + } + + // 兼容旧数据:旧结构把 level/operator/threshold/message + // 作为 alarmRules.children 中的字段描述保存。 + const legacyRule = Object.fromEntries( + (children || []) + .filter(child => ['level', 'operator', 'threshold', 'message'].includes(child.name)) + .map(child => [child.name, child.input]) + ); + result[name] = Object.keys(legacyRule).length ? [legacyRule] : []; return; } @@ -422,4 +435,4 @@ export const transformRecognizeNodeData = (source) => { }); return result; -} \ No newline at end of file +} diff --git a/src/views/flow/components/params/RecognizeNodeParams.vue b/src/views/flow/components/params/RecognizeNodeParams.vue index 5c9f766..8ece251 100644 --- a/src/views/flow/components/params/RecognizeNodeParams.vue +++ b/src/views/flow/components/params/RecognizeNodeParams.vue @@ -44,56 +44,39 @@ -
-
- - - - - - - - - - - - - - - - - - - - - -
+ +
+ + + + + + + + + + + + + + + + + + + +
@@ -127,7 +110,7 @@ import { ref, reactive, watch, nextTick } from 'vue' import { Plus, Minus } from '@element-plus/icons-vue' import FormItemRecursive from '../FormItemRecursive.vue' -import { getInput, transformRecognizeNodeData } from '@/utils/flow' +import { transformRecognizeNodeData } from '@/utils/flow' import { useQuote } from './useQuote.js' const props = defineProps({ @@ -167,6 +150,29 @@ const addFormItem = (e, type) => { // 商道智能体 const RecognizeNodeData = ref({}) +const alarmOperators = [ + { label: '大于(GT)', value: 'GT' }, + { label: '大于等于(GTE)', value: 'GTE' }, + { label: '小于(LT)', value: 'LT' }, + { label: '小于等于(LTE)', value: 'LTE' }, + { label: '等于(EQ)', value: 'EQ' }, + { label: '不等于(NE)', value: 'NE' } +] + +const addAlarmRule = (e) => { + e.stopPropagation() + RecognizeNodeData.value.alarmRules.push({ + level: 1, + operator: 'GTE', + threshold: 0, + message: '' + }) +} + +const deleteAlarmRule = (index) => { + RecognizeNodeData.value.alarmRules.splice(index, 1) +} + const addRecognizeItem = (e) => { e.stopPropagation(); RecognizeNodeData.value.outputParams.push({ name: "", type: "string", input: "" }); @@ -197,7 +203,7 @@ const initData = () => { ...transformedData, outputParams }; - console.log('RecognizeNodeData', RecognizeNodeData.value) + console.log('RecognizeNodeData', JSON.stringify(RecognizeNodeData.value)) } watch( @@ -220,11 +226,18 @@ const validateAndSave = async () => { } const nodeParams = [] - nodeParams.push({ name: "config", type: "input", input: "", children: RecognizeNodeData.value.config, required: true }) - nodeParams.push({ name: "invokeTts", type: "input", input: RecognizeNodeData.value.invokeTts }) - if (RecognizeNodeData.value.invokeTts) { - nodeParams.push({ name: "tts", type: "input", input: "", children: RecognizeNodeData.value.tts }) - } + nodeParams.push(...RecognizeNodeData.value.nodeParams) + nodeParams.push({ + name: "alarmRules", + type: "input", + input: RecognizeNodeData.value.alarmRules.map(({ level, operator, threshold, message }) => ({ + level, + operator, + threshold, + message + })), + disabled: true + }) lf.setProperties(props.data.id, { ...props.data.properties, nodeParams, @@ -324,4 +337,20 @@ defineExpose({ validateAndSave }) cursor: pointer; } } - \ No newline at end of file + +.alarm-rules { + :deep(.el-row) { + flex-wrap: nowrap; + + .el-form-item { + flex: 1; + } + + .el-select, + .el-input, + .el-input-number { + width: 100%; + } + } +} + diff --git a/src/views/flow/config.js b/src/views/flow/config.js index 5ed2307..93ba78a 100644 --- a/src/views/flow/config.js +++ b/src/views/flow/config.js @@ -447,12 +447,7 @@ function handler(params) { nodeParams: [ { name: 'imageUrl', type: "input", input: "", disabled: true }, { name: 'resultName', type: "input", input: "", disabled: true }, - { name: "alarmRules", type: "input", input: "", children: [ - { name: 'level', type: "input", componentType: 'number', max: 3, step: 1, input: 1, disabled: true }, - { name: 'operator', type: "input", input: "", disabled: true }, - { name: 'threshold', type: "input", componentType: 'number', max: 3, step: 1, input: 1, disabled: true }, - { name: 'message', type: "input", input: "", disabled: true }, - ]} + { name: "alarmRules", type: "input", input: [], disabled: true } ], outputParams: [] },