文件下载

This commit is contained in:
zyn
2023-05-06 10:46:51 +08:00
parent 417bbb9e35
commit 7d11475659
2 changed files with 84 additions and 2 deletions
@@ -218,7 +218,15 @@
></el-input>
<div style="display: flex;justify-content: space-between">
<div style="width: 80%;margin-top: 13px">
<div v-for="(item,index) in LSBBBUSSFileList" :key="index" @click="handleFilePreview(item)" style="color: #409eff;cursor:pointer" class="fileClass">{{ item.name }}</div>
<!--<div v-for="(item,index) in LSBBBUSSFileList" :key="index" @click="handleFilePreview(item)" style="color: #409eff;cursor:pointer" class="fileClass">{{ item.name }}</div>-->
<div v-for="(item,index) in LSBBBUSSFileList" :key="index"
@click="handleFilePreview(item)" style="color: #409eff;cursor:pointer;margin-left: 12px;"
class="fileClass">
<span style="" @click="handleFilePreview2(item,'preview')" :title="item.name"> {{ item.name }}</span>
<span style="margin-left: 7px;" v-if="item.id !== ''">
<i class="el-icon-download" title="下载" @click="handleFilePreview2(item,'down')"></i>
</span>
</div>
</div>
<div style="width: 20%;">
<el-button :disabled="disabledXX"
@@ -2829,6 +2837,39 @@ export default {
this.$preview(attId)
}
},
handleFilePreview2(file, type) {
let attId = ""
if (file && file.id) {
attId = file.id
} else {
attId = file.response.data.id
}
if (file.name == this.form.standName) {
let fileName = ""
let fileNam2 = ""
if (this.form.standName && this.form.standName !== '') {
fileName = this.form.standName + '-企业标准.docx'
fileNam2 = this.form.standName
} else {
fileName = '企业标准.docx'
fileNam2 = '企业标准'
}
let form = JSON.parse(JSON.stringify(this.form))
form.standCode = ''
form.issueDate = ''
this.$onlineEditPreview(file.id, fileNam2, this.$store.getters.userInfo.userId, this.$store.getters.userInfo.userName, form)
return
}
if (type === 'down') {
if (attId) {
window.open('/api/att/attFile/downloadFileForSarNew?fileId=' + attId)
} else {
this.$message.warning('文件不存在,下载失败')
}
} else {
this.$preview(attId)
}
},
// 导入标准数据成功后执行
importFileSuccess (response, file,fileList) {
// 上传成功后判断是否是两条数据是的话替换掉旧数据
@@ -181,7 +181,15 @@
></el-input>
<div style="display: flex;justify-content: space-between">
<div style="width: 80%;margin-top: 13px">
<div v-for="(item,index) in LSBBBUSSFileList" :key="index" @click="handleFilePreview(item)" style="color: #409eff;cursor:pointer" class="fileClass">{{ item.name }}</div>
<!--<div v-for="(item,index) in LSBBBUSSFileList" :key="index" @click="handleFilePreview(item)" style="color: #409eff;cursor:pointer" class="fileClass">{{ item.name }}</div>-->
<div v-for="(item,index) in LSBBBUSSFileList" :key="index"
@click="handleFilePreview(item)" style="color: #409eff;cursor:pointer;margin-left: 12px;"
class="fileClass">
<span style="" @click="handleFilePreview2(item,'preview')" :title="item.name"> {{ item.name }}</span>
<span style="margin-left: 7px;" v-if="item.id !== ''">
<i class="el-icon-download" title="下载" @click="handleFilePreview2(item,'down')"></i>
</span>
</div>
</div>
<div style="width: 20%;">
<el-button :disabled="disabledXX"
@@ -2789,6 +2797,39 @@ export default {
this.$preview(attId)
}
},
handleFilePreview2(file, type) {
let attId = ""
if (file && file.id) {
attId = file.id
} else {
attId = file.response.data.id
}
if (file.name == this.form.standName) {
let fileName = ""
let fileNam2 = ""
if (this.form.standName && this.form.standName !== '') {
fileName = this.form.standName + '-企业标准.docx'
fileNam2 = this.form.standName
} else {
fileName = '企业标准.docx'
fileNam2 = '企业标准'
}
let form = JSON.parse(JSON.stringify(this.form))
form.standCode = ''
form.issueDate = ''
this.$onlineEditPreview(file.id, fileNam2, this.$store.getters.userInfo.userId, this.$store.getters.userInfo.userName, form)
return
}
if (type === 'down') {
if (attId) {
window.open('/api/att/attFile/downloadFileForSarNew?fileId=' + attId)
} else {
this.$message.warning('文件不存在,下载失败')
}
} else {
this.$preview(attId)
}
},
// 导入标准数据成功后执行
importFileSuccess (response, file,fileList) {
// 上传成功后判断是否是两条数据是的话替换掉旧数据