From 352f4cf84d29c70c79c2bde7b8a1e758d63a5405 Mon Sep 17 00:00:00 2001 From: liujun Date: Sun, 4 Feb 2024 13:41:56 +0800 Subject: [PATCH] =?UTF-8?q?=E7=9B=91=E7=AE=A1=E7=AB=AF=E4=B8=8A=E4=BC=A0?= =?UTF-8?q?=E5=A7=94=E6=89=98=E4=B9=A6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/useDownloadFile.js | 16 +++++++ src/views/xgf/flow/components/flowInfo.vue | 45 ++++++++++++-------- src/views/xgf/flow_audit/userInfo.vue | 21 ++++++++- src/views/xgf/peopleList/components/list.vue | 4 +- 4 files changed, 66 insertions(+), 20 deletions(-) create mode 100644 src/utils/useDownloadFile.js diff --git a/src/utils/useDownloadFile.js b/src/utils/useDownloadFile.js new file mode 100644 index 0000000..faa22ac --- /dev/null +++ b/src/utils/useDownloadFile.js @@ -0,0 +1,16 @@ +export default async function useDownloadFile(url) { + if (!url) throw new Error('没有下载地址') + fetch(config.fileUrl + url) + .then((res) => res.blob()) + .then((blob) => { + const a = document.createElement('a') + document.body.appendChild(a) + a.style.display = 'none' + const url = window.URL.createObjectURL(blob) + a.href = url + a.download = url.substring(url.lastIndexOf('/') + 1) + a.click() + document.body.removeChild(a) + window.URL.revokeObjectURL(url) + }) +} diff --git a/src/views/xgf/flow/components/flowInfo.vue b/src/views/xgf/flow/components/flowInfo.vue index cabc7cd..75435c4 100644 --- a/src/views/xgf/flow/components/flowInfo.vue +++ b/src/views/xgf/flow/components/flowInfo.vue @@ -7,7 +7,7 @@ title="审批流程" width="60%"> - +