Files
faw-report-library-web/src/views/permissionApplication/launch.vue
T
2023-05-11 18:04:51 +08:00

383 lines
11 KiB
Vue

<script src="../../utils/Enum/index.js"></script>
<script src="../../utils/Enum/enum.js"></script>
<template>
<div class="process">
<div class="process_box">
<process-header v-if="$route.query.isBegin || $route.query.isDraft" :title="'发起流程'"></process-header>
<process-header v-else-if="$route.query.type == 'yiban'" :title="'已办流程'" :proceesNum="prcNum"></process-header>
<process-header v-else :title="'发起人修改'" :proceesNum="prcNum"></process-header>
<div class="procedure">
<div class="process_content">
<span class="base_title">基础信息</span>
<el-row>
<report-table v-model="tableData" @updateTable="getV" :disabled="showTableD"></report-table>
</el-row>
<el-row>
</el-row>
</div>
<div class="process_content" v-if="initShow">
<span class="base_title">审批历史</span>
<process-approval-history :prcNum="prcNum"></process-approval-history>
</div>
</div>
<process-footer
v-if="!formControl"
showCancel
:show-save="isShowSave"
:show-submit="isShowSubmit"
:submitLoading="isSubmit"
:resetLoading="saveLoading"
@save="handleSave"
@submit="handleSubmit"
></process-footer>
</div>
</div>
</template>
<script>
import processHeader from '@/components/ProcessHeader'
import processFooter from '@/components/ProcessFooter'
import processApprovalHistory from '@/components/ProcessApprovalHistory'
import reportTable from './components/reportTable'
import processMixin from "../../components/ProcessMixin";
import { PERMISSION } from '@/utils/Enum/enum'
export default {
name: 'launch',
components: {
processHeader,
reportTable,
processFooter,
processApprovalHistory,
},
mixins: [processMixin],
data() {
return {
PERMISSION,
delData:[],
showTableD: false,
initShow: false, // 控制审批历史是否显示 只有在不是第一次的时候才是true
treeType: '',
orgTableVal: '',
orgTableValName: '',
visibleOrgTable: false,
isSubmit: false,
saveLoading: false,
isShowSave: false,
isShowSubmit: true,
formControl: false,
assignForm: {
oneApprove: '',
twoApprove: '',
twoApproveName: '',
oneApproveName: '',
remark:''
},
tableData: [],
applicationForm: {
applyReason: '',
power: ''
},
q: {
pageSize: 10000,
pageNo: 1
},
processForm: {
prcName: ''
},
processFormRule: {
prcName: [{
required: true,
message: '请输入流程名称',
trigger: 'change'
}, {
max: 100,
message: '流程名称最多填写100字符',
trigger: 'change'
}]
},
assignFormRules: {
remark: [{
max: 500, message: '说明最多填写500字符'
}]
},
prcType: '',
prcName:'',
params:[] //处理好格式的数据
}
},
async created() {
// 第一次进入此页面 需要清楚校验
if (this.$route.query.isBegin) {
// if (this.$route.query.ids.split(',').length > 0) {
this.reportList(this.$route.query.ids)
// }
this.isShowSave = true
this.$store.commit('setHandleProcess','')
}
// 如果是从草稿进入的
if (this.$route.query.isDraft) {
this.isShowSave = true
this.taskId = this.$store.getters.handleProcess?.taskId
this.prcNum = this.$store.getters.handleProcess?.prcNum
this.prcId = this.$store.getters.handleProcess?.prcId
this.prcName = this.$store.getters.handleProcess?.prcName
this.dataId= this.$store.getters.handleProcess?.dataId
this.prcType= this.$store.getters.handleProcess?.prcType
this.getProcessDetail().then(res => {
let powerName=''
let dataJson=JSON.parse(this.processOld.dataJson)
if(dataJson.power){
this.PERMISSION.forEach(item=>{
if(item.value == dataJson.power){
powerName=item.label
}
})
}
let submitJson = JSON.parse(this.processOld.submitJson)
// this.applicationForm.applyReason = applyReason.applyReason
this.tableData.push({...dataJson,...submitJson,powerName:powerName})
})
}
if (this.$route.query.taskDefinitionKey == 'reEdit' ) {
this.taskId = this.$store.getters.handleProcess.taskId
this.prcNum = this.$store.getters.handleProcess.prcNum
this.prcId = this.$store.getters.handleProcess.prcId
this.prcName = this.$store.getters.handleProcess.prcName
this.prcName = JSON.stringify(this.prcName)
this.initShow = true
this.formControlname = true
await this.getProcessDetail()
let powerName=''
this.PERMISSION.forEach(item=>{
if(item.value == JSON.parse(this.processOld.dataJson).power ){
powerName=item.label
}
})
let submitJson = JSON.parse(this.processOld.submitJson)
// this.applicationForm.applyReason = applyReason.applyReason
this.tableData.push({...JSON.parse(this.processOld.dataJson),...JSON.parse(this.processOld.submitJson),powerName:powerName})
}
if (this.$route.query.type == 'yiban') {
this.taskId = this.$store.getters.handleProcess.taskId
this.prcNum = this.$store.getters.handleProcess.prcNum
this.prcId = this.$store.getters.handleProcess.prcId
this.prcName = this.$store.getters.handleProcess.prcName
this.formControl = true
this.initShow = true
this.showTableD = true
await this.getProcessDetail()
let powerName=''
this.PERMISSION.forEach(item=>{
if(item.value == JSON.parse(this.processOld.dataJson).power ){
powerName=item.label
}
})
let submitJson = JSON.parse(this.processOld.submitJson)
// this.applicationForm.applyReason = applyReason.applyReason
this.tableData.push({...JSON.parse(this.processOld.dataJson),...submitJson,powerName:powerName})
}
},
methods: {
getV(newValue,jiaVlue)
{
if(jiaVlue &&jiaVlue.length > 0){
jiaVlue.forEach(item=>{
this.delData.push({
prcId:this.prcId,
reportId:item
})
})
this.$set(this,'delData',this.delData)
}
this.$set(this,'tableData',newValue)
// this.tableData=newValue;
// this.delData=jiaVlue
},
// 获取表格列表 吧查询到的值传给子组件
reportList(ids) {
this.$api.report.reportList({
pageSize:1000,
pageNo:1,
ids: ids.split(',')
}).then(({data}) => {
this.tableData = data.records.map(item => {
item.oneApprove = item.createUserId || ''
item.oneApproveName= item.uploader || ''
item.reportId = item['id']
delete item['id']
return item
})
})
},
handleReset() {
if(this.$route.query.taskDefinitionKey == 'reEdit'){
this.processForm.prcName = this.prcName
}
},
//判断表格数据是否完整
JuggleTableAll(){
let list= this.tableData.filter(item=>{
if(!item.twoApprove || item.twoApprove=='' || item.power==''){
return item
}
})
if(list.length>0){
return false
}
return true
},
// 整理数据
organizeData() {
let newParams=[]
newParams=this.tableData.map(item=>{
let obj={}
obj={
id:'',
prcName:item.name,
prcType:item.power==0?'':item.power,
createUser:this.userId,
createUserName:this.userName,
userId:this.userId,
dataJson:'',
bpnId: this.$store.getters.handleProcess?.id,
reportId: item.reportId,
}
let submitJson={
oneApprove:item.oneApprove,
oneApproveName:item.oneApproveName,
twoApprove:item.twoApprove,
twoApproveName:item.twoApproveName,
userId:this.userId,
}
delete item['oneApprove']
delete item['oneApproveName']
delete item['twoApprove']
delete item['twoApproveName']
let dataJson=item
obj.submitJson=JSON.stringify(submitJson)
obj.dataJson=JSON.stringify({...dataJson, createUser:this.userId, createUserName:this.userName})
return obj
})
if (this.initShow){
newParams[0].taskId=this.taskId
}
this.params=newParams
},
// 保存
handleSave(){
this.saveLoading = true
if(this.tableData.length==0){
this.$message.warning('至少需要选择一条报告数据')
return
}
// 处理表格数据
this.organizeData()
this.params=this.params.map(item=>{
item.id = this.$store.getters.handleProcess?.id
return item
})
this.saveProcessALL(this.params).then(
()=>{
this.saveLoading = false
this.$message['success']('保存成功')
this.$router.push({
path: "/userCenter/processCenter",
query: {
id: 'AEHJB8YNJ3'
}
})
}
).catch(()=>{
this.saveLoading = false
})
},
// 提交
handleSubmit() {
// 过了校验 需要把数据都整合 this.tableData this.applicationForm this.assignForm
// 表格数据没有不能提交 需要提示
if (this.tableData.length == 0) {
this.$message.warning('至少需要选择一条报告数据')
} else {
// 调用流程数据
console.log("发送数据")
// 处理表格数据
//如果不是第一次
if (this.initShow) {
let flag= this.JuggleSub(this.taskId)
if(flag){
this.organizeData()
this.completeProcess(this.params[0])
}
} else {
if(this.JuggleTableAll()){
this.organizeData()
this.startProcess()
}else{
this.$message.warning("请把表格数据填写完整")
}
// this.isSendDraft().then(()=>{
// })
}
}
},
//修改参数
changeParam() {
},
// 草稿发起 需要先调用这个接口
isSendDraft(){
let ids=this.tableData.map(item=>{
return item.reportId
})
return new Promise((resolve,reject)=>{
this.$api.permissionProcess.selectReport({ids:ids}).then((res)=>{
if(res.data.length==0){
resolve(true)
}else{
this.$message.warning("报告"+res.data.join(',')+"已经在流程中")
reject()
}
})
})
},
startProcess() {
//把表单都整合到form中
this.$api.process.startProcessALL(this.params).then((res) => {
let data=res.data.result.split(',')
this.params=this.params.map((item,index)=>{
item.taskId=data[index]
return item
})
this.completeProcessALL(this.params)
})
},
//获取流程详细信息
}
}
</script>
<style scoped>
</style>