amis-saas-5351 从开发分支合入release

Change-Id: Ib192a24f0ed3500b3480d6103d9cf3ad3dcd9c64
This commit is contained in:
jinye 2022-10-19 18:40:52 +08:00
commit 2385df9506
15 changed files with 180 additions and 24 deletions

View File

@ -3,7 +3,7 @@
*/ */
import flatten from 'lodash/flatten'; import flatten from 'lodash/flatten';
import {getEventControlConfig} from '../renderer/event-control/helper'; import {getEventControlConfig, SUPPORT_STATIC_FORMITEM_CMPTS} from '../renderer/event-control/helper';
import {getSchemaTpl, isObject, tipedLabel} from 'amis-editor-core'; import {getSchemaTpl, isObject, tipedLabel} from 'amis-editor-core';
import type {BaseEventContext} from 'amis-editor-core'; import type {BaseEventContext} from 'amis-editor-core';
import {SchemaObject} from 'amis/lib/Schema'; import {SchemaObject} from 'amis/lib/Schema';
@ -196,6 +196,8 @@ export const formItemControl: (
>, >,
context?: BaseEventContext context?: BaseEventContext
) => Array<any> = (panels, context) => { ) => Array<any> = (panels, context) => {
const type = context?.schema?.type || '';
const supportStatic = SUPPORT_STATIC_FORMITEM_CMPTS.includes(type);
const collapseProps = { const collapseProps = {
type: 'collapse', type: 'collapse',
headingClassName: 'ae-formItemControl-header', headingClassName: 'ae-formItemControl-header',
@ -250,6 +252,7 @@ export const formItemControl: (
body: normalizeBodySchema( body: normalizeBodySchema(
[ [
getSchemaTpl('hidden'), getSchemaTpl('hidden'),
supportStatic ? getSchemaTpl('static') : null,
// TODO: 下面的部分表单项才有,是不是判断一下是否是表单项 // TODO: 下面的部分表单项才有,是不是判断一下是否是表单项
getSchemaTpl('disabled'), getSchemaTpl('disabled'),
getSchemaTpl('clearValueOnHidden') getSchemaTpl('clearValueOnHidden')
@ -283,7 +286,6 @@ export const formItemControl: (
// } // }
// ]) // ])
]; ];
return [ return [
{ {
type: 'tabs', type: 'tabs',
@ -337,7 +339,13 @@ export const formItemControl: (
label: '描述 CSS 类名', label: '描述 CSS 类名',
name: 'descriptionClassName', name: 'descriptionClassName',
visibleOn: 'this.description' visibleOn: 'this.description'
}),
...!supportStatic ? [] : [
getSchemaTpl('className', {
label: '静态 CSS 类名',
name: 'staticClassName'
}) })
]
], ],
panels?.style?.body, panels?.style?.body,
panels?.style?.replace, panels?.style?.replace,

View File

@ -25,7 +25,8 @@ export class ButtonGroupControlPlugin extends BasePlugin {
tags = ['按钮']; tags = ['按钮'];
scaffold = { scaffold = {
type: 'button-group-select', type: 'button-group-select',
name: 'a', name: 'buttonGroupSelect',
label: '按钮点选',
inline: false, inline: false,
options: [ options: [
{ {

View File

@ -121,6 +121,7 @@ export class ButtonToolbarControlPlugin extends BasePlugin {
}, },
getSchemaTpl('style:classNames', { getSchemaTpl('style:classNames', {
isFormItem: true, isFormItem: true,
unsupportStatic: true,
schema: [ schema: [
getSchemaTpl('className', { getSchemaTpl('className', {
label: '描述', label: '描述',

View File

@ -157,7 +157,10 @@ export class CodeEditorControlPlugin extends BasePlugin {
getSchemaTpl('autoFillApi') getSchemaTpl('autoFillApi')
] ]
}, },
getSchemaTpl('status', {isFormItem: true}), getSchemaTpl('status', {
isFormItem: true,
unsupportStatic: true
}),
getSchemaTpl('validation', { getSchemaTpl('validation', {
tag: ValidatorTag.Code tag: ValidatorTag.Code
}) })
@ -204,7 +207,9 @@ export class CodeEditorControlPlugin extends BasePlugin {
} }
] ]
}), }),
getSchemaTpl('style:classNames') getSchemaTpl('style:classNames', {
unsupportStatic: true
})
]) ])
}, },
{ {

View File

@ -166,7 +166,10 @@ export class DiffEditorControlPlugin extends BasePlugin {
getSchemaTpl('autoFillApi') getSchemaTpl('autoFillApi')
] ]
}, },
getSchemaTpl('status', {isFormItem: true}), getSchemaTpl('status', {
isFormItem: true,
unsupportStatic: true
}),
getSchemaTpl('validation', { getSchemaTpl('validation', {
tag: ValidatorTag.All tag: ValidatorTag.All
}) })
@ -213,7 +216,9 @@ export class DiffEditorControlPlugin extends BasePlugin {
} }
] ]
}), }),
getSchemaTpl('style:classNames') getSchemaTpl('style:classNames', {
unsupportStatic: true
})
]) ])
}, },
{ {

View File

@ -811,6 +811,11 @@ export class FormPlugin extends BasePlugin {
getSchemaTpl('className'), getSchemaTpl('className'),
getSchemaTpl('className', {
name: 'staticClassName',
label: '静态展示时 的 CSS 类名'
}),
getSchemaTpl('className', { getSchemaTpl('className', {
name: 'panelClassName', name: 'panelClassName',
visibleOn: 'this.wrapWithPanel !== false', visibleOn: 'this.wrapWithPanel !== false',
@ -845,7 +850,8 @@ export class FormPlugin extends BasePlugin {
}), }),
getSchemaTpl('disabled'), getSchemaTpl('disabled'),
getSchemaTpl('visible') getSchemaTpl('visible'),
getSchemaTpl('static')
] ]
} }
]) ])

View File

@ -362,7 +362,10 @@ export class FileControlPlugin extends BasePlugin {
}) })
] ]
}, },
getSchemaTpl('status', {isFormItem: true}), getSchemaTpl('status', {
isFormItem: true,
unsupportStatic: true
}),
getSchemaTpl('validation', {tag: ValidatorTag.File}) getSchemaTpl('validation', {tag: ValidatorTag.File})
]) ])
}, },
@ -371,6 +374,7 @@ export class FileControlPlugin extends BasePlugin {
body: getSchemaTpl('collapseGroup', [ body: getSchemaTpl('collapseGroup', [
getSchemaTpl('style:formItem', {renderer: context.info.renderer}), getSchemaTpl('style:formItem', {renderer: context.info.renderer}),
getSchemaTpl('style:classNames', { getSchemaTpl('style:classNames', {
unsupportStatic: true,
schema: [ schema: [
getSchemaTpl('className', { getSchemaTpl('className', {
name: 'descriptionClassName', name: 'descriptionClassName',

View File

@ -376,7 +376,10 @@ export class ImageControlPlugin extends BasePlugin {
} }
] ]
}, },
getSchemaTpl('status', {isFormItem: true}), getSchemaTpl('status', {
isFormItem: true,
unsupportStatic: true
}),
getSchemaTpl('validation', {tag: ValidatorTag.File}) getSchemaTpl('validation', {tag: ValidatorTag.File})
]) ])
}, },
@ -415,6 +418,7 @@ export class ImageControlPlugin extends BasePlugin {
] ]
}, },
getSchemaTpl('style:classNames', { getSchemaTpl('style:classNames', {
unsupportStatic: true,
schema: [] schema: []
}) })
]) ])

View File

@ -15,6 +15,7 @@ import {
import {defaultValue, getSchemaTpl} from 'amis-editor-core'; import {defaultValue, getSchemaTpl} from 'amis-editor-core';
import find from 'lodash/find'; import find from 'lodash/find';
import {JSONDelete, JSONPipeIn, JSONUpdate} from 'amis-editor-core'; import {JSONDelete, JSONPipeIn, JSONUpdate} from 'amis-editor-core';
import {SUPPORT_STATIC_FORMITEM_CMPTS} from '../../renderer/event-control/helper';
export class ItemPlugin extends BasePlugin { export class ItemPlugin extends BasePlugin {
// panelTitle = '表单项通配'; // panelTitle = '表单项通配';
@ -55,8 +56,10 @@ export class ItemPlugin extends BasePlugin {
} }
} }
panelBodyCreator = (context: BaseEventContext) => { panelBodyCreator = (context: BaseEventContext) => {
const type = context.schema.type || '';
const supportStatic = SUPPORT_STATIC_FORMITEM_CMPTS.includes(type);
const ignoreName = ~['button', 'submit', 'reset'].indexOf( const ignoreName = ~['button', 'submit', 'reset'].indexOf(
context.schema.type type
); );
const notRequiredName = ~[ const notRequiredName = ~[
'button-toobar', 'button-toobar',
@ -72,7 +75,7 @@ export class ItemPlugin extends BasePlugin {
'table', 'table',
'elevator', 'elevator',
'static' 'static'
].indexOf(context.schema.type); ].indexOf(type);
const hasReadOnly = ~[ const hasReadOnly = ~[
'switch', 'switch',
'wizard', 'wizard',
@ -81,9 +84,9 @@ export class ItemPlugin extends BasePlugin {
'input-rating', 'input-rating',
'input-text', 'input-text',
'textarea' 'textarea'
].indexOf(context.schema.type); ].indexOf(type);
/** 不支持配置校验属性的组件 */ /** 不支持配置校验属性的组件 */
const ignoreValidator = !!~['input-group'].indexOf(context.schema.type); const ignoreValidator = !!~['input-group'].indexOf(type);
const renderer: any = context.info.renderer; const renderer: any = context.info.renderer;
return [ return [
getSchemaTpl('tabs', [ getSchemaTpl('tabs', [
@ -155,8 +158,14 @@ export class ItemPlugin extends BasePlugin {
label: '描述 CSS 类名', label: '描述 CSS 类名',
name: 'descriptionClassName', name: 'descriptionClassName',
visibleOn: 'this.description' visibleOn: 'this.description'
}),
...!supportStatic ? [] : [
getSchemaTpl('className', {
label: '静态 CSS 类名',
name: 'staticClassName'
}) })
] ]
]
}, },
{ {
@ -165,7 +174,7 @@ export class ItemPlugin extends BasePlugin {
// TODO: 有些表单项没有 disabled // TODO: 有些表单项没有 disabled
getSchemaTpl('disabled'), getSchemaTpl('disabled'),
getSchemaTpl('visible'), getSchemaTpl('visible'),
supportStatic ? getSchemaTpl('static') : null,
getSchemaTpl('switch', { getSchemaTpl('switch', {
name: 'clearValueOnHidden', name: 'clearValueOnHidden',
label: '隐藏时删除表单项值', label: '隐藏时删除表单项值',

View File

@ -112,7 +112,6 @@ export class ListControlPlugin extends BasePlugin {
getSchemaTpl('label'), getSchemaTpl('label'),
getSchemaTpl('multiple'), getSchemaTpl('multiple'),
getSchemaTpl('extractValue'), getSchemaTpl('extractValue'),
getSchemaTpl('valueFormula', { getSchemaTpl('valueFormula', {
rendererSchema: context?.schema, rendererSchema: context?.schema,
useSelectMode: true, // 改用 Select 设置模式 useSelectMode: true, // 改用 Select 设置模式

View File

@ -25,7 +25,8 @@ export class SwitchControlPlugin extends BasePlugin {
tags = ['表单项']; tags = ['表单项'];
scaffold = { scaffold = {
type: 'switch', type: 'switch',
option: '开关', label: '开关',
option: '说明',
name: 'switch', name: 'switch',
falseValue: false, falseValue: false,
trueValue: true trueValue: true

View File

@ -13,7 +13,8 @@ import {
SHOW_SELECT_PROP, SHOW_SELECT_PROP,
renderCmptActionSelect, renderCmptActionSelect,
renderCmptSelect, renderCmptSelect,
SUPPORT_DISABLED_CMPTS SUPPORT_DISABLED_CMPTS,
SUPPORT_STATIC_FORMITEM_CMPTS
} from './helper'; } from './helper';
import {BaseLabelMark} from '../../component/BaseControl'; import {BaseLabelMark} from '../../component/BaseControl';
import {i18n as _i18n} from 'i18n-runtime'; import {i18n as _i18n} from 'i18n-runtime';
@ -671,6 +672,66 @@ const ACTION_TYPE_TREE = (manager: any): RendererPluginAction[] => {
} }
] ]
}, },
{
actionLabel: '组件展示态',
actionType: 'staticStatus',
description: '控制所选的组件的输入态/静态',
actions: [
{
actionType: 'static',
descDetail: (info: any) => {
return (
<div>
<span className="variable-left variable-right">
{info?.rendererLabel}
</span>
</div>
);
}
},
{
actionType: 'nonstatic',
descDetail: (info: any) => {
return (
<div>
<span className="variable-left variable-right">
{info?.rendererLabel}
</span>
</div>
);
}
}
],
supportComponents: [
'form',
...SUPPORT_STATIC_FORMITEM_CMPTS
],
schema: [
...renderCmptSelect('选择组件', true),
{
type: 'radios',
label: '组件状态',
name: 'groupType',
mode: 'horizontal',
inputClassName: 'event-action-radio',
value: 'nonstatic',
required: true,
pipeIn: defaultValue('nonstatic'),
options: [
{
label: '表单输入',
value: 'nonstatic'
},
{
label: '表单静态',
value: 'static'
}
]
}
]
},
{ {
actionLabel: '刷新组件', actionLabel: '刷新组件',
actionType: 'reload', actionType: 'reload',

View File

@ -24,6 +24,7 @@ import {
import CmptActionSelect from './comp-action-select'; import CmptActionSelect from './comp-action-select';
import {Button} from 'amis'; import {Button} from 'amis';
import ACTION_TYPE_TREE from './actions'; import ACTION_TYPE_TREE from './actions';
import without from 'lodash/without';
// 数据容器范围 // 数据容器范围
export const DATA_CONTAINER = [ export const DATA_CONTAINER = [
@ -117,6 +118,26 @@ export const FORMITEM_CMPTS = [
'uuid' 'uuid'
]; ];
export const SUPPORT_STATIC_FORMITEM_CMPTS = without(FORMITEM_CMPTS, ...[
'button-toolbar',
'condition-builder',
'diff-editor',
'editor',
'formula',
'hidden',
'icon-picker',
'input-excel',
'input-file',
'input-formula',
'input-image',
'input-repeat',
'input-rich-text',
'input-sub-form',
'input-table',
'picker',
'uuid'
]);
export const SUPPORT_DISABLED_CMPTS = [ export const SUPPORT_DISABLED_CMPTS = [
'button-group', 'button-group',
'action', 'action',

View File

@ -606,12 +606,20 @@ setSchemaTpl('combo-container', (config: SchemaObject) => {
*/ */
setSchemaTpl( setSchemaTpl(
'status', 'status',
(config: {isFormItem?: boolean; readonly?: boolean; disabled?: boolean}) => { (config: {
isFormItem?: boolean;
readonly?: boolean;
disabled?: boolean;
unsupportStatic?: boolean;
}) => {
return { return {
title: '状态', title: '状态',
body: [ body: [
getSchemaTpl('newVisible'), getSchemaTpl('newVisible'),
getSchemaTpl('hidden'), getSchemaTpl('hidden'),
!config?.unsupportStatic && config?.isFormItem
? getSchemaTpl('static')
: null,
config?.readonly ? getSchemaTpl('readonly') : null, config?.readonly ? getSchemaTpl('readonly') : null,
config?.disabled || config?.isFormItem config?.disabled || config?.isFormItem
? getSchemaTpl('disabled') ? getSchemaTpl('disabled')
@ -684,6 +692,15 @@ setSchemaTpl('visible', {
expressionName: 'visibleOn' expressionName: 'visibleOn'
}); });
setSchemaTpl('static', {
type: 'ae-StatusControl',
label: '静态展示',
mode: 'normal',
name: 'static',
expressionName: 'staticOn'
});
// 新版配置面板兼容 [可见] 状态 // 新版配置面板兼容 [可见] 状态
setSchemaTpl('newVisible', { setSchemaTpl('newVisible', {
type: 'ae-StatusControl', type: 'ae-StatusControl',

View File

@ -18,8 +18,16 @@ setSchemaTpl('style:formItem', ({renderer, schema}: any) => {
setSchemaTpl( setSchemaTpl(
'style:classNames', 'style:classNames',
(config: {schema: SchemaCollection; isFormItem: boolean}) => { (config: {
const {isFormItem = true, schema = []} = config || {}; schema: SchemaCollection;
isFormItem: boolean;
unsupportStatic?: boolean;
}) => {
const {
isFormItem = true,
unsupportStatic = false,
schema = []
} = config || {};
return { return {
title: 'CSS 类名', title: 'CSS 类名',
@ -35,8 +43,14 @@ setSchemaTpl(
getSchemaTpl('className', { getSchemaTpl('className', {
label: '控件', label: '控件',
name: 'inputClassName' name: 'inputClassName'
}),
...unsupportStatic ? [] : [
getSchemaTpl('className', {
label: '表单项静态',
name: 'staticClassName'
}) })
] ]
]
: [ : [
getSchemaTpl('className', { getSchemaTpl('className', {
label: '外层' label: '外层'