Przeglądaj źródła

学生端班级模块

stupig-zcx 1 rok temu
rodzic
commit
019a5c9cf4

+ 12 - 0
src/views/ClassPage/StudentClass.vue

@@ -0,0 +1,12 @@
+<template>
+    <div>
+        <h1>学生班级</h1>
+    </div>
+</template>
+
+<script setup lang="ts">
+
+</script>
+
+<style scoped>
+</style>

+ 65 - 55
src/views/ClassPage/StudentDetail.vue

@@ -1,11 +1,13 @@
 <template>
 <template>
     <div class="course-class" v-show="DataLoading">
     <div class="course-class" v-show="DataLoading">
-        <classHeader>{{Studentdata.stuName}}:{{ Studentdata.officialNumber }}</classHeader>
+        <classHeader>{{store.user.role === 'STUDENT'?Coursedata.courseName:Studentdata.stuName}}:{{store.user.role === 'STUDENT'?Classdata.className: Studentdata.officialNumber }} 
+            <template #TeacherName v-if="store.user.role === 'STUDENT'">{{ Coursedata.teacherNames[0] }}</template>
+        </classHeader>
         <div class="content">
         <div class="content">
             <div class="search">
             <div class="search">
                 <img src="@/assets/search.svg" width="20px" height="20px"></img> 
                 <img src="@/assets/search.svg" width="20px" height="20px"></img> 
                 <div class="searchInput">
                 <div class="searchInput">
-                    <input type="text" v-model.trim="searchInput" placeholder="输入姓名或学号">
+                    <input type="text" v-model.trim="searchInput" placeholder="输入作业序号或作业名称">
                     <div class="fix">
                     <div class="fix">
                         <span>搜索</span>
                         <span>搜索</span>
                         <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#b8b8b8" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18l6-6-6-6"/></svg>
                         <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="#b8b8b8" stroke-width="3" stroke-linecap="round" stroke-linejoin="round"><path d="M9 18l6-6-6-6"/></svg>
@@ -121,30 +123,30 @@ const TheSort = ref("无")
 const ShowTheSort = ref("默认")
 const ShowTheSort = ref("默认")
 
 
 const StudentdataLoading = ref(false)
 const StudentdataLoading = ref(false)
-// const CourseDataLoading = ref(false)
-// const ClassDataLoading = ref(false)
+const CourseDataLoading = ref(false)
+const ClassDataLoading = ref(false)
 
 
-// const Coursedata = reactive<CourseDetailVO>({
-//   courseId: null,
-//   courseName: '',
-//   teacherIds: [],
-//   teacherNames: [],
-//   courseImages: [''],
-//   targetGrade: '',
-//   startTime: '',
-//   endTime: '',
-//   createTime: '',
-//   description: '',
-// })
+const Coursedata = reactive<CourseDetailVO>({
+  courseId: null,
+  courseName: '',
+  teacherIds: [],
+  teacherNames: [],
+  courseImages: [''],
+  targetGrade: '',
+  startTime: '',
+  endTime: '',
+  createTime: '',
+  description: '',
+})
 
 
-// const Classdata = reactive<ClassVO>({
-//   classId: null,
-//   className: '',
-//   courseId: null,
-//   stuNumber: null,
-//   classTime: '',
-//   teacherId: null,
-// })
+const Classdata = reactive<ClassVO>({
+  classId: null,
+  className: '',
+  courseId: null,
+  stuNumber: null,
+  classTime: '',
+  teacherId: null,
+})
 const sortMethods = ["默认","成绩从低到高","成绩从高到低","未批改优先","未提交优先"]
 const sortMethods = ["默认","成绩从低到高","成绩从高到低","未批改优先","未提交优先"]
 const Studentdata = ref({
 const Studentdata = ref({
     "officialNumber": 522025312092,
     "officialNumber": 522025312092,
@@ -189,45 +191,50 @@ const Studentdata = ref({
     ]
     ]
 })
 })
 
 
-const identify = () => {
-    if(store.user.role === "STUDENT"){
-        router.push('/404')
-    }
-}
+// const identify = () => {
+//     if(store.user.role === "STUDENT"){
+//         router.push('/404')
+//     }
+// }
 const getStudent = () => {
 const getStudent = () => {
     StudentdataLoading.value = false
     StudentdataLoading.value = false
     console.log(courseId)
     console.log(courseId)
     console.log(studentId)
     console.log(studentId)
     StudentdataLoading.value = true
     StudentdataLoading.value = true
 }
 }
-// const getClass = () => {
-//     console.log("classId:",classId)
-//     Classdata.classId = classId
-//     Classdata.courseId = courseId
-//     Classdata.className = "读写1班"
-//     Classdata.stuNumber = 30
-//     Classdata.classTime = "Mon 10:10"
-//     Classdata.teacherId = 4
+const getClass = () => {
+    console.log("classId:",classId)
+    Classdata.classId = classId
+    Classdata.courseId = courseId
+    Classdata.className = "读写1班"
+    Classdata.stuNumber = 30
+    Classdata.classTime = "Mon 10:10"
+    Classdata.teacherId = 4
 
 
-//     ClassDataLoading.value = true
-// }
+    ClassDataLoading.value = true
+}
 
 
-// const getCourse = () => {
-//   // 获取课程信息
-//   apis.getCourseByCourseId(courseId)
-//       .then((res: any) => {
-//         let data = res.data.data.records[0]
-//         Object.assign(Coursedata, {...data})
-//         CourseDataLoading.value = true
-//       })
-//       .catch((err: any) => {
-//         console.error(err);
-//       })
-// }
+const getCourse = () => {
+  // 获取课程信息
+  apis.getCourseByCourseId(courseId)
+      .then((res: any) => {
+        let data = res.data.data.records[0]
+        Object.assign(Coursedata, {...data})
+        CourseDataLoading.value = true
+      })
+      .catch((err: any) => {
+        console.error(err);
+      })
+}
 
 
 const DataLoading = computed(() => {
 const DataLoading = computed(() => {
 //   return CourseDataLoading.value && ClassDataLoading.value
 //   return CourseDataLoading.value && ClassDataLoading.value
-    return StudentdataLoading
+    if(store.user.role === "STUDENT"){
+        return StudentdataLoading.value && CourseDataLoading.value && ClassDataLoading.value
+    }
+    else{
+        return StudentdataLoading.value
+    }
 })
 })
 const searchData = computed(()=>{
 const searchData = computed(()=>{
     if(searchInput.value===""){
     if(searchInput.value===""){
@@ -290,10 +297,13 @@ watch(ShowTheSort,(newData) =>{
 })
 })
 
 
 onMounted(() => {
 onMounted(() => {
-    identify()
-    // getClass()
-    // getCourse()
+    // identify()
+    if(store.user.role === "STUDENT"){
+        getCourse()
+        getClass()
+    }
     getStudent()
     getStudent()
+    
 })
 })
 </script>
 </script>
 
 

+ 4 - 1
src/views/ClassPage/components/classHeader.vue

@@ -3,6 +3,9 @@
         <div class="title title_border">
         <div class="title title_border">
             <slot></slot>
             <slot></slot>
         </div>
         </div>
+        <div class="title title_border"style="margin-left:-200px;">
+            <slot name="TeacherName"></slot>
+        </div>
         <div class="title" @click="$router.go(-1)" style="padding-right: 4.1vw;cursor: pointer;">
         <div class="title" @click="$router.go(-1)" style="padding-right: 4.1vw;cursor: pointer;">
             <el-icon style="vertical-align: bottom; margin-right: 6px;"><ArrowLeftBold/></el-icon>
             <el-icon style="vertical-align: bottom; margin-right: 6px;"><ArrowLeftBold/></el-icon>
             返回
             返回
@@ -40,7 +43,7 @@ export default {
     font-weight: 700;
     font-weight: 700;
     line-height: 24px;
     line-height: 24px;
     height:28px;
     height:28px;
-    padding: 10px;
+    padding-bottom: 10px;
     display: flex;
     display: flex;
     flex-direction: row;
     flex-direction: row;
     align-items: center;
     align-items: center;

+ 19 - 0
src/views/CourseSquare/component/CourseDetails/index.vue

@@ -45,6 +45,15 @@
               {{dataForm.description}}
               {{dataForm.description}}
             </div>
             </div>
           </template>
           </template>
+          <template v-else-if="activeTab == '班级列表'">
+            <div>
+                <button 
+                style="color: #fff;background-color: #4a90c4;border: none;padding: 5px 10px;border-radius: 5px;cursor: pointer;" 
+                @click="$router.push(`/home/studentDetail?classId=${classId}&courseId=${courseId}&stuId=${store.user.id}`)">
+                查看班级列表
+              </button>
+            </div>
+          </template>
           <template v-else>
           <template v-else>
             <CourseHomeworkTable :disabled="isDisabled()" :columns="columns" :tableData="homeworkList" :role="role" :courseId="dataForm.courseId" :isShowNewHomework="showEdit && role == 'teachers'"/>
             <CourseHomeworkTable :disabled="isDisabled()" :columns="columns" :tableData="homeworkList" :role="role" :courseId="dataForm.courseId" :isShowNewHomework="showEdit && role == 'teachers'"/>
           </template>
           </template>
@@ -140,6 +149,7 @@ const store = useStore()
 const route = useRoute()
 const route = useRoute()
 const role:'teachers' | 'student' = store.user.role === 'STUDENT' ?   'student':'teachers';
 const role:'teachers' | 'student' = store.user.role === 'STUDENT' ?   'student':'teachers';
 
 
+let classId
 const courseId = +route.params.courseId
 const courseId = +route.params.courseId
 
 
 let showCode = ref(true)
 let showCode = ref(true)
@@ -148,6 +158,8 @@ let showEdit = ref(false)
 let visible = ref(false)
 let visible = ref(false)
 let uploadRef = ref()
 let uploadRef = ref()
 
 
+classId = 2
+
 // 用于展示课程信息
 // 用于展示课程信息
 let dataForm = reactive<CourseDetailVO>({
 let dataForm = reactive<CourseDetailVO>({
   courseId: null,
   courseId: null,
@@ -559,7 +571,14 @@ function isDisabled(){
   if(role == "teachers") return !showEdit.value;
   if(role == "teachers") return !showEdit.value;
 }
 }
 
 
+const ShowStudentClass = () => {
+  if(role == "student"){
+    items.value.push({label: "班级列表", key: "班级列表"})
+  }
+}
+
 onMounted(() => {
 onMounted(() => {
+  ShowStudentClass()
   getCourse()
   getCourse()
   getHomeworkList()
   getHomeworkList()