refactor: 通过extensionElements来存储候选审批人

pull/610/head
Lesan 2024-12-04 15:39:40 +08:00
parent eb6f3a3e49
commit abdaf2e0ca
1 changed files with 45 additions and 0 deletions

View File

@ -142,6 +142,7 @@ const props = defineProps({
id: String,
type: String
})
const prefix = inject('prefix')
const userTaskForm = ref({
candidateStrategy: undefined, //
candidateParam: [] //
@ -154,12 +155,39 @@ const deptTreeOptions = ref() // 部门树
const postOptions = ref<PostApi.PostVO[]>([]) //
const userOptions = ref<UserApi.UserVO[]>([]) //
const userGroupOptions = ref<UserGroupApi.UserGroupVO[]>([]) //
const otherExtensions = ref()
const resetTaskForm = () => {
const businessObject = bpmnElement.value.businessObject
if (!businessObject) {
return
}
const extensionElements = businessObject?.extensionElements ?? []
userTaskForm.value.candidateStrategy = extensionElements.values?.filter(
(ex) => ex.$type === `${prefix}:CandidateStrategy`
)?.[0]?.value
const candidateParamStr = extensionElements.values?.filter(
(ex) => ex.$type === `${prefix}:CandidateParam`
)?.[0]?.value
if (candidateParamStr && candidateParamStr.length > 0) {
if (userTaskForm.value.candidateStrategy === 60) {
// input
userTaskForm.value.candidateParam = [candidateParamStr]
} else {
userTaskForm.value.candidateParam = candidateParamStr.split(',').map((item) => item)
}
} else {
userTaskForm.value.candidateParam = []
}
otherExtensions.value =
extensionElements.values?.filter(
(ex) => ex.$type !== `${prefix}:CandidateStrategy` && ex.$type !== `${prefix}:CandidateParam`
) ?? []
// extensionElements
return
if (businessObject.candidateStrategy != undefined) {
userTaskForm.value.candidateStrategy = parseInt(businessObject.candidateStrategy) as any
} else {
@ -187,6 +215,23 @@ const changeCandidateStrategy = () => {
/** 选中某个 options 时候,更新 bpmn 图 */
const updateElementTask = () => {
const extensions = bpmnInstances().moddle.create('bpmn:ExtensionElements', {
values: [
...otherExtensions.value,
bpmnInstances().moddle.create(`${prefix}:CandidateStrategy`, {
value: userTaskForm.value.candidateStrategy
}),
bpmnInstances().moddle.create(`${prefix}:CandidateParam`, {
value: userTaskForm.value.candidateParam.join(',')
})
]
})
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), {
extensionElements: extensions
})
// extensionElements
return
bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), {
candidateStrategy: userTaskForm.value.candidateStrategy,
candidateParam: userTaskForm.value.candidateParam.join(',')