feat: 学校管理-展开行时自动选中左侧对应区域

展开学校/年级节点时,左侧区域树自动高亮选中该学校所属的区域
This commit is contained in:
神码-方晓辉 2026-02-02 19:16:56 +08:00
parent 9820899ef7
commit d28b68ef46
1 changed files with 22 additions and 0 deletions

View File

@ -61,6 +61,7 @@
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }" :tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
:header-cell-style="{ background: '#f5f7fa', color: '#606266' }" :header-cell-style="{ background: '#f5f7fa', color: '#606266' }"
style="width: 100%" style="width: 100%"
@expand-change="handleExpandChange"
> >
<el-table-column prop="name" label="学校名称" min-width="200" show-overflow-tooltip /> <el-table-column prop="name" label="学校名称" min-width="200" show-overflow-tooltip />
<el-table-column prop="schoolCode" label="学校编码" width="130" /> <el-table-column prop="schoolCode" label="学校编码" width="130" />
@ -193,6 +194,27 @@ const handleNodeClick = (data) => {
getSchoolTree() getSchoolTree()
} }
// /
const handleExpandChange = (row, expanded) => {
if (!expanded) return //
// ID regionId/
let regionId = null
if (row.type === 'school') {
regionId = row.regionId
} else if (row.type === 'grade' || row.type === 'class') {
// treeData regionId
const school = treeData.value.find(s => s.id === row.schoolId)
regionId = school?.regionId
}
if (regionId) {
//
treeRef.value?.setCurrentKey(regionId)
selectedRegionId.value = regionId
}
}
// //
const handleQuery = () => { const handleQuery = () => {
getSchoolTree() getSchoolTree()