parent
9820899ef7
commit
d28b68ef46
|
|
@ -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()
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue