BPM:重构流程分配人的实现,通过 BpmTaskCandidateStrategy 策略模式

This commit is contained in:
YunaiV 2024-03-15 00:19:23 +08:00
parent 960f27f6ef
commit 5f7ccd4e7c
6 changed files with 57 additions and 63 deletions

View File

@ -334,12 +334,12 @@
"type": "String" "type": "String"
}, },
{ {
"name": "assignType", "name": "candidateStrategy",
"isAttr": true, "isAttr": true,
"type": "String" "type": "String"
}, },
{ {
"name": "assignOptions", "name": "candidateParam",
"isAttr": true, "isAttr": true,
"type": "String" "type": "String"
} }

View File

@ -321,12 +321,12 @@
"type": "String" "type": "String"
}, },
{ {
"name": "assignType", "name": "candidateStrategy",
"isAttr": true, "isAttr": true,
"type": "String" "type": "String"
}, },
{ {
"name": "assignOptions", "name": "candidateParam",
"isAttr": true, "isAttr": true,
"type": "String" "type": "String"
} }

View File

@ -321,12 +321,12 @@
"type": "String" "type": "String"
}, },
{ {
"name": "assignType", "name": "candidateStrategy",
"isAttr": true, "isAttr": true,
"type": "String" "type": "String"
}, },
{ {
"name": "assignOptions", "name": "candidateParam",
"isAttr": true, "isAttr": true,
"type": "String" "type": "String"
} }

View File

@ -1,23 +1,27 @@
<template> <template>
<el-form label-width="100px"> <el-form label-width="100px">
<el-form-item label="规则类型" prop="assignType"> <el-form-item label="规则类型" prop="candidateStrategy">
<el-select <el-select
v-model="userTaskForm.assignType" v-model="userTaskForm.candidateStrategy"
clearable clearable
style="width: 100%" style="width: 100%"
@change="changeAssignType" @change="changecandidateStrategy"
> >
<el-option <el-option
v-for="dict in getIntDictOptions(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE)" v-for="dict in getIntDictOptions(DICT_TYPE.BPM_TASK_CANDIDATE_STRATEGY)"
:key="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value" :value="dict.value"
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item v-if="userTaskForm.assignType == 10" label="指定角色" prop="assignOptions"> <el-form-item
v-if="userTaskForm.candidateStrategy == 10"
label="指定角色"
prop="candidateParam"
>
<el-select <el-select
v-model="userTaskForm.assignOptions" v-model="userTaskForm.candidateParam"
clearable clearable
multiple multiple
style="width: 100%" style="width: 100%"
@ -27,14 +31,14 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if="userTaskForm.assignType == 20 || userTaskForm.assignType == 21" v-if="userTaskForm.candidateStrategy == 20 || userTaskForm.candidateStrategy == 21"
label="指定部门" label="指定部门"
prop="assignOptions" prop="candidateParam"
span="24" span="24"
> >
<el-tree-select <el-tree-select
ref="treeRef" ref="treeRef"
v-model="userTaskForm.assignOptions" v-model="userTaskForm.candidateParam"
:data="deptTreeOptions" :data="deptTreeOptions"
:props="defaultProps" :props="defaultProps"
empty-text="加载中,请稍后" empty-text="加载中,请稍后"
@ -45,13 +49,13 @@
/> />
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if="userTaskForm.assignType == 22" v-if="userTaskForm.candidateStrategy == 22"
label="指定岗位" label="指定岗位"
prop="assignOptions" prop="candidateParam"
span="24" span="24"
> >
<el-select <el-select
v-model="userTaskForm.assignOptions" v-model="userTaskForm.candidateParam"
clearable clearable
multiple multiple
style="width: 100%" style="width: 100%"
@ -62,16 +66,16 @@
</el-form-item> </el-form-item>
<el-form-item <el-form-item
v-if=" v-if="
userTaskForm.assignType == 30 || userTaskForm.candidateStrategy == 30 ||
userTaskForm.assignType == 31 || userTaskForm.candidateStrategy == 31 ||
userTaskForm.assignType == 32 userTaskForm.candidateStrategy == 32
" "
label="指定用户" label="指定用户"
prop="assignOptions" prop="candidateParam"
span="24" span="24"
> >
<el-select <el-select
v-model="userTaskForm.assignOptions" v-model="userTaskForm.candidateParam"
clearable clearable
multiple multiple
style="width: 100%" style="width: 100%"
@ -85,9 +89,13 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item v-if="userTaskForm.assignType === 40" label="指定用户组" prop="assignOptions"> <el-form-item
v-if="userTaskForm.candidateStrategy === 40"
label="指定用户组"
prop="candidateParam"
>
<el-select <el-select
v-model="userTaskForm.assignOptions" v-model="userTaskForm.candidateParam"
clearable clearable
multiple multiple
style="width: 100%" style="width: 100%"
@ -101,26 +109,14 @@
/> />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item v-if="userTaskForm.assignType === 50" label="指定脚本" prop="assignOptions"> <el-form-item
<el-select v-if="userTaskForm.candidateStrategy === 60"
v-model="userTaskForm.assignOptions" label="流程表达式"
clearable prop="candidateParam"
multiple
style="width: 100%"
@change="updateElementTask"
> >
<el-option
v-for="dict in taskAssignScriptDictDatas"
:key="dict.value"
:label="dict.label"
:value="dict.value"
/>
</el-select>
</el-form-item>
<el-form-item v-if="userTaskForm.assignType === 60" label="流程表达式" prop="assignOptions">
<el-input <el-input
type="textarea" type="textarea"
v-model="userTaskForm.assignOptions[0]" v-model="userTaskForm.candidateParam[0]"
clearable clearable
style="width: 100%" style="width: 100%"
@change="updateElementTask" @change="updateElementTask"
@ -144,10 +140,9 @@ const props = defineProps({
type: String type: String
}) })
const userTaskForm = ref({ const userTaskForm = ref({
assignType: undefined, // candidateStrategy: undefined, //
assignOptions: [] // candidateParam: [] //
}) })
// const mockData=ref([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
const bpmnElement = ref() const bpmnElement = ref()
const bpmnInstances = () => (window as any)?.bpmnInstances const bpmnInstances = () => (window as any)?.bpmnInstances
@ -156,42 +151,42 @@ const deptTreeOptions = ref() // 部门树
const postOptions = ref<PostApi.PostVO[]>([]) // const postOptions = ref<PostApi.PostVO[]>([]) //
const userOptions = ref<UserApi.UserVO[]>([]) // const userOptions = ref<UserApi.UserVO[]>([]) //
const userGroupOptions = ref<UserGroupApi.UserGroupVO[]>([]) // const userGroupOptions = ref<UserGroupApi.UserGroupVO[]>([]) //
const taskAssignScriptDictDatas = getIntDictOptions(DICT_TYPE.BPM_TASK_ASSIGN_SCRIPT)
const resetTaskForm = () => { const resetTaskForm = () => {
const businessObject = bpmnElement.value.businessObject const businessObject = bpmnElement.value.businessObject
if (!businessObject) { if (!businessObject) {
return return
} }
if (businessObject.assignType != undefined) { if (businessObject.candidateStrategy != undefined) {
userTaskForm.value.assignType = parseInt(businessObject.assignType) as any userTaskForm.value.candidateStrategy = parseInt(businessObject.candidateStrategy) as any
} else { } else {
userTaskForm.value.assignType = undefined userTaskForm.value.candidateStrategy = undefined
} }
if (businessObject.assignOptions && businessObject.assignOptions.length > 0) { if (businessObject.candidateParam && businessObject.candidateParam.length > 0) {
if (userTaskForm.value.assignType === 60) { if (userTaskForm.value.candidateStrategy === 60) {
userTaskForm.value.assignOptions = [businessObject.assignOptions] // input
userTaskForm.value.candidateParam = [businessObject.candidateParam]
} else { } else {
userTaskForm.value.assignOptions = businessObject.assignOptions userTaskForm.value.candidateParam = businessObject.candidateParam
.split(',') .split(',')
.map((item) => +item) .map((item) => +item)
} }
} else { } else {
userTaskForm.value.assignOptions = [] userTaskForm.value.candidateParam = []
} }
} }
/** 更新 assignType 字段时,需要清空 assignOptions,并触发 bpmn 图更新 */ /** 更新 candidateStrategy 字段时,需要清空 candidateParam,并触发 bpmn 图更新 */
const changeAssignType = () => { const changecandidateStrategy = () => {
userTaskForm.value.assignOptions = [] userTaskForm.value.candidateParam = []
updateElementTask() updateElementTask()
} }
/** 选中某个 options 时候,更新 bpmn 图 */ /** 选中某个 options 时候,更新 bpmn 图 */
const updateElementTask = () => { const updateElementTask = () => {
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), {
assignType: userTaskForm.value.assignType, candidateStrategy: userTaskForm.value.candidateStrategy,
assignOptions: userTaskForm.value.assignOptions.join(',') candidateParam: userTaskForm.value.candidateParam.join(',')
}) })
} }

View File

@ -138,10 +138,9 @@ export enum DICT_TYPE {
// ========== BPM 模块 ========== // ========== BPM 模块 ==========
BPM_MODEL_CATEGORY = 'bpm_model_category', BPM_MODEL_CATEGORY = 'bpm_model_category',
BPM_MODEL_FORM_TYPE = 'bpm_model_form_type', BPM_MODEL_FORM_TYPE = 'bpm_model_form_type',
BPM_TASK_ASSIGN_RULE_TYPE = 'bpm_task_assign_rule_type', BPM_TASK_CANDIDATE_STRATEGY = 'bpm_task_candidate_strategy',
BPM_PROCESS_INSTANCE_STATUS = 'bpm_process_instance_status', BPM_PROCESS_INSTANCE_STATUS = 'bpm_process_instance_status',
BPM_PROCESS_INSTANCE_RESULT = 'bpm_process_instance_result', BPM_PROCESS_INSTANCE_RESULT = 'bpm_process_instance_result',
BPM_TASK_ASSIGN_SCRIPT = 'bpm_task_assign_script',
BPM_OA_LEAVE_TYPE = 'bpm_oa_leave_type', BPM_OA_LEAVE_TYPE = 'bpm_oa_leave_type',
// ========== PAY 模块 ========== // ========== PAY 模块 ==========

View File

@ -17,7 +17,7 @@
<el-form-item label="规则类型" prop="type"> <el-form-item label="规则类型" prop="type">
<el-select v-model="formData.type" clearable style="width: 100%"> <el-select v-model="formData.type" clearable style="width: 100%">
<el-option <el-option
v-for="dict in getIntDictOptions(DICT_TYPE.BPM_TASK_ASSIGN_RULE_TYPE)" v-for="dict in getIntDictOptions(DICT_TYPE.BPM_TASK_CANDIDATE_STRATEGY)"
:key="dict.value" :key="dict.value"
:label="dict.label" :label="dict.label"
:value="dict.value" :value="dict.value"