实训{{text}}时间
{{day}}天
{{hour}}小时
@@ -138,16 +138,15 @@ export default {
data() {
return {
classId: util.getCookie('classId'),
- className: util.getCookie("className"),
- courseId: util.getCookie("courseId"),
- projectId: util.getCookie("projectId"),
- assessmentId: util.getCookie("assessmentId"),
+ className: util.getCookie('className') ? decodeURI(util.getCookie('className')) : '',
+ courseId: util.getCookie('courseId'),
+ projectId: util.getCookie('projectId') ? Number(util.getCookie('projectId')) : '',
+ assessmentId: util.getCookie('assessmentId'),
projectPermissions: 0, // 项目权限(0、练习 1、考核 2、竞赛)
isSubmit: false, // 是否提交的标识
entryTime: new Date(),
- startTime: util.getCookie("startTime") ? new Date(util.getCookie("startTime")).getTime() : '',
- endTime: util.getCookie("stopTime") ? new Date(util.getCookie("stopTime")).getTime() : '',
- autoStart: true,
+ startTime: util.getCookie('startTime'),
+ endTime: util.getCookie('stopTime'),
pannelVisible: true, // 实验面板显示标识
grade: '00', // 得分
text: '', // 倒计时前面的文字,练习:所用;考核:剩余。练习是计时,考核是倒计时
@@ -156,25 +155,23 @@ export default {
seconds: 0, // 秒数
minutes: 0, // 分钟数
hour: 0, // 小时数
- createTime: '', // 开始时间
- actEndTime: '', // 倒计时结束时间
projectList: [], // 项目列表
- experimentTarget: "", //实验目标
- experimentDescription: "", //案例描述
- experimentHint: "", //实验提示
+ experimentTarget: '', //实验目标
+ experimentDescription: '', //案例描述
+ experimentHint: '', //实验提示
hintOpen: 1, // 是否显示实验提示
points: [], // 判分点列表
judgmentId: '', // 当前判分点id
curReq: [], // 当前实验要求
taskList: [], // 实验任务列表
- pannelTab: "first", // 面板信息切换值
+ pannelTab: 'first', // 面板信息切换值
isSelected: false // 是否选择过项目的标识,选择了会置为true
};
},
mounted() {
this.projectPermissions = this.projectId ? 1 : 0 // 考核/练习
if(this.projectId){ // 考核(考核才会从外面带进来projectId,练习是默认显示第一个项目)
- this.getProDetail()
+ this.getList()
}else{ // 练习
// 获取项目列表
this.getList().then(() => {
@@ -201,7 +198,7 @@ export default {
this.$get(`${this.api.queryTestProject}`,data).then(res => {
const list = res.projects
this.projectList = list
- this.projectId = list ? list[0].projectId : 0 // 默认取第一个项目
+ if (!this.projectPermissions) this.projectId = list ? list[0].projectId : 0 // 默认取第一个项目
this.getProDetail().then(() => {
resolve()
}).catch(res => {
@@ -231,53 +228,12 @@ export default {
this.experimentTarget = project.experimentTarget
this.experimentDescription = project.experimentDescription
this.experimentHint = project.experimentHint
- // this.actEndTime = project[0].endTime
this.hintOpen = !res.projectManage.hintOpen // 0显示,1不显示
this.$emit('tell', projectId, this.points)
- if (this.projectPermissions == 1) {
- this.text = "剩余"
- var interval = setInterval(() => {
- // 获取当前时间,同时得到活动结束时间数组
- let newTime = new Date().getTime();
- // 对结束时间进行处理渲染到页面
- let endTime = new Date(this.actEndTime).getTime();
- let obj = null; // 如果活动未结束,对时间进行处理
- if (endTime - newTime > 0) {
- let time = (endTime - newTime) / 1000; // 获取天、时、分、秒
- let day = parseInt(time / (60 * 60 * 24));
- let hou = parseInt((time % (60 * 60 * 24)) / 3600);
- let min = parseInt(((time % (60 * 60 * 24)) % 3600) / 60);
- let sec = parseInt(((time % (60 * 60 * 24)) % 3600) % 60);
- obj = {
- day: this.timeFormat(day),
- hou: this.timeFormat(hou),
- min: this.timeFormat(min),
- sec: this.timeFormat(sec)
- };
- } else {
- // 活动已结束,全部设置为'00'
- obj = {
- day: "00",
- hou: "00",
- min: "00",
- sec: "00"
- };
- clearInterval(interval);
- }
- this.day = obj.day;
- this.hour = obj.hou;
- this.minutes = obj.min;
- this.seconds = obj.sec;
- }, 1000);
- } else {
- this.text = "已用";
- // 获取当前时间
- this.createTime = new Date().getTime()
- //自动开始
- if (this.autoStart) {
- this.startCount()
- }
- }
+ const isAss = this.projectPermissions == 1 // 是否是考核
+ this.text = isAss ? '剩余' : '已用'
+ this.countVal = isAss ? (new Date(this.endTime).getTime() - Date.now()) / 1000 : 0 // 如果是考核,取考核的结束时间减去当前时间去做倒计时,练习则直接给0做计时
+ this.startCount()
resolve()
}).catch(err => {
reject()
@@ -286,8 +242,8 @@ export default {
},
// 获取上次缓存记录
getCache(pId, jId) {
- const projectId = pId ? pId : this.projectId
- const judgmentId = jId ? jId : this.judgmentId
+ const projectId = pId || this.projectId
+ const judgmentId = jId || this.judgmentId
this.$post(this.api.getLastCache, {
bcId: judgmentId, // 如果传进来了判分点id,说明本地有缓存,则直接取本地缓存的判分点id,否则,取第一个项目的第一个判分点id
projectId, // 项目id,同上
@@ -304,11 +260,21 @@ export default {
localStorage.removeItem('codeCache') // 恢复代码后清除本地缓存
this.projectId = projectId
this.judgmentId = judgmentId
- const item = this.points.find(e => e.judgmentId === judgmentId)
- if (item) item.code = code
- // debugger
- this.$emit('tell', projectId, this.points)
- this.$emit('recoveryCode', judgmentId + '')
+ // 如果是本地缓存里有项目id和判分点id,则要再次获取项目详情,取判分列表再次赋值;本地没有缓存则取只恢复第一个判分点的代码
+ if (pId) {
+ this.getProDetail().then(() => {
+ const points = this.points
+ const item = points.find(e => e.judgmentId === judgmentId)
+ if (item) item.code = code
+ this.$emit('tell', projectId, points)
+ this.$emit('recoveryCode', points.findIndex(e => e.judgmentId === judgmentId) + '')
+ }).catch(res => {})
+ } else {
+ const item = this.points.find(e => e.judgmentId === judgmentId)
+ if (item) item.code = code
+ this.$emit('tell', projectId, this.points)
+ this.$emit('recoveryCode')
+ }
}).catch(() => {
localStorage.removeItem('codeCache')
})
@@ -323,7 +289,7 @@ export default {
}).catch(res => {})
this.isSubmit = false
this.countVal = 0
- this.grade = 0
+ this.grade = '00'
// 切换实训项目-标签页回到第一个位置
this.$emit('recoveryCode')
newmain.$emit('isSubmit', this.isSubmit)
@@ -347,8 +313,6 @@ export default {
// 提交
submit() {
const pointList = this.$parent.workbench
- // debugger
- console.log(pointList)
if(!pointList.find(e => e.codeId)) return this.$message.error('请先完成实验')
this.$confirm("此操作将视为结束考试, 是否继续?", "提示", {
confirmButtonText: "确定",
@@ -359,11 +323,11 @@ export default {
const date = new Date()
const entryTime = this.entryTime
const timeSum = Math.ceil((date.getTime() - entryTime.getTime()) / 60000) // 计算实验用时(分钟),向上取整
- const endTime = util.formatDate('yyyy-MM-dd hh:mm:ss', date) // 结束时间
+ const submitTime = util.formatDate('yyyy-MM-dd hh:mm:ss', date)
const projectId = this.projectId
const projectName = this.projectList.find(e => e.projectId == projectId).projectName // 获取项目名称
- this.actEndTime = date
this.reloadCount()
+ // 判分点参数
const attributesReqList = []
pointList.map(e => {
e.codeId && attributesReqList.push({
@@ -377,22 +341,22 @@ export default {
classId: this.classId ? this.classId : '',
className: this.className ? this.className : '',
curriculumId: this.courseId,
- startTime: util.formatDate('yyyy-MM-dd hh:mm:ss', entryTime),
- endTime,
- submitTime: endTime,
+ startTime: this.projectPermissions ? this.startTime : util.formatDate('yyyy-MM-dd hh:mm:ss', entryTime), // 开始时间(考核:直接从职站取考核的开始时间;练习:取页面进入的时间)
+ endTime: this.projectPermissions ? this.endTime : submitTime, // 结束时间(考核:直接从职站取考核的结束时间;练习:取提交时间)
+ submitTime, // 提交时间,即当前时间(这3个时间都是传完整的日期时间格式)
timeSum,
projectId,
projectName,
assessmentId: this.assessmentId ? this.assessmentId : '',
- totalScore: 100,
+ totalScore: 100, // 判分点总分固定为100
systemId: 1,
- purpose: this.experimentTarget,
+ purpose: this.experimentTarget, // 实验目的
attributesReqList
}
this.$post(this.api.submit, data).then(res => {
localStorage.removeItem('codeCache')
this.isSubmit = true
- newmain.$emit("isSubmit", this.isSubmit);
+ newmain.$emit('isSubmit', this.isSubmit)
let list = res.message
let result = []
let taskList = this.taskList
@@ -412,12 +376,7 @@ export default {
});
})
.catch(err => {})
- }).catch(() => {
- this.$message({
- type: "info",
- message: "已取消提交"
- })
- })
+ }).catch(() => {})
},
// 实验面板显示隐藏
togglePannel() {
@@ -436,29 +395,29 @@ export default {
this.minutes = '00'
this.hour = '00'
},
- counterFn(counterTime) {
+ // 计时器(考核是倒计时,练习是计时)
+ counter(counterTime) {
let leave1 = counterTime % (24 * 3600) //计算天数后剩余的毫秒数
let leave2 = leave1 % 3600 //计算小时数后剩余的毫秒数
let leave3 = leave2 % 60 //计算分钟数后剩余的毫秒数
- let day = Math.floor(counterTime / (24 * 3600 * 1)); //计算相差天数
- let hour = Math.floor(leave1 / (3600 * 1)); //计算相差小时
- let minutes = Math.floor(leave2 / (60 * 1)); //计算相差分钟
- let seconds = Math.round(leave3 / 1); //计算相差秒
- day = day >= 10 ? day : "0" + day;
- hour = hour >= 10 ? hour : "0" + hour;
- minutes = minutes >= 10 ? minutes : "0" + minutes;
- seconds = seconds >= 10 ? seconds : "0" + seconds;
- this.day = day;
- this.hour = hour;
- this.minutes = minutes;
- this.seconds = seconds;
+ let day = Math.floor(counterTime / (24 * 3600 * 1)) //计算相差天数
+ let hour = Math.floor(leave1 / (3600 * 1)) //计算相差小时
+ let minutes = Math.floor(leave2 / (60 * 1)) //计算相差分钟
+ let seconds = Math.round(leave3 / 1) //计算相差秒
+ day = day >= 10 ? day : "0" + day
+ hour = hour >= 10 ? hour : "0" + hour
+ minutes = minutes >= 10 ? minutes : "0" + minutes
+ seconds = seconds >= 10 ? seconds : "0" + seconds
+ this.day = day
+ this.hour = hour
+ this.minutes = minutes
+ this.seconds = seconds
},
- // 倒计时
+ // 启动倒计时
startCount() {
clearInterval(this.counterTimer)
- this.countVal = this.countVal ? this.countVal : 0
this.counterTimer = setInterval(() => {
- this.counterFn(this.countVal++)
+ this.counter(this.projectPermissions ? this.countVal-- : this.countVal++)
}, 1000)
}
}
diff --git a/src/components/codemirror.vue b/src/components/codemirror.vue
index a704528..6acd19e 100644
--- a/src/components/codemirror.vue
+++ b/src/components/codemirror.vue
@@ -302,7 +302,7 @@ export default {
this.picSrc = ''
this.$emit('update:codeId', res.codeId)
if(photo){
- this.isError = data.retResult
+ this.isError = ''
const text = result.replace(photo, '')
this.runResult = text
this.picSrc = photo
diff --git a/src/views/Home.vue b/src/views/Home.vue
index c6ce0cc..54120f3 100644
--- a/src/views/Home.vue
+++ b/src/views/Home.vue
@@ -4,7 +4,7 @@
{{$config.title}}
- 退出实验
+ 退出实验
@@ -77,7 +77,7 @@ export default {
if(!this.$refs.mainindex.isSubmit && !this.assessmentId && list.length && list.some(e => e.code)){
const cache = {
projectId: this.projectId,
- judgmentId: list[this.curTab].judgmentId
+ judgmentId: list[Number(this.curTab)].judgmentId
}
localStorage.setItem('codeCache', JSON.stringify(cache))
list.map(e => {
@@ -111,8 +111,8 @@ export default {
},1000)
},
// 重置编辑器
- recoveryCode(curTab){
- this.curTab = '0'
+ recoveryCode(curTab = '0'){
+ this.curTab = curTab
this.codeKey++
},
// 退出实验
@@ -128,7 +128,7 @@ export default {
if (this.$config.isBeta) {
location.href = `http://120.78.198.231/#/station/list`
}
- location.href = `${this.$config.host}#/dashboard#1`
+ // location.href = `${this.$config.host}#/dashboard#1`
}
this.$refs.mainindex.getClearTime();
},