pipeIn pipeOut 逻辑修复

This commit is contained in:
liaoxuezhi 2019-11-27 17:05:09 +08:00
parent 7b593155f2
commit 4ba27608e6
2 changed files with 8 additions and 6 deletions

View File

@ -346,8 +346,9 @@ export default class FormControl extends React.PureComponent<
changeImmediately: boolean = false
) {
const {
formStore: form,
onChange,
control: {type},
control: {type, pipeOut},
formInited
} = this.props;
@ -357,6 +358,11 @@ export default class FormControl extends React.PureComponent<
return;
}
if (pipeOut) {
const oldValue = this.model.value;
value = pipeOut(value, oldValue, form.data);
}
this.setState(
{
value
@ -374,16 +380,13 @@ export default class FormControl extends React.PureComponent<
onChange,
control: {validateOnChange, name, pipeOut, onChange: onFormItemChange}
} = this.props;
if (!this.model) {
return;
}
let value = this.state.value;
const oldValue = this.model.value;
if (pipeOut) {
value = pipeOut(value, oldValue, form.data);
}
if (oldValue === value) {
return;
}

View File

@ -3,7 +3,6 @@ import cx from 'classnames';
import React from 'react';
import hoistNonReactStatic = require('hoist-non-react-statics');
import {ExtractProps, Omit} from './types';
import PropTypes from 'prop-types';
export type ClassValue =
| string