From d34c4066ddd398ae004a7e7762990c7fd6ad298c Mon Sep 17 00:00:00 2001 From: 2betop <2betop.cn@gmail.com> Date: Tue, 22 Aug 2023 19:49:26 +0800 Subject: [PATCH] =?UTF-8?q?chore:=20condition-builder=20=E7=9A=84=20showIf?= =?UTF-8?q?=20=E5=8A=9F=E8=83=BD=E9=80=9A=E8=BF=87=20formulaForIf=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=8A=E4=B8=8B=E6=96=87=E4=BF=A1=E6=81=AF?= =?UTF-8?q?=E8=80=8C=E4=B8=8D=E6=98=AF=E5=A4=8D=E7=94=A8=E5=80=BC=E7=9A=84?= =?UTF-8?q?=E5=85=AC=E5=BC=8F=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/zh-CN/components/form/condition-builder.md | 4 +++- packages/amis-ui/src/components/condition-builder/Group.tsx | 5 ++++- .../amis-ui/src/components/condition-builder/GroupOrItem.tsx | 5 ++++- packages/amis-ui/src/components/condition-builder/index.tsx | 5 ++++- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/docs/zh-CN/components/form/condition-builder.md b/docs/zh-CN/components/form/condition-builder.md index b2dbe6e15..2da1946d7 100644 --- a/docs/zh-CN/components/form/condition-builder.md +++ b/docs/zh-CN/components/form/condition-builder.md @@ -1279,7 +1279,7 @@ selectMode 为`chained`时,使用`source`字段 } ] }, - "formula": { + "formulaForIf": { "mode":"input-group", "variables": [ { @@ -1435,7 +1435,9 @@ selectMode 为`chained`时,使用`source`字段 | addBtnVisibleOn | `string` | | 表达式:控制按钮“添加条件”的显示。参数为`depth`、`breadth`,分别代表深度、长度。表达式需要返回`boolean`类型 | `3.2.0` | | addGroupBtnVisibleOn | `string` | | 表达式:控制按钮“添加条件组”的显示。参数为`depth`、`breadth`,分别代表深度、长度。表达式需要返回`boolean`类型 | `3.2.0` | | inputSettings | `InputSettings` | | 开启公式编辑模式时的输入控件类型 | `3.2.0` | +| formula | `object` | | 字段输入控件变成公式编辑器。 | `3.2.0` | | showIf | `boolean` | | 开启后条件中额外还能配置启动条件。 | `3.2.0` | +| formulaForIf | `object` | | 给 showIF 表达式用的公式信息 | `3.4.0` | ### InputSettings diff --git a/packages/amis-ui/src/components/condition-builder/Group.tsx b/packages/amis-ui/src/components/condition-builder/Group.tsx index 243f898dd..e999a2218 100644 --- a/packages/amis-ui/src/components/condition-builder/Group.tsx +++ b/packages/amis-ui/src/components/condition-builder/Group.tsx @@ -32,6 +32,7 @@ export interface ConditionGroupProps extends ThemeProps, LocaleProps { showNot?: boolean; showANDOR?: boolean; showIf?: boolean; + formulaForIf?: FormulaPickerProps; data?: any; disabled?: boolean; searchable?: boolean; @@ -194,7 +195,8 @@ export class ConditionGroup extends React.Component< depth, isAddBtnVisibleOn, isAddGroupBtnVisibleOn, - showIf + showIf, + formulaForIf } = this.props; const {isCollapsed} = this.state; @@ -286,6 +288,7 @@ export class ConditionGroup extends React.Component< isAddBtnVisibleOn={isAddBtnVisibleOn} isAddGroupBtnVisibleOn={isAddGroupBtnVisibleOn} showIf={showIf} + formulaForIf={formulaForIf} /> )) ) : ( diff --git a/packages/amis-ui/src/components/condition-builder/GroupOrItem.tsx b/packages/amis-ui/src/components/condition-builder/GroupOrItem.tsx index 5ece6c451..e3d20cb34 100644 --- a/packages/amis-ui/src/components/condition-builder/GroupOrItem.tsx +++ b/packages/amis-ui/src/components/condition-builder/GroupOrItem.tsx @@ -35,6 +35,7 @@ export interface CBGroupOrItemProps extends ThemeProps { isAddBtnVisibleOn?: (param: {depth: number; breadth: number}) => boolean; isAddGroupBtnVisibleOn?: (param: {depth: number; breadth: number}) => boolean; showIf?: boolean; + formulaForIf?: FormulaPickerProps; } export class CBGroupOrItem extends React.Component { @@ -101,6 +102,7 @@ export class CBGroupOrItem extends React.Component { isAddBtnVisibleOn, isAddGroupBtnVisibleOn, showIf, + formulaForIf, mobileUI } = this.props; @@ -152,6 +154,7 @@ export class CBGroupOrItem extends React.Component { isAddBtnVisibleOn={isAddBtnVisibleOn} isAddGroupBtnVisibleOn={isAddGroupBtnVisibleOn} showIf={showIf} + formulaForIf={formulaForIf} /> ) : ( @@ -182,7 +185,7 @@ export class CBGroupOrItem extends React.Component { /> {showIf ? ( void; @@ -263,7 +264,8 @@ export class QueryBuilder extends React.Component< selectMode, isAddBtnVisibleOn, isAddGroupBtnVisibleOn, - showIf + showIf, + formulaForIf } = this.props; const normalizedValue = Array.isArray(value?.children) @@ -308,6 +310,7 @@ export class QueryBuilder extends React.Component< isAddBtnVisibleOn={isAddBtnVisibleOn} isAddGroupBtnVisibleOn={isAddGroupBtnVisibleOn} showIf={showIf} + formulaForIf={formulaForIf} /> ); }