Commit 560da690 authored by ztf's avatar ztf

行动项附件下载组件

parent 0ae0f6ff
...@@ -14,14 +14,14 @@ export function downFileByFileCode(fileCode) { ...@@ -14,14 +14,14 @@ export function downFileByFileCode(fileCode) {
export function downFileByFileId(fileId) { export function downFileByFileId(fileId) {
return downloadFile(`/dfs/fileManager/downloadio?fileId=${fileId}`) return downloadFile(`/dfs/fileManager/downloadio?fileId=${fileId}`)
} }
// // 下载文件 // 下载文件
// export function downFileByFileId(objName, objId, linkId, disLoadingFlag) { export function downFileByFileIds(objName, objId, linkId, disLoadingFlag) {
// let url = `/dfs/fileManager/downloadio?objName=${objName}&objId=${objId}&linkId=${linkId}` let url = `/dfs/fileManager/downloadio?objName=${objName}&objId=${objId}&linkId=${linkId}`
// if (disLoadingFlag) { if (disLoadingFlag) {
// url += '&disLoadingFlag=' + disLoadingFlag url += '&disLoadingFlag=' + disLoadingFlag
// } }
// return downloadFile(url) return downloadFile(url)
// } }
export function downFileUseFileId(fileId) { export function downFileUseFileId(fileId) {
return downloadFile(`/dfs/fileManager/downloadio?fileId=${fileId}`) return downloadFile(`/dfs/fileManager/downloadio?fileId=${fileId}`)
} }
<template>
<div class="downloadObjFiles">
<span
v-if="ifShow"
ref="load"
class="content"
:basicData="basicData"
@click="downFileByFile"
>下载</span>
</div>
</template>
<script>
import { downFileByFileIds } from '@/api/file'
// import { post } from '@/utils/http'
export default {
name: 'DownloadObjFiles',
componentName: '行动项-附件下载',
props: {
basicData: {
type: Object,
default: () => {}
},
form: {
type: Object,
default: () => {}
}
},
data() {
return {
}
},
computed: {
ifShow() {
if (this.form.state !== 'under_reviewing' || this.form.state !== 'Complete') {
return true
} else {
return false
}
}
},
mounted() {
console.log('form44444', this.form)
console.log('basicData5555', this)
},
methods: {
downFileByFile() {
const subTypeName = this.$parent.$parent.$parent.$parent.$parent.$parent.$parent.basicData.subTypeName
const obj = this.form.objFileLinks[0]
downFileByFileIds(subTypeName, obj.targetId, obj.id, true).then(res => {
console.log('下载ll')
this.downLoadFileUrl(res)
})
},
downLoadFileUrl(res) {
if (res.headers['content-disposition']) {
const fileName = decodeURI(res.headers['content-disposition'].substring(res.headers['content-disposition'].indexOf('=') + 1, res.headers['content-disposition'].length))
const url = window.URL.createObjectURL(new Blob([res.data], { type: res.headers['content-type'] }))
this.$utils.downLoadFileUrl(url, decodeURI(fileName))
} else {
if (res.data instanceof Blob) {
var reader = new FileReader()
reader.addEventListener('loadend', () => {
const message = reader.result && JSON.parse(reader.result)
this.$utils.showMessageWarning(message ? message.message : '数据包下载出错:未找到数据包内容的下载链接,请联系管理员排查问题!')
})
reader.readAsText(res.data, 'utf-8')
} else {
const message = res.data && res.data.message
this.$utils.showMessageWarning(message || '数据包下载出错:未找到数据包内容的下载链接,请联系管理员排查问题!')
}
}
}
}
}
</script>
<style lang="scss" scoped>
.downloadObjFiles{
text-align: center;
.content{
color: #2363AF;
cursor: pointer;
}
}
</style>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment