|
|
|
@ -300,6 +300,8 @@ if (param.token) { |
|
|
|
|
Cookies.set('sand-resultAnnouncementTime', param.resultAnnouncementTime ?? ''); |
|
|
|
|
Cookies.set('sand-curriculumName', param.curriculumName ?? ''); |
|
|
|
|
Cookies.set('sand-stopTime', param.stopTime ?? ''); |
|
|
|
|
Cookies.set('sand-userId', param.userId ?? ''); |
|
|
|
|
Cookies.set('sand-account', param.account ?? ''); |
|
|
|
|
Cookies.set('sand-admin', param.admin ?? ''); // 从中台进来的标识 |
|
|
|
|
Cookies.remove('sand-submit'); |
|
|
|
|
router.replace(route.path); |
|
|
|
@ -319,6 +321,8 @@ if (param.token) { |
|
|
|
|
param.resultAnnouncementTime = Cookies.get('sand-resultAnnouncementTime'); |
|
|
|
|
param.curriculumName = Cookies.get('sand-curriculumName'); |
|
|
|
|
param.stopTime = Cookies.get('sand-stopTime'); |
|
|
|
|
param.userId = Cookies.get('sand-userId'); |
|
|
|
|
param.account = Cookies.get('sand-account'); |
|
|
|
|
isSubmit.value = Cookies.get('sand-submit') === 'true'; |
|
|
|
|
} |
|
|
|
|
if (param.projectId) param.projectId = +param.projectId; |
|
|
|
@ -412,12 +416,15 @@ const getAssStatus = async () => { |
|
|
|
|
if (!isSubmit.value) { |
|
|
|
|
const { data } = await getDetailById(param.assessmentId); |
|
|
|
|
const done = data ? data.status === 2 : false; // 状态(0、待开始 1、进行中 2、已结束) |
|
|
|
|
// 如果考核已结束,则清除查询考核状态的定时器,并且自动提交 |
|
|
|
|
// 如果考核已结束,自动提交 |
|
|
|
|
if (done) { |
|
|
|
|
// this.$alert('考核时间已到,系统已自动交卷', '提示', { |
|
|
|
|
// confirmButtonText: '确定', |
|
|
|
|
// }); |
|
|
|
|
submit(); |
|
|
|
|
ElMessageBox.alert(`考核时间已到,系统已自动交卷`, '提示', { |
|
|
|
|
confirmButtonText: '确定', |
|
|
|
|
callback: (action: Action) => { |
|
|
|
|
logout(); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
@ -434,9 +441,12 @@ const getCompetitionStatus = async () => { |
|
|
|
|
const now = await getNow(); |
|
|
|
|
// 如果已经结束 |
|
|
|
|
if (now >= endTime) { |
|
|
|
|
// this.$alert('竞赛时间已到,系统已自动交卷', '提示', { |
|
|
|
|
// confirmButtonText: '确定', |
|
|
|
|
// }); |
|
|
|
|
ElMessageBox.alert(`竞赛时间已到,系统已自动交卷`, '提示', { |
|
|
|
|
confirmButtonText: '确定', |
|
|
|
|
callback: (action: Action) => { |
|
|
|
|
logout(); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
submit(); |
|
|
|
|
} else { |
|
|
|
|
// 没结束,则显示倒计时 |
|
|
|
@ -533,12 +543,16 @@ const submit = async () => { |
|
|
|
|
|
|
|
|
|
// 非练习 |
|
|
|
|
per.value && |
|
|
|
|
ElMessageBox.alert(`提交成功${param.resultsDetails == 0 && param.resultAnnouncementTime != 0 ? ',成绩将在' + param.resultAnnouncementTime + '小时后发布,请去参赛信息模块查看' : ''}`, '提示', { |
|
|
|
|
ElMessageBox.alert( |
|
|
|
|
`提交成功${param.resultsDetails == 0 && param.resultAnnouncementTime != 0 ? ',成绩将在' + param.resultAnnouncementTime + '小时后发布,请去参赛信息模块查看' : ''}`, |
|
|
|
|
'提示', |
|
|
|
|
{ |
|
|
|
|
confirmButtonText: '确定', |
|
|
|
|
callback: (action: Action) => { |
|
|
|
|
logout(); |
|
|
|
|
}, |
|
|
|
|
}); |
|
|
|
|
}, |
|
|
|
|
); |
|
|
|
|
}) |
|
|
|
|
.catch(() => { |
|
|
|
|
submiting.value = false; |
|
|
|
@ -598,6 +612,46 @@ const getEntryTime = async () => { |
|
|
|
|
if (!now) now = await getNow(); |
|
|
|
|
entryTime.value = now; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
// websocket获取考核及竞赛信息,用于自动提交 |
|
|
|
|
// socket连接成功 |
|
|
|
|
const open = () => { |
|
|
|
|
console.log('socket连接成功'); |
|
|
|
|
}; |
|
|
|
|
// socket连接失败 |
|
|
|
|
const error = () => { |
|
|
|
|
console.log('连接错误'); |
|
|
|
|
}; |
|
|
|
|
// 接收消息 |
|
|
|
|
const getMessage = (msg) => { |
|
|
|
|
console.log('==websocket接收数据=='); |
|
|
|
|
console.log(JSON.parse(msg.data)); |
|
|
|
|
const { content } = JSON.parse(msg.data); |
|
|
|
|
// 1赛事、2创业、3考核、4模型。-号拼接携带id |
|
|
|
|
if (content == 1) { |
|
|
|
|
getCompetitionStatus(); |
|
|
|
|
} else if (content.includes('3-')) { |
|
|
|
|
// 考核:3-考核id |
|
|
|
|
getAssStatus(); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
// 关闭socket |
|
|
|
|
const close = () => { |
|
|
|
|
console.log('socket已经关闭'); |
|
|
|
|
}; |
|
|
|
|
// 初始化socket |
|
|
|
|
const initSocket = () => { |
|
|
|
|
// 实例化socket |
|
|
|
|
const socket = new WebSocket(`ws://${location.host}/nakadai/websocket/${param.userId}/${param.account}`); |
|
|
|
|
// this.socket = new WebSocket(`ws://121.37.12.51:9100/nakadai/websocket/${id}/${account}`) |
|
|
|
|
// 监听socket连接 |
|
|
|
|
socket.onopen = open; |
|
|
|
|
// 监听socket错误信息 |
|
|
|
|
socket.onerror = error; |
|
|
|
|
// 监听socket消息 |
|
|
|
|
socket.onmessage = getMessage; |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
onMounted(() => { |
|
|
|
|
getLevel.value = inject('getLevel'); // 关卡页面获取关卡方法 |
|
|
|
|
per.value = param.assessmentId ? 1 : param.competitionId ? 2 : 0; |
|
|
|
@ -605,10 +659,12 @@ onMounted(() => { |
|
|
|
|
param.cid && getEntryTime(); |
|
|
|
|
|
|
|
|
|
if (param.assessmentId) { |
|
|
|
|
initSocket(); |
|
|
|
|
getAssList(); |
|
|
|
|
} else { |
|
|
|
|
param.cid && getList(); |
|
|
|
|
if (param.competitionId) { |
|
|
|
|
initSocket(); |
|
|
|
|
getCompetitionStatus(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|