Add error status for upload file item

This commit is contained in:
afc163 2015-09-14 00:28:39 +08:00
parent 8d6b3be20f
commit fcc8c26166
4 changed files with 9 additions and 5 deletions

View File

@ -18,7 +18,7 @@ var props = {
}
if (info.file.status === 'done') {
message.success(info.file.name + ' 上传成功。');
} else if (info.file.error) {
} else if (info.file.status === 'error') {
message.error(info.file.name + ' 上传失败。');
}
}

View File

@ -19,7 +19,7 @@ var props = {
}
if (info.file.status === 'done') {
message.success(info.file.name + ' 上传成功。');
} else if (info.file.error) {
} else if (info.file.status === 'error') {
message.error(info.file.name + ' 上传失败。');
}
}

View File

@ -31,7 +31,6 @@ const AntUpload = React.createClass({
});
},
removeFile(file) {
file.status = 'removed';
let fileList = this.state.fileList.concat();
let targetItem = getFileItem(file, fileList);
let index = fileList.indexOf(targetItem);
@ -68,6 +67,7 @@ const AntUpload = React.createClass({
onError(error, response, file) {
file.error = error;
file.response = response;
file.status = 'error';
this.handleRemove(file);
},
handleRemove(file) {
@ -79,6 +79,10 @@ const AntUpload = React.createClass({
});
}
},
handleManualRemove(file) {
file.status = 'removed';
this.handleRemove(file);
},
onChange(info) {
// 1. fileList
// 2. info.event fileList
@ -134,7 +138,7 @@ const AntUpload = React.createClass({
</Upload>
</div>
<UploadList items={this.state.fileList}
onRemove={this.handleRemove}/>
onRemove={this.handleManualRemove} />
</div>
);
}

View File

@ -45,7 +45,7 @@
{
uid: 'uid', // 文件唯一标识,建议设置为负数,防止和内部产生的 id 冲突
name: 'xx.png' // 文件名
status: 'done', // 状态uploading done
status: 'done', // 状态uploading done error removed
response: '{"status":"success"}' // 服务端响应内容
}
```