mirror of
https://gitee.com/baidu/amis.git
synced 2024-12-04 04:59:17 +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 = {};
|
static defaultProps = {};
|
||||||
|
|
||||||
lazyValidate: Function;
|
lazyValidate: Function;
|
||||||
lazyEmitChange: (value: any, submitOnChange: boolean) => void;
|
lazyEmitChange: (submitOnChange: boolean) => void;
|
||||||
state = {value: this.props.control.value};
|
state = {value: this.props.control.value};
|
||||||
componentWillMount() {
|
componentWillMount() {
|
||||||
const {
|
const {
|
||||||
@ -142,7 +142,7 @@ export default class FormControl extends React.PureComponent<
|
|||||||
if (name && form !== store) {
|
if (name && form !== store) {
|
||||||
const value = getVariable(store.data, name);
|
const value = getVariable(store.data, name);
|
||||||
if (typeof value !== 'undefined' && value !== this.getValue()) {
|
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)) !==
|
(value = getVariable(data as any, name)) !==
|
||||||
getVariable(prevProps.data, 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
|
changeImmediately
|
||||||
? this.emitChange(value, submitOnChange)
|
? this.emitChange(submitOnChange)
|
||||||
: this.lazyEmitChange(value, submitOnChange)
|
: this.lazyEmitChange(submitOnChange)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
emitChange(
|
emitChange(submitOnChange: boolean = this.props.control.submitOnChange) {
|
||||||
value: any,
|
|
||||||
submitOnChange: boolean = this.props.control.submitOnChange
|
|
||||||
) {
|
|
||||||
const {
|
const {
|
||||||
formStore: form,
|
formStore: form,
|
||||||
onChange,
|
onChange,
|
||||||
@ -379,7 +376,7 @@ export default class FormControl extends React.PureComponent<
|
|||||||
if (!this.model) {
|
if (!this.model) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
let value = this.state.value;
|
||||||
const oldValue = this.model.value;
|
const oldValue = this.model.value;
|
||||||
|
|
||||||
if (pipeOut) {
|
if (pipeOut) {
|
||||||
|
@ -342,7 +342,11 @@ export const FormItemStore = types
|
|||||||
data: object,
|
data: object,
|
||||||
options?: fetchOptions,
|
options?: fetchOptions,
|
||||||
clearValue?: any,
|
clearValue?: any,
|
||||||
onChange?: (value: any) => void
|
onChange?: (
|
||||||
|
value: any,
|
||||||
|
submitOnChange: boolean,
|
||||||
|
changeImmediately: boolean
|
||||||
|
) => void
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
if (loadCancel) {
|
if (loadCancel) {
|
||||||
@ -387,11 +391,11 @@ export const FormItemStore = types
|
|||||||
setOptions(options);
|
setOptions(options);
|
||||||
|
|
||||||
if (json.data && typeof (json.data as any).value !== 'undefined') {
|
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) {
|
} else if (clearValue) {
|
||||||
self.selectedOptions.some((item: any) => item.__unmatched) &&
|
self.selectedOptions.some((item: any) => item.__unmatched) &&
|
||||||
onChange &&
|
onChange &&
|
||||||
onChange('');
|
onChange('', false, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user