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