remove file on file failture

This commit is contained in:
yiminghe 2015-08-27 17:35:10 +08:00
parent 97ac458507
commit f9450f14df

View File

@ -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){