readOnly mode stop showing validation text

This commit is contained in:
FateRiddle
2019-12-11 08:45:07 +08:00
parent 1623f0aab3
commit e587bcb08b
2 changed files with 21 additions and 7 deletions

View File

@@ -43,8 +43,8 @@ function getBasicProps(settings, materials) {
displayType,
showDescIcon,
showValidate,
formData,
readOnly, // 添加全局控制只读模式
formData,
} = settings;
// 目前做了处理的`uiSchema`参数
const {
@@ -100,8 +100,9 @@ function getBasicProps(settings, materials) {
{
...subSchema,
column,
showDescIcon,
displayType,
showDescIcon,
showValidate,
readOnly,
formData,
},

View File

@@ -25,9 +25,24 @@ function renderField(schema, fields, events) {
}
// 在顶层将 propsSchema 和 uiSchema 合并,便于后续处理。 也可直接传入合并的 schema
const Wrapper = ({ schema, propsSchema = {}, uiSchema = {}, ...rest }) => {
const Wrapper = ({
schema,
propsSchema = {},
uiSchema = {},
readOnly,
showValidate,
...rest
}) => {
const _schema = schema ? schema : combineSchema(propsSchema, uiSchema);
return <FormRender {...rest} schema={_schema} />;
return (
<FormRender
readOnly={readOnly}
showValidate={!readOnly && showValidate} // 预览模式下不展示校验
{...rest}
schema={_schema}
/>
);
};
class FormRender extends React.Component {
@@ -82,9 +97,7 @@ class FormRender extends React.Component {
!isDeepEqual(nextProps.schema, schema) ||
!isDeepEqual(Object.keys(nextProps.formData), Object.keys(formData))
) {
setTimeout(() => {
this.needUpdateForm();
}, 0);
setTimeout(this.needUpdateForm, 0);
}
}