Skip to content

Commit 9e2958f

Browse files
committed
feat: 同步bpm设计器审批人配置,表单内用户字段
1 parent dc8f5cf commit 9e2958f

File tree

1 file changed

+49
-2
lines changed
  • src/components/bpmnProcessDesigner/package/penal/task/task-components

1 file changed

+49
-2
lines changed

src/components/bpmnProcessDesigner/package/penal/task/task-components/UserTask.vue

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,26 @@
109109
/>
110110
</el-select>
111111
</el-form-item>
112+
<el-form-item
113+
v-if="userTaskForm.candidateStrategy === CandidateStrategy.FORM_USER"
114+
label="用户字段"
115+
prop="formUser"
116+
>
117+
<el-select
118+
v-model="userTaskForm.candidateParam"
119+
clearable
120+
style="width: 100%"
121+
@change="handleFormUserChange"
122+
>
123+
<el-option
124+
v-for="(item, idx) in userFieldOnFormOptions"
125+
:key="idx"
126+
:label="item.title"
127+
:value="item.field"
128+
:disabled="!item.required"
129+
/>
130+
</el-select>
131+
</el-form-item>
112132
<el-form-item
113133
v-if="userTaskForm.candidateStrategy === CandidateStrategy.EXPRESSION"
114134
label="流程表达式"
@@ -133,7 +153,8 @@
133153
<script lang="ts" setup>
134154
import {
135155
CANDIDATE_STRATEGY,
136-
CandidateStrategy
156+
CandidateStrategy,
157+
FieldPermissionType
137158
} from '@/components/SimpleProcessDesignerV2/src/consts'
138159
import { defaultProps, handleTree } from '@/utils/tree'
139160
import * as RoleApi from '@/api/system/role'
@@ -143,6 +164,7 @@ import * as UserApi from '@/api/system/user'
143164
import * as UserGroupApi from '@/api/bpm/userGroup'
144165
import ProcessExpressionDialog from './ProcessExpressionDialog.vue'
145166
import { ProcessExpressionVO } from '@/api/bpm/processExpression'
167+
import { useFormFieldsPermission } from '@/components/SimpleProcessDesignerV2/src/node'
146168
147169
defineOptions({ name: 'UserTask' })
148170
const props = defineProps({
@@ -162,6 +184,14 @@ const deptTreeOptions = ref() // 部门树
162184
const postOptions = ref<PostApi.PostVO[]>([]) // 岗位列表
163185
const userOptions = ref<UserApi.UserVO[]>([]) // 用户列表
164186
const userGroupOptions = ref<UserGroupApi.UserGroupVO[]>([]) // 用户组列表
187+
188+
// 表单内用户字段
189+
const { formFieldOptions } = useFormFieldsPermission(FieldPermissionType.READ)
190+
// 表单内用户字段选项, 必须是必填和用户选择器
191+
const userFieldOnFormOptions = computed(() => {
192+
return formFieldOptions.filter((item) => item.type === 'UserSelect')
193+
})
194+
165195
const otherExtensions = ref()
166196
167197
const resetTaskForm = () => {
@@ -223,6 +253,12 @@ const resetTaskForm = () => {
223253
/** 更新 candidateStrategy 字段时,需要清空 candidateParam,并触发 bpmn 图更新 */
224254
const changeCandidateStrategy = () => {
225255
userTaskForm.value.candidateParam = []
256+
if (userTaskForm.value.candidateStrategy === CandidateStrategy.FORM_USER) {
257+
// 特殊处理表单内用户字段,当只有发起人选项时应选中发起人
258+
if (!userFieldOnFormOptions.value || userFieldOnFormOptions.value.length <= 1) {
259+
userTaskForm.value.candidateStrategy = CandidateStrategy.START_USER
260+
}
261+
}
226262
updateElementTask()
227263
}
228264
@@ -235,7 +271,10 @@ const updateElementTask = () => {
235271
value: userTaskForm.value.candidateStrategy
236272
}),
237273
bpmnInstances().moddle.create(`${prefix}:CandidateParam`, {
238-
value: userTaskForm.value.candidateParam.join(',')
274+
value:
275+
userTaskForm.value.candidateParam instanceof Array
276+
? userTaskForm.value.candidateParam.join(',')
277+
: userTaskForm.value.candidateParam
239278
})
240279
]
241280
})
@@ -261,6 +300,14 @@ const selectProcessExpression = (expression: ProcessExpressionVO) => {
261300
updateElementTask()
262301
}
263302
303+
const handleFormUserChange = (e) => {
304+
if (e === 'PROCESS_START_USER_ID') {
305+
userTaskForm.value.candidateParam = []
306+
userTaskForm.value.candidateStrategy = CandidateStrategy.START_USER
307+
}
308+
updateElementTask()
309+
}
310+
264311
watch(
265312
() => props.id,
266313
() => {

0 commit comments

Comments
 (0)