Ver código fonte

我的作业接口修改

canghailong 6 meses atrás
pai
commit
ca3c8c3bd6

+ 1 - 0
src/api/student/examPaper.js

@@ -5,6 +5,7 @@ const request = (url, ...arg) => baseRequest(`/api/webapp/` + url, ...arg)
 export default {
 	select: (id) => request('api/student/exam/paper/select/' + id, '', 'post'),
 	pageList: (query) => request('api/student/exam/paper/pageList', query, 'post'),
+	newPageList: (query) => request('api/student/exam/paper/selectList', query, 'post'),
 	task: () => request('api/student/dashboard/task'),
 	pageExamList: (query) => request('api/admin/s_exam/page', query, 'get')
 }

+ 4 - 5
src/views/student/exam/paper/do.vue

@@ -67,7 +67,7 @@
 				</a-form>
 			</a-layout-content>
 		</a-layout>
-		<forumBtn :forumData="forumData" :resourceType="resourceType" :isShow="[1,2,3]"></forumBtn>
+		<forumBtn :forumData="forumData" :resourceType="resourceType" :isShow="[1, 2, 3]"></forumBtn>
 	</div>
 </template>
 
@@ -80,7 +80,6 @@
 	import examPaperApi from '@/api/student/examPaper'
 	import examPaperAnswerApi from '@/api/student/examPaperAnswer'
 	import { Modal } from 'ant-design-vue'
-	import EventBus from '@/utils/EventBus'
 	import '../../style.less'
 	const route = useRoute()
 	const router = useRouter()
@@ -150,7 +149,7 @@
 			}
 		}, 1000)
 	}
-
+	const channel = new BroadcastChannel('getTaskList')
 	function submitForm() {
 		clearInterval(timer.value)
 		formLoading.value = true
@@ -162,8 +161,8 @@
 					content: `试卷得分:${re}分`,
 					okText: '返回',
 					onOk: () => {
-						EventBus.emit('getReadList')
-						window.close();
+						channel.postMessage({ type: 1 })
+						window.close()
 					}
 				})
 				formLoading.value = false

+ 59 - 72
src/views/student/paper/index.vue

@@ -15,65 +15,41 @@
 						:pagination="pagination"
 					>
 						<template #bodyCell="{ column, record }">
-							<div v-if="examType != 4">
-								<template v-if="column.key === 'examName'">
-									{{ record.examName }}
-								</template>
-								<template v-if="column.key === 'examType'">
-									{{ examTypeName(record.examType) || '--' }}
-								</template>
-								<template v-if="column.key === 'startTime'">
-									{{ formatDateTime(record.startTime) || '--' }}
-								</template>
-								<template v-if="column.key === 'endTime'">
-									{{ formatDateTime(record.endTime) || '--' }}
-								</template>
-								<template v-if="column.key === 'status'">
-									<a-tag :color="statusTagFormatter(record.status)" size="small">
-										{{ statusTextFormatter(record.status) }}
-									</a-tag>
-								</template>
-								<template v-if="column.key === 'action'">
-									<router-link
-										v-if="record.status == 0"
-										:to="{ path: '/student/do', query: { id: record.paperId } }"
-										target="_blank"
-									>
-										<a-button type="link" size="small">填写{{ examName }}</a-button>
-									</router-link>
-									<router-link
-										v-if="record.status == 2"
-										:to="{ path: '/student/read', query: { id: record.answerId } }"
-										target="_blank"
-									>
-										<a-button type="link" size="small">查看结果</a-button>
-									</router-link>
-								</template>
-							</div>
-							<div v-if="examType == 4">
-								<template v-if="column.key === 'name'">
-									{{ record.name }}
-								</template>
-								<template v-if="column.key === 'paperType'">
-									{{ paperTypeEnum(record.paperType) }}
-								</template>
-								<template v-if="column.key === 'action'">
-									<router-link
-										v-if="!record.status"
-										:to="{ path: '/student/do', query: { id: record.id } }"
-										target="_blank"
-									>
-										<a-button type="link" size="small">开始答题</a-button>
-									</router-link>
-									<router-link
-										v-if="record.status == 2"
-										:to="{ path: '/student/read', query: { id: record.answerId } }"
-										target="_blank"
-									>
-										<a-button type="link" size="small">查看结果</a-button>
-									</router-link>
-								</template>
-							</div>
+							<template v-if="record.examType && column.key === 'examType'">
+								{{ examTypeName(record.examType) || '--' }}
+							</template>
+							<template v-if="record.startTime && column.key === 'startTime'">
+								{{ formatDateTime(record.startTime) || '--' }}
+							</template>
+							<template v-if="record.endTime && column.key === 'endTime'">
+								{{ formatDateTime(record.endTime) || '--' }}
+							</template>
+
+							<template v-if="record.paperType && column.key === 'paperType'">
+								{{ paperTypeEnum(record.paperType) }}
+							</template>
+
+							<template v-if="column.key === 'status'">
+								<a-tag :color="statusTagFormatter(record.status)" size="small">
+									{{ statusTextFormatter(record.status) }}
+								</a-tag>
+							</template>
+							<template v-if="column.key === 'action'">
+								<router-link
+									v-if="record.status == 0"
+									:to="{ path: '/student/do', query: { id: record.paperId ? record.paperId : record.id } }"
+									target="_blank"
+								>
+									<a-button type="link" size="small">{{ examType == 4 ? `开始答题` : `填写${examName}` }}</a-button>
+								</router-link>
+								<router-link
+									v-if="record.status == 2"
+									:to="{ path: '/student/read', query: { id: record.answerId } }"
+									target="_blank"
+								>
+									<a-button type="link" size="small">查看结果</a-button>
+								</router-link>
+							</template>
 						</template>
 					</a-table>
 				</a-spin>
@@ -89,7 +65,6 @@
 	import { useRoute } from 'vue-router'
 	import tool from '@/utils/tool'
 	import { parseTime } from '@/utils/exam'
-	import EventBus from '@/utils/EventBus'
 	const route = useRoute()
 	const formatDateTime = (val) => {
 		if (!val) return ''
@@ -143,18 +118,22 @@
 		}
 	]
 	const taskColumns = computed(() =>
-		taskAllColumns.value.filter((r) => r.examType.includes(parseFloat(examType.value)))
+		taskAllColumns.value.filter((r) => r.columnsType.includes(parseFloat(examType.value)))
 	)
 	const taskAllColumns = ref([
-		{ title: '作业名称', dataIndex: 'name', key: 'name', examType: [4] },
-		{ title: '试卷类型', dataIndex: 'paperType', key: 'paperType', width: 120, examType: [4] },
+		{ title: '课程名称', dataIndex: 'courseName', key: 'courseName', columnsType: [4] },
+		{ title: '章节名称', dataIndex: 'chapterName', key: 'chapterName', columnsType: [4] },
+		{ title: '课时名称', dataIndex: 'hourName', key: 'hourName', columnsType: [4] },
+		{ title: '作业名称', dataIndex: 'name', key: 'name', columnsType: [4] },
+		{ title: '试卷类型', dataIndex: 'paperType', key: 'paperType', width: 120, columnsType: [4] },
 
-		{ title: '问卷名称', dataIndex: 'examName', key: 'examName', examType: [1, 2, 3] },
-		{ title: '问卷类型', dataIndex: 'examType', key: 'examType', width: 120, examType: [1, 2, 3] },
-		{ title: '开始时间', dataIndex: 'startTime', key: 'startTime', width: 180, examType: [1, 2, 3] },
-		{ title: '结束时间', dataIndex: 'endTime', key: 'endTime', width: 180, examType: [1, 2, 3] },
-		{ title: '状态', dataIndex: 'status', key: 'status', width: 90, examType: [1, 2, 3] },
-		{ title: '操作', key: 'action', align: 'right', width: 120, examType: [1, 2, 3, 4] }
+		{ title: '问卷名称', dataIndex: 'examName', key: 'examName', columnsType: [1, 2, 3] },
+		{ title: '问卷类型', dataIndex: 'examType', key: 'examType', width: 120, columnsType: [1, 2, 3] },
+		{ title: '开始时间', dataIndex: 'startTime', key: 'startTime', width: 180, columnsType: [1, 2, 3] },
+		{ title: '结束时间', dataIndex: 'endTime', key: 'endTime', width: 180, columnsType: [1, 2, 3] },
+
+		{ title: '状态', dataIndex: 'status', key: 'status', width: 90, columnsType: [1, 2, 3, 4] },
+		{ title: '操作', key: 'action', align: 'right', width: 120, columnsType: [1, 2, 3, 4] }
 	])
 
 	const statusTextFormatter = (status) => {
@@ -182,7 +161,7 @@
 				examType: examType.value
 			}
 			if (examType.value == 4) {
-				res = await examPaperApi.pageList(params)
+				res = await examPaperApi.newPageList(params)
 			} else {
 				res = await taskApi.pageExamList(params)
 			}
@@ -210,12 +189,20 @@
 	// lifecycle
 	const examType = ref()
 	const paperType = ref(2)
-	EventBus.off('getTaskList', getTaskList)
-	EventBus.on('getTaskList', getTaskList)
+	const channel = new BroadcastChannel('getTaskList')
+	channel.onmessage = function (event) {
+		if (event.data.type == 1) {
+			getTaskList()
+		}
+	}
 	onMounted(() => {
 		examType.value = route.params && route.params.examType
 		getTaskList()
 	})
+	onUnmounted(() => {
+		channel.onmessage = null
+		channel.close()
+	})
 </script>
 
 <style lang="less" scoped>