feat: update platform teacher management

dev-QQq
chenyuan 2 months ago
parent ad91bc0f9b
commit 9def91daf9

@ -38,40 +38,46 @@ export function deletePlatformSchool(id) {
});
}
export function getPlatformSchoolAdmins(params) {
export function getPlatformTeachers(params) {
return request({
url: "/api/platform-admin/school-admins",
url: "/api/platform-admin/teachers",
method: "get",
params,
});
}
export function getPlatformSchoolAdmin(id) {
export function getPlatformTeacher(id) {
return request({
url: `/api/platform-admin/school-admins/${id}`,
url: `/api/platform-admin/teachers/${id}`,
method: "get",
});
}
export function addPlatformSchoolAdmin(data) {
export function addPlatformTeacher(data) {
return request({
url: "/api/platform-admin/school-admins",
url: "/api/platform-admin/teachers",
method: "post",
data,
});
}
export function updatePlatformSchoolAdmin(id, data) {
export function updatePlatformTeacher(id, data) {
return request({
url: `/api/platform-admin/school-admins/${id}`,
url: `/api/platform-admin/teachers/${id}`,
method: "put",
data,
});
}
export function deletePlatformSchoolAdmin(id) {
export function deletePlatformTeacher(id) {
return request({
url: `/api/platform-admin/school-admins/${id}`,
url: `/api/platform-admin/teachers/${id}`,
method: "delete",
});
}
export const getPlatformSchoolAdmins = getPlatformTeachers;
export const getPlatformSchoolAdmin = getPlatformTeacher;
export const addPlatformSchoolAdmin = addPlatformTeacher;
export const updatePlatformSchoolAdmin = updatePlatformTeacher;
export const deletePlatformSchoolAdmin = deletePlatformTeacher;

@ -101,10 +101,10 @@ const mentList = ref([
activePrefix: "/platform-schools",
},
{
name: "学校管理员",
path: "/platform-school-admins/index",
name: "教师管理",
path: "/platform-teachers/index",
role: 1,
activePrefix: "/platform-school-admins",
activePrefix: "/platform-teachers",
},
{
name: "院系管理",

@ -525,17 +525,17 @@ export const platformAdminRoutes = [
],
},
{
path: "/platform-school-admins",
path: "/platform-teachers",
component: Layout,
redirect: "/platform-school-admins/index",
redirect: "/platform-teachers/index",
roles: ["platformAdmin"],
meta: { title: "学校管理员", icon: "用户", affix: true },
meta: { title: "教师管理", icon: "用户", affix: true },
children: [
{
path: "index",
component: () => import("@/views/platformAdmin/schoolAdmin/index.vue"),
name: "platformSchoolAdmins",
meta: { title: "学校管理员", icon: "用户", affix: true },
name: "platformTeachers",
meta: { title: "教师管理", icon: "用户", affix: true },
},
],
},

@ -4,7 +4,7 @@
<section class="admin-hero">
<div class="admin-badge">Platform Admin / Console</div>
<h1 class="admin-title">平台超管工作台</h1>
<p class="admin-subtitle">统一维护学校档案和学校管理员账号学校内部数据交给学校管理员处理</p>
<p class="admin-subtitle">统一维护学校档案和教师账号管理型老师由平台超管指定</p>
</section>
<section class="admin-panel">
<div class="quick-grid">
@ -14,10 +14,10 @@
<p>新增编辑删除学校基础信息</p>
<el-button type="primary">进入管理</el-button>
</div>
<div class="quick-card" @click="go('/platform-school-admins/index')">
<div class="quick-label">Admins</div>
<h2>学校管理员</h2>
<p>为每所学校维护 role=2 管理员账号</p>
<div class="quick-card" @click="go('/platform-teachers/index')">
<div class="quick-label">Teachers</div>
<h2>教师管理</h2>
<p>维护教师账号并指定是否为管理型老师</p>
<el-button type="primary">进入管理</el-button>
</div>
</div>

@ -1,9 +1,9 @@
<template>
<div class="school-admin-workbench">
<section class="admin-hero">
<div class="admin-badge">Platform Admin / School Admins</div>
<h1 class="admin-title">学校管理员</h1>
<p class="admin-subtitle">为学校分配管理员账号账号只能绑定到指定学校后端会固定保存为学校管理员角色</p>
<div class="admin-badge">Platform Admin / Teachers</div>
<h1 class="admin-title">教师管理</h1>
<p class="admin-subtitle">统一维护教师账号超管可指定管理型老师普通教师账号默认不具备管理权限</p>
</section>
<section class="admin-panel">
@ -25,7 +25,16 @@
<el-table-column label="所属学校" min-width="180">
<template #default="{ row }">{{ schoolName(row.schoolId) }}</template>
</el-table-column>
<el-table-column label="性别" prop="sex" width="90" />
<el-table-column label="性别" width="90">
<template #default="{ row }">{{ sexText(row.sex) }}</template>
</el-table-column>
<el-table-column label="管理型老师" width="120">
<template #default="{ row }">
<el-tag :type="row.teacherAdmin ? 'success' : 'info'" effect="dark">
{{ row.teacherAdmin ? "是" : "否" }}
</el-tag>
</template>
</el-table-column>
<el-table-column label="手机号" prop="phone" min-width="140" />
<el-table-column label="邮箱" prop="email" min-width="180" />
<el-table-column label="操作" width="160" fixed="right">
@ -48,13 +57,13 @@
<el-dialog
v-model="dialogVisible"
:title="form.userId ? '编辑学校管理员' : '新增学校管理员'"
:title="form.userId ? '编辑教师' : '新增教师'"
width="560px"
align-center
append-to-body
custom-class="admin-edit-dialog platform-admin-dialog"
>
<el-form :model="form" label-width="92px">
<el-form :model="form" label-width="112px">
<el-form-item label="所属学校">
<el-select v-model="form.schoolId" filterable placeholder="请选择学校" style="width: 100%">
<el-option v-for="school in schools" :key="school.schoolId" :label="school.schoolName" :value="school.schoolId" />
@ -66,11 +75,14 @@
<el-form-item label="账号">
<el-input v-model="form.username" :disabled="Boolean(form.userId)" />
</el-form-item>
<el-form-item label="角色">
<el-input model-value="" disabled />
</el-form-item>
<el-form-item label="性别">
<el-input v-model="form.sex" />
<el-select v-model="form.sex" placeholder="请选择性别" style="width: 100%">
<el-option label="男" value="男" />
<el-option label="女" value="女" />
</el-select>
</el-form-item>
<el-form-item label="管理型老师">
<el-switch v-model="form.teacherAdmin" active-text="" inactive-text="" />
</el-form-item>
<el-form-item label="手机号">
<el-input v-model="form.phone" />
@ -92,11 +104,11 @@
import "@/views/schoolAdmin/admin-theme.scss";
import { ElMessage, ElMessageBox } from "element-plus";
import {
addPlatformSchoolAdmin,
deletePlatformSchoolAdmin,
getPlatformSchoolAdmins,
addPlatformTeacher,
deletePlatformTeacher,
getPlatformSchools,
updatePlatformSchoolAdmin,
getPlatformTeachers,
updatePlatformTeacher,
} from "@/api/platformAdmin";
const query = reactive({ index: 1, size: 10, schoolId: "", name: "", username: "", phone: "" });
@ -111,6 +123,12 @@ const schoolName = (schoolId) => {
return schools.value.find((school) => school.schoolId === schoolId)?.schoolName || schoolId || "-";
};
const sexText = (sex) => {
if (sex === "1") return "男";
if (sex === "2") return "女";
return sex || "-";
};
const loadSchools = async () => {
const res = await getPlatformSchools({ index: 1, size: 1000 });
schools.value = res.data?.list || [];
@ -119,7 +137,7 @@ const loadSchools = async () => {
const load = async () => {
loading.value = true;
try {
const res = await getPlatformSchoolAdmins(query);
const res = await getPlatformTeachers(query);
rows.value = res.data?.list || [];
total.value = res.data?.total || 0;
} finally {
@ -142,20 +160,20 @@ const handleSizeChange = () => {
};
const openCreate = () => {
form.value = {};
form.value = { teacherAdmin: false };
dialogVisible.value = true;
};
const openEdit = (row) => {
form.value = { ...row };
form.value = { ...row, teacherAdmin: Boolean(row.teacherAdmin) };
dialogVisible.value = true;
};
const submit = async () => {
if (form.value.userId) {
await updatePlatformSchoolAdmin(form.value.userId, form.value);
await updatePlatformTeacher(form.value.userId, form.value);
} else {
await addPlatformSchoolAdmin(form.value);
await addPlatformTeacher(form.value);
}
ElMessage.success("保存成功");
dialogVisible.value = false;
@ -163,8 +181,8 @@ const submit = async () => {
};
const remove = async (row) => {
await ElMessageBox.confirm("确认删除该学校管理员?", "提示", { type: "warning" });
await deletePlatformSchoolAdmin(row.userId);
await ElMessageBox.confirm("确认删除该教师?如果教师已创建班级,将不能删除。", "提示", { type: "warning" });
await deletePlatformTeacher(row.userId);
ElMessage.success("删除成功");
load();
};

Loading…
Cancel
Save