Skip to content

Commit 8244050

Browse files
committed
review:代码审查
1 parent 3725e9d commit 8244050

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

src/views/bpm/processInstance/detail/ProcessInstanceOperationButton.vue

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@
4444
:rows="4"
4545
/>
4646
</el-form-item>
47-
<el-form-item label="下一个节点的审批人" prop="nextAssignees" v-if="nextAssigneesActivityNode.length > 0">
47+
<el-form-item
48+
label="下一个节点的审批人"
49+
prop="nextAssignees"
50+
v-if="nextAssigneesActivityNode.length > 0"
51+
>
4852
<div class="ml-10px -mt-15px -mb-35px">
4953
<ProcessInstanceTimeline
5054
:activity-nodes="nextAssigneesActivityNode"
@@ -725,11 +729,12 @@ const initNextAssigneesFormField = async () => {
725729
})
726730
if (data && data.length > 0) {
727731
data.forEach((node: any) => {
732+
// 如果是发起人自选,并且没有审批人 或者 是审批人自选
728733
if (
729-
isEmpty(node.tasks) &&
730-
isEmpty(node.candidateUsers) &&
731-
(CandidateStrategy.START_USER_SELECT === node.candidateStrategy ||
732-
CandidateStrategy.APPROVE_USER_SELECT === node.candidateStrategy)
734+
(isEmpty(node.tasks) &&
735+
isEmpty(node.candidateUsers) &&
736+
CandidateStrategy.START_USER_SELECT === node.candidateStrategy) ||
737+
CandidateStrategy.APPROVE_USER_SELECT === node.candidateStrategy
733738
) {
734739
nextAssigneesActivityNode.value.push(node)
735740
}
@@ -741,6 +746,20 @@ const initNextAssigneesFormField = async () => {
741746
const selectNextAssigneesConfirm = (id: string, userList: any[]) => {
742747
approveReasonForm.nextAssignees[id] = userList?.map((item: any) => item.id)
743748
}
749+
/** 审批通过时,校验每个自选审批人的节点是否都已配置了审批人 */
750+
const validateNextAssignees = () => {
751+
// 如果需要自选审批人,则校验自选审批人
752+
if (Object.keys(nextAssigneesActivityNode.value).length > 0) {
753+
// 校验每个节点是否都已配置审批人
754+
for (const item of nextAssigneesActivityNode.value) {
755+
if (isEmpty(approveReasonForm.nextAssignees[item.id])) {
756+
message.warning('下一个节点的审批人不能为空!')
757+
return false
758+
}
759+
}
760+
}
761+
return true
762+
}
744763
745764
/** 处理审批通过和不通过的操作 */
746765
const handleAudit = async (pass: boolean, formRef: FormInstance | undefined) => {
@@ -757,12 +776,8 @@ const handleAudit = async (pass: boolean, formRef: FormInstance | undefined) =>
757776
}
758777
759778
if (pass) {
760-
// 如果需要自选审批人,则校验自选审批人
761-
if (Object.keys(nextAssigneesActivityNode.value).length > 0
762-
&& Object.keys(approveReasonForm.nextAssignees).length === 0) {
763-
message.warning('下一个节点的审批人不能为空!')
764-
return
765-
}
779+
const nextAssigneesValid = validateNextAssignees()
780+
if (!nextAssigneesValid) return
766781
const variables = getUpdatedProcessInstanceVariables()
767782
// 审批通过数据
768783
const data = {

0 commit comments

Comments
 (0)