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

1094 lines
46 KiB
Vue

<template>
<internal-detail-page :title="pageTitle" :content-padding="0">
<!-- 标题右侧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"
: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"
: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">
<a-col :span="12">
<!-- 所长,节点6需要选所长 -->
<a-form-item v-if="currentNode === 6" :labelCol="labelCol" :wrapperCol="wrapperCol" :label="$t('workCenter.enterpriseInitChangePlan.superintendent')">
<user-selection :placeholder="$t('pleaseSelect') + $t('workCenter.enterpriseInitChangePlan.superintendent')"
type="radio"
v-decorator="['newMainDraftUserLeaderLeader', validatorRules.newMainDraftUserLeaderLeader]"
input-type="textarea" />
</a-form-item>
</a-col>
<a-col :span="12">
<!-- 相关人员,节点7需要选相关人员 -->
<a-form-item v-if="currentNode === 7" :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 :url="url">
<personnel-info slot="personnelInfo" ref="personnelInfo" :data="personnelInfoData" :currentNode="currentNode + ''"></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,
enterprisePlanApprovalDetermine,
enterprisePlanApprovalSave,
enterprisePlanApproval,
getProcessDataById
} 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 } from '@/enums/commonEnums'
import Vue from 'vue'
import { USER_INFO } from '@/store/mutation-types'
import pick from 'lodash.pick'
// 标准立项的人员信息
const approvalPersonalInfo = [ // 人员信息的数据
{
id: 1,
nodeName: '主起草人发起',
nodeRoleName: '发起人',
canChoose: false,
userList: Vue.ls.get(USER_INFO).realname + '(' + Vue.ls.get(USER_INFO).username + ')',
fieldName: 'createUser'
},
{
id: 2,
nodeName: '部所联络人校对',
nodeRoleName: '部所联络人',
canChoose: true,
chooseType: 'radio',
chooseSource: 'contactManage',
fieldName: 'contactUser'
},
{
id: 3,
nodeName: '专家审批',
nodeRoleName: '专家',
canChoose: true,
chooseType: 'checkbox',
chooseSource: 'workGroup',
fieldName: 'standardExpert'
},
{
id: 4,
nodeName: '发起人主管级领导审批',
nodeRoleName: '发起人主管级领导',
canChoose: true,
chooseType: 'radio',
fieldName: 'mainDraftUserLeader'
},
{
id: 5,
nodeName: '发起人主管级上级领导审批',
nodeRoleName: '发起人主管级上级领导',
canChoose: true,
chooseType: 'radio',
fieldName: 'mainDraftUserLeaderLeader'
},
{
id: 6,
nodeName: '标准化审批',
nodeRoleName: '标准化',
canChoose: true,
chooseType: 'radio',
fieldName: 'standardizationApprovalUser'
}
]
// 变更的人员信息
const changePersonalInfo = [
{
id: 1,
nodeName: '主起草人发起',
nodeRoleName: '发起人',
userList: Vue.ls.get(USER_INFO).realname + '(' + Vue.ls.get(USER_INFO).username + ')',
fieldName: 'createUser',
canChoose: false
},
{
id: 2,
nodeName: '部所联络人校对',
nodeRoleName: '部所联络人',
canChoose: true,
chooseType: 'radio',
chooseSource: 'contactManage',
fieldName: 'contactUser'
},
{
id: 3,
nodeName: '主起草人主管级领导审批',
nodeRoleName: '主起草人主管级领导',
canChoose: true,
chooseType: 'radio',
fieldName: 'mainDraftUserLeader'
},
{
id: 4,
nodeName: '主起草人主管级上一级领导审批',
nodeRoleName: '主起草人主管级上一级领导',
canChoose: true,
chooseType: 'radio',
fieldName: 'mainDraftUserLeaderLeader'
},
{
id: 5,
nodeName: '标准化审批',
nodeRoleName: '标准化',
canChoose: true,
chooseType: 'radio',
fieldName: 'standardizationApprovalUser'
},
{
id: 6,
nodeName: '新起草部门主管级上一级领导下发',
nodeRoleName: '新起草部门主管级上一级领导',
canChoose: false,
chooseType: 'radio'
},
{
id: 7,
nodeName: '新起草部门主管级领导确认',
nodeRoleName: '新起草部门主管级领导',
canChoose: false,
chooseType: 'radio'
},
{
id: 8,
nodeName: '相关人员会签',
nodeRoleName: '相关人员',
canChoose: false,
chooseType: 'checkbox'
},
{
id: 9,
nodeName: '抄送主起草人',
nodeRoleName: '主起草人',
canChoose: false,
chooseType: 'checkbox'
}
]
export default {
name: 'PlanApprovalFlow',
components: {
MergeBaseInfo,
DutyDepartChangeBaseInfo,
JobEndBaseInfo,
ProcessDetailList,
FinishTimeChangeBaseInfo,
ApprovalBaseInfo,
UserSelectModal,
PersonnelInfo,
InternalDetailPage,
UserSelection
},
computed: {
pageTitle () {
return this.$t('flowCenter') + this.$route.meta.title
},
// 流程名称是否不可填写
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 () {
console.log(this.$route.query.taskId)
if (this.$route.query.taskId) {
// 有流程id说明是从流程中心来的,需要初始化数据
this.getProcessData(this.$route.query.taskId)
} else {
// 没有taskId说明是新建进来的,初始化人员信息
this.personnelInfoData = approvalPersonalInfo
}
// 如果是查看进入的,不可编辑,不可操作
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, // 当前节点
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'
},
// 相关人员
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), // 审批信息表单
personnelInfoData: [],
url: {
list: '' // 人员信息的右侧表格获取接口
}
}
},
methods: {
// 根据流程id获取数据并回显
getProcessData (taskId) {
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'))
})
// 初始化流程节点,此流程因为节点名称有重复,需要在此处根据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 {
this.currentNode = 9
}
}
// 根据流程节点初始化是否可以编辑
if (this.currentNode === 1) {
this.disabled = false
} else {
this.disabled = true
}
// 初始化业务基本信息的申请类型和项目类别,分开赋值是因为项目类别会没有下拉数据无法回显
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.currentNode === 1) {
// 立项的节点1
this.personnelInfoData = approvalPersonalInfo.map(item => {
if (item.fieldName) {
return {
...item,
user: this.model.flowUser[item.fieldName],
user_dictText: this.model.flowUser[item.fieldName + '_dictText']
}
} else {
return item
}
})
} else if (this.formInline.applicationCategory === ApplicationCategory.INITIATION.value) {
// 立项的其他节点
this.personnelInfoData = approvalPersonalInfo.map(item => {
if (item.fieldName) {
return {
...item,
user: this.model.flowUser[item.fieldName],
userList: this.model.flowUser[item.fieldName + '_dictText'],
canChoose: false
}
} else {
return item
}
})
} else if (this.formInline.applicationCategory === ApplicationCategory.CHANGE.value && this.currentNode === 1) {
// 变更的节点1
this.personnelInfoData = changePersonalInfo.map(item => {
if (item.fieldName) {
return {
...item,
user: this.model.flowUser[item.fieldName],
user_dictText: this.model.flowUser[item.fieldName + '_dictText']
}
} else {
return item
}
})
} else {
// 变更的其他节点
this.personnelInfoData = changePersonalInfo.map(item => {
if (item.fieldName) {
return { ...item, user: this.model.flowUser[item.fieldName], userList: this.model.flowUser[item.fieldName + '_dictText'], canChoose: false }
} else {
return item
}
})
}
// 初始化业务基本信息中组件内容
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)
}
})
},
// 头部tab改变
switchChange (value) {
this.switchValue = value
},
// 申请类型改变
applicationCategoryChange (value) {
if (value) {
if (this.formInline.applicationCategory === ApplicationCategory.INITIATION.value) {
this.personnelInfoData = approvalPersonalInfo
} else {
this.personnelInfoData = changePersonalInfo
}
}
if (this.formInline.projectType) {
this.formInline.projectType = undefined
}
},
// 业务基本信息组件中获取到流程名称改变后的值
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 personnelInfo = this.$refs.personnelInfo.stepsData
const personnelObj = {}
for (const item of personnelInfo) {
if (item.fieldName) {
personnelObj[item.fieldName] = item.user
}
}
// 发起人设置为当前登录人
personnelObj.createUser = Vue.ls.get(USER_INFO).id
// 业务基础信息组件中的数据
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)
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
},
// 节点一时候的提交,发起立项变更申请,有taskId就是驳回后的提交
handleStart () {
if (this.loading) return
// 人员信息的数据, 处理成对象
const personnelInfo = this.$refs.personnelInfo.stepsData
const personnelObj = {}
for (const item of personnelInfo) {
if (item.fieldName) {
personnelObj[item.fieldName] = item.user
}
}
// 发起人设置为当前登录人
personnelObj.createUser = Vue.ls.get(USER_INFO).id
// 后端需要单独传主起草人
personnelObj.mainDraftUser = Vue.ls.get(USER_INFO).id
// 校验是否填了所有能填的人员信息
if (!Object.values(personnelObj).every(v => !!v)) {
this.$message.warning(this.$t('pleaseEnterPersonnelInfo'))
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)
} 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 = Object.assign({}, values, approvalValues)
param.taskId = this.$route.query.taskId
enterprisePlanApprovalAgree(param).then(res => {
if (res.success) {
this.$message.success(res.message)
} 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)
} else {
this.$message.warning(res.message)
}
}).finally(() => {
this.loading = false
})
}
})
},
// 同意
handleAgree () {
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)
} 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)
} 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 = Object.assign({}, values)
param.taskId = this.$route.query.taskId
enterprisePlanApprovalDetermine(param).then(res => {
if (res.success) {
this.$message.success(res.message)
} 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>