109
109
/>
110
110
</el-select >
111
111
</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 >
112
132
<el-form-item
113
133
v-if =" userTaskForm.candidateStrategy === CandidateStrategy.EXPRESSION"
114
134
label =" 流程表达式"
133
153
<script lang="ts" setup>
134
154
import {
135
155
CANDIDATE_STRATEGY ,
136
- CandidateStrategy
156
+ CandidateStrategy ,
157
+ FieldPermissionType
137
158
} from ' @/components/SimpleProcessDesignerV2/src/consts'
138
159
import { defaultProps , handleTree } from ' @/utils/tree'
139
160
import * as RoleApi from ' @/api/system/role'
@@ -143,6 +164,7 @@ import * as UserApi from '@/api/system/user'
143
164
import * as UserGroupApi from ' @/api/bpm/userGroup'
144
165
import ProcessExpressionDialog from ' ./ProcessExpressionDialog.vue'
145
166
import { ProcessExpressionVO } from ' @/api/bpm/processExpression'
167
+ import { useFormFieldsPermission } from ' @/components/SimpleProcessDesignerV2/src/node'
146
168
147
169
defineOptions ({ name: ' UserTask' })
148
170
const props = defineProps ({
@@ -162,6 +184,14 @@ const deptTreeOptions = ref() // 部门树
162
184
const postOptions = ref <PostApi .PostVO []>([]) // 岗位列表
163
185
const userOptions = ref <UserApi .UserVO []>([]) // 用户列表
164
186
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
+
165
195
const otherExtensions = ref ()
166
196
167
197
const resetTaskForm = () => {
@@ -223,6 +253,12 @@ const resetTaskForm = () => {
223
253
/** 更新 candidateStrategy 字段时,需要清空 candidateParam,并触发 bpmn 图更新 */
224
254
const changeCandidateStrategy = () => {
225
255
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
+ }
226
262
updateElementTask ()
227
263
}
228
264
@@ -235,7 +271,10 @@ const updateElementTask = () => {
235
271
value: userTaskForm .value .candidateStrategy
236
272
}),
237
273
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
239
278
})
240
279
]
241
280
})
@@ -261,6 +300,14 @@ const selectProcessExpression = (expression: ProcessExpressionVO) => {
261
300
updateElementTask ()
262
301
}
263
302
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
+
264
311
watch (
265
312
() => props .id ,
266
313
() => {
0 commit comments