Files
laws-sinotruk-client/src/views/workCenter/enterpriseStandardInitChange/PlanApprovalChangeFlow.vue
T

1135 lines
52 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<template>
<internal-detail-page :title="pageTitle" :content-padding="0" :loading="loading">
<!-- 标题右侧tab -->
<template v-slot:titleRightCustom>
<div class="table-operator-tab">
<a class="switch-item" :class="switchValue === 'base' ? 'table-operator-tab-active' : ''"
@click="switchChange('base')">{{ $t('basicInformation') }}
</a>
<a class="switch-item" :class="switchValue === 'user' ? 'table-operator-tab-active' : ''"
@click="switchChange('user')">{{ $t('personalInformation') }}
</a>
</div>
</template>
<!-- 基础信息 -->
<div v-show="switchValue === 'base'" class="detail-page-scroll-content">
<!-- 流程信息 -->
<div class="process-part-title">{{ $t('processInformation') }}</div>
<a-form :form="processInfoForm">
<a-row>
<a-col :span="12">
<!-- 流程名称 -->
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('processName')" :colon="formItemColon">
<a-input :placeholder="$t('pleaseEnter') + $t('processName')"
@change="event => event.target.value = event.target.value.trim()"
:disabled="disabled || processNameDisabled"
:maxLength="50"
v-decorator="['prcName', validatorRules.prcName]" />
</a-form-item>
</a-col>
<a-col :span="12">
<!-- 截止日期 -->
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('expirationDate')" :colon="formItemColon">
<a-date-picker :placeholder="$t('pleaseSelect') + $t('expirationDate')"
style="width: 100%"
:disabled="disabled"
value-format="YYYY-MM-DD"
v-decorator="['dueTime']" />
</a-form-item>
</a-col>
<a-col :span="24">
<!-- 流程说明 -->
<a-form-item :labelCol="longLabelCol" :wrapperCol="longWrapperCol" :label="$t('processExplain')" :colon="formItemColon">
<a-textarea :placeholder="$t('pleaseEnter') + $t('processExplain')"
:maxLength="500"
:rows="4"
:disabled="disabled"
v-decorator="['prcMes']" />
</a-form-item>
</a-col>
</a-row>
</a-form>
<!-- 业务基本信息 -->
<div class="process-part-title">{{ $t('basicServiceInformation') }}</div>
<!-- 申请类型和项目类型 -->
<a-form-model :model="formInline" :rules="rules" ref="ruleForm">
<div class="form-flex-box">
<!-- 申请类型 -->
<div class="box-title-text form-flex-item">
<div class="title-text">
<span class="required">*</span>
<span class="title-text-text" :title="$t('workCenter.enterpriseInitChangePlan.applicationType')">
{{ $t('workCenter.enterpriseInitChangePlan.applicationType') }}
</span>
</div>
<a-form-model-item class="item-model" prop="applicationCategory">
<!--<j-dict-select-tag v-model="formInline.applicationCategory"-->
<!-- :disabled="disabled"-->
<!-- :placeholder="$t('pleaseSelect')+$t('workCenter.enterpriseInitChangePlan.applicationType')"-->
<!-- :type="'select'"-->
<!-- :triggerChange="false"-->
<!-- dictCode="esp_application_category" />-->
<a-select v-model="formInline.applicationCategory"
:disabled="disabled || categoryTypeDisabled"
@change="applicationCategoryChange"
:placeholder="$t('pleaseSelect')+$t('workCenter.enterpriseInitChangePlan.applicationType')">
<a-select-option :value="ApplicationCategory.INITIATION.value">{{ $t('workCenter.enterpriseInitChangePlan.standardProjectEstablishment') }}</a-select-option>
<a-select-option :value="ApplicationCategory.CHANGE.value">{{ $t('workCenter.enterpriseInitChangePlan.change') }}</a-select-option>
</a-select>
</a-form-model-item>
</div>
<!-- 项目类别 -->
<div class="box-title-text form-flex-item">
<div class="title-text">
<span class="required">*</span>
<span class="title-text-text" :title="$t('workCenter.enterpriseInitChangePlan.itemCategory')">
{{ $t('workCenter.enterpriseInitChangePlan.itemCategory') }}
</span>
</div>
<a-form-model-item class="item-model" prop="projectType">
<a-select v-if="formInline.applicationCategory === ApplicationCategory.INITIATION.value"
v-model="formInline.projectType"
:disabled="disabled || categoryTypeDisabled"
@change="projectTypeChange"
:placeholder="$t('pleaseSelect')+$t('workCenter.enterpriseInitChangePlan.itemCategory')">
<a-select-option :value="ProjectType.ENACT.value">{{ $t('workCenter.enterpriseInitChangePlan.formulate') }}</a-select-option>
<a-select-option :value="ProjectType.MODIFY.value">{{ $t('workCenter.enterpriseInitChangePlan.revise') }}</a-select-option>
</a-select>
<a-select v-else-if="formInline.applicationCategory === ApplicationCategory.CHANGE.value"
v-model="formInline.projectType"
:disabled="disabled || categoryTypeDisabled"
@change="projectTypeChange"
:placeholder="$t('pleaseSelect')+$t('workCenter.enterpriseInitChangePlan.itemCategory')">
<a-select-option :value="ProjectType.COMPLETE_TIME_CHANGE.value">{{ $t('workCenter.enterpriseInitChangePlan.completionTimeChange') }}</a-select-option>
<a-select-option :value="ProjectType.WORK_TERMINATE.value">{{ $t('workCenter.enterpriseInitChangePlan.terminationOfWork') }}</a-select-option>
<a-select-option :value="ProjectType.RESPONSIBLE_DEPT_CHANGE.value">{{ $t('workCenter.enterpriseInitChangePlan.dutyDepartChange') }}</a-select-option>
<a-select-option :value="ProjectType.MERGE.value">{{ $t('workCenter.enterpriseInitChangePlan.merge') }}</a-select-option>
</a-select>
<a-select v-else
v-model="formInline.projectType"
:disabled="disabled"
:placeholder="$t('pleaseSelect')+$t('workCenter.enterpriseInitChangePlan.itemCategory')">
</a-select>
</a-form-model-item>
</div>
</div>
</a-form-model>
<!-- 申请类型为立项时的业务基本信息部分组件 -->
<approval-base-info
v-if="formInline.applicationCategory === ApplicationCategory.INITIATION.value"
ref="approvalBaseInfo"
:disabled="disabled"
:currentNode="currentNode"
:isInitData="isInitData"
@processNameChange="processNameChange"
:projectType="formInline.projectType">
</approval-base-info>
<!-- 申请类型为变更,项目类型为完成时间变更时的业务基本信息部分组件 -->
<finish-time-change-base-info
v-else-if="formInline.applicationCategory === ApplicationCategory.CHANGE.value && formInline.projectType === ProjectType.COMPLETE_TIME_CHANGE.value"
ref="changeBaseInfo"
:disabled="disabled"
:currentNode="currentNode"
:projectType="formInline.projectType"
>
</finish-time-change-base-info>
<!-- 申请类型为变更,项目类型为工作终止时的业务基本信息部分组件 -->
<job-end-base-info
v-else-if="formInline.applicationCategory === ApplicationCategory.CHANGE.value && formInline.projectType === ProjectType.WORK_TERMINATE.value"
ref="changeBaseInfo"
:disabled="disabled"
:currentNode="currentNode"
:projectType="formInline.projectType"
>
</job-end-base-info>
<!-- 申请类型为变更,项目类型为责任部门变更的业务基本信息部分组件 -->
<duty-depart-change-base-info
v-else-if="formInline.applicationCategory === ApplicationCategory.CHANGE.value && formInline.projectType === ProjectType.RESPONSIBLE_DEPT_CHANGE.value"
ref="changeBaseInfo"
:disabled="disabled"
@processNameChange="processNameChange"
:currentNode="currentNode"
:projectType="formInline.projectType"
>
</duty-depart-change-base-info>
<!-- 申请类型为变更,项目类型为合并的业务基本信息部分组件 -->
<merge-base-info
v-else-if="formInline.applicationCategory === ApplicationCategory.CHANGE.value && formInline.projectType === ProjectType.MERGE.value"
ref="changeBaseInfo"
:disabled="disabled"
:isInitData="isInitData"
@processNameChange="processNameChange"
:projectType="formInline.projectType"
>
</merge-base-info>
<!-- 部分节点需要选人 -->
<a-form v-if="formInline.applicationCategory === ApplicationCategory.CHANGE.value && [7, 8].includes(currentNode)" class="user-form" :form="userForm">
<a-row :gutter="24">
<!-- 所长,节点7需要选所长 -->
<a-col :span="12" v-if="currentNode === 7">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('workCenter.enterpriseInitChangePlan.superintendent')">
<user-selection :placeholder="$t('pleaseSelect') + $t('workCenter.enterpriseInitChangePlan.superintendent')"
type="radio"
v-decorator="['newMainDraftUserLeader', validatorRules.newMainDraftUserLeader]"
@nameChange="userSelectNameChange"
filedName="newMainDraftUserLeader"
:nameStr="userFormModel.newMainDraftUserLeader_dictText"
input-type="textarea" />
</a-form-item>
</a-col>
<!-- 相关人员,节点8需要选相关人员 -->
<a-col :span="12" v-if="currentNode === 8">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('workCenter.enterpriseInitChangePlan.relatedPersonnel')">
<user-selection :placeholder="$t('pleaseSelect') + $t('workCenter.enterpriseInitChangePlan.relatedPersonnel')"
type="checkbox"
v-decorator="['relatedUserList', validatorRules.relatedUserList]"
@nameChange="userSelectNameChange"
filedName="relatedUserList"
:nameStr="userFormModel.relatedUserList_dictText"
input-type="textarea" />
</a-form-item>
</a-col>
</a-row>
</a-form>
<!-- 流程审批信息 -->
<div class="process-part-title">{{ $t('processApprovalInformation') }}</div>
<a-form :form="approvalInfoForm">
<!--备注-->
<a-form-item :labelCol="longLabelCol" :wrapperCol="longWrapperCol" :label="$t('remarks')" :colon="formItemColon">
<a-textarea :placeholder="$t('pleaseEnter') + $t('remarks')"
:maxLength="500"
:rows="4"
v-decorator="['commitText', validatorRules.commitText]" />
</a-form-item>
<!--附件-->
<a-form-item :labelCol="longLabelCol" :wrapperCol="longWrapperCol" :label="$t('attach')" :colon="formItemColon">
<j-upload v-decorator="['commitFile']" return-id />
</a-form-item>
</a-form>
</div>
<!-- 人员信息 -->
<div v-show="switchValue === 'user'" class="detail-page-scroll-content p-0">
<process-detail-list :processKey="ProcessKey.ES_INIT_CHANGE.value">
<personnel-info slot="personnelInfo" ref="personnelInfo" :data="personnelInfoData" :currentNode="currentNodeId"></personnel-info>
</process-detail-list>
</div>
<!-- 操作按钮 -->
<div class="detail-page-bottom-operate-box">
<!-- 发起节点 -->
<template v-if="currentNode === 1">
<!-- 保存 -->
<a-button type="primary" ghost :loading="loading" @click="handleSave"><i class="iconfont icon-save"></i> {{ $t('preservation') }}</a-button>
<!-- 提交 -->
<a-button type="primary" :loading="loading" @click="handleStart" icon="upload">{{ $t('submit') }}</a-button>
</template>
<!-- 变更的新起草部门主管级上一级领导下发节点 -->
<template v-else-if="formInline.applicationCategory === ApplicationCategory.CHANGE.value && [7, 8].includes(currentNode)">
<!-- 转办 -->
<a-button type="primary" ghost :loading="loading" @click="handleTurnTo" icon="arrow-up">{{ $t('turnTo') }}</a-button>
<!-- 保存 -->
<a-button type="primary" ghost :loading="loading" @click="handleSave"><i class="iconfont icon-save"></i> {{ $t('preservation') }}</a-button>
<!-- 提交 -->
<a-button type="primary" :loading="loading" @click="handleSubmit" icon="upload">{{ $t('submit') }}</a-button>
</template>
<template v-else-if="formInline.applicationCategory === ApplicationCategory.CHANGE.value && currentNode === 10">
<!-- 确定, 谁发起的谁点确定抄送消息 -->
<a-button type="primary" :loading="loading" @click="handleDetermine" icon="upload">{{ $t('determine') }}</a-button>
</template>
<template v-else>
<!-- 转办 -->
<a-button type="primary" ghost :loading="loading" @click="handleTurnTo" icon="arrow-up">{{ $t('turnTo') }}</a-button>
<!-- 保存 -->
<a-button type="primary" ghost :loading="loading" @click="handleSave"><i class="iconfont icon-save"></i> {{ $t('preservation') }}</a-button>
<!-- 同意 -->
<a-button type="primary" :loading="loading" @click="handleAgree" icon="check-circle">{{ $t('agree') }}</a-button>
<!-- 驳回 -->
<a-button type="primary" :loading="loading" @click="handleReject" icon="close-circle">{{ $t('reject') }}</a-button>
</template>
</div>
<!-- 选人弹框 -->
<user-select-modal ref="userSelectModal" type="radio" @change="userSelectModalChange"></user-select-modal>
</internal-detail-page>
</template>
<script>
import InternalDetailPage from '@/components/InternalDetailPage'
import PersonnelInfo from '@/components/PersonnelInfo'
import UserSelectModal from '@/components/selection/UserSelectModal'
import UserSelection from '@/components/selection/UserSelection'
import {
enterprisePlanApprovalTurnTo,
enterprisePlanApprovalAgree,
enterprisePlanApprovalReject,
enterprisePlanApprovalSave,
enterprisePlanApproval,
getProcessDataById,
getProcessNodeList,
getProcessDataDraft
} from '@/api/workCenter'
import ApprovalBaseInfo from './modules/ApprovalBaseInfo'
import FinishTimeChangeBaseInfo from './modules/FinishTimeChangeBaseInfo'
import ProcessDetailList from '@/components/ProcessDetailList'
import JobEndBaseInfo from './modules/JobEndBaseInfo'
import DutyDepartChangeBaseInfo from './modules/DutyDepartChangeBaseInfo'
import MergeBaseInfo from './modules/MergeBaseInfo'
import { ProjectType, ApplicationCategory, ProcessKey, EsInitChangeNodes } from '@/enums/commonEnums'
import Vue from 'vue'
import { USER_INFO } from '@/store/mutation-types'
import pick from 'lodash.pick'
import { WorkCenterMixin } from '@/mixins/WorkCenterMixin'
export default {
name: 'PlanApprovalFlow',
components: {
MergeBaseInfo,
DutyDepartChangeBaseInfo,
JobEndBaseInfo,
ProcessDetailList,
FinishTimeChangeBaseInfo,
ApprovalBaseInfo,
UserSelectModal,
PersonnelInfo,
InternalDetailPage,
UserSelection
},
mixins: [WorkCenterMixin],
computed: {
pageTitle () {
return this.$t('flowCenter') + this.$route.meta.title + '(' + this.currentNodeName + ')'
},
// 流程名称是否不可填写
processNameDisabled () {
if (this.formInline.applicationCategory === ApplicationCategory.CHANGE.value &&
(this.formInline.projectType === ProjectType.COMPLETE_TIME_CHANGE.value ||
this.formInline.projectType === ProjectType.WORK_TERMINATE.value)) {
// 是完成时间变更或工作终止,流程名称无法自动生成,须填写
return false
} else {
return true
}
}
},
mounted () {
// 初始化流程节点
const nodeId = this.$route.query.nodeId
if (nodeId) {
this.currentNodeId = nodeId
if (nodeId === EsInitChangeNodes.mainDrafterStart.value) {
this.currentNode = 1
} else if (nodeId === EsInitChangeNodes.contactCheck.value) {
this.currentNode = 2
} else if (nodeId === EsInitChangeNodes.expertApproval.value) {
this.currentNode = 3
} else if (nodeId === EsInitChangeNodes.leaderApproval.value) {
this.currentNode = 4
} else if (nodeId === EsInitChangeNodes.leaderLeaderApproval.value) {
this.currentNode = 5
} else if (nodeId === EsInitChangeNodes.standardizationApproval.value) {
this.currentNode = 6
} else if (nodeId === EsInitChangeNodes.newDraftUnitLeaderLeaderSend.value) {
this.currentNode = 7
} else if (nodeId === EsInitChangeNodes.newDraftUnitLeaderConfirm.value) {
this.currentNode = 8
} else if (nodeId === EsInitChangeNodes.relevantPersonnelWillSign.value) {
this.currentNode = 9
} else if (nodeId === EsInitChangeNodes.mainDrafterCopy.value) {
this.currentNode = 10
} else {
// 预留加签节点
this.currentNode = 999
}
}
// 查询流程定义列表,通过查出的数据获取到流程定义id,如果已经发起过流程,用这个id和流程实例id去查人员信息数据
this.getPersonInfoStructure(ProcessKey.ES_INIT_CHANGE.value)
// 根据流程节点初始化是否可以编辑
if (this.$route.query.processInstanceId) {
if (this.currentNode === 1) {
this.disabled = false
} else {
this.disabled = true
}
}
if (this.$route.query.taskId && !this.$route.query.draftId) {
// 有流程id说明是从流程中心来的,需要初始化数据
this.getProcessData('todo', { taskId: this.$route.query.taskId })
// 待办进来的节点1说明是被驳回的,不可修改申请类型和项目类别
this.categoryTypeDisabled = true
}
if (this.$route.query.draftId) {
// 有草稿id,说明是从流程中心-草稿来的,需要初始化数据
this.getProcessData('draft', { draftId: this.$route.query.draftId, projectId: this.$route.query.projectId })
}
if (this.$route.query.taskName) {
// 说明是已发起流程
this.currentNodeName = this.$route.query.taskName
} else {
this.currentNodeName = '主起草人发起'
}
},
data () {
return {
ProjectType,
ApplicationCategory,
ProcessKey,
loading: false,
switchValue: 'base', // 头部tab选中值
disabled: false,
categoryTypeDisabled: false, // 申请类型和项目类别不可更改
currentNode: 1, // 当前节点
currentNodeName: '', // 当前节点名称
currentNodeId: EsInitChangeNodes.mainDrafterStart.value, // 当前节点id
model: [],
processInfoForm: this.$form.createForm(this),
labelCol: {
xs: { span: 24 },
sm: { span: 4 }
},
wrapperCol: {
xs: { span: 24 },
sm: { span: 20 }
},
longLabelCol: {
xs: { span: 24 },
sm: { span: 2 }
},
longWrapperCol: {
xs: { span: 24 },
sm: { span: 22 }
},
validatorRules: {
// 流程名称
prcName: {
rules: [
{ required: true, message: this.$t('pleaseEnter') + this.$t('processName') }
],
validateTrigger: 'blur'
},
commitText: {
rules: [
{ required: false, message: this.$t('pleaseEnter') + this.$t('remarks') }
],
validateTrigger: 'blur'
},
// 新起草部门主管级上级领导
newMainDraftUserLeaderLeader: {
rules: [
{ required: true, message: this.$t('pleaseSelect') + this.$t('workCenter.enterpriseInitChangePlan.superintendent') }
],
validateTrigger: 'change'
},
// 所长
newMainDraftUserLeader: {
rules: [
{ required: true, message: this.$t('pleaseSelect') + this.$t('workCenter.enterpriseInitChangePlan.superintendent') }
],
validateTrigger: 'change'
},
// 相关人员
relatedUserList: {
rules: [
{ required: true, message: this.$t('pleaseSelect') + this.$t('workCenter.enterpriseInitChangePlan.relatedPersonnel') }
],
validateTrigger: 'change'
}
},
formInline: {},
rules: {
// 申请类型
applicationCategory: [
{
required: true,
message: this.$t('workCenter.enterpriseInitChangePlan.applicationType') + this.$t('cannotEmpty'),
trigger: 'change'
}
],
// 项目类别
projectType: [
{
required: true,
message: this.$t('workCenter.enterpriseInitChangePlan.itemCategory') + this.$t('cannotEmpty'),
trigger: 'change'
}
]
},
userForm: this.$form.createForm(this), // 部分节点需要选人的表单
userFormModel: {},
approvalInfoForm: this.$form.createForm(this), // 审批信息表单
personnelInfoDataAll: [], // 整体人员信息
personnelInfoData: [], // 传给人员信息组件的人员信息
url: {
list: '' // 人员信息的右侧表格获取接口
},
isInitData: false // 是否正在初始化数据,正在初始化数据的时候不获取企标编号
}
},
methods: {
// 查询人员信息结构数据
getPersonInfoStructure (key) {
console.log('-----------getPersonInfoStructure-------', key)
const param = {}
param.processDefinitionKey = key
if (this.$route.query.processInstanceId) {
param.processInstanceId = this.$route.query.processInstanceId
}
getProcessNodeList(param).then(res => {
if (res.success) {
// 处理人员信息数据
this.personnelInfoDataAll = res.result.map(item => {
return {
...item,
chooseType: item.variableType === 'string' ? 'radio' : 'checkbox'
}
})
if (!this.$route.query.processInstanceId) {
// 说明是在新发起一个节点,初始化发起人员信息
const firstFieldName = this.personnelInfoDataAll[0].variableName
for (const item of this.personnelInfoDataAll) {
if (item.variableName === firstFieldName) {
item.linkUserIds = Vue.ls.get(USER_INFO).id
item.linkUserIds_dictText = Vue.ls.get(USER_INFO).realname + '(' + Vue.ls.get(USER_INFO).username + ')'
item.userList = Vue.ls.get(USER_INFO).realname + '(' + Vue.ls.get(USER_INFO).username + ')'
}
}
// this.personnelInfoDataAll[0].linkUserIds = Vue.ls.get(USER_INFO).id
// this.personnelInfoDataAll[0].userList = Vue.ls.get(USER_INFO).realname + '(' + Vue.ls.get(USER_INFO).username + ')'
// 筛选出立项的人员信息
this.personnelInfoData = this.personnelInfoDataAll.filter(item => item.branchType.split(',').includes('1'))
// 是立项,主管级领导审批和主管级上一届领导审批的节点名需要换成发起人...
const leader = this.personnelInfoData.find(item => item.variableName === 'mainDraftUserLeader')
leader.nodeName = EsInitChangeNodes.leaderApproval.initiationText
const leaderLeader = this.personnelInfoData.find(item => item.variableName === 'mainDraftUserLeaderLeader')
leaderLeader.nodeName = EsInitChangeNodes.leaderLeaderApproval.initiationText
}
}
})
},
/**
* 切换立项、变更、责任部门变更修改人员信息结构数据
* @param type: 1,立项;2,变更;3, 责任部门变更
*/
resetPersonInfoStructure (type) {
// 筛选出人员信息
const personnelData = this.$refs.personnelInfo.stepsData
this.personnelInfoData = this.personnelInfoDataAll.filter(item => item.branchType.split(',').includes(type))
// 把原本有的人员再给回去
for (const item of this.personnelInfoData) {
const findObj = personnelData.find(data => data.id === item.id)
if (findObj) {
item.linkUserIds = findObj.linkUserIds
item.linkUserIds_dictText = findObj.linkUserIds_dictText
}
}
if (type === '1') {
// 是立项,主管级领导审批和主管级上一级领导审批的节点名需要换成发起人...
const leader = this.personnelInfoData.find(item => item.variableName === 'mainDraftUserLeader')
leader.nodeName = EsInitChangeNodes.leaderApproval.initiationText
const leaderLeader = this.personnelInfoData.find(item => item.variableName === 'mainDraftUserLeaderLeader')
leaderLeader.nodeName = EsInitChangeNodes.leaderLeaderApproval.initiationText
} else {
// 是变更,主管级领导审批和主管级上一级领导审批的节点名需要换成主起草人...
const leader = this.personnelInfoData.find(item => item.variableName === 'mainDraftUserLeader')
leader.nodeName = EsInitChangeNodes.leaderApproval.changeText
const leaderLeader = this.personnelInfoData.find(item => item.variableName === 'mainDraftUserLeaderLeader')
leaderLeader.nodeName = EsInitChangeNodes.leaderLeaderApproval.changeText
}
},
// 根据流程id获取数据并回显
getProcessData (type, param) {
this.loading = true
this.isInitData = true
let func
let params = {}
if (type === 'todo') {
func = getProcessDataById
params = param.taskId
} else {
func = getProcessDataDraft
params = param
}
func(params).then(res => {
if (res.success) {
this.model = res.result
// 初始化流程信息
this.processInfoForm.setFieldsValue(pick(this.model.common, 'prcName', 'dueTime', 'prcMes'))
// 有草稿json按草稿进来的回显
if (this.model.infoJsonStr) {
// 初始化流程信息
const prcObj = Object.assign({}, this.model)
prcObj.dueTime = this.model.processDueDate
prcObj.prcMes = this.model.processDescription
this.processInfoForm.setFieldsValue(pick(prcObj, 'prcName', 'dueTime', 'prcMes'))
// 初始化流程审批信息
prcObj.commitText = this.model.handleText
prcObj.commitFile = this.model.handleFile
this.approvalInfoForm.setFieldsValue(pick(prcObj, 'commitText', 'commitFile'))
console.log(JSON.parse(this.model.infoJsonStr))
this.model.dataList = JSON.parse(this.model.infoJsonStr).arr || JSON.parse(this.model.infoJsonStr).dataList
}
// 初始化业务基本信息的申请类型和项目类别,分开赋值是因为项目类别会没有下拉数据无法回显
const baseInfoForm = {}
baseInfoForm.applicationCategory = this.model.dataList[0] ? this.model.dataList[0].applicationCategory : undefined
this.formInline = Object.assign({}, baseInfoForm)
baseInfoForm.projectType = this.model.dataList[0] ? this.model.dataList[0].projectType : undefined
this.formInline = Object.assign({}, baseInfoForm)
// 初始化人员信息
if (this.formInline.applicationCategory === ApplicationCategory.INITIATION.value) {
// 立项
this.resetPersonInfoStructure('1')
} else if (this.formInline.applicationCategory === ApplicationCategory.CHANGE.value &&
this.formInline.projectType !== ProjectType.RESPONSIBLE_DEPT_CHANGE.value) {
// 非责任部门变更
this.resetPersonInfoStructure('2')
} else if (this.formInline.applicationCategory === ApplicationCategory.CHANGE.value &&
this.formInline.projectType === ProjectType.RESPONSIBLE_DEPT_CHANGE.value) {
// 变更的责任部门变更
this.resetPersonInfoStructure('3')
}
// 对人员信息进行处理
if (this.$route.query.processInstanceId) {
if (this.currentNode === 1) {
this.initPersonInfoData(true)
} else {
// 如果不是第一个节点,人员信息全部不可选
this.initPersonInfoData(false)
}
}
// 如果是草稿节点1的保存回显人员信息
if (type === 'draft' && this.currentNode === 1) {
const personnelObj = JSON.parse(this.model.infoJsonStr).personnelObj || JSON.parse(this.model.infoJsonStr).flowUserInfoVO
this.draftInitPersonInfo(personnelObj)
}
// 初始化业务基本信息中组件内容
if (this.formInline.applicationCategory === ApplicationCategory.INITIATION.value) {
// 是立项
this.$nextTick(() => {
this.$nextTick(() => {
this.$refs.approvalBaseInfo.isEditSetData = true
const param = this.model.dataList[0]
param.enStandardSystem = param.enStandardSystem ? param.enStandardSystem.split(',').map(item => { return { value: item } }) : []
// 处理隶属工作组格式
if (param.workGroup) {
param.workGroup = { value: param.workGroup, label: param.workGroup_dictText }
}
this.$refs.approvalBaseInfo.formInline = param
setTimeout(() => {
this.$refs.approvalBaseInfo.isEditSetData = false
}, 500)
})
})
} else if (this.formInline.applicationCategory === ApplicationCategory.CHANGE.value &&
(this.formInline.projectType === ProjectType.COMPLETE_TIME_CHANGE.value ||
this.formInline.projectType === ProjectType.WORK_TERMINATE.value)) {
// 是完成时间变更或工作终止的变更
this.$nextTick(() => {
this.$refs.changeBaseInfo.dataSource = JSON.parse(JSON.stringify(this.model.dataList)).map(item => {
const uidGenerator = () => {
return '-' + parseInt(Math.random() * 10000 + 1, 10)
}
return {
uid: uidGenerator(),
...item
}
})
})
} else if (this.formInline.applicationCategory === ApplicationCategory.CHANGE.value &&
(this.formInline.projectType === ProjectType.RESPONSIBLE_DEPT_CHANGE.value ||
this.formInline.projectType === ProjectType.MERGE.value)) {
// 是责任部门变更或合并变更
this.$nextTick(() => {
this.$nextTick(() => {
const param = this.model.dataList[0]
if (param.enStandardSystem) {
param.enStandardSystem = param.enStandardSystem.split(',').map(item => { return { value: item } })
}
this.$refs.changeBaseInfo.formInline = param
})
// 回显部分节点选人
this.userFormModel = {
newMainDraftUserLeader_dictText: this.model.dataList[0].newMainDraftUserLeader_dictText,
relatedUserList_dictText: this.model.dataList[0].relatedUserList_dictText || this.model.dataList[0].newMainDraftingUser_dictText
}
this.model.dataList[0].relatedUserList = this.model.dataList[0].relatedUserList || this.model.dataList[0].newMainDraftingUser
this.userForm.setFieldsValue(pick(this.model.dataList[0], 'newMainDraftUserLeader', 'relatedUserList'))
})
}
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
setTimeout(() => {
this.isInitData = false
}, 500)
})
},
// 头部tab改变
switchChange (value) {
this.switchValue = value
},
// 申请类型改变
applicationCategoryChange (value) {
if (value) {
if (this.formInline.applicationCategory === ApplicationCategory.INITIATION.value) {
this.resetPersonInfoStructure('1')
} else {
this.resetPersonInfoStructure('2')
}
}
if (this.formInline.projectType) {
this.formInline.projectType = undefined
}
// 清空流程名称
this.processInfoForm.resetFields(['prcName'])
},
// 项目类别改变
projectTypeChange (value) {
console.log(value, this.formInline.applicationCategory)
if (value && this.formInline.applicationCategory === ApplicationCategory.CHANGE.value) {
if (value === ProjectType.RESPONSIBLE_DEPT_CHANGE.value) {
// 是责任部门变更
this.resetPersonInfoStructure('3')
} else {
// 是其他类型变更
this.resetPersonInfoStructure('2')
}
}
// 清空流程名称
this.processInfoForm.resetFields(['prcName'])
},
// 选择用户得到用户名
userSelectNameChange (value, fieldName) {
console.log(fieldName)
this.userFormModel[fieldName + '_dictText'] = value
},
// 业务基本信息组件中获取到流程名称改变后的值
processNameChange (value) {
const param = { prcName: value }
this.$nextTick(() => {
this.processInfoForm.setFieldsValue(pick(param, 'prcName'))
})
},
// 保存
handleSave () {
// 有任意一项填了即可
// 流程信息表单
const processInfoForm = this.processInfoForm.getFieldsValue()
// 业务基本信息-申请类型和项目类别
const ruleForm = this.formInline
// 流程审批信息
const approvalInfoForm = this.approvalInfoForm.getFieldsValue()
// 部分节点的选人表单
const userInfoForm = this.userForm.getFieldsValue()
// 人员信息的数据, 处理成对象
const personnelObj = this.$refs.personnelInfo.getDataObj()
// 业务基础信息组件中的数据
let arr = []
// 业务基本信息-立项表单
if (this.$refs.approvalBaseInfo) {
const approvalBaseInfo = Object.assign({}, this.$refs.approvalBaseInfo.formInline)
// 企标体系处理成逗号分隔
if (approvalBaseInfo.enStandardSystem && approvalBaseInfo.enStandardSystem.length > 0) {
approvalBaseInfo.enStandardSystem = approvalBaseInfo.enStandardSystem.map(item => item.value).join(',')
}
// 校验至少填了一项
const param = { ...processInfoForm, ...ruleForm, ...approvalBaseInfo, ...approvalInfoForm, ...personnelObj, ...userInfoForm }
const flag = Object.values(param).some(v => !!v || v === 0)
if (!flag) {
// 提示至少填写一项
this.$message.warning(this.$t('pleaseFillInAtLeastOneItem'))
return
}
arr.push({ ...ruleForm, ...approvalBaseInfo })
} else if (this.formInline.projectType === ProjectType.COMPLETE_TIME_CHANGE.value) {
// 业务基本信息-变更-完成时间变更
const param = { ...processInfoForm, ...ruleForm, ...approvalInfoForm, ...personnelObj, ...userInfoForm }
const flag = Object.values(param).some(v => !!v || v === 0)
if (!flag && this.$refs.changeBaseInfo.dataSource.length <= 0) {
// 提示至少填写一项
this.$message.warning(this.$t('pleaseFillInAtLeastOneItem'))
return
}
arr = this.$refs.changeBaseInfo.dataSource.map(item => { return { ...item, ...ruleForm } })
} else if (this.formInline.projectType === ProjectType.WORK_TERMINATE.value) {
// 业务基本信息-变更-工作终止
const param = { ...processInfoForm, ...ruleForm, ...approvalInfoForm, ...personnelObj, ...userInfoForm }
const flag = Object.values(param).some(v => !!v || v === 0)
if (!flag && this.$refs.changeBaseInfo.dataSource.length <= 0) {
// 提示至少填写一项
this.$message.warning(this.$t('pleaseFillInAtLeastOneItem'))
return
}
arr = this.$refs.changeBaseInfo.dataSource.map(item => { return { ...item, ...ruleForm } })
} else if (this.formInline.projectType === ProjectType.RESPONSIBLE_DEPT_CHANGE.value) {
// 业务基本信息-变更-责任部门变更
const dutyDepartChangeForm = this.$refs.changeBaseInfo.formInline
const param = { ...processInfoForm, ...ruleForm, ...dutyDepartChangeForm, ...approvalInfoForm, ...personnelObj, ...userInfoForm }
const flag = Object.values(param).some(v => !!v || v === 0)
if (!flag) {
// 提示至少填写一项
this.$message.warning(this.$t('pleaseFillInAtLeastOneItem'))
return
}
arr.push({ ...ruleForm, ...dutyDepartChangeForm, ...userInfoForm })
} else if (this.formInline.projectType === ProjectType.MERGE.value) {
// 业务基本信息-变更-合并
const mergeForm = this.$refs.changeBaseInfo.formInline
const param = { ...processInfoForm, ...ruleForm, ...mergeForm, ...approvalInfoForm, ...personnelObj, ...userInfoForm }
const flag = Object.values(param).some(v => !!v || v === 0)
if (!flag) {
// 提示至少填写一项
this.$message.warning(this.$t('pleaseFillInAtLeastOneItem'))
return
}
arr.push({ ...ruleForm, ...mergeForm })
} else {
// 还没有选择申请类型和项目类别,需要外层信息至少填了一项
const param = { ...processInfoForm, ...ruleForm, ...approvalInfoForm, ...personnelObj, ...userInfoForm }
const flag = Object.values(param).some(v => !!v || v === 0)
if (!flag) {
// 提示至少填写一项
this.$message.warning(this.$t('pleaseFillInAtLeastOneItem'))
return
}
}
this.loading = true
const paramObj = {} // 传给后端的参数
// 流程信息
paramObj.basicProcessInfoDTO = Object.assign({}, processInfoForm)
paramObj.basicProcessInfoDTO.processName = paramObj.basicProcessInfoDTO.prcName
paramObj.basicProcessInfoDTO.processDueDate = paramObj.basicProcessInfoDTO.dueTime
paramObj.basicProcessInfoDTO.processDescription = paramObj.basicProcessInfoDTO.prcMes
paramObj.basicProcessInfoDTO.processInstanceId = this.$route.query.processInstanceId
// 流程审批信息
paramObj.basicTaskInfoDTO = Object.assign({}, approvalInfoForm)
paramObj.basicTaskInfoDTO.handleText = paramObj.basicTaskInfoDTO.commitText
paramObj.basicTaskInfoDTO.handleFile = paramObj.basicTaskInfoDTO.commitFile
paramObj.basicTaskInfoDTO.taskId = this.$route.query.taskId
// 草稿id
if (this.model.infoJsonStr) {
paramObj.draftId = this.model.id
}
// 业务基本信息和人员信息
console.log(this.userFormModel)
paramObj.infoJsonStr = JSON.stringify({
arr: arr.map(item => {
return { ...item, ...this.userFormModel }
}),
personnelObj: personnelObj
})
// param.common = { ...processInfoForm, ...approvalInfoForm } // 流程信息和流程审批信息
// param.common.taskId = this.$route.query.taskId || null
// param.common.processInstanceId = this.model.common ? this.model.common.processInstanceId : null
// param.dataList = arr // 业务基础信息数组
// param.flowUser = personnelObj // 人员信息
// 保存到草稿
enterprisePlanApprovalSave(paramObj).then(res => {
if (res.success) {
this.$message.success(res.message)
this.goBack()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
},
// 节点一时候的提交,发起立项变更申请,有taskId就是驳回后的提交
handleStart () {
if (this.loading) return
console.log(this.formInline)
this.processInfoForm.validateFields((err, values) => {
this.$refs.ruleForm.validate(valid => {
this.approvalInfoForm.validateFields((approvalErr, approvalValues) => {
let arr = [] // 业务基本信息部分的数据封装
let haveErr = true // 是否有错误,有错,则不能提交,false没有错
// 立项和变更的数据不一样,分开判断
if (this.formInline.applicationCategory === ApplicationCategory.INITIATION.value) {
// 是立项
this.$refs.approvalBaseInfo.$refs.ruleForm.validate(approvalBaseValid => {
if (valid && approvalBaseValid && !err && !approvalErr) {
const param = Object.assign({}, this.formInline, this.$refs.approvalBaseInfo.formInline)
// 企标体系处理成逗号分隔
param.enStandardSystem = param.enStandardSystem.map(item => item.value).join(',')
arr.push(param)
haveErr = false
} else {
haveErr = true
}
})
} else if (this.formInline.projectType === ProjectType.COMPLETE_TIME_CHANGE.value ||
this.formInline.projectType === ProjectType.WORK_TERMINATE.value) {
// 是变更-完成时间 或者 变更-工作终止变更
if (valid && !err && !approvalErr && this.$refs.changeBaseInfo && this.$refs.changeBaseInfo.dataSource.length > 0) {
arr = this.$refs.changeBaseInfo.dataSource.map(item => { return { ...item, ...this.formInline } })
haveErr = false
} else if (valid && !err && !approvalErr && this.$refs.changeBaseInfo) {
haveErr = true
} else {
haveErr = true
if (this.$refs.changeBaseInfo.dataSource.length <= 0) {
this.$message.warning(this.$t('addAtLeastOneRowOfData'))
}
}
} else if (this.formInline.projectType === ProjectType.RESPONSIBLE_DEPT_CHANGE.value) {
// 是变更-责任部门变更
this.$refs.changeBaseInfo.$refs.ruleForm.validate(changeBaseValid => {
if (valid && changeBaseValid && !err && !approvalErr) {
const param = Object.assign({}, this.formInline, this.$refs.changeBaseInfo.formInline)
arr.push(param)
haveErr = false
} else {
haveErr = true
}
})
} else if (this.formInline.projectType === ProjectType.MERGE.value) {
// 是变更-合并
this.$refs.changeBaseInfo.$refs.ruleForm.validate(changeBaseValid => {
if (valid && changeBaseValid && !err && !approvalErr) {
const changeBaseInfo = this.$refs.changeBaseInfo.formInline
if (changeBaseInfo.projectTypeOne !== changeBaseInfo.projectTypeTwo) {
// 合并时候的两个计划需要限定修订+修订,或者制定+制定
this.$message.warning(this.$t('workCenter.enterpriseInitChangePlan.pleaseSelectTwoSameProjectTypePlan'))
return
}
const param = Object.assign({}, this.formInline, this.$refs.changeBaseInfo.formInline)
// 企标体系处理成逗号分隔
param.enStandardSystem = param.enStandardSystem.map(item => item.value).join(',')
arr.push(param)
haveErr = false
} else {
haveErr = true
}
})
}
if (haveErr) {
this.switchValue = 'base'
return
}
// 人员信息的数据, 处理成对象
const personnelObj = this.$refs.personnelInfo.getDataObjVerify()
// 校验是否填了所有能填的人员信息
if (!personnelObj) {
this.switchValue = 'user'
return
}
this.loading = true
const param = {} // 需要传给后端的数据
param.common = { ...values, ...approvalValues } // 流程信息和流程审批信息
param.dataList = arr
param.flowUser = personnelObj
let func
if (this.$route.query.taskId) {
// 有taskId说明是驳回的提交
func = enterprisePlanApprovalAgree
param.common.taskId = this.$route.query.taskId
} else {
func = enterprisePlanApproval
}
func(param).then(async res => {
if (res.success) {
this.$message.success(res.message)
this.goBack()
} else {
this.$message.warning(res.message)
if (res.message === this.$t('workCenter.enterpriseInitChangePlan.existingNumber')) {
// 已经存在编号,重新生成
if ([ProjectType.ENACT.value, ProjectType.MODIFY.value, ProjectType.MERGE.value].includes(this.formInline.projectType)) {
// 是制定修订或者合并,重新获取企标编号
this.loading = true
await this.$refs.approvalBaseInfo.getEnStandardNo()
setTimeout(() => {
this.loading = false
// 提示顺序号已重新生成
this.$message.success(this.$t('workCenter.enterpriseInitChangePlan.numberReset'))
}, 500)
}
}
}
}).finally(() => {
this.loading = false
})
})
})
})
},
// 其他节点的提交,校验部分节点需要选人的表单和审批信息即可
handleSubmit () {
if (this.loading) return
this.userForm.validateFields((err, values) => {
this.approvalInfoForm.validateFields((approvalErr, approvalValues) => {
if (!err && !approvalErr) {
this.loading = true
const param = {}
param.common = Object.assign({}, approvalValues)
param.common.taskId = this.$route.query.taskId
param.flowUser = Object.assign({}, values)
enterprisePlanApprovalAgree(param).then(res => {
if (res.success) {
this.$message.success(res.message)
this.goBack()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
}
})
})
},
// 转办
handleTurnTo () {
if (this.loading) return
// 点击显示选人组件
this.$refs.userSelectModal.open()
},
// 转办选完人的回调
userSelectModalChange (userIds) {
this.approvalInfoForm.validateFields((err, values) => {
if (!err) {
this.loading = true
const param = Object.assign({}, values)
param.userId = userIds
param.taskId = this.$route.query.taskId
enterprisePlanApprovalTurnTo(param).then(res => {
if (res.success) {
this.$message.success(res.message)
this.goBack()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
}
})
},
// 同意
handleAgree () {
if (this.loading) return
this.validatorRules.commitText.rules[0].required = false
if (!this.approvalInfoForm.getFieldValue('commitText')) {
this.approvalInfoForm.setFieldsValue({ commitText: '同意' })
}
const param = {} // 需要传给后端的数据
this.approvalInfoForm.validateFields((err, values) => {
if (this.formInline.projectType === this.ProjectType.RESPONSIBLE_DEPT_CHANGE.value && this.currentNode === 6) {
// 责任部门变更,节点6需要校验业务基本信息的必填,新起草单位负责人就是新起草部门主管级上一级领导
this.$refs.changeBaseInfo.$refs.ruleForm.validate(valid => {
if (!err && valid) {
// 校验完成
param.common = Object.assign({}, values)
param.common.taskId = this.$route.query.taskId
param.dataList = [this.$refs.changeBaseInfo.formInline]
param.flowUser = { newMainDraftUserLeaderLeader: this.$refs.changeBaseInfo.formInline.newMainDraftingUnitResponsiblePerson }
}
})
} else {
if (!err) {
param.common = Object.assign({}, values)
param.common.taskId = this.$route.query.taskId
}
}
this.loading = true
enterprisePlanApprovalAgree(param).then(res => {
if (res.success) {
this.$message.success(res.message)
this.goBack()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
})
},
// 驳回
handleReject () {
if (this.loading) return
this.validatorRules.commitText.rules[0].required = true
if (!this.approvalInfoForm.getFieldValue('commitText')) {
this.$message.warning(this.$t('pleaseEnterRemarks'))
this.switchValue = 'base'
}
this.$nextTick(() => {
this.approvalInfoForm.validateFields((err, values) => {
if (!err) {
this.loading = true
const param = {}
param.common = Object.assign({}, values)
param.common.taskId = this.$route.query.taskId
enterprisePlanApprovalReject(param).then(res => {
if (res.success) {
this.$message.success(res.message)
this.goBack()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
this.validatorRules.commitText.rules[0].required = false
})
}
})
})
},
// 确定
handleDetermine () {
if (this.loading) return
this.approvalInfoForm.validateFields((err, values) => {
if (!err) {
this.loading = true
const param = {}
param.common = Object.assign({}, values)
param.common.taskId = this.$route.query.taskId
enterprisePlanApprovalAgree(param).then(res => {
if (res.success) {
this.$message.success(res.message)
this.goBack()
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
}
})
}
}
}
</script>
<style scoped lang="less">
@import '~@assets/less/common.less';
/deep/ .ant-form-item-children {
width: 100%;
display: inline-block;
}
.form-flex-item {
width: calc(100% / 3);
}
.bottom-operate-box {
height: 52px;
padding: 10px 32px;
text-align: right;
.ant-btn {
margin-left: 15px;
}
}
.user-form {
margin-top: 24px;
/deep/ .ant-form-item {
margin-bottom: 0;
}
}
</style>