feat: 流程发起页面-右侧流程滚动到对应的分类区域左侧分类active响应式变化

pull/594/head
GoldenZqqq 2024-11-19 15:09:45 +08:00
parent 6304a8e9b6
commit 5f2e23f4da
1 changed files with 38 additions and 1 deletions

View File

@ -33,7 +33,7 @@
</div>
</el-col>
<el-col :span="19">
<el-scrollbar ref="scrollWrapper" height="700">
<el-scrollbar ref="scrollWrapper" height="700" @scroll="handleScroll">
<div
class="mb-20px pl-10px"
v-for="(definitions, categoryCode) in processDefinitionGroup"
@ -220,6 +220,43 @@ 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()