diff --git a/component/UpLoad/UpLoad.vue b/component/UpLoad/UpLoad.vue index c5599cda88a9252dc831cb83fdd319dbb721ef92..e2d58be804754ead76a834850864000b97322623 100644 --- a/component/UpLoad/UpLoad.vue +++ b/component/UpLoad/UpLoad.vue @@ -33,19 +33,19 @@
-
- - {{ item.name }} - - - -
+
+ + {{ item.name }} + + + +
diff --git a/component/UserCard/UserCard.vue b/component/UserCard/UserCard.vue index 223b1a00fb933e857b6bac8feea91cac22d813ce..97f0ecc3209ca43f14cc7dae773b3135faf38931 100644 --- a/component/UserCard/UserCard.vue +++ b/component/UserCard/UserCard.vue @@ -29,15 +29,15 @@
-
- - {{ user.userName }} -
+
+ + {{ user.userName }} +
diff --git a/iview/components/upload/ajax.js b/iview/components/upload/ajax.js index 1089c4e9cd6101337601fff5fce772c21e7755a6..59f16aee08b5312629a9b0f57afc306eb3ced5d1 100644 --- a/iview/components/upload/ajax.js +++ b/iview/components/upload/ajax.js @@ -81,4 +81,5 @@ export default function upload(option) { } } xhr.send(formData); + return xhr; // 返回xhr对象,可用于中断上传 } diff --git a/iview/components/upload/upload.vue b/iview/components/upload/upload.vue index 53d5baf2093d761cf2fc31a769852dee5643f619..718a02b76bccced626057f7bb4093f5f4c07eb55 100644 --- a/iview/components/upload/upload.vue +++ b/iview/components/upload/upload.vue @@ -231,11 +231,11 @@ export default { } } - this.handleStart(file); + const _file = this.handleStart(file); let formData = new FormData(); formData.append(this.name, file); - ajax({ + _file.xhr = ajax({ headers: this.headers, withCredentials: this.withCredentials, file: file, @@ -252,6 +252,7 @@ export default { this.handleError(err, response, file); } }); + return _file; }, handleStart(file) { file.uid = Date.now() + this.tempIndex++; @@ -265,6 +266,7 @@ export default { }; this.fileList.push(_file); + return _file; }, getFile(file) { const fileList = this.fileList; @@ -308,15 +310,29 @@ export default { }, handleRemove(file) { const fileList = this.fileList; + if(file && file.xhr) { + file.xhr.abort(); + } fileList.splice(fileList.indexOf(file), 1); this.onRemove(file, fileList); }, + handleCancelAjax(file) { + // 处理取消上传 + if(file && file.xhr && file.status == 'uploading') { + file.xhr.abort(); + } + }, handlePreview(file) { if (file.status === 'finished') { this.onPreview(file); } }, clearFiles() { + this.fileList.forEach(file => { + if(file && file.xhr) { + file.xhr.abort(); + } + }); this.fileList = []; } }, diff --git a/package.json b/package.json index f2c2f899d06a5139884a8b967bf32841772f437c..1b3f6e44a83fa21a59721cfce85dcaf81560af14 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "neatlogic-ui", - "version": "1.0.6", + "version": "1.0.7", "private": false, "main": "dist/neatlogic-ui.umd.min.js", "author": "neatlogic",