|
|
@@ -4,8 +4,8 @@
|
|
|
Created Date: 2024-7-3
|
|
|
-->
|
|
|
<template>
|
|
|
- <el-card style="margin: 10px auto 0;height: 625px; width: 80%" shadow="never">
|
|
|
- <el-button :icon="Refresh" circle></el-button>
|
|
|
+ <el-card style="margin: 10px auto 0;height: 90vh; width: 80%" shadow="never">
|
|
|
+ <el-button :icon="Refresh" circle @click="doRefresh"></el-button>
|
|
|
<el-select
|
|
|
v-model="state"
|
|
|
placeholder="状态"
|
|
|
@@ -19,97 +19,143 @@
|
|
|
:value="item.value"
|
|
|
/>
|
|
|
</el-select>
|
|
|
- <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 v-model="assignmentName" placeholder="请输入作业名称" clearable style="width: 180px;"/>
|
|
|
+ <el-button @click="handleSearch" color="#597D3B">
|
|
|
+ <el-icon style="margin-right: 3px" ><Search/></el-icon>
|
|
|
+ 查询
|
|
|
+ </el-button>
|
|
|
|
|
|
- <el-table :data="homeworkList.tableData" style="width: 100%; height: 100%">
|
|
|
+ <el-table :data="pageInfo.tableData" style="width: 100%" height="80vh">
|
|
|
+ <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>
|
|
|
+ <el-table-column label="操作">
|
|
|
<template #default="scope">
|
|
|
- <el-button text @click="handleShowDetail(scope.row.assignmentId)" style="margin-right: 0; margin-left: 0;padding-left: 5px; padding-right: 5px">
|
|
|
+ <el-button @click="handleShowDetail(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"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ :current-page="pageInfo.pages"
|
|
|
+ :page-size="pageInfo.size"
|
|
|
+ layout="total, prev, pager, next, jumper"
|
|
|
+ :total="pageInfo.total">
|
|
|
+ </el-pagination>
|
|
|
</el-card>
|
|
|
</template>
|
|
|
|
|
|
<script lang="ts" setup>
|
|
|
-import {Refresh, ZoomIn} from "@element-plus/icons-vue";
|
|
|
-import {onMounted, reactive, ref} from "vue";
|
|
|
-import useApis from "@/apis";
|
|
|
-import {useStore} from "@/store";
|
|
|
-import type {CourseVO, IAssignment} from "@/types/vo";
|
|
|
-import router from "@/router";
|
|
|
-
|
|
|
-const apis = useApis()
|
|
|
-const store = useStore()
|
|
|
-const role:'teachers' | 'student' = store.user.role === 'STUDENT' ? 'student':'teachers';
|
|
|
-
|
|
|
-let homeworkList = reactive<{
|
|
|
- tableData: IAssignment[]
|
|
|
-}>({
|
|
|
- tableData: []
|
|
|
-})
|
|
|
-
|
|
|
-const handleShowDetail = (assignmentId:number) => {
|
|
|
- router.push(`/home/homeworkDetail/${assignmentId}`)
|
|
|
+ import {Refresh, ZoomIn, Search} 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 {type AssignmentQueryDTO, AssignmentStatus} from "@/types/dto";
|
|
|
+ import assignment from "@/apis/assignment";
|
|
|
|
|
|
-}
|
|
|
+ const apis = useApis()
|
|
|
+ const store = useStore()
|
|
|
+ const doRefresh:Function = inject("reload")
|
|
|
+ const role:'teachers' | 'student' = store.user.role === 'STUDENT' ? 'student':'teachers';
|
|
|
|
|
|
-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])
|
|
|
- }
|
|
|
- })
|
|
|
- .catch((err: any) => {
|
|
|
- console.error(err);
|
|
|
- })
|
|
|
- .finally(() => {
|
|
|
- });
|
|
|
-}
|
|
|
+ // 获取的所有作业
|
|
|
+ let homeworkList = reactive<{
|
|
|
+ tableData: IAssignment[]
|
|
|
+ }>({
|
|
|
+ tableData: []
|
|
|
+ })
|
|
|
|
|
|
-const fetchHomeworkListByUserId = () => {
|
|
|
- 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)
|
|
|
- }
|
|
|
- })
|
|
|
- .catch((err: any) => {
|
|
|
- console.error(err);
|
|
|
- })
|
|
|
- .finally(() => {
|
|
|
- });
|
|
|
- } else if (role === "teachers") {
|
|
|
- apis.getCourseByTeacherId(store.user.id)
|
|
|
+ // 符合查询条件的作业
|
|
|
+ let processedHomeworkList = reactive<{
|
|
|
+ tableData: IAssignment[],
|
|
|
+ }>({
|
|
|
+ tableData: [],
|
|
|
+ })
|
|
|
+
|
|
|
+ // 最终展示的作业
|
|
|
+ let pageInfo = reactive<{
|
|
|
+ tableData: IAssignment[],
|
|
|
+ size: number, // 分页大小
|
|
|
+ pages: number, // 总页数
|
|
|
+ total: number
|
|
|
+ }>({
|
|
|
+ tableData: [],
|
|
|
+ size: 10,
|
|
|
+ pages: 1,
|
|
|
+ total: null,
|
|
|
+ })
|
|
|
+
|
|
|
+ const handleShowDetail = (assignmentId:number) => {
|
|
|
+ router.push(`/home/homeworkDetail/${assignmentId}`)
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ const handleCurrentChange = (pageNum: number) => {
|
|
|
+ Object.assign(pageInfo, {
|
|
|
+ tableData: getSlice(pageNum),
|
|
|
+ size: 10,
|
|
|
+ pages: pageNum,
|
|
|
+ total: processedHomeworkList.tableData.length,
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ const fetchHomeworkListByUserId = () => {
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ })
|
|
|
+ .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);
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const fetchHomeworkListByCourseId = (courseId:number) => {
|
|
|
+ apis.getAssignmentByCourseId(courseId)
|
|
|
.then((res: any) => {
|
|
|
- let data:CourseVO[] = res.data.data.records
|
|
|
- for(let i = 0; i < data.length; i++){
|
|
|
- fetchHomeworkListByCourseId(data[i].courseId)
|
|
|
+ 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,
|
|
|
+ })
|
|
|
})
|
|
|
.catch((err: any) => {
|
|
|
console.error(err);
|
|
|
@@ -117,29 +163,73 @@ const fetchHomeworkListByUserId = () => {
|
|
|
.finally(() => {
|
|
|
});
|
|
|
}
|
|
|
-}
|
|
|
|
|
|
-onMounted(() => {
|
|
|
- fetchHomeworkListByUserId()
|
|
|
- console.log(homeworkList)
|
|
|
-})
|
|
|
-
|
|
|
-// TODO:状态选择
|
|
|
-let state = ref(null)
|
|
|
-const stateOptions = [
|
|
|
- {
|
|
|
- value: 0,
|
|
|
- label: "已提交"
|
|
|
- },
|
|
|
- {
|
|
|
- value: 1,
|
|
|
- label: "未提交"
|
|
|
- },
|
|
|
- {
|
|
|
- value: 2,
|
|
|
- label: "已截止"
|
|
|
- },
|
|
|
-]
|
|
|
+ // 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++){
|
|
|
+ let assignmentItem = homeworkList.tableData[i]
|
|
|
+ let input = true;
|
|
|
+ if(state.value != null && state.value != assignmentItem.status) input = false;
|
|
|
+ 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,
|
|
|
+ total: processedHomeworkList.tableData.length,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //用于分页展示,截取数据
|
|
|
+ const getSlice = (page: number) => {
|
|
|
+ return processedHomeworkList.tableData.slice(page - 1, page + 10 - 1)
|
|
|
+ }
|
|
|
+
|
|
|
+ onMounted(() => {
|
|
|
+ fetchHomeworkListByUserId()
|
|
|
+ console.log(homeworkList)
|
|
|
+ })
|
|
|
+
|
|
|
+ let state = ref(null)
|
|
|
+ const stateOptions = [
|
|
|
+ {
|
|
|
+ value: AssignmentStatus.NOT_STARTED,
|
|
|
+ label: "未发布"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: AssignmentStatus.PROCEEDING,
|
|
|
+ label: "进行中"
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: AssignmentStatus.FINISHED,
|
|
|
+ label: "已截止"
|
|
|
+ },
|
|
|
+ ]
|
|
|
+
|
|
|
+ let assignmentName = ref('')
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<script lang="ts">
|