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

1023 lines
46 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')">
<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')">
<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')">
<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" class="form-add" :rules="rules" ref="ruleForm">
<div class="collapsible-panel-form">
<div class="form-flex-box collapsible-panel-form-content collapsible-content-no-head">
<!-- 申请类型 -->
<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"
@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"
: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"
@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>
</div>
</a-form-model>
<!-- 申请类型为立项时的业务基本信息部分组件 -->
<approval-base-info
v-if="formInline.applicationCategory === ApplicationCategory.INITIATION.value"
ref="approvalBaseInfo"
:disabled="disabled"
:currentNode="currentNode"
@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"
@processNameChange="processNameChange"
:projectType="formInline.projectType"
>
</merge-base-info>
<!-- 部分节点需要选人 -->
<a-form v-if="formInline.applicationCategory === ApplicationCategory.CHANGE.value && [6, 7].includes(currentNode)" class="user-form" :form="userForm">
<a-row :gutter="24">
<!-- 所长,节点6需要选所长 -->
<a-col :span="12" v-if="currentNode === 6">
<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]"
input-type="textarea" />
</a-form-item>
</a-col>
<!-- 相关人员,节点7需要选相关人员 -->
<a-col :span="12" v-if="currentNode === 7">
<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="['relatedUser', validatorRules.relatedUser]"
input-type="textarea" />
</a-form-item>
</a-col>
</a-row>
</a-form>
<!-- 流程审批信息 -->
<div class="process-part-title" v-if="!onlyLook">{{ $t('processApprovalInformation') }}</div>
<a-form :form="approvalInfoForm" v-if="!onlyLook">
<!--备注-->
<a-form-item :labelCol="longLabelCol" :wrapperCol="longWrapperCol" :label="$t('remarks')">
<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('businessSupport.questionAnswer.attach')">
<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>
<personnel-info slot="personnelInfo" ref="personnelInfo" :data="personnelInfoData" :currentNode="currentNodeName"></personnel-info>
</process-detail-list>
</div>
<!-- 操作按钮 -->
<div class="detail-page-bottom-operate-box" v-if="!onlyLook">
<!-- 发起节点 -->
<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 && [6, 7].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 === 9">
<!-- 确定, 谁发起的谁点确定抄送消息 -->
<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
} 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 } 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
}
}
// 项目类别下拉框数据
// projectTypeOptions () {
// if (this.formInline.applicationCategory === ApplicationCategory.INITIATION.value) {
// return [
// { value: ProjectType.ENACT.value, label: this.$t('workCenter.enterpriseInitChangePlan.formulate') },
// { value: ProjectType.MODIFY.value, label: this.$t('workCenter.enterpriseInitChangePlan.revise') }
// ]
// } else if (this.formInline.applicationCategory === ApplicationCategory.CHANGE.value) {
// return [
// { value: ProjectType.COMPLETE_TIME_CHANGE.value, label: this.$t('workCenter.enterpriseInitChangePlan.completionTimeChange') },
// { value: ProjectType.WORK_TERMINATE.value, label: this.$t('workCenter.enterpriseInitChangePlan.terminationOfWork') },
// { value: ProjectType.RESPONSIBLE_DEPT_CHANGE.value, label: this.$t('workCenter.enterpriseInitChangePlan.dutyDepartChange') },
// { value: ProjectType.MERGE.value, label: this.$t('workCenter.enterpriseInitChangePlan.merge') },
// ]
// } else {
// return []
// }
// }
},
mounted () {
// 查询流程定义列表,通过查出的数据获取到流程定义id,如果已经发起过流程,用这个id和流程实例id去查人员信息数据
this.getPersonInfoStructure(ProcessKey.ES_INIT_CHANGE.value)
if (this.$route.query.taskId) {
this.currentNodeName = this.$route.query.taskName
// 有流程id说明是从流程中心来的,需要初始化数据
this.getProcessData(this.$route.query.taskId)
} else {
this.currentNodeName = '主起草人发起'
}
// 如果是查看进入的,不可编辑,不可操作
if (this.$route.query.onlyLook) {
this.onlyLook = this.$route.query.onlyLook
this.disabled = this.$route.query.onlyLook
}
},
data () {
return {
ProjectType,
ApplicationCategory,
loading: false,
switchValue: 'base', // 头部tab选中值
disabled: false,
onlyLook: false, // 是否仅查看
currentNode: 1, // 当前节点
currentNodeName: '', // 当前节点名称
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'
},
// 相关人员
relatedUser: {
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', 'blur']
}
],
// 项目类别
projectType: [
{
required: true,
message: this.$t('workCenter.enterpriseInitChangePlan.itemCategory') + this.$t('cannotEmpty'),
trigger: 'change'
}
]
},
userForm: this.$form.createForm(this), // 部分节点需要选人的表单
approvalInfoForm: this.$form.createForm(this), // 审批信息表单
personnelInfoDataAll: [], // 整体人员信息
personnelInfoData: [], // 传给人员信息组件的人员信息
url: {
list: '' // 人员信息的右侧表格获取接口
}
}
},
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) {
// 说明是在新发起一个节点,初始化发起人员信息
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'))
}
}
})
},
/**
* 切换立项、变更、责任部门变更修改人员信息结构数据
* @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
}
}
},
// 根据流程id获取数据并回显
getProcessData (taskId) {
this.loading = true
getProcessDataById(taskId).then(res => {
if (res.success) {
this.model = res.result
this.$nextTick(() => {
// 初始化流程信息
this.processInfoForm.setFieldsValue(pick(this.model.common, 'prcName', 'dueTime', 'prcMes'))
// 初始化流程审批信息,todo:需要判断是不是草稿进来的,草稿进来的才回显审批信息
// this.approvalInfoForm.setFieldsValue(pick(this.model[0], 'commitText', 'commitFile'))
})
// 初始化业务基本信息的申请类型和项目类别,分开赋值是因为项目类别会没有下拉数据无法回显
const baseInfoForm = {}
baseInfoForm.applicationCategory = this.model.dataList[0].applicationCategory
this.formInline = Object.assign({}, baseInfoForm)
baseInfoForm.projectType = this.model.dataList[0].projectType
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')
}
// 初始化流程节点,此流程因为节点名称有重复,需要在此处根据applicationCatsegory做一些判断
const taskName = this.$route.query.taskName
if (taskName) {
if (taskName === '主起草人发起') {
this.currentNode = 1
} else if (taskName === '部所联络人校对') {
this.currentNode = 2
} else if (taskName === '专家审批' || taskName === '主起草人主管级领导审批') {
this.currentNode = 3
} else if (taskName === '发起人主管级领导审批' || taskName === '主起草人主管级上级领导审批') {
this.currentNode = 4
} else if (taskName === '发起人主管级上级领导审批' || (taskName === '标准化审批' && this.formInline.applicationCategory === this.ApplicationCategory.CHANGE.value)) {
this.currentNode = 5
} else if ((taskName === '标准化审批' && this.formInline.applicationCategory === this.ApplicationCategory.INITIATION.value) || taskName === '新起草部门主管级上一级领导下发主管级领导') {
this.currentNode = 6
} else if (taskName === '新起草部门主管级领导确认新起草人') {
this.currentNode = 7
} else if (taskName === '相关人员会签') {
this.currentNode = 8
} else if (taskName === '抄送主起草人确认') {
this.currentNode = 9
} else {
// 预留加签节点
this.currentNode = 999
}
}
if (this.currentNode === 1) {
this.initPersonInfoData(true)
} else {
// 不是第一个节点需要处理人员信息都不可选
this.initPersonInfoData(false)
}
console.log(this.currentNode)
// 根据流程节点初始化是否可以编辑
if (this.currentNode === 1) {
this.disabled = false
} else {
this.disabled = true
}
// 初始化业务基本信息中组件内容
if (this.formInline.applicationCategory === ApplicationCategory.INITIATION.value) {
// 是立项
this.$nextTick(() => {
this.$nextTick(() => {
const param = this.model.dataList[0]
param.enStandardSystem = param.enStandardSystem.split(',').map(item => { return { value: item } })
this.$refs.approvalBaseInfo.formInline = param
})
})
} 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))
})
} 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
})
})
}
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
},
// 头部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
}
},
// 项目类别改变
projectTypeChange (value) {
console.log(value, this.formInline.applicationCategory)
if (value) {
if (value === ProjectType.RESPONSIBLE_DEPT_CHANGE.value) {
// 是责任部门变更
this.resetPersonInfoStructure('3')
} else {
// 是其他类型变更
this.resetPersonInfoStructure('2')
}
}
},
// 业务基本信息组件中获取到流程名称改变后的值
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 = 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 })
} 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 param = {} // 传给后端的参数
param.common = { ...processInfoForm, ...approvalInfoForm } // 流程信息和流程审批信息
param.dataList = arr // 业务基础信息数组
param.flowUser = personnelObj // 人员信息
// 保存到草稿
enterprisePlanApprovalSave(param).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
// 人员信息的数据, 处理成对象
const personnelObj = this.$refs.personnelInfo.getDataObjVerify()
// 校验是否填了所有能填的人员信息
if (!personnelObj) {
return
}
// 专家审批至少需要选两个专家 todo: 后端选多人流程进行不下去,暂时不限制传多人
// if (personnelObj.standardExpert.split(',').length < 2) {
// this.$message.warning(this.$t('workCenter.enterpriseInitChangePlan.pleaseSelectLeastTwoExpert'))
// 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) {
this.loading = true
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) {
this.loading = true
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) {
this.loading = true
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) {
this.loading = true
const changeBaseInfo = this.$refs.changeBaseInfo.formInline
if (changeBaseInfo.projectTypeOne !== changeBaseInfo.projectTypeTwo) {
// 合并时候的两个计划需要限定修订+修订,或者制定+制定
this.$message.warning(this.$t('workCenter.enterpriseInitChangePlan.pleaseSelectTwoSameProjectTypePlan'))
return
}
this.loading = true
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
}
})
} else {
// 校验特定节点需要填写人的必填
// this.userForm.validateFields((userErr, userValues) => {
// if (valid && !err && !approvalErr && !userErr) {
// this.loading = true
// const param = this.$refs.changeBaseInfo.dataSource
// console.log(param)
// }
// })
}
if (haveErr) {
return
}
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(res => {
if (res.success) {
this.$message.success(res.message)
this.goBack()
} else {
this.$message.warning(res.message)
}
}).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
const param = {} // 需要传给后端的数据
this.approvalInfoForm.validateFields((err, values) => {
if (this.formInline.projectType === this.ProjectType.RESPONSIBLE_DEPT_CHANGE.value && this.currentNode === 5) {
// 责任部门变更,节点5需要校验业务基本信息的必填,新起草单位负责人就是新起草部门主管级上一级领导
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'))
return
}
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;
}
.collapsible-content-no-head {
border-top: 1px solid #E5E6EB;
border-radius: 8px 8px 8px 8px;
}
.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>