Просмотр исходного кода

Merge branch 'refs/heads/master' into refactor-admin

# Conflicts:
#	src/views/HomeworkPage/index.vue
#	src/views/LoginPage/component/Register.vue
201250038 1 год назад
Родитель
Сommit
8510e1ffb1

+ 4 - 4
src/apis/course.ts

@@ -9,16 +9,16 @@ const courseApis = {
     createCourse(courseDTO: CourseDTO){
       return axiosInstance.post(`${COURSE_PREFIX}`, courseDTO)
     },
-    getCourseByStudentId(studentId: number, page: number=0, size: number=10){
-        return axiosInstance.get(`${COURSE_PREFIX}/byStudent/${studentId}`, {
+    getCourseByStudentId(page: number=0, size: number=10){
+        return axiosInstance.get(`${COURSE_PREFIX}/byStudent`, {
             params: {
                 page,
                 size
             }
         })
     },
-    getCourseByTeacherId(teacherId: number, page: number=0, size: number=10){
-        return axiosInstance.get(`${COURSE_PREFIX}/byTeacher/${teacherId}`, {
+    getCourseByTeacherId(page: number=0, size: number=10){
+        return axiosInstance.get(`${COURSE_PREFIX}/byTeacher`, {
             params: {
                 page,
                 size

+ 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

+ 5 - 15
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]
   }
 }
@@ -205,7 +195,7 @@ const fetchAllCourse = () => {
 
 const fetchCourseByUserId = () => {
   if(role === 'student'){
-    apis.getCourseByStudentId(store.user.id, queryInfo.pageNow, queryInfo.pageSize)
+    apis.getCourseByStudentId(queryInfo.pageNow, queryInfo.pageSize)
         .then((res: any) => {
           console.log(res)
           pageInfo.courseData = res.data.data.records
@@ -218,7 +208,7 @@ const fetchCourseByUserId = () => {
         })
         .finally(() => {});
   } else if(role === "teachers"){
-    apis.getCourseByTeacherId(store.user.id, queryInfo.pageNow, queryInfo.pageSize)
+    apis.getCourseByTeacherId(queryInfo.pageNow, queryInfo.pageSize)
         .then((res: any) => {
           console.log(res.data.data)
           pageInfo.courseData = res.data.data.records

+ 6 - 79
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: [],
   })
 
   //只获取前五个课程
@@ -177,7 +115,7 @@
 
   const fetchCourseByUserId = () => {
     if(role === 'student'){
-      apis.getCourseByStudentId(store.user.id)
+      apis.getCourseByStudentId()
           .then((res: any) => {
             courses.course = res.data.data.records
             processCourses()
@@ -187,7 +125,7 @@
           })
           .finally(() => {});
     } else if(role === "teachers"){
-      apis.getCourseByTeacherId(store.user.id)
+      apis.getCourseByTeacherId()
           .then((res: any) => {
             courses.course = res.data.data.records
             processCourses()
@@ -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]
     }

+ 4 - 13
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]
 }
 
@@ -391,7 +382,7 @@ const getHomeworkList = () => {
   学生,是否显示选课码输入框选课
  */
 const isShowCode = () => {
-  apis.getCourseByStudentId(store.user.id)
+  apis.getCourseByStudentId()
     .then((res: any) => {
       let data = res.data.data.records
       for(let i = 0 ; i < data.length; i++){
@@ -439,10 +430,10 @@ const enroll = () => {
   教师,是否显示编辑课程按钮
  */
 const isShowEdit = () => {
-  apis.getCourseByTeacherId(store.user.id)
+  apis.getCourseByTeacherId()
       .then((res: any) => {
         let total = res.data.data.total
-        apis.getCourseByTeacherId(store.user.id, 1, total)
+        apis.getCourseByTeacherId(1, total)
             .then((res: any) => {
               let data = res.data.data.records
               for(let i = 0 ; i < data.length; i++){

+ 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: "",

+ 12 - 6
src/views/HomeworkPage/index.vue

@@ -31,9 +31,15 @@
       </template>
       <el-table-column type="index"/>
       <el-table-column prop="assignmentName" label="课程名称" width="400"/>
-      <!-- <el-table-column prop="description" label="描述" width="400"/> -->
+<!--      <el-table-column prop="description" label="描述" width="400"/>-->
       <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="操作" 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">
@@ -139,11 +145,11 @@
 
   const fetchData = () => {
     if (role === 'student') {
-      apis.getCourseByStudentId(store.user.id)
+      apis.getCourseByStudentId()
           .then((res: any) => {
             // 获取课程总数
             let total = res.data.data.total;
-            apis.getCourseByStudentId(store.user.id,1,total)
+            apis.getCourseByStudentId(1, total)
                 .then((res: any) => {
                   let data:CourseVO[] = res.data.data.records
                   for(let i = 0; i < data.length; i++){
@@ -152,11 +158,11 @@
                 })
           })
     } else if (role === "teachers") {
-      apis.getCourseByTeacherId(store.user.id)
+      apis.getCourseByTeacherId()
           .then((res: any) => {
             // 获取课程总数
             let total = res.data.data.total;
-            apis.getCourseByTeacherId(store.user.id,1,total)
+            apis.getCourseByTeacherId(1, total)
                 .then((res: any) => {
                   let data:CourseVO[] = res.data.data.records
                   for(let i = 0; i < data.length; i++){

+ 35 - 14
src/views/LoginPage/component/Register.vue

@@ -8,7 +8,7 @@
       <!-- <div style="background-color: #8e8e8e; padding: 20px; width: 600px; border-radius: 5px; margin: 20px auto"> -->
 
       <div class="vessel-title">
-        欢迎注册SEEAI平台账号
+        欢迎注册 SEEAI 平台账号
       </div>
       <!--角色-->
       <el-form :rules="userRules" :model="userRegisterDTO" ref="formRef" :size="formSize">
@@ -45,14 +45,18 @@
           <el-form-item label="验证码" prop="verifyCode" class="form-item">
             <el-input v-model="userRegisterDTO.verifyCode" placeholder="输入验证码"></el-input>
           </el-form-item>
-          <el-button @click="sendVerifyCode"  class="button">发送验证码</el-button>
+          <el-button @click="sendVerifyCode" class="button">发送验证码</el-button>
         </div>
 
         <div style="display: flex; justify-content: center; align-items: center;">
-          <el-button @click="register(formRef)"  class="login-button" >注册</el-button>
+          <el-button @click="register(formRef)" class="login-button">注册</el-button>
+        </div>
+
+        <!-- 返回登录页面,下划线灰色小字 -->
+        <div style="display: flex; justify-content: center; align-items: center; margin-top: 10px;">
+          <router-link to="/login" style="color: #8e8e8e; text-decoration: underline;">已有帐号,去登录?</router-link>
         </div>
 
-        <div class="sign" @click="onClickLogin" style="margin-top: 10px">已有帐号,去登录?</div>
       </el-form>
 
     </div>
@@ -70,7 +74,6 @@ import { reactive, ref } from "vue";
 import useApis from "@/apis";
 import { Role } from "@/types/enums";
 import { type ComponentSize, ElMessage, type FormInstance, type FormRules } from "element-plus";
-import { useRoute } from "vue-router";
 import router from "@/router";
 
 const apis = useApis()
@@ -87,7 +90,7 @@ const roleOptions = [
     value: Role.TEACHER,
     disabled: false
   },
-  
+
 ]
 
 const formSize = ref<ComponentSize>('default')
@@ -144,10 +147,25 @@ const register = async (formEl: FormInstance | undefined) => {
       console.log("合法输入")
       apis.register(userRegisterDTO)
         .then((res: any) => {
-          router.push(`/login`)
+          if (res.data.code === 200) {
+            ElMessage({
+              message: '注册成功',
+              type: 'success',
+            })
+            router.push(`/login`)
+          } else {
+            ElMessage({
+              message: '注册失败: ' + res.data.msg,
+              type: 'error',
+            })
+          }
         })
         .catch((err: any) => {
           console.error(err);
+          ElMessage({
+            message: '注册失败',
+            type: 'error',
+          })
         })
         .finally(() => {
         });
@@ -164,10 +182,17 @@ const register = async (formEl: FormInstance | undefined) => {
 const sendVerifyCode = () => {
   apis.sendVerifyCode(userRegisterDTO.officialEmail)
     .then((res: any) => {
-      ElMessage({
+      if (res.data.code === 200) {
+        ElMessage({
         message: '验证码发送成功,请前往您的邮箱查看',
-        type: 'success',
-      })
+          type: 'success',
+        })
+      } else {
+        ElMessage({
+          message: '验证码发送失败: ' + res.data.msg,
+          type: 'error',
+        })
+      }
     })
     .catch((err: any) => {
       ElMessage({
@@ -179,10 +204,6 @@ const sendVerifyCode = () => {
     .finally(() => {
     });
 }
-
-const onClickLogin = () => {
-  router.push('/login');
-};
 </script>
 
 <script lang="ts">