728 lines
26 KiB
Vue
728 lines
26 KiB
Vue
<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 class="detail-page-scroll-content" v-show="switchValue === 'base'">
|
||
<!-- 流程信息 -->
|
||
<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')"
|
||
:maxLength="50"
|
||
:disabled="disabled || processDisabled"
|
||
v-decorator="['prcName', validatorRules.processName]" />
|
||
</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 || processDisabled"
|
||
value-format="YYYY-MM-DD hh:mm:ss"
|
||
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 || processDisabled"
|
||
v-decorator="['prcMes']" />
|
||
</a-form-item>
|
||
</a-col>
|
||
</a-row>
|
||
</a-form>
|
||
|
||
<!-- 业务基本信息 -->
|
||
<div class="process-part-title">{{ $t('basicServiceInformation') }}</div>
|
||
|
||
<!-- 标准表格 -->
|
||
<base-info-table v-if="isInitiate" ref="baseInfoTable" :info="info" style="margin-bottom: 40px;"></base-info-table>
|
||
<!-- 表单 -->
|
||
<a-form :form="baseInfoForm">
|
||
<a-row>
|
||
<template v-if="!isInitiate">
|
||
<a-col :span="12">
|
||
<!-- 申请人 -->
|
||
<a-form-item :labelCol="labelColBaseInfo" :wrapperCol="wrapperColBaseInfo" :label="$t('workCenter.permissionApplicationProcess.applicant')">
|
||
<a-input :placeholder="$t('pleaseEnter') + $t('workCenter.permissionApplicationProcess.applicant')"
|
||
:maxLength="50"
|
||
:disabled="disabled"
|
||
v-decorator="['userDictText', validatorRules.applicant]" />
|
||
</a-form-item>
|
||
</a-col>
|
||
<a-col :span="24"></a-col>
|
||
<a-col :span="24">
|
||
<!-- 申请权限 -->
|
||
<a-form-item :labelCol="longLabelColBaseInfo" :wrapperCol="longWrapperColBaseInfo" :label="$t('workCenter.permissionApplicationProcess.applyForPermission')">
|
||
<base-info-table v-if="!isInitiate" :disabled="!isInitiate" ref="applyPermissionTable"></base-info-table>
|
||
</a-form-item>
|
||
</a-col>
|
||
|
||
<a-col :span="24"></a-col>
|
||
</template>
|
||
<a-col :span="12">
|
||
<!-- 授权到期日期 -->
|
||
<a-form-item :labelCol="labelColBaseInfo" :wrapperCol="wrapperColBaseInfo" :label="$t('workCenter.permissionApplicationProcess.authExpirationDate')">
|
||
<j-date date-format="YYYY-MM-DD" style="width: 100%" showType="day" :disabled="disabled"
|
||
:placeholder="$t('pleaseSelect') + $t('workCenter.permissionApplicationProcess.authExpirationDate')"
|
||
v-decorator="['expirationDate', validatorRules.authExpirationDate]" />
|
||
</a-form-item>
|
||
</a-col>
|
||
<a-col :span="24">
|
||
<!-- 申请说明 -->
|
||
<a-form-item :labelCol="longLabelColBaseInfo" :wrapperCol="longWrapperColBaseInfo" :label="$t('workCenter.permissionApplicationProcess.applicationDescription')">
|
||
<a-textarea :placeholder="$t('pleaseSelect') + $t('workCenter.permissionApplicationProcess.applicationDescription')"
|
||
:maxLength="500"
|
||
:rows="4"
|
||
:disabled="disabled"
|
||
v-decorator="['applyDetail', validatorRules.applicationDescription]" />
|
||
</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')">
|
||
<a-textarea :placeholder="$t('pleaseEnter') + $t('remarks')"
|
||
:maxLength="500"
|
||
:rows="4"
|
||
v-decorator="['commitText', validatorRules.remarks]" />
|
||
</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 :process-key="processKey">
|
||
<template #personnelInfo>
|
||
<personnel-info ref="personnelInfo" :data="personnelInfoData" :current-node="currentNode" />
|
||
</template>
|
||
</process-detail-list>
|
||
</div>
|
||
|
||
<div class="detail-page-bottom-operate-box">
|
||
<!--转办-->
|
||
<a-button v-if="btn.includes('transfer')" type="primary" :loading="loading" @click="handleTurnTo" ghost icon="arrow-up">{{ $t('turnTo') }}</a-button>
|
||
<!--保存-->
|
||
<a-button v-if="btn.includes('save')" type="primary" :loading="loading" @click="handleSave" ghost><i class="iconfont icon-save" />{{ $t('preservation') }}</a-button>
|
||
<!--提交-->
|
||
<a-button v-if="btn.includes('submit')" type="primary" :loading="loading" @click="handleSubmit" icon="upload">{{ $t('submit') }}</a-button>
|
||
<!--同意-->
|
||
<a-button v-if="btn.includes('agree')" type="primary" :loading="loading" @click="handleAgree" icon="check-circle">{{ $t('agree') }}</a-button>
|
||
<!--驳回-->
|
||
<a-button v-if="btn.includes('reject')" type="primary" :loading="loading" @click="handleReject" icon="close-circle">{{ $t('reject') }}</a-button>
|
||
</div>
|
||
<!--转办选人-->
|
||
<user-select-modal ref="userSelectModal" check-required @change="continueTurnTo" />
|
||
</internal-detail-page>
|
||
</template>
|
||
|
||
<script>
|
||
import '@assets/less/common.less'
|
||
import InternalDetailPage from '@comp/InternalDetailPage'
|
||
import ProcessDetailList from '@comp/ProcessDetailList'
|
||
import PersonnelInfo from '@comp/PersonnelInfo'
|
||
import BaseInfoTable from '@views/workCenter/permissionApplicationProcess/modules/BaseInfoTable'
|
||
import UserSelectModal from '@comp/selection/UserSelectModal'
|
||
import { WorkCenterMixin } from '@/mixins/WorkCenterMixin'
|
||
import { ApprovalOpinions, PermissionApply, ProcessKey } from '@/enums/commonEnums'
|
||
import {
|
||
approvalPermissionApply, checkPermissionApply, getPermissionApplyDataById,
|
||
getPermissionApplyDetail,
|
||
getPermissionApplyProjectId, rejectPermissionApply,
|
||
savePermissionApply, startPermissionApply,
|
||
transferPermissionApply
|
||
} from '@api/workCenter'
|
||
import { cloneDeep } from 'lodash'
|
||
|
||
const tabList = ['base', 'user']
|
||
export default {
|
||
name: 'PermissionApplicationProcess',
|
||
components: { UserSelectModal, BaseInfoTable, PersonnelInfo, ProcessDetailList, InternalDetailPage },
|
||
mixins: [WorkCenterMixin],
|
||
data () {
|
||
return {
|
||
loading: false,
|
||
switchValue: 'base',
|
||
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 }
|
||
},
|
||
labelColBaseInfo: {
|
||
xs: { span: 24 },
|
||
sm: { span: 6 }
|
||
},
|
||
wrapperColBaseInfo: {
|
||
xs: { span: 24 },
|
||
sm: { span: 18 }
|
||
},
|
||
longLabelColBaseInfo: {
|
||
xs: { span: 24 },
|
||
sm: { span: 3 }
|
||
},
|
||
longWrapperColBaseInfo: {
|
||
xs: { span: 24 },
|
||
sm: { span: 21 }
|
||
},
|
||
// 流程key
|
||
processKey: ProcessKey.PERMISSION_APPLY.value,
|
||
// 当前流程信息
|
||
PermissionApply,
|
||
info: {},
|
||
formInfo: {},
|
||
currentNode: '',
|
||
currentNodeName: '',
|
||
// 项目id
|
||
projectId: '',
|
||
btn: [],
|
||
validatorRules: {
|
||
// 流程名称
|
||
processName: {
|
||
rules: [
|
||
{ required: true, message: this.$t('pleaseEnter') + this.$t('processName') }
|
||
],
|
||
validateTrigger: 'blur'
|
||
},
|
||
// 授权到期日期
|
||
authExpirationDate: {
|
||
rules: [
|
||
{ required: true, message: this.$t('pleaseSelect') + this.$t('workCenter.permissionApplicationProcess.authExpirationDate') }
|
||
],
|
||
validateTrigger: 'change'
|
||
},
|
||
// 备注
|
||
remarks: {
|
||
rules: [
|
||
{ required: false, message: this.$t('pleaseEnter') + this.$t('remarks') }
|
||
],
|
||
validateTrigger: 'blur'
|
||
}
|
||
},
|
||
// 流程表单
|
||
processInfoForm: this.$form.createForm(this),
|
||
// 业务表单
|
||
baseInfoForm: this.$form.createForm(this),
|
||
// 流程审批信息表单
|
||
approvalInfoForm: this.$form.createForm(this)
|
||
}
|
||
},
|
||
computed: {
|
||
pageTitle () {
|
||
return this.$t('flowCenter') + this.$route.meta.title + '(' + this.nodeTitle + ')'
|
||
},
|
||
// 节点标题
|
||
nodeTitle () {
|
||
return this.$route.query.taskName || PermissionApply.initiate.text
|
||
},
|
||
// 禁用业务表单
|
||
disabled () {
|
||
return !this.isInitiate
|
||
},
|
||
// 流程信息禁用
|
||
processDisabled () {
|
||
return this.currentNode !== PermissionApply.initiate.value
|
||
},
|
||
// 是否发起节点(节点1)
|
||
isInitiate () {
|
||
return this.currentNode === PermissionApply.initiate.value
|
||
}
|
||
// leaderApproval
|
||
// standardApproval
|
||
},
|
||
created () {
|
||
const { projectId, nodeId, taskName } = this.$route.query
|
||
// 发起、草稿进来没有nodeId,就默认发起节点
|
||
this.currentNode = nodeId || PermissionApply.initiate.value
|
||
this.currentNodeName = taskName || PermissionApply.initiate.text
|
||
this.projectId = projectId || ''
|
||
this.btn = PermissionApply.propertyOfValue('btn', this.currentNode) || []
|
||
// 如果有nodeId,但是匹配不到任何节点,就是是增加的审批节点
|
||
if (nodeId && !PermissionApply.keyOfValue(nodeId)) {
|
||
// 同意按钮
|
||
this.btn = ['agree']
|
||
}
|
||
// 查询人员信息
|
||
this.getPersonInfoStructure(this.processKey, () => {
|
||
this.initPersonInfoData(this.isInitiate)
|
||
})
|
||
// 如果是待办或草稿进来,就获取详情数据
|
||
if (this.$route.query.projectId) {
|
||
this.loadPage()
|
||
return
|
||
}
|
||
// 如果是新建进来,就获取项目id
|
||
this.getProjectId()
|
||
},
|
||
methods: {
|
||
/**
|
||
* 获取项目id
|
||
*/
|
||
getProjectId () {
|
||
this.loading = true
|
||
// 否则就是创建一个新的流程
|
||
getPermissionApplyProjectId().then(res => {
|
||
if (res) {
|
||
this.projectId = res + ''
|
||
}
|
||
}).finally(() => {
|
||
this.loading = false
|
||
})
|
||
},
|
||
/**
|
||
* 获取页面详情
|
||
*/
|
||
loadPage () {
|
||
const { projectId, taskId, draftId } = this.$route.query
|
||
this.loading = true
|
||
// 获取流程数据
|
||
getPermissionApplyDetail({
|
||
projectId,
|
||
taskId
|
||
}).then(res => {
|
||
if (res.success) {
|
||
const data = res.result || {}
|
||
const processAll = data.processAll || {}
|
||
const processApprovalRecord = data.processApprovalRecord || {}
|
||
this.info = data
|
||
// 页面回显
|
||
this.processInfoForm && this.processInfoForm.setFieldsValue({
|
||
prcName: processAll.prcName,
|
||
dueTime: processAll.dueTime,
|
||
prcMes: processAll.prcMes
|
||
})
|
||
this.approvalInfoForm && this.approvalInfoForm.setFieldsValue({
|
||
commitText: processApprovalRecord.commitText,
|
||
commitFile: processApprovalRecord.commitFile
|
||
})
|
||
|
||
// 草稿状态回显
|
||
if (draftId) {
|
||
const infoJson = JSON.parse(data.infoJsonStr || '{}')
|
||
console.log('草稿回显', JSON.parse(data.infoJsonStr || '{}'), infoJson)
|
||
// 节点1 回显人员信息
|
||
if (this.isInitiate) {
|
||
this.draftInitPersonInfo(infoJson.personInfo)
|
||
}
|
||
// 回显业务信息,如果有标识属性就是强制撤回
|
||
if (Object.hasOwnProperty.call(infoJson, 'revocation')) {
|
||
const formData = infoJson.draftData
|
||
const list = formData.lawsEnterpriseStandardList || []
|
||
// 保存并回显表单信息
|
||
this.info = cloneDeep(formData)
|
||
this.formInfo = formData
|
||
this.$nextTick(() => {
|
||
// 发起节点的表格和审批节点的表格,哪个存在回显哪个的数据
|
||
this.$refs.baseInfoTable && this.$refs.baseInfoTable.setData(list)
|
||
this.$refs.applyPermissionTable && this.$refs.applyPermissionTable.setData(list)
|
||
this.baseInfoForm.setFieldsValue({
|
||
expirationDate: formData.expirationDate,
|
||
userDictText: formData.userDictText,
|
||
standardNumbers: formData.standardNumbers,
|
||
applyDetail: formData.applyDetail
|
||
})
|
||
})
|
||
} else {
|
||
// 非强制撤回调接口查数据
|
||
this.getFormInfo()
|
||
}
|
||
} else {
|
||
// 非草稿调用接口查数据
|
||
this.getFormInfo()
|
||
}
|
||
}
|
||
}).finally(() => {
|
||
this.loading = false
|
||
})
|
||
},
|
||
// 获取业务表单信息
|
||
getFormInfo () {
|
||
getPermissionApplyDataById({ projectId: this.projectId }).then(res => {
|
||
if (res.success) {
|
||
const data = res.result || {}
|
||
const list = data.lawsEnterpriseStandardList || []
|
||
// 发起节点的表格和审批节点的表格,哪个存在回显哪个的数据
|
||
this.$refs.baseInfoTable && this.$refs.baseInfoTable.setData(list)
|
||
this.$refs.applyPermissionTable && this.$refs.applyPermissionTable.setData(list)
|
||
this.formInfo = data
|
||
this.baseInfoForm.setFieldsValue({
|
||
expirationDate: data.expirationDate,
|
||
userDictText: data.userDictText,
|
||
standardNumbers: data.standardNumbers,
|
||
applyDetail: data.applyDetail
|
||
})
|
||
}
|
||
})
|
||
},
|
||
// 获取人员信息
|
||
getPersonInfo (isValidate = true) {
|
||
let personnelObj = {}
|
||
const funName = isValidate ? 'getDataObjVerify' : 'getDataObj'
|
||
// 节点1:所有的人员信息
|
||
if (this.isInitiate) {
|
||
// 人员信息的数据, 处理成对象
|
||
personnelObj = this.$refs.personnelInfo[funName]()
|
||
if (!personnelObj) {
|
||
return false
|
||
}
|
||
// List拆成数组
|
||
for (const key in personnelObj) {
|
||
if (personnelObj[key] && key.includes('List')) {
|
||
personnelObj[key] = personnelObj[key].split(',')
|
||
}
|
||
}
|
||
}
|
||
return personnelObj
|
||
},
|
||
// 获取页面参数
|
||
async getPageParams (isValidate = true) {
|
||
// 去除备注必填
|
||
this.validatorRules.remarks.rules[0].required = false
|
||
// 报错标记(base基本信息校验失败,user人员信息校验失败)
|
||
let flag = ''
|
||
const base = 'base'
|
||
const user = 'user'
|
||
if (isValidate) {
|
||
// 节点1判断表格是否有数据
|
||
if (this.isInitiate && this.$refs.baseInfoTable.dataSource.length === 0) {
|
||
this.$message.warning(this.$t('addAtLeastOneRowOfData'))
|
||
if (!flag) {
|
||
flag = base
|
||
}
|
||
} else if (!this.isInitiate && this.$refs.applyPermissionTable.dataSource.length === 0) {
|
||
// 其他节点判断表单中的表格是否有数据
|
||
this.$message.warning(this.$t('addAtLeastOneRowOfData'))
|
||
if (!flag) {
|
||
flag = base
|
||
}
|
||
}
|
||
// 校验表格中是否已有权限
|
||
if (isValidate && this.isInitiate) {
|
||
const ids = this.$refs.baseInfoTable.dataSource.map(item => item.id).join(',')
|
||
await checkPermissionApply({ ids }).then(res => {
|
||
if (!res.success) {
|
||
this.$message.warning(res.message)
|
||
if (!flag) {
|
||
flag = base
|
||
}
|
||
}
|
||
}).catch(() => {
|
||
// 请求异常报错会有全局的提示,flag为当前页面不做跳转
|
||
flag = this.switchValue
|
||
})
|
||
}
|
||
}
|
||
const params = {}
|
||
// 收集所有表单信息
|
||
let formDataList = []
|
||
if (isValidate) {
|
||
formDataList = await this.validateFormList(this.processInfoForm, this.approvalInfoForm, this.baseInfoForm).catch(() => {
|
||
if (!flag) {
|
||
flag = base
|
||
}
|
||
// 设置成数组防止后面报错
|
||
return []
|
||
})
|
||
} else {
|
||
formDataList = [
|
||
this.processInfoForm.getFieldsValue(),
|
||
this.approvalInfoForm.getFieldsValue(),
|
||
this.baseInfoForm.getFieldsValue()
|
||
]
|
||
// 保存清空校验
|
||
this.approvalInfoForm.validateFields(['commitText'], { force: true }, () => {})
|
||
}
|
||
// 收集人员信息
|
||
const personInfo = this.getPersonInfo(isValidate && !flag)
|
||
if (!personInfo) {
|
||
flag = user
|
||
}
|
||
|
||
// 开始处理信息
|
||
// 流程信息
|
||
params.processAll = Object.assign({}, this.info.processAll, formDataList[0], {
|
||
projectId: this.projectId,
|
||
nodeId: this.$route.query.nodeId,
|
||
taskId: this.$route.query.taskId,
|
||
prcType: 20
|
||
})
|
||
|
||
// 处理其他参数
|
||
params.map = Object.assign({}, personInfo)
|
||
|
||
// 流程审批信息
|
||
params.processApprovalRecord = Object.assign({}, this.info.processApprovalRecord, formDataList[1], {
|
||
projectId: this.projectId
|
||
})
|
||
|
||
// 处理业务信息
|
||
params.processEsPermissionApply = Object.assign({}, formDataList[2], {
|
||
projectId: this.projectId,
|
||
id: this.formInfo.id
|
||
})
|
||
// 节点1带上表格中的所有标准号和当前登录人(申请人)
|
||
if (this.isInitiate) {
|
||
params.processEsPermissionApply.standardNumbers = this.$refs.baseInfoTable.getStandardNumbers()
|
||
params.processEsPermissionApply.userId = this.$store.getters.userInfo.id
|
||
}
|
||
|
||
// 发起保存草稿信息
|
||
if (this.isInitiate) {
|
||
params.infoJsonStr = JSON.stringify({
|
||
// 人员信息(要重新获取,流程里的信息不能直接用,后端需要多选人员处理成数组了)
|
||
personInfo: this.$refs.personnelInfo.getDataObj(),
|
||
// 业务数据,用于强制撤回后回显
|
||
draftData: Object.assign({}, params.processEsPermissionApply, {
|
||
lawsEnterpriseStandardList: this.$refs.baseInfoTable.dataSource
|
||
})
|
||
})
|
||
}
|
||
|
||
// 如果有校验失败的,那就报错
|
||
if (flag) {
|
||
throw new Error(flag)
|
||
}
|
||
return params
|
||
},
|
||
/**
|
||
* 转办弹框
|
||
*/
|
||
handleTurnTo () {
|
||
this.$refs.userSelectModal.open()
|
||
},
|
||
/**
|
||
* 转办
|
||
*/
|
||
continueTurnTo (userId) {
|
||
if (this.loading) return
|
||
this.loading = true
|
||
const params = {
|
||
taskId: this.$route.query.taskId,
|
||
userId
|
||
}
|
||
transferPermissionApply(params).then(res => {
|
||
if (res.success) {
|
||
this.$message.success(res.message)
|
||
this.goBack()
|
||
} else {
|
||
this.$message.warn(res.message)
|
||
}
|
||
}).catch(() => {
|
||
this.loading = false
|
||
}).finally(() => {
|
||
setTimeout(() => {
|
||
this.loading = false
|
||
}, 1000)
|
||
})
|
||
},
|
||
/**
|
||
* 保存
|
||
*/
|
||
handleSave () {
|
||
if (this.loading) return
|
||
this.loading = true
|
||
this.getPageParams(false).then(res => {
|
||
// 1待办 2草稿
|
||
res.saveSource = (this.$route.query.draftId || !this.$route.query.projectId) ? 2 : 1
|
||
console.log(res)
|
||
return savePermissionApply(res)
|
||
}).then(res => {
|
||
if (res.success) {
|
||
this.$message.success(res.message)
|
||
this.goBack()
|
||
} else {
|
||
this.$message.warn(res.message)
|
||
}
|
||
}).catch((err) => {
|
||
console.log(err)
|
||
this.loading = false
|
||
}).finally(() => {
|
||
setTimeout(() => {
|
||
this.loading = false
|
||
}, 1000)
|
||
})
|
||
},
|
||
/**
|
||
* 提交
|
||
*/
|
||
handleSubmit () {
|
||
if (this.loading) return
|
||
// 有taskId说明已经发起过,调审批接口,否则调发起接口
|
||
if (this.$route.query.taskId) {
|
||
this.handleAgree(true)
|
||
return
|
||
}
|
||
this.loading = true
|
||
this.getPageParams().then(res => {
|
||
console.log(res)
|
||
return startPermissionApply(res)
|
||
}).then(res => {
|
||
if (res.success) {
|
||
this.$message.success(res.message)
|
||
this.goBack()
|
||
} else {
|
||
this.$message.warn(res.message)
|
||
}
|
||
}).catch((err) => {
|
||
console.log(err)
|
||
if (err && err.message && tabList.includes(err.message)) {
|
||
this.switchChange(err.message)
|
||
}
|
||
this.loading = false
|
||
}).finally(() => {
|
||
setTimeout(() => {
|
||
this.loading = false
|
||
}, 1000)
|
||
})
|
||
},
|
||
/**
|
||
* 同意
|
||
* @param isSubmitBtn - 是否提交按钮(提交按钮除了发起也走同意接口)
|
||
*/
|
||
handleAgree (isSubmitBtn) {
|
||
if (this.loading) return
|
||
this.loading = true
|
||
this.getPageParams().then(res => {
|
||
// 同意和提交一直传true
|
||
res.map.pass = true
|
||
// 不是提交按钮
|
||
if (isSubmitBtn !== true) {
|
||
// 没有填写注释,就默认同意
|
||
if (!res.processApprovalRecord.commitText) {
|
||
res.processApprovalRecord.commitText = '同意'
|
||
}
|
||
// 审批意见
|
||
res.processApprovalRecord.commitFlag = ApprovalOpinions.AGREE.value
|
||
}
|
||
return approvalPermissionApply(res)
|
||
}).then(res => {
|
||
if (res.success) {
|
||
this.$message.success(res.message)
|
||
this.goBack()
|
||
} else {
|
||
this.$message.warn(res.message)
|
||
}
|
||
}).catch((err) => {
|
||
if (err && err.message && tabList.includes(err.message)) {
|
||
this.switchChange(err.message)
|
||
}
|
||
this.loading = false
|
||
}).finally(() => {
|
||
setTimeout(() => {
|
||
this.loading = false
|
||
}, 1000)
|
||
})
|
||
},
|
||
/**
|
||
* 驳回
|
||
*/
|
||
handleReject () {
|
||
if (this.loading) return
|
||
// 备注设置必填并校验(校验第一次正常,第二次校验就不提示,force配置项解决问题)
|
||
this.validatorRules.remarks.rules[0].required = true
|
||
this.$nextTick(() => {
|
||
this.approvalInfoForm.validateFields(['commitText'], { force: true }, (err) => {
|
||
if (err) {
|
||
this.switchChange('base')
|
||
}
|
||
})
|
||
})
|
||
// 驳回需要填写备注
|
||
if (!this.approvalInfoForm.getFieldValue('commitText')) {
|
||
this.$message.warning(this.$t('pleaseEnterRemarks'))
|
||
return
|
||
}
|
||
this.loading = true
|
||
this.getPageParams().then(res => {
|
||
res.map.pass = false
|
||
// 审批意见
|
||
res.processApprovalRecord.commitFlag = ApprovalOpinions.REJECT.value
|
||
return rejectPermissionApply(res)
|
||
}).then(res => {
|
||
if (res.success) {
|
||
this.$message.success(res.message)
|
||
this.goBack()
|
||
} else {
|
||
this.$message.warn(res.message)
|
||
}
|
||
}).catch((err) => {
|
||
if (err && err.message && tabList.includes(err.message)) {
|
||
this.switchChange(err.message)
|
||
}
|
||
this.loading = false
|
||
}).finally(() => {
|
||
setTimeout(() => {
|
||
this.loading = false
|
||
}, 1000)
|
||
})
|
||
},
|
||
/**
|
||
* 验证所有表单
|
||
* @param formList - 多个需要校验的表单实例
|
||
*/
|
||
validateFormList (...formList) {
|
||
const promiseList = []
|
||
for (const form of formList) {
|
||
promiseList.push(
|
||
new Promise((resolve, reject) => {
|
||
form.validateFields({ force: true }, (err, val) => {
|
||
if (!err) {
|
||
resolve(val)
|
||
} else {
|
||
reject(err)
|
||
}
|
||
})
|
||
})
|
||
)
|
||
}
|
||
return Promise.all(promiseList).catch(() => {
|
||
throw new Error('base')
|
||
})
|
||
}
|
||
}
|
||
}
|
||
</script>
|
||
|
||
<style lang="less" scoped>
|
||
// 右边框
|
||
.j-table .resize-table-th:last-child {
|
||
border-right: 1px solid #e8e8e8;
|
||
}
|
||
</style>
|