From 90d12791773f1347c4e429f68c848db4ef73b8cf Mon Sep 17 00:00:00 2001 From: yaojn Date: Tue, 18 Mar 2025 11:53:40 +0800 Subject: [PATCH] =?UTF-8?q?-=20[=E5=8A=9F=E8=83=BD]=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BB=84=E4=BB=B6=E5=8F=96=E6=B6=88=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=A7=E5=B0=8F=E9=99=90=E5=88=B6=20=20=20=20-=20[?= =?UTF-8?q?=E5=85=B3=E8=81=94]#[1361642678353920]=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E7=BB=84=E4=BB=B6=E5=8F=96=E6=B6=88=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=A4=A7=E5=B0=8F=E9=99=90=E5=88=B6=20http://192.168.?= =?UTF-8?q?0.96:8090/demo/rdm.html#/story-detail/939050947543040/939050947?= =?UTF-8?q?543042/1361642678353920?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/resources/components/UpLoad/UpLoad.vue | 14 ++++-- .../components/UploadDialog/UploadDialog.vue | 49 ++++++++++++++++--- .../matrix/components/UploadDialog.vue | 48 +++++++++++++++--- 4 files changed, 93 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 7eec1503..c9c79fb5 100755 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "marked": "^7.0.1", "mavon-editor": "^2.10.4", "navigator": "^1.0.1", - "neatlogic-ui": "^1.0.6", + "neatlogic-ui": "^1.0.7", "particles.vue": "^2.42.2", "qs": "^6.11.2", "save": "^2.4.0", diff --git a/src/resources/components/UpLoad/UpLoad.vue b/src/resources/components/UpLoad/UpLoad.vue index 7513d4b9..4a9e2dc2 100644 --- a/src/resources/components/UpLoad/UpLoad.vue +++ b/src/resources/components/UpLoad/UpLoad.vue @@ -37,13 +37,10 @@

{{ title }}

-
-
- +

{{ $t('page.clickanddragfile') }}

-
@@ -178,7 +175,7 @@ export default { }, maxsize: { type: Number, - default: 1000000 + default: 0 }, defaultList: { type: Array, @@ -286,6 +283,12 @@ export default { Object.assign(this.filedata, this.params); }, created() {}, + destroyed() { + const uploadRef = this.$refs.upload; + if (uploadRef) { + uploadRef.clearFiles(); + } + }, methods: { openDialog() { this.isShowScreenshotFromClicpboardDialog = true; @@ -382,6 +385,7 @@ export default { handleRemoveFile(item) { const fileList = this.$refs.upload.fileList; this.$refs.upload.fileList.splice(fileList.indexOf(item), 1); + this.$refs.upload.handleCancelAjax(item); this.$emit('remove', this.$refs.upload.fileList, item.id); }, //下载请求 diff --git a/src/resources/components/UploadDialog/UploadDialog.vue b/src/resources/components/UploadDialog/UploadDialog.vue index 4d6f2a08..c6b019c6 100644 --- a/src/resources/components/UploadDialog/UploadDialog.vue +++ b/src/resources/components/UploadDialog/UploadDialog.vue @@ -37,7 +37,7 @@
{{ uploadFilelimitTips(multiple, formatList) }}
- {{ $t('page.uploadfilelimit', {target: maxSize}) }} +
@@ -183,7 +183,7 @@ export default { data: { type: Object, default: () => {} }, //上传时附带的额外参数 dataType: { type: String, default: 'file' }, formatList: { type: Array, default: () => [] }, - maxSize: { type: Number, default: 10 }, //文件大小限制,单位为MB + maxSize: { type: Number, default: 0 }, //文件大小限制,单位为MB multiple: { type: Boolean, default: true }, beforeUpload: { type: Function, default: null }, //自定义的上传前处理函数 immediatelyUpload: { type: Boolean, default: false }, @@ -218,6 +218,12 @@ export default { isImport: false }; }, + destroyed() { + const uploadRef = this.$refs.upload; + if (uploadRef) { + uploadRef.clearFiles(); + } + }, methods: { async showDialog() { this.fileList = [...this.fileList, ...this.defaultFileList]; @@ -230,6 +236,16 @@ export default { }, hideDialog() { this.isModalShow = false; + let uploadRef = this.$refs.upload; + this.fileList.forEach(item => { + if (item && typeof item.Status == 'number' && item.Status != 0 && item.Status < 100 && item.xhr) { + if (uploadRef) { + uploadRef.handleCancelAjax({ + ...item + }); + } + } + }); this.fileList = []; this.validConfig = { failureCount: 0, @@ -281,7 +297,10 @@ export default { return this.immediatelyUpload; }, handleProgress(event, file, fileList) { - this.fileList.find(item => item.file.name === file.name).Status = event.percent; + let findFileItem = this.fileList.find(item => item.file.name === file.name); + if (findFileItem) { + findFileItem.Status = event.percent; + } }, handleSuccess(response, file) { let desc = ''; @@ -338,11 +357,21 @@ export default { title: this.$t('message.importfailed'), desc: response.Message }); - this.fileList.find(item => item.file.name === file.name).Status = response.Status; + let findFileItem = this.fileList.find(item => item.file.name === file.name); + if (findFileItem) { + findFileItem.Status = response.Status; + } } }, removeFile(file) { this.fileList.splice(this.fileList.indexOf(file), 1); + let uploadRef = this.$refs.upload; + if (uploadRef && file.Status > 0 && file.Status < 100) { + uploadRef.handleCancelAjax({ + ...file, + status: file.Status == 100 ? 'finsihed' : 'uploading' + }); + } this.$emit('update:defaultFileList', this.fileList); this.$emit('on-remove-file', file, this.fileList); }, @@ -359,8 +388,12 @@ export default { } this.fileList .filter(item => item.Status !== 'OK' && item.Status !== 'ERROR') - .map(item => { - this.$refs.upload.post(item.file); + .forEach(item => { + let { xhr = '', status = '' } = this.$refs.upload.post(item.file); + if (xhr) { + item.xhr = xhr; + item.status = status; + } }); this.$nextTick(() => { this.isImport = true; @@ -447,7 +480,7 @@ export default { width: 270px; height: 100%; } - /deep/ .ivu-upload-drag{ + /deep/ .ivu-upload-drag { height: 100%; } .drag-area { @@ -543,7 +576,7 @@ export default { margin-left: 280px; width: 510px; height: 100%; - .valid-icon{ + .valid-icon { display: inline-block; padding-right: 10px; } diff --git a/src/views/pages/framework/matrix/components/UploadDialog.vue b/src/views/pages/framework/matrix/components/UploadDialog.vue index 17469c77..dbe66070 100644 --- a/src/views/pages/framework/matrix/components/UploadDialog.vue +++ b/src/views/pages/framework/matrix/components/UploadDialog.vue @@ -37,7 +37,9 @@
{{ uploadFilelimitTips(multiple, formatList) }}
- {{ $t('page.uploadfilelimit', {target: maxSize}) }} +
@@ -210,7 +212,7 @@ export default { data: { type: Object, default: () => {} }, //上传时附带的额外参数 dataType: { type: String, default: 'file' }, formatList: { type: Array, default: () => [] }, - maxSize: { type: Number, default: 10 }, //文件大小限制,单位为MB + maxSize: { type: Number, default: 0 }, //文件大小限制,单位为MB multiple: { type: Boolean, default: true }, beforeUpload: { type: Function, default: null }, //自定义的上传前处理函数 immediatelyUpload: { type: Boolean, default: false }, @@ -289,6 +291,13 @@ export default { } }; }, + destroyed() { + // 清空上传组件 + const uploadRef = this.$refs.upload; + if (uploadRef) { + uploadRef.clearFiles(); + } + }, methods: { async showDialog() { this.fileList = [...this.fileList, ...this.defaultFileList]; @@ -301,6 +310,16 @@ export default { }, hideDialog() { this.isModalShow = false; + let uploadRef = this.$refs.upload; + this.fileList.forEach(item => { + if (item && typeof item.Status == 'number' && item.Status != 0 && item.Status < 100 && item.xhr) { + if (uploadRef) { + uploadRef.handleCancelAjax({ + ...item + }); + } + } + }); this.fileList = []; this.validConfig = { failureCount: 0, @@ -352,7 +371,10 @@ export default { return this.immediatelyUpload; }, handleProgress(event, file, fileList) { - this.fileList.find(item => item.file.name === file.name).Status = event.percent; + let findFileItem = this.fileList.find(item => item.file.name === file.name); + if (findFileItem) { + findFileItem.Status = event.percent; + } }, handleSuccess(response, file) { let desc = ''; @@ -422,11 +444,21 @@ export default { title: this.$t('message.importfailed'), desc: response.Message }); - this.fileList.find(item => item.file.name === file.name).Status = response.Status; + let findFileItem = this.fileList.find(item => item.file.name === file.name); + if (findFileItem) { + findFileItem.Status = response.Status; + } } }, removeFile(file) { this.fileList.splice(this.fileList.indexOf(file), 1); + let uploadRef = this.$refs.upload; + if (uploadRef && file.Status > 0 && file.Status < 100) { + uploadRef.handleCancelAjax({ + ...file, + status: file.Status == 100 ? 'finsihed' : 'uploading' + }); + } this.$emit('update:defaultFileList', this.fileList); this.$emit('on-remove-file', file, this.fileList); }, @@ -443,8 +475,12 @@ export default { } this.fileList .filter(item => item.Status !== 'OK' && item.Status !== 'ERROR') - .map(item => { - this.$refs.upload.post(item.file); + .forEach(item => { + let { xhr = '', status = '' } = this.$refs.upload.post(item.file); + if (xhr) { + item.xhr = xhr; + item.status = status; + } }); this.$nextTick(() => { this.isImport = true; -- Gitee