fix : 修改提交/重新提交功能文件传参问题

This commit is contained in:
2024-06-07 20:36:54 +08:00
parent ee81e1bb23
commit 27bc6ea89f
5 changed files with 72 additions and 134 deletions

View File

@@ -12,7 +12,8 @@
</el-form>
<AttachmentUpload ref="attachment" label="项目验收附件" :showTable="showTable" :otherFileList="otherFileList"
@getAttachment="getAttachment"
@getOtherFile="getOtherFile" :showFileList="true" :formData="formData" :preview="name === 'Implementation/edit'"/>
@getOtherFile="getOtherFile" :showFileList="true" :formData="formData"
:preview="name === 'Implementation/edit'"/>
<div class="approval-record">
<baseTitle title="流程"></baseTitle>
<process-diagram-viewer mode="view" v-if="processDiagramViewer"/>
@@ -26,18 +27,18 @@
<script setup lang="jsx">
import ProcessDiagramViewer from '@/views/workflow/common/ProcessDiagramViewer.vue';
import {getProjectCheckProcess, projectCheck,getCheckDetail,resubmitCheck} from "@/api/project-manage";
import {getProjectCheckProcess, projectCheck, getCheckDetail, resubmitCheck} from "@/api/project-manage";
import {ElNotification} from "element-plus";
import {useProcessStore} from '@/stores/processStore.js';
import {useTagsView} from '@/stores/tagsview.js'
const tagsViewStore = useTagsView()
const router = useRouter()
const route = useRoute()
const attachment = ref()
const name=ref(router.currentRoute.value.name)
const name = ref(router.currentRoute.value.name)
const loading = ref(false)
const formData = ref({})
const file = ref({})
const applyForm = ref()
const deploymentId = ref()
const showTable = ref(true)
@@ -46,9 +47,9 @@ const processInstanceData = ref()
const processDiagramViewer = ref(true)
const processStore = useProcessStore()
const compositeParam = (item) => {
let tag=''
if(name.value==='Implementation/check'||name.value === 'Implementation/edit'){
tag='项目验收'
let tag = ''
if (name.value === 'Implementation/check' || name.value === 'Implementation/edit') {
tag = '项目验收'
}
return {
fileId: item.id,
@@ -62,7 +63,6 @@ const compositeParam = (item) => {
}
const getAttachment = (val) => {
console.log('上传文件getAttachment', val)
file.value=compositeParam(val)
formData.value.singleFile = compositeParam(val)
}
const getOtherFile = (val) => {
@@ -86,32 +86,20 @@ const handleSubmit = (instance) => {
instance.validate(async (valid) => {
if (!valid) return
let files = []
let singleFile={}
let fileArray
if(name.value === 'Implementation/edit'){
singleFile = {
fileId: attachment.value.singleFile.fileId
}
fileArray=attachment.value.allFileList
}else {
if (file.value.fileId !== undefined) {
singleFile = {
fileId: file.value.fileId
}
}
fileArray=otherFileList.value
}
fileArray.forEach(item => {
otherFileList.value.forEach(item => {
files.push(getFileParam(item))
})
if (formData.value.singleFile !== undefined) {
formData.value.singleFile = getFileParam(formData.value.singleFile)
}
let params = {
deploymentId: deploymentId.value,
requirementId: route.query.id,
fileList: files,
singleFile: singleFile,
projectId:route.query.projectId,
singleFile: formData.value.singleFile,
projectId: route.query.projectId,
}
if (JSON.stringify(singleFile) === "{}") {
if (!attachment.value.isSingleFile) {
attachment.value.validate()
ElNotification({
title: '提示',
@@ -119,10 +107,10 @@ const handleSubmit = (instance) => {
type: 'error'
})
return;
}else {
} else {
attachment.value.clearValidate()
}
console.log('params-提交',params)
console.log('params-提交', params)
let res = await projectCheck(params)
ElNotification({
title: '提示',
@@ -141,34 +129,21 @@ const handleResubmit = (instance) => {
if (!instance) return
instance.validate(async (valid) => {
if (!valid) return
let singleFile = {}
let otherFiles = []
let fileArray
if (attachment.value.singleFile!==null&&name.value === 'Implementation/edit') {
singleFile = {
fileId: attachment.value.singleFile.fileId
}
fileArray = attachment.value.allFileList
} else {
if (file.value.fileId !== undefined) {
singleFile = {
fileId: file.value.fileId
}
}
fileArray = otherFileList.value
if (name.value === 'Implementation/edit') {
attachment.value.allFileList?.forEach(item => {
otherFiles.push(getFileParam(item))
})
}
fileArray.forEach(item => {
otherFiles.push(getFileParam(item))
})
//todo requirementId
let params = {
deploymentId: deploymentId.value,
requirementId: route.query.id,
fileList: otherFiles,
singleFile: singleFile,
singleFile: formData.value.singleFile,
projectId: route.query.projectId,
}
if (JSON.stringify(singleFile) === "{}") {
if (!attachment.value.isSingleFile || !formData.value.singleFile) {
attachment.value.validate()
ElNotification({
title: '提示',
@@ -176,7 +151,7 @@ const handleResubmit = (instance) => {
type: 'error'
})
return;
}else {
} else {
attachment.value.clearValidate()
}
console.log('重新提交params', params)
@@ -204,16 +179,16 @@ const getDetailInfo = async () => {
})
if (res.code === 1000) {
formData.value = res.data.formData
loading.value=false
loading.value = false
}
})
}
const init = () => {
const init = () => {
getProjectCheckProcess(route.query.projectId).then(res => {
processDiagramViewer.value = false
if (res.code === 1000) {
let data = res.data
deploymentId.value=data.deploymentId
deploymentId.value = data.deploymentId
processInstanceData.value = data
processStore.setDesign(data)
processStore.runningList.value = data.runningList;
@@ -224,7 +199,7 @@ const init = () => {
nextTick(() => {
processDiagramViewer.value = true
})
}else {
} else {
ElNotification({
title: '提示',
message: res.msg,
@@ -235,8 +210,8 @@ const init = () => {
}
onMounted(async () => {
await init()
if (name.value === 'Implementation/edit'){
loading.value=true
if (name.value === 'Implementation/edit') {
loading.value = true
await getDetailInfo()
}
})