Files
mosr-web/src/views/project-management/initiation/apply.vue

256 lines
7.0 KiB
Vue

<template>
<div class="apply-block">
<el-form :model="formData" ref="applyForm" label-width="auto" :rules="rules">
<baseTitle title="项目立项申请"></baseTitle>
<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="需求申请书附件" :showTable="showTable" :otherFileList="otherFileList"
@getAttachment="getAttachment"
@getOtherFile="getOtherFile" :showFileList="true" :formData="formData" :preview="name === 'Initiation/edit'"/>
<div class="approval-record">
<baseTitle title="流程"></baseTitle>
<process-diagram-viewer mode="view" v-if="processDiagramViewer"/>
</div>
<div class="oper-page-btn">
<el-button color="#DED0B2" @click="handleSubmit(applyForm)">提交</el-button>
<el-button color="#DED0B2" @click="handleResubmit">重新提交</el-button>
</div>
</div>
</template>
<script setup lang="jsx">
import {useTagsView} from '@/stores/tagsview.js'
import {ElMessage, ElNotification} from "element-plus";
import ProcessDiagramViewer from '@/views/workflow/common/ProcessDiagramViewer.vue';
import {getApplyProcess, projectApply,resubmitApply,getApplyDetail} from "@/api/project-manage";
import {useProcessStore} from '@/stores/processStore.js';
const tagsViewStore = useTagsView()
const router = useRouter()
const route = useRoute()
const formData = ref({})
const rules = reactive({
attachment: [{required: true, message: '请上传项目立项附件', trigger: 'blur'}],
})
const processStore = useProcessStore()
const deploymentId = ref()
const attachment = ref()
const file = ref({})
const applyForm = ref()
const showTable = ref(true)
const otherFileList = ref([])
const tableConfig = reactive({
columns: [
{
prop: 'index',
type: 'index',
label: '序号',
align: 'center',
width: '80',
},
{
prop: 'originalFileName',
label: '文件名',
align: 'center',
},
{
prop: 'tag',
label: '标签',
align: 'center'
},
{
prop: 'size',
label: '文件大小',
align: 'center',
currentRender: ({row, index}) => (parseInt(row.size / 1024) + 'KB')
},
// {
// prop: 'oper',
// label: '操作',
// align: 'center',
// currentRender: ({row, index}) => {
// return (
// <div>
// <a style="cursor: pointer;font-size: 14px;color: #2a99ff;" href={row.url}>下载</a>
// <el-button type="primary" size="large" link onClick={() => beforeRemove(row)}>删除</el-button>
// </div>
// )
// }
// }
]
})
const loading = ref(false)
const processInstanceData = ref()
const processDiagramViewer = ref(true)
const name=ref(router.currentRoute.value.name)
const compositeParam = (item) => {
let tag = ''
if (name.value === 'Initiation/apply'||name.value === 'Initiation/edit') {
tag = '项目立项申请'
}
return {
fileId: item.id,
size: item.size,
originalFileName: item.originalFilename,
fileType: item.fileType,
url: item.url,
tag:tag
}
}
const getAttachment = (val) => {
console.log('上传文件getAttachment', val)
file.value=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
}
}
const handleSubmit = (instance) => {
if (!instance) return
instance.validate(async (valid) => {
if(JSON.stringify(file.value) === "{}"){
attachment.value.validate()
}else {
attachment.value.clearValidate()
}
if (!valid) return
let files = []
let singleFile={}
if(file.value.fileId!==undefined){
singleFile = {
fileId: file.value.fileId
}
}
otherFileList.value.forEach(item => {
files.push(getFileParam(item))
})
let params = {
deploymentId: deploymentId.value,
requirementId: route.query.id,
fileList: files,
singleFile: singleFile,
projectId:route.query.projectId,
}
console.log('params',params)
let 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 = []
let singleFile={}
let fileArray
if (JSON.stringify(file.value) === "{}"||attachment.value.singleFile===null) {
attachment.value.validate()
} else {
attachment.value.clearValidate()
}
if(attachment.value.singleFile!==null&&name.value === 'Initiation/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 => {
files.push(getFileParam(item))
})
let params = {
deploymentId: deploymentId.value,
requirementId: route.query.id,
fileList: files,
singleFile: singleFile,
projectId:route.query.projectId,
}
console.log('params',params)
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 getDetailInfo = async () => {
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
}
})
}
const init = () => {
getApplyProcess().then(res => {
processDiagramViewer.value = false
if (res.code === 1000) {
let data = res.data
deploymentId.value=data.deploymentId
processInstanceData.value = data
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
})
}
})
}
init()
onMounted(async () => {
await init()
if (name.value === 'Initiation/edit') {
loading.value=true
await getDetailInfo()
}
})
</script>
<style scoped>
</style>