fix: 修复 inputFormula evalMode false 时提交报错问题 (#9899)

This commit is contained in:
liaoxuezhi 2024-03-27 11:03:50 +08:00 committed by 2betop
parent 6df3026f3c
commit 2d6ade5790
2 changed files with 21 additions and 2 deletions

View File

@ -22,7 +22,7 @@ order: 21
"name": "formula", "name": "formula",
"label": "公式", "label": "公式",
"evalMode": true, "evalMode": true,
"value": "SUM(1 , 2)", "value": "SUM(1 , user.id)",
"variables": [ "variables": [
{ {
"label": "表单字段", "label": "表单字段",
@ -72,6 +72,20 @@ order: 21
} }
] ]
}, },
{
"label": "人员对象",
"value": "user",
"children": [
{
"label": "ID",
"value": "user.id"
},
{
"label": "用户名",
"value": "user.name"
},
]
},
{ {
"label": "长文本测试分类长文本测试分类长文本测试分类长文本测试分类", "label": "长文本测试分类长文本测试分类长文本测试分类长文本测试分类",
"children": [ "children": [

View File

@ -344,7 +344,11 @@ export class FormulaPicker extends React.Component<
let ast: any; let ast: any;
try { try {
ast = parse(editorValue, {evalMode: true, allowFilter: false}); ast = parse(editorValue, {
// mixedMode 弹窗中的一定是表达式
evalMode: this.props.mixedMode ? true : this.props.evalMode,
allowFilter: false
});
} catch (error) { } catch (error) {
this.setState({isError: error?.message ?? true}); this.setState({isError: error?.message ?? true});
return; return;
@ -462,6 +466,7 @@ export class FormulaPicker extends React.Component<
try { try {
value && value &&
parse(value, { parse(value, {
// mixedMode 值是模版, 要 ${} 包裹表达式
evalMode: this.props.mixedMode ? false : this.props.evalMode, evalMode: this.props.mixedMode ? false : this.props.evalMode,
allowFilter: false allowFilter: false
}); });