Merge remote-tracking branch 'baidu/master'
This commit is contained in:
commit
56b79c6ca1
|
@ -380,7 +380,7 @@ export default class FormControl extends React.PureComponent<
|
|||
(validateOnChange !== false && (form.submited || this.model.validated))
|
||||
) {
|
||||
this.lazyValidate();
|
||||
} else if (validateOnChange === false && !this.model.valid) {
|
||||
} else if (validateOnChange === false) {
|
||||
this.model.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -400,7 +400,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|||
return;
|
||||
}
|
||||
|
||||
const __ = this.props.translate;
|
||||
const {translate: __, multiple, autoFill, onBulkChange} = this.props;
|
||||
const file = find(
|
||||
this.state.files,
|
||||
item => item.state === 'pending'
|
||||
|
@ -441,7 +441,16 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|||
error: error ? error : null,
|
||||
files: files
|
||||
},
|
||||
this.tick
|
||||
() => {
|
||||
const sendTo =
|
||||
!multiple &&
|
||||
autoFill &&
|
||||
!isEmpty(autoFill) &&
|
||||
dataMapping(autoFill, obj || {});
|
||||
sendTo && onBulkChange(sendTo);
|
||||
|
||||
this.tick();
|
||||
}
|
||||
);
|
||||
},
|
||||
progress => {
|
||||
|
@ -498,10 +507,7 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|||
asBase64,
|
||||
asBlob,
|
||||
data,
|
||||
translate: __,
|
||||
multiple,
|
||||
autoFill,
|
||||
onBulkChange
|
||||
translate: __
|
||||
} = this.props;
|
||||
|
||||
if (asBase64) {
|
||||
|
@ -563,13 +569,6 @@ export default class FileControl extends React.Component<FileProps, FileState> {
|
|||
onProgress(1);
|
||||
const value = (ret.data as any).value || ret.data;
|
||||
|
||||
const sendTo =
|
||||
!multiple &&
|
||||
autoFill &&
|
||||
!isEmpty(autoFill) &&
|
||||
dataMapping(autoFill, ret.data);
|
||||
sendTo && onBulkChange(sendTo);
|
||||
|
||||
cb(null, file, {
|
||||
...(isPlainObject(ret.data) ? ret.data : null),
|
||||
value: value,
|
||||
|
|
|
@ -369,6 +369,7 @@ export default class ImageControl extends React.Component<
|
|||
}
|
||||
|
||||
tick() {
|
||||
const {multiple, autoFill, onBulkChange} = this.props;
|
||||
if (this.current || !this.state.uploading) {
|
||||
return;
|
||||
}
|
||||
|
@ -428,7 +429,16 @@ export default class ImageControl extends React.Component<
|
|||
{
|
||||
files: this.files = files
|
||||
},
|
||||
this.tick
|
||||
() => {
|
||||
const sendTo =
|
||||
!multiple &&
|
||||
autoFill &&
|
||||
!isEmpty(autoFill) &&
|
||||
dataMapping(autoFill, obj || {});
|
||||
sendTo && onBulkChange(sendTo);
|
||||
|
||||
this.tick();
|
||||
}
|
||||
);
|
||||
},
|
||||
progress => {
|
||||
|
@ -764,7 +774,7 @@ export default class ImageControl extends React.Component<
|
|||
cb: (error: null | string, file: Blob, obj?: FileValue) => void,
|
||||
onProgress: (progress: number) => void
|
||||
) {
|
||||
const {translate: __, multiple, autoFill, onBulkChange} = this.props;
|
||||
const __ = this.props.translate;
|
||||
this._send(file, this.props.reciever as string, {}, onProgress)
|
||||
.then((ret: Payload) => {
|
||||
if (ret.status) {
|
||||
|
@ -777,13 +787,6 @@ export default class ImageControl extends React.Component<
|
|||
};
|
||||
obj.value = obj.value || obj.url;
|
||||
|
||||
const sendTo =
|
||||
!multiple &&
|
||||
autoFill &&
|
||||
!isEmpty(autoFill) &&
|
||||
dataMapping(autoFill, obj);
|
||||
sendTo && onBulkChange(sendTo);
|
||||
|
||||
cb(null, file, obj);
|
||||
})
|
||||
.catch(error => cb(error.message || __('上传失败,请重试'), file));
|
||||
|
|
|
@ -565,6 +565,12 @@ export const FormItemStore = types
|
|||
|
||||
const form = self.form;
|
||||
const value = self.value;
|
||||
|
||||
// 有可能销毁了
|
||||
if (!form) {
|
||||
return;
|
||||
}
|
||||
|
||||
const selected = Array.isArray(value)
|
||||
? value.map(item =>
|
||||
item && item.hasOwnProperty(self.valueField || 'value')
|
||||
|
|
Loading…
Reference in New Issue