Skip to content

Commit

Permalink
fix(editor): 下拉选择框和复选框组件配置接口类数据源后,被设置了value
Browse files Browse the repository at this point in the history
  • Loading branch information
yangwei9012 committed Jan 16, 2024
1 parent b2520da commit 8aecaff
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
19 changes: 13 additions & 6 deletions packages/amis-editor/src/plugin/Form/Checkboxes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
getSchemaTpl,
valuePipeOut,
EditorNodeType,
EditorManager
EditorManager,
undefinedPipeOut
} from 'amis-editor-core';
import {registerEditorPlugin} from 'amis-editor-core';
import {
Expand Down Expand Up @@ -173,11 +174,6 @@ export class CheckboxesControlPlugin extends BasePlugin {
]
}
],
getSchemaTpl('valueFormula', {
rendererSchema: (schema: Schema) => schema,
useSelectMode: true, // 改用 Select 设置模式
visibleOn: 'this.options && this.options.length > 0'
}),
getSchemaTpl('joinValues', {
visibleOn: true
}),
Expand All @@ -199,6 +195,17 @@ export class CheckboxesControlPlugin extends BasePlugin {
getSchemaTpl('optionControlV2', {
multiple: true
}),
getSchemaTpl('valueFormula', {
rendererSchema: (schema: Schema) => ({
...schema,
type: 'input-text'
}),
pipeOut: undefinedPipeOut,
// 默认值组件设计有些问题,自动发起了请求,接口数据作为了默认值选项,接口形式应该是设置静态值或者FX
needDeleteProps: ['source'],
// 当数据源是自定义静态选项时,不额外配置默认值,在选项上直接勾选即可,放开会有个bug:当去掉勾选时,默认值配置组件不清空,只是schema清空了value
visibleOn: 'this.selectFirst !== true && this.source != null'
}),
// 自定义选项模板
getSchemaTpl('optionsMenuTpl', {
manager: this.manager
Expand Down
3 changes: 2 additions & 1 deletion packages/amis-editor/src/plugin/Form/Select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,8 @@ export class SelectControlPlugin extends BasePlugin {
pipeOut: undefinedPipeOut,
// 默认值组件设计有些问题,自动发起了请求,接口数据作为了默认值选项,接口形式应该是设置静态值或者FX
needDeleteProps: ['source'],
hiddenOn: 'this.selectFirst === true'
// 当数据源是自定义静态选项时,不额外配置默认值,在选项上直接勾选即可,放开会有个bug:当去掉勾选时,默认值配置组件不清空,只是schema清空了value
visibleOn: 'this.selectFirst !== true && this.source != null'
}),
getSchemaTpl(
'loadingConfig',
Expand Down

0 comments on commit 8aecaff

Please sign in to comment.