Merge pull request #7912 from 2betop/chore-condition-builder2

chore: condition-builder 的 showIf 功能通过 formulaForIf 配置上下文信息而不是复用值的公式信息
This commit is contained in:
hsm-lv 2023-08-23 18:38:04 +08:00 committed by GitHub
commit 534b037f95
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 4 deletions

View File

@ -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

View File

@ -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}
/>
))
) : (

View File

@ -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<CBGroupOrItemProps> {
@ -101,6 +102,7 @@ export class CBGroupOrItem extends React.Component<CBGroupOrItemProps> {
isAddBtnVisibleOn,
isAddGroupBtnVisibleOn,
showIf,
formulaForIf,
mobileUI
} = this.props;
@ -152,6 +154,7 @@ export class CBGroupOrItem extends React.Component<CBGroupOrItemProps> {
isAddBtnVisibleOn={isAddBtnVisibleOn}
isAddGroupBtnVisibleOn={isAddGroupBtnVisibleOn}
showIf={showIf}
formulaForIf={formulaForIf}
/>
</div>
) : (
@ -182,7 +185,7 @@ export class CBGroupOrItem extends React.Component<CBGroupOrItemProps> {
/>
{showIf ? (
<FormulaPicker
{...formula}
{...formulaForIf}
evalMode={true}
mixedMode={false}
header="设置条件"

View File

@ -33,6 +33,7 @@ export interface ConditionBuilderProps extends ThemeProps, LocaleProps {
showNot?: boolean; // 是否显示非按钮
showANDOR?: boolean; // 是否显示并或切换键按钮
showIf?: boolean; // 是否显示条件
formulaForIf?: FormulaPickerProps;
value?: ConditionGroupValue;
data?: any;
onChange: (value?: ConditionGroupValue) => 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}
/>
);
}