@@ -128,21 +128,36 @@ export class RCREFormItem extends React.PureComponent<RCREFormItemProps, {
128128
129129 let isRequiredChanged = prevProps . required !== this . props . required ;
130130 let isRuleChanged = ! isEqual ( prevRules , nextRules ) ;
131+ let isFilterRuleChanged = false ;
131132
132- // let isFilterRuleChanged;
133- // if (prevProps.filterRule && this.props.filterRule) {
134- // let oldFilterRule = this.validFilterRule(prevProps.filterRule, null, prevRunTime, prevProps.filterErrMsg);
135- // let nextFilterRule = this.validFilterRule(this.props.filterRule, null, nextRunTime, this.props.filterErrMsg);
136- // isFilterRuleChanged = !isEqual(oldFilterRule, nextFilterRule);
137- // }
133+ let controlledNames = Object . keys ( this . controlElements ) ;
138134
139- // if (prevProps.validation && this.props.validation) {
140- // let oldStatus = this.runValidation(prevProps.validation, null, prevRunTime);
141- // let nextStatus = this.runValidation(this.props.validation, null, nextRunTime);
142- // isFilterRuleChanged = !isEqual(oldStatus, nextStatus);
143- // }
135+ for ( let name of controlledNames ) {
136+ let prevValue = prevProps . containerContext . $getData ( name ) ;
137+ let nextValue = this . props . containerContext . $getData ( name ) ;
144138
145- if ( isRequiredChanged || isRuleChanged ) {
139+ if ( prevProps . filterRule && this . props . filterRule ) {
140+ let prevValidateResult = this . validFilterRule ( prevProps . filterRule , prevValue , prevRunTime , prevProps . filterErrMsg ) ;
141+ let nextValidateResult = this . validFilterRule ( this . props . filterRule , nextValue , nextRunTime , this . props . filterErrMsg ) ;
142+
143+ if ( ! isEqual ( prevValidateResult , nextValidateResult ) ) {
144+ isFilterRuleChanged = true ;
145+ break ;
146+ }
147+ }
148+
149+ if ( prevProps . validation && this . props . validation ) {
150+ let oldStatus = this . runValidation ( prevProps . validation , prevValue , prevRunTime ) ;
151+ let nextStatus = this . runValidation ( this . props . validation , nextValue , nextRunTime ) ;
152+
153+ if ( ! isEqual ( oldStatus , nextStatus ) ) {
154+ isFilterRuleChanged = true ;
155+ break ;
156+ }
157+ }
158+ }
159+
160+ if ( isRequiredChanged || isRuleChanged || isFilterRuleChanged ) {
146161 let names = Object . keys ( this . controlElements ) ;
147162 for ( let name of names ) {
148163 let element = this . controlElements [ name ] ;
@@ -496,10 +511,12 @@ export class RCREFormItem extends React.PureComponent<RCREFormItemProps, {
496511
497512 private handleChange = ( name : string , data : any ) => {
498513 // 输入值改变,需要重置API请求锁
499- console . log ( 'validate' ) ;
500- // this.isApiValidate = false;
501- this . props . containerContext . $setData ( name , data ) ;
502- this . validateFormItem ( name , data ) ;
514+ this . setState ( {
515+ validating : false
516+ } , ( ) => {
517+ this . props . containerContext . $setData ( name , data ) ;
518+ this . validateFormItem ( name , data ) ;
519+ } ) ;
503520 }
504521
505522 private handleDelete = ( name : string ) => {
0 commit comments