From e587bcb08be72300da4a61b347da62dcbe49c168 Mon Sep 17 00:00:00 2001 From: FateRiddle Date: Wed, 11 Dec 2019 08:45:07 +0800 Subject: [PATCH] readOnly mode stop showing validation text --- src/base/parser.js | 5 +++-- src/index.js | 23 ++++++++++++++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/base/parser.js b/src/base/parser.js index 1ae73dc..9ced92a 100644 --- a/src/base/parser.js +++ b/src/base/parser.js @@ -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, }, diff --git a/src/index.js b/src/index.js index abace4a..d52fa0c 100755 --- a/src/index.js +++ b/src/index.js @@ -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 ; + + return ( + + ); }; 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); } }