mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-03 12:38:53 +08:00
修复 formitem 的修改应该记录最后一次的结果
This commit is contained in:
parent
47008ca307
commit
6ff27bc335
@ -53,7 +53,7 @@ export default class FormControl extends React.PureComponent<
|
||||
static defaultProps = {};
|
||||
|
||||
lazyValidate: Function;
|
||||
lazyEmitChange: (value: any, submitOnChange: boolean) => void;
|
||||
lazyEmitChange: (submitOnChange: boolean) => void;
|
||||
state = {value: this.props.control.value};
|
||||
componentWillMount() {
|
||||
const {
|
||||
@ -142,7 +142,7 @@ export default class FormControl extends React.PureComponent<
|
||||
if (name && form !== store) {
|
||||
const value = getVariable(store.data, name);
|
||||
if (typeof value !== 'undefined' && value !== this.getValue()) {
|
||||
this.emitChange(value, false);
|
||||
this.handleChange(value, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -261,7 +261,7 @@ export default class FormControl extends React.PureComponent<
|
||||
(value = getVariable(data as any, name)) !==
|
||||
getVariable(prevProps.data, name)
|
||||
) {
|
||||
this.emitChange(value, false);
|
||||
this.handleChange(value, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -362,15 +362,12 @@ export default class FormControl extends React.PureComponent<
|
||||
},
|
||||
() =>
|
||||
changeImmediately
|
||||
? this.emitChange(value, submitOnChange)
|
||||
: this.lazyEmitChange(value, submitOnChange)
|
||||
? this.emitChange(submitOnChange)
|
||||
: this.lazyEmitChange(submitOnChange)
|
||||
);
|
||||
}
|
||||
|
||||
emitChange(
|
||||
value: any,
|
||||
submitOnChange: boolean = this.props.control.submitOnChange
|
||||
) {
|
||||
emitChange(submitOnChange: boolean = this.props.control.submitOnChange) {
|
||||
const {
|
||||
formStore: form,
|
||||
onChange,
|
||||
@ -379,7 +376,7 @@ export default class FormControl extends React.PureComponent<
|
||||
if (!this.model) {
|
||||
return;
|
||||
}
|
||||
|
||||
let value = this.state.value;
|
||||
const oldValue = this.model.value;
|
||||
|
||||
if (pipeOut) {
|
||||
|
@ -342,7 +342,11 @@ export const FormItemStore = types
|
||||
data: object,
|
||||
options?: fetchOptions,
|
||||
clearValue?: any,
|
||||
onChange?: (value: any) => void
|
||||
onChange?: (
|
||||
value: any,
|
||||
submitOnChange: boolean,
|
||||
changeImmediately: boolean
|
||||
) => void
|
||||
) {
|
||||
try {
|
||||
if (loadCancel) {
|
||||
@ -387,11 +391,11 @@ export const FormItemStore = types
|
||||
setOptions(options);
|
||||
|
||||
if (json.data && typeof (json.data as any).value !== 'undefined') {
|
||||
onChange && onChange((json.data as any).value);
|
||||
onChange && onChange((json.data as any).value, false, true);
|
||||
} else if (clearValue) {
|
||||
self.selectedOptions.some((item: any) => item.__unmatched) &&
|
||||
onChange &&
|
||||
onChange('');
|
||||
onChange('', false, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user