|
|
<!--
|
|
|
* @Author: qinzhenpen qzp1807@126.com
|
|
|
* @Date: 2025-05-13 16:22:46
|
|
|
* @LastEditors: qinzhenpen qzp1807@126.com
|
|
|
* @LastEditTime: 2025-05-22 09:41:23
|
|
|
* @FilePath: \e-commerce-internet\src\views\teacherEnd\school\index.vue
|
|
|
* @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
|
|
|
-->
|
|
|
<template>
|
|
|
<div class="student-page">
|
|
|
<!-- 页面头部 -->
|
|
|
<div class="page-header">
|
|
|
<div class="header-icon">
|
|
|
<el-icon>
|
|
|
<User />
|
|
|
</el-icon>
|
|
|
</div>
|
|
|
<div class="header-content">
|
|
|
<h1>学生管理</h1>
|
|
|
<p>管理系统学生用户信息,支持学生账号的增删改查及数据初始化操作</p>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
<div class="query-bar">
|
|
|
<div class="query-item">
|
|
|
<span class="query-label">班级:</span>
|
|
|
<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-select>
|
|
|
</div>
|
|
|
<div class="query-item">
|
|
|
<span class="query-label">学生姓名:</span>
|
|
|
<el-input style="width: 14rem" v-model="paramsquery.name" placeholder="请输入"></el-input>
|
|
|
</div>
|
|
|
<div class="query-item">
|
|
|
<span class="query-label">学生学号:</span>
|
|
|
<el-input style="width: 14rem" v-model="paramsquery.userName" placeholder="请输入"></el-input>
|
|
|
<el-button @click="getList" type="primary" class="ml10">
|
|
|
<el-icon>
|
|
|
<Search />
|
|
|
</el-icon>
|
|
|
搜索
|
|
|
</el-button>
|
|
|
</div>
|
|
|
<div class="btn-group">
|
|
|
<el-button type="primary" @click="addschool">
|
|
|
<el-icon>
|
|
|
<Plus />
|
|
|
</el-icon>
|
|
|
新增
|
|
|
</el-button>
|
|
|
<el-upload action="/api/user/importTeacherStudents" :show-file-list="false"
|
|
|
:before-upload="beforeImportStudents" :http-request="uploadStudents">
|
|
|
<el-button type="primary">
|
|
|
<el-icon>
|
|
|
<Upload />
|
|
|
</el-icon>
|
|
|
导入
|
|
|
</el-button>
|
|
|
</el-upload>
|
|
|
<el-button type="warning" @click="exportTeacher">
|
|
|
<el-icon>
|
|
|
<Download />
|
|
|
</el-icon>
|
|
|
导出
|
|
|
</el-button>
|
|
|
<el-button type="warning" @click="downloadTemplate">
|
|
|
<el-icon>
|
|
|
<Download />
|
|
|
</el-icon>
|
|
|
模板下载
|
|
|
</el-button>
|
|
|
<el-button type="primary" @click="refresh">
|
|
|
<el-icon>
|
|
|
<Refresh />
|
|
|
</el-icon>
|
|
|
刷新
|
|
|
</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
<el-table :data="tableData" border v-loading="loading" style="width: 100%" :header-cell-style="{
|
|
|
color: '#fff',
|
|
|
fontSize: '14px',
|
|
|
fontWeight: '600',
|
|
|
background: 'linear-gradient(135deg, #0099cc 0%, #006699 100%)',
|
|
|
}">
|
|
|
<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="username" align="center"></el-table-column>
|
|
|
<el-table-column label="账号来源" prop="codeFrom" align="center"></el-table-column>
|
|
|
<el-table-column label="创建日期" prop="createTime" align="center">
|
|
|
<template #default="{ row }">
|
|
|
<span>{{ formatDate(row.createTime) }}</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column label="操作" align="center" width="500">
|
|
|
<template #default="{ row }">
|
|
|
<div class="action-group">
|
|
|
<el-button type="primary" @click="editSchool(row)">
|
|
|
<el-icon>
|
|
|
<Edit />
|
|
|
</el-icon>
|
|
|
编辑
|
|
|
</el-button>
|
|
|
<el-button type="danger" @click="delSchool(row)">
|
|
|
<el-icon>
|
|
|
<Delete />
|
|
|
</el-icon>
|
|
|
删除
|
|
|
</el-button>
|
|
|
<el-button type="success" @click="initPassword(row, 0)">
|
|
|
<el-icon>
|
|
|
<Lock />
|
|
|
</el-icon>
|
|
|
密码初始化
|
|
|
</el-button>
|
|
|
<el-button type="warning" @click="initPassword(row, 1)">
|
|
|
<el-icon>
|
|
|
<Refresh />
|
|
|
</el-icon>
|
|
|
数据初始化
|
|
|
</el-button>
|
|
|
</div>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
<pagination v-show="schoolTotal > 0" :total="schoolTotal" v-model:page="paramsquery.index"
|
|
|
v-model:limit="paramsquery.size" @pagination="getList" />
|
|
|
<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">
|
|
|
<el-form-item label="所属院系:" prop="schoolFacultyId">
|
|
|
<el-select v-model="formInline.schoolFacultyId" placeholder="" clearable @change="getMajorList"
|
|
|
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-input v-else v-model="classInfo.name" style="width: 20rem" disabled></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="所属专业:" prop="schoolMajorId">
|
|
|
<el-select v-model="formInline.schoolMajorId" placeholder="" clearable style="width: 20rem"
|
|
|
v-if="status" @change="getClassByMajor">
|
|
|
<el-option v-for="major in majorList" :key="major.schoolMajorId"
|
|
|
:label="major.schoolMajorName" :value="major.schoolMajorId" />
|
|
|
</el-select>
|
|
|
<el-input v-else v-model="classInfo.value" placeholder="请输入所属专业:" style="width: 20rem"
|
|
|
disabled></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="所属班级:" prop="schoolClassId">
|
|
|
<el-select v-model="formInline.schoolClassId" placeholder="" clearable style="width: 20rem"
|
|
|
v-if="status">
|
|
|
<el-option v-for="major in classList1" :key="major.schoolClassId" :label="major.className"
|
|
|
:value="major.schoolClassId" />
|
|
|
</el-select>
|
|
|
<el-input v-else v-model="classInfo.className" placeholder="请输入所属班级:" style="width: 20rem"
|
|
|
disabled></el-input>
|
|
|
</el-form-item>
|
|
|
</template>
|
|
|
<el-form-item v-if="isTeacherRosterMode" label="所属教学班:" prop="teachingClassId">
|
|
|
<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-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="学生姓名:" prop="name">
|
|
|
<el-input v-model="formInline.name" style="width: 20rem" placeholder=""></el-input>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="学号:" prop="userName">
|
|
|
<el-input v-model="formInline.userName" style="width: 20rem" placeholder=""></el-input>
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<template #footer>
|
|
|
<span class="dialog-footers">
|
|
|
<el-button @click="dialogVisible = false">取消</el-button>
|
|
|
<el-button type="primary" @click="submitForm">确定</el-button>
|
|
|
</span>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script setup>
|
|
|
import { Search, Plus, Refresh, Edit, Delete, Lock } from "@element-plus/icons-vue"
|
|
|
import { formatDate } from "@/utils/index"
|
|
|
import { ElMessageBox } from "element-plus"
|
|
|
const { proxy } = getCurrentInstance()
|
|
|
import useUserStore from "@/store/modules/user"
|
|
|
const userStore = useUserStore()
|
|
|
const currentUserId = computed(() => userStore.userInfo.userId)
|
|
|
const currentSchoolId = computed(() => userStore.userInfo.schoolId)
|
|
|
const isTeacherRosterMode = computed(() => userStore.schoolProductConfig?.studentRosterOwner === "TEACHER")
|
|
|
const isManagerTeacher = computed(() => userStore.userInfo.teacherAdmin === true)
|
|
|
import * as indexApi from "@/api/teacher"
|
|
|
const dialogVisible = ref(false)
|
|
|
const loading = ref(false)
|
|
|
const formInline = ref({
|
|
|
schoolFacultyId: "",
|
|
|
schoolId: userStore.userInfo.schoolId,
|
|
|
schoolMajorId: "",
|
|
|
schoolMajorName: "",
|
|
|
schoolClassId: "",
|
|
|
teachingClassId: "",
|
|
|
schoolName: "",
|
|
|
userName: "",
|
|
|
})
|
|
|
const createEmptyForm = () => ({
|
|
|
schoolFacultyId: "",
|
|
|
schoolId: currentSchoolId.value,
|
|
|
schoolMajorId: "",
|
|
|
schoolMajorName: "",
|
|
|
schoolClassId: "",
|
|
|
teachingClassId: "",
|
|
|
schoolName: "",
|
|
|
userName: "",
|
|
|
name: "",
|
|
|
})
|
|
|
const organizationRules = {
|
|
|
schoolFacultyId: [{ required: true, message: "请选择所属院系", trigger: "change" }],
|
|
|
schoolMajorId: [{ required: true, message: "请选择所属专业", trigger: "change" }],
|
|
|
schoolClassId: [{ required: true, message: "请选择所属班级", trigger: "change" }],
|
|
|
}
|
|
|
const studentIdentityRules = {
|
|
|
name: [{ required: true, message: "请输入学生姓名", trigger: "blur" }],
|
|
|
userName: [{ required: true, message: "请输入学号", trigger: "blur" }],
|
|
|
}
|
|
|
const teacherRosterRules = {
|
|
|
...studentIdentityRules,
|
|
|
teachingClassId: [{ required: true, message: "请选择所属教学班", trigger: "change" }],
|
|
|
}
|
|
|
const studentFormRules = computed(() => (isTeacherRosterMode.value ? teacherRosterRules : { ...organizationRules, ...studentIdentityRules }))
|
|
|
const paramsquery = ref({
|
|
|
index: 1,
|
|
|
size: 10,
|
|
|
schoolId: userStore.userInfo.schoolId,
|
|
|
})
|
|
|
const classInfo = ref({})
|
|
|
const schoolTotal = ref(0)
|
|
|
function buildStudentImportFormData(file) {
|
|
|
const formData = new FormData()
|
|
|
formData.append("file", file)
|
|
|
formData.append("operatorId", currentUserId.value)
|
|
|
return formData
|
|
|
}
|
|
|
// 新增编辑状态
|
|
|
const status = ref(false)
|
|
|
// 院校list
|
|
|
const tableData = ref([])
|
|
|
// 获取院校列表
|
|
|
const getList = () => {
|
|
|
indexApi.getStudentList({ ...paramsquery.value, operatorId: currentUserId.value }).then((res) => {
|
|
|
tableData.value = res.data.list
|
|
|
schoolTotal.value = res.data.total
|
|
|
})
|
|
|
}
|
|
|
// 删除院校
|
|
|
const delSchool = (id) => {
|
|
|
indexApi.deleteStudent({ userId: id.userId, operatorId: currentUserId.value, teachingClassId: resolveRowTeachingClassId(id) }).then((res) => {
|
|
|
proxy.$message.success("删除成功")
|
|
|
getList()
|
|
|
})
|
|
|
}
|
|
|
// 新增院校
|
|
|
const addschool = () => {
|
|
|
formInline.value = createEmptyForm()
|
|
|
classInfo.value = {}
|
|
|
classList1.value = []
|
|
|
dialogVisible.value = true
|
|
|
status.value = true
|
|
|
}
|
|
|
const editSchool = (row) => {
|
|
|
console.log(row)
|
|
|
let data = { ...row }
|
|
|
formInline.value = data
|
|
|
formInline.value.userName = row.username
|
|
|
formInline.value.teachingClassId = isTeacherRosterMode.value ? row.teachingClassId || currentTeachingClassId() : ""
|
|
|
classInfo.value = {
|
|
|
className: row.className || row.schoolClassName || "",
|
|
|
}
|
|
|
dialogVisible.value = true
|
|
|
status.value = false
|
|
|
if (!isTeacherRosterMode.value && row.schoolMajorId) {
|
|
|
indexApi.getFacultyAndMajorName({ schoolMajorId: row.schoolMajorId }).then((res) => {
|
|
|
classInfo.value.name = Object.keys(res.data)[0]
|
|
|
classInfo.value.value = Object.values(res.data)[0]
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
const add = () => {
|
|
|
formInline.value.schoolId = currentSchoolId.value
|
|
|
formInline.value.operatorId = currentUserId.value
|
|
|
if (isTeacherRosterMode.value) {
|
|
|
indexApi.addTeacherRosterStudent(formInline.value).then((res) => {
|
|
|
proxy.$message.success("添加成功")
|
|
|
dialogVisible.value = false
|
|
|
getList()
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
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.userId = currentUserId.value
|
|
|
indexApi.addStudent(formInline.value).then((res) => {
|
|
|
proxy.$message.success("添加成功")
|
|
|
dialogVisible.value = false
|
|
|
getList()
|
|
|
})
|
|
|
}
|
|
|
const edit = () => {
|
|
|
formInline.value.status = true
|
|
|
formInline.value.operatorId = currentUserId.value
|
|
|
if (isTeacherRosterMode.value) {
|
|
|
indexApi.updateTeacherRosterStudent(formInline.value).then((res) => {
|
|
|
proxy.$message.success("编辑成功")
|
|
|
dialogVisible.value = false
|
|
|
getList()
|
|
|
})
|
|
|
return
|
|
|
}
|
|
|
formInline.value.teachingClassId = currentTeachingClassId()
|
|
|
indexApi.updateStudent(formInline.value).then((res) => {
|
|
|
proxy.$message.success("编辑成功")
|
|
|
dialogVisible.value = false
|
|
|
getList()
|
|
|
})
|
|
|
}
|
|
|
// 提交
|
|
|
const submitForm = () => {
|
|
|
proxy.$refs.formInlineref.validate((valid) => {
|
|
|
if (valid) {
|
|
|
status.value ? add() : edit()
|
|
|
} else {
|
|
|
return false
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
const onClose = () => {
|
|
|
formInline.value = createEmptyForm()
|
|
|
classInfo.value = {}
|
|
|
classList1.value = []
|
|
|
dialogVisible.value = false
|
|
|
}
|
|
|
// 刷新
|
|
|
const refresh = () => {
|
|
|
loading.value = true
|
|
|
setTimeout(() => {
|
|
|
loading.value = false
|
|
|
getList()
|
|
|
}, 2000)
|
|
|
}
|
|
|
// 查询院系下拉列表
|
|
|
const facultyList = ref([])
|
|
|
const getFacultyList = () => {
|
|
|
indexApi.seleteSchoolFacultyList({ schoolId: userStore.userInfo.schoolId }).then((res) => {
|
|
|
facultyList.value = res.data
|
|
|
})
|
|
|
}
|
|
|
// 专业下拉框
|
|
|
const majorList = ref([])
|
|
|
const getMajorList = () => {
|
|
|
if (!formInline.value.schoolFacultyId) return
|
|
|
paramsquery.value.schoolMajorId = ""
|
|
|
indexApi.getMajorListBySchoolId({ schoolFacultyId: formInline.value.schoolFacultyId }).then((res) => {
|
|
|
majorList.value = res.data
|
|
|
})
|
|
|
}
|
|
|
const uploadStudents = (options) => {
|
|
|
if (isTeacherRosterMode.value) {
|
|
|
const formData = new FormData()
|
|
|
formData.append("file", options.file)
|
|
|
return indexApi.importTeacherRosterStudents(formData).then((res) => {
|
|
|
handleSuccess(res)
|
|
|
})
|
|
|
}
|
|
|
const formData = buildStudentImportFormData(options.file)
|
|
|
return indexApi.importTeacherStudents(formData).then((res) => {
|
|
|
handleSuccess(res)
|
|
|
})
|
|
|
}
|
|
|
const handleSuccess = (res, file) => {
|
|
|
if (res?.statusCode && res.statusCode !== "OK" && res.statusCode !== 200) {
|
|
|
proxy.$message.error(res?.message || "导入失败")
|
|
|
return
|
|
|
}
|
|
|
getList()
|
|
|
proxy.$modal.msgSuccess("导入成功")
|
|
|
}
|
|
|
// 导出教师账号
|
|
|
const exportTeacher = () => {
|
|
|
indexApi.exportStudentList({ schoolId: userStore.userInfo.schoolId, operatorId: currentUserId.value, schoolClassId: currentTeachingClassId() }).then((res) => {
|
|
|
const blob = new Blob([res], { type: "application/vnd.ms-excel" })
|
|
|
const url = URL.createObjectURL(blob)
|
|
|
const link = document.createElement("a")
|
|
|
link.href = url
|
|
|
link.setAttribute("download", "学生信息表格.xlsx")
|
|
|
link.click()
|
|
|
URL.revokeObjectURL(url)
|
|
|
})
|
|
|
}
|
|
|
// 导入模版下载
|
|
|
const buildOwnedAdminClassRows = async () => {
|
|
|
const majorGroups = await Promise.all(
|
|
|
facultyList.value.map((faculty) =>
|
|
|
indexApi
|
|
|
.getMajorListBySchoolId({ schoolFacultyId: faculty.schoolFacultyId })
|
|
|
.then((res) => (res.data || []).map((major) => ({ ...major, schoolFacultyName: faculty.schoolFacultyName })))
|
|
|
.catch(() => []),
|
|
|
),
|
|
|
)
|
|
|
const allMajors = majorGroups.flat()
|
|
|
return classList.value
|
|
|
.filter((item) => canUseAdminClassForStudent(item))
|
|
|
.map((item) => {
|
|
|
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))
|
|
|
return [faculty?.schoolFacultyName || item.schoolFacultyName || "", major?.schoolMajorName || item.schoolMajorName || "", item.className || ""]
|
|
|
})
|
|
|
.filter((row) => row.every(Boolean))
|
|
|
}
|
|
|
|
|
|
const downloadTemplate = async () => {
|
|
|
const XLSX = await import("xlsx")
|
|
|
if (isTeacherRosterMode.value) {
|
|
|
const exampleClassName = teachingClassOptions.value[0]?.className || "教学一班"
|
|
|
const templateSheet = XLSX.utils.aoa_to_sheet([
|
|
|
["学生姓名", "学号", "班级"],
|
|
|
["张三", "20260001", exampleClassName],
|
|
|
])
|
|
|
templateSheet["!cols"] = [{ wch: 16 }, { wch: 18 }, { wch: 20 }]
|
|
|
const workbook = XLSX.utils.book_new()
|
|
|
XLSX.utils.book_append_sheet(workbook, templateSheet, "学生导入模板")
|
|
|
XLSX.writeFile(workbook, "学生账号导入模板.xlsx")
|
|
|
return
|
|
|
}
|
|
|
const adminClassRows = await buildOwnedAdminClassRows()
|
|
|
const firstAdminClass = adminClassRows[0] || ["电子商务学院", "电子商务", "行政一班"]
|
|
|
const templateSheet = XLSX.utils.aoa_to_sheet([
|
|
|
["姓名", "学号", "性别", "所属院系", "所属专业", "所属班级"],
|
|
|
["张三", "20260001", "男", firstAdminClass[0], firstAdminClass[1], firstAdminClass[2]],
|
|
|
])
|
|
|
templateSheet["!cols"] = [{ wch: 14 }, { wch: 18 }, { wch: 10 }, { wch: 24 }, { wch: 24 }, { wch: 20 }]
|
|
|
const dataRows = adminClassRows.length ? adminClassRows : [["暂无可导入行政班", "请先维护专业", "请先创建行政班"]]
|
|
|
const dataSheet = XLSX.utils.aoa_to_sheet([["所属院系", "所属专业", "所属班级"], ...dataRows])
|
|
|
dataSheet["!cols"] = [{ wch: 28 }, { wch: 28 }, { wch: 24 }]
|
|
|
const guideSheet = XLSX.utils.aoa_to_sheet([["填写说明"], ["1. 本模板用于学生账号导入,不要填写任何数据ID。"], ["2. 所属院系、所属专业、所属班级请使用基础数据页中的名称。"], ["3. 只能导入本校行政班,不能导入教学班或其他学校的班级。"], ["4. 性别可填写男、女,也可留空。"], ["5. 任意一行校验失败时,整批导入失败并返回失败原因。"]])
|
|
|
guideSheet["!cols"] = [{ wch: 76 }]
|
|
|
const workbook = XLSX.utils.book_new()
|
|
|
XLSX.utils.book_append_sheet(workbook, templateSheet, "学生导入模板")
|
|
|
XLSX.utils.book_append_sheet(workbook, dataSheet, "基础数据")
|
|
|
XLSX.utils.book_append_sheet(workbook, guideSheet, "填写说明")
|
|
|
XLSX.writeFile(workbook, "学生账号导入模板.xlsx")
|
|
|
}
|
|
|
|
|
|
const classList = ref([])
|
|
|
const normalizeClassType = (schoolClass) => {
|
|
|
if (schoolClass?.classType) return schoolClass.classType
|
|
|
return schoolClass?.createdBy ? "TEACHING" : "ADMIN"
|
|
|
}
|
|
|
const sameValue = (left, right) => String(left || "") === String(right || "")
|
|
|
const canUseAdminClassForStudent = (schoolClass) => {
|
|
|
if (normalizeClassType(schoolClass) !== "ADMIN") return false
|
|
|
return !schoolClass?.schoolId || sameValue(schoolClass.schoolId, currentSchoolId.value)
|
|
|
}
|
|
|
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 studentClassOptions = computed(() => teachingClassOptions.value)
|
|
|
const currentTeachingClassId = () => {
|
|
|
const selectedClass = classMap.value.get(paramsquery.value.schoolClassId)
|
|
|
return selectedClass && normalizeClassType(selectedClass) === "TEACHING" ? selectedClass.schoolClassId : ""
|
|
|
}
|
|
|
const resolveRowTeachingClassId = (row) => currentTeachingClassId() || row?.teachingClassId || ""
|
|
|
const beforeImportStudents = (file) => {
|
|
|
if (!/\.(xls|xlsx)$/i.test(file.name)) {
|
|
|
proxy.$message.warning("请选择xls或xlsx格式文件")
|
|
|
return false
|
|
|
}
|
|
|
return true
|
|
|
}
|
|
|
const getClassList = () => {
|
|
|
indexApi.getClassListBySchoolId({ schoolId: userStore.userInfo.schoolId }).then((res) => {
|
|
|
classList.value = res.data
|
|
|
})
|
|
|
}
|
|
|
const classList1 = ref([])
|
|
|
// 根据专业查班级
|
|
|
const getClassByMajor = () => {
|
|
|
if (!formInline.value.schoolMajorId) return
|
|
|
formInline.value.schoolClassId = ""
|
|
|
indexApi.getClassListByMajorId({ schoolMajorId: formInline.value.schoolMajorId }).then((res) => {
|
|
|
classList1.value = (res.data || []).filter((item) => canUseAdminClassForStudent(item))
|
|
|
})
|
|
|
}
|
|
|
//初始化密码
|
|
|
const initPassword = (row, status) => {
|
|
|
if (status == 0) {
|
|
|
ElMessageBox.confirm("确定初始化密码吗?", "提示", {
|
|
|
confirmButtonText: "确定",
|
|
|
cancelButtonText: "取消",
|
|
|
type: "warning",
|
|
|
})
|
|
|
.then(() => {
|
|
|
indexApi.initStudentPassword({ userId: row.userId, operatorId: currentUserId.value, teachingClassId: resolveRowTeachingClassId(row) }).then((res) => {
|
|
|
proxy.$message.success("密码初始化成功")
|
|
|
getList()
|
|
|
})
|
|
|
})
|
|
|
.catch(() => { })
|
|
|
} else {
|
|
|
ElMessageBox.confirm("确定初始化当前学生数据吗?", "提示", {
|
|
|
confirmButtonText: "确定",
|
|
|
cancelButtonText: "取消",
|
|
|
type: "warning",
|
|
|
})
|
|
|
.then(() => {
|
|
|
const teachingClassId = resolveRowTeachingClassId(row)
|
|
|
if (!teachingClassId) {
|
|
|
proxy.$message.warning("请先选择教学班")
|
|
|
return
|
|
|
}
|
|
|
indexApi
|
|
|
.initializeTeachingClassStudentTrainingData({
|
|
|
teachingClassId,
|
|
|
studentUserId: row.userId,
|
|
|
operatorId: currentUserId.value,
|
|
|
})
|
|
|
.then((res) => {
|
|
|
proxy.$message.success("初始化成功")
|
|
|
getList()
|
|
|
})
|
|
|
})
|
|
|
.catch(() => { })
|
|
|
}
|
|
|
}
|
|
|
onMounted(async () => {
|
|
|
await userStore.ensureSchoolProductConfig().catch(() => null)
|
|
|
getList()
|
|
|
getClassList()
|
|
|
if (!isTeacherRosterMode.value) {
|
|
|
getFacultyList()
|
|
|
}
|
|
|
})
|
|
|
</script>
|
|
|
<style lang="scss" scoped>
|
|
|
.student-page {
|
|
|
min-height: calc(100vh - 70px);
|
|
|
|
|
|
// 页面头部卡片
|
|
|
.page-header {
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
gap: 20px;
|
|
|
padding: 24px 28px;
|
|
|
background: linear-gradient(135deg, rgba(8, 24, 39, 0.9) 0%, rgba(6, 17, 29, 0.9) 100%);
|
|
|
border-radius: 16px;
|
|
|
margin-bottom: 20px;
|
|
|
border: 1px solid rgba(0, 200, 255, 0.2);
|
|
|
box-shadow:
|
|
|
0 8px 32px rgba(0, 0, 0, 0.4),
|
|
|
inset 0 1px 0 rgba(255, 255, 255, 0.05);
|
|
|
|
|
|
.header-icon {
|
|
|
width: 60px;
|
|
|
height: 60px;
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
background: linear-gradient(135deg, #00d4ff 0%, #0099cc 100%);
|
|
|
border-radius: 14px;
|
|
|
font-size: 30px;
|
|
|
color: #0a0f1c;
|
|
|
box-shadow: 0 0 30px rgba(0, 212, 255, 0.4);
|
|
|
}
|
|
|
|
|
|
.header-content {
|
|
|
h1 {
|
|
|
margin: 0 0 6px 0;
|
|
|
font-size: 24px;
|
|
|
font-weight: 700;
|
|
|
color: #fff;
|
|
|
letter-spacing: 2px;
|
|
|
text-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
|
|
|
}
|
|
|
|
|
|
p {
|
|
|
margin: 0;
|
|
|
font-size: 14px;
|
|
|
color: rgba(255, 255, 255, 0.5);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 搜索栏
|
|
|
.query-bar {
|
|
|
display: flex;
|
|
|
flex-wrap: wrap;
|
|
|
align-items: center;
|
|
|
gap: 16px;
|
|
|
padding: 20px 24px;
|
|
|
background: rgba(6, 17, 29, 0.6);
|
|
|
border-radius: 14px;
|
|
|
margin-bottom: 16px;
|
|
|
border: 1px solid rgba(0, 200, 255, 0.15);
|
|
|
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
|
|
|
|
|
|
.query-item {
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
gap: 8px;
|
|
|
|
|
|
.query-label {
|
|
|
color: rgba(255, 255, 255, 0.7);
|
|
|
font-size: 14px;
|
|
|
white-space: nowrap;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
.btn-group {
|
|
|
margin-left: auto;
|
|
|
display: flex;
|
|
|
gap: 10px;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 表格样式
|
|
|
.el-table {
|
|
|
border-radius: 14px;
|
|
|
overflow: hidden;
|
|
|
background: transparent;
|
|
|
border: 1px solid rgba(0, 200, 255, 0.15);
|
|
|
box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
|
|
|
|
|
|
:deep(.el-table__header-wrapper th) {
|
|
|
background: transparent;
|
|
|
color: #fff;
|
|
|
font-weight: 600;
|
|
|
border: none !important;
|
|
|
padding: 14px 0;
|
|
|
font-size: 14px;
|
|
|
text-shadow: 0 0 10px rgba(0, 212, 255, 0.3);
|
|
|
}
|
|
|
|
|
|
:deep(.el-table__body-wrapper tr) {
|
|
|
background: transparent;
|
|
|
transition: all 0.3s ease;
|
|
|
|
|
|
&:hover>td {
|
|
|
background: rgba(0, 212, 255, 0.08) !important;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
:deep(.el-table__row td) {
|
|
|
padding: 14px 0;
|
|
|
border-bottom: 1px solid rgba(0, 200, 255, 0.1) !important;
|
|
|
background: transparent !important;
|
|
|
}
|
|
|
|
|
|
:deep(.el-table__cell) {
|
|
|
font-size: 14px;
|
|
|
color: rgba(255, 255, 255, 0.85);
|
|
|
background: transparent !important;
|
|
|
border: none !important;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 操作按钮组
|
|
|
.action-group {
|
|
|
display: flex;
|
|
|
align-items: center;
|
|
|
justify-content: center;
|
|
|
gap: 8px;
|
|
|
flex-wrap: wrap;
|
|
|
}
|
|
|
|
|
|
// 按钮样式
|
|
|
.el-button {
|
|
|
display: inline-flex;
|
|
|
align-items: center;
|
|
|
gap: 5px;
|
|
|
border-radius: 8px;
|
|
|
font-weight: 500;
|
|
|
transition: all 0.3s ease;
|
|
|
padding: 8px 14px;
|
|
|
border: 1px solid rgba(0, 200, 255, 0.3);
|
|
|
background: rgba(0, 150, 200, 0.15);
|
|
|
color: #00d4ff;
|
|
|
|
|
|
&:hover {
|
|
|
transform: translateY(-1px);
|
|
|
box-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
|
|
|
background: rgba(0, 212, 255, 0.2);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
// 弹窗样式
|
|
|
.el-dialog {
|
|
|
border-radius: 18px;
|
|
|
overflow: hidden;
|
|
|
background: linear-gradient(135deg, #07111d 0%, #03070e 100%);
|
|
|
border: 1px solid rgba(0, 200, 255, 0.2);
|
|
|
box-shadow:
|
|
|
0 20px 60px rgba(0, 0, 0, 0.6),
|
|
|
0 0 40px rgba(0, 212, 255, 0.1);
|
|
|
|
|
|
:deep(.el-dialog__header) {
|
|
|
background: linear-gradient(135deg, #0099cc 0%, #006699 100%);
|
|
|
color: #fff;
|
|
|
padding: 22px 28px;
|
|
|
margin: 0;
|
|
|
|
|
|
.el-dialog__title {
|
|
|
color: #fff;
|
|
|
font-weight: 700;
|
|
|
font-size: 18px;
|
|
|
text-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
|
|
|
}
|
|
|
|
|
|
.el-dialog__headerbtn {
|
|
|
.el-dialog__close {
|
|
|
color: rgba(255, 255, 255, 0.8);
|
|
|
font-size: 20px;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
:deep(.el-dialog__body) {
|
|
|
padding: 28px;
|
|
|
background: transparent;
|
|
|
}
|
|
|
|
|
|
:deep(.el-dialog__footer) {
|
|
|
padding: 18px 28px;
|
|
|
border-top: 1px solid rgba(0, 200, 255, 0.15);
|
|
|
background: rgba(10, 15, 30, 0.5);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
:deep(.pagination-container) {
|
|
|
.el-pagination {
|
|
|
position: sticky !important;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
</style>
|