Merge pull request 'feat : 项目立项, 阶段变更zip下载' (#909) from dj into master

Reviewed-on: http://git.feashow.cn/clay/mosr-web/pulls/909
This commit is contained in:
2024-11-03 11:32:31 +00:00
4 changed files with 53 additions and 14 deletions

View File

@@ -1,4 +1,7 @@
import request from '@/utils/request.js'
import axios from "axios";
import {getToken} from "@/utils/auth";
//需求征集
export const getDemandInfo = (param) => {
return request({
@@ -104,3 +107,22 @@ export const downloadTemplate = (type) => {
}
});
};
export const downloadTemplateZip = (typeList) => {
return axios.get(
`${import.meta.env.VITE_BASE_URL}/workflow/mosr/attachment/download/pack?typeList=${typeList}`,
{
responseType: 'blob',
headers: {
Authorization: getToken()
},
}
);
// return request({
// url: '/workflow/mosr/attachment/download/pack',
// method: "get",
// responseType:'blob',
// params:{
// typeList:typeList
// }
// });
};

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 '科技创新项目验收申请表'
}

View File

@@ -25,7 +25,7 @@
</el-form>
<user-picker :multiple="true" ref="userPicker" title="请选择抄送人员" v-model:value="userList"
@ok="ccPersonPickerOkOrCancel" @cancelOrClear="ccPersonPickerOkOrCancel"/>
<AttachmentUpload ref="attachment" label="阶段变更附件" :showTable="showTable" v-model:otherFileList="otherFileList" templateName="科技创新项目变更申请表" :templateDownloadBtnShow="true"
<AttachmentUpload ref="attachment" label="阶段变更附件" :showTable="showTable" v-model:otherFileList="otherFileList" templateName="科技创新项目变更模板" :templateDownloadBtnShow="true"
@getAttachment="getAttachment" v-model:singleList="singleList" :showSingleTable="showSingleTable"
@getOtherFile="getOtherFile" :showFileList="true" :formData="formData" tag="阶段变更"
:preview="name === 'Phase/edit'"/>