2
2
import { Close } from " @element-plus/icons-vue" ;
3
3
import { useTaskStore } from " @/store/task.ts" ;
4
4
import { storeToRefs } from " pinia" ;
5
+ import { reactive , ref } from " vue" ;
6
+ import { process } from " @/api" ;
5
7
6
8
const taskStore = useTaskStore ();
7
9
const { tool } = storeToRefs (taskStore );
8
10
9
- const onCancel = () => {
10
- taskStore .close ();
11
- };
12
- const onExecute = () => {
13
- alert (" execute!" );
14
- };
11
+ const argConfig = reactive <
12
+ {
13
+ name : string ;
14
+ description : string ;
15
+ type : string ;
16
+ input : string ;
17
+ }[]
18
+ > ([]);
19
+
20
+ const processConfig = reactive <{
21
+ [key : string ]: string ;
22
+ }>({});
23
+
24
+ interface Response {
25
+ message: string ;
26
+ output: string ;
27
+ error: string ;
28
+ }
29
+
30
+ let res = ref <Response >();
31
+
32
+ for (const [, arg] of tool .value .args .entries ()) {
33
+ argConfig .push (Object .assign (arg , { input: " " }));
34
+ }
35
+
36
+ async function onExecute(id : string , input : typeof argConfig ) {
37
+ for (const [, arg] of input .entries ()) {
38
+ processConfig [arg .name ] = arg .input ;
39
+ }
40
+ console .log (processConfig );
41
+ res .value = (await process (id , processConfig )).data as Response ;
42
+ console .log (res .value );
43
+ }
15
44
16
- // console.log(argCfg.value);
45
+ function onCancel() {
46
+ taskStore .close ();
47
+ }
17
48
</script >
18
49
<template >
19
50
<el-card
@@ -31,28 +62,40 @@ const onExecute = () => {
31
62
<el-form label-position =" top" style =" margin : 20px " >
32
63
<el-descriptions direction =" vertical" :column =" 1" >
33
64
<el-descriptions-item label =" Tool name" >
34
- {{ tool.id + " " + tool. name }}
65
+ {{ tool.name }}
35
66
</el-descriptions-item >
36
67
<el-descriptions-item label =" Tool description" >
37
68
{{ tool.description }}
38
69
</el-descriptions-item >
39
70
</el-descriptions >
40
71
<el-form-item label =" Args" >
41
- <el-table :data =" tool.args " header-cell-class-name =" header-cell-class" >
72
+ <el-table :data =" argConfig " header-cell-class-name =" header-cell-class" >
42
73
<el-table-column prop =" name" label =" Name" />
43
74
<el-table-column prop =" description" label =" Description" />
44
- <el-table-column :prop =" ' '" label =" Input" />
75
+ <el-table-column prop =" input" label =" Input" >
76
+ <template #default =" scope " >
77
+ <el-input
78
+ v-model =" scope.row.input"
79
+ style =" height : 100% ; width : 100% "
80
+ type =" textarea"
81
+ autosize
82
+ placeholder =" Please input"
83
+ />
84
+ </template >
85
+ </el-table-column >
45
86
</el-table >
46
87
</el-form-item >
47
- <el-descriptions direction =" vertical" :column =" 1" >
88
+ <el-descriptions v-if = " res " direction =" vertical" :column =" 1" >
48
89
<el-descriptions-item label =" Result" >
49
- {{ "resutl" }}
90
+ {{ res?.message }}
50
91
</el-descriptions-item >
51
92
</el-descriptions >
52
93
<el-form-item >
53
94
<div style =" width : 100% ; display : flex ; justify-content : space-between " >
54
95
<el-button @click =" onCancel" >Cancel</el-button >
55
- <el-button type =" primary" @click =" onExecute" >Execute </el-button >
96
+ <el-button type =" primary" @click =" onExecute(tool.id, argConfig)"
97
+ >Execute
98
+ </el-button >
56
99
</div >
57
100
</el-form-item >
58
101
</el-form >
0 commit comments