feat(web): 增加判断节点对不同类型的适配和处理

This commit is contained in:
2025-07-15 23:19:33 +08:00
parent 35c5150a1f
commit 91e6f49342
6 changed files with 71 additions and 30 deletions

View File

@@ -100,6 +100,24 @@ export const generateAllIncomerOutputVariablesFormOptions: (id: string, inputSch
}))
}
type ConditionOperator = string | { label: string, value: string }
const textOperators: ConditionOperator[] = ['equal', 'not_equal', 'is_empty', 'is_not_empty', 'like', 'not_like', 'starts_with', 'ends_with']
const textDefaultOperator: string = 'equal'
const booleanOperators: ConditionOperator[] = [
{label: '为真', value: 'is_true'},
{label: '为假', value: 'is_false'},
]
const booleanDefaultOperator: string = 'is_true'
const numberOperators: ConditionOperator[] = [
'equal',
'not_equal',
{label: '大于', value: 'greater'},
{label: '大于或等于', value: 'greater_equal'},
{label: '小于', value: 'less'},
{label: '小于或等于', value: 'less_equal'},
]
const numberDefaultOperator: string = 'equal'
export const generateAllIncomerOutputVariablesConditions: (id: string, inputSchema: Record<string, Record<string, any>>, nodes: Node[], edges: Edge[], data: any) => Option[] = (id, inputSchema, nodes, edges, data) => {
let optionMap: Record<string, Option[]> = {}
for (const item of getAllIncomerNodeOutputVariables(id, inputSchema, nodes, edges, data)) {
@@ -108,8 +126,34 @@ export const generateAllIncomerOutputVariablesConditions: (id: string, inputSche
}
optionMap[item.group].push({
label: item.name,
type: item.type,
type: 'custom',
name: item.variable,
...(item.type === 'text' ? {
value: {
type: 'input-text',
required: true,
clearable: true,
},
defaultOp: textDefaultOperator,
operators: textOperators,
} : {}),
...(item.type === 'boolean' ? {
value: {
type: 'wrapper',
size: 'none',
},
defaultOp: booleanDefaultOperator,
operators: booleanOperators,
} : {}),
...(item.type === 'number' ? {
value: {
type: 'input-number',
required: true,
clearable: true,
},
defaultOp: numberDefaultOperator,
operators: numberOperators,
} : {}),
})
}
return Object.keys(optionMap)