|
@@ -5,42 +5,36 @@ import VarInput from '@/nodes/_base/VarInput.vue'
|
|
|
import VarSelect from '@/nodes/_base/VarSelect.vue'
|
|
import VarSelect from '@/nodes/_base/VarSelect.vue'
|
|
|
import { VARIABLE_TYPE_OPERATORS } from '@/constant'
|
|
import { VARIABLE_TYPE_OPERATORS } from '@/constant'
|
|
|
import { useSetterModel } from '../_shared/useSetterModel'
|
|
import { useSetterModel } from '../_shared/useSetterModel'
|
|
|
|
|
+import { ALLOWED_INPUT_TYPES, filterArrayVariables, type AllowedListInputType } from '../utils'
|
|
|
|
|
|
|
|
import type { ConditionType, NodeVariable, NodeVariableType } from '@/nodes/Interface'
|
|
import type { ConditionType, NodeVariable, NodeVariableType } from '@/nodes/Interface'
|
|
|
import type { ListData } from './index'
|
|
import type { ListData } from './index'
|
|
|
-import type { NodeVar } from '@/types/var'
|
|
|
|
|
|
|
|
|
|
-type AllowedListInputType = 'array[string]' | 'array[number]' | 'array[boolean]' | 'array[file]'
|
|
|
|
|
-
|
|
|
|
|
-type FilterValueType = Extract<ConditionType['varType'], 'string' | 'number' | 'boolean'>
|
|
|
|
|
|
|
+type FilterValueType = Extract<ConditionType['varType'], 'string' | 'number' | 'boolean' | 'object'>
|
|
|
|
|
|
|
|
type OperatorsType = ListData['filter_by']['conditions'][0]['comparison_operator']
|
|
type OperatorsType = ListData['filter_by']['conditions'][0]['comparison_operator']
|
|
|
|
|
|
|
|
-const ALLOWED_INPUT_TYPES: AllowedListInputType[] = [
|
|
|
|
|
- 'array[string]',
|
|
|
|
|
- 'array[number]',
|
|
|
|
|
- 'array[boolean]',
|
|
|
|
|
- 'array[file]'
|
|
|
|
|
-]
|
|
|
|
|
-
|
|
|
|
|
const FILTER_VALUE_TYPE_MAP: Record<AllowedListInputType, FilterValueType> = {
|
|
const FILTER_VALUE_TYPE_MAP: Record<AllowedListInputType, FilterValueType> = {
|
|
|
'array[string]': 'string',
|
|
'array[string]': 'string',
|
|
|
'array[number]': 'number',
|
|
'array[number]': 'number',
|
|
|
'array[boolean]': 'boolean',
|
|
'array[boolean]': 'boolean',
|
|
|
- 'array[file]': 'string'
|
|
|
|
|
|
|
+ 'array[file]': 'string',
|
|
|
|
|
+ 'array[object]': 'object'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const DEFAULT_OPERATOR_MAP: Record<FilterValueType, ConditionType['comparison_operator']> = {
|
|
const DEFAULT_OPERATOR_MAP: Record<FilterValueType, ConditionType['comparison_operator']> = {
|
|
|
string: 'contains',
|
|
string: 'contains',
|
|
|
number: '=',
|
|
number: '=',
|
|
|
- boolean: 'is'
|
|
|
|
|
|
|
+ boolean: 'is',
|
|
|
|
|
+ object: 'is'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const OUTPUT_ITEM_TYPE_MAP: Record<AllowedListInputType, NodeVariableType> = {
|
|
const OUTPUT_ITEM_TYPE_MAP: Record<AllowedListInputType, NodeVariableType> = {
|
|
|
'array[string]': 'string',
|
|
'array[string]': 'string',
|
|
|
'array[number]': 'number',
|
|
'array[number]': 'number',
|
|
|
'array[boolean]': 'boolean',
|
|
'array[boolean]': 'boolean',
|
|
|
- 'array[file]': 'object'
|
|
|
|
|
|
|
+ 'array[file]': 'object',
|
|
|
|
|
+ 'array[object]': 'object'
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
const FILE_OPTIONS = [
|
|
const FILE_OPTIONS = [
|
|
@@ -171,17 +165,6 @@ watch(
|
|
|
{ immediate: true }
|
|
{ immediate: true }
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
-const filterVarFn = (list: NodeVar[]) => {
|
|
|
|
|
- return list
|
|
|
|
|
- .map((group) => ({
|
|
|
|
|
- ...group,
|
|
|
|
|
- variableList: group.variableList.filter((item) =>
|
|
|
|
|
- ALLOWED_INPUT_TYPES.includes(item.type as AllowedListInputType)
|
|
|
|
|
- )
|
|
|
|
|
- }))
|
|
|
|
|
- .filter((group) => group.variableList.length)
|
|
|
|
|
-}
|
|
|
|
|
-
|
|
|
|
|
const handleInputVarChange = (val: { value: string; type: string }) => {
|
|
const handleInputVarChange = (val: { value: string; type: string }) => {
|
|
|
const nextType = val.type as NodeVariableType
|
|
const nextType = val.type as NodeVariableType
|
|
|
const nextInputVar: NodeVariable = {
|
|
const nextInputVar: NodeVariable = {
|
|
@@ -213,7 +196,7 @@ const handleLeftChange = (val: string) => {
|
|
|
</div>
|
|
</div>
|
|
|
<VarSelect
|
|
<VarSelect
|
|
|
:model-value="inputVar?.value"
|
|
:model-value="inputVar?.value"
|
|
|
- :filter-fn="filterVarFn"
|
|
|
|
|
|
|
+ :filter-fn="filterArrayVariables"
|
|
|
@change="handleInputVarChange"
|
|
@change="handleInputVarChange"
|
|
|
placeholder="请选择输入变量"
|
|
placeholder="请选择输入变量"
|
|
|
/>
|
|
/>
|