Skip to content

Commit 4f5fb87

Browse files
committed
feat(taskConfig): access tool processing api
1 parent 7f7e28b commit 4f5fb87

File tree

2 files changed

+58
-14
lines changed

2 files changed

+58
-14
lines changed

src/api/index.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66

77
// 手动修改 Mock 接口
88
// export * from "./job.ts"
9-
export * from "./mock.ts"
9+
export * from "./mock.ts";
10+
export * from "./qgis.ts";

src/components/taskConfig/index.vue

+56-13
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,49 @@
22
import { Close } from "@element-plus/icons-vue";
33
import { useTaskStore } from "@/store/task.ts";
44
import { storeToRefs } from "pinia";
5+
import { reactive, ref } from "vue";
6+
import { process } from "@/api";
57
68
const taskStore = useTaskStore();
79
const { tool } = storeToRefs(taskStore);
810
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+
}
1544
16-
// console.log(argCfg.value);
45+
function onCancel() {
46+
taskStore.close();
47+
}
1748
</script>
1849
<template>
1950
<el-card
@@ -31,28 +62,40 @@ const onExecute = () => {
3162
<el-form label-position="top" style="margin: 20px">
3263
<el-descriptions direction="vertical" :column="1">
3364
<el-descriptions-item label="Tool name">
34-
{{ tool.id + " " + tool.name }}
65+
{{ tool.name }}
3566
</el-descriptions-item>
3667
<el-descriptions-item label="Tool description">
3768
{{ tool.description }}
3869
</el-descriptions-item>
3970
</el-descriptions>
4071
<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">
4273
<el-table-column prop="name" label="Name" />
4374
<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>
4586
</el-table>
4687
</el-form-item>
47-
<el-descriptions direction="vertical" :column="1">
88+
<el-descriptions v-if="res" direction="vertical" :column="1">
4889
<el-descriptions-item label="Result">
49-
{{ "resutl" }}
90+
{{ res?.message }}
5091
</el-descriptions-item>
5192
</el-descriptions>
5293
<el-form-item>
5394
<div style="width: 100%; display: flex; justify-content: space-between">
5495
<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>
5699
</div>
57100
</el-form-item>
58101
</el-form>

0 commit comments

Comments
 (0)