feat : 项目立项, 阶段变更zip下载

This commit is contained in:
2024-11-03 19:31:59 +08:00
parent 08da2601d8
commit 39c9408f34
4 changed files with 53 additions and 14 deletions

View File

@@ -44,7 +44,7 @@
<script setup lang="jsx">
import FileUpload from '@/components/FileUpload.vue'
import {deleteFile, downloadFile, downloadTemplate} from "@/api/project-demand";
import {deleteFile, downloadFile, downloadTemplate, downloadTemplateZip} from "@/api/project-demand";
import {ElMessageBox, ElNotification} from "element-plus";
@@ -355,25 +355,42 @@ watch(() => isHaveOneFile.value, (newVal) => {
// }, {deep: true})
const handleImportTemplateDownload = () => {
const handleImportTemplateDownload = async () => {
console.info("🚀 ~method:handleImportTemplateDownload -----", props.tag)
let templateType = ''
let templateTypeList = ''
let isZip = false
if (props.tag === '需求上报') {
templateType = '2'
isZip = false
} else if (props.tag === '项目立项') {
templateType = '5'
templateTypeList = '5,6'
isZip = true
} else if (props.tag === '项目验收') {
templateType = '7'
}else if (props.tag === '阶段变更') {
templateType = '8'
isZip = false
} else if (props.tag === '阶段变更') {
templateTypeList = '8,9'
isZip = true
}
downloadTemplate(templateType).then(res => {
const blob = new Blob([res])
let a = document.createElement('a')
a.href = URL.createObjectURL(blob)
a.download = props.templateName + ".docx"
a.click()
})
let res = ''
if (isZip) {
res = await downloadTemplateZip(templateTypeList)
let fileName = props.templateName +'.zip'
const blob = new Blob([res.data])
let a = document.createElement('a')
a.href = URL.createObjectURL(blob)
a.download = fileName
a.click()
} else {
res = await downloadTemplate(templateType)
const blob = new Blob([res])
let a = document.createElement('a')
a.href = URL.createObjectURL(blob)
a.download = props.templateName + ".docx"
a.click()
}
}

View File

@@ -254,7 +254,7 @@ const filePreviewShow = ref(false)
const getTemplateName=(type)=>{
switch (type) {
case 'apply':
return '科技创新项目立项申请表'
return '科技创新项目立项模板'
case 'check':
return '科技创新项目验收申请表'
}