| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583 |
- <!--
- Description: 我的批改页面
- Author: BaiQi
- Created Date: 2024-7-25
- -->
- <template>
- <div class="course-page">
- <!-- 左侧菜单栏 -->
- <div class="left-sidebar">
- <!-- EAI平台装饰栏 -->
- <div class="platform-header">
- <div class="platform-name">EAI专业英语平台</div>
- </div>
-
- <!-- 搜索框 -->
- <div class="search-section">
- <div class="search-input-container" @click="openSearchDialog">
- <el-icon class="search-icon"><Search /></el-icon>
- <input type="text" placeholder="搜索" class="search-input" readonly />
- </div>
- </div>
-
- <!-- 菜单列表 -->
- <div class="menu-section">
- <!-- 加载状态 -->
- <div v-if="loading" class="loading-container">
- <div class="loading-text">加载中...</div>
- </div>
- <div class="menu-item" v-for="course in courseList" :key="course.courseId">
- <div class="course-header" @click="toggleCourse(course.courseId)">
- <el-icon class="expand-icon" :class="{ 'expanded': course.expanded }">
- <ArrowDown v-if="course.expanded" />
- <ArrowRight v-else />
- </el-icon>
- <el-icon class="course-icon"><Document /></el-icon>
- <span class="course-name">{{ course.courseName }}</span>
- </div>
-
- <!-- 作业子菜单 -->
- <div class="assignment-list" v-if="course.expanded">
- <div
- class="assignment-item"
- v-for="assignment in course.assignments"
- :key="assignment.assignmentId"
- :class="{ 'active': assignment.active }"
- @click="selectAssignment(assignment.assignmentId)"
- >
- <el-icon class="assignment-icon" :class="{ 'active-icon': assignment.active }">
- <Document />
- </el-icon>
- <span class="assignment-name">{{ assignment.assignmentName }}</span>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <!-- 右侧内容区域 -->
- <div class="right-content">
- <!-- 当没有选中作业时显示空白状态 -->
- <div v-if="!selectedAssignment" class="empty-state">
- <div class="empty-content">
- <el-icon class="empty-icon"><Document /></el-icon>
- <div class="empty-text">请选择一个作业开始批改</div>
- </div>
- </div>
-
- <!-- 当选中作业时显示内容 -->
- <div v-else class="assignment-content">
- <!-- 右上角数据看板按钮 -->
- <div class="top-actions">
- <el-button type="primary" class="dashboard-button">数据看板</el-button>
- </div>
-
- <!-- 统计卡片区域 -->
- <div class="stats-container">
- <div class="stats-card">
- <div class="stats-icon user-icon">
- <el-icon><User /></el-icon>
- </div>
- <div class="stats-content">
- <div class="stats-label">作业总人数</div>
- <div class="stats-value">{{ statsData.totalStudents }}</div>
- </div>
- </div>
-
- <div class="stats-card">
- <div class="stats-icon completed-icon">
- <el-icon><CircleCheck /></el-icon>
- </div>
- <div class="stats-content">
- <div class="stats-label">已批改人数</div>
- <div class="stats-value">{{ statsData.correctedCount }}</div>
- </div>
- </div>
-
- <div class="stats-card">
- <div class="stats-icon pending-icon">
- <el-icon><Document /></el-icon>
- </div>
- <div class="stats-content">
- <div class="stats-label">已提交未批改人数</div>
- <div class="stats-value">{{ statsData.submittedNotCorrectedCount }}</div>
- </div>
- </div>
-
- <div class="stats-card">
- <div class="stats-icon not-submitted-icon">
- <el-icon><WarningFilled /></el-icon>
- </div>
- <div class="stats-content">
- <div class="stats-label">未提交人数</div>
- <div class="stats-value">{{ statsData.notSubmittedCount }}</div>
- </div>
- </div>
- </div>
-
- <div class="assignment-body">
- <!-- 课程作业标题 -->
- <div class="assignment-title-section">
- <h3 class="assignment-full-title">{{ selectedAssignment.courseName }}:{{ selectedAssignment.assignmentName }}</h3>
- </div>
-
- <!-- 搜索筛选栏 -->
- <div class="filter-section">
- <div class="filter-controls">
- <el-icon class="reset-icon" @click="resetFilters"><Refresh /></el-icon>
- <div class="search-input-wrapper">
- <input
- type="text"
- placeholder="请输入内容"
- class="filter-search-input"
- v-model="filterQuery"
- />
- </div>
- <el-select v-model="statusFilter" placeholder="状态" class="filter-select">
- <el-option label="全部" value=""></el-option>
- <el-option label="未提交" value="未提交"></el-option>
- <el-option label="已提交未批改" value="已提交未批改"></el-option>
- <el-option label="已批改" value="已批改"></el-option>
- <el-option label="补交_未批改" value="补交_未批改"></el-option>
- <el-option label="补交_已批改" value="补交_已批改"></el-option>
- </el-select>
- <el-select v-model="classFilter" placeholder="班级" class="filter-select" @change="handleClassFilterChange">
- <el-option label="全部" value=""></el-option>
- <el-option
- v-for="classItem in classList"
- :key="classItem.classId"
- :label="classItem.className"
- :value="classItem.classId.toString()"
- ></el-option>
- </el-select>
- <el-button type="primary" class="search-button">搜索</el-button>
- </div>
- </div>
-
- <!-- 学生作业表格 -->
- <div class="table-section">
- <el-table :data="filteredStudentList" class="student-table" stripe>
- <el-table-column prop="status" label="状态" width="230" align="left">
- <template #default="scope">
- <span :class="getStatusClass(scope.row.status)" class="status-badge">
- {{ statusMap[scope.row.status] || scope.row.status }}
- </span>
- </template>
- </el-table-column>
- <el-table-column prop="stuName" label="学生姓名" width="230"></el-table-column>
- <el-table-column label="班级" width="230">
- <template #default="scope">
- {{ getStudentClassName(scope.row) }}
- </template>
- </el-table-column>
- <el-table-column prop="score" label="得分" width="230">
- <template #header>
- <div class="score-header" @click="toggleSort">
- <span>得分</span>
- <el-icon class="sort-icon" :class="getSortIconClass()">
- <Sort />
- </el-icon>
- </div>
- </template>
- <template #default="scope">
- <span :class="getScoreClass(scope.row)" class="score-badge">
- {{ getScoreDisplay(scope.row) }}
- </span>
- </template>
- </el-table-column>
- <el-table-column label="备注" width="230">
- <template #default="scope">
- <span v-if="isLateSubmission(scope.row.status)" class="late-submission-badge">
- 补交
- </span>
- </template>
- </el-table-column>
- <el-table-column label="操作" width="230">
- <template #default="scope">
- <el-button
- type="primary"
- size="small"
- class="action-button"
- :disabled="scope.row.status === 'NOT_SUBMITTED'"
- @click="handleCorrect(scope.row)"
- >
- <el-icon class="correct-icon"><ZoomIn /></el-icon>
- 批改
- </el-button>
- </template>
- </el-table-column>
- </el-table>
- </div>
-
- <div class="example-pagination-block">
- <el-pagination
- v-model:current-page="currentPage"
- :page-size="pageSize"
- layout="total, prev, pager, next"
- :total="total"
- :page-count="totalPages"
- @current-change="handleCurrentChange"
- />
- </div>
- </div>
- </div>
- </div>
-
- <!-- 搜索弹窗 -->
- <el-dialog
- v-model="searchDialogVisible"
- title="搜索课程和作业"
- width="50%"
- :before-close="handleCloseSearchDialog"
- class="search-dialog"
- >
- <div class="search-dialog-container">
- <!-- 搜索框部分 -->
- <div class="dialog-search-section">
- <div class="dialog-search-input-container">
- <el-icon class="dialog-search-icon"><Search /></el-icon>
- <input
- type="text"
- placeholder="输入课程或作业名称..."
- class="dialog-search-input"
- v-model="searchQuery"
- @input="performSearch"
- ref="dialogSearchInput"
- />
- </div>
- </div>
-
- <!-- 搜索结果部分 -->
- <div class="search-results-section">
- <div v-if="searchResults.length === 0" class="no-results">
- <span>{{ searchQuery ? '没有找到相关结果' : '请输入搜索内容' }}</span>
- </div>
- <div v-else class="search-results-list">
- <div
- v-for="result in searchResults"
- :key="result.id"
- class="search-result-item"
- @click="handleSearchResultClick(result)"
- >
- <el-icon class="result-icon" v-if="result.type === 'course'">
- <Document />
- </el-icon>
- <el-icon class="result-icon assignment-result-icon" v-else>
- <Document />
- </el-icon>
- <div class="result-content">
- <div class="result-title">{{ result.name }}</div>
- <div class="result-path" v-if="result.type === 'assignment'">
- 课程: {{ result.courseName }}
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </el-dialog>
- </div>
- </template>
- <script lang="ts" setup>
- import useApis from "@/apis";
- import {ref, reactive, computed, onMounted} from "vue";
- import {useRouter, useRoute} from "vue-router";
- import {Refresh, Search, Document, ArrowDown, ArrowRight, User, CircleCheck, WarningFilled, Sort, ZoomIn} from "@element-plus/icons-vue";
- import type {ClassDTO, StudentAssignmentStatusDTO} from "@/types/dto";
- import type {CourseVO, IAssignment} from "@/types/vo";
- import "./CoursePage.scss"
- import {useStore} from "@/store";
- const store = useStore()
- const router = useRouter()
- const route = useRoute()
- const apis = useApis()
- const selectedAssignment = ref(null)
-
- // 定义课程和作业的数据结构
- interface CourseWithAssignments {
- courseId: number;
- courseName: string;
- expanded: boolean;
- assignments: AssignmentWithStatus[];
- }
-
- interface AssignmentWithStatus {
- assignmentId: number;
- assignmentName: string;
- active: boolean;
- courseId: number;
- }
-
- // 真实数据 - 课程和作业列表
- const courseList = reactive<CourseWithAssignments[]>([])
-
- // 原始课程数据(从API获取)
- const rawCourses = reactive<CourseVO[]>([])
-
- // 原始作业数据(从API获取)
- const rawAssignments = reactive<IAssignment[]>([])
-
- // 加载状态
- const loading = ref(false)
-
- // 加载所有课程
- const loadCourses = async () => {
- try {
- loading.value = true
- // 使用正确的CourseQuery来获取所有课程
- const courseQuery = {
- courseId: null,
- teacherId: store.user.id,
- teacherPid: Number(store.user.pid),
- studentId: null,
- courseName: null,
- semester: null,
- }
- const response = await apis.getAllCourse(courseQuery, 1, 1000)
-
- if (response.data.code === 200) {
- // 根据其他代码,数据可能在response.data.data.records中
- const courseData = response.data.data.records || response.data.data.content || response.data.data
- console.log('加载到的课程数据 1:', courseData)
- rawCourses.splice(0, rawCourses.length, ...courseData)
- await loadAllAssignments()
- buildCourseTree()
- }
- } catch (error) {
- console.error('加载课程失败 :', error)
- } finally {
- loading.value = false
- }
- }
-
- // 加载所有作业
- const loadAllAssignments = async () => {
- try {
- // 使用正确的AssignmentQuery来获取所有作业
- const assignmentQuery = {
- assignmentId: null,
- teacherId: store.user.id,
- courseId: null,
- assignmentName: null,
- status: null,
- type: null,
- }
- const response = await apis.getAssignmentByQuery(assignmentQuery, 1, 1000)
-
- if (response.data.code === 200) {
- // 数据可能在不同的路径中
- const assignmentData = response.data.data.records || response.data.data.content || response.data.data
- console.log('加载到的作业数据:', assignmentData)
- rawAssignments.splice(0, rawAssignments.length, ...assignmentData)
- }
- } catch (error) {
- console.error('加载作业失败:', error)
- }
- }
-
- // 构建课程树结构
- const buildCourseTree = () => {
- const courseMap = new Map<number, CourseWithAssignments>()
-
- console.log('构建课程树 - 课程数量:', rawCourses.length, '作业数量:', rawAssignments.length)
-
- // 初始化课程
- rawCourses.forEach(course => {
- courseMap.set(course.courseId, {
- courseId: course.courseId,
- courseName: course.courseName,
- expanded: false,
- assignments: []
- })
- })
-
- // 添加作业到对应课程
- rawAssignments.forEach(assignment => {
- const course = courseMap.get(assignment.courseId)
- if (course) {
- course.assignments.push({
- assignmentId: assignment.assignmentId,
- assignmentName: assignment.assignmentName,
- active: false,
- courseId: assignment.courseId
- })
- }
- })
-
- // 更新courseList
- courseList.splice(0, courseList.length, ...Array.from(courseMap.values()))
- console.log('构建完成的课程树:', courseList.length, '个课程')
- }
- // 切换课程展开/收起
- const toggleCourse = (courseId: number) => {
- const course = courseList.find(c => c.courseId === courseId)
- if (course) {
- course.expanded = !course.expanded
- }
- }
-
- // 选择作业
- const selectAssignment = async (assignmentId: number) => {
- // 清除所有作业的active状态
- courseList.forEach(course => {
- course.assignments.forEach(assignment => {
- assignment.active = false
- })
- })
-
- // 设置选中的作业为active
- courseList.forEach(course => {
- const assignment = course.assignments.find(a => a.assignmentId === assignmentId)
- if (assignment) {
- assignment.active = true
- // 设置选中的作业信息
- selectedAssignment.value = {
- assignmentId: assignment.assignmentId,
- assignmentName: assignment.assignmentName,
- courseName: course.courseName,
- courseId: course.courseId
- }
-
- // 加载相关数据
- onAssignmentSelected({
- assignmentId: assignment.assignmentId,
- courseId: course.courseId
- })
- }
- })
- }
-
- // 搜索弹窗相关逻辑
- const searchDialogVisible = ref(false)
- const searchQuery = ref('')
- const searchResults = ref([])
- const dialogSearchInput = ref(null)
-
- // 筛选相关逻辑
- const filterQuery = ref('')
- const statusFilter = ref('')
- const classFilter = ref('')
-
- // 监听班级筛选变化
- const handleClassFilterChange = async () => {
- if (selectedAssignment.value && classFilter.value) {
- // 重新加载选中班级的学生数据
- studentList.splice(0, studentList.length)
- await loadStudentAssignmentStatus(classFilter.value, selectedAssignment.value.assignmentId.toString())
- } else if (selectedAssignment.value && !classFilter.value) {
- // 如果选择了"全部",重新加载所有班级的数据
- await loadAllStudentAssignmentStatus(selectedAssignment.value.assignmentId)
- }
- }
-
- // 排序相关逻辑
- const sortOrder = ref(0) // 0: 原始顺序, 1: 高到低, 2: 低到高
-
- // 学生数据
- const studentList = reactive<StudentAssignmentStatusDTO[]>([])
-
- // 班级列表数据
- const classList = reactive<ClassDTO[]>([])
-
- // 统计卡片数据
- const statsData = reactive({
- totalStudents: 0,
- correctedCount: 0,
- submittedNotCorrectedCount: 0,
- notSubmittedCount: 0
- })
-
- // 学生班级映射数据(用于存储学生ID到班级名称的映射)
- const studentClassMap = reactive(new Map<number, string>())
-
- // 状态映射
- const statusMap = {
- 'NOT_SUBMITTED': '未提交',
- 'SUBMITTED': '已提交未批改',
- 'CORRECTED': '已批改',
- 'LATE_SUBMITTED': '补交_未批改',
- 'LATE_SUBMITTED_CORRECTED': '补交_已批改'
- }
-
- // 当前页码
- const currentPage = ref(1)
- // 每页显示条数
- const pageSize = 10
- // 计算筛选后的学生列表(包含分页)
- const filteredStudentList = computed(() => {
- let filtered = [...studentList]
-
- // 筛选逻辑
- if (filterQuery.value) {
- filtered = filtered.filter(student =>
- student.stuName.toLowerCase().includes(filterQuery.value.toLowerCase())
- )
- }
-
- if (statusFilter.value) {
- filtered = filtered.filter(student => statusMap[student.status] === statusFilter.value)
- }
-
- if (classFilter.value) {
- // 根据选中的班级ID重新加载数据
- // 这里可以实现按班级筛选的逻辑
- // 暂时保持原有的筛选逻辑
- }
-
- // 排序逻辑
- if (sortOrder.value === 1) {
- // 高到低排序
- filtered.sort((a, b) => {
- const scoreA = getScoreForSort(a)
- const scoreB = getScoreForSort(b)
- return scoreB - scoreA
- })
- } else if (sortOrder.value === 2) {
- // 低到高排序
- filtered.sort((a, b) => {
- const scoreA = getScoreForSort(a)
- const scoreB = getScoreForSort(b)
- return scoreA - scoreB
- })
- }
- // sortOrder.value === 0 时保持原始顺序
-
- // 分页逻辑
- const startIndex = (currentPage.value - 1) * pageSize
- const endIndex = startIndex + pageSize
- return filtered.slice(startIndex, endIndex)
- })
- // 单独的计算属性来获取总页数
- const totalPages = computed(() => {
- let filtered = [...studentList]
-
- if (filterQuery.value) {
- filtered = filtered.filter(student =>
- student.stuName.toLowerCase().includes(filterQuery.value.toLowerCase())
- )
- }
-
- if (statusFilter.value) {
- filtered = filtered.filter(student => statusMap[student.status] === statusFilter.value)
- }
-
- if (classFilter.value) {
- // 根据选中的班级ID重新加载数据
- // 这里可以实现按班级筛选的逻辑
- // 暂时保持原有的筛选逻辑
- }
-
- return Math.ceil(filtered.length / pageSize)
- })
- // 总条目数
- const total = computed(() => {
- let filtered = [...studentList]
- if (filterQuery.value) {
- filtered = filtered.filter(student =>
- student.stuName.toLowerCase().includes(filterQuery.value.toLowerCase())
- )
- }
- if (statusFilter.value) {
- filtered = filtered.filter(student => statusMap[student.status] === statusFilter.value)
- }
- if (classFilter.value) {
- // 根据选中的班级ID重新加载数据
- // 这里可以实现按班级筛选的逻辑
- // 暂时保持原有的筛选逻辑
- }
- return filtered.length
- })
-
- // 重置筛选条件
- const resetFilters = () => {
- filterQuery.value = ''
- statusFilter.value = ''
- classFilter.value = ''
- sortOrder.value = 0
- currentPage.value = 1 // 重置页码
-
- // 重新加载所有数据并更新统计
- if (selectedAssignment.value) {
- loadAllStudentAssignmentStatus(selectedAssignment.value.assignmentId)
- }
- }
- // 处理页码改变
- const handleCurrentChange = (val: number) => {
- currentPage.value = val
- }
-
- // 获取用于排序的分数值
- const getScoreForSort = (student: StudentAssignmentStatusDTO) => {
- if ((student.status === 'CORRECTED' || student.status === 'LATE_SUBMITTED_CORRECTED') && student.score !== null) {
- return student.score
- } else if (student.status === 'SUBMITTED' || student.status === 'LATE_SUBMITTED') {
- return -1 // 未批改排在未提交前面
- } else {
- return -2 // 未提交排在最后
- }
- }
-
- // 切换排序状态
- const toggleSort = () => {
- sortOrder.value = (sortOrder.value + 1) % 3
- }
-
- // 获取排序图标样式
- const getSortIconClass = () => {
- return {
- 'sort-asc': sortOrder.value === 2,
- 'sort-desc': sortOrder.value === 1,
- 'sort-default': sortOrder.value === 0
- }
- }
-
- // 获取状态样式类
- const getStatusClass = (status: string) => {
- const mappedStatus = statusMap[status] || status
- return `status-${mappedStatus.replace(/[^a-zA-Z0-9]/g, '')}`
- }
-
- // 获取分数样式类
- const getScoreClass = (row: StudentAssignmentStatusDTO) => {
- if (row.status === 'NOT_SUBMITTED') return 'score-not-submitted'
- if (row.status === 'SUBMITTED' || row.status === 'LATE_SUBMITTED') return 'score-not-graded'
- if ((row.status === 'CORRECTED' || row.status === 'LATE_SUBMITTED_CORRECTED') && row.score !== null) {
- return row.score < 60 ? 'score-low' : 'score-high'
- }
- return ''
- }
-
- // 获取分数显示内容
- const getScoreDisplay = (row: StudentAssignmentStatusDTO) => {
- if (row.status === 'NOT_SUBMITTED') return '未提交'
- if (row.status === 'SUBMITTED' || row.status === 'LATE_SUBMITTED') return '未批改'
- if (row.status === 'CORRECTED' || row.status === 'LATE_SUBMITTED_CORRECTED') {
- return row.score !== null ? row.score : '未批改'
- }
- return '未批改'
- }
-
- // 判断是否为补交状态
- const isLateSubmission = (status: string) => {
- return status === 'LATE_SUBMITTED' || status === 'LATE_SUBMITTED_CORRECTED'
- }
-
- // 处理批改操作
- const handleCorrect = (row: StudentAssignmentStatusDTO) => {
- console.log('批改学生作业:', row)
-
- // 跳转到批改页面,路径为 home/assignment/:assignmentId/correct,并传递studentId参数
- if (selectedAssignment.value) {
- router.push({
- path: `/home/assignment/${selectedAssignment.value.assignmentId}/correct`,
- query: {
- studentId: row.studentId.toString()
- }
- })
- }
- }
-
- // 加载班级列表
- const loadClassList = async (courseId: number) => {
- try {
- const response = await apis.getClassesByCourse(courseId)
- if (response.data.code === 200) {
- classList.splice(0, classList.length, ...response.data.data)
- }
- } catch (error) {
- console.error('加载班级列表失败:', error)
- }
- }
-
- // 加载学生作业状态
- const loadStudentAssignmentStatus = async (classId: string, assignmentId: string) => {
- try {
- const response = await apis.getAssignmentStatusByClass(classId, assignmentId)
- if (response.data.code === 200) {
- // 获取班级名称
- const classItem = classList.find(c => c.classId.toString() === classId)
- const className = classItem ? classItem.className : '未知班级'
- // console.log(response.data.data)
- // 为每个学生建立班级映射关系
- response.data.data.forEach((student: StudentAssignmentStatusDTO) => {
- studentClassMap.set(student.studentId, className)
- })
-
- // 追加数据而不是替换
- studentList.push(...response.data.data)
- }
- } catch (error) {
- console.error('加载学生作业状态失败:', error)
- }
- }
-
- // 当选择作业时加载相关数据
- const onAssignmentSelected = async (assignment: any) => {
- if (assignment && assignment.courseId) {
- // 首先加载班级列表
- await loadClassList(assignment.courseId)
-
- // 加载所有班级的学生作业状态
- if (classList.length > 0) {
- await loadAllStudentAssignmentStatus(assignment.assignmentId)
- }
- }
- }
-
- // 加载所有班级的学生作业状态
- const loadAllStudentAssignmentStatus = async (assignmentId: number) => {
- try {
- // 清空现有学生数据
- studentList.splice(0, studentList.length)
-
- // 遍历所有班级,加载每个班级的学生数据
- for (const classItem of classList) {
- await loadStudentAssignmentStatus(classItem.classId.toString(), assignmentId.toString())
- }
-
- // 更新统计数据
- updateStatsData()
- } catch (error) {
- console.error('加载所有学生作业状态失败:', error)
- }
- }
-
- // 获取学生班级名称
- const getStudentClassName = (student: StudentAssignmentStatusDTO) => {
- // 由于StudentAssignmentStatusDTO中没有班级信息,我们需要通过其他方式获取
- // 这里暂时返回一个默认值,实际项目中可能需要通过API获取学生班级信息
- return studentClassMap.get(student.studentId) || '未知班级'
- }
-
- // 更新统计数据
- const updateStatsData = () => {
- console.log(studentList)
- const total = studentList.length
- const corrected = studentList.filter(student =>
- student.status === 'CORRECTED' || student.status === 'LATE_SUBMITTED_CORRECTED'
- ).length
- const submittedNotCorrected = studentList.filter(student =>
- student.status === 'SUBMITTED' || student.status === 'LATE_SUBMITTED'
- ).length
- const notSubmitted = studentList.filter(student => student.status === 'NOT_SUBMITTED').length
-
- statsData.totalStudents = total
- statsData.correctedCount = corrected
- statsData.submittedNotCorrectedCount = submittedNotCorrected
- statsData.notSubmittedCount = notSubmitted
- }
-
-
- const openSearchDialog = () => {
- searchDialogVisible.value = true
- // 延迟聚焦,确保对话框渲染完成
- setTimeout(() => {
- if (dialogSearchInput.value) {
- dialogSearchInput.value.focus()
- }
- }, 100)
- }
-
- const handleCloseSearchDialog = (done) => {
- searchQuery.value = ''
- searchResults.value = []
- done()
- }
-
- const performSearch = () => {
- const query = searchQuery.value.trim().toLowerCase()
- if (!query) {
- searchResults.value = []
- return
- }
-
- const results = []
-
- // 搜索课程和作业
- courseList.forEach(course => {
- // 搜索课程
- if (course.courseName.toLowerCase().includes(query)) {
- results.push({
- id: course.courseId,
- name: course.courseName,
- type: 'course'
- })
- }
-
- // 搜索作业
- course.assignments.forEach(assignment => {
- if (assignment.assignmentName.toLowerCase().includes(query)) {
- results.push({
- id: assignment.assignmentId,
- name: assignment.assignmentName,
- courseName: course.courseName,
- type: 'assignment'
- })
- }
- })
- })
-
- searchResults.value = results
- }
-
- const handleSearchResultClick = (result) => {
- if (result.type === 'course') {
- // 展开对应的课程
- const course = courseList.find(c => c.courseId === result.id)
- if (course) {
- course.expanded = true
- }
- } else {
- // 选中对应的作业并展开对应课程
- courseList.forEach(course => {
- const assignment = course.assignments.find(a => a.assignmentId === result.id)
- if (assignment) {
- course.expanded = true
- }
- })
- selectAssignment(result.id)
- }
- // 关闭弹窗
- searchDialogVisible.value = false
- searchQuery.value = ''
- searchResults.value = []
- }
-
- // 自动选中课程和作业的函数
- const autoSelectFromRoute = () => {
- const courseIdFromRoute = route.query.courseId
- const assignmentIdFromRoute = route.query.assignmentId
- const fromCorrect = route.query.fromCorrect
-
- if (fromCorrect && courseIdFromRoute && assignmentIdFromRoute) {
- const courseId = Number(courseIdFromRoute)
- const assignmentId = Number(assignmentIdFromRoute)
-
- console.log('准备自动选中:', { courseId, assignmentId })
-
- // 使用递归检查数据是否加载完成
- const checkAndSelect = (attempts = 0) => {
- if (attempts > 20) { // 最多尝试20次,避免无限循环
- console.warn('自动选中超时,数据可能未加载完成')
- return
- }
-
- const course = courseList.find(c => c.courseId === courseId)
- if (course && course.assignments.length > 0) {
- // 数据已加载,执行选中
- course.expanded = true
-
- // 确保作业存在
- const assignment = course.assignments.find(a => a.assignmentId === assignmentId)
- if (assignment) {
- selectAssignment(assignmentId)
- console.log('自动选中成功:', { courseName: course.courseName, assignmentName: assignment.assignmentName })
-
- // 清理URL参数,避免刷新时重复执行
- router.replace({
- name: 'myCorrectWithCourse'
- })
- } else {
- console.warn('未找到指定的作业:', assignmentId)
- }
- } else {
- // 数据未加载完成,继续等待
- setTimeout(() => checkAndSelect(attempts + 1), 200)
- }
- }
-
- checkAndSelect()
- }
- }
-
- // 组件挂载时加载数据
- onMounted(async () => {
- await loadCourses()
- // 检查是否需要自动选中
- autoSelectFromRoute()
- })
- </script>
- <script lang="ts">
- export default {
- name: "CoursePage"
- }
- </script>
- <style scoped>
- .course-page {
- display: flex;
- height: 95vh;
- background-color: #f5f5f5;
- font-family: "Noto Sans SC", sans-serif;
- }
- .left-sidebar {
- width: 280px;
- background-color: #F0F2F5;
- border-right: 1px solid #e8e8e8;
- display: flex;
- flex-direction: column;
- height: 100vh;
- flex-shrink: 0; /* 防止侧边栏被压缩 */
- }
- .platform-header {
- height: 60px;
- background-color: #F0F2F5;
- border-bottom: 1px solid #e8e8e8;
- display: flex;
- align-items: center;
- justify-content: center;
- padding: 0 20px;
- }
- .platform-name {
- color: #606266;
- font-size: 24px;
- font-weight: 400;
- font-family: "Noto Sans SC", sans-serif;
- }
- .search-section {
- padding: 16px 20px;
- border-bottom: 1px solid #e8e8e8;
- background-color: #F0F2F5;
- }
- .search-input-container {
- position: relative;
- display: flex;
- align-items: center;
- font-family: "Noto Sans SC", sans-serif;
- }
- .search-icon {
- position: absolute;
- left: 12px;
- color: #999;
- font-size: 16px;
- }
- .search-input {
- width: 100%;
- height: 36px;
- padding: 0 12px 0 36px;
- border: 1px solid #d9d9d9;
- border-radius: 6px;
- font-size: 14px;
- outline: none;
- background-color: #FFFFFF;
- font-family: "Noto Sans SC", sans-serif;
- }
- .search-input:focus {
- border-color: #1890ff;
- background-color: white;
- }
- .menu-section {
- flex: 1;
- overflow-y: auto;
- overflow-x: hidden; /* 防止水平滚动 */
- padding: 0;
- height: calc(100vh - 120px);
- width: 100%; /* 确保宽度不超过父容器 */
- }
- .menu-item {
- margin-bottom: 0px;
- }
- .course-header {
- display: flex;
- align-items: center;
- padding: 12px 20px;
- cursor: pointer;
- transition: background-color 0.2s;
- font-family: "Noto Sans SC", sans-serif;
- background-color: #F0F2F5;
- color: #606266;
- }
- .course-header:hover {
- background-color: #FFFFFF;
- }
- .expand-icon {
- font-size: 12px;
- color: #666;
- margin-right: 8px;
- transition: transform 0.2s;
- }
- .expand-icon.expanded {
- transform: rotate(0deg);
- }
- .course-icon {
- font-size: 16px;
- color: #666;
- margin-right: 8px;
- }
- .course-name {
- font-size: 14px;
- color: #606266;
- font-weight: 500;
- font-family: "Noto Sans SC", sans-serif;
- }
- .assignment-list {
- background-color: #fafafa;
- }
- .assignment-item {
- display: flex;
- align-items: center;
- padding: 8px 20px 8px 48px;
- cursor: pointer;
- transition: background-color 0.2s;
- font-family: "Noto Sans SC", sans-serif;
- background-color: #F0F2F5;
- color: #606266;
- white-space: nowrap; /* 防止文本换行 */
- overflow: hidden; /* 隐藏超出部分 */
- text-overflow: ellipsis; /* 显示省略号 */
- }
- .assignment-item:hover {
- background-color: #FFFFFF;
- }
- .assignment-item.active {
- background-color: rgba(112, 187, 219, 0.50);
- border-radius: 10px;
- opacity: 0.8;
- }
- .assignment-icon {
- font-size: 14px;
- color: #606266;
- margin-right: 8px;
- }
- .assignment-icon.active-icon {
- color: #435FE9;
- }
- .assignment-name {
- font-size: 13px;
- font-weight: 500;
- color: #606266;
- font-family: "Noto Sans SC", sans-serif;
- flex: 1;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- }
- .assignment-item.active .assignment-name {
- color: #435FE9;
- font-weight: 500;
- }
- /* 加载状态样式 */
- .loading-container {
- display: flex;
- justify-content: center;
- align-items: center;
- padding: 20px;
- }
- .loading-text {
- color: #606266;
- font-size: 14px;
- font-family: "Noto Sans SC", sans-serif;
- }
- .right-content {
- flex: 1;
- background-color: white;
- padding: 20px;
- height: 100vh;
- }
- /* 空白状态样式 */
- .empty-state {
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- }
- .empty-content {
- text-align: center;
- color: #999;
- }
- .empty-icon {
- font-size: 64px;
- color: #d9d9d9;
- margin-bottom: 16px;
- }
- .empty-text {
- font-size: 16px;
- font-family: "Noto Sans SC", sans-serif;
- }
- /* 作业内容样式 */
- .assignment-content {
- height: 100%;
- display: flex;
- flex-direction: column;
- }
-
- /* 右上角按钮样式 */
- .top-actions {
- display: flex;
- justify-content: flex-end;
- margin-bottom: 10px;
- }
-
- .dashboard-button {
- background-color: #4A90C4;
- border-color: #4A90C4;
- border-radius: 4px;
- padding: 6px 12px;
- font-size: 12px;
- font-family: "Noto Sans SC", sans-serif;
- }
-
- /* 统计卡片区域样式 */
- .stats-container {
- display: flex;
- justify-content: space-around;
- align-items: center;
- margin-bottom: 5px;
- padding: 0;
- gap: 16px;
- }
-
- .stats-card {
- display: flex;
- align-items: center;
- background: white;
- border-radius: 8px;
- padding: 16px;
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
- min-width: 180px;
- max-width: 220px;
- }
-
- .stats-icon {
- width: 48px;
- height: 48px;
- border-radius: 8px;
- display: flex;
- align-items: center;
- justify-content: center;
- margin-right: 12px;
- font-size: 24px;
- color: white;
- }
-
- .user-icon {
- background-color: #70BBD9;
- }
-
- .completed-icon {
- background-color: #90D7B4;
- }
-
- .pending-icon {
- background-color: #B8B8B8;
- }
-
- .not-submitted-icon {
- background-color: #F5A658;
- }
-
- .stats-content {
- flex: 1;
- }
-
- .stats-label {
- font-size: 14px;
- color: #666;
- margin-bottom: 4px;
- font-family: "Noto Sans SC", sans-serif;
- }
-
- .stats-value {
- font-size: 24px;
- font-weight: 600;
- color: #333;
- font-family: "Noto Sans SC", sans-serif;
- }
-
-
- .assignment-body {
- flex: 1;
- padding: 20px 0;
- }
-
- /* 作业标题区域 */
- .assignment-title-section {
- margin-bottom: 20px;
- }
-
- .assignment-full-title {
- font-size: 18px;
- font-weight: 600;
- color: #333;
- margin: 0;
- font-family: "Noto Sans SC", sans-serif;
- }
-
- /* 筛选区域样式 */
- .filter-section {
- margin-bottom: 20px;
- }
-
- .filter-controls {
- display: flex;
- align-items: center;
- gap: 12px;
- }
-
- .reset-icon {
- font-size: 18px;
- color: #666;
- cursor: pointer;
- padding: 8px;
- border-radius: 4px;
- transition: background-color 0.2s;
- }
-
- .reset-icon:hover {
- background-color: #f5f5f5;
- }
-
- .search-input-wrapper {
- flex: 1;
- max-width: 300px;
- }
-
- .filter-search-input {
- width: 90%;
- height: 32px;
- padding: 0 12px;
- border: 1px solid #d9d9d9;
- border-radius: 4px;
- font-size: 14px;
- outline: none;
- font-family: "Noto Sans SC", sans-serif;
- }
-
- .filter-search-input:focus {
- border-color: #4A90C4;
- }
-
- .filter-select {
- width: 120px;
- }
-
- .search-button {
- background-color: #4A90C4;
- border-color: #4A90C4;
- font-family: "Noto Sans SC", sans-serif;
- }
-
- /* 表格区域样式 */
- .table-section {
- margin-bottom: 20px;
- }
-
- .student-table {
- width: 100%;
- font-family: "Noto Sans SC", sans-serif;
- }
-
- /* 状态标签样式 */
- .status-badge {
- padding: 4px 8px;
- border-radius: 4px;
- font-size: 12px;
- font-weight: 500;
- display: inline-block;
- width: 100%;
- text-align: left;
- font-family: "Noto Sans SC", sans-serif;
- }
-
- /* 状态列单元格左对齐 */
- .student-table .el-table__cell {
- text-align: left !important;
- }
-
- .student-table .el-table__header-wrapper .el-table__cell {
- text-align: left !important;
- }
-
- .status-未提交 {
- background-color: #F4A261;
- color: white;
- }
-
- .status-已提交未批改 {
- background-color: #D9D9D9;
- color: #666;
- }
-
- .status-已批改 {
- background-color: #7ADBB0;
- color: white;
- }
-
- .status-补交未批改 {
- background-color: #F2A947;
- color: white;
- }
-
- .status-补交已批改 {
- background-color: #52C41A;
- color: white;
- }
-
- /* 分数标签样式 */
- .score-badge {
- padding: 4px 8px;
- border-radius: 4px;
- font-size: 12px;
- font-weight: 500;
- display: inline-block;
- min-width: 60px;
- text-align: center;
- font-family: "Noto Sans SC", sans-serif;
- }
-
- .score-not-submitted {
- background-color: #F4A261;
- color: white;
- }
-
- .score-not-graded {
- background-color: #D9D9D9;
- color: #666;
- }
-
- .score-low {
- background-color: #F0C05A;
- color: white;
- }
-
- .score-high {
- background-color: #7ADBB0;
- color: white;
- }
-
- /* 操作按钮样式 */
- .action-button {
- width: 60px;
- height: 30px;
- border-radius: 4px;
- background-color: #4A90C4;
- border-color: #4A90C4;
- padding: 4px 8px;
- font-size: 13px;
- font-family: "Noto Sans SC", sans-serif;
- }
-
- /* 禁用状态的按钮样式 */
- .action-button:disabled {
- background-color: #f5f5f5;
- border-color: #d9d9d9;
- color: #bfbfbf;
- cursor: not-allowed;
- }
-
- .action-button:disabled .correct-icon {
- color: #bfbfbf;
- }
- /* 批改按钮图标样式 */
- .correct-icon {
- font-size: 16px;
- margin-right: 4px;
- }
-
- /* 排序头部样式 */
- .score-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- cursor: pointer;
- user-select: none;
- font-family: "Noto Sans SC", sans-serif;
- }
-
- .sort-icon {
- font-size: 14px;
- color: #999;
- transition: color 0.2s;
- }
-
- .sort-icon.sort-asc {
- color: #4A90C4;
- transform: rotate(0deg);
- }
-
- .sort-icon.sort-desc {
- color: #4A90C4;
- transform: rotate(180deg);
- }
-
- .sort-icon.sort-default {
- color: #999;
- }
-
- .score-header:hover .sort-icon {
- color: #4A90C4;
- }
-
- /* 补交标识样式 */
- .late-submission-badge {
- padding: 4px 8px;
- background-color: #C45C4A;
- color: white;
- border-radius: 4px;
- font-size: 12px;
- font-weight: 500;
- display: inline-block;
- min-width: 60px;
- text-align: center;
- font-family: "Noto Sans SC", sans-serif;
- }
-
- /* 搜索弹窗样式 */
- .search-dialog-container {
- display: flex;
- flex-direction: column;
- height: 60vh;
- }
- .dialog-search-section {
- padding-bottom: 16px;
- border-bottom: 1px solid #e8e8e8;
- margin-bottom: 16px;
- }
- .dialog-search-input-container {
- position: relative;
- display: flex;
- align-items: center;
- font-family: "Noto Sans SC", sans-serif;
- }
- .dialog-search-icon {
- position: absolute;
- left: 12px;
- color: #999;
- font-size: 18px;
- }
- .dialog-search-input {
- width: 100%;
- height: 40px;
- padding: 0 12px 0 40px;
- border: 1px solid #d9d9d9;
- border-radius: 6px;
- font-size: 16px;
- outline: none;
- background-color: #FFFFFF;
- font-family: "Noto Sans SC", sans-serif;
- }
- .dialog-search-input:focus {
- border-color: #1890ff;
- }
- .search-results-section {
- flex: 1;
- overflow-y: auto;
- }
- .no-results {
- height: 100%;
- display: flex;
- align-items: center;
- justify-content: center;
- color: #999;
- font-size: 14px;
- font-family: "Noto Sans SC", sans-serif;
- }
- .search-results-list {
- height: 100%;
- overflow-y: auto;
- }
- .search-result-item {
- display: flex;
- align-items: center;
- padding: 12px 16px;
- cursor: pointer;
- border-bottom: 1px solid #e8e8e8;
- transition: background-color 0.2s;
- font-family: "Noto Sans SC", sans-serif;
- }
- .search-result-item:hover {
- background-color: #F0F2F5;
- }
- .result-icon {
- font-size: 18px;
- color: #606266;
- margin-right: 12px;
- }
- .assignment-result-icon {
- font-size: 16px;
- margin-left: 16px;
- }
- .result-content {
- flex: 1;
- display: flex;
- flex-direction: column;
- }
- .result-title {
- font-size: 14px;
- font-weight: 500;
- color: #606266;
- font-family: "Noto Sans SC", sans-serif;
- }
- .result-path {
- font-size: 12px;
- color: #999;
- margin-top: 4px;
- font-family: "Noto Sans SC", sans-serif;
- }
- .example-pagination-block {
- margin-top: 10px;
- }
- </style>
|