diff --git a/docs/zh-CN/components/form/formitem.md b/docs/zh-CN/components/form/formitem.md index 2b9b5bc54..21d9d4d1e 100755 --- a/docs/zh-CN/components/form/formitem.md +++ b/docs/zh-CN/components/form/formitem.md @@ -218,7 +218,33 @@ order: 1 "label": "禁用", "name": "text2", "disabled": true - } + }, + { + "type": "grid", + "columns": [ + { + "body": [ + { + "type": "input-text", + "label": "姓名", + "name": "name", + "value": "amis", + "disabled": true + } + ] + }, + { + "body": [ + { + "type": "input-email", + "label": "邮箱", + "name": "email", + "disabled": true + } + ] + } + ] + }, ] } ``` diff --git a/packages/amis-core/src/SchemaRenderer.tsx b/packages/amis-core/src/SchemaRenderer.tsx index f2a59be6c..8b4abed6c 100644 --- a/packages/amis-core/src/SchemaRenderer.tsx +++ b/packages/amis-core/src/SchemaRenderer.tsx @@ -16,7 +16,7 @@ import {ScopedContext} from './Scoped'; import {Schema, SchemaNode} from './types'; import {DebugWrapper} from './utils/debug'; import getExprProperties from './utils/filter-schema'; -import {anyChanged, chainEvents, autobind, createObject} from './utils/helper'; +import {anyChanged, chainEvents, autobind} from './utils/helper'; import {SimpleMap} from './utils/SimpleMap'; import {bindEvent, dispatchEvent, RendererEvent} from './utils/renderer-event'; diff --git a/packages/amis-core/src/renderers/Form.tsx b/packages/amis-core/src/renderers/Form.tsx index 90f5fa4ac..e2be92861 100644 --- a/packages/amis-core/src/renderers/Form.tsx +++ b/packages/amis-core/src/renderers/Form.tsx @@ -1522,7 +1522,14 @@ export default class Form extends React.Component { formLabelAlign: labelAlign !== 'left' ? 'right' : labelAlign, formLabelWidth: labelWidth, controlWidth, - disabled: disabled || (control as Schema).disabled || form.loading, + /** + * form.loading有为true时才下发disabled属性,否则不显性设置disbaled为false + * Form中包含容器类组件时,这些组件会将此处的disbaled继续下发至子组件,导致SchemaRenderer中props.disabled覆盖schema.disabled + */ + disabled: + disabled || + (control as Schema).disabled || + (form.loading ? true : undefined), btnDisabled: disabled || form.loading || form.validating, onAction: this.handleAction, onQuery: this.handleQuery, diff --git a/packages/amis/src/renderers/Grid.tsx b/packages/amis/src/renderers/Grid.tsx index 6a8be9caf..ddfc5b2a2 100644 --- a/packages/amis/src/renderers/Grid.tsx +++ b/packages/amis/src/renderers/Grid.tsx @@ -1,13 +1,7 @@ import React from 'react'; import {FormHorizontal, Renderer, RendererProps} from 'amis-core'; -import {Schema} from 'amis-core'; import pick from 'lodash/pick'; -import { - BaseSchema, - SchemaClassName, - SchemaCollection, - SchemaObject -} from '../Schema'; +import {BaseSchema, SchemaClassName, SchemaCollection} from '../Schema'; import {ucFirst} from 'amis-core'; import {Spinner} from 'amis-ui';