Skip to content

Commit e3563e6

Browse files
自定义时,只有string需要类型转换。
1 parent 74684af commit e3563e6

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

apps/application/flow/step_node/variable_assign_node/impl/base_variable_assign_node.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,28 @@ def convert(self, val, target_type):
3636
return val
3737

3838
if target_type == 'json_object':
39+
if isinstance(val, dict) or isinstance(val, list):
40+
return val
3941
return json.loads(val)
4042
elif target_type == 'json_string':
43+
if isinstance(val, str):
44+
return val
4145
return json.dumps(val, ensure_ascii=False)
4246
elif target_type == 'string':
47+
if isinstance(val, str):
48+
return val
4349
return str(val)
4450
elif target_type == 'int':
51+
if isinstance(val, int):
52+
return val
4553
return int(val)
4654
elif target_type == 'float':
55+
if isinstance(val, float):
56+
return val
4757
return float(val)
4858
elif target_type == 'boolean':
59+
if isinstance(val, bool):
60+
return val
4961
return bool(val)
5062
else:
5163
return val

ui/src/workflow/nodes/variable-assign-node/index.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,12 @@
144144
</el-select>
145145
</el-form-item>
146146

147-
<el-select v-model="item.target_type" style="max-width: 120px" :placeholder="$t('workflow.nodes.variableAssignNode.convertType')">
147+
<el-select
148+
v-if="item.type === 'string'"
149+
v-model="item.target_type"
150+
style="max-width: 120px"
151+
:placeholder="$t('workflow.nodes.variableAssignNode.convertType')"
152+
>
148153
<el-option v-for="item2 in targetTypeOptions" :key="item2.key" :label="item2.label" :value="item2.key" />
149154
</el-select>
150155
</div>

0 commit comments

Comments
 (0)