fix: 按钮disabledOn属性失效问题 (#4324)

This commit is contained in:
RUNZE LU 2022-05-12 18:57:46 +08:00 committed by GitHub
parent 0f55b7cc8b
commit a9004e2563
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 62 additions and 1 deletions

View File

@ -45,6 +45,63 @@ CRUD即增删改查组件主要用来展现数据列表并支持各类
{
"name": "grade",
"label": "CSS grade"
},
{
"type": "operation",
"label": "操作",
"buttons": [
{
"label": "详情",
"type": "button",
"level": "link",
"actionType": "dialog",
"dialog": {
"title": "查看详情",
"body": {
"type": "form",
"body": [
{
"type": "input-text",
"name": "engine",
"label": "Engine"
},
{
"type": "input-text",
"name": "browser",
"label": "Browser"
},
{
"type": "input-text",
"name": "platform",
"label": "platform"
},
{
"type": "input-text",
"name": "version",
"label": "version"
},
{
"type": "control",
"label": "grade",
"body": {
"type": "tag",
"label": "${grade}",
"displayMode": "normal",
"color": "active"
}
}
]
}
}
},
{
"label": "删除",
"type": "button",
"level": "link",
"className": "text-danger",
"disabledOn": "this.grade === 'A'"
}
]
}
]
}

View File

@ -391,10 +391,14 @@ export class SchemaRenderer extends React.Component<SchemaRendererProps, any> {
ref: this.refFn,
render: this.renderChild,
rootStore: rootStore,
disabled: disable ?? rest.disabled ?? restSchema.disabled,
// disabled: disable ?? rest.disabled ?? restSchema.disabled,
dispatchEvent: this.dispatchEvent
};
if (disable) {
(props as any).disabled = true;
}
// 自动解析变量模式,主要是方便直接引入第三方组件库,无需为了支持变量封装一层
if (renderer.autoVar) {
for (const key of Object.keys($schema)) {