提交学习管理员的权限管理模块
This commit is contained in:
1 parent
517a0052bc
commit
dcecdbd6aa
6 files changed
+105
-55
No files matched your search
+1
-47
@@ -89,56 +89,10 @@ export const constantRoutes: RouteRecordRaw[] = [
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
path: '/xljk',
|
||||
component: Layout,
|
||||
hidden: true,
|
||||
children: [
|
||||
{
|
||||
path: 'evaluation/detail/:id',
|
||||
component: () => import('@/views/xljk/evaluation/detail.vue'),
|
||||
name: 'XljkEvaluationDetail',
|
||||
meta: { title: '心理健康测评详情', icon: 'form', activeMenu: '/xljk/evaluation' }
|
||||
},
|
||||
{
|
||||
path: 'evaluation/add',
|
||||
component: () => import('@/views/xljk/evaluation/add.vue'),
|
||||
name: 'XljkEvaluationAdd',
|
||||
meta: { title: '新增心理健康测评', icon: 'form', activeMenu: '/xljk/evaluation' }
|
||||
},
|
||||
{
|
||||
path: 'evaluation/edit/:id',
|
||||
component: () => import('@/views/xljk/evaluation/edit.vue'),
|
||||
name: 'XljkEvaluationEdit',
|
||||
meta: { title: '编辑心理健康测评', icon: 'form', activeMenu: '/xljk/evaluation' }
|
||||
},
|
||||
{
|
||||
path: 'evaluation/fill/:id',
|
||||
component: () => import('@/views/xljk/evaluation/fill.vue'),
|
||||
name: 'XljkEvaluationFill',
|
||||
meta: { title: '填写心理健康测评', icon: 'form', activeMenu: '/xljk/evaluation' }
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
|
||||
// 动态路由,基于用户权限动态去加载
|
||||
export const dynamicRoutes: RouteRecordRaw[] = [
|
||||
{
|
||||
path: '/xljk',
|
||||
component: Layout,
|
||||
name: 'Xljk',
|
||||
meta: { title: '学工管理', icon: 'education' },
|
||||
children: [
|
||||
{
|
||||
path: 'evaluation',
|
||||
component: () => import('@/views/xljk/evaluation/index.vue'),
|
||||
name: 'XljkEvaluation',
|
||||
meta: { title: '心理健康测评', icon: 'heart', permissions: ['xljk:evaluation:list'] }
|
||||
}
|
||||
]
|
||||
}
|
||||
];
|
||||
export const dynamicRoutes: RouteRecordRaw[] = [];
|
||||
|
||||
/**
|
||||
* 创建路由
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<el-input v-model="customSearchForm.phone" placeholder="请输入手机号码" clearable @keyup.enter="handleSearch('custom')" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleSearch('custom')">搜索</el-button>
|
||||
<el-button type="primary" icon="Search" @click="fetchCustomAdminsWithScope('custom')">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="handleReset('custom')">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -85,7 +85,23 @@
|
||||
{{ scope.row.gender == 0 ? '男' : '女' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="scope" label="管理范围" align="center" />
|
||||
<el-table-column prop="scope" label="管理范围" align="center">
|
||||
<template #default="scope">
|
||||
<el-tooltip
|
||||
v-if="scope.row.authSourceNames && scope.row.authSourceNames.length > 2"
|
||||
:content="scope.row.authSourceNames.join(',')"
|
||||
placement="top"
|
||||
>
|
||||
<span>
|
||||
{{ scope.row.authSourceNames.slice(0, 2).join(',')
|
||||
}}{{ scope.row.authSourceNames.length > 2 ? ' 等' + scope.row.authSourceNames.length + '个' : '' }}
|
||||
</span>
|
||||
</el-tooltip>
|
||||
<span v-else>
|
||||
{{ scope.row.authSourceNames?.join(',') || '-' }}
|
||||
</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" align="center" />
|
||||
<el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
@@ -163,12 +179,13 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { ref, reactive, onMounted, watch } from 'vue';
|
||||
import AdminDialog from './components/AdminDialog.vue';
|
||||
import ScopeDialog from './components/ScopeDialog.vue';
|
||||
import { ElMessage, ElMessageBox } from 'element-plus';
|
||||
import { listStudentManager, delStudentManager, listActiveClassTeachers } from '@/api/xgStudentManager/studentManager';
|
||||
import type { StudentManagerQuery } from '@/api/xgStudentManager/studentManager/types';
|
||||
import service from '@/utils/request';
|
||||
|
||||
// 暴露组件以修复导出问题
|
||||
defineExpose({});
|
||||
@@ -221,7 +238,6 @@ async function fetchAdmins(type: string) {
|
||||
...searchForm,
|
||||
managerType
|
||||
});
|
||||
|
||||
// 更新对应类型的管理员数据
|
||||
if (type === 'school') {
|
||||
schoolAdmins.value = res.rows || [];
|
||||
@@ -256,9 +272,34 @@ function getSearchForm(type: string) {
|
||||
}
|
||||
}
|
||||
|
||||
// 获取自定义管理员及其管理范围
|
||||
async function fetchCustomAdminsWithScope() {
|
||||
await fetchAdmins('custom');
|
||||
// 遍历 customAdmins,异步获取每个管理员的authSource
|
||||
for (const admin of customAdmins.value) {
|
||||
try {
|
||||
const res = await service({
|
||||
url: '/xgStudentManagerSource/studentManagerSource//authSourceNames',
|
||||
method: 'get',
|
||||
params: { managerId: admin.id }
|
||||
});
|
||||
admin.authSourceNames = res?.data || [];
|
||||
} catch (e) {
|
||||
admin.authSourceNames = [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 监听tab切换,切到custom时自动加载管理范围
|
||||
watch(activeTab, (val) => {
|
||||
if (val === 'custom') {
|
||||
fetchCustomAdminsWithScope();
|
||||
}
|
||||
});
|
||||
|
||||
onMounted(() => {
|
||||
fetchAdmins('school');
|
||||
fetchAdmins('custom');
|
||||
fetchCustomAdminsWithScope();
|
||||
fetchAdmins('teacher');
|
||||
});
|
||||
|
||||
@@ -321,7 +362,11 @@ function onScope(type: string, admin: any) {
|
||||
function onDialogSubmit(admin: any) {
|
||||
// 表单已在对话框组件内处理API调用
|
||||
// 刷新列表数据
|
||||
fetchAdmins(activeTab.value);
|
||||
if (activeTab.value === 'custom') {
|
||||
fetchCustomAdminsWithScope();
|
||||
} else {
|
||||
fetchAdmins(activeTab.value);
|
||||
}
|
||||
dialogVisible.value = false;
|
||||
}
|
||||
|
||||
@@ -331,6 +376,7 @@ async function onScopeSubmit(scope: any) {
|
||||
// 成功后刷新数据并提示
|
||||
ElMessage.success('管理范围分配成功');
|
||||
fetchAdmins(scopeType.value);
|
||||
fetchCustomAdminsWithScope();
|
||||
scopeDialogVisible.value = false;
|
||||
} catch (error) {
|
||||
ElMessage.error('管理范围分配失败');
|
||||
@@ -353,7 +399,9 @@ function getListByType(type: string) {
|
||||
|
||||
// 过滤
|
||||
function filteredAdmins(type: string) {
|
||||
console.log(getListByType(type).value);
|
||||
if (type === 'custom') {
|
||||
return customAdmins.value;
|
||||
}
|
||||
return getListByType(type).value;
|
||||
}
|
||||
|
||||
@@ -376,7 +424,11 @@ function handleReset(type: string) {
|
||||
teacherSearchForm.phone = '';
|
||||
break;
|
||||
}
|
||||
fetchAdmins(type);
|
||||
if (type === 'custom') {
|
||||
fetchCustomAdminsWithScope();
|
||||
} else {
|
||||
fetchAdmins(type);
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in new issue
Block a user