Skip to content

Commit f9cb0e2

Browse files
committed
refactor: enhance input handling for custom sources in form fields
--bug=1054775 --user=刘瑞斌 【应用编排】MCP调用节点,自定义工具参数建议支持选择数据类型 https://www.tapd.cn/57709429/s/1685483
1 parent c781c11 commit f9cb0e2

File tree

1 file changed

+58
-6
lines changed

1 file changed

+58
-6
lines changed

ui/src/workflow/nodes/mcp-node/index.vue

Lines changed: 58 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,24 @@
9797
</div>
9898
</template>
9999
<el-input
100-
v-if="item.source === 'custom'"
100+
v-if="item.source === 'custom' && item.input_type === 'TextInput'"
101101
v-model="form_data.tool_params[form_data.params_nested][item.label.label]"
102102
/>
103+
<el-input-number
104+
v-else-if="item.source === 'custom' && item.input_type === 'NumberInput'"
105+
v-model="form_data.tool_params[form_data.params_nested][item.label.label]"
106+
/>
107+
<el-switch
108+
v-else-if="item.source === 'custom' && item.input_type === 'SwitchInput'"
109+
v-model="form_data.tool_params[form_data.params_nested][item.label.label]"
110+
/>
111+
<el-input
112+
v-else-if="item.source === 'custom' && item.input_type === 'JsonInput'"
113+
v-model="form_data.tool_params[form_data.params_nested][item.label.label]"
114+
type="textarea"
115+
/>
103116
<NodeCascader
104-
v-else
117+
v-if="item.source === 'referencing'"
105118
ref="nodeCascaderRef2"
106119
:nodeModel="nodeModel"
107120
class="w-full"
@@ -148,11 +161,24 @@
148161
</div>
149162
</template>
150163
<el-input
151-
v-if="item.source === 'custom'"
164+
v-if="item.source === 'custom' && item.input_type === 'TextInput'"
165+
v-model="form_data.tool_params[item.label.label]"
166+
/>
167+
<el-input-number
168+
v-else-if="item.source === 'custom' && item.input_type === 'NumberInput'"
169+
v-model="form_data.tool_params[item.label.label]"
170+
/>
171+
<el-switch
172+
v-else-if="item.source === 'custom' && item.input_type === 'SwitchInput'"
173+
v-model="form_data.tool_params[item.label.label]"
174+
/>
175+
<el-input
176+
v-else-if="item.source === 'custom' && item.input_type === 'JsonInput'"
152177
v-model="form_data.tool_params[item.label.label]"
178+
type="textarea"
153179
/>
154180
<NodeCascader
155-
v-else
181+
v-if="item.source === 'referencing'"
156182
ref="nodeCascaderRef2"
157183
:nodeModel="nodeModel"
158184
class="w-full"
@@ -244,6 +270,19 @@ function changeTool() {
244270
if (params) {
245271
form_data.value.params_nested = item
246272
for (const item2 in params) {
273+
let input_type = 'TextInput'
274+
if (params[item2].type === 'string') {
275+
input_type = 'TextInput'
276+
} else if (params[item2].type === 'number') {
277+
input_type = 'NumberInput'
278+
} else if (params[item2].type === 'boolean') {
279+
input_type = 'SwitchInput'
280+
} else if (params[item2].type === 'array') {
281+
input_type = 'JsonInput'
282+
} else if (params[item2].type === 'object') {
283+
input_type = 'JsonInput'
284+
}
285+
console.log(params[item2])
247286
form_data.value.tool_form_field.push({
248287
field: item2,
249288
label: {
@@ -252,7 +291,7 @@ function changeTool() {
252291
attrs: { tooltip: params[item2].description },
253292
props_info: {}
254293
},
255-
input_type: 'TextInput',
294+
input_type: input_type,
256295
source: 'referencing',
257296
required: args_schema.properties[item].required?.indexOf(item2) !== -1,
258297
props_info: {
@@ -268,6 +307,19 @@ function changeTool() {
268307
}
269308
} else {
270309
form_data.value.params_nested = ''
310+
let input_type = 'TextInput'
311+
if (args_schema.properties[item].type === 'string') {
312+
input_type = 'TextInput'
313+
} else if (args_schema.properties[item].type === 'number') {
314+
input_type = 'NumberInput'
315+
} else if (args_schema.properties[item].type === 'boolean') {
316+
input_type = 'SwitchInput'
317+
} else if (args_schema.properties[item].type === 'array') {
318+
input_type = 'JsonInput'
319+
} else if (args_schema.properties[item].type === 'object') {
320+
input_type = 'JsonInput'
321+
}
322+
console.log(args_schema.properties[item]);
271323
form_data.value.tool_form_field.push({
272324
field: item,
273325
label: {
@@ -276,7 +328,7 @@ function changeTool() {
276328
attrs: { tooltip: args_schema.properties[item].description },
277329
props_info: {}
278330
},
279-
input_type: 'TextInput',
331+
input_type: input_type,
280332
source: 'referencing',
281333
required: args_schema.required?.indexOf(item) !== -1,
282334
props_info: {

0 commit comments

Comments
 (0)