feat : "需求上报, 项目立项, 项目验收, 阶段变更, 专项资金" 上传文件旁边加上模板下载功能

This commit is contained in:
2024-11-02 22:00:08 +08:00
parent a175a6456a
commit 08da2601d8
6 changed files with 110 additions and 41 deletions

View File

@@ -94,3 +94,13 @@ export const getRequirementStatePerm = () => {
method: "get" method: "get"
}); });
}; };
export const downloadTemplate = (type) => {
return request({
url: '/workflow/mosr/attachment/download/template',
method: "get",
responseType:'blob',
params:{
type:type
}
});
};

View File

@@ -1,29 +1,32 @@
<template> <template>
<el-form :model="formData" ref="applyForm" :rules="rules" :label-position="labelPosition" style="margin-left: 5px"> <el-form :model="formData" ref="applyForm" :rules="rules" :label-position="labelPosition" style="margin-left: 5px">
<el-row> <el-row>
<!-- <el-col :span="24">--> <!-- <el-col :span="24">-->
<!-- <el-form-item :label="label" prop="attachment" >--> <!-- <el-form-item :label="label" prop="attachment" >-->
<!-- <template v-if="preview">--> <!-- <template v-if="preview">-->
<!-- <file-upload @getFile="getAttachment" :multiple="false"--> <!-- <file-upload @getFile="getAttachment" :multiple="false"-->
<!-- :disabled="singleFileArray?.length>0?true:false" title="如需修改需求申请书附件,请先删除文件再上传!"/>--> <!-- :disabled="singleFileArray?.length>0?true:false" title="如需修改需求申请书附件,请先删除文件再上传!"/>-->
<!-- <fvTable style="width: 100%;max-height: 80px;" height="80" v-if="singleFileArray?.length>0"--> <!-- <fvTable style="width: 100%;max-height: 80px;" height="80" v-if="singleFileArray?.length>0"-->
<!-- :tableConfig="editSingleTableConfig"--> <!-- :tableConfig="editSingleTableConfig"-->
<!-- :data="singleFileArray" :isSettingCol="false" :pagination="false">--> <!-- :data="singleFileArray" :isSettingCol="false" :pagination="false">-->
<!-- </fvTable>--> <!-- </fvTable>-->
<!-- </template>--> <!-- </template>-->
<!-- <template v-else-if="!preview">--> <!-- <template v-else-if="!preview">-->
<!-- <file-upload @getFile="getAttachment" :multiple="false"--> <!-- <file-upload @getFile="getAttachment" :multiple="false"-->
<!-- :disabled="isSingleFile"/>--> <!-- :disabled="isSingleFile"/>-->
<!-- <fvTable style="width: 100%;max-height: 80px;" v-if="showSingleTable" height="80"--> <!-- <fvTable style="width: 100%;max-height: 80px;" v-if="showSingleTable" height="80"-->
<!-- :tableConfig="singleTableConfig"--> <!-- :tableConfig="singleTableConfig"-->
<!-- :data="_singleFileValue" :isSettingCol="false" :pagination="false">--> <!-- :data="_singleFileValue" :isSettingCol="false" :pagination="false">-->
<!-- </fvTable>--> <!-- </fvTable>-->
<!-- </template>--> <!-- </template>-->
<!-- </el-form-item>--> <!-- </el-form-item>-->
<!-- </el-col>--> <!-- </el-col>-->
<el-col :span="24"> <el-col :span="24">
<el-form-item :label="label" prop="" required> <el-form-item :label="label" prop="" required>
<file-upload @getFile="getOtherFile"/> <file-upload @getFile="getOtherFile"/>
<el-button color="#DED0B2" v-if="templateDownloadBtnShow" @click="handleImportTemplateDownload"
style="margin-left: 10px">模板下载
</el-button>
<fvTable style="width: 100%;max-height: 160px;" v-if="showTable" height="160" :tableConfig="tableConfig" <fvTable style="width: 100%;max-height: 160px;" v-if="showTable" height="160" :tableConfig="tableConfig"
:data="allFileList" :isSettingCol="false" :pagination="false"> :data="allFileList" :isSettingCol="false" :pagination="false">
<template #empty> <template #empty>
@@ -34,13 +37,14 @@
</el-col> </el-col>
</el-row> </el-row>
</el-form> </el-form>
<file-preview ref="filePreviewRef" v-if="filePreviewShow" :fileName="filePreviewParam.fileName" :fileUrl="filePreviewParam.fileUrl" <file-preview ref="filePreviewRef" v-if="filePreviewShow" :fileName="filePreviewParam.fileName"
:fileUrl="filePreviewParam.fileUrl"
:fileType="filePreviewParam.fileType"/> :fileType="filePreviewParam.fileType"/>
</template> </template>
<script setup lang="jsx"> <script setup lang="jsx">
import FileUpload from '@/components/FileUpload.vue' import FileUpload from '@/components/FileUpload.vue'
import {deleteFile, downloadFile} from "@/api/project-demand"; import {deleteFile, downloadFile, downloadTemplate} from "@/api/project-demand";
import {ElMessageBox, ElNotification} from "element-plus"; import {ElMessageBox, ElNotification} from "element-plus";
@@ -65,6 +69,16 @@ const props = defineProps({
type: Boolean, type: Boolean,
default: false default: false
}, },
//是否显示模板下载按钮
templateDownloadBtnShow: {
type: Boolean,
default: false
},
//模板下载时的文件名
templateName: {
type: String,
default: ''
},
singleList: { singleList: {
type: Array, type: Array,
default: [] default: []
@@ -103,7 +117,8 @@ const baseTableConf = reactive(
align: 'center', align: 'center',
width: 400, width: 400,
currentRender: ({row, index}) => ( currentRender: ({row, index}) => (
<div style="color: #2a99ff;cursor: pointer;" onClick={() => clickToPreview(row)}>{row.originalFileName}</div>) <div style="color: #2a99ff;cursor: pointer;"
onClick={() => clickToPreview(row)}>{row.originalFileName}</div>)
}, },
{ {
prop: 'tag', prop: 'tag',
@@ -249,7 +264,7 @@ const isHaveOneFile = ref(false)
const allFileList = ref([]) const allFileList = ref([])
if (localStorage.getItem('singleFile')) { if (localStorage.getItem('singleFile')) {
singleFileArray.value.push(JSON.parse(localStorage.getItem('singleFile'))) singleFileArray.value.push(JSON.parse(localStorage.getItem('singleFile')))
singleFile.value =JSON.parse(localStorage.getItem('singleFile')) singleFile.value = JSON.parse(localStorage.getItem('singleFile'))
} }
const filePreviewParam = ref({ const filePreviewParam = ref({
@@ -277,7 +292,7 @@ const _otherFileListValue = computed({
} }
}) })
if (_otherFileListValue.value && _otherFileListValue.value.length > 0) { if (_otherFileListValue.value && _otherFileListValue.value.length > 0) {
isHaveOneFile.value=true isHaveOneFile.value = true
_otherFileListValue.value.forEach(item => { _otherFileListValue.value.forEach(item => {
allFileList.value.push(item) allFileList.value.push(item)
}) })
@@ -288,7 +303,7 @@ if (_otherFileListValue.value && _otherFileListValue.value.length > 0) {
watch(() => props.formData.fileList, (newVal) => { watch(() => props.formData.fileList, (newVal) => {
if (props.preview) { if (props.preview) {
newVal?.forEach(item => { newVal?.forEach(item => {
isHaveOneFile.value=true isHaveOneFile.value = true
allFileList.value.push(item) allFileList.value.push(item)
}) })
} }
@@ -340,6 +355,26 @@ watch(() => isHaveOneFile.value, (newVal) => {
// }, {deep: true}) // }, {deep: true})
const handleImportTemplateDownload = () => {
console.info("🚀 ~method:handleImportTemplateDownload -----", props.tag)
let templateType = ''
if (props.tag === '需求上报') {
templateType = '2'
} else if (props.tag === '项目立项') {
templateType = '5'
} else if (props.tag === '项目验收') {
templateType = '7'
}else if (props.tag === '阶段变更') {
templateType = '8'
}
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()
})
}
const clickToPreview = (row) => { const clickToPreview = (row) => {
@@ -350,14 +385,13 @@ const clickToPreview = (row) => {
fileName: row.originalFileName, fileName: row.originalFileName,
fileType: row.fileType fileType: row.fileType
} }
nextTick(()=>{ nextTick(() => {
filePreviewShow.value = true filePreviewShow.value = true
}) })
// filePreviewRef.value.show() // filePreviewRef.value.show()
} }
const handleDelete = (row, type) => { const handleDelete = (row, type) => {
deleteFile(row.fileId).then(res => { deleteFile(row.fileId).then(res => {
ElNotification({ ElNotification({
@@ -371,14 +405,14 @@ const handleDelete = (row, type) => {
isSingleFile.value = false isSingleFile.value = false
} else { } else {
allFileList.value.splice(allFileList.value.findIndex((item) => item.fileId === row.fileId), 1); allFileList.value.splice(allFileList.value.findIndex((item) => item.fileId === row.fileId), 1);
if(allFileList.value&&allFileList.value?.length==0){ if (allFileList.value && allFileList.value?.length == 0) {
isHaveOneFile.value=false isHaveOneFile.value = false
}else{ } else {
isHaveOneFile.value=true isHaveOneFile.value = true
} }
if(localStorage.getItem('collectData')){ if (localStorage.getItem('collectData')) {
let collectData=JSON.parse(localStorage.getItem('collectData')) let collectData = JSON.parse(localStorage.getItem('collectData'))
collectData.fileList=allFileList.value collectData.fileList = allFileList.value
localStorage.setItem('collectData', JSON.stringify(collectData)) localStorage.setItem('collectData', JSON.stringify(collectData))
} }
} }
@@ -409,7 +443,7 @@ const getOtherFile = (val) => {
} else { } else {
allFileList.value = _otherFileListValue.value allFileList.value = _otherFileListValue.value
} }
isHaveOneFile.value=true isHaveOneFile.value = true
emit('getOtherFile', val) emit('getOtherFile', val)
} }
const deleteAttachment = (val) => { const deleteAttachment = (val) => {

View File

@@ -62,7 +62,7 @@
</el-form> </el-form>
<!-- v-if="showAttachment"--> <!-- v-if="showAttachment"-->
<AttachmentUpload ref="attachment" :label="getTitleName(title)+'附件'" :showTable="showTable" <AttachmentUpload ref="attachment" :label="getTitleName(title)+'附件'" :showTable="showTable"
v-model:otherFileList="otherFileList" :tag="getTitleName(props.title)" v-model:otherFileList="otherFileList" :tag="getTitleName(props.title)" :templateName="getTemplateName(props.title)" :templateDownloadBtnShow="props.title==='apply'?true:props.title==='check'"
@getAttachment="getAttachment" v-model:singleList="singleList" :showSingleTable="showSingleTable" @getAttachment="getAttachment" v-model:singleList="singleList" :showSingleTable="showSingleTable"
@getOtherFile="getOtherFile" :showFileList="true" :formData="localFormData" @getOtherFile="getOtherFile" :showFileList="true" :formData="localFormData"
:preview="mode == 'resubmit'"/> :preview="mode == 'resubmit'"/>
@@ -250,6 +250,16 @@ const filePreviewParam = ref({
fileType: 'pdf' fileType: 'pdf'
}) })
const filePreviewShow = ref(false) const filePreviewShow = ref(false)
const getTemplateName=(type)=>{
switch (type) {
case 'apply':
return '科技创新项目立项申请表'
case 'check':
return '科技创新项目验收申请表'
}
}
const handleShowOptionalChargeLeadershipPicker = () => { const handleShowOptionalChargeLeadershipPicker = () => {
optionalChargeLeadershipPickerRef.value.showUserPicker() optionalChargeLeadershipPickerRef.value.showUserPicker()
} }

View File

@@ -284,7 +284,7 @@
<baseTitle title="附件文件"></baseTitle> <baseTitle title="附件文件"></baseTitle>
<div :style="{marginRight:!formData.isSpecialFund?'20px':'80px'}"> <div :style="{marginRight:!formData.isSpecialFund?'20px':'80px'}">
<AttachmentUpload ref="attachment" label="需求申请书附件" <AttachmentUpload ref="attachment" label="需求申请书附件"
:showTable="showTable" :showTable="showTable" templateName="科技创新项目需求申请书" :templateDownloadBtnShow="true"
v-model:otherFileList="otherFileList" v-model:otherFileList="otherFileList"
@getOtherFile="getOtherFile" @getOtherFile="getOtherFile"
:showSingleTable="showSingleTable" @getAttachment="getAttachment" :showSingleTable="showSingleTable" @getAttachment="getAttachment"

View File

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

View File

@@ -34,7 +34,10 @@
</el-row> </el-row>
</el-form> </el-form>
<baseTitle title="附件文件" style="margin-right: 10px"></baseTitle> <baseTitle title="附件文件" style="margin-right: 10px"></baseTitle>
<file-upload @getFile="getFile"/> <div style="display:flex;">
<file-upload @getFile="getFile"/>
<el-button color="#DED0B2" @click="handleImportTemplateDownload" style="margin-left: 10px">模板下载</el-button>
</div>
<fvTable style="width: 100%;max-height: 160px;" v-if="showTable" <fvTable style="width: 100%;max-height: 160px;" v-if="showTable"
:tableConfig="tableConfig" height="160" :data="formData.files" :tableConfig="tableConfig" height="160" :data="formData.files"
@@ -84,7 +87,7 @@ import {addFund, resubmitFund, getFundDetail, getFundDetailProcess, getFundProce
import {useRouter} from "vue-router"; import {useRouter} from "vue-router";
import {useTagsView} from '@/stores/tagsview.js' import {useTagsView} from '@/stores/tagsview.js'
import {useProcessStore} from '@/stores/processStore.js'; import {useProcessStore} from '@/stores/processStore.js';
import {downloadFile, deleteFile} from "@/api/project-demand"; import {downloadFile, deleteFile,downloadTemplate} from "@/api/project-demand";
const changeDiagram = ref(false) const changeDiagram = ref(false)
const tagsViewStore = useTagsView() const tagsViewStore = useTagsView()
@@ -161,6 +164,18 @@ const filePreviewParam = ref({
fileType: 'pdf' fileType: 'pdf'
}) })
const filePreviewShow = ref(false) const filePreviewShow = ref(false)
const handleImportTemplateDownload=()=>{
downloadTemplate('13').then(res => {
const blob = new Blob([res])
let a = document.createElement('a')
a.href = URL.createObjectURL(blob)
a.download = '科技创新项目专项资金任务书.docx'
a.click()
})
}
const clickToPreview = (row) => { const clickToPreview = (row) => {
filePreviewShow.value = false filePreviewShow.value = false
filePreviewParam.value = { filePreviewParam.value = {