Skip to content

Commit 5f2e23f

Browse files
committed
feat: 流程发起页面-右侧流程滚动到对应的分类区域左侧分类active响应式变化
1 parent 6304a8e commit 5f2e23f

File tree

1 file changed

+38
-1
lines changed
  • src/views/bpm/processInstance/create

1 file changed

+38
-1
lines changed

src/views/bpm/processInstance/create/index.vue

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
</div>
3434
</el-col>
3535
<el-col :span="19">
36-
<el-scrollbar ref="scrollWrapper" height="700">
36+
<el-scrollbar ref="scrollWrapper" height="700" @scroll="handleScroll">
3737
<div
3838
class="mb-20px pl-10px"
3939
v-for="(definitions, categoryCode) in processDefinitionGroup"
@@ -220,6 +220,43 @@ const handleSelect = async (row, formVariables?) => {
220220
processDefinitionDetailRef.value?.initProcessInfo(row, formVariables)
221221
}
222222
223+
/** 处理滚动事件 */
224+
const handleScroll = (e) => {
225+
// 直接使用事件对象获取滚动位置
226+
const scrollTop = e.scrollTop
227+
228+
// 获取所有分类区域的位置信息
229+
const categoryPositions = categoryList.value
230+
.map((category) => {
231+
const categoryRef = proxy.$refs[`category-${category.code}`]
232+
if (categoryRef?.[0]) {
233+
return {
234+
code: category.code,
235+
offsetTop: categoryRef[0].offsetTop,
236+
height: categoryRef[0].offsetHeight
237+
}
238+
}
239+
return null
240+
})
241+
.filter(Boolean)
242+
243+
// 查找当前滚动位置对应的分类
244+
let currentCategory = categoryPositions[0]
245+
for (const position of categoryPositions) {
246+
// 为了更好的用户体验,可以添加一个缓冲区域(比如 50px)
247+
if (scrollTop >= position.offsetTop - 50) {
248+
currentCategory = position
249+
} else {
250+
break
251+
}
252+
}
253+
254+
// 更新当前 active 的分类
255+
if (currentCategory && categoryActive.value.code !== currentCategory.code) {
256+
categoryActive.value = categoryList.value.find((c) => c.code === currentCategory.code)
257+
}
258+
}
259+
223260
/** 初始化 */
224261
onMounted(() => {
225262
getList()

0 commit comments

Comments
 (0)