|
@@ -4,7 +4,7 @@
|
|
|
Created Date: 2024-7-3
|
|
Created Date: 2024-7-3
|
|
|
-->
|
|
-->
|
|
|
<template>
|
|
<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-button :icon="Refresh" circle @click="doRefresh"></el-button>
|
|
|
<el-select
|
|
<el-select
|
|
|
v-model="state"
|
|
v-model="state"
|
|
@@ -25,7 +25,7 @@
|
|
|
查询
|
|
查询
|
|
|
</el-button>
|
|
</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 #empty>
|
|
|
暂无作业
|
|
暂无作业
|
|
|
</template>
|
|
</template>
|
|
@@ -48,9 +48,11 @@
|
|
|
small
|
|
small
|
|
|
style="font-size: 16px;margin-top: 10px;margin-left: 450px"
|
|
style="font-size: 16px;margin-top: 10px;margin-left: 450px"
|
|
|
@current-change="handleCurrentChange"
|
|
@current-change="handleCurrentChange"
|
|
|
|
|
+ @size-change="handleSizeChange"
|
|
|
|
|
+ :page-sizes="[5, 10, 15]"
|
|
|
:current-page="pageInfo.pages"
|
|
:current-page="pageInfo.pages"
|
|
|
:page-size="pageInfo.size"
|
|
:page-size="pageInfo.size"
|
|
|
- layout="total, prev, pager, next, jumper"
|
|
|
|
|
|
|
+ layout="total, sizes, prev, pager, next, jumper"
|
|
|
:total="pageInfo.total">
|
|
:total="pageInfo.total">
|
|
|
</el-pagination>
|
|
</el-pagination>
|
|
|
</el-card>
|
|
</el-card>
|
|
@@ -63,12 +65,13 @@
|
|
|
import {useStore} from "@/store";
|
|
import {useStore} from "@/store";
|
|
|
import type {CourseVO, IAssignment} from "@/types/vo";
|
|
import type {CourseVO, IAssignment} from "@/types/vo";
|
|
|
import router from "@/router";
|
|
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 apis = useApis()
|
|
|
const store = useStore()
|
|
const store = useStore()
|
|
|
const doRefresh:Function = inject("reload")
|
|
const doRefresh:Function = inject("reload")
|
|
|
|
|
+ const {formatDate} = useFormatDate()
|
|
|
const role:'teachers' | 'student' = store.user.role === 'STUDENT' ? 'student':'teachers';
|
|
const role:'teachers' | 'student' = store.user.role === 'STUDENT' ? 'student':'teachers';
|
|
|
|
|
|
|
|
// 获取的所有作业
|
|
// 获取的所有作业
|
|
@@ -105,86 +108,74 @@
|
|
|
|
|
|
|
|
const handleCurrentChange = (pageNum: number) => {
|
|
const handleCurrentChange = (pageNum: number) => {
|
|
|
Object.assign(pageInfo, {
|
|
Object.assign(pageInfo, {
|
|
|
- tableData: getSlice(pageNum),
|
|
|
|
|
- size: 10,
|
|
|
|
|
|
|
+ tableData: getSlice(pageNum, pageInfo.size),
|
|
|
|
|
+ size: pageInfo.size,
|
|
|
pages: pageNum,
|
|
pages: pageNum,
|
|
|
total: processedHomeworkList.tableData.length,
|
|
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') {
|
|
if (role === 'student') {
|
|
|
apis.getCourseByStudentId(store.user.id)
|
|
apis.getCourseByStudentId(store.user.id)
|
|
|
.then((res: any) => {
|
|
.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") {
|
|
} else if (role === "teachers") {
|
|
|
apis.getCourseByTeacherId(store.user.id)
|
|
apis.getCourseByTeacherId(store.user.id)
|
|
|
.then((res: any) => {
|
|
.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) => {
|
|
const fetchHomeworkListByCourseId = (courseId:number) => {
|
|
|
apis.getAssignmentByCourseId(courseId)
|
|
apis.getAssignmentByCourseId(courseId)
|
|
|
.then((res: any) => {
|
|
.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 = () => {
|
|
const handleSearch = () => {
|
|
|
processedHomeworkList.tableData = []
|
|
processedHomeworkList.tableData = []
|
|
|
for(let i = 0; i < homeworkList.tableData.length; i++){
|
|
for(let i = 0; i < homeworkList.tableData.length; i++){
|
|
@@ -194,21 +185,21 @@
|
|
|
if(assignmentName.value != '' && !assignmentItem.assignmentName.includes(assignmentName.value)) input = false;
|
|
if(assignmentName.value != '' && !assignmentItem.assignmentName.includes(assignmentName.value)) input = false;
|
|
|
if(input) processedHomeworkList.tableData.push(assignmentItem);
|
|
if(input) processedHomeworkList.tableData.push(assignmentItem);
|
|
|
Object.assign(pageInfo, {
|
|
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,
|
|
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(() => {
|
|
onMounted(() => {
|
|
|
- fetchHomeworkListByUserId()
|
|
|
|
|
|
|
+ fetchData()
|
|
|
console.log(homeworkList)
|
|
console.log(homeworkList)
|
|
|
})
|
|
})
|
|
|
|
|
|