mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 19:19:57 +08:00
remove file on file failture
This commit is contained in:
parent
97ac458507
commit
f9450f14df
@ -30,22 +30,36 @@ const AntUpload = React.createClass({
|
||||
});
|
||||
this.props.onStart(file);
|
||||
},
|
||||
removeFile(file){
|
||||
var downloadList = this.state.downloadList.concat();
|
||||
let targetItem = getFileItem(file, downloadList);
|
||||
var index = downloadList.indexOf(targetItem);
|
||||
if (index !== -1) {
|
||||
downloadList.splice(index, 1);
|
||||
}
|
||||
this.setState({
|
||||
downloadList: downloadList
|
||||
});
|
||||
},
|
||||
onSuccess(ret, file) {
|
||||
var res = this.props.onSuccess(ret, file);
|
||||
if (res !== false) {
|
||||
Message.success(file.name + '上传完成');
|
||||
let targetItem = getFileItem(file, this.state.downloadList);
|
||||
let targetItem = getFileItem(file, downloadList);
|
||||
targetItem.status = 'done';
|
||||
this.setState({
|
||||
downloadList: this.state.downloadList
|
||||
});
|
||||
} else {
|
||||
this.removeFile(file);
|
||||
}
|
||||
},
|
||||
onProgress(e, file) {
|
||||
this.props.onProgress(e, file);
|
||||
},
|
||||
onError(err, responce, file) {
|
||||
Message.error('上传失败');
|
||||
Message.error(file.name + ' 上传失败');
|
||||
this.removeFile(file);
|
||||
this.props.onError(err, responce, file);
|
||||
},
|
||||
onRemove(file){
|
||||
|
Loading…
Reference in New Issue
Block a user