diff --git a/src/api/monitor/index.ts b/src/api/monitor/index.ts index 9c03d60..806de13 100644 --- a/src/api/monitor/index.ts +++ b/src/api/monitor/index.ts @@ -40,6 +40,7 @@ export const MonitorApi = { deleteMonitor: async (id: number) => { return await request.delete({ url: `/exam/monitor/delete?id=` + id }) }, + // 获取学生文件 getMonitorStuFileUrl: async (temporaryId: string) => { return await request.get({ url: `/exam/monitor/getMonitorStuFileUrl?temporaryId=` + temporaryId }) @@ -56,10 +57,20 @@ export const MonitorApi = { }, - updateMonitorStatus:async( data)=>{ + updateMonitorStatus: async (data) => { return await request.post({ url: `/exam/monitor/updateMonitorStatus` , data }) }, + getMonitorTaskPage: async (params: any) => { return await request.get({ url: `/exam/monitorTask/page`, params }) }, + + stopExamForAdmin: async (params: any) => { + return await request.get({ url: `/tool/stopExamForAdmin?userId=`+ params.userId + `&taskId=` + params.taskId + `&paperNum=` + params.paperNum}) + }, + + reStartExamForAdmin: async (data) => { + return await request.post({ url: `/tool/reStartExamForAdmin` , data }) + }, + } diff --git a/src/views/monitor/monitor/index.vue b/src/views/monitor/monitor/index.vue index f4ed455..3f110d7 100644 --- a/src/views/monitor/monitor/index.vue +++ b/src/views/monitor/monitor/index.vue @@ -1,21 +1,4 @@ - + - - @@ -220,7 +194,112 @@ @pagination="getList" /> + + + *只有状态为考试中的考试才可以增加时间,增加的时间的同时,并勾选考试中. + + + + 待考 + 考试中 + 考试完成 + + + + + + + + + + + + + + + + {{ formData.nickname }} + + + + + {{ formData.username }} + + + + + + + {{ formData.className }} + + + + + {{ formData.taskName }} + + + + + + + {{ formData.paperNum }} + + + + + {{ formData.score }} + + + + + + + {{ formData.remainingTime }} + + + + + {{ formData.ip }} + + + + + + + {{ formData.startTime }} + + + + + {{ formData.endTime }} + + + + + + + + + + + + + + + + + @@ -233,8 +312,9 @@ import MonitorForm from './MonitorForm.vue' import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import taskMonitor from './task-monitor.vue' import * as ClassApi from '@/api/exam/class' - +const formData = ref({}) import { ref } from 'vue' +import { getInfo } from '@/api/login' const selectedTaskId = ref(null) const fixedTaskId = ref('') @@ -250,9 +330,11 @@ defineOptions({ name: 'Monitor' }) const initDialogVisible = ref(true) // 弹窗开关 const dialogVisible = ref(false) +const dialogVisibleForInfo = ref(false) const message = useMessage() // 消息弹窗 const { t } = useI18n() // 国际化 -const selectedStatus = ref(null) +const selectedStatus = ref('') +const times = ref('') const loading = ref(true) // 列表的加载中 const list = ref([]) // 列表的数据 const total = ref(0) // 列表的总页数 @@ -260,7 +342,7 @@ const classNameList = ref() const queryParams = reactive({ pageNo: 1, pageSize: 10, - monitorId: undefined, + monitorId: '', taskId: '', username: undefined, nickname: undefined, @@ -272,7 +354,8 @@ const queryParams = reactive({ taskName: undefined, ip: undefined, remainingTime: [], - createTime: [] + startTime: undefined, + endTime: undefined }) const queryFormRef = ref() // 搜索的表单 const exportLoading = ref(false) // 导出的加载中 @@ -311,11 +394,15 @@ const returnTop = async () => { /** 表格选中数据 */ const selections = ref([]) -const taskList = ref([]) +interface TaskItem { + taskName: string + [key: string]: any +} +const taskList = ref([]) const handleSelectionChange = (rows) => { selections.value = rows } -const dateFormatterMin = (row, column, cellValue) => { +const dateFormatterMin = (_row: any, _column: any, cellValue: number) => { if (cellValue == null || isNaN(cellValue)) return '-' const hours = Math.floor(cellValue / 3600) @@ -323,7 +410,7 @@ const dateFormatterMin = (row, column, cellValue) => { const seconds = cellValue % 60 // 补零处理 - const pad = (n) => n.toString().padStart(2, '0') + const pad = (n: number) => n.toString().padStart(2, '0') return `${pad(hours)}:${pad(minutes)}:${pad(seconds)}` } @@ -347,10 +434,10 @@ const openForm = (type: string, id?: number) => { } // 提交状态变更 const confirmChange = async () => { - if (selectedStatus.value === null) { - ElMessage.error('请选择考试状态') - return - } + // if (selectedStatus.value === null) { + // ElMessage.error('请选择考试状态') + // return + // } const rows = selections.value @@ -358,12 +445,31 @@ const confirmChange = async () => { await MonitorApi.updateMonitorStatus({ monitorIds, // 这是数组 - status: selectedStatus.value // 这是 0,1,2 + status: selectedStatus.value, // 这是 0,1,2 + times: times.value // 这是 "HH:mm:ss" + }).then((res) => { + // 清空选择 + selections.value = [] + selectedStatus.value = '' + times.value = '' + console.log(res) + if (res.type === 'STOP') { + MonitorApi.stopExamForAdmin({ + stuId: res.stuId, + taskId: res.taskId, + paperNum: res.paperNum + }) + } else { + MonitorApi.reStartExamForAdmin({ + stuId: res.stuId, + taskId: res.taskId, + paperId: res.paperNum + }) + } + ElMessage.success('更新成功') + dialogVisible.value = false + getList() }) - - ElMessage.success('考试状态更新成功') - dialogVisible.value = false - getList() } /** 删除按钮操作 */ const handleDelete = async (id: number) => { @@ -378,6 +484,11 @@ const handleDelete = async (id: number) => { } catch {} } +const getMonitorInfo = async (row: any) => { + formData.value = row + dialogVisibleForInfo.value = true +} + const downloadFile = async (row: any) => { const res = await MonitorApi.getMonitorStuFileUrl(row.temporaryId) console.log(res)