diff --git a/src/components/bpmnProcessDesigner/package/designer/plugins/descriptor/flowableDescriptor.json b/src/components/bpmnProcessDesigner/package/designer/plugins/descriptor/flowableDescriptor.json index d1ca4a439d42a74bf9b6374498bf955b8c3320e8..5544b2d061e83754e2e04418b64c1c7f3cbc8159 100644 --- a/src/components/bpmnProcessDesigner/package/designer/plugins/descriptor/flowableDescriptor.json +++ b/src/components/bpmnProcessDesigner/package/designer/plugins/descriptor/flowableDescriptor.json @@ -1281,7 +1281,32 @@ "isBody": true } ] + }, + { + "name": "ButtonsSetting", + "superClass": ["Element"], + "meta": { + "allowedIn": ["bpmn:UserTask"] + }, + "properties": [ + { + "name": "flowable:id", + "type": "Integer", + "isAttr": true + }, + { + "name": "flowable:enable", + "type": "Boolean", + "isAttr": true + }, + { + "name": "flowable:displayName", + "type": "String", + "isAttr": true + } + ] } + ], "emumerations": [] } diff --git a/src/components/bpmnProcessDesigner/package/penal/custom-config/ElementCustomConfig.vue b/src/components/bpmnProcessDesigner/package/penal/custom-config/ElementCustomConfig.vue index e5497b083c4c86808dc924498699ec35879e0b61..9cf7e96632ca9e1ab2b90d4de3b025aedcc31074 100644 --- a/src/components/bpmnProcessDesigner/package/penal/custom-config/ElementCustomConfig.vue +++ b/src/components/bpmnProcessDesigner/package/penal/custom-config/ElementCustomConfig.vue @@ -2,6 +2,7 @@ 1. 审批人与提交人为同一人时 2. 审批人拒绝时 3. 审批人为空时 + 4. 操作按钮 --> @@ -74,6 +75,35 @@ + + 操作按钮 + + + 操作按钮 + 显示名称 + 启用 + + + {{ OPERATION_BUTTON_NAME.get(item.id) }} + + + {{ item.displayName }} + + + + + + @@ -83,7 +113,9 @@ import { RejectHandlerType, REJECT_HANDLER_TYPES, ASSIGN_EMPTY_HANDLER_TYPES, - AssignEmptyHandlerType + AssignEmptyHandlerType, + OPERATION_BUTTON_NAME, + DEFAULT_BUTTON_SETTING } from '@/components/SimpleProcessDesignerV2/src/consts' import * as UserApi from '@/api/system/user' @@ -111,6 +143,11 @@ const assignEmptyHandlerType = ref() const assignEmptyUserIdsEl = ref() const assignEmptyUserIds = ref() +// 操作按钮 +const buttonsSettingEl = ref() +const { buttonsSetting, btnDisplayNameEdit, changeBtnDisplayName, btnDisplayNameBlurEvent } = + useButtonsSetting() + const elExtensionElements = ref() const otherExtensions = ref() const bpmnElement = ref() @@ -165,6 +202,22 @@ const resetCustomConfigList = () => { return num > Number.MAX_SAFE_INTEGER || num < -Number.MAX_SAFE_INTEGER ? item : num }) + // 操作按钮 + buttonsSettingEl.value = elExtensionElements.value.values?.filter( + (ex) => ex.$type === `${prefix}:ButtonsSetting` + ) + if (buttonsSettingEl.value.length === 0) { + DEFAULT_BUTTON_SETTING.forEach((item) => { + buttonsSettingEl.value.push( + bpmnInstances().moddle.create(`${prefix}:ButtonsSetting`, { + 'flowable:id': item.id, + 'flowable:displayName': item.displayName, + 'flowable:enable': item.enable + }) + ) + }) + } + // 保留剩余扩展元素,便于后面更新该元素对应属性 otherExtensions.value = elExtensionElements.value.values?.filter( @@ -173,7 +226,8 @@ const resetCustomConfigList = () => { ex.$type !== `${prefix}:RejectHandlerType` && ex.$type !== `${prefix}:RejectReturnTaskId` && ex.$type !== `${prefix}:AssignEmptyHandlerType` && - ex.$type !== `${prefix}:AssignEmptyUserIds` + ex.$type !== `${prefix}:AssignEmptyUserIds` && + ex.$type !== `${prefix}:ButtonsSetting` ) ?? [] // 更新元素扩展属性,避免后续报错 @@ -221,7 +275,8 @@ const updateElementExtensions = () => { rejectHandlerTypeEl.value, returnNodeIdEl.value, assignEmptyHandlerTypeEl.value, - assignEmptyUserIdsEl.value + assignEmptyUserIdsEl.value, + ...buttonsSettingEl.value ] }) bpmnInstances().modeling.updateProperties(toRaw(bpmnElement.value), { @@ -245,6 +300,7 @@ function findAllPredecessorsExcludingStart(elementId, modeler) { const elementRegistry = modeler.get('elementRegistry') const allConnections = elementRegistry.filter((element) => element.type === 'bpmn:SequenceFlow') const predecessors = new Set() // 使用 Set 来避免重复节点 + const visited = new Set() // 用于记录已访问的节点 // 检查是否是开始事件节点 function isStartEvent(element) { @@ -252,6 +308,14 @@ function findAllPredecessorsExcludingStart(elementId, modeler) { } function findPredecessorsRecursively(element) { + // 如果该节点已经访问过,直接返回,避免循环 + if (visited.has(element)) { + return + } + + // 标记当前节点为已访问 + visited.add(element) + // 获取与当前节点相连的所有连接 const incomingConnections = allConnections.filter((connection) => connection.target === element) @@ -275,9 +339,114 @@ function findAllPredecessorsExcludingStart(elementId, modeler) { return Array.from(predecessors) // 返回前置节点数组 } +function useButtonsSetting() { + const buttonsSetting = ref() + // 操作按钮显示名称可编辑 + const btnDisplayNameEdit = ref([]) + const changeBtnDisplayName = (index: number) => { + btnDisplayNameEdit.value[index] = true + } + const btnDisplayNameBlurEvent = (index: number) => { + btnDisplayNameEdit.value[index] = false + const buttonItem = buttonsSetting.value![index] + buttonItem.displayName = buttonItem.displayName || OPERATION_BUTTON_NAME.get(buttonItem.id)! + } + return { + buttonsSetting, + btnDisplayNameEdit, + changeBtnDisplayName, + btnDisplayNameBlurEvent + } +} + const userOptions = ref([]) // 用户列表 onMounted(async () => { // 获得用户列表 userOptions.value = await UserApi.getSimpleUserList() }) + + diff --git a/src/views/bpm/processInstance/detail/ProcessInstanceOperationButton.vue b/src/views/bpm/processInstance/detail/ProcessInstanceOperationButton.vue index b92be7e42ab97860934f367ef2d36a46f215aded..c1a69089e2896a8e4d9f228e92aa9253df0a90d7 100644 --- a/src/views/bpm/processInstance/detail/ProcessInstanceOperationButton.vue +++ b/src/views/bpm/processInstance/detail/ProcessInstanceOperationButton.vue @@ -77,17 +77,6 @@ :rules="genericRule" label-width="100px" > - - - 填写表单【{{ runningTask?.formName }}】 - - -