mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-05 05:18:34 +08:00
commit
5a354ec45e
@ -3,7 +3,12 @@
|
||||
*/
|
||||
|
||||
import React from 'react';
|
||||
import {render as renderAmis, autobind, FormControlProps} from 'amis-core';
|
||||
import {
|
||||
render as renderAmis,
|
||||
autobind,
|
||||
FormControlProps,
|
||||
flattenTree
|
||||
} from 'amis-core';
|
||||
import cx from 'classnames';
|
||||
import {FormItem, Button, PickerContainer, ConditionBuilderFields} from 'amis';
|
||||
import {reaction} from 'mobx';
|
||||
@ -98,30 +103,30 @@ export default class ConditionFormulaControl extends React.Component<
|
||||
|
||||
// 自身字段
|
||||
const selfName = this.props?.data?.name;
|
||||
const vars =
|
||||
variablesArr?.filter((item: any) => item?.label === '组件上下文')?.[0]
|
||||
?.children?.[0]?.children || [];
|
||||
|
||||
fieldsArr = vars
|
||||
.map((item: any) => {
|
||||
if (item && item.type && PropsFieldsMapping[item.type]) {
|
||||
let obj: any = {
|
||||
label: item.label,
|
||||
type: PropsFieldsMapping[item.type],
|
||||
name: item.value
|
||||
fieldsArr = flattenTree(variablesArr, (item: any) => {
|
||||
if (
|
||||
item &&
|
||||
item.type &&
|
||||
PropsFieldsMapping[item.type] &&
|
||||
!item.isMember
|
||||
) {
|
||||
let obj: any = {
|
||||
label: item.label,
|
||||
type: PropsFieldsMapping[item.type],
|
||||
name: item.value
|
||||
};
|
||||
|
||||
if (selfName === item.value) {
|
||||
obj = {
|
||||
...obj,
|
||||
label: item.label + '(self)',
|
||||
disabled: true
|
||||
};
|
||||
|
||||
if (selfName === item.value) {
|
||||
obj = {
|
||||
...obj,
|
||||
label: item.label + '(self)',
|
||||
disabled: true
|
||||
};
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
})
|
||||
?.filter((item: any) => item);
|
||||
return obj;
|
||||
}
|
||||
})?.filter(item => item);
|
||||
}
|
||||
return fieldsArr.concat(fields || []);
|
||||
}
|
||||
@ -152,7 +157,7 @@ export default class ConditionFormulaControl extends React.Component<
|
||||
}
|
||||
|
||||
render() {
|
||||
const {name, className, size} = this.props;
|
||||
const {name, className, modalSize} = this.props;
|
||||
const {formulaPickerValue, fields} = this.state;
|
||||
return (
|
||||
<div className={cx('ae-ExpressionFormulaControl', className)}>
|
||||
@ -181,7 +186,7 @@ export default class ConditionFormulaControl extends React.Component<
|
||||
}}
|
||||
value={formulaPickerValue}
|
||||
onConfirm={this.handleConfirm}
|
||||
size={size ?? 'lg'}
|
||||
size={modalSize ?? 'lg'}
|
||||
>
|
||||
{({onClick}: {onClick: (e: React.MouseEvent) => any}) => (
|
||||
<Button
|
||||
|
@ -255,6 +255,7 @@ export class StatusControl extends React.Component<
|
||||
getSchemaTpl('conditionFormulaControl', {
|
||||
label: '条件设置',
|
||||
name: 'condition',
|
||||
modalSize: 'xs',
|
||||
visibleOn: 'this.statusType === 3'
|
||||
})
|
||||
]
|
||||
|
@ -6,7 +6,7 @@ import React, {ReactNode} from 'react';
|
||||
import groupBy from 'lodash/groupBy';
|
||||
import remove from 'lodash/remove';
|
||||
import cx from 'classnames';
|
||||
import {ConditionBuilderFields, FormItem} from 'amis';
|
||||
import {ConditionBuilderFields, FormItem, flattenTree} from 'amis';
|
||||
|
||||
import {
|
||||
autobind,
|
||||
@ -92,13 +92,11 @@ export default class ValidationControl extends React.Component<
|
||||
const variablesArr = await getVariables(this);
|
||||
// 自身字段
|
||||
const selfName = this.props.data.name;
|
||||
const vars =
|
||||
variablesArr?.filter((item: any) => item?.label === '组件上下文')?.[0]
|
||||
?.children?.[0]?.children || [];
|
||||
|
||||
const arr: ConditionBuilderFields = vars
|
||||
.map((item: any) => {
|
||||
if (item && item.value) {
|
||||
const arr: ConditionBuilderFields = flattenTree(
|
||||
variablesArr,
|
||||
(item: any) => {
|
||||
if (item.value && item.type !== 'array' && !item.isMember) {
|
||||
let obj: any = {
|
||||
label: item.label,
|
||||
value: item.value
|
||||
@ -113,8 +111,8 @@ export default class ValidationControl extends React.Component<
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
})
|
||||
?.filter((item: any) => item);
|
||||
}
|
||||
)?.filter(item => item);
|
||||
|
||||
return arr;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user