瀏覽代碼

Merge branch 'master' into correctPage-byXY

xiaoyu 2 年之前
父節點
當前提交
2d28832d2e

+ 2 - 2
src/apis/axios.config.ts

@@ -1,7 +1,8 @@
 import axios from "axios";
 
 // const BASEURL = 'http://47.111.23.171:8081'
-const BASEURL = '/api'
+const BASEURL = 'http://localhost:8080'
+// const BASEURL = 'http://8.130.126.86:8080'
 
 const axiosInstance = axios.create({
     baseURL: BASEURL,
@@ -19,7 +20,6 @@ axiosInstance.interceptors.request.use(
             token = JSON.parse(sessionStorage.getItem('user-storage') as string).token
         }
 
-        console.log(token, "axios.configs")
         // 如果存在token,则每次请求前加入到请求头中
         if (token) config.headers["Authorization"] = token
         return config

+ 11 - 0
src/apis/engagement.ts

@@ -52,6 +52,17 @@ const engagementApis = {
                 assignmentId
             }
         })
+    },
+    getEngagementByAssignmentId(assignmentId:number, page: number=0, size: number=10){
+        return axiosInstance.post(`${ENGAGE_PREFIX}/query`, {
+
+        }, {
+            params: {
+                page,
+                size,
+                assignmentId
+            }
+        })
     }
 }
 

+ 1 - 1
src/components/AIChatter/AIChatter.vue

@@ -41,7 +41,7 @@
           <!--名字-->
           <div style="margin-bottom: 2px">{{ index % 2 === 0 ? 'You' : data.model }}</div>
           <!--内容-->
-          <div :class="$style.content">{{ item.content }}</div>
+          <div :class="$style.content">{{ item?.content }}</div>
         </div>
       </div>
       <div ref="messagesEndRef" />

+ 5 - 4
src/components/WordEditor/WordEditor.vue

@@ -6,7 +6,7 @@
 <template>
     <DocumentEditor
         id="docxEditor"
-        documentServerUrl="http://47.111.23.171:8082/"
+        documentServerUrl="http://139.196.252.184:8082/"
         :config="config"
         @events_onDocumentReady="onDocumentReady"
         @onLoadComponentError="onLoadComponentError"
@@ -32,7 +32,7 @@
 
   const props = defineProps<IProps>()
 
-  const documentServerUrl = 'http://47.111.23.171:8082/';
+  const documentServerUrl = 'http://139.196.252.184:8082/';
 
   // OnlyOffice编辑器配置
   let config = reactive({
@@ -62,14 +62,14 @@
     },
     editorConfig: {
       lang: 'zh-CN',
-      callbackUrl: 'http://47.111.23.171:8081/api/onlyoffice/callback',
+      callbackUrl: 'http://139.196.252.184:8081/api/onlyoffice/callback',
       customization: {
         autosave: false,
         comments: false,
         compactHeader: true,
         compactToolbar: false,
         compatibleFeatures: false,
-        forcesave: true,
+        forceSave: true,
         help: false,
         hideRightMenu: true,
         hideRulers: true,
@@ -133,6 +133,7 @@
 
   // 监听 OnlyOffice组件中的文档状态变化事件
   const onDocumentStateChange = (event: any) => {
+    console.log("监听 OnlyOffice组件中的文档状态变化事件", event.data)
     props.onValueChange?.(event.data);
   };
 </script>

+ 15 - 1
src/router/index.ts

@@ -66,7 +66,21 @@ const router = createRouter({
           name: 'correct',
           component: () => import('../views/CorrectPage/CorrectPage.vue')
         },
-
+        {
+          path: 'myCorrect/course',
+          name: 'myCorrectWithCourse',
+          component: () => import("@/views/CorrectPage/CoursePage.vue")
+        },
+        {
+          path: 'myCorrect/assignment',
+          name: 'myCorrectWithAssignment',
+          component: () => import("@/views/CorrectPage/AssignmentPage.vue")
+        },
+        {
+          path: 'myCorrect/assignment/:assignmentId',
+          name: 'myCorrectWithAssignmentId',
+          component: () => import("@/views/CorrectPage/CorrectAssignmentPage.vue")
+        },
       ]
     },
   ]

+ 2 - 7
src/types/dto.ts

@@ -15,13 +15,6 @@ export interface AssignmentQueryDTO {
     status?: AssignmentStatus;
 }
 
-export enum AssignmentStatus {
-    NOT_STARTED = "NOT_STARTED",
-    PROCEEDING = "PROCEEDING",
-    FINISHED = "FINISHED"
-}
-
-
 export interface EnrollDTO {
     studentId:number;
     courseId:number;
@@ -49,3 +42,5 @@ export interface CourseUpdateDTO {
     description: string; // 课程描述不能缺失
     enrollCode: string; // 选课码不能缺失
 }
+
+

+ 22 - 0
src/types/enums.ts

@@ -0,0 +1,22 @@
+export enum AssignmentStatus {
+    NOT_STARTED = "NOT_STARTED",
+    PROCEEDING = "PROCEEDING",
+    FINISHED = "FINISHED"
+}
+
+export enum AssignmentCompletionStatus {
+    NOT_EDITED = "NOT_EDITED",
+    NOT_SUBMITTED = "NOT_SUBMITTED",
+    SUBMITTED = "SUBMITTED",
+    NOT_DONE = "NOT_DONE",
+    PUBLISHED = "PUBLISHED",
+    NOT_CORRECTED = "NOT_CORRECTED",
+    CORRECTED = "CORRECTED",
+    // NOT_EDITED(0, "NOT_EDITED"), // 待完成,还未进行写作页面进行编辑
+    // NOT_SUBMITTED(1, "NOT_SUBMITTED"), // 未提交,正在完成作业中
+    // SUBMITTED(2, "SUBMITTED"), // 已提交,完成编辑并提交内容
+    // NOT_DONE(3, "NOT_DONE"), // 未完成,到了DDL,仍然没有提交的
+    // PUBLISHED(4, "PUBLISHED"), // 老师已批改并发布
+    // NOT_CORRECTED(5, "NOT_CORRECTED"), //未批改(状态仅老师可见)
+    // CORRECTED(6, "CORRECTED") //已批改、但还未发布(状态仅老师可见)
+}

+ 8 - 0
src/types/query.ts

@@ -1,3 +1,5 @@
+import type {AssignmentCompletionStatus} from "@/types/enums";
+
 export interface CourseQuery {
     courseId:number;
     teacherId:number;
@@ -14,4 +16,10 @@ export interface AssignmentQuery {
     status:string;
 }
 
+export interface EngagementQuery {
+    assignmentId: number,
+    status?: number
+}
+
+
 

+ 19 - 0
src/views/CorrectPage/AssignmentPage.scss

@@ -0,0 +1,19 @@
+.assignment-card-contain {
+  margin: 10px auto 0;
+  height: 100%;
+  width: 80%;
+
+  .title{
+    font-size: 20px;
+    font-weight: 700;
+    padding: 0 15px 15px 15px;
+  }
+
+  .input-group{
+    padding-left: 15px;
+    .search-input{
+      width: 180px;
+      margin: 0 10px 0 10px;
+    }
+  }
+}

+ 191 - 0
src/views/CorrectPage/AssignmentPage.vue

@@ -0,0 +1,191 @@
+<!--
+  Description: 我的作业界面
+  Author: BaiQi
+  Created Date: 2024-7-3
+-->
+<template>
+  <el-card class="assignment-card-contain" shadow="never">
+
+    <el-button class="back-button" text @click="router.push('/home/myCorrect/course')"><el-icon><ArrowLeft /></el-icon>返回</el-button>
+
+    <div class="title">
+      <span>所属课程:{{ courseInfo.courseName }}</span>
+    </div>
+
+    <div class="input-group">
+      <el-button :icon="Refresh" circle @click="doRefresh"></el-button>
+      <!--    <el-select-->
+      <!--        v-model="state"-->
+      <!--        placeholder="状态"-->
+      <!--        size="default"-->
+      <!--        style="width: 150px; margin-left: 10px;"-->
+      <!--    >-->
+      <!--      <el-option-->
+      <!--          v-for="item in stateOptions"-->
+      <!--          :key="item.value"-->
+      <!--          :label="item.label"-->
+      <!--          :value="item.value"-->
+      <!--      />-->
+      <!--    </el-select>-->
+      <el-input class="search-input" v-model="assignmentNameToSearch" placeholder="请输入作业名称" clearable style="width: 180px;"/>
+      <el-button @click="handleSearch" color="#597D3B">
+        <el-icon style="margin-right: 3px" ><Search/></el-icon>
+        查询
+      </el-button>
+    </div>
+
+    <el-table stripe :data="pageInfo.tableData" style="width: 100%" height="100%">
+      <template #empty>
+        暂无作业
+      </template>
+      <el-table-column type="index"/>
+      <el-table-column prop="assignmentName" label="作业名称"/>
+      <el-table-column prop="description" label="描述"/>
+      <el-table-column prop="endTime" label="截止时间" sortable/>
+      <el-table-column prop="status" label="状态" sortable/>
+      <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">
+            <el-icon style="margin-right: 3px"><ZoomIn/></el-icon>
+            批改作业
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <el-pagination
+        small
+        style="font-size: 16px;margin-top: 10px;margin-left: 450px"
+        :page-sizes="[5, 10, 15]"
+        @current-change="handleCurrentChange"
+        @size-change="handleSizeChange"
+        :current-page="queryInfo.pageNow"
+        :page-size="queryInfo.pageSize"
+        layout="total, sizes, prev, pager, next, jumper"
+        :total="pageInfo.total">
+    </el-pagination>
+  </el-card>
+</template>
+
+<script lang="ts" setup>
+  import {Refresh, ZoomIn, Search, ArrowLeft} from "@element-plus/icons-vue";
+  import {inject, onMounted, reactive, ref} from "vue";
+  import useApis from "@/apis";
+  import {useStore} from "@/store";
+  import type {CourseVO, IAssignment} from "@/types/vo";
+  import router from "@/router";
+  import {useRoute} from "vue-router";
+  import "./AssignmentPage.scss"
+  import type {AssignmentQuery} from "@/types/query";
+  import {AssignmentStatus} from "@/types/enums";
+  import {useFormatDate} from "@/hooks/useFormatDate";
+
+  const apis = useApis()
+  const store = useStore()
+  const route = useRoute()
+  const doRefresh:Function = inject("reload")
+  const {formatDate} = useFormatDate()
+  const role:'teachers' | 'student' = store.user.role === 'STUDENT' ?   'student':'teachers';
+
+  // 最终展示的作业
+  let pageInfo = reactive<{
+    tableData: any,
+    total: number
+  }>({
+    tableData: [],
+    total: null,
+  })
+
+  let queryInfo = reactive({
+    pageSize:10,
+    pageNow:1,
+  })
+
+  let courseInfo = reactive<CourseVO>({} as CourseVO)
+
+  let query = reactive<AssignmentQuery>({
+    courseId: +route.query.courseId
+  } as AssignmentQuery)
+
+  const fetchCourseInfo = () => {
+    apis.getCourseByCourseId(+route.query.courseId)
+        .then((res:any) => {
+          Object.assign(courseInfo, res.data.data.records[0])
+        })
+        .catch((err:any) => {
+          console.log("错误信息", err)
+        })
+  }
+
+  const handleCorrect = (assignmentId:number) => {
+    router.push({
+      path:`/home/myCorrect/assignment/${assignmentId}`
+  })
+
+  }
+
+  const handleCurrentChange = (pageNum: number) => {
+    queryInfo.pageNow = pageNum
+    fetchData(query)
+  }
+  const handleSizeChange = (pageSize: number) => {
+    queryInfo.pageSize = pageSize
+    fetchData(query)
+  }
+
+  let assignmentNameToSearch = ref('')
+  const handleSearch = () => {
+    Object.assign(query, {
+      courseId: courseInfo.courseId,
+      assignmentName:assignmentNameToSearch
+    })
+    fetchData(query)
+  }
+
+  const fetchData = (query: AssignmentQuery) => {
+    apis.getAssignmentByQuery(query, queryInfo.pageNow, queryInfo.pageSize)
+        .then((res:any) => {
+          console.log(res.data.data)
+          pageInfo.tableData = res.data.data.records;
+          pageInfo.total = res.data.data.total
+          processData()
+        })
+        .catch((err:any) => {
+          console.log("错误信息", err)
+        })
+  }
+
+  const processData = () => {
+    for (let i = 0; i < pageInfo.tableData.length; i++) {
+      pageInfo.tableData[i].endTime = formatDate(pageInfo.tableData[i].endTime)
+    }
+  }
+
+  onMounted(() => {
+    fetchCourseInfo()
+    fetchData(query)
+  })
+
+  let state = ref(null)
+  const stateOptions = [
+    {
+      value: AssignmentStatus.NOT_STARTED,
+      label: "未发布"
+    },
+    {
+      value: AssignmentStatus.PROCEEDING,
+      label: "进行中"
+    },
+    {
+      value: AssignmentStatus.FINISHED,
+      label: "已截止"
+    },
+  ]
+
+</script>
+
+<script lang="ts">
+export default {
+  name: "HomeworkPage"
+}
+</script>

+ 19 - 0
src/views/CorrectPage/CorrectAssignmentPage.scss

@@ -0,0 +1,19 @@
+.correct-assignment-card-contain {
+  margin: 10px auto 0;
+  height: 100%;
+  width: 80%;
+
+  .title{
+    font-size: 20px;
+    font-weight: 700;
+    padding: 0 15px 15px 15px;
+  }
+
+  .input-group{
+    padding-left: 15px;
+    .search-input{
+      width: 180px;
+      margin: 0 10px 0 10px;
+    }
+  }
+}

+ 281 - 0
src/views/CorrectPage/CorrectAssignmentPage.vue

@@ -0,0 +1,281 @@
+<!--
+  Description: 我的作业界面
+  Author: BaiQi
+  Created Date: 2024-7-3
+-->
+<template>
+  <el-card class="correct-assignment-card-contain" shadow="never">
+    <el-button text @click="handleBack"><el-icon><ArrowLeft/></el-icon>返回</el-button>
+
+    <div class="title">
+      <span>所属作业:{{ assignmentInfo.assignmentName }}</span>
+    </div>
+
+    <div class="input-group">
+      <el-button :icon="Refresh" circle @click="doRefresh"></el-button>
+      <el-select
+          v-model="status"
+          placeholder="状态"
+          size="default"
+          style="width: 150px; margin-left: 10px;"
+          @change="handleStatusChange"
+      >
+        <el-option
+            v-for="item in statusOptions"
+            :key="item.value"
+            :label="item.label"
+            :value="item.value"
+        />
+      </el-select>
+    </div>
+
+    <el-table :data="pageInfo.tableData" style="width: 100%;" height="100%" :row-style="{height: '30px'}" v-if="status == ''">
+      <template #empty>
+        暂无作业
+      </template>
+      <el-table-column type="index"/>
+      <el-table-column prop="statusName" label="状态" sortable/>
+      <el-table-column prop="studentName" label="学生姓名"/>
+      <el-table-column prop="score" label="得分" sortable/>
+      <el-table-column prop="remark" label="评价"/>
+      <el-table-column label="操作">
+        <template #default="scope">
+          <el-button @click="handleCorrect(scope.row.assignmentId, scope.row.studentId)" style="margin-right: 0; margin-left: 0;padding-left: 10px; padding-right: 10px" color="#597D3B">
+            <el-icon style="margin-right: 3px"><ZoomIn/></el-icon>
+            批改
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <el-table :data="getSlice(queryInfo.pageNow, queryInfo.pageSize)" style="width: 100%;" height="100%" :row-style="{height: '30px'}" v-if="status != ''">
+      <template #empty>
+        暂无作业
+      </template>
+      <el-table-column type="index"/>
+      <el-table-column prop="statusName" label="状态" sortable/>
+      <el-table-column prop="studentName" label="学生姓名"/>
+      <el-table-column prop="score" label="得分" sortable/>
+      <el-table-column prop="remark" label="评价"/>
+      <el-table-column label="操作">
+        <template #default="scope">
+          <el-button @click="handleCorrect(scope.row.assignmentId, scope.row.studentId)" style="margin-right: 0; margin-left: 0;padding-left: 10px; padding-right: 10px" color="#597D3B">
+            <el-icon style="margin-right: 3px"><ZoomIn/></el-icon>
+            批改
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <el-pagination
+        small
+        style="font-size: 16px;margin-top: 10px;margin-left: 450px"
+        :page-sizes="[5, 10, 15]"
+        @current-change="handleCurrentChange"
+        @size-change="handleSizeChange"
+        :current-page="queryInfo.pageNow"
+        :page-size="queryInfo.pageSize"
+        layout="total, sizes, prev, pager, next, jumper"
+        :total="pageInfo.total">
+    </el-pagination>
+  </el-card>
+</template>
+
+<script lang="ts" setup>
+import {Refresh, ZoomIn, ArrowLeft, Search} 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 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";
+
+  const apis = useApis()
+  const store = useStore()
+  const route = useRoute()
+  const doRefresh:Function = inject("reload")
+  const role:'teachers' | 'student' = store.user.role === 'STUDENT' ?   'student':'teachers';
+
+  let assignmentInfo = reactive<AssignmentVO>({} as IAssignment)
+
+  let pageInfo = reactive<{
+    tableData: any[],
+    total: number
+  }>({
+    tableData: [],
+    total: 0,
+  })
+
+  const queryInfo = reactive({
+    pageNow: 1,
+    pageSize: 10,
+  })
+
+  const handleBack = () => {
+    router.replace({
+      path:`/home/myCorrect/assignment`,
+      query: {
+        courseId: assignmentInfo.courseId,
+      }
+    });
+  }
+
+  const handleCorrect = (assignmentId:number, studentId:number) => {
+    router.push(`/home/myCorrect/assignment/${assignmentId}`)
+    router.push({
+      path:
+          `/home/assignment/${assignmentId}/correct`,
+      query: {
+        studentId: studentId
+      }
+    })
+    // alert(studentId)
+  }
+
+  const handleCurrentChange = (pageNum: number) => {
+    queryInfo.pageNow=pageNum;
+    fetchData();
+  }
+  const handleSizeChange = (pageSize: number) => {
+    queryInfo.pageSize = pageSize
+    fetchData()
+  }
+
+  /*
+  前端实现按状态查询
+  所有符合状态的作业
+   */
+  let pageInfo2Status = reactive<{
+    tableData: any[],
+    total: number
+  }>({
+    tableData: [],
+    total: 0,
+  })
+
+  let total = ref(0); // 记录总数
+  const handleStatusChange = (value: AssignmentCompletionStatus) => {
+    apis.getEngagementByAssignmentId(+route.params.assignmentId, 1, total.value)
+        .then((res:any) => {
+          Object.assign(pageInfo2Status, {
+            total: res.data.data ? res.data.data.total:0,
+            tableData: res.data.data ? res.data.data.records:[]
+          })
+          process2Status()
+          processData(pageInfo)
+        })
+        .catch((err:any) => {
+          console.log("错误信息", err)
+        })
+  }
+
+  const process2Status = () => {
+    Object.assign(pageInfo, {
+      tableData: [],
+      total: 0,
+    })
+    for(let i = 0; i < pageInfo2Status.tableData.length; i++){
+      if(pageInfo2Status.tableData[i].status == status.value){
+        pageInfo.tableData.push(pageInfo2Status.tableData[i])
+        pageInfo.total++;
+      }
+    }
+  }
+
+  const getSlice = (pages:number, size:number) => {
+    return pageInfo.tableData.slice((pages-1)*size, pages*size-1)
+  }
+
+  const fetchAssignmentInfo = () => {
+    apis.getAssignmentById(+route.params.assignmentId)
+        .then((res:any) => {
+          Object.assign(assignmentInfo, {
+            ...res.data.data
+          })
+          console.log("assignment", assignmentInfo)
+        })
+        .catch((err:any) => {
+          console.log("错误信息", err)
+        })
+  }
+
+  const fetchData = () => {
+    apis.getEngagementByAssignmentId(+route.params.assignmentId, queryInfo.pageNow, queryInfo.pageSize)
+        .then((res:any) => {
+          pageInfo.total = res.data.data ? parseInt(res.data.data.total):0
+          pageInfo.tableData = res.data.data ? res.data.data.records:[]
+          processData(pageInfo)
+          console.log(pageInfo.tableData)
+          total.value = res.data.data ? parseInt(res.data.data.total):0
+        })
+        .catch((err:any) => {
+          console.log("错误信息", err)
+        })
+  }
+
+  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
+          break;
+        }
+      }
+    }
+  }
+
+  onMounted(() => {
+    // fetchHomeworkListByUserId()
+    fetchAssignmentInfo()
+    fetchData()
+    console.log(route.query)
+  })
+
+  let status = ref('')
+  const statusOptions = [
+    {
+      value: AssignmentCompletionStatus.NOT_EDITED,
+      label: "待完成"
+    },
+    {
+      value: AssignmentCompletionStatus.NOT_SUBMITTED,
+      label: "未提交"
+    },
+    {
+      value: AssignmentCompletionStatus.SUBMITTED,
+      label: "已提交"
+    },
+    {
+      value: AssignmentCompletionStatus.NOT_DONE,
+      label: "未完成"
+    },
+    {
+      value: AssignmentCompletionStatus.PUBLISHED,
+      label: "已批改"
+    },
+    {
+      value: AssignmentCompletionStatus.NOT_CORRECTED,
+      label: "未批改"
+    },
+    {
+      value: AssignmentCompletionStatus.CORRECTED,
+      label: "已批改未发布"
+    },
+  ]
+
+</script>
+
+<script lang="ts">
+export default {
+  name: "AssignmentPage"
+}
+</script>

+ 20 - 0
src/views/CorrectPage/CoursePage.scss

@@ -0,0 +1,20 @@
+.course-card-contain {
+  margin: 10px auto 0;
+  height: 100%;
+  width: 80%;
+
+  .title{
+    font-size: 20px;
+    font-weight: 700;
+    padding: 0 10px 10px 10px;
+  }
+
+  .back-button{
+    padding: 0!important;
+  }
+
+  .search-input{
+    width: 180px;
+    margin: 0 10px 0 10px;
+  }
+}

+ 174 - 0
src/views/CorrectPage/CoursePage.vue

@@ -0,0 +1,174 @@
+<!--
+  Description: 我的批改页面
+  Author: BaiQi
+  Created Date: 2024-7-25
+-->
+<template>
+  <el-card class="course-card-contain" shadow="never">
+    <div class="title">
+      <span>课程列表</span>
+    </div>
+
+    <el-button :icon="Refresh" circle @click="doRefresh"></el-button>
+    <el-input v-model="courseName" placeholder="请输入课程名称" clearable class="search-input"/>
+    <el-button color="#597D3B" @click="handleSearch">
+      <el-icon style="margin-right: 3px"><Search/></el-icon>
+      查询
+    </el-button>
+
+    <el-table :data="pageInfo.records" style="width: 100%; max-height: 70vh" height="100%" :row-style="{height: '30px'}">
+      <template #empty>
+        暂无课程
+      </template>
+      <el-table-column type="index"/>
+      <el-table-column prop="courseName" label="课程名称"/>
+      <el-table-column prop="description" label="描述"/>
+      <el-table-column prop="endTime" label="截止时间" sortable/>
+<!--      <el-table-column prop="endTime" label="状态" sortable/>-->
+      <el-table-column label="操作">
+        <template #default="scope">
+          <el-button @click="handleCorrect(scope.row.courseId, scope.row.courseName)" style="margin-right: 0; margin-left: 0;padding-left: 10px; padding-right: 10px" color="#597D3B">
+            <el-icon style="margin-right: 3px" ><ZoomIn/></el-icon>
+            批改作业
+          </el-button>
+        </template>
+      </el-table-column>
+    </el-table>
+
+    <el-pagination
+        small
+        style="font-size: 16px;margin-top: 10px;margin-left: 450px"
+        :page-sizes="[5, 10, 15]"
+        @current-change="handleCurrentChange"
+        @size-change="handleSizeChange"
+        :current-page="queryInfo.pageNow"
+        :page-size="queryInfo.pageSize"
+        layout="total, sizes, prev, pager, next, jumper"
+        :total="pageInfo.total">
+    </el-pagination>
+
+  </el-card>
+
+</template>
+
+<script lang="ts" setup>
+  import useApis from "@/apis";
+  import {useStore} from "@/store";
+  import {inject, onMounted, reactive, ref} from "vue";
+  import type {CourseVO} from "@/types/vo";
+  import {Refresh, Search, ZoomIn} from "@element-plus/icons-vue";
+  import router from "@/router";
+  import type {CourseDTO} from "@/types/dto";
+  import "./CoursePage.scss"
+  import type {CourseQuery} from "@/types/query";
+  import {useFormatDate} from "@/hooks/useFormatDate";
+
+  const apis = useApis()
+  const store = useStore()
+  const doRefresh:Function = inject("reload")
+  const {formatDate} = useFormatDate()
+
+  const queryInfo = reactive({
+    pageNow: 1,
+    pageSize: 10,
+  })
+
+  let pageInfo = reactive<{
+    records: CourseVO[],
+    current: number,// 当前页码
+    size: number, // 分页大小
+    pages: number, // 总页数
+    total: number
+  }>({
+    records: null,
+    current: null,
+    size: null,
+    pages: null,
+    total: null,
+  })
+
+  const query = reactive<CourseQuery>({
+    courseId:null,
+    teacherId:store.user.id,
+    studentId:null,
+    courseName:null,
+    semester:null,
+  })
+
+  let courseName = ref('')
+  const handleSearch = () => {
+    Object.assign(query, {
+      courseId:null,
+      teacherId:store.user.id,
+      studentId:null,
+      courseName:courseName.value,
+      semester:null,
+    })
+    fetchData(query)
+  }
+
+  /*
+  路由跳转到作业界面
+   */
+  const handleCorrect = (courseId:number, courseName:string) => {
+    router.replace({
+      path:`/home/myCorrect/assignment`,
+      query: {
+        courseId: courseId,
+      }
+    });
+    // location.reload()
+  }
+
+  const fetchData = (query: CourseQuery) => {
+    apis.getAllCourse(query, queryInfo.pageNow, queryInfo.pageSize)
+        .then((res: any) => {
+          let data = res.data.data
+          Object.assign(pageInfo, {...data})
+          processData()
+        })
+        .catch((err: any) => {
+          console.error(err);
+        })
+        .finally(() => {
+        });
+  }
+
+  const processData = () => {
+    for(let i = 0; i < pageInfo.records.length; i++){
+      pageInfo.records[i].endTime = formatDate(pageInfo.records[i].endTime)
+    }
+  }
+
+  const handleCurrentChange =(index:number)=>{
+    queryInfo.pageNow=index;
+    fetchData(query);
+  }
+  const handleSizeChange = (pageSize: number) => {
+    queryInfo.pageSize = pageSize
+    fetchData(query)
+  }
+
+  onMounted(() => {
+    fetchData(query)
+  })
+
+  // TODO:状态选择
+  let state = ref(null)
+  const stateOptions = [
+    {
+      value: 0,
+      label: "已结课"
+    },
+    {
+      value: 1,
+      label: "未结课"
+    },
+  ]
+</script>
+
+<script lang="ts">
+export default {
+  name: "CoursePage"
+}
+</script>

+ 85 - 37
src/views/CoursePage/CoursePage.vue

@@ -4,26 +4,18 @@
   Created Date: 2024-7-2
 -->
 <template>
-  <el-card style="margin: 10px auto 0;height: 90vh; width: 80%" shadow="never">
+  <el-card style="margin: 10px auto 0;height: 100%; width: 80%" shadow="never">
     <el-button :icon="Refresh" circle @click="doRefresh"></el-button>
     <template v-if="role == 'teachers'">
       <el-button @click="visible = !visible" color="#597d3b">新增课程</el-button>
     </template>
-<!--    <el-select-->
-<!--        v-model="state"-->
-<!--        placeholder="状态"-->
-<!--        size="default"-->
-<!--        style="width: 150px; margin-left: 10px;"-->
-<!--    >-->
-<!--      <el-option-->
-<!--          v-for="item in stateOptions"-->
-<!--          :key="item.value"-->
-<!--          :label="item.label"-->
-<!--          :value="item.value"-->
-<!--      />-->
-<!--    </el-select>-->
-
-    <el-table :data="pageInfo.records" style="width: 100%" height="80vh">
+    <el-input v-model="courseName" placeholder="请输入课程名称" clearable style="width: 180px; margin: 0 10px 0 10px ;"/>
+    <el-button color="#597D3B" @click="handleSearch">
+      <el-icon style="margin-right: 3px"><Search/></el-icon>
+      查询
+    </el-button>
+
+    <el-table :data="pageInfo.records" style="width: 100%" height="100%">
       <template #empty>
         暂无课程
       </template>
@@ -44,10 +36,12 @@
     <el-pagination
         small
         style="font-size: 16px;margin-top: 10px;margin-left: 450px"
+        :page-sizes="[5, 10, 15]"
         @current-change="handleCurrentChange"
+        @size-change="handleSizeChange"
         :current-page="queryInfo.pageNow"
         :page-size="queryInfo.pageSize"
-        layout="total, prev, pager, next, jumper"
+        layout="total, sizes, prev, pager, next, jumper"
         :total="pageInfo.total">
     </el-pagination>
 
@@ -88,14 +82,17 @@
   import {useStore} from "@/store";
   import {inject, onMounted, reactive, ref} from "vue";
   import type {CourseVO} from "@/types/vo";
-  import {Refresh, ZoomIn} from "@element-plus/icons-vue";
+  import {Refresh, Search, ZoomIn} from "@element-plus/icons-vue";
   import router from "@/router";
   import type {CourseDTO} from "@/types/dto";
   import {ElNotification} from "element-plus";
+  import type {CourseQuery} from "@/types/query";
+  import {useFormatDate} from "@/hooks/useFormatDate";
 
   const apis = useApis()
   const store = useStore()
   const doRefresh:Function = inject("reload")
+  const {formatDate} = useFormatDate()
   const role:'teachers' | 'student' = store.user.role === 'STUDENT' ?   'student':'teachers';
 
   let visible = ref(false)
@@ -130,18 +127,44 @@
     enrollCode: ""
   })
 
-  /*
-  时间格式转换方法
-   */
-  function formatDate(date:string) {
-    const d = new Date(date);
-    const year = d.getFullYear();
-    const month = String(d.getMonth() + 1).padStart(2, '0');
-    const day = String(d.getDate()).padStart(2, '0');
-    const hours = String(d.getHours()).padStart(2, '0');
-    const minutes = String(d.getMinutes()).padStart(2, '0');
-    const seconds = String(d.getSeconds()).padStart(2, '0');
-    return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
+  const query = reactive<CourseQuery>({
+    courseId:null,
+    teacherId:store.user.id,
+    studentId:null,
+    courseName:null,
+    semester:null,
+  })
+
+  let courseName = ref('')
+  const handleSearch = () => {
+    if (role === 'student') {
+      Object.assign(query, {
+        courseId: null,
+        teacherId: null,
+        studentId: store.user.id,
+        courseName: courseName.value,
+        semester: null,
+      })
+    } else if(role === 'teachers'){
+      Object.assign(query, {
+        courseId: null,
+        teacherId: store.user.id,
+        studentId: null,
+        courseName: courseName.value,
+        semester: null,
+      })
+    }
+    apis.getAllCourse(query, queryInfo.pageNow, queryInfo.pageSize)
+        .then((res: any) => {
+          let data = res.data.data
+          console.log(data)
+          Object.assign(pageInfo, {...data})
+        })
+        .catch((err: any) => {
+          console.error(err);
+        })
+        .finally(() => {
+        });
   }
 
   const handleSubmit = () => {
@@ -170,13 +193,20 @@
     // location.reload()
   }
 
-  const fetchCourseByUserId = () => {
+  const fetchData = () => {
     if (role === 'student') {
-      apis.getCourseByStudentId(store.user.id, queryInfo.pageNow, queryInfo.pageSize)
+      Object.assign(query, {
+        courseId:null,
+        teacherId:null,
+        studentId:store.user.id,
+        courseName:null,
+        semester:null,
+      })
+      apis.getAllCourse(query, queryInfo.pageNow, queryInfo.pageSize)
           .then((res: any) => {
             let data = res.data.data
-            console.log(data)
             Object.assign(pageInfo, {...data})
+            processData()
           })
           .catch((err: any) => {
             console.error(err);
@@ -184,11 +214,19 @@
           .finally(() => {
           });
     } else if (role === "teachers") {
-      apis.getCourseByTeacherId(store.user.id, queryInfo.pageNow, queryInfo.pageSize)
+      Object.assign(query, {
+        courseId:null,
+        teacherId:store.user.id,
+        studentId:null,
+        courseName:null,
+        semester:null,
+      })
+      apis.getAllCourse(query, queryInfo.pageNow, queryInfo.pageSize)
           .then((res: any) => {
             let data = res.data.data
             console.log(data)
             Object.assign(pageInfo, {...data})
+            processData()
           })
           .catch((err: any) => {
             console.error(err);
@@ -198,14 +236,24 @@
     }
   }
 
+  const processData = () => {
+    for(let i = 0; i < pageInfo.records.length; i++){
+      pageInfo.records[i].endTime = formatDate(pageInfo.records[i].endTime)
+    }
+  }
+
   const handleCurrentChange =(index:number)=>{
     queryInfo.pageNow=index;
-    fetchCourseByUserId();
+    fetchData();
+  }
+  const handleSizeChange = (pageSize: number) => {
+    queryInfo.pageSize = pageSize
+    fetchData()
   }
 
+
   onMounted(() => {
-    fetchCourseByUserId()
-    console.log("我的课程挂载")
+    fetchData()
   })
 
   // TODO:状态选择

+ 10 - 3
src/views/CourseSquare/component/AllCourse/MoreCourse.scss

@@ -4,6 +4,15 @@
   overflow: hidden;
   margin: 40px auto 0 auto;
 
+  .course-header {
+    margin: 0 auto;
+    width: 1100px;
+    .course-header-title {
+      margin-bottom: 10px;
+      font-size: 20px;
+    }
+  }
+
   .course-content-container {
     overflow: hidden;
     margin: 0 auto;
@@ -14,9 +23,7 @@
     border-radius: 7px;
 
     .course-content-title {
-      width: 200px;
-      margin: 10px 0 0 30px ;
-      font-size: 20px;
+      margin: 10px 100px 10px 0;
     }
 
     .course-items-container {

+ 76 - 12
src/views/CourseSquare/component/AllCourse/MoreCourse.vue

@@ -1,8 +1,16 @@
 <template>
   <div class="course-content">
+    <div class="course-header">
+      <span class="course-header-title">{{ props.title }}</span>
+    </div>
     <div class="course-content-container">
       <div class="course-content-title">
-        {{ props.title }}
+        <el-button :icon="Refresh" circle @click="doRefresh" style="margin: 0 10px 0 30px"></el-button>
+        <el-input v-model="courseName" placeholder="请输入课程名称" clearable class="search-input" style="width: 180px; margin-right: 10px"/>
+        <el-button @click="handleSearch" color="#597D3B">
+          <el-icon style="margin-right: 3px" ><Search/></el-icon>
+          查询
+        </el-button>
       </div>
       <div class="course-items-container">
         <el-card v-for="item in getCoursesSlice(0, 5)" :key="item.courseId" class="course-item active" @click="handleClick(item.courseId)">
@@ -56,15 +64,18 @@
 
 <script lang="ts" setup>
 import './MoreCourse.scss'
-import {defineProps, onMounted, reactive} from "vue";
+import {defineProps, inject, onMounted, reactive, ref} from "vue";
 import useApis from "@/apis";
 import type {CourseQuery} from "@/types/query";
 import router from "@/router";
 import {useStore} from "@/store";
+import {Refresh, Search} from "@element-plus/icons-vue";
 
 const apis = useApis()
 const store = useStore()
+const doRefresh:Function = inject("reload")
 const role:'teachers' | 'student' = store.user.role === 'STUDENT' ?   'student':'teachers';
+let courseName = ref('')
 
 const props = defineProps<{
   title: string;
@@ -81,6 +92,65 @@ let pageInfo = reactive({
   courseData: []
 })
 
+let pageInfo2Show = reactive({
+  total: 0,
+  courseData: []
+})
+
+const query = reactive<CourseQuery>({
+  courseId:null,
+  teacherId:null,
+  studentId:null,
+  courseName:null,
+  semester:null,
+})
+
+const handleSearch = () => {
+  if(props.type == 'all'){
+    Object.assign(query, {
+      courseId:null,
+      teacherId:null,
+      studentId:null,
+      courseName:courseName.value,
+      semester:null,
+    })
+    fetchAllCourse()
+  } else {
+    if(role == 'student'){
+      Object.assign(query, {
+        courseId:null,
+        teacherId:null,
+        studentId:store.user.id,
+        courseName:courseName.value,
+        semester:null,
+      })
+      fetchAllCourse()
+    }else {
+      Object.assign(query, {
+        courseId:null,
+        teacherId:store.user.id,
+        studentId:null,
+        courseName:courseName.value,
+        semester:null,
+      })
+      fetchAllCourse()
+    }
+  }
+}
+
+const courseNameFilter = () => {
+  Object.assign(pageInfo2Show, {
+    total: 0,
+    courseData: []
+  })
+  for(let i = 0; i < pageInfo.total; i++){
+    if(pageInfo.courseData[i].courseName.includes(courseName.value)){
+      pageInfo2Show.courseData.push(pageInfo.courseData[i])
+      pageInfo2Show.total++;
+    }
+  }
+}
+
 // 处理课程卡片的点击事件
 const handleClick = (value:number) => {
   router.push(`/home/courseDetail/${value}`)
@@ -102,18 +172,12 @@ const fetchData = () => {
 }
 
 const fetchAllCourse = () => {
-  const query = reactive<CourseQuery>({
-    courseId:null,
-    teacherId:null,
-    studentId:null,
-    courseName:null,
-    semester:null,
-  })
   apis.getAllCourse(query, queryInfo.pageNow, queryInfo.pageSize)
       .then((res: any) => {
         console.log(res)
         pageInfo.courseData = res.data.data.records
         pageInfo.total = res.data.data.total
+        Object.assign(pageInfo2Show, pageInfo)
       })
       .catch((err: any) => {
         console.error("错误信息",err);
@@ -128,6 +192,7 @@ const fetchCourseByUserId = () => {
           console.log(res)
           pageInfo.courseData = res.data.data.records
           pageInfo.total = res.data.data.total
+          Object.assign(pageInfo2Show, pageInfo)
         })
         .catch((err: any) => {
           console.error(err);
@@ -139,6 +204,7 @@ const fetchCourseByUserId = () => {
           console.log(res.data.data)
           pageInfo.courseData = res.data.data.records
           pageInfo.total = res.data.data.total
+          Object.assign(pageInfo2Show, pageInfo)
         })
         .catch((err: any) => {
           console.error(err);
@@ -147,11 +213,9 @@ const fetchCourseByUserId = () => {
   }
 }
 
-
-
 //只获取前五个课程
 const getCoursesSlice = (start:number, end:number) => {
-  return pageInfo.courseData.slice(start, end)
+  return pageInfo2Show.courseData.slice(start, end)
 }
 
 onMounted(()=>{

+ 4 - 3
src/views/CourseSquare/component/CourseDetails/component/CourseHomeworkTable.vue

@@ -23,7 +23,7 @@
         </el-table-column>
         <el-table-column :label="role == 'teachers'? '编辑':'写作'">
           <template #default="scope">
-            <el-button color="#888" circle @click="handleFunctionButton(scope.row.assignmentId)"/>
+            <el-button color="#888" circle @click="handleFunctionButton(scope.row.assignmentId)" :disabled="props.disabled"/>
           </template>
         </el-table-column>
       </el-table>
@@ -82,7 +82,8 @@ import ViewsWordEditor from "@/components/ViewsWordEditor/ViewsWordEditor.vue";
     columns: IAssignmentTableColumn[],
     role: string,
     courseId: number,
-    isShowNewHomework: boolean
+    isShowNewHomework: boolean,
+    disabled: boolean;
   }>()
 
   const apis = useApis()
@@ -176,7 +177,7 @@ const openEditor = (url: string, title: string) => {
       assignmentName: assignment.assignmentName,
       description: assignment.description,
       descriptionFile: assignment.descriptionFile,
-      attachments: assignment.attachments,
+      attachments: assignment.attachments == null? ['']:assignment.attachments,
       startTime: assignment.startTime,
       endTime: assignment.endTime
     })

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

@@ -42,7 +42,7 @@
             </div>
           </template>
           <template v-else>
-            <CourseHomeworkTable :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>
         </el-tab-pane>
       </el-tabs>
@@ -345,6 +345,11 @@ const handleSubmit = () => {
     })
 }
 
+function isDisabled(){
+  if(role == "student") return showCode.value;
+  if(role == "teachers") return !showEdit.value;
+}
+
 onMounted(() => {
   getCourse()
   getHomeworkList()

+ 0 - 28
src/views/CourseSquare/index.tsx

@@ -1,28 +0,0 @@
-import 'swiper/css';
-import "./index.scss"
-import {Banner} from "./component/Banner/Banner"
-import {Course} from "@/pages/CourseSquare/component/Course";
-import {useState} from "react";
-import {CourseDetails} from "@/pages/CourseSquare/component/CourseDetails";
-
-/**
- * 课程广场
- * @constructor
- */
-export function CourseSquare() {
-    const [current, setCurrent] = useState()
-
-    return <div className="course">
-        {
-            !current ?
-                <>
-                    <Banner/>
-                    <Course title="课程广场" onChange={setCurrent}/>
-                    <Course title="我的课程" onChange={setCurrent}/>
-                </> :
-                <CourseDetails/>
-        }
-
-
-    </div>
-}

+ 1 - 6
src/views/EditPage/EditPage.vue

@@ -55,7 +55,6 @@
     await apis.getAIDialogues(assignmentId, store.user.id)
         .then((_res:any) => {
           const data = _res.data.data
-          console.log(data)
           Object.assign(dataForm, {
             dialogueId: data?.dialogueId,
             messages: data?.messages.content,
@@ -65,21 +64,17 @@
 
     await apis.getEngagement(store.user.id, assignmentId)
         .then((_res:any) => {
-          console.log(_res)
           Object.assign(dataForm, {
             dialogueId: dataForm.dialogueId,
             messages: dataForm.messages,
             engagement: _res.data.data
           })
         }).catch((_err:any) => {
-          console.log(_err)
           router.push("/login")
         })
   }
 
   onMounted( () => {
-    console.log("获取数据")
-    console.log(assignmentId,"assassignmentId的值")
     fetchData()
   })
 
@@ -92,5 +87,5 @@ export default {
 </script>
 
 <!--<style module>-->
-<!--//@import "index.scss";-->
+<!--//@import "CoursePage.scss";-->
 <!--</style>-->

+ 8 - 7
src/views/Home/Role.vue

@@ -23,18 +23,21 @@
   const isRouterAlive = ref(true);
   const reload = ()=>{
     isRouterAlive.value = false;
-    console.log("刷新前")
+    // console.log("刷新前")
     nextTick(()=>{
       isRouterAlive.value = true;
-      console.log("刷新后")
+      // console.log("刷新后")
     });
   };
   provide("reload",reload);
 
+  /*
+  路由变换
+   */
   const changePage = (value: string) => {
-    console.log(role)
+    // console.log(role)
     if(role == 'student'){
-      console.log("学生")
+      // console.log("学生")
       switch (value){
         case 'CourseSquare':
           router.push("/home/courseSquare");
@@ -44,7 +47,6 @@
           break;
         case 'MyWork':
           router.push("/home/myHomework");
-          // router.push("/home/assignment/1/edit");
           break;
       }
       // changePage.value = value
@@ -57,8 +59,7 @@
           router.push("/home/myCourse");
           break;
         case 'MyWork':
-          router.push("/home/myHomework");
-          // router.push("/home/assignment/1/edit");
+          router.push("/home/myCorrect/course");
           break;
       }
     }

+ 0 - 3
src/views/Home/component/Dictionaries/index.scss

@@ -15,8 +15,5 @@
     padding: 15px;
     box-sizing: border-box;
 
-    .ant-input-outlined {
-      border-radius: 100px !important;
-    }
   }
 }

+ 8 - 4
src/views/Home/component/Dictionaries/index.vue

@@ -15,11 +15,11 @@
 <!--          <LanguageIcon :currentLanguage="currentLanguage"></LanguageIcon>-->
 <!--        </template>-->
         <template #suffix>
-          <div v-loading="loading">
-            <el-icon v-if="!loading" @click="search" >
+          <el-button @click="search" style="width: 40px; border: none" v-loading="loading">
+            <el-icon v-if="!loading" >
               <Search />
             </el-icon>
-          </div>
+          </el-button>
         </template>
       </el-input>
       <!--TODO 字典展示-->
@@ -42,12 +42,16 @@
   const res = ref('')
   const loading = ref(false)
 
+
+  const chinesePattern = new RegExp("[\u4E00-\u9FA5]+");
+  const englishPattern = new RegExp("[A-Za-z]+");
+
   const search = () => {
     loading.value = true
     apis.requestDictionary({
       q: content.value,
       from: 'auto',
-      to: currentLanguage.value === 'zh' ? 'zh-cn' : 'en'
+      to: chinesePattern.test(content.value) ? 'zh-cn' : 'en'
     }, 1, store.user.id)
         .then((response:any) => {
           console.log('requestDictionary', response)

+ 4 - 3
src/views/Home/component/Edit/index.vue

@@ -62,7 +62,7 @@
 
   // 设置文件标题
   onMounted(() => {
-    data.fileTitle = `${store.user.name}_第一次作业.docx`;
+    data.fileTitle = `${store.user.name}_作业.docx`;
   });
 
   // 成功操作的消息提示
@@ -81,13 +81,14 @@
   const handleValueChange = (state: boolean) => {
     if (state) data.hasModified = true;
     data.isModified = state;
+    alert("1")
   };
 
   // 提交操作
   const handleSubmit = () => {
     // 内容已保存,且已经修改过,则可以点击提交
     if (!data.isModified && data.hasModified) {
-      apis.engagementSubmit(store.user.id, 1)
+      apis.engagementSubmit(store.user.id, props.engagement.assignmentId)
           .then((_res: any) => {
             console.log(_res);
             success(_res.data.data);
@@ -109,7 +110,7 @@
   // 暂存操作
   const handleStage = () => {
     if (!data.isModified && data.hasModified) {
-      apis.engagementStage(store.user.id, 1)
+      apis.engagementStage(store.user.id, props.engagement.assignmentId)
           .then((_res: any) => {
             console.log(_res);
             success(_res.data.data);

+ 2 - 2
src/views/Home/component/Silder/index.vue

@@ -45,9 +45,9 @@
         </div>
         <div class="capacity-item">
 <!--          <el-spin :spinning="loading" style="height: 100%; width: 100%; display: flex; align-items: center; justify-content: center;">-->
-<!--            <div v-if="!loading" class="remark">{{ aiRemark }}</div>-->
+            <div v-if="!loading" class="remark">{{ aiRemark }}</div>
 <!--          </el-spin>-->
-          <div class='remark'>{{aiRemark}}</div>
+<!--          <div class='remark'>{{aiRemark}}</div>-->
         </div>
       </template>
     </div>

+ 60 - 69
src/views/HomeworkPage/index.vue

@@ -4,7 +4,7 @@
   Created Date: 2024-7-3
 -->
 <template>
-  <el-card style="margin: 10px auto 0;height: 90vh; width: 80%" shadow="never">
+  <el-card style="margin: 10px auto 0;height: 100%; width: 80%" shadow="never">
     <el-button :icon="Refresh" circle @click="doRefresh"></el-button>
     <el-select
         v-model="state"
@@ -25,7 +25,7 @@
       查询
     </el-button>
 
-    <el-table :data="pageInfo.tableData" style="width: 100%" height="80vh">
+    <el-table :data="pageInfo.tableData" style="width: 100%" height="100%">
       <template #empty>
         暂无作业
       </template>
@@ -48,9 +48,11 @@
         small
         style="font-size: 16px;margin-top: 10px;margin-left: 450px"
         @current-change="handleCurrentChange"
+        @size-change="handleSizeChange"
+        :page-sizes="[5, 10, 15]"
         :current-page="pageInfo.pages"
         :page-size="pageInfo.size"
-        layout="total, prev, pager, next, jumper"
+        layout="total, sizes, prev, pager, next, jumper"
         :total="pageInfo.total">
     </el-pagination>
   </el-card>
@@ -63,12 +65,13 @@
   import {useStore} from "@/store";
   import type {CourseVO, IAssignment} from "@/types/vo";
   import router from "@/router";
-  import {type AssignmentQueryDTO, AssignmentStatus} from "@/types/dto";
-  import assignment from "@/apis/assignment";
+  import {AssignmentStatus} from "@/types/enums";
+  import {useFormatDate} from "@/hooks/useFormatDate";
 
   const apis = useApis()
   const store = useStore()
   const doRefresh:Function = inject("reload")
+  const {formatDate} = useFormatDate()
   const role:'teachers' | 'student' = store.user.role === 'STUDENT' ?   'student':'teachers';
 
   // 获取的所有作业
@@ -105,86 +108,74 @@
 
   const handleCurrentChange = (pageNum: number) => {
     Object.assign(pageInfo, {
-      tableData: getSlice(pageNum),
-      size: 10,
+      tableData: getSlice(pageNum, pageInfo.size),
+      size: pageInfo.size,
       pages: pageNum,
       total: processedHomeworkList.tableData.length,
     })
   }
+  const handleSizeChange = (pageSize: number) => {
+    Object.assign(pageInfo, {
+      tableData: getSlice(1, pageSize),
+      size: pageSize,
+      pages: 1,
+      total: processedHomeworkList.tableData.length,
+    })
+  }
+
 
-  const fetchHomeworkListByUserId = () => {
+  const fetchData = () => {
     if (role === 'student') {
       apis.getCourseByStudentId(store.user.id)
           .then((res: any) => {
-            let data:CourseVO[] = res.data.data.records
-            for(let i = 0; i < data.length; i++){
-              fetchHomeworkListByCourseId(data[i].courseId)
-            }
+            // 获取课程总数
+            let total = res.data.data.total;
+            apis.getCourseByStudentId(store.user.id,1,total)
+                .then((res: any) => {
+                  let data:CourseVO[] = res.data.data.records
+                  for(let i = 0; i < data.length; i++){
+                    fetchHomeworkListByCourseId(data[i].courseId)
+                  }
+                })
           })
-          .catch((err: any) => {
-            console.error(err);
-          })
-          .finally(() => {
-          });
     } else if (role === "teachers") {
       apis.getCourseByTeacherId(store.user.id)
           .then((res: any) => {
-            let data:CourseVO[] = res.data.data.records
-            for(let i = 0; i < data.length; i++){
-              fetchHomeworkListByCourseId(data[i].courseId)
-            }
-          })
-          .catch((err: any) => {
-            console.error(err);
+            // 获取课程总数
+            let total = res.data.data.total;
+            apis.getCourseByTeacherId(store.user.id,1,total)
+                .then((res: any) => {
+                  let data:CourseVO[] = res.data.data.records
+                  for(let i = 0; i < data.length; i++){
+                    fetchHomeworkListByCourseId(data[i].courseId)
+                  }
+                })
           })
-          .finally(() => {
-          });
     }
   }
 
   const fetchHomeworkListByCourseId = (courseId:number) => {
     apis.getAssignmentByCourseId(courseId)
         .then((res: any) => {
-          let data = res.data.data.records
-          for(let i = 0; i < data.length; i++) {
-            homeworkList.tableData.push(data[i])
-          }
-          processedHomeworkList.tableData = homeworkList.tableData
-          Object.assign(pageInfo, {
-            tableData: getSlice(1),
-            size: 10,
-            pages: 1,
-            total: processedHomeworkList.tableData.length,
-          })
+          let total = res.data.data.total
+          apis.getAssignmentByCourseId(courseId, 1, total)
+              .then((res: any) => {
+                let data = res.data.data.records
+                for(let i = 0; i < data.length; i++) {
+                  data[i].endTime = formatDate(data[i].endTime)
+                  homeworkList.tableData.push(data[i])
+                }
+                processedHomeworkList.tableData = homeworkList.tableData
+                Object.assign(pageInfo, {
+                  tableData: getSlice(pageInfo.pages, pageInfo.size),
+                  size: pageInfo.size,
+                  pages: pageInfo.pages,
+                  total: processedHomeworkList.tableData.length,
+                })
+              })
         })
-        .catch((err: any) => {
-          console.error(err);
-        })
-        .finally(() => {
-        });
   }
 
-  // let options = reactive({
-  //     listData:[]
-  // })
-  // let loading = ref(false)
-  // const HomeworkListRemoteMethod = (query:string) => {
-  //   options.listData = [];
-  //   if (query) {
-  //     loading.value = true;
-  //     homeworkList.tableData.filter((item) => {
-  //       if(item.assignmentName.includes(query)){
-  //         options.listData.push({
-  //           value: item.assignmentId,
-  //           label: item.assignmentName
-  //         })
-  //       }
-  //     })
-  //     loading.value = false;
-  //     console.log(options.listData)
-  //   }
-  // }
-
   const handleSearch = () => {
     processedHomeworkList.tableData = []
     for(let i = 0; i < homeworkList.tableData.length; i++){
@@ -194,21 +185,21 @@
       if(assignmentName.value != '' && !assignmentItem.assignmentName.includes(assignmentName.value)) input = false;
       if(input) processedHomeworkList.tableData.push(assignmentItem);
       Object.assign(pageInfo, {
-        tableData: getSlice(1),
-        size: 10,
-        pages: 1,
+        tableData: getSlice(pageInfo.pages, pageInfo.size),
+        size: pageInfo.size,
+        pages: pageInfo.pages,
         total: processedHomeworkList.tableData.length,
       })
     }
   }
 
   //用于分页展示,截取数据
-  const getSlice = (page: number) => {
-    return processedHomeworkList.tableData.slice(page - 1, page + 10 - 1)
+  const getSlice = (page: number, size: number) => {
+    return processedHomeworkList.tableData.slice((page-1)*size, page*size)
   }
 
   onMounted(() => {
-    fetchHomeworkListByUserId()
+    fetchData()
     console.log(homeworkList)
   })
 

+ 6 - 13
vite.config.ts

@@ -5,18 +5,7 @@ import vue from '@vitejs/plugin-vue'
 
 // https://vitejs.dev/config/
 export default defineConfig({
-  //配置代理,解决跨域问题。详见EAI问题文档
-  server: {
-    host: '127.0.0.1',
-    port: 4000,
-    proxy: {
-      '/api': {  
-        target: 'http://localhost:8080',
-        changeOrigin: true,
-        rewrite: (path) => path.replace(/^\/api/, ''),
-      },
-    },
-  },
+
   plugins: [
     vue(),
   ],
@@ -24,5 +13,9 @@ export default defineConfig({
     alias: {
       '@': fileURLToPath(new URL('./src', import.meta.url))
     }
-  }
+  },
+ server: {
+   host: '127.0.0.1',
+   port: 4000
+ }
 })