wujingjing
2024-12-23 dd407c5da58ca201a1fc91af028ace3a6491853b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<template>
    <NodeBasicLayout
        v-model:title="data.title"
        :type="NodeType.Start"
        :description="VueFlowHelper.getConfigValue(data, 'description', '工作流运行的起始节点。')"
    >
        <FieldLayout :title="VueFlowHelper.getConfigValue(varListConfig, 'name', '流程参数')">
            <el-table class="flex-auto" :data="varList" border>
                <el-table-column prop="name" width="170" label="参数名" fixed>
                    <template #default="scope">
                        <el-input v-model="scope.row.name"></el-input>
                    </template>
                </el-table-column>
                <!-- <el-table-column prop="type" width="220" label="类型">
                    <template #default="scope">
                        <el-select v-model="scope.row.type">
                            <el-option
                                v-for="item in Object.keys(parameterTypeMap)"
                                :key="item"
                                :value="item"
                                :label="parameterTypeMap[item]"
                            ></el-option>
                        </el-select>
                    </template>
                </el-table-column> -->
                <el-table-column prop="description" width="380" label="描述">
                    <template #default="scope">
                        <el-input class="nowheel" type="textarea" :autosize="{ minRows: 1, maxRows: 6 }" v-model="scope.row.description"></el-input>
                    </template>
                </el-table-column>
                <!-- <el-table-column prop="isRequired" width="56" label="必填">
                    <template #default="scope">
                        <el-checkbox v-model="scope.row.isRequired"></el-checkbox>
                    </template>
                </el-table-column> -->
 
                <el-table-column label="操作" width="55" fixed="right">
                    <template #default="scope">
                        <el-tooltip effect="dark" content="删除" placement="top">
                            <i
                                class="ywifont ywicon-shanchu !text-[17px] text-red-400 cursor-pointer"
                                @click="handleClickDeleteBtn(scope.$index)"
                            ></i>
                        </el-tooltip>
                    </template>
                </el-table-column>
            </el-table>
            <el-button class="w-fit" type="primary" @click="handleClickAddBtn">添加参数</el-button>
        </FieldLayout>
        <Handle :id="handleId" type="source" :position="Position.Right" />
    </NodeBasicLayout>
</template>
 
<script lang="ts" setup>
import { Handle, Position, useNode, useVueFlow } from '@vue-flow/core';
import { ref } from 'vue';
 
import type { NodeProps } from '@vue-flow/core';
import { VueFlowHelper } from '../../VueFlowHelper';
import { NodeType, parameterTypeMap } from '../../vueFlowEnum';
import { LLMNodeData, LLMNodeEvents } from './index';
 
import NodeBasicLayout from './components/NodeBasicLayout.vue';
import FieldLayout from './components/FieldLayout.vue';
defineProps<NodeProps<LLMNodeData, LLMNodeEvents>>();
const node = useNode();
const handleId = ref(VueFlowHelper.getHandleId(node.node, 'source'));
 
const data = ref(node.node.data);
 
const varList = ref(VueFlowHelper.getFieldValue(data.value, 'var_list'));
 
function handleClickAddBtn() {
    varList.value.push({
        name: '',
        description: '',
        type: '',
        isRequired: true,
    });
}
const varListConfig = ref(VueFlowHelper.getGroupParam(data.value, 0));
 
const varListParam = ref(VueFlowHelper.getParams(varListConfig.value, 'var_list'));
 
VueFlowHelper.getConfigValue(varListParam.value, 'label', '');
 
function handleClickDeleteBtn(index: number) {
    varList.value.splice(index, 1);
}
</script>