amis-saas-6892 [Feature] 编辑器fx 交互优化

Change-Id: I8593c1c40a8f1be2c6bc601041e966793d257cac
This commit is contained in:
jiatianqi 2022-11-02 16:52:18 +08:00
parent 3ef7b49f9f
commit 2ab575b200
2 changed files with 27 additions and 35 deletions

View File

@ -162,7 +162,7 @@ export default class FormulaControl extends React.Component<
this.isUnmount = true; this.isUnmount = true;
} }
// 组件默认值设置交互中未使用 // 组件默认值设置交互中未使用自定义variables情况适用
normalizeVariables(variables: any) { normalizeVariables(variables: any) {
if (!variables) { if (!variables) {
return []; return [];
@ -170,6 +170,7 @@ export default class FormulaControl extends React.Component<
if ( if (
variables && variables &&
Array.isArray(variables) &&
variables.some((item: any) => isExpression(item.children)) variables.some((item: any) => isExpression(item.children))
) { ) {
variables = dataMapping(variables, this.props.data); variables = dataMapping(variables, this.props.data);

View File

@ -11,6 +11,7 @@ import {SchemaObject} from 'amis/lib/Schema';
import flatten from 'lodash/flatten'; import flatten from 'lodash/flatten';
import {InputComponentName} from '../component/InputComponentName'; import {InputComponentName} from '../component/InputComponentName';
import {FormulaDateType} from '../renderer/FormulaControl'; import {FormulaDateType} from '../renderer/FormulaControl';
import {VariableItem} from 'amis-ui/lib/components/formula/Editor';
/** /**
* @deprecated switch * @deprecated switch
@ -358,6 +359,8 @@ setSchemaTpl(
valueType?: string; // 用于设置期望数值类型 valueType?: string; // 用于设置期望数值类型
visibleOn?: string; // 用于控制显示的表达式 visibleOn?: string; // 用于控制显示的表达式
DateTimeType?: FormulaDateType; // 日期类组件要支持 表达式 & 相对值 DateTimeType?: FormulaDateType; // 日期类组件要支持 表达式 & 相对值
variables?: Array<VariableItem>; // 自定义变量集合
variableMode?: 'tabs' | 'tree'; // 变量展现模式
}) => { }) => {
let curRendererSchema = config?.rendererSchema; let curRendererSchema = config?.rendererSchema;
if ( if (
@ -371,41 +374,28 @@ setSchemaTpl(
}; };
} }
if (config?.mode === 'vertical') { return {
// 上下展示,可避免 自定义渲染器 出现挤压 type: 'group',
return {
type: 'group',
mode: 'vertical',
visibleOn: config?.visibleOn,
body: [
{
type: 'ae-formulaControl',
label: config?.label ?? '默认值',
name: config?.name || 'value',
rendererSchema: curRendererSchema,
rendererWrapper: config?.rendererWrapper,
needDeleteProps: config?.needDeleteProps,
valueType: config?.valueType,
header: config.header ?? '表达式',
DateTimeType: config.DateTimeType ?? FormulaDateType.NotDate
}
]
};
} else {
// 默认左右展示 // 默认左右展示
return { // 上下展示,可避免 自定义渲染器 出现挤压
type: 'ae-formulaControl', mode: config?.mode === 'vertical' ? 'vertical' : 'horizontal',
label: config?.label || '默认值', visibleOn: config?.visibleOn,
name: config?.name || 'value', body: [
rendererSchema: curRendererSchema, {
rendererWrapper: config?.rendererWrapper, type: 'ae-formulaControl',
needDeleteProps: config?.needDeleteProps, label: config?.label ?? '默认值',
valueType: config?.valueType, name: config?.name || 'value',
visibleOn: config?.visibleOn, rendererSchema: curRendererSchema,
header: config?.header ?? '表达式', rendererWrapper: config?.rendererWrapper,
DateTimeType: config?.DateTimeType ?? FormulaDateType.NotDate needDeleteProps: config?.needDeleteProps,
}; valueType: config?.valueType,
} header: config?.header ?? '表达式',
DateTimeType: config?.DateTimeType ?? FormulaDateType.NotDate,
variables: config?.variables || null,
variableMode: config?.variableMode
}
]
};
} }
); );
@ -1007,6 +997,7 @@ setSchemaTpl('badge', {
type: 'ae-badge' type: 'ae-badge'
}); });
// 暂未使用
setSchemaTpl('formulaControl', (schema: object = {}) => { setSchemaTpl('formulaControl', (schema: object = {}) => {
return { return {
type: 'ae-formulaControl', type: 'ae-formulaControl',