From 5f2e23f4da983c4a99c3763507f102bc5326df10 Mon Sep 17 00:00:00 2001 From: GoldenZqqq <1361001127@qq.com> Date: Tue, 19 Nov 2024 15:09:45 +0800 Subject: [PATCH 1/6] =?UTF-8?q?feat:=20=E6=B5=81=E7=A8=8B=E5=8F=91?= =?UTF-8?q?=E8=B5=B7=E9=A1=B5=E9=9D=A2-=E5=8F=B3=E4=BE=A7=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E6=BB=9A=E5=8A=A8=E5=88=B0=E5=AF=B9=E5=BA=94=E7=9A=84?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E5=8C=BA=E5=9F=9F=E5=B7=A6=E4=BE=A7=E5=88=86?= =?UTF-8?q?=E7=B1=BBactive=E5=93=8D=E5=BA=94=E5=BC=8F=E5=8F=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bpm/processInstance/create/index.vue | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/src/views/bpm/processInstance/create/index.vue b/src/views/bpm/processInstance/create/index.vue index 49fac73e..a028b0e7 100644 --- a/src/views/bpm/processInstance/create/index.vue +++ b/src/views/bpm/processInstance/create/index.vue @@ -33,7 +33,7 @@ - +
{ 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() From caa31a67fed1c38c8ee1d000f0c3aea76187f0b6 Mon Sep 17 00:00:00 2001 From: GoldenZqqq <1361001127@qq.com> Date: Tue, 19 Nov 2024 15:54:52 +0800 Subject: [PATCH 2/6] =?UTF-8?q?feat:=20=E5=8F=91=E8=B5=B7=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=E9=A1=B5=E9=9D=A2-=E5=B7=A6=E4=BE=A7=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E5=88=97=E8=A1=A8=E5=8F=AA=E5=B1=95=E7=A4=BA=E6=9C=89?= =?UTF-8?q?=E6=B5=81=E7=A8=8B=E7=9A=84=E5=88=86=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../create/ProcessDefinitionDetail.vue | 6 +++-- .../bpm/processInstance/create/index.vue | 25 ++++++++++++++++--- 2 files changed, 25 insertions(+), 6 deletions(-) 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 a028b0e7..4253448f 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] + // 等待流程定义数据加载完成后再设置默认选中分类 + await nextTick() + // 选中第一个有流程的分类 + if (availableCategories.value.length > 0) { + categoryActive.value = availableCategories.value[0] } } finally { } @@ -261,6 +263,21 @@ const handleScroll = (e) => { 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 @@