diff --git a/scss/components/_condition-builder.scss b/scss/components/_condition-builder.scss index 05cbd2b86..3d87626b3 100644 --- a/scss/components/_condition-builder.scss +++ b/scss/components/_condition-builder.scss @@ -279,7 +279,7 @@ display: block; font-size: $fontSizeSm; align-self: center; - margin: -5px 0 -5px -8px; + margin: -5px 5px -5px -8px; padding: 5px; border-radius: 5px; user-select: none; diff --git a/src/components/condition-builder/Expression.tsx b/src/components/condition-builder/Expression.tsx index f464ffc33..266b0179d 100644 --- a/src/components/condition-builder/Expression.tsx +++ b/src/components/condition-builder/Expression.tsx @@ -36,7 +36,6 @@ export interface ExpressionProps extends ThemeProps { valueField?: FieldSimple; fields?: Field[]; funcs?: Funcs; - defaultType?: 'value' | 'field' | 'func' | 'formula'; allowedTypes?: Array<'value' | 'field' | 'func' | 'formula'>; op?: OperatorType; config: Config; @@ -120,12 +119,12 @@ export class Expression extends React.Component { const { value, valueField, - defaultType, allowedTypes, funcs, fields, op, - classnames: cx + classnames: cx, + config } = this.props; const inputType = ((value as any)?.type === 'field' @@ -137,7 +136,6 @@ export class Expression extends React.Component { : value !== undefined ? 'value' : undefined) || - defaultType || allowedTypes?.[0] || 'value'; @@ -177,11 +175,11 @@ export class Expression extends React.Component { {inputType === 'func' ? ( ) : null} diff --git a/src/components/condition-builder/Formula.tsx b/src/components/condition-builder/Formula.tsx index 0270fab48..5cce9b234 100644 --- a/src/components/condition-builder/Formula.tsx +++ b/src/components/condition-builder/Formula.tsx @@ -14,10 +14,10 @@ export class Formula extends React.Component { return (
公式} + prefix={表达式} />
); diff --git a/src/components/condition-builder/Func.tsx b/src/components/condition-builder/Func.tsx index 8e4ecc37b..cd7a41d67 100644 --- a/src/components/condition-builder/Func.tsx +++ b/src/components/condition-builder/Func.tsx @@ -7,13 +7,14 @@ import {autobind, findTree, noop} from '../../utils/helper'; import ResultBox from '../ResultBox'; import {Icon} from '../icons'; import Expression from './Expression'; +import {Config} from './config'; export interface ConditionFuncProps extends ThemeProps { value: ExpressionFunc; onChange: (value: ExpressionFunc) => void; + config: Config; fields?: Field[]; funcs?: Funcs; - defaultType?: 'value' | 'field' | 'func' | 'formula'; allowedTypes?: Array<'value' | 'field' | 'func' | 'formula'>; } @@ -36,14 +37,7 @@ export class ConditionFunc extends React.Component { } renderFunc(func: Func) { - const { - classnames: cx, - fields, - value, - funcs, - defaultType, - allowedTypes - } = this.props; + const {classnames: cx, fields, value, funcs, config} = this.props; return (
@@ -52,6 +46,7 @@ export class ConditionFunc extends React.Component {
{func.args.map((item, index) => ( { valueField={{type: item.type} as any} onChange={this.handleArgChange} funcs={funcs} - defaultType={defaultType} // allowedTypes={allowedTypes} /> ))} diff --git a/src/components/condition-builder/Item.tsx b/src/components/condition-builder/Item.tsx index 4efebfe54..45c42f741 100644 --- a/src/components/condition-builder/Item.tsx +++ b/src/components/condition-builder/Item.tsx @@ -104,10 +104,11 @@ export class ConditionItem extends React.Component { value={value.left} onChange={this.handleLeftChange} fields={fields} - defaultType="field" - allowedTypes={(config.valueTypes || ['field', 'func']).filter( - type => type === 'field' || type === 'func' - )} + allowedTypes={ + ['field', 'func'].filter( + type => type === 'field' || type === 'func' + ) as any + } /> ); } @@ -251,7 +252,6 @@ export class ConditionItem extends React.Component { value={(value.right as Array)?.[0]} onChange={this.handleRightSubChange.bind(this, 0)} fields={fields} - defaultType="value" allowedTypes={ field?.valueTypes || config.valueTypes || ['value', 'field', 'func', 'formula'] @@ -267,7 +267,6 @@ export class ConditionItem extends React.Component { value={(value.right as Array)?.[1]} onChange={this.handleRightSubChange.bind(this, 1)} fields={fields} - defaultType="value" allowedTypes={ field?.valueTypes || config.valueTypes || ['value', 'field', 'func', 'formula'] @@ -286,7 +285,6 @@ export class ConditionItem extends React.Component { value={value.right} onChange={this.handleRightChange} fields={fields} - defaultType="value" allowedTypes={ field?.valueTypes || config.valueTypes || ['value', 'field', 'func', 'formula']