|
@@ -1,10 +1,21 @@
|
|
|
<script lang="ts" setup>
|
|
<script lang="ts" setup>
|
|
|
-import { computed } from 'vue'
|
|
|
|
|
|
|
+import { computed, watch } from 'vue'
|
|
|
import VarSelect from '@/nodes/_base/VarSelect.vue'
|
|
import VarSelect from '@/nodes/_base/VarSelect.vue'
|
|
|
import { useSetterModel } from '../_shared/useSetterModel'
|
|
import { useSetterModel } from '../_shared/useSetterModel'
|
|
|
|
|
|
|
|
import type { IterationData } from './index'
|
|
import type { IterationData } from './index'
|
|
|
-import type { NodeVariableType } from '@/nodes/Interface'
|
|
|
|
|
|
|
+import type { NodeVariable, NodeVariableType } from '@/nodes/Interface'
|
|
|
|
|
+
|
|
|
|
|
+const outputsTypeMap = {
|
|
|
|
|
+ string: 'array[string]',
|
|
|
|
|
+ number: 'array[number]',
|
|
|
|
|
+ boolean: 'array[boolean]',
|
|
|
|
|
+ object: 'array[object]',
|
|
|
|
|
+ 'array[string]': 'array[object]',
|
|
|
|
|
+ 'array[number]': 'array[object]',
|
|
|
|
|
+ 'array[boolean]': 'array[object]',
|
|
|
|
|
+ 'array[object]': 'array[object]'
|
|
|
|
|
+}
|
|
|
|
|
|
|
|
const props = defineProps<{
|
|
const props = defineProps<{
|
|
|
data: IterationData
|
|
data: IterationData
|
|
@@ -24,7 +35,10 @@ const formData = useSetterModel<IterationData>(props, emit)
|
|
|
|
|
|
|
|
const inputVar = computed({
|
|
const inputVar = computed({
|
|
|
get() {
|
|
get() {
|
|
|
- return formData.value.variables?.[0]
|
|
|
|
|
|
|
+ return (
|
|
|
|
|
+ formData.value.variables?.[0] ||
|
|
|
|
|
+ ({ value: '', type: '', name: '' } as unknown as NodeVariable)
|
|
|
|
|
+ )
|
|
|
},
|
|
},
|
|
|
set(val) {
|
|
set(val) {
|
|
|
if (val && formData.value.variables?.[0]) {
|
|
if (val && formData.value.variables?.[0]) {
|
|
@@ -35,49 +49,27 @@ const inputVar = computed({
|
|
|
}
|
|
}
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
-const handleInputVarChange = (val: { value: string; type: string }) => {
|
|
|
|
|
- if (inputVar.value) {
|
|
|
|
|
- inputVar.value.value = val.value
|
|
|
|
|
- inputVar.value.type = val.type as NodeVariableType
|
|
|
|
|
- }
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-const outputsTypeMap = {
|
|
|
|
|
- string: 'array[string]',
|
|
|
|
|
- number: 'array[number]',
|
|
|
|
|
- boolean: 'array[boolean]',
|
|
|
|
|
- object: 'array[object]',
|
|
|
|
|
- 'array[string]': 'array[object]',
|
|
|
|
|
- 'array[number]': 'array[object]',
|
|
|
|
|
- 'array[boolean]': 'array[object]',
|
|
|
|
|
- 'array[object]': 'array[object]'
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
-const handleOutputIterationVariableChange = (val: { value: string; type: string }) => {
|
|
|
|
|
- if (formData.value.output_iteration_variable) {
|
|
|
|
|
- formData.value.output_iteration_variable.value = val.value
|
|
|
|
|
- formData.value.output_iteration_variable.type = val.type as NodeVariableType
|
|
|
|
|
- } else {
|
|
|
|
|
- formData.value.output_iteration_variable = {
|
|
|
|
|
- name: '',
|
|
|
|
|
- value: val.value,
|
|
|
|
|
- type: val.type as NodeVariableType
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- // 设置输出变量类型
|
|
|
|
|
- if (formData.value.outputs?.[0]) {
|
|
|
|
|
- formData.value.outputs[0].type = outputsTypeMap[
|
|
|
|
|
- val.type as keyof typeof outputsTypeMap
|
|
|
|
|
- ] as NodeVariableType
|
|
|
|
|
- } else {
|
|
|
|
|
- formData.value.outputs = [
|
|
|
|
|
- {
|
|
|
|
|
- name: 'outputs',
|
|
|
|
|
- type: outputsTypeMap[val.type as keyof typeof outputsTypeMap] as NodeVariableType
|
|
|
|
|
|
|
+watch(
|
|
|
|
|
+ () => formData.value.output_iteration_variable.type,
|
|
|
|
|
+ (val) => {
|
|
|
|
|
+ if (val) {
|
|
|
|
|
+ if (formData.value.outputs?.[0]) {
|
|
|
|
|
+ formData.value.outputs[0].type = outputsTypeMap[
|
|
|
|
|
+ val as keyof typeof outputsTypeMap
|
|
|
|
|
+ ] as NodeVariableType
|
|
|
|
|
+ } else {
|
|
|
|
|
+ formData.value.outputs = [
|
|
|
|
|
+ {
|
|
|
|
|
+ name: 'outputs',
|
|
|
|
|
+ type: outputsTypeMap[val as keyof typeof outputsTypeMap] as NodeVariableType
|
|
|
|
|
+ }
|
|
|
|
|
+ ]
|
|
|
}
|
|
}
|
|
|
- ]
|
|
|
|
|
|
|
+ } else {
|
|
|
|
|
+ formData.value.outputs = []
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
-}
|
|
|
|
|
|
|
+)
|
|
|
</script>
|
|
</script>
|
|
|
|
|
|
|
|
<template>
|
|
<template>
|
|
@@ -87,10 +79,9 @@ const handleOutputIterationVariableChange = (val: { value: string; type: string
|
|
|
<div class="w-full flex items-center justify-between beautify">
|
|
<div class="w-full flex items-center justify-between beautify">
|
|
|
<label class="text-14px font-bold text-gray-700">输入</label>
|
|
<label class="text-14px font-bold text-gray-700">输入</label>
|
|
|
</div>
|
|
</div>
|
|
|
- <!--TODO: 输入变量类型选择-->
|
|
|
|
|
<VarSelect
|
|
<VarSelect
|
|
|
- :model-value="inputVar?.value"
|
|
|
|
|
- @change="handleInputVarChange"
|
|
|
|
|
|
|
+ v-model:model-value="inputVar.value"
|
|
|
|
|
+ v-model:var-type="inputVar.type"
|
|
|
placeholder="请选择输入变量"
|
|
placeholder="请选择输入变量"
|
|
|
/>
|
|
/>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
@@ -99,10 +90,9 @@ const handleOutputIterationVariableChange = (val: { value: string; type: string
|
|
|
<div class="w-full flex items-center justify-between beautify">
|
|
<div class="w-full flex items-center justify-between beautify">
|
|
|
<label class="text-14px font-bold text-gray-700">输出</label>
|
|
<label class="text-14px font-bold text-gray-700">输出</label>
|
|
|
</div>
|
|
</div>
|
|
|
- <!--TODO: 输出变量类型选择 内部迭代节点输出变量-->
|
|
|
|
|
<VarSelect
|
|
<VarSelect
|
|
|
- :model-value="formData?.output_iteration_variable?.value"
|
|
|
|
|
- @change="handleOutputIterationVariableChange"
|
|
|
|
|
|
|
+ v-model:model-value="formData.output_iteration_variable.value"
|
|
|
|
|
+ v-model:var-type="formData.output_iteration_variable.type"
|
|
|
placeholder="请选择输入变量"
|
|
placeholder="请选择输入变量"
|
|
|
/>
|
|
/>
|
|
|
</el-form-item>
|
|
</el-form-item>
|