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] =?UTF-8?q?feat:=20=E6=B5=81=E7=A8=8B=E5=8F=91=E8=B5=B7?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2-=E5=8F=B3=E4=BE=A7=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E6=BB=9A=E5=8A=A8=E5=88=B0=E5=AF=B9=E5=BA=94=E7=9A=84=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E5=8C=BA=E5=9F=9F=E5=B7=A6=E4=BE=A7=E5=88=86=E7=B1=BB?= =?UTF-8?q?active=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()