|
|
@@ -5,6 +5,7 @@ import NodeRuntimeConfig from '@/nodes/_base/NodeRuntimeConfig.vue'
|
|
|
import VarSelect from '@/nodes/_base/VarSelect.vue'
|
|
|
import { useSetterModel } from '../_shared/useSetterModel'
|
|
|
import { useI18n } from '@/composables/useI18n'
|
|
|
+import { filterArrayVariables } from '../utils'
|
|
|
|
|
|
import type { IterationData } from './index'
|
|
|
import type { NodeVariable, NodeVariableType } from '@/nodes/Interface'
|
|
|
@@ -54,20 +55,57 @@ const formData = useSetterModel<IterationData>(props, emit)
|
|
|
|
|
|
const inputVar = computed({
|
|
|
get() {
|
|
|
- return (
|
|
|
- formData.value.variables?.[0] ||
|
|
|
- ({ value: '', type: '', name: '' } as unknown as NodeVariable)
|
|
|
- )
|
|
|
+ return formData.value.variables?.[0]
|
|
|
},
|
|
|
set(val) {
|
|
|
if (val && formData.value.variables?.[0]) {
|
|
|
formData.value.variables[0] = val
|
|
|
} else if (val) {
|
|
|
formData.value.variables = [val]
|
|
|
+ } else {
|
|
|
+ formData.value.variables = []
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+const outputIterationVar = computed({
|
|
|
+ get() {
|
|
|
+ return formData.value.output_iteration_variable
|
|
|
+ },
|
|
|
+ set(val) {
|
|
|
+ formData.value.output_iteration_variable =
|
|
|
+ val || ({ name: '', type: '', value: '' } as unknown as NodeVariable)
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const handleInputVarChange = (val: { value: string; type: NodeVariableType }) => {
|
|
|
+ inputVar.value = {
|
|
|
+ name: 'iteration_input',
|
|
|
+ value: val.value,
|
|
|
+ type: val.type
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const handleInputVarClear = () => {
|
|
|
+ inputVar.value = undefined
|
|
|
+}
|
|
|
+
|
|
|
+const handleOutputIterationVarChange = (val: { value: string; type: NodeVariableType }) => {
|
|
|
+ outputIterationVar.value = {
|
|
|
+ name: '',
|
|
|
+ value: val.value,
|
|
|
+ type: val.type
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+const handleOutputIterationVarClear = () => {
|
|
|
+ outputIterationVar.value = {
|
|
|
+ name: '',
|
|
|
+ value: '',
|
|
|
+ type: ''
|
|
|
+ } as unknown as NodeVariable
|
|
|
+}
|
|
|
+
|
|
|
watch(
|
|
|
() => formData.value.output_iteration_variable?.type,
|
|
|
(val) => {
|
|
|
@@ -99,9 +137,12 @@ watch(
|
|
|
<label class="text-14px font-bold text-gray-700">{{ texts.input }}</label>
|
|
|
</div>
|
|
|
<VarSelect
|
|
|
- v-model:model-value="inputVar.value"
|
|
|
- v-model:var-type="inputVar.type"
|
|
|
+ :model-value="inputVar?.value"
|
|
|
+ :var-type="inputVar?.type"
|
|
|
:placeholder="texts.selectInput"
|
|
|
+ :filter-fn="filterArrayVariables"
|
|
|
+ @change="handleInputVarChange"
|
|
|
+ @clear="handleInputVarClear"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
|
|
|
@@ -110,9 +151,11 @@ watch(
|
|
|
<label class="text-14px font-bold text-gray-700">{{ texts.output }}</label>
|
|
|
</div>
|
|
|
<VarSelect
|
|
|
- v-model:model-value="formData.output_iteration_variable.value"
|
|
|
- v-model:var-type="formData.output_iteration_variable.type"
|
|
|
+ :model-value="outputIterationVar?.value"
|
|
|
+ :var-type="outputIterationVar?.type"
|
|
|
:placeholder="texts.selectInput"
|
|
|
+ @change="handleOutputIterationVarChange"
|
|
|
+ @clear="handleOutputIterationVarClear"
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
|