Преглед изворни кода

fix: 修复了课程广场展示问题,将任课教师的姓名显示逻辑移到后端; 修复作业详情页面老师姓名显示问题; 修复批改页面状态显示问题。

201250038 пре 1 година
родитељ
комит
38f5940dc7

+ 3 - 0
src/types/vo.ts

@@ -38,6 +38,8 @@ export interface IAssignment {
 
     teacherId: number; // 发布作业的老师的Id
 
+    teacherName: string; // 发布作业的老师的姓名
+
     courseId: number; // 哪个课程下的assignment
 
     startTime: string;
@@ -105,6 +107,7 @@ export interface CourseVO {
     courseId: number;
     courseName: string;
     teacherIds: number[];
+    teacherNames: string[];
     courseImages: string[];
     targetGrade: string;
     startTime: string;

+ 23 - 17
src/views/CorrectPage/AssignmentPage.vue

@@ -42,7 +42,13 @@
       <el-table-column prop="assignmentName" label="作业名称" width="400"/>
       <el-table-column prop="description" label="描述" width="500"/>
       <el-table-column prop="endTime" label="截止时间" sortable/>
-      <el-table-column prop="status" label="状态" sortable/>
+      <el-table-column prop="status" label="状态" sortable>
+        <template #default="{row}">
+          <el-tag v-if="row.status === AssignmentStatus.NOT_STARTED" type="info">未发布</el-tag>
+          <el-tag v-else-if="row.status === AssignmentStatus.PROCEEDING" type="success">进行中</el-tag>
+          <el-tag v-else-if="row.status === AssignmentStatus.FINISHED" type="danger">已截止</el-tag>
+        </template>
+      </el-table-column>
       <el-table-column label="操作">
         <template #default="scope">
           <el-button @click="handleCorrect(scope.row.assignmentId)" style="margin-right: 0; margin-left: 0;padding-left: 10px; padding-right: 10px" color="#597D3B">
@@ -159,7 +165,7 @@
   const processData = () => {
     for (let i = 0; i < pageInfo.tableData.length; i++) {
       pageInfo.tableData[i].endTime = formatDate(pageInfo.tableData[i].endTime)
-    }
+    }    
   }
 
   onMounted(() => {
@@ -167,21 +173,21 @@
     fetchData(query)
   })
 
-  let state = ref(null)
-  const stateOptions = [
-    {
-      value: AssignmentStatus.NOT_STARTED,
-      label: "未发布"
-    },
-    {
-      value: AssignmentStatus.PROCEEDING,
-      label: "进行中"
-    },
-    {
-      value: AssignmentStatus.FINISHED,
-      label: "已截止"
-    },
-  ]
+  // let state = ref(null)
+  // const stateOptions = [
+  //   {
+  //     value: AssignmentStatus.NOT_STARTED,
+  //     label: "未发布"
+  //   },
+  //   {
+  //     value: AssignmentStatus.PROCEEDING,
+  //     label: "进行中"
+  //   },
+  //   {
+  //     value: AssignmentStatus.FINISHED,
+  //     label: "已截止"
+  //   },
+  // ]
 
 </script>
 

+ 6 - 10
src/views/CorrectPage/CorrectAssignmentPage.vue

@@ -82,18 +82,15 @@
 </template>
 
 <script lang="ts" setup>
-import {Refresh, ZoomIn, ArrowLeft, Search} from "@element-plus/icons-vue";
+import {Refresh, ZoomIn, ArrowLeft} from "@element-plus/icons-vue";
   import {inject, onMounted, reactive, ref} from "vue";
   import useApis from "@/apis";
   import {useStore} from "@/store";
-  import type {AssignmentVO, CourseVO, engagementVO, IAssignment} from "@/types/vo";
+  import type {AssignmentVO, IAssignment} from "@/types/vo";
   import router from "@/router";
   import {useRoute} from "vue-router";
   import "./CorrectAssignmentPage.scss"
-  import {AssignmentCompletionStatus, AssignmentStatus} from "@/types/enums";
-  import type {EngagementQuery} from "@/types/query";
-// import * as process from "node:process";
-import {useFormatDate} from "@/hooks/useFormatDate";
+  import {AssignmentCompletionStatus} from "@/types/enums";
 
   const apis = useApis()
   const store = useStore()
@@ -218,12 +215,11 @@ import {useFormatDate} from "@/hooks/useFormatDate";
         })
   }
 
+  /*
+  * 处理状态
+   */
   async function processData(data:any){
     for(let i = 0; i < data.tableData.length; i++){
-      apis.findUserById(data.tableData[i].studentId)
-          .then((res:any)=>{
-            data.tableData[i].studentName = res.data.data.records[0].name
-          })
       for(let j = 0; j < statusOptions.length; j++){
         if(data.tableData[i].status == statusOptions[j].value){
           data.tableData[i].statusName = statusOptions[j].label

+ 3 - 13
src/views/CourseSquare/component/AllCourse/MoreCourse.vue

@@ -20,7 +20,7 @@
           <div class="course-item-content">
             <div style="font-weight: bold; font-size: 16px; margin: 5px 0">{{item.courseName}}</div>
             <div style="line-height: 1.5" class="collapsed" ><span style="color: rgba(0, 0, 0, 0.6)">课程描述:</span>{{item.description}}</div>
-            <div style="line-height: 1.5; margin-top: 5px" class="collapsed" ><span  style="color: rgba(0, 0, 0, 0.6)">任课教师:</span>{{item.teacherIds.join(",")}}</div>
+            <div style="line-height: 1.5; margin-top: 5px" class="collapsed" ><span  style="color: rgba(0, 0, 0, 0.6)">任课教师:</span>{{item.teacherNames.join(",")}}</div>
           </div>
         </el-card>
 
@@ -38,7 +38,7 @@
           <div class="course-item-content">
             <div style="font-weight: bold; font-size: 16px; margin: 5px 0">{{item.courseName}}</div>
             <div style="line-height: 1.5" class="collapsed" ><span style="color: rgba(0, 0, 0, 0.6)">课程描述:</span>{{item.description}}</div>
-            <div style="line-height: 1.5; margin-top: 5px" class="collapsed" ><span  style="color: rgba(0, 0, 0, 0.6)">任课教师:</span>{{item.teacherIds.join(",")}}</div>
+            <div style="line-height: 1.5; margin-top: 5px" class="collapsed" ><span  style="color: rgba(0, 0, 0, 0.6)">任课教师:</span>{{item.teacherNames.join(",")}}</div>
           </div>
         </el-card>
 
@@ -173,17 +173,7 @@ const fetchData = () => {
 
 const processData = () => {
   for(let i:number = 0; i < pageInfo.courseData.length; i++){
-    for(let j = 0; j < pageInfo.courseData[i].teacherIds.length; j++){
-      apis.findUserById(pageInfo.courseData[i].teacherIds[j])
-          .then((res:any) => {
-            pageInfo.courseData[i].teacherIds[j] = res.data.data.records[0].name
-          })
-          .catch((err:any) => {
-            console.log("错误信息",err)
-          })
-    }
-  }
-  for(let i:number = 0; i < pageInfo.courseData.length; i++){
+    console.log(pageInfo.courseData[i].courseImages[0])
     pageInfo.courseData[i].courseImages[0] = pageInfo.courseData[i].courseImages[0].split("?")[0]
   }
 }

+ 4 - 77
src/views/CourseSquare/component/Course/index.vue

@@ -21,7 +21,7 @@
         <div class="course-item-content">
           <div style="font-weight: bold; font-size: 16px; margin: 5px 0">{{item.courseName}}</div>
           <div style="line-height: 1.5;" class="collapsed" ><span style="color: rgba(0, 0, 0, 0.6)">课程描述:</span>{{item.description}}</div>
-          <div style="line-height: 1.5; margin-top: 5px" class="collapsed" ><span  style="color: rgba(0, 0, 0, 0.6)">任课教师:</span>{{item.teacherIds.join(",")}}</div>
+          <div style="line-height: 1.5; margin-top: 5px" class="collapsed" ><span  style="color: rgba(0, 0, 0, 0.6)">任课教师:</span>{{item.teacherNames.join(",")}}</div>
         </div>
       </el-card>
       <template v-if="getCoursesSlice().length < 5">
@@ -54,75 +54,13 @@
   const role:'teachers' | 'student' = store.user.role === 'STUDENT' ?   'student':'teachers';
 
   const props = defineProps<{
-    title:string,
+    title: string,
     type: 'all' | 'my'
   }>()
 
   // 课程数据
   const courses = reactive({
-    course: [
-      {
-        courseId: 5,
-        courseName: '英文论文写作',
-        description: '',
-        teacherIds: [],
-        courseImages: [],
-        targetGrade: null,
-        startTime: new Date(),
-        endTime: new Date(),
-      },
-      {
-        courseId: 7,
-        courseName: '数学分析',
-        description: '',
-        teacherIds: [],
-        courseImages: [],
-        targetGrade: null,
-        startTime: new Date(),
-        endTime: new Date(),
-      },
-      {
-        courseId: 8,
-        courseName: '线性代数',
-        description: '',
-        teacherIds: [],
-        courseImages: [],
-        targetGrade: null,
-        startTime: new Date(),
-        endTime: new Date(),
-      },
-      // {
-      //   courseId: 4,
-      //   courseName: '计算机科学',
-      //   description: '',
-      //   teacherIds: [],
-      //   courseImages: [],
-      //   targetGrade: null,
-      //   startTime: new Date(),
-      //   endTime: new Date(),
-      // },
-      // {
-      //   courseId: 5,
-      //   courseName: '物理学基础',
-      //   description: '',
-      //   teacherIds: [],
-      //   courseImages: [],
-      //   targetGrade: null,
-      //   startTime: new Date(),
-      //   endTime: new Date(),
-      // },
-      // {
-      //   courseId: 6,
-      //   courseName: '化学基础',
-      //   description: '',
-      //   teacherIds: [],
-      //   courseImages: [],
-      //   targetGrade: null,
-      //   startTime: new Date(),
-      //   endTime: new Date(),
-      // },
-      // 可以根据需要添加更多课程对象
-    ],
+    course: [],
   })
 
   //只获取前五个课程
@@ -200,20 +138,9 @@
   }
 
   /*
-  用于显示教师姓名
+  * 处理课程图片
    */
   const processCourses = () => {
-    for(let i:number = 0; i < courses.course.length; i++){
-      for(let j = 0; j < courses.course[i].teacherIds.length; j++){
-        apis.findUserById(courses.course[i].teacherIds[j])
-            .then((res:any) => {
-              courses.course[i].teacherIds[j] = res.data.data.records[0].name
-            })
-            .catch((err:any) => {
-              console.log("错误信息",err)
-            })
-      }
-    }
     for(let i:number = 0; i < courses.course.length; i++){
       courses.course[i].courseImages[0] = courses.course[i].courseImages[0].split("?")[0]
     }

+ 1 - 10
src/views/CourseSquare/component/CourseDetails/index.vue

@@ -308,18 +308,9 @@ const handleChange = (file,fileList) => {
 
 
 /*
-  用于显示教师姓名
+  用于处理课程图片
    */
 const processCourses = () => {
-  for(let i = 0; i < dataForm.teacherIds.length; i++){
-    apis.findUserById(dataForm.teacherIds[i])
-        .then((res:any) => {
-          dataForm.teacherNames[i] = res.data.data.records[0].name
-        })
-        .catch((err:any) => {
-          console.log("错误信息",err)
-        })
-  }
   dataForm.courseImages[0] = dataForm.courseImages[0].split("?")[0]
 }
 

+ 2 - 1
src/views/HomeworkPage/component/HomeworkDetail.vue

@@ -14,7 +14,7 @@
         </div>
         <div class="item">
           <span style="font-weight: 600">发布老师: </span>
-          {{data.teacherId}}
+          {{data.teacherName}}
         </div>
         <div class="item">
           <span style="font-weight: 600">截止日期: </span>
@@ -68,6 +68,7 @@ let data = reactive<IAssignment>({
   descriptionFile: null,
   attachments: null,
   teacherId: null,
+  teacherName: "",
   courseId: null,
   startTime: "",
   endTime: "",

+ 7 - 1
src/views/HomeworkPage/index.vue

@@ -33,7 +33,13 @@
       <el-table-column prop="assignmentName" label="课程名称" width="300"/>
       <el-table-column prop="description" label="描述" width="400"/>
       <el-table-column prop="endTime" label="截止时间" sortable  width="200"/>
-      <el-table-column prop="status" label="状态" sortable width="150"/>
+      <el-table-column prop="status" label="状态" sortable width="150">
+        <template #default="{row}">
+          <el-tag v-if="row.status === AssignmentStatus.NOT_STARTED" type="info">未发布</el-tag>
+          <el-tag v-else-if="row.status === AssignmentStatus.PROCEEDING" type="success">进行中</el-tag>
+          <el-tag v-else-if="row.status === AssignmentStatus.FINISHED" type="danger">已截止</el-tag>
+        </template>
+      </el-table-column>
       <el-table-column label="操作" width="100">
         <template #default="scope">
           <el-button @click="handleShowDetail(scope.row.assignmentId)" style="margin-right: 0; margin-left: 0;padding-left: 10px; padding-right: 10px" color="#597D3B">