From d2a06b827fdcf4b274c503c25b3c21fd727ccbbc Mon Sep 17 00:00:00 2001 From: gaoluyang <2820782392@qq.com> Date: 星期五, 07 三月 2025 10:18:45 +0800 Subject: [PATCH] 文件下载全局修改 --- src/views/business/inspectionTask/components/InspectionWord.vue | 13 -- src/views/CNAS/systemManagement/internalAuditManagement/components/ViewTestRecord.vue | 9 -- src/views/CNAS/systemManagement/documentRecords/approvalRecord.vue | 4 src/views/CNAS/resourceDemand/device/component/equipmentAcceptance.vue | 9 -- src/views/CNAS/systemManagement/managementReview/components/managementReviewPlan.vue | 3 src/api/cnas/process/reportResults.js | 2 src/views/CNAS/resourceDemand/facilitiesEnvironment/component/facilities-environmental-conditions/lightning-protection-detection.vue | 8 + src/views/CNAS/systemManagement/documentControl/components/FileList.vue | 3 src/views/business/unpass/components/unPassDialog.vue | 11 -- src/views/business/materialOrderComponents/materialOrder/filesLookVisible.vue | 11 -- src/views/business/productOrder/index.vue | 15 --- src/views/CNAS/resourceDemand/device/component/calibration.vue | 9 -- src/views/CNAS/systemManagement/documentControl/components/ControlledFileApplication.vue | 3 src/views/CNAS/systemManagement/documentRecords/outDocumenRecordt.vue | 3 src/views/CNAS/systemManagement/customerSatisfaction/index.vue | 9 -- src/views/CNAS/systemManagement/documentControl/components/FileChangeRequest.vue | 3 src/views/CNAS/process/uncertainty/index.vue | 7 + src/views/CNAS/systemManagement/documentRecords/revisionRecord.vue | 4 src/views/structural/capabilityAndLaboratory/laboratory/index.vue | 3 src/views/CNAS/process/sampleDisposal/index.vue | 9 + src/views/CNAS/systemManagement/correctiveAction/components/ViewTestRecord.vue | 9 -- src/views/business/reportPreparation/index.vue | 11 -- src/views/CNAS/process/reportResults/index.vue | 4 src/views/business/inspectionTask/inspection.vue | 11 -- src/views/CNAS/systemManagement/documentRecords/regularReviewsRecord.vue | 7 - src/views/CNAS/systemManagement/documentRecords/distributionCollectionRecord.vue | 4 src/views/CNAS/systemManagement/documentRecords/cancellationRecord.vue | 4 src/plugins/download.js | 42 +++++++--- 28 files changed, 73 insertions(+), 157 deletions(-) diff --git a/src/api/cnas/process/reportResults.js b/src/api/cnas/process/reportResults.js index a7f25d6..bfd2fd5 100644 --- a/src/api/cnas/process/reportResults.js +++ b/src/api/cnas/process/reportResults.js @@ -5,7 +5,7 @@ export function exportProcessReport(data) { return request({ url: "/processReport/exportProcessReport", - method: "post", + method: "get", data: data, }); } diff --git a/src/plugins/download.js b/src/plugins/download.js index c0c1878..36db93e 100644 --- a/src/plugins/download.js +++ b/src/plugins/download.js @@ -4,6 +4,7 @@ import { getToken } from "@/utils/auth"; import errorCode from "@/utils/errorCode"; import { blobValidate } from "@/utils/ruoyi"; +import Vue from "vue"; const baseURL = process.env.VUE_APP_BASE_API; let downloadLoadingInstance; @@ -80,22 +81,37 @@ downloadLoadingInstance.close(); }); }, + async downloadFileFromUrl(url, filename) { + try { + let state = /\.(jpg|jpeg|png|gif)$/i.test(url) // 鍒ゆ柇鏄惁涓哄浘鐗� + let url1 = '' + if (state) { + url1 = Vue.prototype.javaApi + '/img/' + url; + } else { + url1 = Vue.prototype.javaApi + '/word/' + url + } + // 浣跨敤 fetch 鑾峰彇鏂囦欢 + const response = await fetch(url1); + if (!response.ok) { + throw new Error('鏂囦欢涓嬭浇澶辫触: ' + response.statusText); + } + // 灏嗘枃浠惰浆鎹负 Blob + const blob = await response.blob(); + // 浣跨敤 saveAs 淇濆瓨鏂囦欢 + saveAs(blob, filename); + Message.success("鏁版嵁瀵煎嚭鎴愬姛"); + } catch (error) { + Message.error(error); + } + }, saveAs(text, name, opts) { - if (typeof text === "string") { - // 璺緞涓嬭浇 + // 娴佷笅杞� + blobToText(text).then((result) => { + Message.error(result.msg); + }).catch(() => { saveAs(text, name, opts); Message.success("鏁版嵁瀵煎嚭鎴愬姛"); - } else { - // 娴佷笅杞� - blobToText(text) - .then((result) => { - Message.error(result.msg); - }) - .catch(() => { - saveAs(text, name, opts); - Message.success("鏁版嵁瀵煎嚭鎴愬姛"); - }); - } + }); }, async printErrMsg(data) { const resText = await data.text(); diff --git a/src/views/CNAS/process/reportResults/index.vue b/src/views/CNAS/process/reportResults/index.vue index 08ad966..695cdc1 100644 --- a/src/views/CNAS/process/reportResults/index.vue +++ b/src/views/CNAS/process/reportResults/index.vue @@ -222,9 +222,7 @@ this.outLoading = true exportProcessReport({ ids: this.mutilSelect.map(m => m.id) }).then(res => { this.outLoading = false - if (res.code === 201) return - const url = this.javaApi + '/word/' + res.data; - this.$download.saveAs(url, "鎶ュ憡缁撴灉"); + this.$download.downloadFileFromUrl(res.data, "鎶ュ憡缁撴灉"); }) }, openAdd() { diff --git a/src/views/CNAS/process/sampleDisposal/index.vue b/src/views/CNAS/process/sampleDisposal/index.vue index 8759567..c534d45 100644 --- a/src/views/CNAS/process/sampleDisposal/index.vue +++ b/src/views/CNAS/process/sampleDisposal/index.vue @@ -1,5 +1,5 @@ <template> - <div class="sample-disposal"> + <div class="capacity-scope"> <el-tabs type="border-card" v-model="activeName" style="height: 100%;" @tab-click="queryParams.totaldealId = ''"> <el-tab-pane label="濉啓" name="濉啓" style="height: 100%;" :key="1"> <el-button size="small" type="primary" @click="handleAdd0" style="margin-left: 20px;">鏂板</el-button> @@ -505,9 +505,12 @@ }, // 瀵煎嚭璇︽儏 handleDown0(row) { + if (!row.url) { + this.$message.warning('鏆傛棤鏂囦欢') + return + } // 鍚庣涓嬭浇 - let url = this.javaApi + '/word/' + row.url - this.$download.saveAs(url, row.month + ' 鏍峰搧澶勭悊鐢宠琛�'); + this.$download.downloadFileFromUrl(row.url, row.month + ' 鏍峰搧澶勭悊鐢宠琛�'); }, handleDelete(row) { this.$confirm("鏄惁鍒犻櫎璇ユ潯鏁版嵁?", "鎻愮ず", { diff --git a/src/views/CNAS/process/uncertainty/index.vue b/src/views/CNAS/process/uncertainty/index.vue index 053008b..8aca44f 100644 --- a/src/views/CNAS/process/uncertainty/index.vue +++ b/src/views/CNAS/process/uncertainty/index.vue @@ -183,8 +183,11 @@ }) }, handleDown(row) { - let url = this.javaApi + '/word/' + row.reportUrl - this.$download.saveAs(url, row.reportName); + if (!row.reportUrl) { + this.$message.warning('鏆傛棤鏂囦欢') + return + } + this.$download.downloadFileFromUrl(row.reportUrl, row.reportName); }, beforeUpload(file) { if (file.size > 1024 * 1024 * 10) { diff --git a/src/views/CNAS/resourceDemand/device/component/calibration.vue b/src/views/CNAS/resourceDemand/device/component/calibration.vue index 0a83361..10954a3 100644 --- a/src/views/CNAS/resourceDemand/device/component/calibration.vue +++ b/src/views/CNAS/resourceDemand/device/component/calibration.vue @@ -416,14 +416,7 @@ }) }, handleAttachmentClick(row) { - let state = /\.(jpg|jpeg|png|gif)$/i.test(row.systemFileName) - if (state) { - let url = this.javaApi + '/img/' + row.systemFileName; - this.$download.saveAs(url, row.systemFileName) - } else { - const url = this.javaApi + '/word/' + row.systemFileName - this.$download.saveAs(url, row.systemFileName) - } + this.$download.downloadFileFromUrl(row.systemFileName, row.systemFileName) }, //瀵煎嚭 handleDown() { diff --git a/src/views/CNAS/resourceDemand/device/component/equipmentAcceptance.vue b/src/views/CNAS/resourceDemand/device/component/equipmentAcceptance.vue index 8dcd2c2..49004f4 100644 --- a/src/views/CNAS/resourceDemand/device/component/equipmentAcceptance.vue +++ b/src/views/CNAS/resourceDemand/device/component/equipmentAcceptance.vue @@ -197,14 +197,7 @@ }, // 涓嬭浇 upload(row) { - let url = ''; - if (row.type == 1) { - url = this.javaApi + '/img/' + row.fileUrl - this.$download.saveAs(url, row.fileName) - } else { - url = this.javaApi + '/word/' + row.fileUrl - this.$download.saveAs(url, row.fileName) - } + this.$download.downloadFileFromUrl(row.fileUrl, row.fileName) }, // 鍒犻櫎 delete(row) { diff --git a/src/views/CNAS/resourceDemand/facilitiesEnvironment/component/facilities-environmental-conditions/lightning-protection-detection.vue b/src/views/CNAS/resourceDemand/facilitiesEnvironment/component/facilities-environmental-conditions/lightning-protection-detection.vue index 48e5b68..71a7c67 100644 --- a/src/views/CNAS/resourceDemand/facilitiesEnvironment/component/facilities-environmental-conditions/lightning-protection-detection.vue +++ b/src/views/CNAS/resourceDemand/facilitiesEnvironment/component/facilities-environmental-conditions/lightning-protection-detection.vue @@ -250,9 +250,11 @@ }) }, download(row) { - let url = ''; - url = this.javaApi + '/img/' + row.systemFileName - this.$download.saveAs(url, row.fileName) + if (!row.systemFileName) { + this.$message.warning('鏆傛棤鏂囦欢') + return + } + this.$download.downloadFileFromUrl(row.systemFileName, row.fileName) } } } diff --git a/src/views/CNAS/systemManagement/correctiveAction/components/ViewTestRecord.vue b/src/views/CNAS/systemManagement/correctiveAction/components/ViewTestRecord.vue index 3c6a5bd..097d40f 100644 --- a/src/views/CNAS/systemManagement/correctiveAction/components/ViewTestRecord.vue +++ b/src/views/CNAS/systemManagement/correctiveAction/components/ViewTestRecord.vue @@ -111,14 +111,7 @@ }, // 涓嬭浇 upload(row) { - let url = ''; - if (row.type == 1) { - url = this.javaApi + '/img/' + row.fileUrl - this.$download.saveAs(url, row.fileName); - } else { - url = this.javaApi + '/word/' + row.fileUrl - this.$download.saveAs(url, row.fileName); - } + this.$download.downloadFileFromUrl(row.fileUrl, row.fileName); }, // 鍒犻櫎 delete(row) { diff --git a/src/views/CNAS/systemManagement/customerSatisfaction/index.vue b/src/views/CNAS/systemManagement/customerSatisfaction/index.vue index 4a1900c..ab7529b 100644 --- a/src/views/CNAS/systemManagement/customerSatisfaction/index.vue +++ b/src/views/CNAS/systemManagement/customerSatisfaction/index.vue @@ -307,14 +307,7 @@ }, // 涓嬭浇瀹㈡埛绂忓缓 upload(row) { - let url = ''; - if (row.type == 1) { - url = this.javaApi + '/img/' + row.fileUrl - this.$download.saveAs(url, row.fileName); - } else { - url = this.javaApi + '/word/' + row.fileUrl - this.$download.saveAs(url, row.fileName); - } + this.$download.downloadFileFromUrl(row.fileUrl, row.fileName); }, // 鍒犻櫎瀹㈡埛鍒嗘瀽闄勪欢 delFile(row) { diff --git a/src/views/CNAS/systemManagement/documentControl/components/ControlledFileApplication.vue b/src/views/CNAS/systemManagement/documentControl/components/ControlledFileApplication.vue index cc35075..7928ac9 100644 --- a/src/views/CNAS/systemManagement/documentControl/components/ControlledFileApplication.vue +++ b/src/views/CNAS/systemManagement/documentControl/components/ControlledFileApplication.vue @@ -461,8 +461,7 @@ }, handleDown(row) { if (!row.url) return this.$message.warning('鏂囦欢鏈笂浼�') - let url = this.javaApi + '/word/' + row.url - this.$download.saveAs(url, row.url); + this.$download.downloadFileFromUrl(row.url, row.url); }, async uploadPDF(pdfBlob) { const formData = new FormData(); diff --git a/src/views/CNAS/systemManagement/documentControl/components/FileChangeRequest.vue b/src/views/CNAS/systemManagement/documentControl/components/FileChangeRequest.vue index b68fb55..7a61745 100644 --- a/src/views/CNAS/systemManagement/documentControl/components/FileChangeRequest.vue +++ b/src/views/CNAS/systemManagement/documentControl/components/FileChangeRequest.vue @@ -568,8 +568,7 @@ // 涓嬭浇闄勪欢 handleDown(row) { if (!row.alterAfterUrl) return this.$message.warning('鏂囦欢鏈笂浼�') - let url = this.javaApi + '/word/' + row.alterAfterUrl - this.$download.saveAs(url, row.alterAfterUrl) + this.$download.downloadFileFromUrl(row.alterAfterUrl, row.alterAfterUrl) }, // 鎵撳紑瀹℃牳寮规 handleCheck(row) { diff --git a/src/views/CNAS/systemManagement/documentControl/components/FileList.vue b/src/views/CNAS/systemManagement/documentControl/components/FileList.vue index 88bc13d..4a77a2a 100644 --- a/src/views/CNAS/systemManagement/documentControl/components/FileList.vue +++ b/src/views/CNAS/systemManagement/documentControl/components/FileList.vue @@ -252,8 +252,7 @@ // 涓嬭浇鏂囦欢 handleDown(row) { if (!row.url) return this.$message.warning('鏂囦欢鏈笂浼�') - let url = this.javaApi + '/word/' + row.url - this.$download.saveAs(url, row.url); + this.$download.downloadFileFromUrl(row.url, row.url); }, // 鏌ョ湅鏂囦欢 handleLook(row) { diff --git a/src/views/CNAS/systemManagement/documentRecords/approvalRecord.vue b/src/views/CNAS/systemManagement/documentRecords/approvalRecord.vue index ef71f30..1f13e97 100644 --- a/src/views/CNAS/systemManagement/documentRecords/approvalRecord.vue +++ b/src/views/CNAS/systemManagement/documentRecords/approvalRecord.vue @@ -283,9 +283,7 @@ // queryParams exportOutManageRecordCheck(this.queryParams).then(res => { this.outLoading = false - if (res.code == 201) return this.$message.error('瀵煎嚭澶辫触') - let url = this.javaApi + '/word/' + res.data - this.$download.saveAs(url, '鏂囦欢瀹℃壒璁板綍') + this.$download.downloadFileFromUrl(res.data, '鏂囦欢瀹℃壒璁板綍') }) }, getAuthorizedPerson() { diff --git a/src/views/CNAS/systemManagement/documentRecords/cancellationRecord.vue b/src/views/CNAS/systemManagement/documentRecords/cancellationRecord.vue index 686e6eb..c214077 100644 --- a/src/views/CNAS/systemManagement/documentRecords/cancellationRecord.vue +++ b/src/views/CNAS/systemManagement/documentRecords/cancellationRecord.vue @@ -243,9 +243,7 @@ this.outLoading = true exportOutManageRecordCancel(this.queryParams).then(res => { this.outLoading = false - if (res.code == 201) return this.$message.error('瀵煎嚭澶辫触') - let url = this.javaApi + '/word/' + res.data - this.$download.saveAs(url, "浣滃簾鏂囦欢閿�姣佽褰�"); + this.$download.downloadFileFromUrl(res.data, "浣滃簾鏂囦欢閿�姣佽褰�"); }) }, getList() { diff --git a/src/views/CNAS/systemManagement/documentRecords/distributionCollectionRecord.vue b/src/views/CNAS/systemManagement/documentRecords/distributionCollectionRecord.vue index d224ee2..0cc82fa 100644 --- a/src/views/CNAS/systemManagement/documentRecords/distributionCollectionRecord.vue +++ b/src/views/CNAS/systemManagement/documentRecords/distributionCollectionRecord.vue @@ -300,9 +300,7 @@ this.outLoading = true exportOutManageRecordIssueRecycle(this.queryParams).then(res => { this.outLoading = false - if (res.code == 201) return this.$message.error('瀵煎嚭澶辫触') - let url = this.javaApi + '/word/' + res.data - this.$download.saveAs(url, '鏂囦欢鍙戞斁涓庡洖鏀惰褰�') + this.$download.downloadFileFromUrl(res.data, '鏂囦欢鍙戞斁涓庡洖鏀惰褰�') }) }, getList() { diff --git a/src/views/CNAS/systemManagement/documentRecords/outDocumenRecordt.vue b/src/views/CNAS/systemManagement/documentRecords/outDocumenRecordt.vue index c7c2922..6b7dd89 100644 --- a/src/views/CNAS/systemManagement/documentRecords/outDocumenRecordt.vue +++ b/src/views/CNAS/systemManagement/documentRecords/outDocumenRecordt.vue @@ -393,8 +393,7 @@ }).catch(err => { }); }, handleDown0(row) { - let url = this.javaApi + '/word/' + row.url - this.$download.saveAs(url, '澶栨潵鏂囦欢纭璁板綍') + this.$download.downloadFileFromUrl(row.url, '澶栨潵鏂囦欢纭璁板綍') }, // 鎻愪氦 handleSubmit(row) { diff --git a/src/views/CNAS/systemManagement/documentRecords/regularReviewsRecord.vue b/src/views/CNAS/systemManagement/documentRecords/regularReviewsRecord.vue index 432faea..a2195e4 100644 --- a/src/views/CNAS/systemManagement/documentRecords/regularReviewsRecord.vue +++ b/src/views/CNAS/systemManagement/documentRecords/regularReviewsRecord.vue @@ -345,9 +345,7 @@ this.outLoading = true exportOutManageRecordIntervals(this.queryParams).then(res => { this.outLoading = false - if (res.code == 201) return this.$message.error('瀵煎嚭澶辫触') - let url = this.javaApi + 'word/' + res.message - this.$download.saveAs(url, "鏂囦欢瀹氭湡瀹℃煡璁板綍"); + this.$download.downloadFileFromUrl(res.message, "鏂囦欢瀹氭湡瀹℃煡璁板綍"); }) }, getList() { @@ -543,8 +541,7 @@ } }, handleDown0(row) { - let url = this.javaApi + '/word/' + row.url - this.$download.saveAs(url, "鎵�鏈夋枃浠跺畾鏈熸鏌ヨ褰�"); + this.$download.downloadFileFromUrl(row.url, "鎵�鏈夋枃浠跺畾鏈熸鏌ヨ褰�"); }, // 鎻愪氦 handleSubmit(row) { diff --git a/src/views/CNAS/systemManagement/documentRecords/revisionRecord.vue b/src/views/CNAS/systemManagement/documentRecords/revisionRecord.vue index e5fa49b..8619551 100644 --- a/src/views/CNAS/systemManagement/documentRecords/revisionRecord.vue +++ b/src/views/CNAS/systemManagement/documentRecords/revisionRecord.vue @@ -550,9 +550,7 @@ this.outLoading = true exportOutManageRecordAudit(this.queryParams).then(res => { this.outLoading = false - if (res.code == 201) return this.$message.error('瀵煎嚭澶辫触') - let url = this.javaApi + '/word/' + res.data - this.$download.saveAs(url, "鏂囦欢淇琛�"); + this.$download.downloadFileFromUrl(res.data, "鏂囦欢淇琛�"); }) }, getList() { diff --git a/src/views/CNAS/systemManagement/internalAuditManagement/components/ViewTestRecord.vue b/src/views/CNAS/systemManagement/internalAuditManagement/components/ViewTestRecord.vue index fac2da1..a96569d 100644 --- a/src/views/CNAS/systemManagement/internalAuditManagement/components/ViewTestRecord.vue +++ b/src/views/CNAS/systemManagement/internalAuditManagement/components/ViewTestRecord.vue @@ -116,14 +116,7 @@ }, // 涓嬭浇 upload(row) { - let url = ''; - if (row.type == 1) { - url = this.javaApi + '/img/' + row.fileUrl - this.$download.saveAs(url, row.fileName) - } else { - url = this.javaApi + '/word/' + row.fileUrl - this.$download.saveAs(url, row.fileName) - } + this.$download.downloadFileFromUrl(row.fileUrl, row.fileName) }, // 鍒犻櫎 delete(row) { diff --git a/src/views/CNAS/systemManagement/managementReview/components/managementReviewPlan.vue b/src/views/CNAS/systemManagement/managementReview/components/managementReviewPlan.vue index 14dc270..b5f1c61 100644 --- a/src/views/CNAS/systemManagement/managementReview/components/managementReviewPlan.vue +++ b/src/views/CNAS/systemManagement/managementReview/components/managementReviewPlan.vue @@ -282,8 +282,7 @@ }, handleDown0(url, name) { if (!url) return this.$message.warning('鏂囦欢鏈笂浼�') - let url0 = this.javaApi + '/word/' + url - this.$download.saveAs(url0, name); + this.$download.downloadFileFromUrl(url, name); } } }; diff --git a/src/views/business/inspectionTask/components/InspectionWord.vue b/src/views/business/inspectionTask/components/InspectionWord.vue index 8ff12cb..abe220c 100644 --- a/src/views/business/inspectionTask/components/InspectionWord.vue +++ b/src/views/business/inspectionTask/components/InspectionWord.vue @@ -247,7 +247,7 @@ import AddUnPass from "@/views/business/unpass/components/addUnPass.vue"; import { checkSubmitPlan, - doInsOrder, + doInsOrder, downFile, getInsProductUnqualifiedRetest, search, selectUserCondition, submitPlan, @@ -2036,16 +2036,7 @@ downFile({ id: row.id, }).then(res => { - if (res.code === 200) { - let url = ''; - if (res.data.type == 1) { - url = this.javaApi + '/img/' + res.data.fileUrl - this.$download.saveAs(url, row.fileName); - } else { - url = this.javaApi + '/word/' + res.data.fileUrl - this.$download.saveAs(url, row.fileName); - } - } + this.$download.downloadFileFromUrl(res.data.fileUrl, row.fileName); }).catch(error => { }) diff --git a/src/views/business/inspectionTask/inspection.vue b/src/views/business/inspectionTask/inspection.vue index 55af32e..ecb16fd 100644 --- a/src/views/business/inspectionTask/inspection.vue +++ b/src/views/business/inspectionTask/inspection.vue @@ -2884,16 +2884,7 @@ }, handleDown(row) { downFile({ id: row.id }).then((res) => { - if (res.code === 200) { - let url = ""; - if (res.data.type == 1) { - url = this.javaApi + "/img/" + res.data.fileUrl; - this.$download.saveAs(url, row.fileName) - } else { - url = this.javaApi + "/word/" + res.data.fileUrl; - this.$download.saveAs(url, row.fileName) - } - } + this.$download.downloadFileFromUrl(res.data.fileUrl, row.fileName) }) .catch((error) => { }); }, diff --git a/src/views/business/materialOrderComponents/materialOrder/filesLookVisible.vue b/src/views/business/materialOrderComponents/materialOrder/filesLookVisible.vue index 8dc8ee0..ef642c2 100644 --- a/src/views/business/materialOrderComponents/materialOrder/filesLookVisible.vue +++ b/src/views/business/materialOrderComponents/materialOrder/filesLookVisible.vue @@ -154,16 +154,7 @@ // 涓嬭浇 handleDown(row) { downFile({ id: row.id, }).then(res => { - if (res.code === 200) { - let url = ''; - if (res.data.type == 1) { - url = this.javaApi + '/img/' + res.data.fileUrl - this.$download.saveAs(url, row.fileName); - } else { - url = this.javaApi + '/word/' + res.data.fileUrl - this.$download.saveAs(url, row.fileName); - } - } + this.$download.downloadFileFromUrl(res.data.fileUrl, row.fileName); }).catch(error => { }) diff --git a/src/views/business/productOrder/index.vue b/src/views/business/productOrder/index.vue index a7a22f7..5ecdc8b 100644 --- a/src/views/business/productOrder/index.vue +++ b/src/views/business/productOrder/index.vue @@ -986,25 +986,16 @@ downFile({ id: row.id, }).then(res => { - if (res.code === 200) { - let url = ''; - if (res.data.type == 1) { - url = this.javaApi + '/img/' + res.data.fileUrl - this.$download.saveAs(url, row.fileName); - } else { - url = this.javaApi + '/word/' + res.data.fileUrl - this.$download.saveAs(url, row.fileName); - } - } + this.$download.downloadFileFromUrl(res.data.fileUrl, row.fileName); }).catch(error => { }) }, // 涓嬭浇鎶ュ憡 download(row) { - let url = this.javaApi + '/word/' + row.urlS ? row.urlS : row.url; + let url = row.urlS ? row.urlS : row.url; if (url) { - this.$download.saveAs(url, this.downLoadInfo.fileName); + this.$download.downloadFileFromUrl(url, this.downLoadInfo.fileName); } }, // 鎾ら攢 diff --git a/src/views/business/reportPreparation/index.vue b/src/views/business/reportPreparation/index.vue index d47b9cf..3ff9d9c 100644 --- a/src/views/business/reportPreparation/index.vue +++ b/src/views/business/reportPreparation/index.vue @@ -547,16 +547,7 @@ downFile({ id: row.id, }).then(res => { - if (res.code === 200) { - let url = ''; - if (res.data.type == 1) { - url = this.javaApi + '/img/' + res.data.fileUrl - this.$download.saveAs(url, row.fileName); - } else { - url = this.javaApi + '/word/' + res.data.fileUrl - this.$download.saveAs(url, row.fileName); - } - } + this.$download.downloadFileFromUrl(res.data.fileUrl, row.fileName); }).catch(error => { }) diff --git a/src/views/business/unpass/components/unPassDialog.vue b/src/views/business/unpass/components/unPassDialog.vue index abb940f..d7de2a8 100644 --- a/src/views/business/unpass/components/unPassDialog.vue +++ b/src/views/business/unpass/components/unPassDialog.vue @@ -180,16 +180,7 @@ downFile({ id: row.id, }).then(res => { - if (res.code === 200) { - let url = ''; - if (res.data.type == 1) { - url = this.javaApi + '/img/' + res.data.fileUrl - this.$download.saveAs(url, row.fileName); - } else { - url = this.javaApi + '/word/' + res.data.fileUrl - this.$download.saveAs(url, row.fileName); - } - } + this.$download.downloadFileFromUrl(res.data.fileUrl, row.fileName); }).catch(error => { }) diff --git a/src/views/structural/capabilityAndLaboratory/laboratory/index.vue b/src/views/structural/capabilityAndLaboratory/laboratory/index.vue index 16a9d49..fc2642c 100644 --- a/src/views/structural/capabilityAndLaboratory/laboratory/index.vue +++ b/src/views/structural/capabilityAndLaboratory/laboratory/index.vue @@ -332,8 +332,7 @@ this.$message.warning('鏆傛棤闄勪欢') return; } - const url = this.javaApi + "/img/" + row.fileUrl; - this.$download.saveAs(url, row.fileUrl); + this.$download.downloadFileFromUrl(row.fileUrl, row.fileUrl); }, openAdd() { this.qualificationsConnectVisible = true; -- Gitblit v1.9.3