考核联调,完善缓存

ui
jialong.yu 3 years ago
parent 0e57c10c13
commit 82126539d5
  1. 153
      src/components/TestPanel.vue
  2. 2
      src/components/codemirror.vue
  3. 10
      src/views/Home.vue

@ -23,7 +23,7 @@
</div>
<div class="countDownBox">
<div style="margin-left: -40px;">
<div :autoStart="autoStart">
<div>
实训{{text}}时间
<span class="timeSpan">{{day}}</span>
<span class="timeSpan">{{hour}}</span>小时
@ -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 // 01
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) {
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, // ididid
projectId, // id
@ -304,11 +260,21 @@ export default {
localStorage.removeItem('codeCache') //
this.projectId = projectId
this.judgmentId = judgmentId
// idid
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
// debugger
this.$emit('tell', projectId, this.points)
this.$emit('recoveryCode', judgmentId + '')
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)
}
}

@ -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

@ -4,7 +4,7 @@
<img v-if="$config.isHh" src="../assets/img/logo-hh.png" alt="" class="logo">
<p v-else>{{$config.title}}</p>
<div class="bt">
<el-button type="primary" @click="back()">退出实验</el-button>
<el-button type="primary" @click="back">退出实验</el-button>
</div>
</div>
@ -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();
},

Loading…
Cancel
Save