“培训申请修复v1.3”
This commit is contained in:
1 parent
53e5afaafe
commit
4fbd380a07
3 files changed
+239
-115
No files matched your search
@@ -64,6 +64,15 @@
|
||||
<!-- 右侧教师列表 -->
|
||||
<div class="teacher-panel">
|
||||
<div v-if="!selectedDeptId" class="empty-tip">请选择左侧部门查看教师列表</div>
|
||||
<div v-else-if="loading" class="empty-tip">
|
||||
<el-icon class="is-loading"><Loading /></el-icon>
|
||||
<span style="margin-left: 8px">加载中...</span>
|
||||
</div>
|
||||
<div v-else-if="permissionDenied" class="permission-denied-tip">
|
||||
<el-icon><Lock /></el-icon>
|
||||
<p>您没有权限查看该部门的教师信息</p>
|
||||
<p class="tip-desc">请联系管理员配置数据权限或选择其他部门</p>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div class="panel-header">
|
||||
<span>{{ selectedDeptName }} - 教师列表</span>
|
||||
@@ -100,7 +109,7 @@
|
||||
性别:{{ teacher.sex === '0' ? '男' : teacher.sex === '1' ? '女' : '未知' }} | 电话:{{ teacher.phonenumber || '暂无' }} | 邮箱:{{ teacher.email || '暂无' }}
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="filteredTeachers.length === 0" class="empty-tip">暂无教师数据</div>
|
||||
<div v-if="filteredTeachers.length === 0 && !permissionDenied" class="empty-tip">该部门暂无教师数据</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -118,7 +127,7 @@
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, computed, watch, onMounted, nextTick } from 'vue';
|
||||
import { Search } from '@element-plus/icons-vue';
|
||||
import { Search, Loading, Lock } from '@element-plus/icons-vue';
|
||||
import { getDeptTreeData, getTeachersByDeptId } from '@/api/system/teacher';
|
||||
import { TeacherVO, DeptTreeNode } from '@/api/system/teacher/types';
|
||||
import { ElMessage } from 'element-plus';
|
||||
@@ -152,6 +161,8 @@ const treeData = ref<DeptTreeNode[]>([]);
|
||||
const teacherList = ref<TeacherVO[]>([]);
|
||||
const selectedDeptId = ref<number | null>(null);
|
||||
const selectedDeptName = ref('');
|
||||
const loading = ref(false); // 加载状态
|
||||
const permissionDenied = ref(false); // 权限被拒标识
|
||||
|
||||
// 显示值计算
|
||||
const displayValue = computed(() => {
|
||||
@@ -230,6 +241,8 @@ const closeDialog = () => {
|
||||
selectedDeptName.value = '';
|
||||
teacherList.value = [];
|
||||
teacherSearchText.value = '';
|
||||
loading.value = false;
|
||||
permissionDenied.value = false;
|
||||
}, 300);
|
||||
};
|
||||
|
||||
@@ -290,14 +303,34 @@ const handleTreeNodeClick = async (data: DeptTreeNode) => {
|
||||
selectedDeptId.value = Number(data.id);
|
||||
selectedDeptName.value = data.label;
|
||||
teacherSearchText.value = '';
|
||||
loading.value = true;
|
||||
permissionDenied.value = false;
|
||||
|
||||
try {
|
||||
const response = await getTeachersByDeptId(Number(data.id));
|
||||
teacherList.value = response.data || [];
|
||||
} catch (error) {
|
||||
ElMessage.error('加载教师列表失败');
|
||||
|
||||
// 如果返回空列表,可能是权限问题(也可能真的没有教师)
|
||||
// 后端添加数据权限后,无权限的部门会被过滤,理论上不会出现在部门树中
|
||||
// 但为了更好的用户体验,仍然保留这个逻辑
|
||||
if (teacherList.value.length === 0) {
|
||||
console.log(`部门 ${data.label} 没有教师数据`);
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('加载教师列表失败:', error);
|
||||
|
||||
// 根据错误信息判断是否为权限问题
|
||||
const errorMsg = error?.msg || error?.message || '';
|
||||
if (error?.code === 403 || errorMsg.includes('权限') || errorMsg.includes('permission')) {
|
||||
permissionDenied.value = true;
|
||||
console.warn(`用户没有权限访问部门 ${data.label} 的教师列表`);
|
||||
} else {
|
||||
ElMessage.error('加载教师列表失败');
|
||||
}
|
||||
|
||||
teacherList.value = [];
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -424,6 +457,28 @@ onMounted(() => {
|
||||
padding: 40px 0;
|
||||
}
|
||||
|
||||
.permission-denied-tip {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.permission-denied-tip .el-icon {
|
||||
font-size: 48px;
|
||||
color: #f56c6c;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.permission-denied-tip p {
|
||||
margin: 8px 0;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.permission-denied-tip .tip-desc {
|
||||
font-size: 12px;
|
||||
color: #c0c4cc;
|
||||
}
|
||||
|
||||
.dialog-footer {
|
||||
display: flex;
|
||||
justify-content: flex-end;
|
||||
|
||||
Reference in new issue
Block a user