考核联调,完善缓存

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>
<div class="countDownBox"> <div class="countDownBox">
<div style="margin-left: -40px;"> <div style="margin-left: -40px;">
<div :autoStart="autoStart"> <div>
实训{{text}}时间 实训{{text}}时间
<span class="timeSpan">{{day}}</span> <span class="timeSpan">{{day}}</span>
<span class="timeSpan">{{hour}}</span>小时 <span class="timeSpan">{{hour}}</span>小时
@ -138,16 +138,15 @@ export default {
data() { data() {
return { return {
classId: util.getCookie('classId'), classId: util.getCookie('classId'),
className: util.getCookie("className"), className: util.getCookie('className') ? decodeURI(util.getCookie('className')) : '',
courseId: util.getCookie("courseId"), courseId: util.getCookie('courseId'),
projectId: util.getCookie("projectId"), projectId: util.getCookie('projectId') ? Number(util.getCookie('projectId')) : '',
assessmentId: util.getCookie("assessmentId"), assessmentId: util.getCookie('assessmentId'),
projectPermissions: 0, // (0 1 2) projectPermissions: 0, // (0 1 2)
isSubmit: false, // isSubmit: false, //
entryTime: new Date(), entryTime: new Date(),
startTime: util.getCookie("startTime") ? new Date(util.getCookie("startTime")).getTime() : '', startTime: util.getCookie('startTime'),
endTime: util.getCookie("stopTime") ? new Date(util.getCookie("stopTime")).getTime() : '', endTime: util.getCookie('stopTime'),
autoStart: true,
pannelVisible: true, // pannelVisible: true, //
grade: '00', // grade: '00', //
text: '', // text: '', //
@ -156,25 +155,23 @@ export default {
seconds: 0, // seconds: 0, //
minutes: 0, // minutes: 0, //
hour: 0, // hour: 0, //
createTime: '', //
actEndTime: '', //
projectList: [], // projectList: [], //
experimentTarget: "", // experimentTarget: '', //
experimentDescription: "", // experimentDescription: '', //
experimentHint: "", // experimentHint: '', //
hintOpen: 1, // hintOpen: 1, //
points: [], // points: [], //
judgmentId: '', // id judgmentId: '', // id
curReq: [], // curReq: [], //
taskList: [], // taskList: [], //
pannelTab: "first", // pannelTab: 'first', //
isSelected: false // true isSelected: false // true
}; };
}, },
mounted() { mounted() {
this.projectPermissions = this.projectId ? 1 : 0 // / this.projectPermissions = this.projectId ? 1 : 0 // /
if(this.projectId){ // projectId) if(this.projectId){ // projectId)
this.getProDetail() this.getList()
}else{ // }else{ //
// //
this.getList().then(() => { this.getList().then(() => {
@ -201,7 +198,7 @@ export default {
this.$get(`${this.api.queryTestProject}`,data).then(res => { this.$get(`${this.api.queryTestProject}`,data).then(res => {
const list = res.projects const list = res.projects
this.projectList = list this.projectList = list
this.projectId = list ? list[0].projectId : 0 // if (!this.projectPermissions) this.projectId = list ? list[0].projectId : 0 //
this.getProDetail().then(() => { this.getProDetail().then(() => {
resolve() resolve()
}).catch(res => { }).catch(res => {
@ -231,53 +228,12 @@ export default {
this.experimentTarget = project.experimentTarget this.experimentTarget = project.experimentTarget
this.experimentDescription = project.experimentDescription this.experimentDescription = project.experimentDescription
this.experimentHint = project.experimentHint this.experimentHint = project.experimentHint
// this.actEndTime = project[0].endTime
this.hintOpen = !res.projectManage.hintOpen // 01 this.hintOpen = !res.projectManage.hintOpen // 01
this.$emit('tell', projectId, this.points) this.$emit('tell', projectId, this.points)
if (this.projectPermissions == 1) { const isAss = this.projectPermissions == 1 //
this.text = "剩余" this.text = isAss ? '剩余' : '已用'
var interval = setInterval(() => { this.countVal = isAss ? (new Date(this.endTime).getTime() - Date.now()) / 1000 : 0 // 0
//
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() this.startCount()
}
}
resolve() resolve()
}).catch(err => { }).catch(err => {
reject() reject()
@ -286,8 +242,8 @@ export default {
}, },
// //
getCache(pId, jId) { getCache(pId, jId) {
const projectId = pId ? pId : this.projectId const projectId = pId || this.projectId
const judgmentId = jId ? jId : this.judgmentId const judgmentId = jId || this.judgmentId
this.$post(this.api.getLastCache, { this.$post(this.api.getLastCache, {
bcId: judgmentId, // ididid bcId: judgmentId, // ididid
projectId, // id projectId, // id
@ -304,11 +260,21 @@ export default {
localStorage.removeItem('codeCache') // localStorage.removeItem('codeCache') //
this.projectId = projectId this.projectId = projectId
this.judgmentId = judgmentId 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) const item = this.points.find(e => e.judgmentId === judgmentId)
if (item) item.code = code if (item) item.code = code
// debugger
this.$emit('tell', projectId, this.points) this.$emit('tell', projectId, this.points)
this.$emit('recoveryCode', judgmentId + '') this.$emit('recoveryCode')
}
}).catch(() => { }).catch(() => {
localStorage.removeItem('codeCache') localStorage.removeItem('codeCache')
}) })
@ -323,7 +289,7 @@ export default {
}).catch(res => {}) }).catch(res => {})
this.isSubmit = false this.isSubmit = false
this.countVal = 0 this.countVal = 0
this.grade = 0 this.grade = '00'
// - // -
this.$emit('recoveryCode') this.$emit('recoveryCode')
newmain.$emit('isSubmit', this.isSubmit) newmain.$emit('isSubmit', this.isSubmit)
@ -347,8 +313,6 @@ export default {
// //
submit() { submit() {
const pointList = this.$parent.workbench const pointList = this.$parent.workbench
// debugger
console.log(pointList)
if(!pointList.find(e => e.codeId)) return this.$message.error('请先完成实验') if(!pointList.find(e => e.codeId)) return this.$message.error('请先完成实验')
this.$confirm("此操作将视为结束考试, 是否继续?", "提示", { this.$confirm("此操作将视为结束考试, 是否继续?", "提示", {
confirmButtonText: "确定", confirmButtonText: "确定",
@ -359,11 +323,11 @@ export default {
const date = new Date() const date = new Date()
const entryTime = this.entryTime const entryTime = this.entryTime
const timeSum = Math.ceil((date.getTime() - entryTime.getTime()) / 60000) // 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 projectId = this.projectId
const projectName = this.projectList.find(e => e.projectId == projectId).projectName // const projectName = this.projectList.find(e => e.projectId == projectId).projectName //
this.actEndTime = date
this.reloadCount() this.reloadCount()
//
const attributesReqList = [] const attributesReqList = []
pointList.map(e => { pointList.map(e => {
e.codeId && attributesReqList.push({ e.codeId && attributesReqList.push({
@ -377,22 +341,22 @@ export default {
classId: this.classId ? this.classId : '', classId: this.classId ? this.classId : '',
className: this.className ? this.className : '', className: this.className ? this.className : '',
curriculumId: this.courseId, curriculumId: this.courseId,
startTime: util.formatDate('yyyy-MM-dd hh:mm:ss', entryTime), startTime: this.projectPermissions ? this.startTime : util.formatDate('yyyy-MM-dd hh:mm:ss', entryTime), //
endTime, endTime: this.projectPermissions ? this.endTime : submitTime, //
submitTime: endTime, submitTime, // 3
timeSum, timeSum,
projectId, projectId,
projectName, projectName,
assessmentId: this.assessmentId ? this.assessmentId : '', assessmentId: this.assessmentId ? this.assessmentId : '',
totalScore: 100, totalScore: 100, // 100
systemId: 1, systemId: 1,
purpose: this.experimentTarget, purpose: this.experimentTarget, //
attributesReqList attributesReqList
} }
this.$post(this.api.submit, data).then(res => { this.$post(this.api.submit, data).then(res => {
localStorage.removeItem('codeCache') localStorage.removeItem('codeCache')
this.isSubmit = true this.isSubmit = true
newmain.$emit("isSubmit", this.isSubmit); newmain.$emit('isSubmit', this.isSubmit)
let list = res.message let list = res.message
let result = [] let result = []
let taskList = this.taskList let taskList = this.taskList
@ -412,12 +376,7 @@ export default {
}); });
}) })
.catch(err => {}) .catch(err => {})
}).catch(() => { }).catch(() => {})
this.$message({
type: "info",
message: "已取消提交"
})
})
}, },
// //
togglePannel() { togglePannel() {
@ -436,29 +395,29 @@ export default {
this.minutes = '00' this.minutes = '00'
this.hour = '00' this.hour = '00'
}, },
counterFn(counterTime) { //
counter(counterTime) {
let leave1 = counterTime % (24 * 3600) // let leave1 = counterTime % (24 * 3600) //
let leave2 = leave1 % 3600 // let leave2 = leave1 % 3600 //
let leave3 = leave2 % 60 // let leave3 = leave2 % 60 //
let day = Math.floor(counterTime / (24 * 3600 * 1)); // let day = Math.floor(counterTime / (24 * 3600 * 1)) //
let hour = Math.floor(leave1 / (3600 * 1)); // let hour = Math.floor(leave1 / (3600 * 1)) //
let minutes = Math.floor(leave2 / (60 * 1)); // let minutes = Math.floor(leave2 / (60 * 1)) //
let seconds = Math.round(leave3 / 1); // let seconds = Math.round(leave3 / 1) //
day = day >= 10 ? day : "0" + day; day = day >= 10 ? day : "0" + day
hour = hour >= 10 ? hour : "0" + hour; hour = hour >= 10 ? hour : "0" + hour
minutes = minutes >= 10 ? minutes : "0" + minutes; minutes = minutes >= 10 ? minutes : "0" + minutes
seconds = seconds >= 10 ? seconds : "0" + seconds; seconds = seconds >= 10 ? seconds : "0" + seconds
this.day = day; this.day = day
this.hour = hour; this.hour = hour
this.minutes = minutes; this.minutes = minutes
this.seconds = seconds; this.seconds = seconds
}, },
// //
startCount() { startCount() {
clearInterval(this.counterTimer) clearInterval(this.counterTimer)
this.countVal = this.countVal ? this.countVal : 0
this.counterTimer = setInterval(() => { this.counterTimer = setInterval(() => {
this.counterFn(this.countVal++) this.counter(this.projectPermissions ? this.countVal-- : this.countVal++)
}, 1000) }, 1000)
} }
} }

@ -302,7 +302,7 @@ export default {
this.picSrc = '' this.picSrc = ''
this.$emit('update:codeId', res.codeId) this.$emit('update:codeId', res.codeId)
if(photo){ if(photo){
this.isError = data.retResult this.isError = ''
const text = result.replace(photo, '') const text = result.replace(photo, '')
this.runResult = text this.runResult = text
this.picSrc = photo this.picSrc = photo

@ -4,7 +4,7 @@
<img v-if="$config.isHh" src="../assets/img/logo-hh.png" alt="" class="logo"> <img v-if="$config.isHh" src="../assets/img/logo-hh.png" alt="" class="logo">
<p v-else>{{$config.title}}</p> <p v-else>{{$config.title}}</p>
<div class="bt"> <div class="bt">
<el-button type="primary" @click="back()">退出实验</el-button> <el-button type="primary" @click="back">退出实验</el-button>
</div> </div>
</div> </div>
@ -77,7 +77,7 @@ export default {
if(!this.$refs.mainindex.isSubmit && !this.assessmentId && list.length && list.some(e => e.code)){ if(!this.$refs.mainindex.isSubmit && !this.assessmentId && list.length && list.some(e => e.code)){
const cache = { const cache = {
projectId: this.projectId, projectId: this.projectId,
judgmentId: list[this.curTab].judgmentId judgmentId: list[Number(this.curTab)].judgmentId
} }
localStorage.setItem('codeCache', JSON.stringify(cache)) localStorage.setItem('codeCache', JSON.stringify(cache))
list.map(e => { list.map(e => {
@ -111,8 +111,8 @@ export default {
},1000) },1000)
}, },
// //
recoveryCode(curTab){ recoveryCode(curTab = '0'){
this.curTab = '0' this.curTab = curTab
this.codeKey++ this.codeKey++
}, },
// 退 // 退
@ -128,7 +128,7 @@ export default {
if (this.$config.isBeta) { if (this.$config.isBeta) {
location.href = `http://120.78.198.231/#/station/list` 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(); this.$refs.mainindex.getClearTime();
}, },

Loading…
Cancel
Save