feat(teacher-end): 实现教师端亮色主题适配

1.  新增教师端亮色主题全局样式,替换原有暗色侧边栏与背景
2.  调整顶部导航栏样式,区分教师端与管理员端配色
3.  优化实训页、折线图饼图配色适配亮色主题
4.  修复弹窗下拉框样式不匹配问题,添加全局主题类标识
5.  移除教师端默认暗色模式配置,统一使用亮色风格
fix/exam-question-access-material-excel-delete-draft
qinzhenpen 3 months ago
parent 8d44538181
commit ed25afab38

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

@ -761,3 +761,6 @@ aside {
.el-table .el-table__cell { .el-table .el-table__cell {
border-radius: 0 !important; border-radius: 0 !important;
} }
/* 教师端亮色主题适配(最后导入,确保覆盖各业务页暗色 scoped 样式与全局暗色规则) */
@import "./teacher-light.scss";

@ -586,3 +586,141 @@
} }
} }
} }
/*
* 教师端亮色主题覆盖
* 取代 #app .studentLayout, #app .teacherLayout 共享的暗色背景
* 仅作用于 .teacherLayout,保留学生端原有暗黑风格
*/
#app .teacherLayout {
// 整体浅色背景 + 蓝色点缀,营造明亮的科技感
background:
radial-gradient(circle at 10% 20%, rgba(30, 136, 229, 0.07), transparent 34%),
radial-gradient(circle at 88% 8%, rgba(66, 165, 245, 0.05), transparent 28%),
linear-gradient(135deg, #f5f8fc 0%, #eaf2fb 52%, #f3f8ff 100%) !important;
.main-container {
background:
radial-gradient(circle at 10% 20%, rgba(30, 136, 229, 0.06), transparent 34%),
radial-gradient(circle at 88% 8%, rgba(66, 165, 245, 0.04), transparent 28%),
linear-gradient(135deg, #f5f8fc 0%, #eaf2fb 52%, #f3f8ff 100%) !important;
}
.app-main,
.teacher-main {
background:
radial-gradient(circle at 12% 18%, rgba(30, 136, 229, 0.05), transparent 34%),
radial-gradient(circle at 78% 6%, rgba(66, 165, 245, 0.04), transparent 28%),
linear-gradient(135deg, #f7fafd 0%, #eef4fb 48%, #f5f8fc 100%) !important;
&::-webkit-scrollbar {
width: 6px;
height: 6px;
}
&::-webkit-scrollbar-track {
background: rgba(30, 60, 100, 0.06);
border-radius: 10px;
}
&::-webkit-scrollbar-thumb {
background: rgba(30, 136, 229, 0.35);
border-radius: 10px;
&:hover {
background: rgba(30, 136, 229, 0.55);
}
}
}
// 侧边栏整体:浅色玻璃质感 + 蓝色描边
.sidebar-container {
border-right: 1px solid rgba(30, 136, 229, 0.18) !important;
background: linear-gradient(180deg, #ffffff 0%, #f3f8ff 100%) !important;
box-shadow: 4px 0 18px rgba(30, 60, 100, 0.06) !important;
&::after {
background: linear-gradient(180deg, rgba(30, 136, 229, 0.35), rgba(30, 136, 229, 0.15) 45%, rgba(30, 136, 229, 0.25)) !important;
}
// 教师端导航容器:浅色玻璃 + 蓝色描边
.student-course-nav {
background:
radial-gradient(circle at 18% 10%, rgba(30, 136, 229, 0.08), transparent 34%),
rgba(255, 255, 255, 0.7) !important;
box-shadow: inset -1px 0 0 rgba(30, 136, 229, 0.08), 8px 0 24px rgba(30, 60, 100, 0.06) !important;
backdrop-filter: blur(10px);
}
// 区块标题:深蓝色字
.student-course-heading {
color: #5a7896 !important;
&:hover,
&.active {
color: #1e88e5 !important;
}
}
// 菜单项:浅色背景 + 深色文字 + 蓝色 hover
.student-course-link {
color: #2c4a6a !important;
background: rgba(30, 136, 229, 0.04) !important;
border: 1px solid rgba(30, 136, 229, 0.1) !important;
&:hover,
&.active {
color: #1e88e5 !important;
border-color: rgba(30, 136, 229, 0.4) !important;
background: linear-gradient(95deg, rgba(30, 136, 229, 0.14), rgba(66, 165, 245, 0.06)) !important;
box-shadow: 0 4px 14px rgba(30, 136, 229, 0.16) !important;
}
&.active {
border-left: 3px solid #1e88e5 !important;
}
}
// 图标容器:浅色玻璃 + 蓝色边框
.student-course-icon {
color: #1e88e5 !important;
border-color: rgba(30, 136, 229, 0.22) !important;
background:
linear-gradient(135deg, rgba(30, 136, 229, 0.16), rgba(66, 165, 245, 0.06)),
rgba(255, 255, 255, 0.6) !important;
box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 0 8px rgba(30, 136, 229, 0.1) !important;
&--heading {
color: #1e88e5 !important;
background: rgba(30, 136, 229, 0.12) !important;
}
}
// 报告按钮(如有):浅色玻璃 + 蓝色高亮
.student-report-button {
color: #1e88e5 !important;
background: rgba(30, 136, 229, 0.1) !important;
border-color: rgba(30, 136, 229, 0.5) !important;
&:hover,
&.active {
color: #ffffff !important;
background: linear-gradient(135deg, #1e88e5, #42a5f5) !important;
box-shadow: 0 4px 14px rgba(30, 136, 229, 0.3) !important;
}
}
}
}
/*
* 教师端实训页背景覆盖
* student-training.scss 中 #app .teacherLayout .app-main:has(.student-training-shell) 使用了暗色背景
* 此处覆盖为亮色,确保实训页与教师端整体亮色主题一致
*/
#app .teacherLayout .app-main:has(.student-training-shell) {
background: linear-gradient(135deg, #f5f8fc 0%, #eaf2fb 52%, #f3f8ff 100%) !important;
}
#app .teacherLayout .app-main:has(.student-training-shell) .student-training-shell {
background: transparent !important;
}

@ -44,6 +44,11 @@
background: #06111d !important; background: #06111d !important;
} }
/* 教师端亮色主题:实训页背景改为浅色,与学生端暗黑风格区分 */
#app .teacherLayout .app-main:has(.student-training-shell) {
background: linear-gradient(135deg, #f5f8fc 0%, #eaf2fb 52%, #f3f8ff 100%) !important;
}
#app .studentLayout .app-main:has(.student-training-shell) .student-training-shell, #app .studentLayout .app-main:has(.student-training-shell) .student-training-shell,
#app .teacherLayout .app-main:has(.student-training-shell) .student-training-shell { #app .teacherLayout .app-main:has(.student-training-shell) .student-training-shell {
box-sizing: border-box !important; box-sizing: border-box !important;
@ -66,6 +71,11 @@
font-variant-numeric: tabular-nums !important; font-variant-numeric: tabular-nums !important;
} }
/* 教师端实训页容器背景改为透明,融入亮色主题 */
#app .teacherLayout .app-main:has(.student-training-shell) .student-training-shell {
background: transparent !important;
}
/* /*
* Student pages use different local names for their main and workbench cards. * Student pages use different local names for their main and workbench cards.
* Keep the layout density here so a page-specific card cannot reclaim the * Keep the layout density here so a page-specific card cannot reclaim the

File diff suppressed because it is too large Load Diff

@ -1,7 +1,7 @@
<template> <template>
<div :class="['navbar', { 'teacher-navbar': role === 3 }]"> <div :class="['navbar', { 'teacher-navbar': role === 3 }]">
<!-- 背景装饰 --> <!-- 背景装饰 -->
<svg class="nav-bg-decoration" viewBox="0 0 1920 60" preserveAspectRatio="xMidYMid slice"> <svg v-if="role !== 3" class="nav-bg-decoration" viewBox="0 0 1920 60" preserveAspectRatio="xMidYMid slice">
<defs> <defs>
<linearGradient id="navGrad" x1="0%" y1="0%" x2="100%" y2="100%"> <linearGradient id="navGrad" x1="0%" y1="0%" x2="100%" y2="100%">
<stop offset="0%" style="stop-color:#001529;stop-opacity:0.95" /> <stop offset="0%" style="stop-color:#001529;stop-opacity:0.95" />
@ -25,6 +25,23 @@
<circle cx="1500" cy="20" r="1.5" fill="#00ff9d" opacity="0.25" /> <circle cx="1500" cy="20" r="1.5" fill="#00ff9d" opacity="0.25" />
<circle cx="1800" cy="40" r="2" fill="#00aaff" opacity="0.3" /> <circle cx="1800" cy="40" r="2" fill="#00aaff" opacity="0.3" />
</svg> </svg>
<!-- 教师端亮色装饰:浅色底纹 + 蓝色点缀,保持科技感 -->
<svg v-else class="nav-bg-decoration" viewBox="0 0 1920 60" preserveAspectRatio="xMidYMid slice">
<defs>
<linearGradient id="teacherGlowLine" x1="0%" y1="0%" x2="100%" y2="0%">
<stop offset="0%" style="stop-color:#1e88e5;stop-opacity:0" />
<stop offset="50%" style="stop-color:#1e88e5;stop-opacity:0.45" />
<stop offset="100%" style="stop-color:#1e88e5;stop-opacity:0" />
</linearGradient>
</defs>
<line x1="0" y1="59" x2="1920" y2="59" stroke="url(#teacherGlowLine)" stroke-width="1" />
<circle cx="180" cy="22" r="2" fill="#1e88e5" opacity="0.25" />
<circle cx="460" cy="36" r="1.5" fill="#42a5f5" opacity="0.3" />
<circle cx="820" cy="18" r="2" fill="#1e88e5" opacity="0.2" />
<circle cx="1180" cy="32" r="1.5" fill="#42a5f5" opacity="0.28" />
<circle cx="1540" cy="24" r="2" fill="#1e88e5" opacity="0.22" />
<circle cx="1780" cy="38" r="1.5" fill="#42a5f5" opacity="0.26" />
</svg>
<div :class="[role !== 3 ? 'navTitle' : 'TnavTitle']"> <div :class="[role !== 3 ? 'navTitle' : 'TnavTitle']">
<div class="logo-area"> <div class="logo-area">
@ -55,7 +72,7 @@
</div> </div>
<div class="divider"></div> <div class="divider"></div>
<div class="avatar-container"> <div class="avatar-container">
<el-dropdown @command="handleCommand" class="right-menu-item hover-effect" trigger="click"> <el-dropdown @command="handleCommand" class="right-menu-item hover-effect" trigger="click" :popper-class="role === 3 ? 'teacher-dropdown-popper' : ''">
<div class="avatar-wrapper"> <div class="avatar-wrapper">
<div class="avatar-ring"> <div class="avatar-ring">
<img src="../../assets/images/头像.webp" class="user-avatar" /> <img src="../../assets/images/头像.webp" class="user-avatar" />
@ -297,7 +314,7 @@ onMounted(() => {
display: flex; display: flex;
align-items: center; align-items: center;
padding: 0 20px; padding: 0 20px;
background: linear-gradient(90deg, rgba(0, 60, 120, 0.5), rgba(0, 30, 60, 0.3) 60%, transparent); background: linear-gradient(90deg, rgba(30, 136, 229, 0.08), rgba(66, 165, 245, 0.04) 60%, transparent);
backdrop-filter: blur(10px); backdrop-filter: blur(10px);
.logo-area { .logo-area {
@ -306,16 +323,16 @@ onMounted(() => {
gap: 12px; gap: 12px;
.logo-icon { .logo-icon {
filter: drop-shadow(0 0 8px rgba(0, 170, 255, 0.5)); filter: drop-shadow(0 0 6px rgba(30, 136, 229, 0.35));
} }
span { span {
font-size: 15px; font-size: 15px;
font-family: var(--student-font-base); font-family: var(--student-font-base);
font-weight: 600; font-weight: 700;
color: #fff; color: #1e3a5f;
letter-spacing: 1px; letter-spacing: 1px;
text-shadow: 0 0 12px rgba(80, 200, 255, 0.4); text-shadow: none;
} }
} }
} }
@ -537,28 +554,179 @@ onMounted(() => {
} }
.teacher-navbar { .teacher-navbar {
background: linear-gradient(135deg, rgba(5, 20, 40, 0.98), rgba(10, 35, 60, 0.95)) !important; // 教师端亮色主题:浅色玻璃质感 + 蓝色点缀,保持科技感
border-bottom: 1px solid rgba(60, 192, 255, 0.2); background: linear-gradient(135deg, #ffffff 0%, #f3f8ff 50%, #eaf2fb 100%) !important;
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); border-bottom: 1px solid rgba(30, 136, 229, 0.18);
box-shadow: 0 6px 24px rgba(30, 60, 100, 0.08);
backdrop-filter: blur(20px); backdrop-filter: blur(20px);
// 菜单项:浅色文字 + 轻量描边
.el-ment {
color: #3a5a7a;
.el-ment-item {
color: #3a5a7a;
background: rgba(30, 136, 229, 0.06);
border: 1px solid rgba(30, 136, 229, 0.12);
.menu-indicator {
background: linear-gradient(90deg, transparent, #1e88e5, transparent);
}
&:hover {
color: #1e88e5;
background: rgba(30, 136, 229, 0.12);
border-color: rgba(30, 136, 229, 0.28);
.menu-indicator {
background: linear-gradient(90deg, transparent, #1e88e5, transparent);
}
}
}
.el-ment-item-active {
color: #1e88e5;
background: linear-gradient(135deg, rgba(30, 136, 229, 0.18), rgba(66, 165, 245, 0.08));
border-color: rgba(30, 136, 229, 0.4);
box-shadow: 0 4px 14px rgba(30, 136, 229, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.6);
.menu-indicator {
background: linear-gradient(90deg, transparent, #1e88e5, transparent);
}
&::before {
background: linear-gradient(90deg, transparent, rgba(30, 136, 229, 0.7), transparent);
}
}
&.teacher-nav {
.el-ment-item {
color: #3a5a7a;
background: rgba(30, 136, 229, 0.05);
border: 1px solid rgba(30, 136, 229, 0.1);
&:hover {
color: #1e88e5;
background: rgba(30, 136, 229, 0.12);
border-color: rgba(30, 136, 229, 0.28);
}
}
.el-ment-item-active {
color: #1e88e5;
background: linear-gradient(135deg, rgba(30, 136, 229, 0.2), rgba(66, 165, 245, 0.1));
border-color: rgba(30, 136, 229, 0.45);
box-shadow: 0 4px 16px rgba(30, 136, 229, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.6);
.menu-indicator {
background: linear-gradient(90deg, transparent, #1e88e5, transparent);
}
}
}
}
// 右侧区域:浅色背景渐变
.right-menu { .right-menu {
background: linear-gradient(90deg, transparent, rgba(0, 40, 80, 0.4)); background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6));
} }
.search-box { .search-box {
background: rgba(60, 180, 255, 0.08) !important; background: rgba(30, 136, 229, 0.08) !important;
border-color: rgba(60, 180, 255, 0.15) !important; border-color: rgba(30, 136, 229, 0.18) !important;
color: rgba(30, 90, 140, 0.7) !important;
&:hover {
background: rgba(30, 136, 229, 0.14) !important;
border-color: rgba(30, 136, 229, 0.32) !important;
color: #1e88e5 !important;
}
} }
.avatar-wrapper { .divider {
background: rgba(60, 180, 255, 0.08) !important; background: linear-gradient(180deg, transparent, rgba(30, 136, 229, 0.35), transparent);
border-color: rgba(60, 180, 255, 0.15) !important; }
.avatar-container .avatar-wrapper {
background: rgba(30, 136, 229, 0.08) !important;
border-color: rgba(30, 136, 229, 0.18) !important;
&:hover {
background: rgba(30, 136, 229, 0.16) !important;
border-color: rgba(30, 136, 229, 0.32) !important;
} }
.avatar-ring { .avatar-ring {
background: linear-gradient(135deg, #00aaff, #00ff9d) !important; background: linear-gradient(135deg, #1e88e5, #42a5f5) !important;
box-shadow: 0 0 12px rgba(0, 170, 255, 0.5) !important; box-shadow: 0 0 10px rgba(30, 136, 229, 0.35) !important;
}
.dropdown-icon {
color: rgba(30, 90, 140, 0.7);
}
}
}
// 教师端下拉面板:亮色玻璃质感(dropdown teleport 到 body,需使用 popper-class 选择器)
.teacher-dropdown-popper {
.dropdown-panel {
background: linear-gradient(160deg, #ffffff 0%, #f3f8ff 50%, #eaf2fb 100%);
border: 1px solid rgba(30, 136, 229, 0.25);
box-shadow: 0 15px 40px rgba(30, 60, 100, 0.18), 0 0 20px rgba(30, 136, 229, 0.08);
.dropdown-header {
background: linear-gradient(135deg, rgba(30, 136, 229, 0.1), rgba(66, 165, 245, 0.05));
border-bottom: 1px solid rgba(30, 136, 229, 0.15);
.user-info {
.user-name {
color: #1e3a5f;
}
.user-role {
color: #1e88e5;
}
}
}
.dropdown-divider {
background: linear-gradient(90deg, transparent, rgba(30, 136, 229, 0.25), transparent);
}
.dropdown-menu-custom {
.dropdown-item {
color: #3a5a7a !important;
svg {
color: rgba(30, 136, 229, 0.8);
}
&:hover {
background: linear-gradient(135deg, rgba(30, 136, 229, 0.14), rgba(66, 165, 245, 0.06)) !important;
color: #1e88e5 !important;
svg {
color: #1e88e5;
}
}
&.logout {
color: rgba(200, 80, 80, 0.85) !important;
svg {
color: rgba(220, 100, 100, 0.8);
}
&:hover {
background: linear-gradient(135deg, rgba(220, 80, 80, 0.14), rgba(200, 60, 60, 0.06)) !important;
color: #d63030 !important;
svg {
color: #d63030;
}
}
}
}
}
} }
} }

@ -1,6 +1,6 @@
<template> <template>
<div :class="classObj" class="app-wrapper" :style="{ '--current-color': theme }"> <div :class="classObj" class="app-wrapper" :style="{ '--current-color': theme }">
<div class="title" style="height: 50px; background-color: #072048 !important; z-index: 900 !important; position: relative"> <div class="title" :style="{ height: '50px', zIndex: 900, position: 'relative', backgroundColor: titleBgColor }">
<Navbar /> <Navbar />
</div> </div>
<div v-if="device === 'mobile' && sidebar.opened" class="drawer-bg" @click="handleClickOutside" /> <div v-if="device === 'mobile' && sidebar.opened" class="drawer-bg" @click="handleClickOutside" />
@ -32,6 +32,9 @@ const needTagsView = computed(() => settingsStore.tagsView);
const fixedHeader = computed(() => settingsStore.fixedHeader); const fixedHeader = computed(() => settingsStore.fixedHeader);
const useTopNavbarOnly = computed(() => role.value === 1 || role.value === 2); const useTopNavbarOnly = computed(() => role.value === 1 || role.value === 2);
// 教师端改用亮色主题:顶部标题栏使用浅色背景,与平台/学校管理员端做区分
const titleBgColor = computed(() => (role.value === 3 ? "#f5f8fc" : "#072048"));
const classObj = computed(() => ({ const classObj = computed(() => ({
hideSidebar: !sidebar.value.opened, hideSidebar: !sidebar.value.opened,
openSidebar: sidebar.value.opened, openSidebar: sidebar.value.opened,
@ -39,8 +42,6 @@ const classObj = computed(() => ({
mobile: device.value === "mobile", mobile: device.value === "mobile",
teacherLayout: role.value === 3, teacherLayout: role.value === 3,
studentLayout: role.value !== 1 && role.value !== 2 && role.value !== 3, studentLayout: role.value !== 1 && role.value !== 2 && role.value !== 3,
// 教师端启用 Element Plus 暗色模式,让所有组件弹层(date-picker、select 等)自动变暗
dark: role.value === 3,
})); }));
const { width, height } = useWindowSize(); const { width, height } = useWindowSize();
@ -66,6 +67,19 @@ const settingRef = ref(null);
function setLayout() { function setLayout() {
settingRef.value.openSetting(); settingRef.value.openSetting();
} }
// 教师端亮色模式标识:挂在 body 上,使 teleport 到 body 的弹层(下拉、日期选择器、弹窗等)也能命中亮色样式
const TEACHER_LIGHT_CLASS = "teacher-light-mode";
watchEffect(() => {
if (role.value === 3) {
document.body.classList.add(TEACHER_LIGHT_CLASS);
} else {
document.body.classList.remove(TEACHER_LIGHT_CLASS);
}
});
onBeforeUnmount(() => {
document.body.classList.remove(TEACHER_LIGHT_CLASS);
});
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

File diff suppressed because it is too large Load Diff

@ -204,15 +204,15 @@ const getIndicatorArrow = (name) => {
return map[name] || "●"; return map[name] || "●";
}; };
// 折线图配色方案 // 折线图配色方案(亮色背景:科技蓝系分类色)
const getLineColor = (index) => { const getLineColor = (index) => {
const colors = [ const colors = [
{ main: "#00d4ff", light: "#7fefff" }, { main: "#1e88e5", light: "#9cc8ef" },
{ main: "#00ff9d", light: "#7fffcc" }, { main: "#2ba471", light: "#9fd8bd" },
{ main: "#ff6b9d", light: "#ffb3c9" }, { main: "#ec6b8f", light: "#f5b8cb" },
{ main: "#ffd93d", light: "#ffea80" }, { main: "#f0a830", light: "#f8d59a" },
{ main: "#a78bfa", light: "#d4bfff" }, { main: "#7e57c2", light: "#c4b0e4" },
{ main: "#22d3ee", light: "#80efff" }, { main: "#26a69a", light: "#9fd8d1" },
]; ];
return colors[index % colors.length].main; return colors[index % colors.length].main;
}; };
@ -236,11 +236,11 @@ const getTrendData = async () => {
axisPointer: { axisPointer: {
type: "cross", type: "cross",
lineStyle: { lineStyle: {
color: "rgba(0, 212, 255, 0.3)", color: "rgba(30, 136, 229, 0.35)",
type: "dashed", type: "dashed",
}, },
crossStyle: { crossStyle: {
color: "rgba(0, 212, 255, 0.5)", color: "rgba(30, 136, 229, 0.5)",
}, },
}, },
formatter: function(params) { formatter: function(params) {
@ -271,11 +271,11 @@ const getTrendData = async () => {
data: classTime.value, data: classTime.value,
axisLine: { axisLine: {
lineStyle: { lineStyle: {
color: "rgba(0, 212, 255, 0.3)", color: "rgba(30, 136, 229, 0.25)",
}, },
}, },
axisLabel: { axisLabel: {
color: "rgba(120, 180, 220, 0.9)", color: "#6b85a3",
fontSize: 11, fontSize: 11,
margin: 12, margin: 12,
}, },
@ -289,7 +289,7 @@ const getTrendData = async () => {
max: 100, max: 100,
splitLine: { splitLine: {
lineStyle: { lineStyle: {
color: "rgba(0, 212, 255, 0.1)", color: "rgba(30, 136, 229, 0.12)",
type: "dashed", type: "dashed",
}, },
}, },
@ -297,19 +297,19 @@ const getTrendData = async () => {
show: false, show: false,
}, },
axisLabel: { axisLabel: {
color: "rgba(120, 180, 220, 0.9)", color: "#6b85a3",
fontSize: 11, fontSize: 11,
formatter: "{value}", formatter: "{value}",
}, },
}, },
series: classList.value.map((item, index) => { series: classList.value.map((item, index) => {
const colorSet = [ const colorSet = [
{ main: "#00d4ff", light: "rgba(0, 212, 255, 0.3)" }, { main: "#1e88e5", light: "rgba(30, 136, 229, 0.22)" },
{ main: "#00ff9d", light: "rgba(0, 255, 157, 0.3)" }, { main: "#2ba471", light: "rgba(43, 164, 113, 0.2)" },
{ main: "#ff6b9d", light: "rgba(255, 107, 157, 0.3)" }, { main: "#ec6b8f", light: "rgba(236, 107, 143, 0.2)" },
{ main: "#ffd93d", light: "rgba(255, 217, 61, 0.3)" }, { main: "#f0a830", light: "rgba(240, 168, 48, 0.2)" },
{ main: "#a78bfa", light: "rgba(167, 139, 250, 0.3)" }, { main: "#7e57c2", light: "rgba(126, 87, 194, 0.2)" },
{ main: "#22d3ee", light: "rgba(34, 211, 238, 0.3)" }, { main: "#26a69a", light: "rgba(38, 166, 154, 0.2)" },
][index % 6]; ][index % 6];
return { return {
...item, ...item,
@ -347,13 +347,13 @@ const getTrendData = async () => {
}); });
}; };
// 饼图配色方案 // 饼图配色方案(亮色背景:科技蓝系分类色)
const getPieColor = (index) => { const getPieColor = (index) => {
const colors = [ const colors = [
{ main: "#ff9f43", light: "rgba(255, 159, 67, 0.2)" }, { main: "#1e88e5", light: "rgba(30, 136, 229, 0.2)" },
{ main: "#26de81", light: "rgba(38, 222, 129, 0.2)" }, { main: "#26a69a", light: "rgba(38, 166, 154, 0.2)" },
{ main: "#4bcffa", light: "rgba(75, 207, 250, 0.2)" }, { main: "#7e57c2", light: "rgba(126, 87, 194, 0.2)" },
{ main: "#fc5c65", light: "rgba(252, 92, 101, 0.2)" }, { main: "#ec6b8f", light: "rgba(236, 107, 143, 0.2)" },
]; ];
return colors[index % colors.length].main; return colors[index % colors.length].main;
}; };
@ -384,7 +384,7 @@ const getStatisticsData = async () => {
itemHeight: 12, itemHeight: 12,
itemGap: 16, itemGap: 16,
textStyle: { textStyle: {
color: "rgba(150, 200, 230, 0.95)", color: "#5a7896",
fontSize: 13, fontSize: 13,
}, },
formatter: (name) => { formatter: (name) => {
@ -394,8 +394,8 @@ const getStatisticsData = async () => {
}, },
textStyle: { textStyle: {
rich: { rich: {
name: { color: "rgba(150, 200, 230, 0.95)", fontSize: 13 }, name: { color: "#5a7896", fontSize: 13 },
num: { color: "#00d4ff", fontSize: 13, fontWeight: 600 }, num: { color: "#1e88e5", fontSize: 13, fontWeight: 600 },
}, },
}, },
}, },
@ -407,7 +407,7 @@ const getStatisticsData = async () => {
avoidLabelOverlap: true, avoidLabelOverlap: true,
itemStyle: { itemStyle: {
borderRadius: 8, borderRadius: 8,
borderColor: "rgba(15, 25, 45, 0.95)", borderColor: "#ffffff",
borderWidth: 3, borderWidth: 3,
}, },
label: { label: {
@ -417,8 +417,8 @@ const getStatisticsData = async () => {
scale: true, scale: true,
scaleSize: 12, scaleSize: 12,
itemStyle: { itemStyle: {
shadowBlur: 20, shadowBlur: 16,
shadowColor: "rgba(0, 212, 255, 0.5)", shadowColor: "rgba(30, 136, 229, 0.35)",
}, },
}, },
data: circularData.value.map((item, index) => ({ data: circularData.value.map((item, index) => ({
@ -527,7 +527,6 @@ onBeforeUnmount(() => {
<style lang="scss" scoped> <style lang="scss" scoped>
// 页面主容器 // 页面主容器
.grade-center { .grade-center {
padding: 20px 24px;
min-height: calc(100vh - 96px); min-height: calc(100vh - 96px);
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -1131,7 +1130,6 @@ onBeforeUnmount(() => {
@media (max-width: 768px) { @media (max-width: 768px) {
.grade-center { .grade-center {
padding: 12px;
} }
.page-header { .page-header {

@ -11,7 +11,9 @@
<!-- 页面头部 --> <!-- 页面头部 -->
<div class="page-header"> <div class="page-header">
<div class="header-icon"> <div class="header-icon">
<el-icon><User /></el-icon> <el-icon>
<User />
</el-icon>
</div> </div>
<div class="header-content"> <div class="header-content">
<h1>学生管理</h1> <h1>学生管理</h1>
@ -23,7 +25,8 @@
<div class="query-item"> <div class="query-item">
<span class="query-label">班级:</span> <span class="query-label">班级:</span>
<el-select v-model="paramsquery.schoolClassId" placeholder="" style="width: 14rem" clearable> <el-select v-model="paramsquery.schoolClassId" placeholder="" style="width: 14rem" clearable>
<el-option v-for="school in studentClassOptions" :key="school.schoolClassId" :label="school.className" :value="school.schoolClassId" /> <el-option v-for="school in studentClassOptions" :key="school.schoolClassId"
:label="school.className" :value="school.schoolClassId" />
</el-select> </el-select>
</div> </div>
<div class="query-item"> <div class="query-item">
@ -34,47 +37,54 @@
<span class="query-label">学生学号:</span> <span class="query-label">学生学号:</span>
<el-input style="width: 14rem" v-model="paramsquery.userName" placeholder="请输入"></el-input> <el-input style="width: 14rem" v-model="paramsquery.userName" placeholder="请输入"></el-input>
<el-button @click="getList" type="primary" class="ml10"> <el-button @click="getList" type="primary" class="ml10">
<el-icon><Search /></el-icon> <el-icon>
<Search />
</el-icon>
搜索 搜索
</el-button> </el-button>
</div> </div>
<div class="btn-group"> <div class="btn-group">
<el-button type="primary" @click="addschool"> <el-button type="primary" @click="addschool">
<el-icon><Plus /></el-icon> <el-icon>
<Plus />
</el-icon>
新增 新增
</el-button> </el-button>
<el-upload action="/api/user/importTeacherStudents" :show-file-list="false" :before-upload="beforeImportStudents" :http-request="uploadStudents"> <el-upload action="/api/user/importTeacherStudents" :show-file-list="false"
:before-upload="beforeImportStudents" :http-request="uploadStudents">
<el-button type="primary"> <el-button type="primary">
<el-icon><Upload /></el-icon> <el-icon>
<Upload />
</el-icon>
导入 导入
</el-button> </el-button>
</el-upload> </el-upload>
<el-button type="warning" @click="exportTeacher"> <el-button type="warning" @click="exportTeacher">
<el-icon><Download /></el-icon> <el-icon>
<Download />
</el-icon>
导出 导出
</el-button> </el-button>
<el-button type="warning" @click="downloadTemplate"> <el-button type="warning" @click="downloadTemplate">
<el-icon><Download /></el-icon> <el-icon>
<Download />
</el-icon>
模板下载 模板下载
</el-button> </el-button>
<el-button type="primary" @click="refresh"> <el-button type="primary" @click="refresh">
<el-icon><Refresh /></el-icon> <el-icon>
<Refresh />
</el-icon>
刷新 刷新
</el-button> </el-button>
</div> </div>
</div> </div>
<el-table <el-table :data="tableData" border v-loading="loading" style="width: 100%" :header-cell-style="{
:data="tableData"
border
v-loading="loading"
style="width: 100%"
:header-cell-style="{
color: '#fff', color: '#fff',
fontSize: '14px', fontSize: '14px',
fontWeight: '600', fontWeight: '600',
background: 'linear-gradient(135deg, #0099cc 0%, #006699 100%)', background: 'linear-gradient(135deg, #0099cc 0%, #006699 100%)',
}" }">
>
<el-table-column label="所属班级" prop="className" align="center"></el-table-column> <el-table-column label="所属班级" prop="className" align="center"></el-table-column>
<el-table-column label="学生姓名" prop="name" align="center"></el-table-column> <el-table-column label="学生姓名" prop="name" align="center"></el-table-column>
<el-table-column label="学号" prop="username" align="center"></el-table-column> <el-table-column label="学号" prop="username" align="center"></el-table-column>
@ -88,51 +98,71 @@
<template #default="{ row }"> <template #default="{ row }">
<div class="action-group"> <div class="action-group">
<el-button type="primary" @click="editSchool(row)"> <el-button type="primary" @click="editSchool(row)">
<el-icon><Edit /></el-icon> <el-icon>
<Edit />
</el-icon>
编辑 编辑
</el-button> </el-button>
<el-button type="danger" @click="delSchool(row)"> <el-button type="danger" @click="delSchool(row)">
<el-icon><Delete /></el-icon> <el-icon>
<Delete />
</el-icon>
删除 删除
</el-button> </el-button>
<el-button type="success" @click="initPassword(row, 0)"> <el-button type="success" @click="initPassword(row, 0)">
<el-icon><Lock /></el-icon> <el-icon>
<Lock />
</el-icon>
密码初始化 密码初始化
</el-button> </el-button>
<el-button type="warning" @click="initPassword(row, 1)"> <el-button type="warning" @click="initPassword(row, 1)">
<el-icon><Refresh /></el-icon> <el-icon>
<Refresh />
</el-icon>
数据初始化 数据初始化
</el-button> </el-button>
</div> </div>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
<pagination v-show="schoolTotal > 0" :total="schoolTotal" v-model:page="paramsquery.index" v-model:limit="paramsquery.size" @pagination="getList" /> <pagination v-show="schoolTotal > 0" :total="schoolTotal" v-model:page="paramsquery.index"
<el-dialog v-model="dialogVisible" width="560px" :title="status ? '新增学生' : '编辑学生'" class="teacher-dialog" @close="onClose"> v-model:limit="paramsquery.size" @pagination="getList" />
<el-form :model="formInline" class="demo-form-inline" ref="formInlineref" label-width="100px" style="width: 80%" :rules="studentFormRules"> <el-dialog v-model="dialogVisible" width="560px" :title="status ? '新增学生' : '编辑学生'" class="teacher-dialog"
@close="onClose">
<el-form :model="formInline" class="demo-form-inline" ref="formInlineref" label-width="100px"
style="width: 80%" :rules="studentFormRules">
<template v-if="!isTeacherRosterMode"> <template v-if="!isTeacherRosterMode">
<el-form-item label="所属院系:" prop="schoolFacultyId"> <el-form-item label="所属院系:" prop="schoolFacultyId">
<el-select v-model="formInline.schoolFacultyId" placeholder="" clearable @change="getMajorList" style="width: 20rem" v-if="status"> <el-select v-model="formInline.schoolFacultyId" placeholder="" clearable @change="getMajorList"
<el-option v-for="school in facultyList" :key="school.schoolId" :label="school.schoolFacultyName" :value="school.schoolFacultyId" /> style="width: 20rem" v-if="status">
<el-option v-for="school in facultyList" :key="school.schoolId"
:label="school.schoolFacultyName" :value="school.schoolFacultyId" />
</el-select> </el-select>
<el-input v-else v-model="classInfo.name" style="width: 20rem" disabled></el-input> <el-input v-else v-model="classInfo.name" style="width: 20rem" disabled></el-input>
</el-form-item> </el-form-item>
<el-form-item label="所属专业:" prop="schoolMajorId"> <el-form-item label="所属专业:" prop="schoolMajorId">
<el-select v-model="formInline.schoolMajorId" placeholder="" clearable style="width: 20rem" v-if="status" @change="getClassByMajor"> <el-select v-model="formInline.schoolMajorId" placeholder="" clearable style="width: 20rem"
<el-option v-for="major in majorList" :key="major.schoolMajorId" :label="major.schoolMajorName" :value="major.schoolMajorId" /> v-if="status" @change="getClassByMajor">
<el-option v-for="major in majorList" :key="major.schoolMajorId"
:label="major.schoolMajorName" :value="major.schoolMajorId" />
</el-select> </el-select>
<el-input v-else v-model="classInfo.value" placeholder="请输入所属专业:" style="width: 20rem" disabled></el-input> <el-input v-else v-model="classInfo.value" placeholder="请输入所属专业:" style="width: 20rem"
disabled></el-input>
</el-form-item> </el-form-item>
<el-form-item label="所属班级:" prop="schoolClassId"> <el-form-item label="所属班级:" prop="schoolClassId">
<el-select v-model="formInline.schoolClassId" placeholder="" clearable style="width: 20rem" v-if="status"> <el-select v-model="formInline.schoolClassId" placeholder="" clearable style="width: 20rem"
<el-option v-for="major in classList1" :key="major.schoolClassId" :label="major.className" :value="major.schoolClassId" /> v-if="status">
<el-option v-for="major in classList1" :key="major.schoolClassId" :label="major.className"
:value="major.schoolClassId" />
</el-select> </el-select>
<el-input v-else v-model="classInfo.className" placeholder="请输入所属班级:" style="width: 20rem" disabled></el-input> <el-input v-else v-model="classInfo.className" placeholder="请输入所属班级:" style="width: 20rem"
disabled></el-input>
</el-form-item> </el-form-item>
</template> </template>
<el-form-item v-if="isTeacherRosterMode" label="所属教学班:" prop="teachingClassId"> <el-form-item v-if="isTeacherRosterMode" label="所属教学班:" prop="teachingClassId">
<el-select v-model="formInline.teachingClassId" placeholder="请选择教学班" clearable style="width: 20rem"> <el-select v-model="formInline.teachingClassId" placeholder="请选择教学班" clearable style="width: 20rem">
<el-option v-for="schoolClass in teachingClassOptions" :key="schoolClass.schoolClassId" :label="schoolClass.className" :value="schoolClass.schoolClassId" /> <el-option v-for="schoolClass in teachingClassOptions" :key="schoolClass.schoolClassId"
:label="schoolClass.className" :value="schoolClass.schoolClassId" />
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="学生姓名:" prop="name"> <el-form-item label="学生姓名:" prop="name">
@ -152,19 +182,19 @@
</div> </div>
</template> </template>
<script setup> <script setup>
import { Search, Plus, Refresh, Edit, Delete, Lock } from "@element-plus/icons-vue"; import { Search, Plus, Refresh, Edit, Delete, Lock } from "@element-plus/icons-vue"
import { formatDate } from "@/utils/index"; import { formatDate } from "@/utils/index"
import { ElMessageBox } from "element-plus"; import { ElMessageBox } from "element-plus"
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance()
import useUserStore from "@/store/modules/user"; import useUserStore from "@/store/modules/user"
const userStore = useUserStore(); const userStore = useUserStore()
const currentUserId = computed(() => userStore.userInfo.userId); const currentUserId = computed(() => userStore.userInfo.userId)
const currentSchoolId = computed(() => userStore.userInfo.schoolId); const currentSchoolId = computed(() => userStore.userInfo.schoolId)
const isTeacherRosterMode = computed(() => userStore.schoolProductConfig?.studentRosterOwner === "TEACHER"); const isTeacherRosterMode = computed(() => userStore.schoolProductConfig?.studentRosterOwner === "TEACHER")
const isManagerTeacher = computed(() => userStore.userInfo.teacherAdmin === true); const isManagerTeacher = computed(() => userStore.userInfo.teacherAdmin === true)
import * as indexApi from "@/api/teacher"; import * as indexApi from "@/api/teacher"
const dialogVisible = ref(false); const dialogVisible = ref(false)
const loading = ref(false); const loading = ref(false)
const formInline = ref({ const formInline = ref({
schoolFacultyId: "", schoolFacultyId: "",
schoolId: userStore.userInfo.schoolId, schoolId: userStore.userInfo.schoolId,
@ -174,7 +204,7 @@ const formInline = ref({
teachingClassId: "", teachingClassId: "",
schoolName: "", schoolName: "",
userName: "", userName: "",
}); })
const createEmptyForm = () => ({ const createEmptyForm = () => ({
schoolFacultyId: "", schoolFacultyId: "",
schoolId: currentSchoolId.value, schoolId: currentSchoolId.value,
@ -185,189 +215,189 @@ const createEmptyForm = () => ({
schoolName: "", schoolName: "",
userName: "", userName: "",
name: "", name: "",
}); })
const organizationRules = { const organizationRules = {
schoolFacultyId: [{ required: true, message: "请选择所属院系", trigger: "change" }], schoolFacultyId: [{ required: true, message: "请选择所属院系", trigger: "change" }],
schoolMajorId: [{ required: true, message: "请选择所属专业", trigger: "change" }], schoolMajorId: [{ required: true, message: "请选择所属专业", trigger: "change" }],
schoolClassId: [{ required: true, message: "请选择所属班级", trigger: "change" }], schoolClassId: [{ required: true, message: "请选择所属班级", trigger: "change" }],
}; }
const studentIdentityRules = { const studentIdentityRules = {
name: [{ required: true, message: "请输入学生姓名", trigger: "blur" }], name: [{ required: true, message: "请输入学生姓名", trigger: "blur" }],
userName: [{ required: true, message: "请输入学号", trigger: "blur" }], userName: [{ required: true, message: "请输入学号", trigger: "blur" }],
}; }
const teacherRosterRules = { const teacherRosterRules = {
...studentIdentityRules, ...studentIdentityRules,
teachingClassId: [{ required: true, message: "请选择所属教学班", trigger: "change" }], teachingClassId: [{ required: true, message: "请选择所属教学班", trigger: "change" }],
}; }
const studentFormRules = computed(() => (isTeacherRosterMode.value ? teacherRosterRules : { ...organizationRules, ...studentIdentityRules })); const studentFormRules = computed(() => (isTeacherRosterMode.value ? teacherRosterRules : { ...organizationRules, ...studentIdentityRules }))
const paramsquery = ref({ const paramsquery = ref({
index: 1, index: 1,
size: 10, size: 10,
schoolId: userStore.userInfo.schoolId, schoolId: userStore.userInfo.schoolId,
}); })
const classInfo = ref({}); const classInfo = ref({})
const schoolTotal = ref(0); const schoolTotal = ref(0)
function buildStudentImportFormData(file) { function buildStudentImportFormData(file) {
const formData = new FormData(); const formData = new FormData()
formData.append("file", file); formData.append("file", file)
formData.append("operatorId", currentUserId.value); formData.append("operatorId", currentUserId.value)
return formData; return formData
} }
// 新增编辑状态 // 新增编辑状态
const status = ref(false); const status = ref(false)
// 院校list // 院校list
const tableData = ref([]); const tableData = ref([])
// 获取院校列表 // 获取院校列表
const getList = () => { const getList = () => {
indexApi.getStudentList({ ...paramsquery.value, operatorId: currentUserId.value }).then((res) => { indexApi.getStudentList({ ...paramsquery.value, operatorId: currentUserId.value }).then((res) => {
tableData.value = res.data.list; tableData.value = res.data.list
schoolTotal.value = res.data.total; schoolTotal.value = res.data.total
}); })
}; }
// 删除院校 // 删除院校
const delSchool = (id) => { const delSchool = (id) => {
indexApi.deleteStudent({ userId: id.userId, operatorId: currentUserId.value, teachingClassId: resolveRowTeachingClassId(id) }).then((res) => { indexApi.deleteStudent({ userId: id.userId, operatorId: currentUserId.value, teachingClassId: resolveRowTeachingClassId(id) }).then((res) => {
proxy.$message.success("删除成功"); proxy.$message.success("删除成功")
getList(); getList()
}); })
}; }
// 新增院校 // 新增院校
const addschool = () => { const addschool = () => {
formInline.value = createEmptyForm(); formInline.value = createEmptyForm()
classInfo.value = {}; classInfo.value = {}
classList1.value = []; classList1.value = []
dialogVisible.value = true; dialogVisible.value = true
status.value = true; status.value = true
}; }
const editSchool = (row) => { const editSchool = (row) => {
console.log(row); console.log(row)
let data = { ...row }; let data = { ...row }
formInline.value = data; formInline.value = data
formInline.value.userName = row.username; formInline.value.userName = row.username
formInline.value.teachingClassId = isTeacherRosterMode.value ? row.teachingClassId || currentTeachingClassId() : ""; formInline.value.teachingClassId = isTeacherRosterMode.value ? row.teachingClassId || currentTeachingClassId() : ""
classInfo.value = { classInfo.value = {
className: row.className || row.schoolClassName || "", className: row.className || row.schoolClassName || "",
}; }
dialogVisible.value = true; dialogVisible.value = true
status.value = false; status.value = false
if (!isTeacherRosterMode.value && row.schoolMajorId) { if (!isTeacherRosterMode.value && row.schoolMajorId) {
indexApi.getFacultyAndMajorName({ schoolMajorId: row.schoolMajorId }).then((res) => { indexApi.getFacultyAndMajorName({ schoolMajorId: row.schoolMajorId }).then((res) => {
classInfo.value.name = Object.keys(res.data)[0]; classInfo.value.name = Object.keys(res.data)[0]
classInfo.value.value = Object.values(res.data)[0]; classInfo.value.value = Object.values(res.data)[0]
}); })
} }
}; }
const add = () => { const add = () => {
formInline.value.schoolId = currentSchoolId.value; formInline.value.schoolId = currentSchoolId.value
formInline.value.operatorId = currentUserId.value; formInline.value.operatorId = currentUserId.value
if (isTeacherRosterMode.value) { if (isTeacherRosterMode.value) {
indexApi.addTeacherRosterStudent(formInline.value).then((res) => { indexApi.addTeacherRosterStudent(formInline.value).then((res) => {
proxy.$message.success("添加成功"); proxy.$message.success("添加成功")
dialogVisible.value = false; dialogVisible.value = false
getList(); getList()
}); })
return; return
} }
formInline.value.schoolMajorName = majorList.value?.filter((item) => item.schoolMajorId == formInline.value.schoolMajorId)[0].schoolMajorName; formInline.value.schoolMajorName = majorList.value?.filter((item) => item.schoolMajorId == formInline.value.schoolMajorId)[0].schoolMajorName
formInline.value.schoolClassName = classList1.value?.filter((item) => item.schoolClassId == formInline.value.schoolClassId)[0].className; formInline.value.schoolClassName = classList1.value?.filter((item) => item.schoolClassId == formInline.value.schoolClassId)[0].className
formInline.value.userId = currentUserId.value; formInline.value.userId = currentUserId.value
indexApi.addStudent(formInline.value).then((res) => { indexApi.addStudent(formInline.value).then((res) => {
proxy.$message.success("添加成功"); proxy.$message.success("添加成功")
dialogVisible.value = false; dialogVisible.value = false
getList(); getList()
}); })
}; }
const edit = () => { const edit = () => {
formInline.value.status = true; formInline.value.status = true
formInline.value.operatorId = currentUserId.value; formInline.value.operatorId = currentUserId.value
if (isTeacherRosterMode.value) { if (isTeacherRosterMode.value) {
indexApi.updateTeacherRosterStudent(formInline.value).then((res) => { indexApi.updateTeacherRosterStudent(formInline.value).then((res) => {
proxy.$message.success("编辑成功"); proxy.$message.success("编辑成功")
dialogVisible.value = false; dialogVisible.value = false
getList(); getList()
}); })
return; return
} }
formInline.value.teachingClassId = currentTeachingClassId(); formInline.value.teachingClassId = currentTeachingClassId()
indexApi.updateStudent(formInline.value).then((res) => { indexApi.updateStudent(formInline.value).then((res) => {
proxy.$message.success("编辑成功"); proxy.$message.success("编辑成功")
dialogVisible.value = false; dialogVisible.value = false
getList(); getList()
}); })
}; }
// 提交 // 提交
const submitForm = () => { const submitForm = () => {
proxy.$refs.formInlineref.validate((valid) => { proxy.$refs.formInlineref.validate((valid) => {
if (valid) { if (valid) {
status.value ? add() : edit(); status.value ? add() : edit()
} else { } else {
return false; return false
} }
}); })
}; }
const onClose = () => { const onClose = () => {
formInline.value = createEmptyForm(); formInline.value = createEmptyForm()
classInfo.value = {}; classInfo.value = {}
classList1.value = []; classList1.value = []
dialogVisible.value = false; dialogVisible.value = false
}; }
// 刷新 // 刷新
const refresh = () => { const refresh = () => {
loading.value = true; loading.value = true
setTimeout(() => { setTimeout(() => {
loading.value = false; loading.value = false
getList(); getList()
}, 2000); }, 2000)
}; }
// 查询院系下拉列表 // 查询院系下拉列表
const facultyList = ref([]); const facultyList = ref([])
const getFacultyList = () => { const getFacultyList = () => {
indexApi.seleteSchoolFacultyList({ schoolId: userStore.userInfo.schoolId }).then((res) => { indexApi.seleteSchoolFacultyList({ schoolId: userStore.userInfo.schoolId }).then((res) => {
facultyList.value = res.data; facultyList.value = res.data
}); })
}; }
// 专业下拉框 // 专业下拉框
const majorList = ref([]); const majorList = ref([])
const getMajorList = () => { const getMajorList = () => {
if (!formInline.value.schoolFacultyId) return; if (!formInline.value.schoolFacultyId) return
paramsquery.value.schoolMajorId = ""; paramsquery.value.schoolMajorId = ""
indexApi.getMajorListBySchoolId({ schoolFacultyId: formInline.value.schoolFacultyId }).then((res) => { indexApi.getMajorListBySchoolId({ schoolFacultyId: formInline.value.schoolFacultyId }).then((res) => {
majorList.value = res.data; majorList.value = res.data
}); })
}; }
const uploadStudents = (options) => { const uploadStudents = (options) => {
if (isTeacherRosterMode.value) { if (isTeacherRosterMode.value) {
const formData = new FormData(); const formData = new FormData()
formData.append("file", options.file); formData.append("file", options.file)
return indexApi.importTeacherRosterStudents(formData).then((res) => { return indexApi.importTeacherRosterStudents(formData).then((res) => {
handleSuccess(res); handleSuccess(res)
}); })
} }
const formData = buildStudentImportFormData(options.file); const formData = buildStudentImportFormData(options.file)
return indexApi.importTeacherStudents(formData).then((res) => { return indexApi.importTeacherStudents(formData).then((res) => {
handleSuccess(res); handleSuccess(res)
}); })
}; }
const handleSuccess = (res, file) => { const handleSuccess = (res, file) => {
if (res?.statusCode && res.statusCode !== "OK" && res.statusCode !== 200) { if (res?.statusCode && res.statusCode !== "OK" && res.statusCode !== 200) {
proxy.$message.error(res?.message || "导入失败"); proxy.$message.error(res?.message || "导入失败")
return; return
} }
getList(); getList()
proxy.$modal.msgSuccess("导入成功"); proxy.$modal.msgSuccess("导入成功")
}; }
// 导出教师账号 // 导出教师账号
const exportTeacher = () => { const exportTeacher = () => {
indexApi.exportStudentList({ schoolId: userStore.userInfo.schoolId, operatorId: currentUserId.value, schoolClassId: currentTeachingClassId() }).then((res) => { indexApi.exportStudentList({ schoolId: userStore.userInfo.schoolId, operatorId: currentUserId.value, schoolClassId: currentTeachingClassId() }).then((res) => {
const blob = new Blob([res], { type: "application/vnd.ms-excel" }); const blob = new Blob([res], { type: "application/vnd.ms-excel" })
const url = URL.createObjectURL(blob); const url = URL.createObjectURL(blob)
const link = document.createElement("a"); const link = document.createElement("a")
link.href = url; link.href = url
link.setAttribute("download", "学生信息表格.xlsx"); link.setAttribute("download", "学生信息表格.xlsx")
link.click(); link.click()
URL.revokeObjectURL(url); URL.revokeObjectURL(url)
}); })
}; }
// 导入模版下载 // 导入模版下载
const buildOwnedAdminClassRows = async () => { const buildOwnedAdminClassRows = async () => {
const majorGroups = await Promise.all( const majorGroups = await Promise.all(
@ -377,90 +407,90 @@ const buildOwnedAdminClassRows = async () => {
.then((res) => (res.data || []).map((major) => ({ ...major, schoolFacultyName: faculty.schoolFacultyName }))) .then((res) => (res.data || []).map((major) => ({ ...major, schoolFacultyName: faculty.schoolFacultyName })))
.catch(() => []), .catch(() => []),
), ),
); )
const allMajors = majorGroups.flat(); const allMajors = majorGroups.flat()
return classList.value return classList.value
.filter((item) => canUseAdminClassForStudent(item)) .filter((item) => canUseAdminClassForStudent(item))
.map((item) => { .map((item) => {
const major = allMajors.find((majorItem) => majorItem.schoolMajorId === item.schoolMajorId) || majorList.value.find((majorItem) => majorItem.schoolMajorId === item.schoolMajorId); const major = allMajors.find((majorItem) => majorItem.schoolMajorId === item.schoolMajorId) || majorList.value.find((majorItem) => majorItem.schoolMajorId === item.schoolMajorId)
const faculty = facultyList.value.find((facultyItem) => facultyItem.schoolFacultyId === (major?.schoolFacultyId || item.schoolFacultyId)); const faculty = facultyList.value.find((facultyItem) => facultyItem.schoolFacultyId === (major?.schoolFacultyId || item.schoolFacultyId))
return [faculty?.schoolFacultyName || item.schoolFacultyName || "", major?.schoolMajorName || item.schoolMajorName || "", item.className || ""]; return [faculty?.schoolFacultyName || item.schoolFacultyName || "", major?.schoolMajorName || item.schoolMajorName || "", item.className || ""]
}) })
.filter((row) => row.every(Boolean)); .filter((row) => row.every(Boolean))
}; }
const downloadTemplate = async () => { const downloadTemplate = async () => {
const XLSX = await import("xlsx"); const XLSX = await import("xlsx")
if (isTeacherRosterMode.value) { if (isTeacherRosterMode.value) {
const exampleClassName = teachingClassOptions.value[0]?.className || "教学一班"; const exampleClassName = teachingClassOptions.value[0]?.className || "教学一班"
const templateSheet = XLSX.utils.aoa_to_sheet([ const templateSheet = XLSX.utils.aoa_to_sheet([
["学生姓名", "学号", "班级"], ["学生姓名", "学号", "班级"],
["张三", "20260001", exampleClassName], ["张三", "20260001", exampleClassName],
]); ])
templateSheet["!cols"] = [{ wch: 16 }, { wch: 18 }, { wch: 20 }]; templateSheet["!cols"] = [{ wch: 16 }, { wch: 18 }, { wch: 20 }]
const workbook = XLSX.utils.book_new(); const workbook = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(workbook, templateSheet, "学生导入模板"); XLSX.utils.book_append_sheet(workbook, templateSheet, "学生导入模板")
XLSX.writeFile(workbook, "学生账号导入模板.xlsx"); XLSX.writeFile(workbook, "学生账号导入模板.xlsx")
return; return
} }
const adminClassRows = await buildOwnedAdminClassRows(); const adminClassRows = await buildOwnedAdminClassRows()
const firstAdminClass = adminClassRows[0] || ["电子商务学院", "电子商务", "行政一班"]; const firstAdminClass = adminClassRows[0] || ["电子商务学院", "电子商务", "行政一班"]
const templateSheet = XLSX.utils.aoa_to_sheet([ const templateSheet = XLSX.utils.aoa_to_sheet([
["姓名", "学号", "性别", "所属院系", "所属专业", "所属班级"], ["姓名", "学号", "性别", "所属院系", "所属专业", "所属班级"],
["张三", "20260001", "男", firstAdminClass[0], firstAdminClass[1], firstAdminClass[2]], ["张三", "20260001", "男", firstAdminClass[0], firstAdminClass[1], firstAdminClass[2]],
]); ])
templateSheet["!cols"] = [{ wch: 14 }, { wch: 18 }, { wch: 10 }, { wch: 24 }, { wch: 24 }, { wch: 20 }]; templateSheet["!cols"] = [{ wch: 14 }, { wch: 18 }, { wch: 10 }, { wch: 24 }, { wch: 24 }, { wch: 20 }]
const dataRows = adminClassRows.length ? adminClassRows : [["暂无可导入行政班", "请先维护专业", "请先创建行政班"]]; const dataRows = adminClassRows.length ? adminClassRows : [["暂无可导入行政班", "请先维护专业", "请先创建行政班"]]
const dataSheet = XLSX.utils.aoa_to_sheet([["所属院系", "所属专业", "所属班级"], ...dataRows]); const dataSheet = XLSX.utils.aoa_to_sheet([["所属院系", "所属专业", "所属班级"], ...dataRows])
dataSheet["!cols"] = [{ wch: 28 }, { wch: 28 }, { wch: 24 }]; dataSheet["!cols"] = [{ wch: 28 }, { wch: 28 }, { wch: 24 }]
const guideSheet = XLSX.utils.aoa_to_sheet([["填写说明"], ["1. 本模板用于学生账号导入,不要填写任何数据ID。"], ["2. 所属院系、所属专业、所属班级请使用基础数据页中的名称。"], ["3. 只能导入本校行政班,不能导入教学班或其他学校的班级。"], ["4. 性别可填写男、女,也可留空。"], ["5. 任意一行校验失败时,整批导入失败并返回失败原因。"]]); const guideSheet = XLSX.utils.aoa_to_sheet([["填写说明"], ["1. 本模板用于学生账号导入,不要填写任何数据ID。"], ["2. 所属院系、所属专业、所属班级请使用基础数据页中的名称。"], ["3. 只能导入本校行政班,不能导入教学班或其他学校的班级。"], ["4. 性别可填写男、女,也可留空。"], ["5. 任意一行校验失败时,整批导入失败并返回失败原因。"]])
guideSheet["!cols"] = [{ wch: 76 }]; guideSheet["!cols"] = [{ wch: 76 }]
const workbook = XLSX.utils.book_new(); const workbook = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(workbook, templateSheet, "学生导入模板"); XLSX.utils.book_append_sheet(workbook, templateSheet, "学生导入模板")
XLSX.utils.book_append_sheet(workbook, dataSheet, "基础数据"); XLSX.utils.book_append_sheet(workbook, dataSheet, "基础数据")
XLSX.utils.book_append_sheet(workbook, guideSheet, "填写说明"); XLSX.utils.book_append_sheet(workbook, guideSheet, "填写说明")
XLSX.writeFile(workbook, "学生账号导入模板.xlsx"); XLSX.writeFile(workbook, "学生账号导入模板.xlsx")
}; }
const classList = ref([]); const classList = ref([])
const normalizeClassType = (schoolClass) => { const normalizeClassType = (schoolClass) => {
if (schoolClass?.classType) return schoolClass.classType; if (schoolClass?.classType) return schoolClass.classType
return schoolClass?.createdBy ? "TEACHING" : "ADMIN"; return schoolClass?.createdBy ? "TEACHING" : "ADMIN"
}; }
const sameValue = (left, right) => String(left || "") === String(right || ""); const sameValue = (left, right) => String(left || "") === String(right || "")
const canUseAdminClassForStudent = (schoolClass) => { const canUseAdminClassForStudent = (schoolClass) => {
if (normalizeClassType(schoolClass) !== "ADMIN") return false; if (normalizeClassType(schoolClass) !== "ADMIN") return false
return !schoolClass?.schoolId || sameValue(schoolClass.schoolId, currentSchoolId.value); return !schoolClass?.schoolId || sameValue(schoolClass.schoolId, currentSchoolId.value)
}; }
const classMap = computed(() => new Map(classList.value.map((item) => [item.schoolClassId, item]))); const classMap = computed(() => new Map(classList.value.map((item) => [item.schoolClassId, item])))
const teachingClassOptions = computed(() => classList.value.filter((schoolClass) => normalizeClassType(schoolClass) === "TEACHING" && sameValue(schoolClass.schoolId, currentSchoolId.value) && (isManagerTeacher.value || sameValue(schoolClass.createdBy, currentUserId.value)))); const teachingClassOptions = computed(() => classList.value.filter((schoolClass) => normalizeClassType(schoolClass) === "TEACHING" && sameValue(schoolClass.schoolId, currentSchoolId.value) && (isManagerTeacher.value || sameValue(schoolClass.createdBy, currentUserId.value))))
const studentClassOptions = computed(() => teachingClassOptions.value); const studentClassOptions = computed(() => teachingClassOptions.value)
const currentTeachingClassId = () => { const currentTeachingClassId = () => {
const selectedClass = classMap.value.get(paramsquery.value.schoolClassId); const selectedClass = classMap.value.get(paramsquery.value.schoolClassId)
return selectedClass && normalizeClassType(selectedClass) === "TEACHING" ? selectedClass.schoolClassId : ""; return selectedClass && normalizeClassType(selectedClass) === "TEACHING" ? selectedClass.schoolClassId : ""
}; }
const resolveRowTeachingClassId = (row) => currentTeachingClassId() || row?.teachingClassId || ""; const resolveRowTeachingClassId = (row) => currentTeachingClassId() || row?.teachingClassId || ""
const beforeImportStudents = (file) => { const beforeImportStudents = (file) => {
if (!/\.(xls|xlsx)$/i.test(file.name)) { if (!/\.(xls|xlsx)$/i.test(file.name)) {
proxy.$message.warning("请选择xls或xlsx格式文件"); proxy.$message.warning("请选择xls或xlsx格式文件")
return false; return false
} }
return true; return true
}; }
const getClassList = () => { const getClassList = () => {
indexApi.getClassListBySchoolId({ schoolId: userStore.userInfo.schoolId }).then((res) => { indexApi.getClassListBySchoolId({ schoolId: userStore.userInfo.schoolId }).then((res) => {
classList.value = res.data; classList.value = res.data
}); })
}; }
const classList1 = ref([]); const classList1 = ref([])
// 根据专业查班级 // 根据专业查班级
const getClassByMajor = () => { const getClassByMajor = () => {
if (!formInline.value.schoolMajorId) return; if (!formInline.value.schoolMajorId) return
formInline.value.schoolClassId = ""; formInline.value.schoolClassId = ""
indexApi.getClassListByMajorId({ schoolMajorId: formInline.value.schoolMajorId }).then((res) => { indexApi.getClassListByMajorId({ schoolMajorId: formInline.value.schoolMajorId }).then((res) => {
classList1.value = (res.data || []).filter((item) => canUseAdminClassForStudent(item)); classList1.value = (res.data || []).filter((item) => canUseAdminClassForStudent(item))
}); })
}; }
//初始化密码 //初始化密码
const initPassword = (row, status) => { const initPassword = (row, status) => {
if (status == 0) { if (status == 0) {
@ -471,11 +501,11 @@ const initPassword = (row, status) => {
}) })
.then(() => { .then(() => {
indexApi.initStudentPassword({ userId: row.userId, operatorId: currentUserId.value, teachingClassId: resolveRowTeachingClassId(row) }).then((res) => { indexApi.initStudentPassword({ userId: row.userId, operatorId: currentUserId.value, teachingClassId: resolveRowTeachingClassId(row) }).then((res) => {
proxy.$message.success("密码初始化成功"); proxy.$message.success("密码初始化成功")
getList(); getList()
}); })
}) })
.catch(() => {}); .catch(() => { })
} else { } else {
ElMessageBox.confirm("确定初始化当前学生数据吗?", "提示", { ElMessageBox.confirm("确定初始化当前学生数据吗?", "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
@ -483,10 +513,10 @@ const initPassword = (row, status) => {
type: "warning", type: "warning",
}) })
.then(() => { .then(() => {
const teachingClassId = resolveRowTeachingClassId(row); const teachingClassId = resolveRowTeachingClassId(row)
if (!teachingClassId) { if (!teachingClassId) {
proxy.$message.warning("请先选择教学班"); proxy.$message.warning("请先选择教学班")
return; return
} }
indexApi indexApi
.initializeTeachingClassStudentTrainingData({ .initializeTeachingClassStudentTrainingData({
@ -495,25 +525,24 @@ const initPassword = (row, status) => {
operatorId: currentUserId.value, operatorId: currentUserId.value,
}) })
.then((res) => { .then((res) => {
proxy.$message.success("初始化成功"); proxy.$message.success("初始化成功")
getList(); getList()
}); })
}) })
.catch(() => {}); .catch(() => { })
} }
}; }
onMounted(async () => { onMounted(async () => {
await userStore.ensureSchoolProductConfig().catch(() => null); await userStore.ensureSchoolProductConfig().catch(() => null)
getList(); getList()
getClassList(); getClassList()
if (!isTeacherRosterMode.value) { if (!isTeacherRosterMode.value) {
getFacultyList(); getFacultyList()
} }
}); })
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>
.student-page { .student-page {
padding: 20px;
min-height: calc(100vh - 70px); min-height: calc(100vh - 70px);
// 页面头部卡片 // 页面头部卡片
@ -552,6 +581,7 @@ onMounted(async () => {
letter-spacing: 2px; letter-spacing: 2px;
text-shadow: 0 0 20px rgba(0, 212, 255, 0.3); text-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
} }
p { p {
margin: 0; margin: 0;
font-size: 14px; font-size: 14px;
@ -614,7 +644,7 @@ onMounted(async () => {
background: transparent; background: transparent;
transition: all 0.3s ease; transition: all 0.3s ease;
&:hover > td { &:hover>td {
background: rgba(0, 212, 255, 0.08) !important; background: rgba(0, 212, 255, 0.08) !important;
} }
} }

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save