提交学生管理权限设置的代码
This commit is contained in:
1 parent
0917c7f156
commit
517a0052bc
28 files changed
+2506
-161
No files matched your search
@@ -8,7 +8,7 @@
|
||||
<el-card shadow="hover">
|
||||
<el-form :inline="true" :model="schoolSearchForm" class="search-form">
|
||||
<el-form-item label="姓名">
|
||||
<el-input v-model="schoolSearchForm.name" placeholder="请输入姓名" clearable @keyup.enter="handleSearch('school')" />
|
||||
<el-input v-model="schoolSearchForm.managerName" placeholder="请输入姓名" clearable @keyup.enter="handleSearch('school')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码">
|
||||
<el-input v-model="schoolSearchForm.phone" placeholder="请输入手机号码" clearable @keyup.enter="handleSearch('school')" />
|
||||
@@ -30,11 +30,11 @@
|
||||
</el-row>
|
||||
</template>
|
||||
<el-table :data="filteredAdmins('school')" border>
|
||||
<el-table-column prop="name" label="姓名" align="center" />
|
||||
<el-table-column prop="managerName" label="姓名" align="center" />
|
||||
<el-table-column prop="phone" label="手机号码" align="center" />
|
||||
<el-table-column prop="sex" label="性别" align="center">
|
||||
<el-table-column prop="gender" label="性别" align="center">
|
||||
<template #default="scope">
|
||||
{{ scope.row.sex === 0 ? '男' : '女' }}
|
||||
{{ scope.row.gender == 0 ? '男' : '女' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="remark" label="备注" align="center" />
|
||||
@@ -57,7 +57,7 @@
|
||||
<el-card shadow="hover">
|
||||
<el-form :inline="true" :model="customSearchForm" class="search-form">
|
||||
<el-form-item label="姓名">
|
||||
<el-input v-model="customSearchForm.name" placeholder="请输入姓名" clearable @keyup.enter="handleSearch('custom')" />
|
||||
<el-input v-model="customSearchForm.managerName" placeholder="请输入姓名" clearable @keyup.enter="handleSearch('custom')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码">
|
||||
<el-input v-model="customSearchForm.phone" placeholder="请输入手机号码" clearable @keyup.enter="handleSearch('custom')" />
|
||||
@@ -78,11 +78,11 @@
|
||||
</el-row>
|
||||
</template>
|
||||
<el-table :data="filteredAdmins('custom')" border>
|
||||
<el-table-column prop="name" label="姓名" align="center" />
|
||||
<el-table-column prop="managerName" label="姓名" align="center" />
|
||||
<el-table-column prop="phone" label="手机号码" align="center" />
|
||||
<el-table-column prop="sex" label="性别" align="center">
|
||||
<el-table-column prop="gender" label="性别" align="center">
|
||||
<template #default="scope">
|
||||
{{ scope.row.sex === 0 ? '男' : '女' }}
|
||||
{{ scope.row.gender == 0 ? '男' : '女' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="scope" label="管理范围" align="center" />
|
||||
@@ -109,7 +109,7 @@
|
||||
<el-card shadow="hover">
|
||||
<el-form :inline="true" :model="teacherSearchForm" class="search-form">
|
||||
<el-form-item label="姓名">
|
||||
<el-input v-model="teacherSearchForm.name" placeholder="请输入姓名" clearable @keyup.enter="handleSearch('teacher')" />
|
||||
<el-input v-model="teacherSearchForm.managerName" placeholder="请输入姓名" clearable @keyup.enter="handleSearch('teacher')" />
|
||||
</el-form-item>
|
||||
<el-form-item label="手机号码">
|
||||
<el-input v-model="teacherSearchForm.phone" placeholder="请输入手机号码" clearable @keyup.enter="handleSearch('teacher')" />
|
||||
@@ -122,13 +122,13 @@
|
||||
</el-card>
|
||||
</div>
|
||||
<el-card shadow="never">
|
||||
<template #header>
|
||||
<!-- <template #header>
|
||||
<el-row :gutter="10" class="mb8">
|
||||
<el-col :span="1.5">
|
||||
<el-button type="primary" plain icon="Plus" @click="onAdd('teacher')">新增班主任</el-button>
|
||||
</el-col>
|
||||
</el-row>
|
||||
</template>
|
||||
</template> -->
|
||||
<el-table :data="filteredAdmins('teacher')" border>
|
||||
<el-table-column prop="name" label="姓名" align="center" />
|
||||
<el-table-column prop="phone" label="手机号码" align="center" />
|
||||
@@ -137,9 +137,9 @@
|
||||
{{ scope.row.sex === 0 ? '男' : '女' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column prop="scope" label="所管理班级" align="center" />
|
||||
<el-table-column prop="className" label="所管理班级" align="center" />
|
||||
<el-table-column prop="remark" label="备注" align="center" />
|
||||
<el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
|
||||
<!-- <el-table-column label="操作" align="center" width="200" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="编辑" placement="top">
|
||||
<el-button link type="primary" plain icon="Edit" @click="onEdit('teacher', scope.row)" />
|
||||
@@ -151,7 +151,7 @@
|
||||
<el-button link type="danger" plain icon="Delete" @click="onDelete('teacher', scope.row)" />
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table-column> -->
|
||||
</el-table>
|
||||
</el-card>
|
||||
</el-tab-pane>
|
||||
@@ -167,19 +167,30 @@ import { ref, reactive, onMounted } 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';
|
||||
|
||||
// 暴露组件以修复导出问题
|
||||
defineExpose({});
|
||||
|
||||
// 导入改为使用模拟数据
|
||||
// import { getAdminList, deleteAdmin, assignScope, getScopeNames } from '@/api/studentMsg/authmsg';
|
||||
|
||||
const activeTab = ref('school');
|
||||
|
||||
// 各tab独立检索表单
|
||||
const schoolSearchForm = reactive({ name: '', phone: '' });
|
||||
const customSearchForm = reactive({ name: '', phone: '' });
|
||||
const teacherSearchForm = reactive({ name: '', phone: '' });
|
||||
const schoolSearchForm = reactive<StudentManagerQuery>({
|
||||
managerName: '',
|
||||
phone: '',
|
||||
managerType: '1',
|
||||
pageNum: 1,
|
||||
pageSize: 1000
|
||||
});
|
||||
const customSearchForm = reactive<StudentManagerQuery>({
|
||||
managerName: '',
|
||||
phone: '',
|
||||
managerType: '2',
|
||||
pageNum: 1,
|
||||
pageSize: 1000
|
||||
});
|
||||
const teacherSearchForm = reactive({ managerName: '', phone: '' });
|
||||
|
||||
// 管理员数据
|
||||
const schoolAdmins = ref([]);
|
||||
@@ -192,46 +203,39 @@ const currentAdmin = ref<any>(null);
|
||||
const scopeDialogVisible = ref(false);
|
||||
const scopeType = ref('');
|
||||
|
||||
// 模拟数据
|
||||
const mockData = {
|
||||
school: [
|
||||
{ id: 1, name: '张校长', phone: '13800138001', sex: 0, remark: '全校管理员' },
|
||||
{ id: 2, name: '李主任', phone: '13800138002', sex: 1, remark: '教务处负责人' }
|
||||
],
|
||||
custom: [
|
||||
{ id: 3, name: '王组长', phone: '13800138003', sex: 0, scope: '高一年级', remark: '年级组长' },
|
||||
{ id: 4, name: '赵主管', phone: '13800138004', sex: 1, scope: '高二年级', remark: '年级负责人' }
|
||||
],
|
||||
teacher: [
|
||||
{ id: 5, name: '刘老师', phone: '13800138005', sex: 0, scope: '高一(1)班', remark: '数学教师' },
|
||||
{ id: 6, name: '陈老师', phone: '13800138006', sex: 1, scope: '高一(2)班', remark: '语文教师' }
|
||||
]
|
||||
};
|
||||
// 班主任模拟数据 (预留,后续完善)
|
||||
const mockTeacherData = [
|
||||
{ id: 5, name: '刘老师', phone: '13800138005', sex: 0, scope: '高一(1)班', remark: '数学教师' },
|
||||
{ id: 6, name: '陈老师', phone: '13800138006', sex: 1, scope: '高一(2)班', remark: '语文教师' }
|
||||
];
|
||||
|
||||
// 获取管理员列表
|
||||
async function fetchAdmins(type: string) {
|
||||
// 实际项目中这里会调用API
|
||||
// 此处使用模拟数据
|
||||
try {
|
||||
// 模拟API检索过滤
|
||||
const searchForm = getSearchForm(type);
|
||||
const filteredData = mockData[type].filter((item) => {
|
||||
const nameMatch = !searchForm.name || item.name.includes(searchForm.name);
|
||||
const phoneMatch = !searchForm.phone || item.phone.includes(searchForm.phone);
|
||||
return nameMatch && phoneMatch;
|
||||
});
|
||||
|
||||
// 更新对应类型的管理员数据
|
||||
switch (type) {
|
||||
case 'school':
|
||||
schoolAdmins.value = filteredData;
|
||||
break;
|
||||
case 'custom':
|
||||
customAdmins.value = filteredData;
|
||||
break;
|
||||
case 'teacher':
|
||||
teacherAdmins.value = filteredData;
|
||||
break;
|
||||
if (type === 'school' || type === 'custom') {
|
||||
// 调用API获取全校管理员或自定义管理员数据
|
||||
const managerType = type === 'school' ? '1' : '2';
|
||||
const res = await listStudentManager({
|
||||
...searchForm,
|
||||
managerType
|
||||
});
|
||||
|
||||
// 更新对应类型的管理员数据
|
||||
if (type === 'school') {
|
||||
schoolAdmins.value = res.rows || [];
|
||||
} else {
|
||||
customAdmins.value = res.rows || [];
|
||||
}
|
||||
} else if (type === 'teacher') {
|
||||
// 通过API获取班主任数据
|
||||
const params = {
|
||||
phone: searchForm.phone,
|
||||
name: searchForm.managerName // teacherSearchForm 实际只有 managerName 字段
|
||||
};
|
||||
const res = await listActiveClassTeachers(params);
|
||||
teacherAdmins.value = res.data || [];
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取管理员列表失败:', error);
|
||||
@@ -274,17 +278,31 @@ function onEdit(type: string, admin: any) {
|
||||
|
||||
async function onDelete(type: string, admin: any) {
|
||||
// 二次确认
|
||||
ElMessageBox.confirm(`确定要删除管理员【${admin.name}】吗?`, '提示', {
|
||||
ElMessageBox.confirm(`确定要删除管理员【${admin.name || admin.managerName}】吗?`, '提示', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.then(async () => {
|
||||
try {
|
||||
// 模拟删除成功
|
||||
mockData[type] = mockData[type].filter((item) => item.id !== admin.id);
|
||||
ElMessage.success('删除成功');
|
||||
fetchAdmins(type); // 删除后刷新
|
||||
if (type === 'school' || type === 'custom') {
|
||||
// 调用删除API
|
||||
const res = await delStudentManager(admin.id);
|
||||
if (res.code === 200) {
|
||||
ElMessage.success('删除成功');
|
||||
fetchAdmins(type);
|
||||
} else {
|
||||
ElMessage.error(res.msg || '删除失败');
|
||||
}
|
||||
} else {
|
||||
// 班主任暂时使用模拟数据
|
||||
ElMessage.success('删除成功');
|
||||
mockTeacherData.splice(
|
||||
mockTeacherData.findIndex((item) => item.id === admin.id),
|
||||
1
|
||||
);
|
||||
fetchAdmins(type);
|
||||
}
|
||||
} catch (e) {
|
||||
ElMessage.error('删除失败');
|
||||
}
|
||||
@@ -301,20 +319,7 @@ function onScope(type: string, admin: any) {
|
||||
}
|
||||
|
||||
function onDialogSubmit(admin: any) {
|
||||
// 模拟添加或编辑操作
|
||||
if (dialogMode.value === 'add') {
|
||||
// 生成新ID
|
||||
const newId = Math.max(...mockData[activeTab.value].map((item) => item.id), 0) + 1;
|
||||
admin.id = newId;
|
||||
mockData[activeTab.value].push(admin);
|
||||
} else {
|
||||
// 编辑
|
||||
const index = mockData[activeTab.value].findIndex((item) => item.id === admin.id);
|
||||
if (index !== -1) {
|
||||
mockData[activeTab.value][index] = admin;
|
||||
}
|
||||
}
|
||||
|
||||
// 表单已在对话框组件内处理API调用
|
||||
// 刷新列表数据
|
||||
fetchAdmins(activeTab.value);
|
||||
dialogVisible.value = false;
|
||||
@@ -322,12 +327,7 @@ function onDialogSubmit(admin: any) {
|
||||
|
||||
async function onScopeSubmit(scope: any) {
|
||||
try {
|
||||
// 模拟分配范围
|
||||
const index = mockData[scopeType.value].findIndex((item) => item.id === currentAdmin.value.id);
|
||||
if (index !== -1) {
|
||||
mockData[scopeType.value][index].scope = scope.scopeName;
|
||||
}
|
||||
|
||||
// 范围分配已在对话框组件内处理API调用
|
||||
// 成功后刷新数据并提示
|
||||
ElMessage.success('管理范围分配成功');
|
||||
fetchAdmins(scopeType.value);
|
||||
@@ -353,6 +353,7 @@ function getListByType(type: string) {
|
||||
|
||||
// 过滤
|
||||
function filteredAdmins(type: string) {
|
||||
console.log(getListByType(type).value);
|
||||
return getListByType(type).value;
|
||||
}
|
||||
|
||||
@@ -363,15 +364,15 @@ function handleSearch(type: string) {
|
||||
function handleReset(type: string) {
|
||||
switch (type) {
|
||||
case 'school':
|
||||
schoolSearchForm.name = '';
|
||||
schoolSearchForm.managerName = '';
|
||||
schoolSearchForm.phone = '';
|
||||
break;
|
||||
case 'custom':
|
||||
customSearchForm.name = '';
|
||||
customSearchForm.managerName = '';
|
||||
customSearchForm.phone = '';
|
||||
break;
|
||||
case 'teacher':
|
||||
teacherSearchForm.name = '';
|
||||
teacherSearchForm.managerName = '';
|
||||
teacherSearchForm.phone = '';
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user