From 5c6dff988800d35b0f615cd439338d6abc52ac19 Mon Sep 17 00:00:00 2001 From: renpy Date: Mon, 28 Aug 2023 15:11:50 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=96=87=E4=BB=B6=E5=88=97?= =?UTF-8?q?=E8=A1=A8=E8=A1=A8=E6=A0=BC=E7=9A=84=E6=A0=B7=E5=BC=8F=E5=8F=8A?= =?UTF-8?q?=E5=88=97=E8=A1=A8=E5=88=86=E9=A1=B5=E5=8F=82=E6=95=B0=20?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E7=9A=84=E9=80=BB=E8=BE=91?= =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=8F=8A=E6=8E=A5=E5=8F=A3=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/Modals/LoadFromFileModal.vue | 104 ++++++------------ 1 file changed, 31 insertions(+), 73 deletions(-) diff --git a/src/views/spectrumAnalysis/components/Modals/LoadFromFileModal.vue b/src/views/spectrumAnalysis/components/Modals/LoadFromFileModal.vue index 960033d..d8acb25 100644 --- a/src/views/spectrumAnalysis/components/Modals/LoadFromFileModal.vue +++ b/src/views/spectrumAnalysis/components/Modals/LoadFromFileModal.vue @@ -30,7 +30,11 @@ @@ -144,6 +123,7 @@ const columns_file = [ { title: 'Name', dataIndex: 'name', + width: '45%', align: 'left', ellipsis: true },{ @@ -184,21 +164,9 @@ export default { total: 0 }, selectedRowKeys: [], - visible_upload: false, - type: undefined, - typeOptions: [ - { - label: "stop", - value: "stop" - },{ - label: "over", - value: "over" - },{ - label: "skip", - value: "skip" - }, - ], fileList: [], + fileNum: 0, + uploading: false } }, methods: { @@ -224,6 +192,7 @@ export default { getAction("/spectrumFile/get", params).then(res => { this.loading_file = false if (res.success) { + this.ipagination.total = res.result.total this.list_file = res.result.records } else { this.$message.warning("This operation fails. Contact your system administrator") @@ -250,25 +219,30 @@ export default { console.log('selectedRowKeys changed: ', selectedRowKeys); this.selectedRowKeys = selectedRowKeys; }, - - handleUpload() { - this.visible_upload = true - }, - onTypeChange(val) { - console.log(val); - this.type = val - }, beforeUpload(file,fileList) { - console.log(file, fileList); this.fileList = fileList - // this.fileList = [...this.fileList, file] - }, - // async transformFile() { - // // 创建jszip实例 - // let zipData = await this.zipFile(this.fileList, (added) => {}) - // console.log(zipData); - // }, + async handleUpload({ file }) { + this.uploading = true + this.fileNum += 1 + if (this.fileNum == this.fileList.length) { + await this.zipFile(this.fileList, (added) => { }).then(content => { + let file = new File([content], 'test.zip', { type: content.type }) + const formData = new FormData() + formData.append("file",file) + postAction("/spectrumFile/upload", formData).then(res => { + this.uploading = false + this.fileNum = 0 + if (res.success) { + console.log(res); + this.$message.success(res.message) + } else { + this.$message.warning(res.message) + } + }) + }) + } + }, async zipFile(fileList, onProgress) { const zip = new JSZip() let i = 0 @@ -294,22 +268,6 @@ export default { } }) }, - async handleUploadFile() { - await this.zipFile(this.fileList, (added) => { }).then(content => { - console.log(content); - - const formData = new FormData() - formData.append("file",content) - formData.append("choice",this.type) - postAction("/spectrumFile/upload", formData).then(res => { - if (res.success) { - console.log(res); - } else { - this.$message.warning("This operation fails. Contact your system administrator") - } - }) - }) - }, handleReset() { this.list = this.getInitialList()