434 lines
13 KiB
Vue
434 lines
13 KiB
Vue
|
|
<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'
|
|
import {template} from "xe-utils";
|
|
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)
|
|
let powerName=''
|
|
// if(dataJson.power)
|
|
this.reportList(JSON.parse(this.processOld.dataJson).reportId)
|
|
let submitJson = JSON.parse(this.processOld.submitJson)
|
|
// this.applicationForm.applyReason = applyReason.applyReason
|
|
|
|
|
|
})
|
|
|
|
}
|
|
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 submitJson = JSON.parse(this.processOld.submitJson)
|
|
|
|
// this.applicationForm.applyReason = applyReason.applyReason
|
|
|
|
this.reportList(JSON.parse(this.processOld.dataJson).reportId)
|
|
}
|
|
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: {
|
|
// 获取领导
|
|
getLearder(id){
|
|
console.log("获取领导")
|
|
return new Promise((resolve,reject)=>{
|
|
this.$api.reportProcess.getLeader({
|
|
userId:id
|
|
}).then(res=>{
|
|
if(res.data.length>0){
|
|
resolve(res.data)
|
|
}else{
|
|
resolve('')
|
|
}
|
|
})
|
|
})
|
|
},
|
|
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}) => {
|
|
if(this.$route.query.taskDefinitionKey == 'reEdit' ){
|
|
let powerName=''
|
|
this.PERMISSION.forEach(item=>{
|
|
if(item.value == JSON.parse(this.processOld.dataJson).power ){
|
|
powerName=item.label
|
|
}
|
|
})
|
|
this.tableData.push({...JSON.parse(this.processOld.dataJson),...JSON.parse(this.processOld.submitJson),powerName:powerName})
|
|
this.tableData[0].oldpower=data.records[0].power
|
|
this.$set(this.tableData[0],'oldpower',data.records[0].power)
|
|
}else if(this.$route.query.isDraft){
|
|
// 草稿的时候 判断当前的权限跟原来的下权限还是都一样
|
|
if(JSON.parse(this.processOld.dataJson).power==data.records[0].power){
|
|
this.tableData.push({...JSON.parse(this.processOld.dataJson),...JSON.parse(this.processOld.submitJson)})
|
|
}else{
|
|
|
|
let powerName=''
|
|
this.PERMISSION.forEach(item=>{
|
|
if(item.value == JSON.parse(this.processOld.dataJson).power ){
|
|
powerName=item.label
|
|
}
|
|
})
|
|
this.tableData.push({...JSON.parse(this.processOld.dataJson),...JSON.parse(this.processOld.submitJson),powerName:powerName})
|
|
this.tableData[0].oldpower=data.records[0].power
|
|
this.$set(this.tableData[0],'oldpower',data.records[0].power)
|
|
}
|
|
}else{
|
|
let templateL=[]
|
|
data.records.map(async item => {
|
|
item.oneApprove = item.createUserId || ''
|
|
item.oneApproveName= item.uploader || ''
|
|
if(item.oneApprove){
|
|
let res=await this.getLearder(item.oneApprove)
|
|
if(res){
|
|
item.twoApprove = res[0].usid
|
|
item.twoApproveName= res[0].usname
|
|
}
|
|
}
|
|
item.reportId = item['id']
|
|
delete item['id']
|
|
templateL.push(item)
|
|
})
|
|
this.tableData=templateL
|
|
console.log("页面没渲染?",this.tableData)
|
|
|
|
}
|
|
})
|
|
|
|
},
|
|
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.$store.commit('setActiveTabIndex', 'five')
|
|
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()){
|
|
// 完整判断草稿发起的在不在流程
|
|
if(this.$route.query.isDraft){
|
|
this.isSendDraft().then((res)=>{
|
|
this.organizeData()
|
|
this.startProcess()
|
|
})
|
|
}else{
|
|
this.organizeData()
|
|
this.startProcess()
|
|
}
|
|
}else{
|
|
this.$message.warning("请把表格数据填写完整")
|
|
}
|
|
}
|
|
}
|
|
|
|
},
|
|
// 草稿发起 需要先调用这个接口
|
|
isSendDraft(){
|
|
let ids=this.tableData.map(item=>{
|
|
return item.reportId
|
|
})
|
|
return new Promise((resolve,reject)=>{
|
|
this.$api.process.selectReport({usid:this.userId,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>
|