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/flowApply/components/userInfo.vue b/src/views/xgf/flowApply/components/userInfo.vue index 05b7242..ab8529c 100644 --- a/src/views/xgf/flowApply/components/userInfo.vue +++ b/src/views/xgf/flowApply/components/userInfo.vue @@ -137,6 +137,22 @@ {{ formatLabel(userDetailForm.ISFLOW) }} +
+
+

承诺书

+
+
+ 下载附件 +
+
+
+
+

委托书

+
+
+ 下载附件 +
+

培训记录

@@ -317,6 +333,7 @@ import vueQr from 'vue-qr' import dateformat from '@/utils/dateformat' import { requestFN } from '@/utils/request' +import useDownloadFile from '../../../../utils/useDownloadFile' export default { components: { vueQr }, @@ -401,6 +418,9 @@ export default { } else { return '' } + }, + download(item) { + useDownloadFile(item) } } }