diff --git a/docs/zh-CN/components/form/input-formula.md b/docs/zh-CN/components/form/input-formula.md index e6d4b81eb..5015d2c8d 100644 --- a/docs/zh-CN/components/form/input-formula.md +++ b/docs/zh-CN/components/form/input-formula.md @@ -22,7 +22,7 @@ order: 21 "name": "formula", "label": "公式", "evalMode": true, - "value": "SUM(1 , 2)", + "value": "SUM(1 , user.id)", "variables": [ { "label": "表单字段", @@ -72,6 +72,20 @@ order: 21 } ] }, + { + "label": "人员对象", + "value": "user", + "children": [ + { + "label": "ID", + "value": "user.id" + }, + { + "label": "用户名", + "value": "user.name" + }, + ] + }, { "label": "长文本测试分类长文本测试分类长文本测试分类长文本测试分类", "children": [ diff --git a/packages/amis-ui/src/components/formula/Picker.tsx b/packages/amis-ui/src/components/formula/Picker.tsx index add29b767..e0e7d6a7b 100644 --- a/packages/amis-ui/src/components/formula/Picker.tsx +++ b/packages/amis-ui/src/components/formula/Picker.tsx @@ -344,7 +344,11 @@ export class FormulaPicker extends React.Component< let ast: any; try { - ast = parse(editorValue, {evalMode: true, allowFilter: false}); + ast = parse(editorValue, { + // mixedMode 弹窗中的一定是表达式 + evalMode: this.props.mixedMode ? true : this.props.evalMode, + allowFilter: false + }); } catch (error) { this.setState({isError: error?.message ?? true}); return; @@ -462,6 +466,7 @@ export class FormulaPicker extends React.Component< try { value && parse(value, { + // mixedMode 值是模版, 要 ${} 包裹表达式 evalMode: this.props.mixedMode ? false : this.props.evalMode, allowFilter: false });