Files
mosr-web/src/components/DetailComponent/ProjectApply.vue

252 lines
7.2 KiB
Vue

<template>
<div class="apply-block">
<el-form :model="formData" ref="applyForm" label-width="auto" :rules="rules">
<el-row>
<el-col :span="12">
<el-form-item label="前置流程">
<el-input v-model="formData.requirementName" clearable></el-input>
</el-form-item>
</el-col>
</el-row>
</el-form>
<AttachmentUpload ref="attachment" :label="title+'附件'" :showTable="showTable" :otherFileList="otherFileList"
@getAttachment="getAttachment"
@getOtherFile="getOtherFile" :showFileList="true" :formData="formData"
:preview="route.query.state==3"/>
<div v-if="route.query.state==3">
<baseTitle title="审批记录"></baseTitle>
<div class="process">
<operation-render v-if="processDiagramViewer" :operation-list="data.operationList"
:state="data.state"/>
</div>
</div>
<baseTitle title="流程"></baseTitle>
<div class="approval-record">
<process-diagram-viewer mode="view" idName="projectApply" v-if="processDiagramViewer"/>
</div>
<div class="oper-page-btn">
<el-button color="#DED0B2" v-if="route.query.state==0" @click="handleSubmit(applyForm)">提交</el-button>
<el-button color="#DED0B2" v-else-if="route.query.state==3" @click="handleSubmit(applyForm)">重新提交</el-button>
</div>
</div>
</template>
<script setup lang="jsx">
import OperationRender from '@/views/workflow/common/OperationRender.vue'
import ProcessDiagramViewer from '@/views/workflow/common/ProcessDiagramViewer.vue';
import {ElNotification} from "element-plus";
import {getApplyProcess, projectApply, resubmitApply, getApplyDetail} from "@/api/project-manage";
import {useProcessStore} from '@/stores/processStore.js';
import {useTagsView} from '@/stores/tagsview.js'
const router = useRouter()
const route = useRoute()
const emit = defineEmits(["getAttachment", "getOtherFile"])
const props = defineProps({
title: {
type: String,
default: '项目立项'
},
showTable: {
type: Boolean,
default: false
},
data: {
type: Array,
default: []
}
})
const rules = reactive({
// requirementName: [{required: true, message: '请选择前置流程', trigger: 'blur'}],
})
const tagsViewStore = useTagsView()
const processStore = useProcessStore()
const otherFileList = ref([])
const formData = ref({})
const attachment = ref()
const showTable = ref(true)
const loading = ref(false)
const processDiagramViewer = ref(false)
const name = ref(router.currentRoute.value.name)
const applyForm = ref()
const deploymentId = ref()
const compositeParam = (item) => {
// let tag = ''
// if (name.value === 'Initiation/apply' || route.query.state==3) {
// tag = props.title
// }
return {
fileId: item.id,
size: item.size,
originalFileName: item.originalFilename,
fileType: item.fileType,
url: item.url,
newFile: false,
tag: props.title
}
}
const getAttachment = (val) => {
console.log('上传文件getAttachment', val)
formData.value.singleFile = compositeParam(val)
}
const getOtherFile = (val) => {
console.log('上传文件getOtherFile', val)
showTable.value = false
let fileObj = compositeParam(val)
otherFileList.value.push(fileObj)
nextTick(() => {
showTable.value = true
})
}
const getFileParam = (item) => {
return {
fileId: item.fileId,
tag: item.tag
}
}
const handleSubmit = (instance) => {
if (!instance) return
instance.validate(async (valid) => {
if (!valid) return
let files = []
if (route.query.state === '3') {
attachment.value.allFileList.forEach(item => {
files.push(getFileParam(item))
})
} else {
otherFileList.value.forEach(item => {
files.push(getFileParam(item))
})
}
// if (formData.value.singleFile !== undefined) {
// formData.value.singleFile = getFileParam(formData.value.singleFile)
// }
if (attachment.value.singleFile == null) {
attachment.value.validate()
ElNotification({
title: '提示',
message: '请上传附件',
type: 'error'
})
return;
} else {
attachment.value.clearValidate()
}
let params = {
deploymentId: deploymentId.value,
requirementId: route.query.id,
fileList: files,
singleFile: formData.value.singleFile,
projectId: route.query.projectId,
}
console.log('params', params)
let res
if (route.query.state === '3') {
res = await resubmitApply(params)
} else {
res = await projectApply(params)
}
ElNotification({
title: '提示',
message: res.msg,
type: res.code === 1000 ? 'success' : 'error'
})
if (res.code === 1000) {
tagsViewStore.delVisitedViews(router.currentRoute.value.path)
await router.push({
name: 'Initiation'
})
}
})
}
// const handleResubmit = async () => {
// let files = []
// if (route.query.state == 3) {
// attachment.value.allFileList.forEach(item => {
// files.push(getFileParam(item))
// })
// }
// if (attachment.value.singleFile == null) {
// attachment.value.validate()
// ElNotification({
// title: '提示',
// message: '请上传附件',
// type: 'error'
// })
// return;
// } else {
// attachment.value.clearValidate()
// }
// let params = {
// deploymentId: deploymentId.value,
// requirementId: route.query.id,
// fileList: files,
// singleFile: attachment.value.singleFile,
// projectId: route.query.projectId,
// }
// console.log('params', params, attachment.value.singleFile)
// let res = await resubmitApply(params)
// ElNotification({
// title: '提示',
// message: res.msg,
// type: res.code === 1000 ? 'success' : 'error'
// })
// if (res.code === 1000) {
// tagsViewStore.delVisitedViews(router.currentRoute.value.path)
// await router.push({
// name: 'Initiation'
// })
// }
// }
const init = () => {
if (!route.query.projectId) return;
processDiagramViewer.value = false
getApplyProcess(route.query.projectId).then(res => {
if (res.code === 1000) {
let data = res.data
deploymentId.value = data.deploymentId
processStore.setDesign(data)
processStore.runningList.value = data.runningList;
processStore.endList.value = data.endList;
processStore.noTakeList.value = data.noTakeList;
processStore.refuseList.value = data.refuseList;
processStore.passList.value = data.passList;
nextTick(() => {
processDiagramViewer.value = true
})
} else {
ElNotification({
title: '提示',
message: res.msg,
type: 'error'
})
}
})
}
const getDetailInfo = async () => {
if (!route.query.projectId) return;
getApplyDetail(route.query.projectId).then(res => {
ElNotification({
title: '提示',
message: res.msg,
type: res.code === 1000 ? 'success' : 'error'
})
if (res.code === 1000) {
formData.value = res.data.formData
loading.value = false
}
})
}
onMounted(async () => {
await init()
if (route.query.state == 3) {
loading.value = true
await getDetailInfo()
}
})
</script>
<style scoped>
</style>