Merge branch 'phatt' into development
This commit is contained in:
commit
f2be0f4af9
1 changed files with 31 additions and 21 deletions
|
|
@ -11,27 +11,37 @@ import FileIcon from '@/components/FileIcon.vue'
|
||||||
const { isFilePreview, fileInfo } = storeToRefs(useFileInfoStore())
|
const { isFilePreview, fileInfo } = storeToRefs(useFileInfoStore())
|
||||||
const { getType, getFormatDate, getSize } = useFileInfoStore()
|
const { getType, getFormatDate, getSize } = useFileInfoStore()
|
||||||
|
|
||||||
async function downloadSubmit(path: any) {
|
async function downloadSubmit(path: string | undefined) {
|
||||||
const [cabinet, drawer, folder, file] = path.split('/')
|
if (path) {
|
||||||
const formatPath = `/cabinet/${cabinet}/drawer/${drawer}/folder/${folder}/file/${file}`
|
let formatPath: string
|
||||||
const res = await axiosClient.get<EhrFile & { download: string }>(
|
|
||||||
`${import.meta.env.VITE_API_ENDPOINT}${formatPath}`,
|
if (path.split('/').length - 1 === 3) {
|
||||||
)
|
const [cabinet, drawer, folder, file] = path.split('/')
|
||||||
await axios
|
formatPath = `cabinet/${cabinet}/drawer/${drawer}/folder/${folder}/file/${file}`
|
||||||
.get(res.data.download, {
|
} else {
|
||||||
method: 'GET',
|
const [cabinet, drawer, folder, subfolder, file] = path.split('/')
|
||||||
responseType: 'blob',
|
formatPath = `cabinet/${cabinet}/drawer/${drawer}/folder/${folder}/subfolder/${subfolder}/file/${file}`
|
||||||
headers: {
|
}
|
||||||
'Content-Type': 'application/json',
|
|
||||||
Accept: res.data.fileType,
|
const res = await axiosClient.get<EhrFile & { download: string }>(
|
||||||
},
|
`${import.meta.env.VITE_API_ENDPOINT}${formatPath}`,
|
||||||
})
|
)
|
||||||
.then((r) => {
|
await axios
|
||||||
const a = document.createElement('a')
|
.get(res.data.download, {
|
||||||
a.href = window.URL.createObjectURL(r.data)
|
method: 'GET',
|
||||||
a.download = res.data.fileName
|
responseType: 'blob',
|
||||||
a.click()
|
headers: {
|
||||||
})
|
'Content-Type': 'application/json',
|
||||||
|
Accept: res.data.fileType,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.then((r) => {
|
||||||
|
const a = document.createElement('a')
|
||||||
|
a.href = window.URL.createObjectURL(r.data)
|
||||||
|
a.download = res.data.fileName
|
||||||
|
a.click()
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue