From 5c8aaba66c16b1a143fdec27e29ad36eaefd1e3a Mon Sep 17 00:00:00 2001 From: licp <lichunping@guanfang.com.cn> Date: 星期二, 31 十二月 2024 14:33:25 +0800 Subject: [PATCH] 无源器件检验开发 --- src/components/do/a8-file-handling/FileObsoletionRequest.vue | 40 +++++++++++++++++++++++++++++++--------- 1 files changed, 31 insertions(+), 9 deletions(-) diff --git a/src/components/do/a8-file-handling/FileObsoletionRequest.vue b/src/components/do/a8-file-handling/FileObsoletionRequest.vue index 0af73dc..90bfc86 100644 --- a/src/components/do/a8-file-handling/FileObsoletionRequest.vue +++ b/src/components/do/a8-file-handling/FileObsoletionRequest.vue @@ -374,9 +374,11 @@ changeFileList(e){ if(e){ let obj = this.fileList.find(a=>a.documentCode == e) - this.addInfo.name = obj.name - this.addInfo.version = obj.version - this.addInfo.documentState = obj.state + if(obj){ + this.addInfo.name = obj.name + this.addInfo.version = obj.version + this.addInfo.documentState = obj.state + } } }, handleUpdate(row){ @@ -434,13 +436,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('瀵煎嚭鎴愬姛') + } + } }) } } -- Gitblit v1.9.3