Skip to content

Commit 2fe28af

Browse files
committed
【功能新增】候选人策略:新增表单部门负责人
1 parent 756addd commit 2fe28af

File tree

4 files changed

+127
-25
lines changed

4 files changed

+127
-25
lines changed

src/components/SimpleProcessDesignerV2/src/consts.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,11 +145,14 @@ export enum CandidateStrategy {
145145
* 指定用户组
146146
*/
147147
USER_GROUP = 40,
148-
149148
/**
150149
* 表单内用户字段
151150
*/
152151
USER_FIELD_ON_FORM = 50,
152+
/**
153+
* 表单内部门负责人
154+
*/
155+
DEPT_LEADER_ON_FORM = 51,
153156
/**
154157
* 流程表达式
155158
*/
@@ -430,6 +433,7 @@ export const CANDIDATE_STRATEGY: DictDataVO[] = [
430433
{ label: '发起人连续部门负责人', value: CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER },
431434
{ label: '用户组', value: CandidateStrategy.USER_GROUP },
432435
{ label: '表单内用户字段', value: CandidateStrategy.USER_FIELD_ON_FORM },
436+
{ label: '表单内部门负责人', value: CandidateStrategy.DEPT_LEADER_ON_FORM },
433437
{ label: '流程表达式', value: CandidateStrategy.EXPRESSION }
434438
]
435439
// 审批节点 的审批类型

src/components/SimpleProcessDesignerV2/src/node.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ export type UserTaskFormType = {
146146
postIds?: number[] // 岗位
147147
expression?: string // 流程表达式
148148
userFieldOnForm?: string // 表单内用户字段
149+
deptFieldOnForm?: string // 表单内部门字段
149150
approveRatio?: number
150151
rejectHandlerType?: RejectHandlerType
151152
returnNodeId?: string
@@ -169,6 +170,7 @@ export type CopyTaskFormType = {
169170
userGroups?: number[] // 用户组
170171
postIds?: number[] // 岗位
171172
userFieldOnForm?: string // 表单内用户字段
173+
deptFieldOnForm?: string // 表单内部门字段
172174
expression?: string // 流程表达式
173175
}
174176

@@ -285,6 +287,11 @@ export function useNodeForm(nodeType: NodeType) {
285287
showText = `表单用户:${item?.title}`
286288
}
287289

290+
// 表单内部门负责人
291+
if (configForm.value?.candidateStrategy === CandidateStrategy.DEPT_LEADER_ON_FORM) {
292+
showText = `表单内部门负责人`
293+
}
294+
288295
// 发起人自选
289296
if (configForm.value?.candidateStrategy === CandidateStrategy.START_USER_SELECT) {
290297
showText = `发起人自选`
@@ -353,6 +360,13 @@ export function useNodeForm(nodeType: NodeType) {
353360
candidateParam = deptIds.concat('|' + configForm.value.deptLevel + '')
354361
break
355362
}
363+
// 表单内部门的负责人
364+
case CandidateStrategy.DEPT_LEADER_ON_FORM: {
365+
// 候选人参数格式: | 分隔 。左边为表单内部门字段。 右边为部门层级
366+
const deptFieldOnForm = configForm.value.deptFieldOnForm!
367+
candidateParam = deptFieldOnForm.concat('|' + configForm.value.deptLevel + '')
368+
break
369+
}
356370
default:
357371
break
358372
}
@@ -405,6 +419,14 @@ export function useNodeForm(nodeType: NodeType) {
405419
configForm.value.deptLevel = +paramArray[1]
406420
break
407421
}
422+
// 表单内的部门负责人
423+
case CandidateStrategy.DEPT_LEADER_ON_FORM: {
424+
// 候选人参数格式: | 分隔 。左边为表单内的部门字段。 右边为部门层级
425+
const paramArray = candidateParam.split('|')
426+
configForm.value.deptFieldOnForm = paramArray[0]
427+
configForm.value.deptLevel = +paramArray[1]
428+
break
429+
}
408430
default:
409431
break
410432
}

src/components/SimpleProcessDesignerV2/src/nodes-config/CopyTaskNodeConfig.vue

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
<el-form-item
6161
v-if="
6262
configForm.candidateStrategy == CandidateStrategy.DEPT_MEMBER ||
63-
configForm.candidateStrategy == CandidateStrategy.DEPT_LEADER
63+
configForm.candidateStrategy == CandidateStrategy.DEPT_LEADER ||
64+
configForm.candidateStrategy == CandidateStrategy.MULTI_LEVEL_DEPT_LEADER
6465
"
6566
label="指定部门"
6667
prop="deptIds"
@@ -136,6 +137,40 @@
136137
/>
137138
</el-select>
138139
</el-form-item>
140+
<el-form-item
141+
v-if="configForm.candidateStrategy === CandidateStrategy.DEPT_LEADER_ON_FORM"
142+
label="表单内部门字段"
143+
prop="deptFieldOnForm"
144+
>
145+
<el-select v-model="configForm.deptFieldOnForm" clearable style="width: 100%">
146+
<el-option
147+
v-for="(item,idx) in deptFieldOnFormOptions"
148+
:key="idx"
149+
:label="item.title"
150+
:value="item.field"
151+
/>
152+
</el-select>
153+
</el-form-item>
154+
<el-form-item
155+
v-if="
156+
configForm.candidateStrategy == CandidateStrategy.MULTI_LEVEL_DEPT_LEADER ||
157+
configForm.candidateStrategy == CandidateStrategy.START_USER_DEPT_LEADER ||
158+
configForm.candidateStrategy == CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER ||
159+
configForm.candidateStrategy == CandidateStrategy.DEPT_LEADER_ON_FORM
160+
"
161+
:label="deptLevelLabel!"
162+
prop="deptLevel"
163+
span="24"
164+
>
165+
<el-select v-model="configForm.deptLevel" clearable>
166+
<el-option
167+
v-for="(item, index) in MULTI_LEVEL_DEPT"
168+
:key="index"
169+
:label="item.label"
170+
:value="item.value"
171+
/>
172+
</el-select>
173+
</el-form-item>
139174
<el-form-item
140175
v-if="configForm.candidateStrategy === CandidateStrategy.EXPRESSION"
141176
label="流程表达式"
@@ -214,7 +249,8 @@ import {
214249
CandidateStrategy,
215250
NodeType,
216251
CANDIDATE_STRATEGY,
217-
FieldPermissionType
252+
FieldPermissionType,
253+
MULTI_LEVEL_DEPT
218254
} from '../consts'
219255
import {
220256
useWatchNode,
@@ -234,6 +270,15 @@ const props = defineProps({
234270
required: true
235271
}
236272
})
273+
const deptLevelLabel = computed(() => {
274+
let label = '部门负责人来源'
275+
if (configForm.value.candidateStrategy == CandidateStrategy.MULTI_LEVEL_DEPT_LEADER) {
276+
label = label + '(指定部门向上)'
277+
} else {
278+
label = label + '(发起人部门向上)'
279+
}
280+
return label
281+
})
237282
// 抽屉配置
238283
const { settingVisible, closeDrawer, openDrawer } = useDrawer()
239284
// 当前节点
@@ -252,6 +297,12 @@ const userFieldOnFormOptions = computed(() => {
252297
(item) => item.required && item.type === 'UserSelect'
253298
)
254299
})
300+
// 表单内部门字段选项, 必须是必填和部门选择器
301+
const deptFieldOnFormOptions = computed(() => {
302+
return formFieldOptions.filter(
303+
(item) => item.required && item.type === 'DeptSelect'
304+
)
305+
})
255306
// 抄送人表单配置
256307
const formRef = ref() // 表单 Ref
257308
// 表单校验规则
@@ -263,6 +314,7 @@ const formRules = reactive({
263314
userGroups: [{ required: true, message: '用户组不能为空', trigger: 'change' }],
264315
postIds: [{ required: true, message: '岗位不能为空', trigger: 'change' }],
265316
userFieldOnForm: [{ required: true, message: '表单内用户字段不能为空', trigger: 'change' }],
317+
deptFieldOnForm: [{ required: true, message: '表单内部门字段不能为空', trigger: 'change' }],
266318
expression: [{ required: true, message: '流程表达式不能为空', trigger: 'blur' }]
267319
})
268320

src/components/SimpleProcessDesignerV2/src/nodes-config/UserTaskNodeConfig.vue

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@
5656
</el-radio>
5757
</el-radio-group>
5858
</el-form-item>
59-
6059
<el-form-item
6160
v-if="configForm.candidateStrategy == CandidateStrategy.ROLE"
6261
label="指定角色"
@@ -94,25 +93,6 @@
9493
show-checkbox
9594
/>
9695
</el-form-item>
97-
<el-form-item
98-
v-if="
99-
configForm.candidateStrategy == CandidateStrategy.MULTI_LEVEL_DEPT_LEADER ||
100-
configForm.candidateStrategy == CandidateStrategy.START_USER_DEPT_LEADER ||
101-
configForm.candidateStrategy == CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER
102-
"
103-
:label="deptLevelLabel!"
104-
prop="deptLevel"
105-
span="24"
106-
>
107-
<el-select v-model="configForm.deptLevel" clearable>
108-
<el-option
109-
v-for="(item, index) in MULTI_LEVEL_DEPT"
110-
:key="index"
111-
:label="item.label"
112-
:value="item.value"
113-
/>
114-
</el-select>
115-
</el-form-item>
11696
<el-form-item
11797
v-if="configForm.candidateStrategy == CandidateStrategy.POST"
11898
label="指定岗位"
@@ -171,6 +151,40 @@
171151
/>
172152
</el-select>
173153
</el-form-item>
154+
<el-form-item
155+
v-if="configForm.candidateStrategy === CandidateStrategy.DEPT_LEADER_ON_FORM"
156+
label="表单内部门字段"
157+
prop="deptFieldOnForm"
158+
>
159+
<el-select v-model="configForm.deptFieldOnForm" clearable style="width: 100%">
160+
<el-option
161+
v-for="(item,idx) in deptFieldOnFormOptions"
162+
:key="idx"
163+
:label="item.title"
164+
:value="item.field"
165+
/>
166+
</el-select>
167+
</el-form-item>
168+
<el-form-item
169+
v-if="
170+
configForm.candidateStrategy == CandidateStrategy.MULTI_LEVEL_DEPT_LEADER ||
171+
configForm.candidateStrategy == CandidateStrategy.START_USER_DEPT_LEADER ||
172+
configForm.candidateStrategy == CandidateStrategy.START_USER_MULTI_LEVEL_DEPT_LEADER ||
173+
configForm.candidateStrategy == CandidateStrategy.DEPT_LEADER_ON_FORM
174+
"
175+
:label="deptLevelLabel!"
176+
prop="deptLevel"
177+
span="24"
178+
>
179+
<el-select v-model="configForm.deptLevel" clearable>
180+
<el-option
181+
v-for="(item, index) in MULTI_LEVEL_DEPT"
182+
:key="index"
183+
:label="item.label"
184+
:value="item.value"
185+
/>
186+
</el-select>
187+
</el-form-item>
174188
<!-- TODO @jason:后续要支持选择已经存好的表达式 -->
175189
<el-form-item
176190
v-if="configForm.candidateStrategy === CandidateStrategy.EXPRESSION"
@@ -482,8 +496,10 @@ const deptLevelLabel = computed(() => {
482496
let label = '部门负责人来源'
483497
if (configForm.value.candidateStrategy == CandidateStrategy.MULTI_LEVEL_DEPT_LEADER) {
484498
label = label + '(指定部门向上)'
499+
} else if (configForm.value.candidateStrategy == CandidateStrategy.DEPT_LEADER_ON_FORM) {
500+
label = label + '(表单内部门向上)'
485501
} else {
486-
label = label + '(发起人部门向上)'
502+
label = label + '(发起人部门向上)'
487503
}
488504
return label
489505
})
@@ -505,6 +521,12 @@ const userFieldOnFormOptions = computed(() => {
505521
(item) => item.required && item.type === 'UserSelect'
506522
)
507523
})
524+
// 表单内部门字段选项, 必须是必填和部门选择器
525+
const deptFieldOnFormOptions = computed(() => {
526+
return formFieldOptions.filter(
527+
(item) => item.required && item.type === 'DeptSelect'
528+
)
529+
})
508530
// 操作按钮设置
509531
const { buttonsSetting, btnDisplayNameEdit, changeBtnDisplayName, btnDisplayNameBlurEvent } =
510532
useButtonsSetting()
@@ -519,6 +541,7 @@ const formRules = reactive({
519541
deptIds: [{ required: true, message: '部门不能为空', trigger: 'change' }],
520542
userGroups: [{ required: true, message: '用户组不能为空', trigger: 'change' }],
521543
userFieldOnForm: [{ required: true, message: '表单内用户字段不能为空', trigger: 'change' }],
544+
deptFieldOnForm: [{ required: true, message: '表单内部门字段不能为空', trigger: 'change' }],
522545
postIds: [{ required: true, message: '岗位不能为空', trigger: 'change' }],
523546
expression: [{ required: true, message: '流程表达式不能为空', trigger: 'blur' }],
524547
approveMethod: [{ required: true, message: '多人审批方式不能为空', trigger: 'change' }],
@@ -554,7 +577,8 @@ const changeCandidateStrategy = () => {
554577
configForm.value.postIds = []
555578
configForm.value.userGroups = []
556579
configForm.value.deptLevel = 1
557-
configForm.value.userFieldOnForm = ''
580+
configForm.value.userFieldOnForm = ''
581+
configForm.value.deptFieldOnForm = ''
558582
configForm.value.approveMethod = ApproveMethodType.SEQUENTIAL_APPROVE
559583
}
560584

0 commit comments

Comments
 (0)