From 7d82eccb418ee72bc162464c607ae6de07af837c Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 19 Sep 2015 17:05:41 +0800 Subject: [PATCH] update upload list logic --- components/upload/index.jsx | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/components/upload/index.jsx b/components/upload/index.jsx index e06f2b0367..bb7d259a9a 100644 --- a/components/upload/index.jsx +++ b/components/upload/index.jsx @@ -30,26 +30,27 @@ const AntUpload = React.createClass({ }; }, onStart(file) { + let targetItem; let nextFileList = this.state.fileList.concat(); if (file.length > 0) { - file = file.map(function(f) { + targetItem = file.map(function(f) { f = fileToObject(f); f.status = 'uploading'; return f; }); nextFileList = nextFileList.concat(file); } else { - file = fileToObject(file); - file.status = 'uploading'; - nextFileList.push(file); + targetItem = fileToObject(file); + targetItem.status = 'uploading'; + nextFileList.push(targetItem); } this.onChange({ - file: file, + file: targetItem, fileList: nextFileList }); }, removeFile(file) { - let fileList = this.state.fileList.concat(); + let fileList = this.state.fileList; let targetItem = getFileItem(file, fileList); let index = fileList.indexOf(targetItem); if (index !== -1) { @@ -69,7 +70,7 @@ const AntUpload = React.createClass({ this.onError(new Error('No response'), response, file); return; } - let fileList = this.state.fileList.concat(); + let fileList = this.state.fileList; let targetItem = getFileItem(file, fileList); // 之前已经删除 if (targetItem) { @@ -77,7 +78,7 @@ const AntUpload = React.createClass({ targetItem.response = response; this.onChange({ file: targetItem, - fileList: this.state.fileList + fileList: fileList }); } }, -- GitLab