From 4b1898aa7f82e400b5958293c6c0a5dce5da6d6c Mon Sep 17 00:00:00 2001 From: zss <zss@example.com> Date: 星期二, 18 二月 2025 14:44:26 +0800 Subject: [PATCH] 在线预览调整 --- src/components/do/a8-file-handling/FileChangeRequest.vue | 35 +++++++++++++++++++++++++++++------ 1 files changed, 29 insertions(+), 6 deletions(-) diff --git a/src/components/do/a8-file-handling/FileChangeRequest.vue b/src/components/do/a8-file-handling/FileChangeRequest.vue index 00f24ac..106bd3b 100644 --- a/src/components/do/a8-file-handling/FileChangeRequest.vue +++ b/src/components/do/a8-file-handling/FileChangeRequest.vue @@ -419,13 +419,33 @@ 'Content-Type': 'application/json' },responseType: "blob"},).then(res => { this.outLoading = false - this.$message.success('瀵煎嚭鎴愬姛') const blob = new Blob([res],{ type: 'application/octet-stream' }); - const url = URL.createObjectURL(blob); - const link = document.createElement('a'); - link.href = url; - link.download = '鏂囦欢鍙樻洿璁板綍.xlsx'; - link.click(); + //灏咮lob 瀵硅薄杞崲鎴愬瓧绗︿覆 + let reader = new FileReader(); + reader.readAsText(blob, 'utf-8'); + reader.onload = () => { + try { + let result = JSON.parse(reader.result); + if (result.message) { + this.$message.error(result.message); + } else { + const url = URL.createObjectURL(blob); + const link = document.createElement('a'); + link.href = url; + link.download = '鏂囦欢鍙樻洿璁板綍.xlsx'; + link.click(); + this.$message.success('瀵煎嚭鎴愬姛') + } + } catch (err) { + console.log(err); + const url = URL.createObjectURL(blob); + const link = document.createElement('a'); + link.href = url; + link.download = '鏂囦欢鍙樻洿璁板綍.xlsx'; + link.click(); + this.$message.success('瀵煎嚭鎴愬姛') + } + } }) }, getAuthorizedPerson() { @@ -465,6 +485,9 @@ // 褰撳墠鏂囦欢 getCurrentFile(e){ this.currentFile = this.fileList.find(m=>m.documentCode==e) + if(!this.currentFile){ + this.currentFile = {} + } }, selectEnumByCategory() { this.$axios.post(this.$api.enums.selectEnumByCategory, { -- Gitblit v1.9.3