From abdaf2e0ca83b9adafa890fec643c88b614ea7de Mon Sep 17 00:00:00 2001 From: Lesan <1960681385@qq.com> Date: Wed, 4 Dec 2024 15:39:40 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E9=80=9A=E8=BF=87extensionElements?= =?UTF-8?q?=E6=9D=A5=E5=AD=98=E5=82=A8=E5=80=99=E9=80=89=E5=AE=A1=E6=89=B9?= =?UTF-8?q?=E4=BA=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../penal/task/task-components/UserTask.vue | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) diff --git a/src/components/bpmnProcessDesigner/package/penal/task/task-components/UserTask.vue b/src/components/bpmnProcessDesigner/package/penal/task/task-components/UserTask.vue index 0eb45f7c..3def6a28 100644 --- a/src/components/bpmnProcessDesigner/package/penal/task/task-components/UserTask.vue +++ b/src/components/bpmnProcessDesigner/package/penal/task/task-components/UserTask.vue @@ -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([]) // 岗位列表 const userOptions = ref([]) // 用户列表 const userGroupOptions = ref([]) // 用户组列表 +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(',')