diff --git a/src/views/bpm/processInstance/create/ProcessDefinitionDetail.vue b/src/views/bpm/processInstance/create/ProcessDefinitionDetail.vue index 50d3fbd7..610963e1 100644 --- a/src/views/bpm/processInstance/create/ProcessDefinitionDetail.vue +++ b/src/views/bpm/processInstance/create/ProcessDefinitionDetail.vue @@ -162,8 +162,10 @@ const getApprovalDetail = async (row: any) => { startUserSelectTasks.value = data.activityNodes?.filter( (node: ApprovalNodeInfo) => CandidateStrategy.START_USER_SELECT === node.candidateStrategy ) - for (const node of startUserSelectTasks.value) { - startUserSelectAssignees.value[node.id] = [] + if (startUserSelectTasks.value?.length > 0) { + for (const node of startUserSelectTasks.value) { + startUserSelectAssignees.value[node.id] = [] + } } // 获取审批节点,显示 Timeline 的数据 diff --git a/src/views/bpm/processInstance/create/index.vue b/src/views/bpm/processInstance/create/index.vue index 49fac73e..a3bf143b 100644 --- a/src/views/bpm/processInstance/create/index.vue +++ b/src/views/bpm/processInstance/create/index.vue @@ -22,7 +22,7 @@
- +
{ try { // 流程分类 categoryList.value = await CategoryApi.getCategorySimpleList() - // 选中首个分类 - if (categoryList.value.length > 0) { - categoryActive.value = categoryList.value[0] - } } finally { } } @@ -154,6 +150,11 @@ const getProcessDefinitionList = async () => { }) // 初始化过滤列表为全部流程定义 filteredProcessDefinitionList.value = processDefinitionList.value + + // 在获取完所有数据后,设置第一个有效分类为激活状态 + if (availableCategories.value.length > 0 && !categoryActive.value?.code) { + categoryActive.value = availableCategories.value[0] + } } finally { } } @@ -220,10 +221,62 @@ const handleSelect = async (row, formVariables?) => { processDefinitionDetailRef.value?.initProcessInfo(row, formVariables) } +/** 处理滚动事件 */ +const handleScroll = (e) => { + // 直接使用事件对象获取滚动位置 + const scrollTop = e.scrollTop + + // 获取所有分类区域的位置信息 + const categoryPositions = categoryList.value + .map((category) => { + const categoryRef = proxy.$refs[`category-${category.code}`] + if (categoryRef?.[0]) { + return { + code: category.code, + offsetTop: categoryRef[0].offsetTop, + height: categoryRef[0].offsetHeight + } + } + return null + }) + .filter(Boolean) + + // 查找当前滚动位置对应的分类 + let currentCategory = categoryPositions[0] + for (const position of categoryPositions) { + // 为了更好的用户体验,可以添加一个缓冲区域(比如 50px) + if (scrollTop >= position.offsetTop - 50) { + currentCategory = position + } else { + break + } + } + + // 更新当前 active 的分类 + if (currentCategory && categoryActive.value.code !== currentCategory.code) { + categoryActive.value = categoryList.value.find((c) => c.code === currentCategory.code) + } +} + /** 初始化 */ onMounted(() => { getList() }) + +/** 过滤出有流程的分类列表 */ +const availableCategories = computed(() => { + if (!categoryList.value?.length || !processDefinitionGroup.value) { + return [] + } + + // 获取所有有流程的分类代码 + const availableCategoryCodes = Object.keys(processDefinitionGroup.value) + + // 过滤出有流程的分类 + return categoryList.value.filter(category => + availableCategoryCodes.includes(category.code) + ) +}) diff --git a/src/views/bpm/processInstance/detail/ProcessInstanceSimpleViewer.vue b/src/views/bpm/processInstance/detail/ProcessInstanceSimpleViewer.vue index d98e7734..0808bec9 100644 --- a/src/views/bpm/processInstance/detail/ProcessInstanceSimpleViewer.vue +++ b/src/views/bpm/processInstance/detail/ProcessInstanceSimpleViewer.vue @@ -1,5 +1,5 @@